@@ -741,6 +741,7 @@ def setUp(self):
741
741
imagebackend.Image._get_driver_format)
742
742
743
743
self.libvirt = self.useFixture(nova_fixtures.LibvirtFixture())
744
+ self.cgroups = self.useFixture(nova_fixtures.CGroupsFixture())
744
745
745
746
# ensure tests perform the same on all host architectures; this is
746
747
# 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, _):
2956
2957
'fake-instance-numa-topology',
2957
2958
'fake-flavor', 'fake-image-meta').obj_to_primitive())
2958
2959
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):
2962
2961
self.flags(cpu_shared_set=None, cpu_dedicated_set=None,
2963
2962
group='compute')
2964
2963
instance_ref = objects.Instance(**self.test_instance)
@@ -2995,9 +2994,7 @@ def test_get_guest_config_numa_host_instance_fits(self, is_able):
2995
2994
2996
2995
@mock.patch('nova.privsep.utils.supports_direct_io',
2997
2996
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):
3001
2998
instance_ref = objects.Instance(**self.test_instance)
3002
2999
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
3003
3000
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):
3388
3385
self._test_get_guest_memory_backing_config,
3389
3386
host_topology, inst_topology, numa_tune)
3390
3387
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):
3395
3389
self.flags(cpu_shared_set='3', cpu_dedicated_set=None,
3396
3390
group='compute')
3397
3391
@@ -3440,9 +3434,7 @@ def test_get_guest_config_numa_host_instance_pci_no_numa_info(
3440
3434
3441
3435
@mock.patch('nova.privsep.utils.supports_direct_io',
3442
3436
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):
3446
3438
self.flags(cpu_shared_set='3', cpu_dedicated_set=None,
3447
3439
group='compute')
3448
3440
instance_ref = objects.Instance(**self.test_instance)
@@ -3550,10 +3542,7 @@ def test_get_guest_config_numa_other_arch_qemu(self):
3550
3542
exception.NUMATopologyUnsupported,
3551
3543
None)
3552
3544
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):
3557
3546
self.flags(cpu_shared_set='2-3', cpu_dedicated_set=None,
3558
3547
group='compute')
3559
3548
@@ -3591,9 +3580,7 @@ def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(
3591
3580
self.assertEqual(0, len(cfg.cputune.vcpupin))
3592
3581
self.assertIsNone(cfg.cpu.numa)
3593
3582
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):
3597
3584
instance_topology = objects.InstanceNUMATopology(cells=[
3598
3585
objects.InstanceNUMACell(
3599
3586
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):
3640
3627
self.assertEqual(instance_cell.memory * units.Ki,
3641
3628
numa_cfg_cell.memory)
3642
3629
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):
3646
3631
self.flags(cpu_shared_set='0-5', cpu_dedicated_set=None,
3647
3632
group='compute')
3648
3633
@@ -7035,9 +7020,7 @@ def test_get_guest_config_with_rng_dev_not_present(self, mock_path):
7035
7020
[],
7036
7021
image_meta, disk_info)
7037
7022
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):
7041
7024
self.flags(virt_type='kvm', group='libvirt')
7042
7025
7043
7026
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7055,9 +7038,7 @@ def test_guest_cpu_shares_with_multi_vcpu(self, is_able):
7055
7038
7056
7039
self.assertEqual(4096, cfg.cputune.shares)
7057
7040
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):
7061
7042
self.flags(virt_type='kvm', group='libvirt')
7062
7043
7063
7044
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7393,9 +7374,7 @@ def test_get_guest_config_disk_cachemodes_network(
7393
7374
self.flags(images_type='rbd', group='libvirt')
7394
7375
self._test_get_guest_config_disk_cachemodes('rbd')
7395
7376
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):
7399
7378
self.flags(virt_type='kvm', group='libvirt')
7400
7379
7401
7380
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7413,9 +7392,10 @@ def test_get_guest_config_with_bogus_cpu_quota(self, is_able):
7413
7392
drvr._get_guest_config,
7414
7393
instance_ref, [], image_meta, disk_info)
7415
7394
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
+
7419
7399
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
7420
7400
instance_ref = objects.Instance(**self.test_instance)
7421
7401
instance_ref.flavor.extra_specs = {'quota:cpu_shares': '10000',
@@ -21715,6 +21695,7 @@ def setUp(self):
21715
21695
self.flags(sysinfo_serial="none", group="libvirt")
21716
21696
self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
21717
21697
self.useFixture(nova_fixtures.LibvirtFixture())
21698
+ self.useFixture(nova_fixtures.CGroupsFixture())
21718
21699
os_vif.initialize()
21719
21700
21720
21701
self.drvr = libvirt_driver.LibvirtDriver(
0 commit comments