render / rpms / libvirt

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