[libvirt] Filter hypervisor_type by virt_type
ComputeNode.supported_hv_specs field has hypervisor_type infomation about which type (e.g. KVM or both KVM and QEMU) of guests are supported by the hypervisor, but it doesn't supply information about which virt_type is set to that compute node. This means that we have no way to know which type of guests are going to be built in that compute node from the ComputeNode object. This can cause wrong behavior in scheduler filters using the supported_hv_specs object, such as ImagePropertiesFilter. In libvirt driver, this patch adds a filter to exclude supported hypervisor_types other than the virt_type which has been set by operator via nova.conf. Partial-Bug: #1195361 Change-Id: I986fe09f97e4d5cad940bea85a87c58606314dba
This commit is contained in:
parent
91f7a99998
commit
eaa766ee20
|
@ -14275,7 +14275,8 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
self.assertEqual(6, drvr._get_vcpu_used())
|
||||
mock_list.assert_called_with(only_guests=True, only_running=True)
|
||||
|
||||
def test_get_instance_capabilities(self):
|
||||
def _test_get_instance_capabilities(self, want):
|
||||
'''Base test for 'get_capabilities' function. '''
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
|
||||
def get_host_capabilities_stub(self):
|
||||
|
@ -14298,12 +14299,28 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
self.stubs.Set(host.Host, "get_capabilities",
|
||||
get_host_capabilities_stub)
|
||||
|
||||
want = [(fields.Architecture.X86_64, 'kvm', 'hvm'),
|
||||
(fields.Architecture.X86_64, 'qemu', 'hvm'),
|
||||
(fields.Architecture.I686, 'kvm', 'hvm')]
|
||||
got = drvr._get_instance_capabilities()
|
||||
self.assertEqual(want, got)
|
||||
|
||||
def test_get_instance_capabilities_kvm(self):
|
||||
self.flags(virt_type='kvm', group='libvirt')
|
||||
|
||||
# Because virt_type is set to kvm, we get only
|
||||
# capabilities where the hypervisor_type is kvm
|
||||
want = [(fields.Architecture.X86_64, 'kvm', 'hvm'),
|
||||
(fields.Architecture.I686, 'kvm', 'hvm')]
|
||||
|
||||
self._test_get_instance_capabilities(want)
|
||||
|
||||
def test_get_instance_capabilities_qemu(self):
|
||||
self.flags(virt_type='qemu', group='libvirt')
|
||||
|
||||
# Because virt_type is set to qemu, we get only
|
||||
# capabilities where the hypervisor_type is qemu
|
||||
want = [(fields.Architecture.X86_64, 'qemu', 'hvm')]
|
||||
|
||||
self._test_get_instance_capabilities(want)
|
||||
|
||||
def test_set_cache_mode(self):
|
||||
self.flags(disk_cachemodes=['file=directsync'], group='libvirt')
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
|
|
|
@ -5520,12 +5520,17 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
hypervisor is capable of hosting. Each tuple consists
|
||||
of the triplet (arch, hypervisor_type, vm_mode).
|
||||
|
||||
Supported hypervisor_type is filtered by virt_type,
|
||||
a parameter set by operators via `nova.conf`.
|
||||
|
||||
:returns: List of tuples describing instance capabilities
|
||||
"""
|
||||
caps = self._host.get_capabilities()
|
||||
instance_caps = list()
|
||||
for g in caps.guests:
|
||||
for dt in g.domtype:
|
||||
if dt != CONF.libvirt.virt_type:
|
||||
continue
|
||||
instance_cap = (
|
||||
fields.Architecture.canonicalize(g.arch),
|
||||
fields.HVType.canonicalize(dt),
|
||||
|
|
Loading…
Reference in New Issue