--- include/libvirt/libvirt.h.in | 1 + 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 ++-- 7 files changed, 38 insertions(+), 12 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index deb35ec..8e7a85d 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1651,6 +1651,7 @@ typedef enum { VIR_DOMAIN_XML_SECURE = (1 << 0), /* dump security sensitive information too */ VIR_DOMAIN_XML_INACTIVE = (1 << 1), /* dump inactive domain information */ VIR_DOMAIN_XML_UPDATE_CPU = (1 << 2), /* update guest CPU requirements according to host CPU */ + VIR_DOMAIN_XML_NO_EPHEMERAL_DEVICES = (1 << 24), /* Do not include ephemeral devices */ } virDomainXMLFlags; char * virDomainGetXMLDesc (virDomainPtr domain, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 52c00db..5e2b224 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13174,7 +13174,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))) { @@ -13675,10 +13676,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; + } + } + } } } @@ -13727,7 +13740,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 0ae30b7..a05e0dd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1335,13 +1335,17 @@ 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 dff53cf..82c5f8d 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -269,7 +269,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 8e8e00c..3b18e80 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2748,9 +2748,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, @@ -11218,7 +11218,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 4851e11..877f99f 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 1b21ef6..4a51e11 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