From 32e9ee7b2a8f095319a806780a93beef0c6cc382 Mon Sep 17 00:00:00 2001 From: Dino Madarang Date: Wed, 27 Dec 2017 15:52:12 -0800 Subject: bugfix: Fix duplicate 'address' in standlone SRIOV * Add unit test per Rodolfo's comment Creating a VM using generted xml file /tmp/vm_sriov_0.xml returns an XML error: missing source address type. This fix modifies generted xml from:
to:
Change-Id: I694153e7468986bacb19ba3e09e761993aad7184 Signed-off-by: Dino Simeon Madarang Reviewed-by: Rodolfo Alonso Hernandez Reviewed-by: Ross Brattain Reviewed-by: Alain Jebara Reviewed-by: Emma Foley --- .../benchmark/contexts/standalone/test_model.py | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'tests/unit/benchmark') diff --git a/tests/unit/benchmark/contexts/standalone/test_model.py b/tests/unit/benchmark/contexts/standalone/test_model.py index 31ec2b7d1..a8c54f193 100644 --- a/tests/unit/benchmark/contexts/standalone/test_model.py +++ b/tests/unit/benchmark/contexts/standalone/test_model.py @@ -134,9 +134,9 @@ class ModelLibvirtTestCase(unittest.TestCase): as mock_parse: xml = copy.deepcopy(self.xml) mock_parse.return_value = xml - vf_pci = '0001:05:04.2' + vm_pci = '0001:05:04.2' model.Libvirt.add_sriov_interfaces( - self.pci_address_str, vf_pci, self.mac, xml_input) + vm_pci, self.pci_address_str, self.mac, xml_input) mock_parse.assert_called_once_with(xml_input) self.mock_write_xml.assert_called_once_with(xml_input) interface = xml.find('devices').find('interface') @@ -145,8 +145,29 @@ class ModelLibvirtTestCase(unittest.TestCase): mac = interface.find('mac') self.assertEqual(self.mac, mac.get('address')) source = interface.find('source') + source_address = source.find('address') self.assertIsNotNone(source.find('address')) - self.assertIsNotNone(interface.find('address')) + + self.assertEqual('pci', source_address.get('type')) + self.assertEqual('0x' + self.pci_address_str.split(':')[0], + source_address.get('domain')) + self.assertEqual('0x' + self.pci_address_str.split(':')[1], + source_address.get('bus')) + self.assertEqual('0x' + self.pci_address_str.split(':')[2].split('.')[0], + source_address.get('slot')) + self.assertEqual('0x' + self.pci_address_str.split(':')[2].split('.')[1], + source_address.get('function')) + + interface_address = interface.find('address') + self.assertEqual('pci', interface_address.get('type')) + self.assertEqual('0x' + vm_pci.split(':')[0], + interface_address.get('domain')) + self.assertEqual('0x' + vm_pci.split(':')[1], + interface_address.get('bus')) + self.assertEqual('0x' + vm_pci.split(':')[2].split('.')[0], + interface_address.get('slot')) + self.assertEqual('0x' + vm_pci.split(':')[2].split('.')[1], + interface_address.get('function')) def test_create_snapshot_qemu(self): result = "/var/lib/libvirt/images/0.qcow2" -- cgit 1.2.3-korg