unify libvirt driver checks for qemu
There are multiple features that are only available with qemu. It makes no sense to have a separate constant for each feature when they're all looking for the same thing. There is currently no list of libvirt hypervisor drivers, so we start such a list. This is not intended to be exhaustive, but rather only for those drivers that need special handling. Change-Id: I3b9546debb3c5bdca13926005a7664c701c6fb9a
This commit is contained in:
parent
1c292f3337
commit
dde011cbcc
|
@ -1389,7 +1389,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
libvirt_driver.MIN_LIBVIRT_NUMA_VERSION) - 1,
|
||||
utils.convert_version_to_int(
|
||||
libvirt_driver.MIN_QEMU_NUMA_HUGEPAGE_VERSION),
|
||||
libvirt_driver.REQ_HYPERVISOR_NUMA_HUGEPAGE,
|
||||
host.HV_DRIVER_QEMU,
|
||||
arch.X86_64,
|
||||
exception.NUMATopologyUnsupported,
|
||||
None)
|
||||
|
@ -1402,7 +1402,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
libvirt_driver.MIN_LIBVIRT_NUMA_VERSION),
|
||||
utils.convert_version_to_int(
|
||||
libvirt_driver.MIN_QEMU_NUMA_HUGEPAGE_VERSION) - 1,
|
||||
libvirt_driver.REQ_HYPERVISOR_NUMA_HUGEPAGE,
|
||||
host.HV_DRIVER_QEMU,
|
||||
arch.X86_64,
|
||||
exception.NUMATopologyUnsupported,
|
||||
None)
|
||||
|
@ -1415,7 +1415,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
libvirt_driver.MIN_LIBVIRT_NUMA_VERSION),
|
||||
utils.convert_version_to_int(
|
||||
libvirt_driver.MIN_QEMU_NUMA_HUGEPAGE_VERSION),
|
||||
libvirt_driver.REQ_HYPERVISOR_NUMA_HUGEPAGE,
|
||||
host.HV_DRIVER_QEMU,
|
||||
arch.PPC64,
|
||||
exception.NUMATopologyUnsupported,
|
||||
None)
|
||||
|
@ -1440,7 +1440,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
libvirt_driver.MIN_LIBVIRT_HUGEPAGE_VERSION) - 1,
|
||||
utils.convert_version_to_int(
|
||||
libvirt_driver.MIN_QEMU_NUMA_HUGEPAGE_VERSION),
|
||||
libvirt_driver.REQ_HYPERVISOR_NUMA_HUGEPAGE,
|
||||
host.HV_DRIVER_QEMU,
|
||||
arch.X86_64,
|
||||
exception.MemoryPagesUnsupported,
|
||||
2048)
|
||||
|
@ -1453,7 +1453,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
libvirt_driver.MIN_LIBVIRT_HUGEPAGE_VERSION),
|
||||
utils.convert_version_to_int(
|
||||
libvirt_driver.MIN_QEMU_NUMA_HUGEPAGE_VERSION) - 1,
|
||||
libvirt_driver.REQ_HYPERVISOR_NUMA_HUGEPAGE,
|
||||
host.HV_DRIVER_QEMU,
|
||||
arch.X86_64,
|
||||
exception.NUMATopologyUnsupported,
|
||||
2048)
|
||||
|
@ -8972,7 +8972,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
libvirt_driver.MIN_LIBVIRT_HUGEPAGE_VERSION) - 1
|
||||
mock_version.return_value = utils.convert_version_to_int(
|
||||
libvirt_driver.MIN_QEMU_NUMA_HUGEPAGE_VERSION)
|
||||
mock_type.return_value = libvirt_driver.REQ_HYPERVISOR_NUMA_HUGEPAGE
|
||||
mock_type.return_value = host.HV_DRIVER_QEMU
|
||||
self._test_get_host_numa_topology(mempages=False)
|
||||
|
||||
def test_get_host_numa_topology_empty(self):
|
||||
|
@ -9003,7 +9003,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
libvirt_driver.MIN_LIBVIRT_NUMA_VERSION) - 1
|
||||
mock_version.return_value = utils.convert_version_to_int(
|
||||
libvirt_driver.MIN_QEMU_NUMA_HUGEPAGE_VERSION)
|
||||
mock_type.return_value = libvirt_driver.REQ_HYPERVISOR_NUMA_HUGEPAGE
|
||||
mock_type.return_value = host.HV_DRIVER_QEMU
|
||||
self.assertIsNone(drvr._get_host_numa_topology())
|
||||
|
||||
@mock.patch.object(fakelibvirt.Connection, 'getType')
|
||||
|
@ -9018,7 +9018,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
libvirt_driver.MIN_LIBVIRT_NUMA_VERSION)
|
||||
mock_version.return_value = utils.convert_version_to_int(
|
||||
libvirt_driver.MIN_QEMU_NUMA_HUGEPAGE_VERSION)
|
||||
mock_type.return_value = 'xen'
|
||||
mock_type.return_value = host.HV_DRIVER_XEN
|
||||
self.assertIsNone(drvr._get_host_numa_topology())
|
||||
|
||||
def test_diagnostic_vcpus_exception(self):
|
||||
|
|
|
@ -335,7 +335,6 @@ MIN_LIBVIRT_VERSION = (0, 9, 11)
|
|||
# delete it & corresponding code using it
|
||||
MIN_LIBVIRT_DEVICE_CALLBACK_VERSION = (1, 1, 1)
|
||||
# Live snapshot requirements
|
||||
REQ_HYPERVISOR_LIVESNAPSHOT = "QEMU"
|
||||
MIN_LIBVIRT_LIVESNAPSHOT_VERSION = (1, 0, 0)
|
||||
MIN_QEMU_LIVESNAPSHOT_VERSION = (1, 3, 0)
|
||||
# block size tuning requirements
|
||||
|
@ -348,7 +347,6 @@ MIN_LIBVIRT_BLOCKCOMMIT_RELATIVE_VERSION = (1, 2, 7)
|
|||
# libvirt discard feature
|
||||
MIN_LIBVIRT_DISCARD_VERSION = (1, 0, 6)
|
||||
MIN_QEMU_DISCARD_VERSION = (1, 6, 0)
|
||||
REQ_HYPERVISOR_DISCARD = "QEMU"
|
||||
# While earlier versions could support NUMA reporting and
|
||||
# NUMA placement, not until 1.2.7 was there the ability
|
||||
# to pin guest nodes to host nodes, so mandate that. Without
|
||||
|
@ -367,7 +365,6 @@ BAD_LIBVIRT_CPU_POLICY_VERSIONS = [(1, 2, 9, 2), (1, 2, 10)]
|
|||
# NUMA nodes, along with the ability to specify hugepage
|
||||
# sizes per guest NUMA node
|
||||
MIN_QEMU_NUMA_HUGEPAGE_VERSION = (2, 1, 0)
|
||||
REQ_HYPERVISOR_NUMA_HUGEPAGE = "QEMU"
|
||||
# fsFreeze/fsThaw requirement
|
||||
MIN_LIBVIRT_FSFREEZE_VERSION = (1, 2, 5)
|
||||
|
||||
|
@ -1326,7 +1323,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
# future.
|
||||
if (self._host.has_min_version(MIN_LIBVIRT_LIVESNAPSHOT_VERSION,
|
||||
MIN_QEMU_LIVESNAPSHOT_VERSION,
|
||||
REQ_HYPERVISOR_LIVESNAPSHOT)
|
||||
host.HV_DRIVER_QEMU)
|
||||
and source_format not in ('lvm', 'rbd')
|
||||
and not CONF.ephemeral_storage_encryption.enabled
|
||||
and not CONF.workarounds.disable_libvirt_livesnapshot):
|
||||
|
@ -3091,7 +3088,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
if CONF.libvirt.hw_disk_discard:
|
||||
if not self._host.has_min_version(MIN_LIBVIRT_DISCARD_VERSION,
|
||||
MIN_QEMU_DISCARD_VERSION,
|
||||
REQ_HYPERVISOR_DISCARD):
|
||||
host.HV_DRIVER_QEMU):
|
||||
msg = (_('Volume sets discard option, but libvirt %(libvirt)s'
|
||||
' or later is required, qemu %(qemu)s'
|
||||
' or later is required.') %
|
||||
|
@ -4703,7 +4700,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
return ((caps.host.cpu.arch in supported_archs) and
|
||||
self._host.has_min_version(MIN_LIBVIRT_NUMA_VERSION,
|
||||
MIN_QEMU_NUMA_HUGEPAGE_VERSION,
|
||||
REQ_HYPERVISOR_NUMA_HUGEPAGE))
|
||||
host.HV_DRIVER_QEMU))
|
||||
|
||||
def _has_hugepage_support(self):
|
||||
# This means that the host can support multiple values for the size
|
||||
|
@ -4713,7 +4710,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
return ((caps.host.cpu.arch in supported_archs) and
|
||||
self._host.has_min_version(MIN_LIBVIRT_HUGEPAGE_VERSION,
|
||||
MIN_QEMU_NUMA_HUGEPAGE_VERSION,
|
||||
REQ_HYPERVISOR_NUMA_HUGEPAGE))
|
||||
host.HV_DRIVER_QEMU))
|
||||
|
||||
def _get_host_numa_topology(self):
|
||||
if not self._has_numa_support():
|
||||
|
|
|
@ -69,6 +69,12 @@ CONF.import_opt('host', 'nova.netconf')
|
|||
CONF.import_opt('my_ip', 'nova.netconf')
|
||||
|
||||
|
||||
# This list is for libvirt hypervisor drivers that need special handling.
|
||||
# This is *not* the complete list of supported hypervisor drivers.
|
||||
HV_DRIVER_QEMU = "QEMU"
|
||||
HV_DRIVER_XEN = "Xen"
|
||||
|
||||
|
||||
class DomainJobInfo(object):
|
||||
"""Information about libvirt background jobs
|
||||
|
||||
|
@ -549,6 +555,10 @@ class Host(object):
|
|||
|
||||
def _version_check(self, lv_ver=None, hv_ver=None, hv_type=None,
|
||||
op=operator.lt):
|
||||
"""Check libvirt version, hypervisor version, and hypervisor type
|
||||
|
||||
:param hv_type: hypervisor driver from the top of this file.
|
||||
"""
|
||||
conn = self.get_connection()
|
||||
try:
|
||||
if lv_ver is not None:
|
||||
|
|
Loading…
Reference in New Issue