Merge "libvirt: Drop MIN_LIBVIRT_PF_WITH_NO_VFS_CAP_VERSION"

This commit is contained in:
Zuul 2018-09-21 12:59:27 +00:00 committed by Gerrit Code Review
commit 5d2d3d8c0d
2 changed files with 66 additions and 109 deletions

View File

@ -15006,112 +15006,85 @@ class LibvirtConnTestCase(test.NoDBTestCase,
_fake_NodeDevXml[name])) _fake_NodeDevXml[name]))
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
with mock.patch.object(
fakelibvirt.Connection, 'getLibVersion') as mock_lib_version:
mock_lib_version.return_value = (
versionutils.convert_version_to_int(
libvirt_driver.MIN_LIBVIRT_PF_WITH_NO_VFS_CAP_VERSION) - 1)
actualvf = drvr._get_pcidev_info("pci_0000_04_00_3") actualvf = drvr._get_pcidev_info("pci_0000_04_00_3")
expect_vf = { expect_vf = {
"dev_id": "pci_0000_04_00_3", "dev_id": "pci_0000_04_00_3",
"address": "0000:04:00.3", "address": "0000:04:00.3",
"product_id": '1521', "product_id": '1521',
"numa_node": None, "numa_node": None,
"vendor_id": '8086', "vendor_id": '8086',
"label": 'label_8086_1521', "label": 'label_8086_1521',
"dev_type": fields.PciDeviceType.SRIOV_PF, "dev_type": fields.PciDeviceType.SRIOV_PF,
} }
self.assertEqual(expect_vf, actualvf)
self.assertEqual(expect_vf, actualvf) actualvf = drvr._get_pcidev_info("pci_0000_04_10_7")
actualvf = drvr._get_pcidev_info("pci_0000_04_10_7") expect_vf = {
"dev_id": "pci_0000_04_10_7",
"address": "0000:04:10.7",
"product_id": '1520',
"numa_node": None,
"vendor_id": '8086',
"label": 'label_8086_1520',
"dev_type": fields.PciDeviceType.SRIOV_VF,
"parent_addr": '0000:04:00.3',
}
self.assertEqual(expect_vf, actualvf)
with mock.patch.object(pci_utils, 'get_net_name_by_vf_pci_address',
return_value="net_enp2s2_02_9a_a1_37_be_54"):
actualvf = drvr._get_pcidev_info("pci_0000_04_11_7")
expect_vf = { expect_vf = {
"dev_id": "pci_0000_04_10_7", "dev_id": "pci_0000_04_11_7",
"address": "0000:04:10.7", "address": "0000:04:11.7",
"product_id": '1520', "product_id": '1520',
"numa_node": None,
"vendor_id": '8086', "vendor_id": '8086',
"numa_node": 0,
"label": 'label_8086_1520', "label": 'label_8086_1520',
"dev_type": fields.PciDeviceType.SRIOV_VF, "dev_type": fields.PciDeviceType.SRIOV_VF,
"parent_addr": '0000:04:00.3', "parent_addr": '0000:04:00.3',
"capabilities": {
"network": ["rx", "tx", "sg", "tso", "gso", "gro",
"rxvlan", "txvlan"]},
} }
self.assertEqual(expect_vf, actualvf) self.assertEqual(expect_vf, actualvf)
with mock.patch.object(pci_utils, 'get_net_name_by_vf_pci_address', actualvf = drvr._get_pcidev_info("pci_0000_04_00_1")
return_value="net_enp2s2_02_9a_a1_37_be_54"): expect_vf = {
actualvf = drvr._get_pcidev_info("pci_0000_04_11_7") "dev_id": "pci_0000_04_00_1",
expect_vf = { "address": "0000:04:00.1",
"dev_id": "pci_0000_04_11_7", "product_id": '1013',
"address": "0000:04:11.7", "numa_node": 0,
"product_id": '1520', "vendor_id": '15b3',
"vendor_id": '8086', "label": 'label_15b3_1013',
"numa_node": 0, "dev_type": fields.PciDeviceType.STANDARD,
"label": 'label_8086_1520', }
"dev_type": fields.PciDeviceType.SRIOV_VF, self.assertEqual(expect_vf, actualvf)
"parent_addr": '0000:04:00.3',
"capabilities": {
"network": ["rx", "tx", "sg", "tso", "gso", "gro",
"rxvlan", "txvlan"]},
}
self.assertEqual(expect_vf, actualvf)
with mock.patch.object( actualvf = drvr._get_pcidev_info("pci_0000_03_00_0")
pci_utils, 'is_physical_function', return_value=True): expect_vf = {
actualvf = drvr._get_pcidev_info("pci_0000_04_00_1") "dev_id": "pci_0000_03_00_0",
expect_vf = { "address": "0000:03:00.0",
"dev_id": "pci_0000_04_00_1", "product_id": '1013',
"address": "0000:04:00.1", "numa_node": 0,
"product_id": '1013', "vendor_id": '15b3',
"numa_node": 0, "label": 'label_15b3_1013',
"vendor_id": '15b3', "dev_type": fields.PciDeviceType.SRIOV_PF,
"label": 'label_15b3_1013', }
"dev_type": fields.PciDeviceType.SRIOV_PF, self.assertEqual(expect_vf, actualvf)
}
self.assertEqual(expect_vf, actualvf)
with mock.patch.object( actualvf = drvr._get_pcidev_info("pci_0000_03_00_1")
pci_utils, 'is_physical_function', return_value=False): expect_vf = {
actualvf = drvr._get_pcidev_info("pci_0000_04_00_1") "dev_id": "pci_0000_03_00_1",
expect_vf = { "address": "0000:03:00.1",
"dev_id": "pci_0000_04_00_1", "product_id": '1013',
"address": "0000:04:00.1", "numa_node": 0,
"product_id": '1013', "vendor_id": '15b3',
"numa_node": 0, "label": 'label_15b3_1013',
"vendor_id": '15b3', "dev_type": fields.PciDeviceType.SRIOV_PF,
"label": 'label_15b3_1013', }
"dev_type": fields.PciDeviceType.STANDARD, self.assertEqual(expect_vf, actualvf)
}
self.assertEqual(expect_vf, actualvf)
with mock.patch.object(
fakelibvirt.Connection, 'getLibVersion') as mock_lib_version:
mock_lib_version.return_value = (
versionutils.convert_version_to_int(
libvirt_driver.MIN_LIBVIRT_PF_WITH_NO_VFS_CAP_VERSION))
actualvf = drvr._get_pcidev_info("pci_0000_03_00_0")
expect_vf = {
"dev_id": "pci_0000_03_00_0",
"address": "0000:03:00.0",
"product_id": '1013',
"numa_node": 0,
"vendor_id": '15b3',
"label": 'label_15b3_1013',
"dev_type": fields.PciDeviceType.SRIOV_PF,
}
self.assertEqual(expect_vf, actualvf)
actualvf = drvr._get_pcidev_info("pci_0000_03_00_1")
expect_vf = {
"dev_id": "pci_0000_03_00_1",
"address": "0000:03:00.1",
"product_id": '1013',
"numa_node": 0,
"vendor_id": '15b3',
"label": 'label_15b3_1013',
"dev_type": fields.PciDeviceType.SRIOV_PF,
}
self.assertEqual(expect_vf, actualvf)
def test_list_devices_not_supported(self): def test_list_devices_not_supported(self):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)

View File

@ -237,11 +237,6 @@ MIN_VIRTUOZZO_VERSION = (7, 0, 0)
# Ability to set the user guest password with parallels # Ability to set the user guest password with parallels
MIN_LIBVIRT_PARALLELS_SET_ADMIN_PASSWD = (2, 0, 0) MIN_LIBVIRT_PARALLELS_SET_ADMIN_PASSWD = (2, 0, 0)
# libvirt < 1.3 reported virt_functions capability
# only when VFs are enabled.
# libvirt 1.3 fix f391889f4e942e22b9ef8ecca492de05106ce41e
MIN_LIBVIRT_PF_WITH_NO_VFS_CAP_VERSION = (1, 3, 0)
# Use the "logd" backend for handling stdout/stderr from QEMU processes. # Use the "logd" backend for handling stdout/stderr from QEMU processes.
MIN_LIBVIRT_VIRTLOGD = (1, 3, 3) MIN_LIBVIRT_VIRTLOGD = (1, 3, 3)
MIN_QEMU_VIRTLOGD = (2, 7, 0) MIN_QEMU_VIRTLOGD = (2, 7, 0)
@ -5887,17 +5882,6 @@ class LibvirtDriver(driver.ComputeDriver):
'parent_addr': phys_address, 'parent_addr': phys_address,
} }
# Note(moshele): libvirt < 1.3 reported virt_functions capability
# only when VFs are enabled. The check below is a workaround
# to get the correct report regardless of whether or not any
# VFs are enabled for the device.
if not self._host.has_min_version(
MIN_LIBVIRT_PF_WITH_NO_VFS_CAP_VERSION):
is_physical_function = pci_utils.is_physical_function(
*pci_utils.get_pci_address_fields(pci_address))
if is_physical_function:
return {'dev_type': fields.PciDeviceType.SRIOV_PF}
return {'dev_type': fields.PciDeviceType.STANDARD} return {'dev_type': fields.PciDeviceType.STANDARD}
def _get_device_capabilities(device, address): def _get_device_capabilities(device, address):