From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 1/3] machine: add machine_base_type() helper
Date: Wed, 12 Nov 2025 12:29:38 +0100 [thread overview]
Message-ID: <20251112112959.237909-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20251112112959.237909-1-f.ebner@proxmox.com>
Use the helper for machine_type_is_q35() to start out. The plan is to
re-use the helper for a function checking which machine flags are
supported for a given machine type.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/Machine.pm | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/PVE/QemuServer/Machine.pm b/src/PVE/QemuServer/Machine.pm
index b2ff7e24..7a401087 100644
--- a/src/PVE/QemuServer/Machine.pm
+++ b/src/PVE/QemuServer/Machine.pm
@@ -142,11 +142,34 @@ sub assert_valid_machine_property {
if $machine_conf->{'aw-bits'} && !$machine_conf->{viommu};
}
+=head3 machine_base_type
+
+ my $base_type = machine_base_type($machine_type);
+
+Returns the base type of the machine, currently either C<i440fx>, C<q35> or C<virt>. A value must be
+passed in. Dies if the machine type cannot be determined, but should not happen if it is valid for
+the C<$machine_fmt> schema.
+
+=cut
+
+my sub machine_base_type {
+ my ($machine_type) = @_;
+
+ die "unable to determine machine base type - no value\n" if !$machine_type;
+
+ return 'q35' if $machine_type =~ m/q35/;
+ return 'i440fx' if $machine_type =~ m/^pc/;
+ return 'virt' if $machine_type =~ m/^virt/;
+
+ die "unable to determine machine base type '$machine_type'\n";
+}
+
sub machine_type_is_q35 {
my ($conf) = @_;
my $machine_conf = parse_machine($conf->{machine});
- return $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
+ return 0 if !$machine_conf || !$machine_conf->{type};
+ return machine_base_type($machine_conf->{type}) eq 'q35' ? 1 : 0;
}
# In list context, also returns whether the current machine is deprecated or not.
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-11-12 11:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 11:29 [pve-devel] [PATCH-SERIES qemu-server 0/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
2025-11-12 11:29 ` Fiona Ebner [this message]
2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 2/3] machine: add machine_supports_flag() helper Fiona Ebner
2025-11-12 11:29 ` [pve-devel] [PATCH qemu-server 3/3] fix #7014: fix regression starting aarch64 VMs with machine type >= 10.1 Fiona Ebner
2025-11-12 11:52 ` Fiona Ebner
2025-11-13 22:13 ` [pve-devel] applied: [PATCH-SERIES qemu-server 0/3] " Thomas Lamprecht
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=20251112112959.237909-2-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.