@@ -741,6 +741,7 @@ def setUp(self):
741741 imagebackend.Image._get_driver_format)
742742
743743 self.libvirt = self.useFixture(nova_fixtures.LibvirtFixture())
744+ self.cgroups = self.useFixture(nova_fixtures.CGroupsFixture())
744745
745746 # ensure tests perform the same on all host architectures; this is
746747 # already done by the fakelibvirt fixture but we want to change the
@@ -2956,9 +2957,7 @@ def test_get_live_migrate_numa_info_empty(self, _):
29562957 'fake-instance-numa-topology',
29572958 'fake-flavor', 'fake-image-meta').obj_to_primitive())
29582959
2959- @mock.patch.object(
2960- host.Host, "is_cpu_control_policy_capable", return_value=True)
2961- def test_get_guest_config_numa_host_instance_fits(self, is_able):
2960+ def test_get_guest_config_numa_host_instance_fits(self):
29622961 self.flags(cpu_shared_set=None, cpu_dedicated_set=None,
29632962 group='compute')
29642963 instance_ref = objects.Instance(**self.test_instance)
@@ -2995,9 +2994,7 @@ def test_get_guest_config_numa_host_instance_fits(self, is_able):
29952994
29962995 @mock.patch('nova.privsep.utils.supports_direct_io',
29972996 new=mock.Mock(return_value=True))
2998- @mock.patch.object(
2999- host.Host, "is_cpu_control_policy_capable", return_value=True)
3000- def test_get_guest_config_numa_host_instance_no_fit(self, is_able):
2997+ def test_get_guest_config_numa_host_instance_no_fit(self):
30012998 instance_ref = objects.Instance(**self.test_instance)
30022999 image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
30033000 flavor = objects.Flavor(memory_mb=4096, vcpus=4, root_gb=496,
@@ -3388,10 +3385,7 @@ def test_get_guest_memory_backing_config_file_backed_hugepages(self):
33883385 self._test_get_guest_memory_backing_config,
33893386 host_topology, inst_topology, numa_tune)
33903387
3391- @mock.patch.object(
3392- host.Host, "is_cpu_control_policy_capable", return_value=True)
3393- def test_get_guest_config_numa_host_instance_pci_no_numa_info(
3394- self, is_able):
3388+ def test_get_guest_config_numa_host_instance_pci_no_numa_info(self):
33953389 self.flags(cpu_shared_set='3', cpu_dedicated_set=None,
33963390 group='compute')
33973391
@@ -3440,9 +3434,7 @@ def test_get_guest_config_numa_host_instance_pci_no_numa_info(
34403434
34413435 @mock.patch('nova.privsep.utils.supports_direct_io',
34423436 new=mock.Mock(return_value=True))
3443- @mock.patch.object(
3444- host.Host, "is_cpu_control_policy_capable", return_value=True)
3445- def test_get_guest_config_numa_host_instance_2pci_no_fit(self, is_able):
3437+ def test_get_guest_config_numa_host_instance_2pci_no_fit(self):
34463438 self.flags(cpu_shared_set='3', cpu_dedicated_set=None,
34473439 group='compute')
34483440 instance_ref = objects.Instance(**self.test_instance)
@@ -3550,10 +3542,7 @@ def test_get_guest_config_numa_other_arch_qemu(self):
35503542 exception.NUMATopologyUnsupported,
35513543 None)
35523544
3553- @mock.patch.object(
3554- host.Host, "is_cpu_control_policy_capable", return_value=True)
3555- def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(
3556- self, is_able):
3545+ def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(self):
35573546 self.flags(cpu_shared_set='2-3', cpu_dedicated_set=None,
35583547 group='compute')
35593548
@@ -3591,9 +3580,7 @@ def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(
35913580 self.assertEqual(0, len(cfg.cputune.vcpupin))
35923581 self.assertIsNone(cfg.cpu.numa)
35933582
3594- @mock.patch.object(
3595- host.Host, "is_cpu_control_policy_capable", return_value=True)
3596- def test_get_guest_config_non_numa_host_instance_topo(self, is_able):
3583+ def test_get_guest_config_non_numa_host_instance_topo(self):
35973584 instance_topology = objects.InstanceNUMATopology(cells=[
35983585 objects.InstanceNUMACell(
35993586 id=0, cpuset=set([0]), pcpuset=set(), memory=1024),
@@ -3640,9 +3627,7 @@ def test_get_guest_config_non_numa_host_instance_topo(self, is_able):
36403627 self.assertEqual(instance_cell.memory * units.Ki,
36413628 numa_cfg_cell.memory)
36423629
3643- @mock.patch.object(
3644- host.Host, "is_cpu_control_policy_capable", return_value=True)
3645- def test_get_guest_config_numa_host_instance_topo(self, is_able):
3630+ def test_get_guest_config_numa_host_instance_topo(self):
36463631 self.flags(cpu_shared_set='0-5', cpu_dedicated_set=None,
36473632 group='compute')
36483633
@@ -7035,9 +7020,7 @@ def test_get_guest_config_with_rng_dev_not_present(self, mock_path):
70357020 [],
70367021 image_meta, disk_info)
70377022
7038- @mock.patch.object(
7039- host.Host, "is_cpu_control_policy_capable", return_value=True)
7040- def test_guest_cpu_shares_with_multi_vcpu(self, is_able):
7023+ def test_guest_cpu_shares_with_multi_vcpu(self):
70417024 self.flags(virt_type='kvm', group='libvirt')
70427025
70437026 drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7055,9 +7038,7 @@ def test_guest_cpu_shares_with_multi_vcpu(self, is_able):
70557038
70567039 self.assertEqual(4096, cfg.cputune.shares)
70577040
7058- @mock.patch.object(
7059- host.Host, "is_cpu_control_policy_capable", return_value=True)
7060- def test_get_guest_config_with_cpu_quota(self, is_able):
7041+ def test_get_guest_config_with_cpu_quota(self):
70617042 self.flags(virt_type='kvm', group='libvirt')
70627043
70637044 drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7393,9 +7374,7 @@ def test_get_guest_config_disk_cachemodes_network(
73937374 self.flags(images_type='rbd', group='libvirt')
73947375 self._test_get_guest_config_disk_cachemodes('rbd')
73957376
7396- @mock.patch.object(
7397- host.Host, "is_cpu_control_policy_capable", return_value=True)
7398- def test_get_guest_config_with_bogus_cpu_quota(self, is_able):
7377+ def test_get_guest_config_with_bogus_cpu_quota(self):
73997378 self.flags(virt_type='kvm', group='libvirt')
74007379
74017380 drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7413,9 +7392,10 @@ def test_get_guest_config_with_bogus_cpu_quota(self, is_able):
74137392 drvr._get_guest_config,
74147393 instance_ref, [], image_meta, disk_info)
74157394
7416- @mock.patch.object(
7417- host.Host, "is_cpu_control_policy_capable", return_value=False)
7418- def test_get_update_guest_cputune(self, is_able):
7395+ def test_get_update_guest_cputune(self):
7396+ # No CPU controller on the host
7397+ self.cgroups.version = 0
7398+
74197399 drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
74207400 instance_ref = objects.Instance(**self.test_instance)
74217401 instance_ref.flavor.extra_specs = {'quota:cpu_shares': '10000',
@@ -21662,6 +21642,7 @@ def setUp(self):
2166221642 self.flags(sysinfo_serial="none", group="libvirt")
2166321643 self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
2166421644 self.useFixture(nova_fixtures.LibvirtFixture())
21645+ self.useFixture(nova_fixtures.CGroupsFixture())
2166521646 os_vif.initialize()
2166621647
2166721648 self.drvr = libvirt_driver.LibvirtDriver(
0 commit comments