From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 755311FF141 for ; Mon, 30 Mar 2026 13:10:04 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D7B9A1DCC3; Mon, 30 Mar 2026 13:10:30 +0200 (CEST) From: Fiona Ebner 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 Message-ID: <20260330110954.82174-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260330110954.82174-1-f.ebner@proxmox.com> References: <20260330110954.82174-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774868943436 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.495 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 5M22U2RFLSOVCOTW3IQQQ7FCLIB7MEUS X-Message-ID-Hash: 5M22U2RFLSOVCOTW3IQQQ7FCLIB7MEUS X-MailFrom: f.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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