From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server v2 2/2] hotplug pending: only query machine type when actually required
Date: Tue, 6 Oct 2026 10:58:33 +0200 [thread overview]
Message-ID: <20261006085936.30542-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20261006085936.30542-1-f.ebner@proxmox.com>
Similar to commit ebe5f14c ("hotplug pending: only check for USB
hoptplug support when actually needed"), only issue the
'query-version' QMP command when actually needed.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
New in v2.
src/PVE/QemuServer.pm | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 758f9d99..74772fdd 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -4569,7 +4569,13 @@ sub vmconfig_hotplug_pending {
my $defaults = load_defaults();
my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
- my $machine_type = PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
+
+ my $_machine_type;
+ my $machine_type = sub {
+ return $_machine_type if defined($_machine_type);
+ $_machine_type = PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
+ return $_machine_type;
+ };
# commit values which do not have any impact on running VM first
# Note: those option cannot raise errors, we we do not care about
@@ -4668,7 +4674,7 @@ sub vmconfig_hotplug_pending {
my $is_usb_hotplug_supported = sub {
return $usb_hotplug if defined($usb_hotplug);
my $ostype = $conf->{ostype};
- my $version = PVE::QemuServer::Machine::extract_version($machine_type);
+ my $version = PVE::QemuServer::Machine::extract_version($machine_type->());
$usb_hotplug =
$hotplug_features->{usb}
&& min_version($version, 7, 1)
@@ -4689,8 +4695,8 @@ sub vmconfig_hotplug_pending {
} elsif ($opt eq 'tablet') {
die "skip\n" if !$hotplug_features->{usb};
if ($defaults->{tablet}) {
- vm_deviceplug($storecfg, $conf, $vmid, 'tablet', $arch, $machine_type);
- vm_deviceplug($storecfg, $conf, $vmid, 'keyboard', $arch, $machine_type)
+ vm_deviceplug($storecfg, $conf, $vmid, 'tablet', $arch, $machine_type->());
+ vm_deviceplug($storecfg, $conf, $vmid, 'keyboard', $arch, $machine_type->())
if $arch eq 'aarch64';
} else {
vm_deviceunplug($vmid, $conf, 'tablet');
@@ -4760,8 +4766,8 @@ sub vmconfig_hotplug_pending {
} elsif ($opt eq 'tablet') {
die "skip\n" if !$hotplug_features->{usb};
if ($value == 1) {
- vm_deviceplug($storecfg, $conf, $vmid, 'tablet', $arch, $machine_type);
- vm_deviceplug($storecfg, $conf, $vmid, 'keyboard', $arch, $machine_type)
+ vm_deviceplug($storecfg, $conf, $vmid, 'tablet', $arch, $machine_type->());
+ vm_deviceplug($storecfg, $conf, $vmid, 'keyboard', $arch, $machine_type->())
if $arch eq 'aarch64';
} elsif ($value == 0) {
vm_deviceunplug($vmid, $conf, 'tablet');
@@ -4775,7 +4781,7 @@ sub vmconfig_hotplug_pending {
if ($d->{host} =~ m/^spice$/i) {
$id = "usbredirdev$index";
}
- qemu_usb_hotplug($storecfg, $conf, $vmid, $id, $d, $arch, $machine_type);
+ qemu_usb_hotplug($storecfg, $conf, $vmid, $id, $d, $arch, $machine_type->());
} elsif ($opt eq 'vcpus') {
die "skip\n" if !$hotplug_features->{cpu};
qemu_cpu_hotplug($vmid, $conf, $value);
@@ -4802,7 +4808,7 @@ sub vmconfig_hotplug_pending {
$opt,
$value,
$arch,
- $machine_type,
+ $machine_type->(),
);
} elsif (is_valid_drivename($opt)) {
die "skip\n" if $opt eq 'efidisk0' || $opt eq 'tpmstate0';
@@ -4821,7 +4827,7 @@ sub vmconfig_hotplug_pending {
$opt,
$value,
$arch,
- $machine_type,
+ $machine_type->(),
);
} elsif ($opt =~ m/^memory$/) { #dimms
die "skip\n" if !$hotplug_features->{memory};
@@ -4862,7 +4868,7 @@ sub vmconfig_hotplug_pending {
$opt,
$value,
$arch,
- $machine_type,
+ $machine_type->(),
);
};
if (my $err = $@) {
--
2.47.3
next prev parent reply other threads:[~2026-10-06 8:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 8:58 [PATCH-SERIES qemu-server v2 0/2] hotplug pending: use machine type from running instance to avoid mismatch Fiona Ebner
2026-10-06 8:58 ` [PATCH qemu-server v2 1/2] " Fiona Ebner
2026-10-06 8:58 ` Fiona Ebner [this message]
2026-10-06 12:15 ` [PATCH qemu-server v2 2/2] hotplug pending: only query machine type when actually required Dominik Csapak
2026-10-06 12:17 ` [PATCH-SERIES qemu-server v2 0/2] hotplug pending: use machine type from running instance to avoid mismatch Dominik Csapak
2026-10-06 12:33 ` applied: " Fiona Ebner
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=20261006085936.30542-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox