From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id C17371FF0B2 for ; Tue, 08 Sep 2026 15:57:59 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D153C21632; Tue, 08 Sep 2026 15:57:36 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3 0/8] pci: bridges: cleanup and hotplug fix Date: Tue, 8 Sep 2026 15:52:00 +0200 Message-ID: <20260908135729.3869365-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.509 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: BXEVCF3AOS4HFXAP4MLGUAJTMMUQFWIT X-Message-ID-Hash: BXEVCF3AOS4HFXAP4MLGUAJTMMUQFWIT 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: Main motivation for this series was a defect in how we handle hotplugging certain devices: When e.g. adding scsi15 on a vm with i440fx + lsi controller, we'd need scsihw2 (since only 7 devices can live on scsihw0 and scsihw1 respectively) which sits on bus pci.4. This itself is not added by default to the config, so we tried to hotplug the bridge. This works, but without SHPC (which is neither the default, nor does it work reliably in all guests) one cannot hot-plug anything into a hot-plugged bridge. So when hotplugging scsi15 in this example, we'd hot-plug pci.4, but adding scsihw2 would fail and leave the disk in 'pending'. When now a live-migration is initiated, the already added bridge is never recorded in the config, and the guest crashes on the remote after it's resumed. Since this is a rather narrow case, I'd opted for preventing hot-plugging bridges completely. This version adds a few more cleanup/maintenance patches and tests, but they should be relatively self-explaining. changes from v2: * rebase on master * improve wording and commit message/subject * add new tests and factor out some changes * rename qemu_add_pci_bridges to assert_pci_bridge_present and remove its now unneeded parameters (and the unnecessary variable in the vm_deviceplug) * rename get_bridges to get_pci_bridges to make it clear its virtual hardware related * rename get_bridge_for device to get_pci_bridge_for_device to be consistent * new patch that increases the minimum machine version to 5.0 (was already technically enforced by qemu, just not by our code) * new patch to add pci.4 by default starting with machine version 11.1 * surely some things i forgot to write down... changes from v1: * updated a few callsites of methods which removed the bridges parameter which i originally forgot (used 'undef' as that parameter) * added a fixes trailer for the hotplug commit * use hostpci_fmt schema to check legacy-igd. parsing twice is not optimal, but it's only 16 lines and we can improve upon that later too Dominik Csapak (8): tests: cfg2cmd: add test for ivshmem with q35 tests: cfg2cmd: add q35 + win7 + hostpci test code cleanup: pci: don't export print_pcie_root_port code cleanup: hot-plug: simplify getting bridge for device hotplug: don't try to hotplug bridges cfg2cmd: reject guests with machine version below 5.0 cfg2cmd: pci: add bridges to device list up front cfg2cmd: pci: add pci.4 by default starting with machine version 11.1 src/PVE/QemuServer.pm | 134 ++++++------------ src/PVE/QemuServer/Drive.pm | 2 +- src/PVE/QemuServer/DriveDevice.pm | 23 ++- src/PVE/QemuServer/PCI.pm | 68 ++++++++- src/PVE/QemuServer/RNG.pm | 4 +- src/PVE/QemuServer/USB.pm | 8 +- src/test/cfg2cmd/efi-raw-old.conf | 4 +- src/test/cfg2cmd/efi-raw-old.conf.cmd | 4 +- src/test/cfg2cmd/linux-bridges-qemu-11.1.conf | 14 ++ .../cfg2cmd/linux-bridges-qemu-11.1.conf.cmd | 36 +++++ .../old-unsupported-machine-version.conf | 4 + src/test/cfg2cmd/pinned-version-pxe-pve.conf | 2 +- .../cfg2cmd/pinned-version-pxe-pve.conf.cmd | 2 +- src/test/cfg2cmd/pinned-version.conf | 2 +- src/test/cfg2cmd/pinned-version.conf.cmd | 4 +- src/test/cfg2cmd/q35-linux-ivshmem.conf | 13 ++ src/test/cfg2cmd/q35-linux-ivshmem.conf.cmd | 35 +++++ src/test/cfg2cmd/q35-usb13-error.conf | 2 +- src/test/cfg2cmd/q35-usb2.conf | 2 +- src/test/cfg2cmd/q35-usb2.conf.cmd | 4 +- src/test/cfg2cmd/q35-usb3.conf | 2 +- src/test/cfg2cmd/q35-usb3.conf.cmd | 4 +- src/test/cfg2cmd/q35-win7-hostpci.conf | 17 +++ src/test/cfg2cmd/q35-win7-hostpci.conf.cmd | 37 +++++ src/test/cfg2cmd/spice-enhancments.conf | 2 +- src/test/cfg2cmd/spice-enhancments.conf.cmd | 4 +- ...ce-linux-4.1.conf => spice-linux-5.0.conf} | 2 +- ...-4.1.conf.cmd => spice-linux-5.0.conf.cmd} | 2 +- src/test/cfg2cmd/spice-usb3.conf | 2 +- src/test/cfg2cmd/spice-usb3.conf.cmd | 4 +- src/test/cfg2cmd/spice-win.conf | 2 +- src/test/cfg2cmd/spice-win.conf.cmd | 2 +- src/test/cfg2cmd/usb13-error.conf | 2 +- 33 files changed, 316 insertions(+), 133 deletions(-) create mode 100644 src/test/cfg2cmd/linux-bridges-qemu-11.1.conf create mode 100644 src/test/cfg2cmd/linux-bridges-qemu-11.1.conf.cmd create mode 100644 src/test/cfg2cmd/old-unsupported-machine-version.conf create mode 100644 src/test/cfg2cmd/q35-linux-ivshmem.conf create mode 100644 src/test/cfg2cmd/q35-linux-ivshmem.conf.cmd create mode 100644 src/test/cfg2cmd/q35-win7-hostpci.conf create mode 100644 src/test/cfg2cmd/q35-win7-hostpci.conf.cmd rename src/test/cfg2cmd/{spice-linux-4.1.conf => spice-linux-5.0.conf} (92%) rename src/test/cfg2cmd/{spice-linux-4.1.conf.cmd => spice-linux-5.0.conf.cmd} (97%) -- 2.47.3