From e155baefb0bbaa0aa78e54fe9e0f10c12336c01a Mon Sep 17 00:00:00 2001 From: Kashyap Chamarthy Date: Fri, 14 Sep 2018 11:49:08 +0200 Subject: [PATCH] libvirt: Use 'virt' as the default machine type for ARMv7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing Nova's default machine type for ARMv7 ('vexpress-15') was added more than four years ago (in commit: 5b27fe7: "libvirt: Allow specification of default machine type"). The 'vexpress-15' board is a specific development board, which has hardware limitations (like only single ethernet adapter). The upstream QEMU recommendation[1] for the past couple of years is to use the 'virt' machine type for both ARMv7, and AArch64, which was specifically designed to be used with virutal machines. Quoting a write-up[2] from QEMU's ARM subsystem maintainer: "Why the 'virt' board? "QEMU has models of nearly 50 different ARM boards, which makes it difficult for new users to pick one which is right for their purposes. This wild profusion reflects a similar diversity in the real hardware world: ARM systems come in many different flavours with very different hardware components and capabilities. A kernel which is expecting to run on one system will likely not run on another. Many of QEMU’s models are annoyingly limited because the real hardware was also limited — there’s no PCI bus on most mobile devices, after all, and a fifteen year old development board wouldn’t have had a gigabyte of RAM on it. "My recommendation is that if you don’t know for certain that you want a model of a specific device, you should choose the “virt” board. This is a purely virtual platform designed for use in virtual machines, and it supports PCI, virtio, a recent ARM CPU and large amounts of RAM. The only thing it doesn’t have out of the box is graphics, but graphical programs on a fully emulated system run very slowly anyway so are best avoided." So, change the default machine type for ARMv7 arch to be 'virt'. [1] https://wiki.qemu.org/Documentation/Platforms/ARM [2] https://translatedcode.wordpress.com/2016/11/03/installing-debian-on-qemus-32-bit-arm-virt-board/ Change-Id: If9ffa5a019f67734a9f30ccaf3ab96ff41262dc8 Signed-off-by: Kashyap Chamarthy --- nova/tests/unit/virt/libvirt/test_driver.py | 2 +- nova/virt/libvirt/driver.py | 19 ++++++++++--------- ...chine-type-for-ARMv7-cd2c252336057ec8.yaml | 12 ++++++++++++ 3 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/Use-virt-as-machine-type-for-ARMv7-cd2c252336057ec8.yaml diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 81af44d22fb9..f1c0f877548f 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -6221,7 +6221,7 @@ class LibvirtConnTestCase(test.NoDBTestCase, cfg = drvr._get_guest_config(instance_ref, _fake_network_info(self, 1), image_meta, disk_info) - self.assertEqual(cfg.os_mach_type, "vexpress-a15") + self.assertEqual(cfg.os_mach_type, "virt") @mock.patch.object(libvirt_driver.LibvirtDriver, "_get_guest_storage_config") diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index b1bf5c5bd732..30b1f365b7b8 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -4169,20 +4169,21 @@ class LibvirtDriver(driver.ComputeDriver): return mappings def _get_machine_type(self, image_meta, caps): - # The underlying machine type can be set as an image attribute, - # or otherwise based on some architecture specific defaults - + # The guest machine type can be set as an image metadata + # property, or otherwise based on architecture-specific + # defaults. mach_type = None if image_meta.properties.get('hw_machine_type') is not None: mach_type = image_meta.properties.hw_machine_type else: - # For ARM systems we will default to vexpress-a15 for armv7 - # and virt for aarch64 - if caps.host.cpu.arch == fields.Architecture.ARMV7: - mach_type = "vexpress-a15" - - if caps.host.cpu.arch == fields.Architecture.AARCH64: + # NOTE(kchamart): For ARMv7 and AArch64, use the 'virt' + # board as the default machine type. It is the recommended + # board, which is designed to be used with virtual machines. + # The 'virt' board is more flexible, supports PCI, 'virtio', + # has decent RAM limits, etc. + if caps.host.cpu.arch in (fields.Architecture.ARMV7, + fields.Architecture.AARCH64): mach_type = "virt" if caps.host.cpu.arch in (fields.Architecture.S390, diff --git a/releasenotes/notes/Use-virt-as-machine-type-for-ARMv7-cd2c252336057ec8.yaml b/releasenotes/notes/Use-virt-as-machine-type-for-ARMv7-cd2c252336057ec8.yaml new file mode 100644 index 000000000000..9f1509a5ff33 --- /dev/null +++ b/releasenotes/notes/Use-virt-as-machine-type-for-ARMv7-cd2c252336057ec8.yaml @@ -0,0 +1,12 @@ +--- +upgrade: + - | + The default QEMU machine type for ARMv7 architecture is now changed + to ``virt`` (from the older ``vexpress-a15``, which is a particular + ARM development board). The ``virt`` board is the recommended + default for ARMv7, which is explicitly designed to be + used with virtual machines. It is more flexible, supports PCI and + 'virtio' devices, has decent RAM limits, and so forth. For + pre-existing Nova guests on ARMv7 to acquire the ``virt`` machine + type: (a) upgrade Nova with this fix; (b) explicitly start and stop + the guests, then they will pick up the 'virt' machine type.