Re: [PATCH v1 08/11] virstorageobj: Introduce VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE flag

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

 



On Fri, May 24, 2019 at 04:35:44PM +0200, Michal Privoznik wrote:
This flag can be used to denote that the definition we're trying
to assign to a pool object is live definition and thus the
inactive definition should be saved into ->newDef.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
src/conf/virstorageobj.c | 19 ++++++++++++++-----
src/conf/virstorageobj.h |  1 +
2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 2b9ad6fc98..bdb167e9e2 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -1508,14 +1508,18 @@ virStoragePoolObjSourceFindDuplicate(virStoragePoolObjListPtr pools,
static void
virStoragePoolObjAssignDef(virStoragePoolObjPtr obj,
                           virStoragePoolDefPtr def,
-                           unsigned int flgs ATTRIBUTE_UNUSED)
+                           unsigned int flags)
{
-    if (!virStoragePoolObjIsActive(obj)) {
-        virStoragePoolDefFree(obj->def);
-        obj->def = def;
-    } else {
+    if (virStoragePoolObjIsActive(obj)) {
        virStoragePoolDefFree(obj->newDef);
        obj->newDef = def;
+    } else {
+        if (!obj->newDef &&
+            flags & VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE)
+            VIR_STEAL_PTR(obj->newDef, obj->def);
+
+        virStoragePoolDefFree(obj->def);
+        obj->def = def;
    }
}

@@ -1529,6 +1533,11 @@ virStoragePoolObjAssignDef(virStoragePoolObjPtr obj,
 * Lookup the @def to see if it already exists in the @pools in order
 * to either update or add if it does not exist.
 *
+ * Use VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE to denote that @def
+ * refers to an active definition and thus any possible inactive
+ * definition found should be saved to ->newDef (in case of
+ * future restore).
+ *
 * If VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE is set in @flags
 * then this will fail if the pool exists and is active.
 *
diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h
index fe62515b50..df699a84c5 100644
--- a/src/conf/virstorageobj.h
+++ b/src/conf/virstorageobj.h
@@ -193,6 +193,7 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn,
                                  virStoragePoolVolumeACLFilter filter);

enum {
+    VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE= (1 << 0),

Missing space before '='.

    VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1),

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature

--
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]

  Powered by Linux