From nobody Mon Nov 23 04:29:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794873046910657.398224934939; Mon, 16 Nov 2026 15:50:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xT6T2-00007E-P6; Mon, 16 Nov 2026 18:50:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xT6T0-00006W-V6 for qemu-devel@nongnu.org; Mon, 16 Nov 2026 18:50:30 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xT6Sy-0005Cj-U9 for qemu-devel@nongnu.org; Mon, 16 Nov 2026 18:50:30 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7C18948662; Tue, 17 Nov 2026 00:50:18 +0100 (CET) From: Thomas Lamprecht To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , Pierrick Bouvier , Ani Sinha Subject: [PATCH for-12.0 1/2] hw/i386/microvm: make the default CPU model version a class field Date: Tue, 17 Nov 2026 00:30:13 +0100 Message-ID: <20261116235010.3622909-2-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261116235010.3622909-1-t.lamprecht@proxmox.com> References: <20261116235010.3622909-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794873015950 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=t.lamprecht@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1794873051078158500 Content-Type: text/plain; charset="utf-8" microvm resolves CPU model names without a version, like "Cascadelake-Server", to the latest version known to the QEMU binary. Store this choice in MicrovmMachineClass, like PCMachineClass does, in preparation for versioned microvm machine types, which need a fixed version for a stable guest CPU. No functional change intended. Signed-off-by: Thomas Lamprecht --- hw/i386/microvm.c | 4 +++- include/hw/i386/microvm.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 18983a363b..ae22bdf433 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -479,6 +479,7 @@ static void microvm_powerdown_req(Notifier *notifier, v= oid *data) =20 static void microvm_machine_state_init(MachineState *machine) { + MicrovmMachineClass *mmc =3D MICROVM_MACHINE_GET_CLASS(machine); MicrovmMachineState *mms =3D MICROVM_MACHINE(machine); X86MachineState *x86ms =3D X86_MACHINE(machine); =20 @@ -492,7 +493,7 @@ static void microvm_machine_state_init(MachineState *ma= chine) =20 microvm_memory_init(mms); =20 - x86_cpus_init(x86ms, CPU_VERSION_LATEST); + x86_cpus_init(x86ms, mmc->default_cpu_version); =20 microvm_devices_init(mms); } @@ -630,6 +631,7 @@ static void microvm_class_init(ObjectClass *oc, const v= oid *data) HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); =20 mmc->x86_load_linux =3D x86_load_linux; + mmc->default_cpu_version =3D CPU_VERSION_LATEST; =20 mc->init =3D microvm_machine_state_init; =20 diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h index 5d5eacd1c6..3903c27c3a 100644 --- a/include/hw/i386/microvm.h +++ b/include/hw/i386/microvm.h @@ -80,6 +80,9 @@ struct MicrovmMachineClass { DeviceState *dev); void (*x86_load_linux)(X86MachineState *x86ms, FWCfgState *fw_cfg, int acpi_data_size); + + /* Default CPU model version. See x86_cpu_set_default_version(). */ + int default_cpu_version; }; =20 struct MicrovmMachineState { --=20 2.47.3 From nobody Mon Nov 23 04:29:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179487306948079.97702211081491; Mon, 16 Nov 2026 15:51:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xT6T3-00007r-Oq; Mon, 16 Nov 2026 18:50:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xT6T2-00007I-KV for qemu-devel@nongnu.org; Mon, 16 Nov 2026 18:50:32 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xT6Sy-0005Ek-Td for qemu-devel@nongnu.org; Mon, 16 Nov 2026 18:50:32 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 502B448657; Tue, 17 Nov 2026 00:50:19 +0100 (CET) From: Thomas Lamprecht To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , Zhao Liu , Pierrick Bouvier , Ani Sinha Subject: [PATCH for-12.0 2/2] hw/i386/microvm: add versioned machine types Date: Tue, 17 Nov 2026 00:30:14 +0100 Message-ID: <20261116235010.3622909-3-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261116235010.3622909-1-t.lamprecht@proxmox.com> References: <20261116235010.3622909-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794873016032 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=t.lamprecht@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1794873072342158500 Content-Type: text/plain; charset="utf-8" microvm was meant for short-lived guests [1] and thus wasn not versioned, so migration across QEMU versions is not supported. It is now also intersting for long-lived ones as better isolated alternative for Linux containers though, which would be nice to allow migration to hosts with a newer QEMU, and Paolo noted that microvm could start having versioned variants [2]. Add microvm-X.Y machine types, starting with 12.0. "microvm" itself is left "unversioned" as it is, instead of becoming an alias of the latest version. An unversioned machine type is meant to be a moving target [2], which includes resolving a CPU model name without a version, like "Cascadelake-Server", to the latest version of the model. A versioned type needs a fixed default for that, and an alias cannot differ from the type it refers to. So the versioned types derive from microvm and default to version 1, like pc and q35 do. A machine class does not inherit the compat property array of its parent class and TypeInfo.secure is not inherited either, so the versioned types add microvm_properties and set the flag again. Both sides of a migration have to use the same versioned type. The machine type check of the migration stream does not fully enforce this, as it only compares as many characters as the name of the source has, i.e., it rejects microvm-12.0 to microvm, but not microvm to microvm-12.0. Also document that with KVM or HVF migration needs the same guest physical address width on both hosts. [1] https://lore.kernel.org/qemu-devel/af3acd26-f114-5889-182a-7dbd025393b9= @redhat.com/ [2] https://lore.kernel.org/qemu-devel/004396c0-8370-4015-b746-3c800f45984f= @redhat.com/ Signed-off-by: Thomas Lamprecht --- docs/system/i386/microvm.rst | 21 ++++++++- hw/i386/microvm.c | 43 +++++++++++++++++++ .../x86_64/test_cpu_model_versions.py | 41 ++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) diff --git a/docs/system/i386/microvm.rst b/docs/system/i386/microvm.rst index 077ea15751..56804f1bd8 100644 --- a/docs/system/i386/microvm.rst +++ b/docs/system/i386/microvm.rst @@ -9,6 +9,24 @@ designed for short-lived guests. microvm also establishes = a baseline for benchmarking and optimizing both QEMU and guest operating systems, since it is optimized for both boot time and footprint. =20 +``microvm`` itself is not versioned: its defaults may change with every +QEMU version, so it does not support migration between QEMU versions. +The ``microvm-X.Y`` machine types are versioned. They keep the behaviour +they had in the QEMU X.Y release, so that VM migration works between +QEMU versions, as long as both sides use the same versioned type. The +first one is ``microvm-12.0``. + +On the versioned types, a CPU model name without a version, like +``Cascadelake-Server``, refers to the first version of the model, as on +the ``pc`` and ``q35`` machine types, while ``microvm`` uses the latest +version. Use a versioned name, like ``Cascadelake-Server-v5``, to select +a specific one. + +With KVM or HVF and a 64-bit CPU model, microvm uses the host's +physical address width for the guest, so migration also requires the +same width on both hosts, for example by capping it with the +``host-phys-bits-limit`` CPU property to a value both hosts support. + =20 Supported devices ----------------- @@ -34,7 +52,8 @@ Currently, microvm does *not* support the following featu= res: =20 - PCI-only devices. - Hotplug of any kind. -- Live migration across QEMU versions. +- Live migration across QEMU versions, unless a versioned machine type + is used. =20 =20 Using the microvm machine type diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index ae22bdf433..5bb6cd1f51 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -735,3 +735,46 @@ static void microvm_machine_init(void) type_register_static(µvm_machine_info); } type_init(microvm_machine_init); + +/* + * Defaults of the versioned machine types, which derive from the + * unversioned one. The compat properties are added again, as a machine + * class does not inherit the compat_props array of its parent class. + */ +static void microvm_machine_options(MachineClass *mc) +{ + MicrovmMachineClass *mmc =3D MICROVM_MACHINE_CLASS(mc); + + mmc->default_cpu_version =3D 1; + compat_props_add(mc->compat_props, microvm_properties, + G_N_ELEMENTS(microvm_properties)); +} + +#define DEFINE_MICROVM_MACHINE(major, minor) \ + static void MACHINE_VER_SYM(class_init, microvm, major, minor)( \ + ObjectClass *oc, \ + const void *data) \ + { \ + MachineClass *mc =3D MACHINE_CLASS(oc); \ + microvm_machine_options(mc); \ + MACHINE_VER_SYM(options, microvm, major, minor)(mc); \ + MACHINE_VER_DEPRECATION(major, minor); \ + } \ + static const TypeInfo MACHINE_VER_SYM(info, microvm, major, minor) =3D= \ + { \ + .name =3D MACHINE_VER_TYPE_NAME("microvm", major, minor), \ + .parent =3D TYPE_MICROVM_MACHINE, \ + .class_init =3D MACHINE_VER_SYM(class_init, microvm, major, minor)= , \ + .secure =3D true, \ + }; \ + static void MACHINE_VER_SYM(register, microvm, major, minor)(void) \ + { \ + MACHINE_VER_DELETION(major, minor); \ + type_register_static(&MACHINE_VER_SYM(info, microvm, major, minor)= ); \ + } \ + type_init(MACHINE_VER_SYM(register, microvm, major, minor)); + +static void microvm_machine_12_0_options(MachineClass *mc) +{ +} +DEFINE_MICROVM_MACHINE(12, 0) diff --git a/tests/functional/x86_64/test_cpu_model_versions.py b/tests/fun= ctional/x86_64/test_cpu_model_versions.py index 36c968f1c0..18b9e934b0 100755 --- a/tests/functional/x86_64/test_cpu_model_versions.py +++ b/tests/functional/x86_64/test_cpu_model_versions.py @@ -178,6 +178,47 @@ def test_unversioned_alias(self): =20 self.validate_aliases(cpus) =20 + def test_microvm_alias(self): + """ + Check if unversioned CPU model is an alias pointing to the latest + version on the unversioned microvm machine type + """ + self.set_machine('microvm') + self.vm.add_args('-S') + self.vm.launch() + + cpus =3D dict((m['name'], m) for m in + self.vm.cmd('query-cpu-definitions')) + + latest =3D max(int(m.group(1)) for m in + (re.fullmatch(r'Cascadelake-Server-v(\d+)', name) + for name in cpus) if m) + self.assertEqual(cpus['Cascadelake-Server'].get('alias-of'), + 'Cascadelake-Server-v%d' % latest, + 'Cascadelake-Server must be an alias of its lates= t ' + 'version') + + self.validate_aliases(cpus) + + def test_microvm_12_0_alias(self): + """ + Check if unversioned CPU model is an alias pointing to right versi= on + on a versioned microvm machine type + """ + self.set_machine('microvm-12.0') + self.vm.add_args('-S') + self.vm.launch() + + cpus =3D dict((m['name'], m) for m in + self.vm.cmd('query-cpu-definitions')) + + self.assertEqual(cpus['Cascadelake-Server'].get('alias-of'), + 'Cascadelake-Server-v1', + 'Cascadelake-Server must be an alias of ' + 'Cascadelake-Server-v1') + + self.validate_aliases(cpus) + def test_none_alias(self): """ Check if unversioned CPU model is an alias pointing to some version --=20 2.47.3