* [PATCH for-12.0 1/2] hw/i386/microvm: make the default CPU model version a class field
2026-11-16 23:30 [PATCH for-12.0 0/2] hw/i386/microvm: add versioned machine types Thomas Lamprecht
@ 2026-11-16 23:30 ` Thomas Lamprecht
2026-11-16 23:30 ` [PATCH for-12.0 2/2] hw/i386/microvm: add versioned machine types Thomas Lamprecht
2026-11-17 16:48 ` [PATCH for-12.0 0/2] " Daniel P. Berrangé
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2026-11-16 23:30 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Michael S. Tsirkin, Richard Henderson, Zhao Liu,
Pierrick Bouvier, Ani Sinha
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 <t.lamprecht@proxmox.com>
---
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, void *data)
static void microvm_machine_state_init(MachineState *machine)
{
+ MicrovmMachineClass *mmc = MICROVM_MACHINE_GET_CLASS(machine);
MicrovmMachineState *mms = MICROVM_MACHINE(machine);
X86MachineState *x86ms = X86_MACHINE(machine);
@@ -492,7 +493,7 @@ static void microvm_machine_state_init(MachineState *machine)
microvm_memory_init(mms);
- x86_cpus_init(x86ms, CPU_VERSION_LATEST);
+ x86_cpus_init(x86ms, mmc->default_cpu_version);
microvm_devices_init(mms);
}
@@ -630,6 +631,7 @@ static void microvm_class_init(ObjectClass *oc, const void *data)
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
mmc->x86_load_linux = x86_load_linux;
+ mmc->default_cpu_version = CPU_VERSION_LATEST;
mc->init = microvm_machine_state_init;
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;
};
struct MicrovmMachineState {
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH for-12.0 2/2] hw/i386/microvm: add versioned machine types
2026-11-16 23:30 [PATCH for-12.0 0/2] hw/i386/microvm: add versioned machine types Thomas Lamprecht
2026-11-16 23:30 ` [PATCH for-12.0 1/2] hw/i386/microvm: make the default CPU model version a class field Thomas Lamprecht
@ 2026-11-16 23:30 ` Thomas Lamprecht
2026-11-17 16:48 ` [PATCH for-12.0 0/2] " Daniel P. Berrangé
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2026-11-16 23:30 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Michael S. Tsirkin, Richard Henderson, Zhao Liu,
Pierrick Bouvier, Ani Sinha
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 <t.lamprecht@proxmox.com>
---
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.
+``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.
+
Supported devices
-----------------
@@ -34,7 +52,8 @@ Currently, microvm does *not* support the following features:
- PCI-only devices.
- Hotplug of any kind.
-- Live migration across QEMU versions.
+- Live migration across QEMU versions, unless a versioned machine type
+ is used.
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 = MICROVM_MACHINE_CLASS(mc);
+
+ mmc->default_cpu_version = 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 = 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) = \
+ { \
+ .name = MACHINE_VER_TYPE_NAME("microvm", major, minor), \
+ .parent = TYPE_MICROVM_MACHINE, \
+ .class_init = MACHINE_VER_SYM(class_init, microvm, major, minor), \
+ .secure = 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/functional/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):
self.validate_aliases(cpus)
+ 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 = dict((m['name'], m) for m in
+ self.vm.cmd('query-cpu-definitions'))
+
+ latest = 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 latest '
+ 'version')
+
+ self.validate_aliases(cpus)
+
+ def test_microvm_12_0_alias(self):
+ """
+ Check if unversioned CPU model is an alias pointing to right version
+ on a versioned microvm machine type
+ """
+ self.set_machine('microvm-12.0')
+ self.vm.add_args('-S')
+ self.vm.launch()
+
+ cpus = 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
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH for-12.0 0/2] hw/i386/microvm: add versioned machine types
2026-11-16 23:30 [PATCH for-12.0 0/2] hw/i386/microvm: add versioned machine types Thomas Lamprecht
2026-11-16 23:30 ` [PATCH for-12.0 1/2] hw/i386/microvm: make the default CPU model version a class field Thomas Lamprecht
2026-11-16 23:30 ` [PATCH for-12.0 2/2] hw/i386/microvm: add versioned machine types Thomas Lamprecht
@ 2026-11-17 16:48 ` Daniel P. Berrangé
2 siblings, 0 replies; 4+ messages in thread
From: Daniel P. Berrangé @ 2026-11-17 16:48 UTC (permalink / raw)
To: Thomas Lamprecht
Cc: qemu-devel, Paolo Bonzini, Michael S. Tsirkin, Richard Henderson,
Zhao Liu, Pierrick Bouvier, Ani Sinha
On Tue, Nov 17, 2026 at 12:30:12AM +0100, Thomas Lamprecht wrote:
> Proxmox VE wants to use microvm with PCIe and ACPI for long-lived Linux
> guests, i.e. like Linux containers but with better isolation. Our
> cluster upgrades and host maintenance rely on live migrating guests to
> hosts that already run a newer QEMU, which is currently not really
> possible with microvm, as it is not versioned.
>
> When microvm was added, versioning was ruled out on purpose [1], as it
> targeted short-lived guests. Since then, Paolo noted that microvm could
> start having versioned variants [2]. So this series adds microvm-X.Y
> machine types, starting with 12.0, as 11.2 is already in freeze.
If you're going to the trouble of enabling PCIe and ACPI for
microvm, and also wanting versioning, then why are you not
picking 'q35' ?
IIRC, since microvm was introduced more pieces of q35 are now
configurable to allow disabling at runtime, further reducing
the difference between a minimal q35 and microvm w/ PCIe+ACPI.
> Noteworthy points that migth be up for discussion:
>
> - Following Paolo preference [2], "microvm" does not become an alias of
> the latest version, rather, it is left as it is. Unversioned machine
> types are meant to be a moving target [2], which includes defaulting
> to the latest version of a CPU model. The versioned types need a fixed
> default and use version 1, like pc and q35 do, and an alias cannot
> differ from the type it refers to.
I think that would be a bad idea, as it would make 'microvm' work
differently to every other machine type where we have versioning.
The standard pattern is that the unversioned name is always an
alias for the latest version.
Defining an unversioned name as a full machine, separate from the
latest versioned machine esentially gives you two things which are
identical. The burden of versioned machines comes from ensuring the
existing versions get the right compat properties set to keep their
ABI unchanged and from wiring up the boilerplate for new versions
at the start of each release.
>
> - The x86 CPU compat properties are part of pc_compat_X_Y in
> hw/i386/pc.c, which is only built with CONFIG_PC. Once microvm-12.0
> needs them, they would have to move, for example to
> hw/i386/x86-common.c (but I'm happy to use another place, just say
> the word).
>
> - With KVM, microvm uses the host's physical address width, so
> migration also needs the same width on both hosts. This is not new,
> the series only documents it for now.
>
> Tested with the x86_64 CPU model and migration functional tests,
> bios-tables-test and qom-test, and by live migrating Linux guests on
> microvm-12.0 with TCG and KVM.
>
> [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/
>
> Thomas Lamprecht (2):
> hw/i386/microvm: make the default CPU model version a class field
> hw/i386/microvm: add versioned machine types
>
> docs/system/i386/microvm.rst | 21 ++++++++-
> hw/i386/microvm.c | 47 ++++++++++++++++++-
> include/hw/i386/microvm.h | 3 ++
> .../x86_64/test_cpu_model_versions.py | 41 ++++++++++++++++
> 4 files changed, 110 insertions(+), 2 deletions(-)
>
>
> base-commit: f71afb409a87c4ecd0f9d63a5963eb645dfab780
> --
> 2.47.3
>
>
>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 4+ messages in thread