The ephemeral flag is checked along with the hostdev parent type before freeing a hostdev. Additionally Hostdev-Hybrid mode supports live migration with PCI Passthrough. Ephemeral flag plays a very important role in the upcoming migration suppot patch. --- include/libvirt/libvirt.h.in | 1 + src/conf/domain_conf.c | 6 +++++- src/conf/domain_conf.h | 1 + src/qemu/qemu_hotplug.c | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index d21d029..6c68fdd 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1631,6 +1631,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 361850a..00624ee 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1544,7 +1544,9 @@ void virDomainDefFree(virDomainDefPtr def) * to virDomainHostdevDefFree(). */ for (i = 0 ; i < def->nhostdevs ; i++) - virDomainHostdevDefFree(def->hostdevs[i]); + if (def->hostdevs[i]->ephemeral == 0) { + virDomainHostdevDefFree(def->hostdevs[i]); + } VIR_FREE(def->hostdevs); for (i = 0 ; i < def->nleases ; i++) @@ -4402,6 +4404,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, virReportOOMError(); goto error; } + hostdev->ephemeral = 1; /* The helper function expects type to already be found and * passed in as a string, since it is in a different place in * NetDef vs HostdevDef. @@ -4795,6 +4798,7 @@ virDomainNetDefParseXML(virCapsPtr caps, virReportOOMError(); goto error; } + hostdev->ephemeral = 1; addrtype = virXPathString("string(./source/address/@type)", ctxt); /* if not explicitly stated, source/vendor implies usb device */ if (!addrtype && virXPathNode("./source/vendor", ctxt) && diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4584671..f88363a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -371,6 +371,7 @@ struct _virDomainHostdevDef { virDomainDeviceDef actualParent; /*used only in the case of hybrid hostdev*/ int mode; /* enum virDomainHostdevMode */ unsigned int managed : 1; + unsigned int ephemeral: 1; union { virDomainHostdevSubsys subsys; struct { diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1822289..0fd506e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2107,7 +2107,8 @@ int qemuDomainDetachThisHostDevice(struct qemud_driver *driver, VIR_WARN("Failed to restore host device labelling"); } virDomainHostdevRemove(vm->def, idx); - virDomainHostdevDefFree(detach); + if (detach->ephemeral == 0) + virDomainHostdevDefFree(detach); } return ret; } -- 1.7.4.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list