[libvirt] [PATCH v6 03/13] virstoragefile: Add virStorageSourceSetBackingStore

Peter Krempa pkrempa at redhat.com
Mon Nov 2 07:23:57 UTC 2015


On Thu, Oct 29, 2015 at 14:43:10 +0100, Matthias Gatto wrote:
> As explained for virStorageSourceGetBackingStore, quorum allows
> multiple backing store, this make the operation to set bs complex
> because we have to check if the backingStore is used as an array
> or a pointer, and set it differently in both case.
> 
> In order to help the manipulation of backing store, I've added a
> function virStorageSourceSetBackingStore.
> 
> For now virStorageSourceSetBackingStore don't handle the case where
> we have more than one backing store in virStorageSource.
> 
> Signed-off-by: Matthias Gatto <matthias.gatto at outscale.com>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/libvirt_private.syms  |  1 +
>  src/util/virstoragefile.c | 10 ++++++++++
>  src/util/virstoragefile.h |  4 ++++
>  3 files changed, 15 insertions(+)
> 


> diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
> index cb8e248..731e0c3 100644
> --- a/src/util/virstoragefile.c
> +++ b/src/util/virstoragefile.c
> @@ -1817,6 +1817,16 @@ virStorageSourceGetBackingStore(const virStorageSource *src,
>  }
>  
>  
> +bool
> +virStorageSourceSetBackingStore(virStorageSourcePtr src,
> +                                virStorageSourcePtr backingStore,
> +                                size_t pos ATTRIBUTE_UNUSED)
> +{

Again, this needs to do bounds checking once you are passing the size
in.

> +    src->backingStore = backingStore;
> +    return !!src->backingStore;

This return value is rather unhelpful. If this function is going to
reallocate the array, please use the -1/0 return values as usual.
Otherwise this function might as well be declared as void, since the
caller knows whether 'backingStore' was passed in or not.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20151102/f377274e/attachment-0001.sig>


More information about the libvir-list mailing list