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

2015-11-01 Thread Peter Krempa
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 
> Signed-off-by: John Ferlan 
> ---
>  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


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

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

2015-10-29 Thread Matthias Gatto
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 
Signed-off-by: John Ferlan 
---
 src/libvirt_private.syms  |  1 +
 src/util/virstoragefile.c | 10 ++
 src/util/virstoragefile.h |  4 
 3 files changed, 15 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8854b26..4aa923a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2173,6 +2173,7 @@ virStorageSourceParseRBDColonString;
 virStorageSourcePoolDefFree;
 virStorageSourcePoolModeTypeFromString;
 virStorageSourcePoolModeTypeToString;
+virStorageSourceSetBackingStore;
 virStorageSourceUpdateBlockPhysicalSize;
 virStorageTypeFromString;
 virStorageTypeToString;
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)
+{
+src->backingStore = backingStore;
+return !!src->backingStore;
+}
+
+
 /**
  * virStorageSourcePtr:
  *
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 8cd4854..5c5c29d 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -289,6 +289,10 @@ struct _virStorageSource {
 #  define DEV_BSIZE 512
 # endif
 
+bool virStorageSourceSetBackingStore(virStorageSourcePtr src,
+ virStorageSourcePtr backingStore,
+ size_t pos);
+
 virStorageSourcePtr virStorageSourceGetBackingStore(const virStorageSource 
*src,
 size_t pos);
 
-- 
2.6.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list