[PATCH 14/15] Using the Ephemeral Flag to prepare for Migration Support.

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

 



---
 src/conf/domain_conf.c    |   24 +++++++++++++++++++-----
 src/qemu/qemu_domain.c    |    6 +++++-
 src/qemu/qemu_domain.h    |    3 ++-
 src/qemu/qemu_driver.c    |    6 +++---
 src/qemu/qemu_hostdev.c   |    6 ++++++
 src/qemu/qemu_migration.c |    4 ++--
 6 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 00624ee..1005265 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12759,7 +12759,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     virCheckFlags(DUMPXML_FLAGS |
                   VIR_DOMAIN_XML_INTERNAL_STATUS |
                   VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
-                  VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES,
+                  VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES |
+                  VIR_DOMAIN_XML_NO_EPHEMERAL_DEVICES,                  
                   -1);
 
     if (!(type = virDomainVirtTypeToString(def->virtType))) {
@@ -13216,10 +13217,22 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         /* If parent.type != NONE, this is just a pointer to the
          * hostdev in a higher-level device (e.g. virDomainNetDef),
          * and will have already been formatted there.
+         * Hostdevs marked as ephemeral are hybrid hostdevs and
+         * should not be formatted.
          */
-        if (def->hostdevs[n]->parent.type == VIR_DOMAIN_DEVICE_NONE &&
-            virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) {
-            goto cleanup;
+        if (def->hostdevs[n]->parent.type == VIR_DOMAIN_DEVICE_NONE) {
+            if ((flags & VIR_DOMAIN_XML_NO_EPHEMERAL_DEVICES) == 0) {
+                if (virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) {
+                    goto cleanup;
+                }
+            }
+            else {
+                if (def->hostdevs[n]->ephemeral == 0) {
+                    if (virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) {
+                        goto cleanup;
+                    }
+                }
+            }
         }
     }
 
@@ -13267,7 +13280,8 @@ virDomainDefFormat(virDomainDefPtr def, unsigned int flags)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
-    virCheckFlags(DUMPXML_FLAGS, NULL);
+    virCheckFlags(DUMPXML_FLAGS | VIR_DOMAIN_XML_NO_EPHEMERAL_DEVICES, 
+                  NULL); 
     if (virDomainDefFormatInternal(def, flags, &buf) < 0)
         return NULL;
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c47890b..447ec24 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1335,12 +1335,16 @@ char *
 qemuDomainDefFormatLive(struct qemud_driver *driver,
                         virDomainDefPtr def,
                         bool inactive,
-                        bool compatible)
+                        bool compatible,
+                        bool ephemeral)
 {
     unsigned int flags = QEMU_DOMAIN_FORMAT_LIVE_FLAGS;
 
     if (inactive)
         flags |= VIR_DOMAIN_XML_INACTIVE;
+    
+    if (ephemeral)
+        flags |= VIR_DOMAIN_XML_NO_EPHEMERAL_DEVICES;
 
     return qemuDomainDefFormatXML(driver, def, flags, compatible);
 }
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index b96087e..8e707a5 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -268,7 +268,8 @@ char *qemuDomainFormatXML(struct qemud_driver *driver,
 char *qemuDomainDefFormatLive(struct qemud_driver *driver,
                               virDomainDefPtr def,
                               bool inactive,
-                              bool compatible);
+                              bool compatible,
+                              bool ephemeral);
 
 void qemuDomainObjTaint(struct qemud_driver *driver,
                         virDomainObjPtr obj,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9bf89bb..e879d6e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2683,9 +2683,9 @@ qemuDomainSaveInternal(struct qemud_driver *driver, virDomainPtr dom,
             virDomainDefFree(def);
             goto endjob;
         }
-        xml = qemuDomainDefFormatLive(driver, def, true, true);
+        xml = qemuDomainDefFormatLive(driver, def, true, true, false);
     } else {
-        xml = qemuDomainDefFormatLive(driver, vm->def, true, true);
+        xml = qemuDomainDefFormatLive(driver, vm->def, true, true, false);
     }
     if (!xml) {
         virReportError(VIR_ERR_OPERATION_FAILED,
@@ -10607,7 +10607,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
     } else {
         /* Easiest way to clone inactive portion of vm->def is via
          * conversion in and back out of xml.  */
-        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, false)) ||
+        if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, false, false)) ||
             !(def->dom = virDomainDefParseString(driver->caps, xml,
                                                  QEMU_EXPECTED_VIRT_TYPES,
                                                  VIR_DOMAIN_XML_INACTIVE)))
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index d2712f4..743d809 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -50,6 +50,8 @@ qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
             continue;
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
+        if (hostdev->ephemeral == 1)
+            continue;
 
         dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
                            hostdev->source.subsys.u.pci.bus,
@@ -92,6 +94,8 @@ qemuGetActivePciHostDeviceList(struct qemud_driver *driver,
             continue;
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
+        if (hostdev->ephemeral == 1)
+            continue;
 
         dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
                            hostdev->source.subsys.u.pci.bus,
@@ -133,6 +137,8 @@ int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
             continue;
         if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
+        if (hostdev->ephemeral == 1)
+            continue;
 
         dev = pciGetDevice(hostdev->source.subsys.u.pci.domain,
                            hostdev->source.subsys.u.pci.bus,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f65c81a..d8aefa0 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1166,9 +1166,9 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
         if (!virDomainDefCheckABIStability(vm->def, def))
             goto cleanup;
 
-        rv = qemuDomainDefFormatLive(driver, def, false, true);
+        rv = qemuDomainDefFormatLive(driver, def, false, true, true);
     } else {
-        rv = qemuDomainDefFormatLive(driver, vm->def, false, true);
+        rv = qemuDomainDefFormatLive(driver, vm->def, false, true, true);
     }
 
 cleanup:
-- 
1.7.4.4


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