@@ -740,6 +740,7 @@ def setUp(self):
740
740
imagebackend.Image._get_driver_format)
741
741
742
742
self.libvirt = self.useFixture(nova_fixtures.LibvirtFixture())
743
+ self.cgroups = self.useFixture(nova_fixtures.CGroupsFixture())
743
744
744
745
# ensure tests perform the same on all host architectures; this is
745
746
# already done by the fakelibvirt fixture but we want to change the
@@ -3047,9 +3048,7 @@ def test_get_live_migrate_numa_info_empty(self, _):
3047
3048
'fake-flavor', 'fake-image-meta').obj_to_primitive())
3048
3049
3049
3050
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3050
- @mock.patch.object(
3051
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3052
- def test_get_guest_config_numa_host_instance_fits(self, is_able):
3051
+ def test_get_guest_config_numa_host_instance_fits(self):
3053
3052
self.flags(cpu_shared_set=None, cpu_dedicated_set=None,
3054
3053
group='compute')
3055
3054
instance_ref = objects.Instance(**self.test_instance)
@@ -3087,9 +3086,7 @@ def test_get_guest_config_numa_host_instance_fits(self, is_able):
3087
3086
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3088
3087
@mock.patch('nova.privsep.utils.supports_direct_io',
3089
3088
new=mock.Mock(return_value=True))
3090
- @mock.patch.object(
3091
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3092
- def test_get_guest_config_numa_host_instance_no_fit(self, is_able):
3089
+ def test_get_guest_config_numa_host_instance_no_fit(self):
3093
3090
instance_ref = objects.Instance(**self.test_instance)
3094
3091
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
3095
3092
flavor = objects.Flavor(memory_mb=4096, vcpus=4, root_gb=496,
@@ -3516,10 +3513,7 @@ def test_get_guest_memory_backing_config_file_backed_hugepages(self):
3516
3513
host_topology, inst_topology, numa_tune)
3517
3514
3518
3515
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3519
- @mock.patch.object(
3520
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3521
- def test_get_guest_config_numa_host_instance_pci_no_numa_info(
3522
- self, is_able):
3516
+ def test_get_guest_config_numa_host_instance_pci_no_numa_info(self):
3523
3517
self.flags(cpu_shared_set='3', cpu_dedicated_set=None,
3524
3518
group='compute')
3525
3519
@@ -3573,10 +3567,7 @@ def test_get_guest_config_numa_host_instance_pci_no_numa_info(
3573
3567
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3574
3568
@mock.patch('nova.privsep.utils.supports_direct_io',
3575
3569
new=mock.Mock(return_value=True))
3576
- @mock.patch.object(
3577
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3578
- def test_get_guest_config_numa_host_instance_2pci_no_fit(
3579
- self, is_able):
3570
+ def test_get_guest_config_numa_host_instance_2pci_no_fit(self):
3580
3571
self.flags(cpu_shared_set='3', cpu_dedicated_set=None,
3581
3572
group='compute')
3582
3573
instance_ref = objects.Instance(**self.test_instance)
@@ -3693,10 +3684,7 @@ def test_get_guest_config_numa_other_arch_qemu(self):
3693
3684
None)
3694
3685
3695
3686
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3696
- @mock.patch.object(
3697
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3698
- def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(
3699
- self, is_able):
3687
+ def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(self):
3700
3688
self.flags(cpu_shared_set='2-3', cpu_dedicated_set=None,
3701
3689
group='compute')
3702
3690
@@ -3735,10 +3723,7 @@ def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(
3735
3723
self.assertIsNone(cfg.cpu.numa)
3736
3724
3737
3725
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3738
- @mock.patch.object(
3739
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3740
- def test_get_guest_config_non_numa_host_instance_topo(
3741
- self, is_able):
3726
+ def test_get_guest_config_non_numa_host_instance_topo(self):
3742
3727
instance_topology = objects.InstanceNUMATopology(cells=[
3743
3728
objects.InstanceNUMACell(
3744
3729
id=0, cpuset=set([0]), pcpuset=set(), memory=1024),
@@ -3786,10 +3771,7 @@ def test_get_guest_config_non_numa_host_instance_topo(
3786
3771
numa_cfg_cell.memory)
3787
3772
3788
3773
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3789
- @mock.patch.object(
3790
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3791
- def test_get_guest_config_numa_host_instance_topo(
3792
- self, is_able):
3774
+ def test_get_guest_config_numa_host_instance_topo(self):
3793
3775
self.flags(cpu_shared_set='0-5', cpu_dedicated_set=None,
3794
3776
group='compute')
3795
3777
@@ -7199,9 +7181,7 @@ def test_get_guest_config_with_rng_dev_not_present(self, mock_path):
7199
7181
[],
7200
7182
image_meta, disk_info)
7201
7183
7202
- @mock.patch.object(
7203
- host.Host, "is_cpu_control_policy_capable", return_value=True)
7204
- def test_get_guest_config_with_cpu_quota(self, is_able):
7184
+ def test_get_guest_config_with_cpu_quota(self):
7205
7185
self.flags(virt_type='kvm', group='libvirt')
7206
7186
7207
7187
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7537,9 +7517,7 @@ def test_get_guest_config_disk_cachemodes_network(
7537
7517
self.flags(images_type='rbd', group='libvirt')
7538
7518
self._test_get_guest_config_disk_cachemodes('rbd')
7539
7519
7540
- @mock.patch.object(
7541
- host.Host, "is_cpu_control_policy_capable", return_value=True)
7542
- def test_get_guest_config_with_bogus_cpu_quota(self, is_able):
7520
+ def test_get_guest_config_with_bogus_cpu_quota(self):
7543
7521
self.flags(virt_type='kvm', group='libvirt')
7544
7522
7545
7523
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7557,9 +7535,10 @@ def test_get_guest_config_with_bogus_cpu_quota(self, is_able):
7557
7535
drvr._get_guest_config,
7558
7536
instance_ref, [], image_meta, disk_info)
7559
7537
7560
- @mock.patch.object(
7561
- host.Host, "is_cpu_control_policy_capable", return_value=False)
7562
- def test_get_update_guest_cputune(self, is_able):
7538
+ def test_get_update_guest_cputune(self):
7539
+ # No CPU controller on the host
7540
+ self.cgroups.version = 0
7541
+
7563
7542
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
7564
7543
instance_ref = objects.Instance(**self.test_instance)
7565
7544
instance_ref.flavor.extra_specs = {'quota:cpu_shares': '10000',
@@ -22110,6 +22089,7 @@ def setUp(self):
22110
22089
self.flags(sysinfo_serial="none", group="libvirt")
22111
22090
self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
22112
22091
self.useFixture(nova_fixtures.LibvirtFixture())
22092
+ self.useFixture(nova_fixtures.CGroupsFixture())
22113
22093
os_vif.initialize()
22114
22094
22115
22095
self.drvr = libvirt_driver.LibvirtDriver(
0 commit comments