diff --git a/config.yaml b/config.yaml index 4fc73e6b..30879867 100644 --- a/config.yaml +++ b/config.yaml @@ -199,6 +199,14 @@ options: Sets vcpu_pin_set option in nova.conf which defines which pcpus that instance vcpus can or cannot use. For example '^0,^2' to reserve two cpus for the host. + cpu-shared-set: + type: string + default: + description: | + Sets compute/cpu_shared_set option in nova.conf defines which + physical CPUs will be used for best-effort guest vCPU resources. + Currently only used by libvirt driver to place guest emulator threads + when hw:emulator_threads_policy:share is set. virtio-net-tx-queue-size: type: int default: diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 8963adcd..f0974161 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -253,6 +253,9 @@ class NovaComputeLibvirtContext(context.OSContextGenerator): if config('vcpu-pin-set'): ctxt['vcpu_pin_set'] = config('vcpu-pin-set') + if config('cpu-shared-set'): + ctxt['cpu_shared_set'] = config('cpu-shared-set') + if config('virtio-net-tx-queue-size'): ctxt['virtio_net_tx_queue_size'] = ( config('virtio-net-tx-queue-size')) diff --git a/templates/rocky/nova.conf b/templates/rocky/nova.conf index c6a184f0..8aaf719f 100644 --- a/templates/rocky/nova.conf +++ b/templates/rocky/nova.conf @@ -264,3 +264,9 @@ disable_libvirt_livesnapshot = False {% include "parts/section-serial-console" %} {% include "parts/section-placement" %} + +[compute] +{% if cpu_shared_set -%} +cpu_shared_set = {{ cpu_shared_set }} +{% endif -%} + diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index 4618e8f0..6159c497 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -439,6 +439,7 @@ class NovaComputeContextTests(CharmTestCase): self.test_config.set('pci-passthrough-whitelist', 'mypcidevices') self.test_config.set('virtio-net-tx-queue-size', 512) self.test_config.set('virtio-net-rx-queue-size', 1024) + self.test_config.set('cpu-shared-set', "4-12,^8,15") libvirt = context.NovaComputeLibvirtContext() self.assertEqual( @@ -455,7 +456,8 @@ class NovaComputeContextTests(CharmTestCase): 'force_raw_images': True, 'pci_passthrough_whitelist': 'mypcidevices', 'virtio_net_tx_queue_size': 512, - 'virtio_net_rx_queue_size': 1024}, libvirt()) + 'virtio_net_rx_queue_size': 1024, + 'cpu_shared_set': "4-12,^8,15"}, libvirt()) def test_ksm_configs(self): self.lsb_release.return_value = {'DISTRIB_CODENAME': 'lucid'}