From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 1A6091FF0B2 for ; Tue, 08 Sep 2026 15:57:52 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 68F1D215FE; Tue, 08 Sep 2026 15:57:36 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3 5/8] hotplug: don't try to hotplug bridges Date: Tue, 8 Sep 2026 15:52:05 +0200 Message-ID: <20260908135729.3869365-6-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260908135729.3869365-1-d.csapak@proxmox.com> References: <20260908135729.3869365-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.507 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: 3VGDQL4LWCWH4WNLYYBAMHKU7EZ7HL5A X-Message-ID-Hash: 3VGDQL4LWCWH4WNLYYBAMHKU7EZ7HL5A X-MailFrom: d.csapak@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: While bridges can be hotplugged (on PCI on i440fx), no device can be hotplugged in that afterwards. For that to work the SHPC option would have to be enabled and the guest must support that. Since this is not guaranteed to work and bridges don't show up in our config, this could lead to bridges added that are not represented in the config. To be on the safe side, simply don't allow hotplugging bridges at all. Luckily, the only bridge we ever tried hotplugging (since machine version 2.3) was pci.4 which only houses scsihw2/3/4 at the moment. These are only used for scsiX where X > 13 and only if the scsihw is an LSI controller, so not very likely to occur. This fixes an issue where trying to hotplug a scsi disk with index >=14 on a i440fx machine with an LSI scsi controller would leave the bridge around after failing to add the scsi controller, and the machine would subsequently crash on live migration. Fixes: 2513b862 (fix #2566: increase scsi limit to 31) Signed-off-by: Dominik Csapak --- src/PVE/QemuServer.pm | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index ce3eea4d..fbb0a23e 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -3899,13 +3899,11 @@ sub vm_devices_list { sub vm_deviceplug { my ($storecfg, $conf, $vmid, $deviceid, $device, $arch, $machine_type) = @_; - my $q35 = PVE::QemuServer::Machine::machine_type_is_q35($conf); - my $devices_list = vm_devices_list($vmid); return 1 if defined($devices_list->{$deviceid}); - # add PCI bridge if we need it for the device - qemu_add_pci_bridge($storecfg, $conf, $vmid, $deviceid, $arch, $machine_type); + # we can't hotplug bridges, so check if the necessary one exists + assert_pci_bridge_present($vmid, $deviceid); if ($deviceid eq 'tablet') { qemu_deviceadd($vmid, print_tabletdevice_full($conf, $arch)); @@ -3992,13 +3990,6 @@ sub vm_deviceplug { warn $@ if $@; die $err; } - } elsif (!$q35 && $deviceid =~ m/^(pci\.)(\d+)$/) { - my $bridgeid = $2; - my $pciaddr = print_pci_addr($deviceid, undef, $arch); - my $devicefull = "pci-bridge,id=pci.$bridgeid,chassis_nr=$bridgeid$pciaddr"; - - qemu_deviceadd($vmid, $devicefull); - qemu_deviceaddverify($vmid, $deviceid); } else { die "can't hotplug device '$deviceid'\n"; } @@ -4215,8 +4206,8 @@ sub qemu_deletescsihw { return 1; } -sub qemu_add_pci_bridge { - my ($storecfg, $conf, $vmid, $device, $arch, $machine_type) = @_; +sub assert_pci_bridge_present { + my ($vmid, $device) = @_; my $bridgeid = PVE::QemuServer::PCI::get_pci_bridge_for_device($device); return 1 if !defined($bridgeid) || $bridgeid < 1; @@ -4225,7 +4216,7 @@ sub qemu_add_pci_bridge { my $devices_list = vm_devices_list($vmid); if (!defined($devices_list->{$bridge})) { - vm_deviceplug($storecfg, $conf, $vmid, $bridge, $arch, $machine_type); + die "can't hotplug bridge necessary for '$device'\n"; } return 1; -- 2.47.3