[Libvirt-cim] [PATCH 1/3] Allow adding bridged network for running domain

John Ferlan jferlan at redhat.com
Thu Aug 8 22:16:40 UTC 2013


Test failed with following:

VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL
ERROR   - (1, u"CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging")
ERROR   - Error invoking AddRS: add_net_res
ERROR   - AddResourceSettings call failed
ERROR   - Failed to destroy Virtual Network 'my_network1'
InvokeMethod(AddResourceSettings): CIM_ERR_FAILED: Unable to change (0) device: internal error unable to execute QEMU command 'device_add': Bus 'pci.0' does not support hotplugging
Bug:<00015>

The fix for this was that the domain needed to be created with the "acpi=True"
flag.  This allowed the test to get a bit further, but it then failed with
the following:

VirtualSystemManagementService - 22_addmulti_brg_interface.py: XFAIL
ERROR   - Got 88:aa:bb:cc:ee:ff, exp 88:aa:bb:cc:ee:ff. Got None, exp my_network1.
ERROR   - Error invoking AddRS: add_net_res
ERROR   - Error adding rs for net mac
ERROR   - Failed to destroy Virtual Network 'my_network1'

The issue here is that the created network bridge doesn't have an xml resource
"source network" as 'my_network1', rather that name is assigned to the pool.
A network bridge type object has a resource "source bridge" which correlates
to the 'virt_net' attribute while network type object correlates to the
'net_name' attribute. Since I wasn't sure how a Xen domain would look I
separated the validation comparisons
---
 .../22_addmulti_brg_interface.py                   |  9 +++++++--
 suites/libvirt-cim/lib/XenKvmLib/vsms_util.py      | 23 +++++++++++++++++-----
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py
index 36d1873..0452bf6 100644
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/22_addmulti_brg_interface.py
@@ -63,8 +63,13 @@ def main():
     service = get_vsms_class(options.virt)(options.ip)
     classname = get_typed_class(options.virt, 'VirtualSystemSettingData')
 
-    vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype,
-                                    net_name=default_brg)
+    # Seems ACPI needs to be set for KVM in order for hotplug to work right
+    if options.virt == "KVM":
+        vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype,
+                                        net_name=default_brg, acpi=True)
+    else:
+        vsxml = get_class(options.virt)(test_dom, mac=default_mac, ntype=ntype,
+                                        net_name=default_brg)
     try:
         ret = vsxml.cim_define(options.ip)
         if not ret:
diff --git a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py
index 075c09f..3c3d0fc 100644
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py
@@ -189,9 +189,22 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr):
                               % attr['nmac'])
 
         if virt == "KVM":
-            name = cxml.get_value_xpath(
+            # For KVM bridge types, compare the source bridge
+            if attr['ntype'] == 'bridge':
+                name = cxml.get_value_xpath(
+                           '/domain/devices/interface/source/@bridge[. = "%s"]'
+                           % attr['virt_net'])
+                attr_name = attr['virt_net']
+            # For KVM network types, compare the network name
+            else:
+                name = cxml.get_value_xpath(
                            '/domain/devices/interface/source/@network[. = "%s"]'
                            % attr['net_name'])
+                attr_name = attr['net_name']
+            if mac != attr['nmac'] or name != attr_name:
+                logger.error("MAC: Got %s, exp %s. NAME: Got %s, exp %s.",
+                             mac, attr['nmac'], name, attr['virt_net'])
+                raise Exception('Error adding rs for net mac')
             
         else:
             # For Xen, network interfaces are converted to bridge interfaces.
@@ -202,10 +215,10 @@ def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr):
             if name != None:
                 name = attr['net_name']
 
-        if mac != attr['nmac'] or name != attr['net_name']:
-            logger.error("Got %s, exp %s. Got %s, exp %s.", mac, 
-                         attr['nmac'], name, attr['net_name'])
-            raise Exception('Error adding rs for net mac')
+            if mac != attr['nmac'] or name != attr['net_name']:
+                logger.error("MAC: Got %s, exp %s. NAME: Got %s, exp %s. br %s",
+                             mac, attr['nmac'], name, attr['net_name'], br)
+                raise Exception('Error adding rs for net mac')
 
         logger.info('good status for net_mac')
     except Exception, details:
-- 
1.8.3.1




More information about the Libvirt-cim mailing list