]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Fix handling of user aliases for default PHB
authorAndrea Bolognani <abologna@redhat.com>
Tue, 16 Jan 2024 16:19:15 +0000 (17:19 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 17 Jan 2024 18:18:20 +0000 (19:18 +0100)
The bus name for the default PHB is always "pci.0".

Fixes: 937f319536723fec57ad472b002a159d0f67a77c
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/pseries-phb-user-alias.ppc64-latest.args

index 15a0ea4081564976c6e73f3db7a0dc434afb2d0b..5c067b8554d1bfaf5647d59cf82f92f54a22ff9b 100644 (file)
@@ -366,9 +366,26 @@ qemuBuildDeviceAddressPCIGetBus(const virDomainDef *domainDef,
             if (virDomainDeviceAliasIsUserAlias(contAlias)) {
                 /* When domain has builtin pci-root controller we don't put it
                  * onto cmd line. Therefore we can't set its alias. In that
-                 * case, use the default one. */
-                if (!qemuDomainIsPSeries(domainDef) &&
-                    cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
+                 * case, use the default one.
+                 *
+                 * Note that we have to check the value of targetIndex here,
+                 * because we need to handle three different cases:
+                 *
+                 *   non-pSeries guest (targetIndex == -1)
+                 *     => must use default alias
+                 *
+                 *   pSeries guest, default PHB (targetIndex == 0)
+                 *     => must use default alias
+                 *
+                 *   pSeries guest, non-default PHB (targetIndex > 0)
+                 *     => can use actual alias
+                 *
+                 * The last one is due to non-default PHBs beind created
+                 * through the spapr-pci-host-bridge device, which supports
+                 * custom device IDs and thus custom bus names.
+                 * */
+                if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT &&
+                    contTargetIndex <= 0) {
                     if (virQEMUCapsHasPCIMultiBus(domainDef))
                         contAlias = "pci.0";
                     else
index e64fc9aa1177a037e18d44594f78909c4c4504c8..8a2be8cf0cab395d790638aa015b63fc9d9d72d6 100644 (file)
@@ -28,7 +28,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -boot strict=on \
 -device '{"driver":"spapr-pci-host-bridge","index":1,"id":"ua-phb1"}' \
 -netdev user,id=hostnet0 \
--device '{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:a2:44:92","bus":"ua-phb0","addr":"0x1"}' \
+-device '{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:a2:44:92","bus":"pci.0","addr":"0x1"}' \
 -netdev user,id=hostnet1 \
 -device '{"driver":"virtio-net-pci","netdev":"hostnet1","id":"net1","mac":"52:54:00:a2:44:93","bus":"ua-phb1.0","addr":"0x1"}' \
 -audiodev '{"id":"audio1","driver":"none"}' \