From b5d9b18c0afd06b721d78bced96b4c6c19f77834 Mon Sep 17 00:00:00 2001 From: James Page Date: Wed, 26 Jul 2017 14:35:33 +0100 Subject: [PATCH] aarch64: set default cpu_mode to host-passthrough Unless explicit configuration is supplied by the charm user, set the cpu_mode configuration on the aarch64 architecture to host-passthrough; host-model is not supported by the underlying hypervisor. Change-Id: I6df2d70e7b5fed7e614ca981864f6f737a1a90eb Closes-Bug: 1673467 --- hooks/nova_compute_context.py | 2 +- unit_tests/test_nova_compute_contexts.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 528740d8..78902b6c 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -197,7 +197,7 @@ class NovaComputeLibvirtContext(context.OSContextGenerator): if config('cpu-mode'): ctxt['cpu_mode'] = config('cpu-mode') - elif ctxt['arch'] in ['ppc64el', 'ppc64le']: + elif ctxt['arch'] in ('ppc64el', 'ppc64le', 'aarch64'): ctxt['cpu_mode'] = 'host-passthrough' elif ctxt['arch'] == 's390x': ctxt['cpu_mode'] = 'none' diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index 31dae263..dfdca4a7 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -364,6 +364,17 @@ class NovaComputeContextTests(CharmTestCase): self.assertEqual(libvirt()['cpu_mode'], 'none') + @patch.object(context, 'platform') + @patch.object(context.uuid, 'uuid4') + def test_libvirt_cpu_mode_aarch64(self, mock_uuid, mock_platform): + self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'} + mock_uuid.return_value = 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7' + mock_platform.machine.return_value = 'aarch64' + libvirt = context.NovaComputeLibvirtContext() + + self.assertEqual(libvirt()['cpu_mode'], + 'host-passthrough') + def test_libvirt_vnf_configs(self): self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid}) self.lsb_release.return_value = {'DISTRIB_CODENAME': 'lucid'}