[PATCH 02/10] 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 f57f956503..5fdcddfa91 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3320,7 +3320,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;
@@ -27891,7 +27891,7 @@ virDomainDefCopy(virDomainDefPtr src,
                  virCapsPtr caps,
                  virDomainXMLOptionPtr xmlopt,
                  void *parseOpaque,
-                 bool migratable)
+                 unsigned int flags)
 {
     char *xml;
     virDomainDefPtr ret;
@@ -27899,7 +27899,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.  */
@@ -27920,7 +27920,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 89a7131fdb..4ca22d3617 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2862,11 +2862,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 e76740247d..c58a9c7d72 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -1443,8 +1443,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 100304fd05..6568054d7d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6182,6 +6182,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;
@@ -6189,8 +6191,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 5c31dfdd58..3fede93687 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15849,7 +15849,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;
     }
@@ -20468,7 +20469,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 856869c9d3..f16bcf75de 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -6467,7 +6467,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
                                           privconn->caps,
                                           privconn->xmlopt,
                                           NULL,
-                                          true)))
+                                          VIR_DOMAIN_DEF_COPY_MIGRATABLE)))
             goto cleanup;
 
         if (testDomainSnapshotAlignDisks(vm, def, flags) < 0)
@@ -6722,7 +6722,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