This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1045002 If a domain has an <interface type='hostdev'> or an <interface type='network'> 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 <interface type='network'> 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 <interface type='hostdev'> or <interface type='network'>) 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 <interface type='hostdev'> to do the same thing in the case of <interface type='network'> with a hostdev network. This bug has existed since the very first addition of hostdev networks to libvirt (0.10.0). --- 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 0079234..583ea02 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12101,9 +12101,12 @@ virDomainDefParseXML(xmlDocPtr xml, def->nets[def->nnets++] = net; - /* <interface type='hostdev'> must also be in the hostdevs array */ - if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV && - virDomainHostdevInsert(def, &net->data.hostdev.def) < 0) { + /* <interface type='hostdev'> (and <interface type='net'> + * 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.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list