From c5e551b03bef744fc1302ccb9fc9e38189cdfb7c Mon Sep 17 00:00:00 2001 Message-Id: From: Laine Stump Date: Tue, 24 Dec 2013 04:24:04 -0700 Subject: [PATCH] qemu: re-add hostdev interfaces to hostdev array on libvirtd restart This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1045002 If a domain has an or an where the network itself is a pool of hostdev devices, then libvirt will internally keep that device on both the interface list *and* the hostdev list for the domain. One of the places this comes in handy is when a new device is being added and libvirt wants to find a unique "alias" name for it - it just scans through the hostdev array and makes sure it picks a name that doesn't match the alias of any device in that array. However, when libvirtd was restarted, if there was an with the network being a hostdev pool, the device would not be added to the reconstructed internal hostdev array, so its alias would not be found during a scan of the hostdev array, thus attempts to add a new hostdev (or or ) would result in a message like this: internal error: unable to execute QEMU command 'device_add': Duplicate ID 'hostdev0' for device This patch simply fixes the existing code in the domain XML parser that fixes up the hostdev array in the case of to do the same thing in the case of with a hostdev network. This bug has existed since the very first addition of hostdev networks to libvirt (0.10.0). (cherry picked from commit 8700b87800b0671963de271a480aa3e0dd333897) Signed-off-by: Jiri Denemark --- src/conf/domain_conf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9cf5432..656fa93 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11917,9 +11917,12 @@ virDomainDefParseXML(xmlDocPtr xml, def->nets[def->nnets++] = net; - /* must also be in the hostdevs array */ - if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV && - virDomainHostdevInsert(def, &net->data.hostdev.def) < 0) { + /* (and + * where the actual network type is already known to be + * hostdev) must also be in the hostdevs array. + */ + if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV && + virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net)) < 0) { goto error; } } -- 1.8.5.2