@@ -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
@@ -3093,9 +3094,7 @@ def test_get_live_migrate_numa_info_empty(self, _):
3093
3094
'fake-flavor', 'fake-image-meta').obj_to_primitive())
3094
3095
3095
3096
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3096
- @mock.patch.object(
3097
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3098
- def test_get_guest_config_numa_host_instance_fits(self, is_able):
3097
+ def test_get_guest_config_numa_host_instance_fits(self):
3099
3098
self.flags(cpu_shared_set=None, cpu_dedicated_set=None,
3100
3099
group='compute')
3101
3100
instance_ref = objects.Instance(**self.test_instance)
@@ -3133,9 +3132,7 @@ def test_get_guest_config_numa_host_instance_fits(self, is_able):
3133
3132
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3134
3133
@mock.patch('nova.privsep.utils.supports_direct_io',
3135
3134
new=mock.Mock(return_value=True))
3136
- @mock.patch.object(
3137
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3138
- def test_get_guest_config_numa_host_instance_no_fit(self, is_able):
3135
+ def test_get_guest_config_numa_host_instance_no_fit(self):
3139
3136
instance_ref = objects.Instance(**self.test_instance)
3140
3137
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
3141
3138
flavor = objects.Flavor(memory_mb=4096, vcpus=4, root_gb=496,
@@ -3563,10 +3560,7 @@ def test_get_guest_memory_backing_config_file_backed_hugepages(self):
3563
3560
host_topology, inst_topology, numa_tune)
3564
3561
3565
3562
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3566
- @mock.patch.object(
3567
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3568
- def test_get_guest_config_numa_host_instance_pci_no_numa_info(
3569
- self, is_able):
3563
+ def test_get_guest_config_numa_host_instance_pci_no_numa_info(self):
3570
3564
self.flags(cpu_shared_set='3', cpu_dedicated_set=None,
3571
3565
group='compute')
3572
3566
@@ -3620,10 +3614,7 @@ def test_get_guest_config_numa_host_instance_pci_no_numa_info(
3620
3614
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3621
3615
@mock.patch('nova.privsep.utils.supports_direct_io',
3622
3616
new=mock.Mock(return_value=True))
3623
- @mock.patch.object(
3624
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3625
- def test_get_guest_config_numa_host_instance_2pci_no_fit(
3626
- self, is_able):
3617
+ def test_get_guest_config_numa_host_instance_2pci_no_fit(self):
3627
3618
self.flags(cpu_shared_set='3', cpu_dedicated_set=None,
3628
3619
group='compute')
3629
3620
instance_ref = objects.Instance(**self.test_instance)
@@ -3740,10 +3731,7 @@ def test_get_guest_config_numa_other_arch_qemu(self):
3740
3731
None)
3741
3732
3742
3733
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3743
- @mock.patch.object(
3744
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3745
- def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(
3746
- self, is_able):
3734
+ def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(self):
3747
3735
self.flags(cpu_shared_set='2-3', cpu_dedicated_set=None,
3748
3736
group='compute')
3749
3737
@@ -3782,10 +3770,7 @@ def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(
3782
3770
self.assertIsNone(cfg.cpu.numa)
3783
3771
3784
3772
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3785
- @mock.patch.object(
3786
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3787
- def test_get_guest_config_non_numa_host_instance_topo(
3788
- self, is_able):
3773
+ def test_get_guest_config_non_numa_host_instance_topo(self):
3789
3774
instance_topology = objects.InstanceNUMATopology(cells=[
3790
3775
objects.InstanceNUMACell(
3791
3776
id=0, cpuset=set([0]), pcpuset=set(), memory=1024),
@@ -3833,10 +3818,7 @@ def test_get_guest_config_non_numa_host_instance_topo(
3833
3818
numa_cfg_cell.memory)
3834
3819
3835
3820
@mock.patch.object(host.Host, "_check_machine_type", new=mock.Mock())
3836
- @mock.patch.object(
3837
- host.Host, "is_cpu_control_policy_capable", return_value=True)
3838
- def test_get_guest_config_numa_host_instance_topo(
3839
- self, is_able):
3821
+ def test_get_guest_config_numa_host_instance_topo(self):
3840
3822
self.flags(cpu_shared_set='0-5', cpu_dedicated_set=None,
3841
3823
group='compute')
3842
3824
@@ -7310,9 +7292,7 @@ def test_get_guest_config_with_rng_dev_not_present(self, mock_path):
7310
7292
[],
7311
7293
image_meta, disk_info)
7312
7294
7313
- @mock.patch.object(
7314
- host.Host, "is_cpu_control_policy_capable", return_value=True)
7315
- def test_get_guest_config_with_cpu_quota(self, is_able):
7295
+ def test_get_guest_config_with_cpu_quota(self):
7316
7296
self.flags(virt_type='kvm', group='libvirt')
7317
7297
7318
7298
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7648,9 +7628,7 @@ def test_get_guest_config_disk_cachemodes_network(
7648
7628
self.flags(images_type='rbd', group='libvirt')
7649
7629
self._test_get_guest_config_disk_cachemodes('rbd')
7650
7630
7651
- @mock.patch.object(
7652
- host.Host, "is_cpu_control_policy_capable", return_value=True)
7653
- def test_get_guest_config_with_bogus_cpu_quota(self, is_able):
7631
+ def test_get_guest_config_with_bogus_cpu_quota(self):
7654
7632
self.flags(virt_type='kvm', group='libvirt')
7655
7633
7656
7634
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -7668,9 +7646,10 @@ def test_get_guest_config_with_bogus_cpu_quota(self, is_able):
7668
7646
drvr._get_guest_config,
7669
7647
instance_ref, [], image_meta, disk_info)
7670
7648
7671
- @mock.patch.object(
7672
- host.Host, "is_cpu_control_policy_capable", return_value=False)
7673
- def test_get_update_guest_cputune(self, is_able):
7649
+ def test_get_update_guest_cputune(self):
7650
+ # No CPU controller on the host
7651
+ self.cgroups.version = 0
7652
+
7674
7653
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
7675
7654
instance_ref = objects.Instance(**self.test_instance)
7676
7655
instance_ref.flavor.extra_specs = {'quota:cpu_shares': '10000',
@@ -22401,6 +22380,7 @@ def setUp(self):
22401
22380
self.flags(sysinfo_serial="none", group="libvirt")
22402
22381
self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
22403
22382
self.useFixture(nova_fixtures.LibvirtFixture())
22383
+ self.useFixture(nova_fixtures.CGroupsFixture())
22404
22384
os_vif.initialize()
22405
22385
22406
22386
self.drvr = libvirt_driver.LibvirtDriver(
0 commit comments