From: Bibo Mao <maobibo@loongson.cn>
To: Song Gao <gaosong@loongson.cn>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>, qemu-devel@nongnu.org
Subject: [PATCH v2 2/2] hw/loongarch/virt: Define versioned virt machine
Date: Thu, 25 Dec 2025 09:41:02 +0800 [thread overview]
Message-ID: <20251225014102.2666365-3-maobibo@loongson.cn> (raw)
In-Reply-To: <20251225014102.2666365-1-maobibo@loongson.cn>
Add versioned virt machine started from QEMU 11.0
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
hw/loongarch/virt.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index ed406e3410..a177d0a195 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -1371,9 +1371,41 @@ static void virt_class_init(ObjectClass *oc, const void *data)
"The string may be up to 8 bytes in size");
}
+#define DEFINE_VIRT_MACHINE_VERSION(latest, ...) \
+ static void MACHINE_VER_SYM(class_init, virt, __VA_ARGS__)( \
+ ObjectClass *oc, \
+ const void *data) \
+ { \
+ MachineClass *mc = MACHINE_CLASS(oc); \
+ MACHINE_VER_SYM(options, virt, __VA_ARGS__)(mc); \
+ mc->desc = "QEMU " MACHINE_VER_STR(__VA_ARGS__) " LoongArch Virtual Machine"; \
+ MACHINE_VER_DEPRECATION(__VA_ARGS__); \
+ if (latest) { \
+ mc->alias = "virt"; \
+ } \
+ } \
+ static const TypeInfo MACHINE_VER_SYM(info, virt, __VA_ARGS__) = \
+ { \
+ .name = MACHINE_VER_TYPE_NAME("virt", __VA_ARGS__), \
+ .parent = TYPE_LOONGARCH_VIRT_MACHINE, \
+ .class_init = MACHINE_VER_SYM(class_init, virt, __VA_ARGS__), \
+ }; \
+ static void MACHINE_VER_SYM(register, virt, __VA_ARGS__)(void) \
+ { \
+ MACHINE_VER_DELETION(__VA_ARGS__); \
+ type_register_static(&MACHINE_VER_SYM(info, virt, __VA_ARGS__)); \
+ } \
+ type_init(MACHINE_VER_SYM(register, virt, __VA_ARGS__));
+
+#define DEFINE_VIRT_MACHINE_AS_LATEST(major, minor) \
+ DEFINE_VIRT_MACHINE_VERSION(true, major, minor)
+#define DEFINE_VIRT_MACHINE(major, minor) \
+ DEFINE_VIRT_MACHINE_VERSION(false, major, minor)
+
static const TypeInfo virt_machine_info = {
.name = TYPE_LOONGARCH_VIRT_MACHINE,
.parent = TYPE_MACHINE,
+ .abstract = true,
.instance_size = sizeof(LoongArchVirtMachineState),
.class_init = virt_class_init,
.instance_init = virt_initfn,
@@ -1389,3 +1421,8 @@ static void machvirt_machine_init(void)
}
type_init(machvirt_machine_init);
+
+static void virt_machine_11_0_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(11, 0)
--
2.39.3
next prev parent reply other threads:[~2025-12-25 1:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-25 1:41 [PATCH v2 0/2] hw/loongarch/virt: Add versioned machine type support Bibo Mao
2025-12-25 1:41 ` [PATCH v2 1/2] hw/loongarch/virt: Define virt machine type with type_init() Bibo Mao
2025-12-25 1:41 ` Bibo Mao [this message]
2026-03-26 7:50 ` [PATCH v2 0/2] hw/loongarch/virt: Add versioned machine type support Bibo Mao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251225014102.2666365-3-maobibo@loongson.cn \
--to=maobibo@loongson.cn \
--cc=gaosong@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox