[libvirt] [PATCH v8 2/5] virstoragefile: Add helper to set storage source backingStore

John Ferlan jferlan at redhat.com
Tue Dec 15 23:14:09 UTC 2015


From: Matthias Gatto <matthias.gatto at outscale.com>

Add a new helper - virStorageSourceSetBackingStore - to set the storage
source backingStore pointer in order to make it easier to change the
future format of the data.

A future patch will adjust the backingStore pointer to become a table or
array of backingStorePtr's accessible by the argument 'pos'.

For now, if 'pos' > 0, the code will return NULL as if the backingStore
pointer couldn't be set.  All callers in subsequent patches will start by
passing a 0 as the parameter.

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 | 26 ++++++++++++++++++++++++++
 src/util/virstoragefile.h |  4 ++++
 3 files changed, 31 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1c55370..509fbae 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2206,6 +2206,7 @@ virStorageSourceParseRBDColonString;
 virStorageSourcePoolDefFree;
 virStorageSourcePoolModeTypeFromString;
 virStorageSourcePoolModeTypeToString;
+virStorageSourceSetBackingStore;
 virStorageSourceUpdateBlockPhysicalSize;
 virStorageTypeFromString;
 virStorageTypeToString;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 2771c95..43a7137 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1833,6 +1833,32 @@ virStorageSourceGetBackingStore(const virStorageSource *src,
 
 
 /**
+ * virStorageSourceSetBackingStore:
+ * @src: virStorageSourcePtr to hold @backingStore
+ * @backingStore - Pointer to the backingStore to store
+ * @pos - presently unused
+ *
+ * Set @backingStore in @src at @pos in src->backingStore. For now, pos
+ * is expected to be 0. A future patch will use pos as the position in
+ * the array of storage backingStore pointers
+ *
+ * Returns:
+ * 0 on success, -1 on failure
+ */
+int
+virStorageSourceSetBackingStore(virStorageSourcePtr src,
+                                virStorageSourcePtr backingStore,
+                                size_t pos)
+{
+    if (pos > 0)
+        return -1;
+
+    src->backingStore = backingStore;
+    return 0;
+}
+
+
+/**
  * virStorageSourcePtr:
  *
  * Deep-copies a virStorageSource structure. If @backing chain is true
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 8cd4854..ce1cb5d 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -289,6 +289,10 @@ struct _virStorageSource {
 #  define DEV_BSIZE 512
 # endif
 
+int virStorageSourceSetBackingStore(virStorageSourcePtr src,
+                                    virStorageSourcePtr backingStore,
+                                    size_t pos);
+
 virStorageSourcePtr virStorageSourceGetBackingStore(const virStorageSource *src,
                                                     size_t pos);
 
-- 
2.5.0




More information about the libvir-list mailing list