]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virstorageobj: Introduce VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE flag
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 24 May 2019 14:35:44 +0000 (16:35 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Aug 2019 15:09:05 +0000 (17:09 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/virstorageobj.c
src/conf/virstorageobj.h

index 08441fcf4bf870084c2559ed7cd777a094c04b57..4af8f5eb0ab6c3202907eb308284c979f8f38dd1 100644 (file)
@@ -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.
  *
index ef4a6bf4087570dc187f52447a32a18cae5a89f1..0af4b2c8218d2660808c2ee0fde008731085d531 100644 (file)
@@ -195,6 +195,7 @@ virStoragePoolObjVolumeListExport(virConnectPtr conn,
                                   virStoragePoolVolumeACLFilter filter);
 
 typedef enum {
+    VIR_STORAGE_POOL_OBJ_LIST_ADD_LIVE = (1 << 0),
     VIR_STORAGE_POOL_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1),
 } virStoragePoolObjListFlags;