From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 2/2] hotplug pending: only check for USB hoptplug support when actually needed
Date: Mon, 30 Mar 2026 13:09:44 +0200 [thread overview]
Message-ID: <20260330110954.82174-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20260330110954.82174-1-f.ebner@proxmox.com>
In particular, this makes the variables $ostype and $version more
local and, for VMs without and explicit machine version, avoids a
'query-version' QMP call when not actually needed.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer.pm | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 26560122..da2379e0 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -4657,16 +4657,22 @@ sub vmconfig_hotplug_pending {
PVE::QemuConfig->write_config($vmid, $conf);
}
- my $ostype = $conf->{ostype};
- my $version = extract_version($machine_type, get_running_qemu_version($vmid));
my $hotplug_features =
parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
+
+ my $usb_hotplug;
my $usb_was_unplugged = 0;
- my $usb_hotplug =
- $hotplug_features->{usb}
- && min_version($version, 7, 1)
- && defined($ostype)
- && ($ostype eq 'l26' || windows_version($ostype) > 7);
+ my $is_usb_hotplug_supported = sub {
+ return $usb_hotplug if defined($usb_hotplug);
+ my $ostype = $conf->{ostype};
+ my $version = extract_version($machine_type, get_running_qemu_version($vmid));
+ $usb_hotplug =
+ $hotplug_features->{usb}
+ && min_version($version, 7, 1)
+ && defined($ostype)
+ && ($ostype eq 'l26' || windows_version($ostype) > 7) ? 1 : 0;
+ return $usb_hotplug;
+ };
my $cgroup = PVE::QemuServer::CGroup->new($vmid);
my $pending_delete_hash = PVE::QemuConfig->parse_pending_delete($conf->{pending}->{delete});
@@ -4689,7 +4695,7 @@ sub vmconfig_hotplug_pending {
}
} elsif ($opt =~ m/^usb(\d+)$/) {
my $index = $1;
- die "skip\n" if !$usb_hotplug;
+ die "skip\n" if !$is_usb_hotplug_supported->();
vm_deviceunplug($vmid, $conf, "usbredirdev$index"); # if it's a spice port
vm_deviceunplug($vmid, $conf, $opt);
$usb_was_unplugged = 1;
@@ -4760,7 +4766,7 @@ sub vmconfig_hotplug_pending {
}
} elsif ($opt =~ m/^usb(\d+)$/) {
my $index = $1;
- die "skip\n" if !$usb_hotplug;
+ die "skip\n" if !$is_usb_hotplug_supported->();
my $d = eval { parse_property_string('pve-qm-usb', $value) };
my $id = $opt;
if ($d->{host} =~ m/^spice$/i) {
--
2.47.3
next prev parent reply other threads:[~2026-03-30 11:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 11:09 [PATCH-SERIES qemu-server 0/2] hotplug pending: only issue QMP commands related to USB hotplug if " Fiona Ebner
2026-03-30 11:09 ` [PATCH qemu-server 1/2] hotplug pending: only check if USB devices are left when one was unplugged Fiona Ebner
2026-03-30 11:09 ` Fiona Ebner [this message]
2026-03-31 14:29 ` [PATCH-SERIES qemu-server 0/2] hotplug pending: only issue QMP commands related to USB hotplug if actually needed Manuel Federanko
2026-03-31 18:40 ` applied: " 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=20260330110954.82174-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 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.