[PATCH v2 02/11] conf: Modify last arg to virDomainDefCopy

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

 



Rather than single boolean, let's create a virDomainDefCopyFlags
and have the last argument be an unsigned int using the new
VIR_DOMAIN_DEF_COPY_MIGRATABLE bit.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 8 ++++----
 src/conf/domain_conf.h   | 6 +++++-
 src/libxl/libxl_domain.c | 4 ++--
 src/qemu/qemu_domain.c   | 5 +++--
 src/qemu/qemu_driver.c   | 5 +++--
 src/test/test_driver.c   | 5 +++--
 6 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dacf888565..1411034e7c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3315,7 +3315,7 @@ virDomainObjSetDefTransient(virCapsPtr caps,
     if (domain->newDef)
         return 0;
 
-    if (!(domain->newDef = virDomainDefCopy(domain->def, caps, xmlopt, NULL, false)))
+    if (!(domain->newDef = virDomainDefCopy(domain->def, caps, xmlopt, NULL, 0)))
         goto out;
 
     ret = 0;
@@ -27892,7 +27892,7 @@ virDomainDefCopy(virDomainDefPtr src,
                  virCapsPtr caps,
                  virDomainXMLOptionPtr xmlopt,
                  void *parseOpaque,
-                 bool migratable)
+                 unsigned int flags)
 {
     char *xml;
     virDomainDefPtr ret;
@@ -27900,7 +27900,7 @@ virDomainDefCopy(virDomainDefPtr src,
     unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
                                VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
 
-    if (migratable)
+    if (flags & VIR_DOMAIN_DEF_COPY_MIGRATABLE)
         format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_MIGRATABLE;
 
     /* Easiest to clone via a round-trip through XML.  */
@@ -27921,7 +27921,7 @@ virDomainObjCopyPersistentDef(virDomainObjPtr dom,
     virDomainDefPtr cur;
 
     cur = virDomainObjGetPersistentDef(caps, xmlopt, dom);
-    return virDomainDefCopy(cur, caps, xmlopt, NULL, false);
+    return virDomainDefCopy(cur, caps, xmlopt, NULL, 0);
 }
 
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3c7eccb8ca..99d1aa529a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2867,11 +2867,15 @@ virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                            bool *state);
 virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
 
+typedef enum {
+    /* Set when creating a copy of a definition for the purpose of migration */
+    VIR_DOMAIN_DEF_COPY_MIGRATABLE = 1 << 0,
+} virDomainDefCopyFlags;
 virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                  virCapsPtr caps,
                                  virDomainXMLOptionPtr xmlopt,
                                  void *parseOpaque,
-                                 bool migratable);
+                                 unsigned int flags);
 virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                               virCapsPtr caps,
                                               virDomainXMLOptionPtr xmlopt);
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index d4859d6707..126d08b499 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -1450,8 +1450,8 @@ libxlDomainDefCheckABIStability(libxlDriverPrivatePtr driver,
     libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
     bool ret = false;
 
-    if (!(migratableDefSrc = virDomainDefCopy(src, cfg->caps, driver->xmlopt, NULL, true)) ||
-        !(migratableDefDst = virDomainDefCopy(dst, cfg->caps, driver->xmlopt, NULL, true)))
+    if (!(migratableDefSrc = virDomainDefCopy(src, cfg->caps, driver->xmlopt, NULL, VIR_DOMAIN_DEF_COPY_MIGRATABLE)) ||
+        !(migratableDefDst = virDomainDefCopy(dst, cfg->caps, driver->xmlopt, NULL, VIR_DOMAIN_DEF_COPY_MIGRATABLE)))
         goto cleanup;
 
     ret = virDomainDefCheckABIStability(migratableDefSrc,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 326c939c85..ed7bd0230e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6198,6 +6198,8 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
     virDomainDefPtr copy = NULL;
     virCapsPtr caps = NULL;
     virQEMUCapsPtr qemuCaps = NULL;
+    unsigned int copyFlags = (flags & VIR_DOMAIN_XML_MIGRATABLE) ?
+                             VIR_DOMAIN_DEF_COPY_MIGRATABLE : 0;
 
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;
@@ -6205,8 +6207,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
     if (!(flags & (VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE)))
         goto format;
 
-    if (!(copy = virDomainDefCopy(def, caps, driver->xmlopt, NULL,
-                                  flags & VIR_DOMAIN_XML_MIGRATABLE)))
+    if (!(copy = virDomainDefCopy(def, caps, driver->xmlopt, NULL, copyFlags)))
         goto cleanup;
 
     def = copy;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7484b00e23..2863508189 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15857,7 +15857,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
     snap->def->current = true;
     if (snap->def->dom) {
         config = virDomainDefCopy(snap->def->dom, caps,
-                                  driver->xmlopt, NULL, true);
+                                  driver->xmlopt, NULL,
+                                  VIR_DOMAIN_DEF_COPY_MIGRATABLE);
         if (!config)
             goto endjob;
     }
@@ -20443,7 +20444,7 @@ qemuDomainGetFSInfo(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto endjob;
 
-    if (!(def = virDomainDefCopy(vm->def, caps, driver->xmlopt, NULL, false)))
+    if (!(def = virDomainDefCopy(vm->def, caps, driver->xmlopt, NULL, 0)))
         goto endjob;
 
     agent = qemuDomainObjEnterAgent(vm);
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index a1888c0c9f..8877a467f6 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -6434,7 +6434,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
                                           privconn->caps,
                                           privconn->xmlopt,
                                           NULL,
-                                          true)))
+                                          VIR_DOMAIN_DEF_COPY_MIGRATABLE)))
             goto cleanup;
 
         if (testDomainSnapshotAlignDisks(vm, def, flags) < 0)
@@ -6689,7 +6689,8 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
 
     snap->def->current = true;
     config = virDomainDefCopy(snap->def->dom, privconn->caps,
-                              privconn->xmlopt, NULL, true);
+                              privconn->xmlopt, NULL,
+                              VIR_DOMAIN_DEF_COPY_MIGRATABLE);
     if (!config)
         goto cleanup;
 
-- 
2.13.6

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