render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From 20ee7e81fe4ea6ca051a5a759d0719986aa75ef5 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <20ee7e81fe4ea6ca051a5a759d0719986aa75ef5.1380703761.git.jdenemar@redhat.com>
43fe83
From: Laine Stump <laine@laine.org>
43fe83
Date: Fri, 27 Sep 2013 05:19:45 -0600
43fe83
Subject: [PATCH] qemu: prefer to put a Q35 machine's dmi-to-pci-bridge at
43fe83
 00:1E.0
43fe83
43fe83
This resolves one of the issues listed in:
43fe83
43fe83
   https://bugzilla.redhat.com/show_bug.cgi?id=1003983
43fe83
43fe83
00:1E.0 is the location of this controller on at least some actual Q35
43fe83
hardware, so we try to replicate the placement. The bridge should work
43fe83
just as well in any other location though, so if 00:1E.0 isn't
43fe83
available, just allow it to be auto-assigned anywhere appropriate.
43fe83
43fe83
(cherry picked from commit 386ebb47a5d707829edf0dccf4d80056ca199e63)
43fe83
43fe83
Conflicts:
43fe83
	tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args
43fe83
        - this is a file added upstream, but not present on the
43fe83
          RHEL7.0 branch.
43fe83
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/qemu/qemu_command.c                            | 22 ++++++++++++++++++++++
43fe83
 tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args |  2 +-
43fe83
 tests/qemuxml2argvdata/qemuxml2argv-q35.args       |  2 +-
43fe83
 3 files changed, 24 insertions(+), 2 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
43fe83
index 47bb22a..47b488a 100644
43fe83
--- a/src/qemu/qemu_command.c
43fe83
+++ b/src/qemu/qemu_command.c
43fe83
@@ -2491,6 +2491,28 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
43fe83
                 }
43fe83
             }
43fe83
             break;
43fe83
+
43fe83
+        case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
43fe83
+            if (def->controllers[i]->model == VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE &&
43fe83
+                def->controllers[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
43fe83
+                /* Try to assign this bridge to 00:1E.0 (because that
43fe83
+                * is its standard location on real hardware) unless
43fe83
+                * it's already taken, but don't insist on it.
43fe83
+                */
43fe83
+                memset(&tmp_addr, 0, sizeof(tmp_addr));
43fe83
+                tmp_addr.slot = 0x1E;
43fe83
+                if (!qemuDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
43fe83
+                    if (qemuDomainPCIAddressReserveAddr(addrs, &tmp_addr,
43fe83
+                                                        flags, true, false) < 0)
43fe83
+                        goto cleanup;
43fe83
+                    def->controllers[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
43fe83
+                    def->controllers[i]->info.addr.pci.domain = 0;
43fe83
+                    def->controllers[i]->info.addr.pci.bus = 0;
43fe83
+                    def->controllers[i]->info.addr.pci.slot = 0x1E;
43fe83
+                    def->controllers[i]->info.addr.pci.function = 0;
43fe83
+                }
43fe83
+            }
43fe83
+            break;
43fe83
         }
43fe83
     }
43fe83
 
43fe83
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args
43fe83
index 84428f9..d7e9acc 100644
43fe83
--- a/tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args
43fe83
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root.args
43fe83
@@ -1,5 +1,5 @@
43fe83
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/libexec/qemu-kvm \
43fe83
 -S -M q35 -m 2048 -smp 2 -nographic -nodefaults \
43fe83
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
43fe83
--device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x2 \
43fe83
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
43fe83
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1
43fe83
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35.args b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
43fe83
index 151863e..45e6ec8 100644
43fe83
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35.args
43fe83
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
43fe83
@@ -1,7 +1,7 @@
43fe83
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
43fe83
 /usr/libexec/qemu-kvm -S -M q35 -m 2048 -smp 2 -nographic -nodefaults \
43fe83
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
43fe83
--device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x2 \
43fe83
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
43fe83
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \
43fe83
 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \
43fe83
 -device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
43fe83
-- 
43fe83
1.8.3.2
43fe83