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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Matthias Gatto <matthias.gatto@xxxxxxxxxxxx>

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@xxxxxxxxxxxx>
Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 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

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]