[PATCH 10/13] qemu: support new pci controller model "pcie-switch-upstream-port"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this is backed by the qemu device x3130-upstream.
---
 src/qemu/qemu_command.c                            | 22 ++++++++++++++++++++++
 .../qemuxml2argv-pcie-switch-upstream-port.args    |  9 +++++++++
 tests/qemuxml2argvtest.c                           |  9 +++++++++
 3 files changed, 40 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.args

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 01ac690..b4df65a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1604,6 +1604,12 @@ qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
                  */
                 flags = VIR_PCI_CONNECT_TYPE_PCIE_ROOT;
                 break;
+            case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
+                /* pcie-switch can only connect to a true
+                 * pcie bus, and can't be hot-plugged.
+                 */
+                flags = VIR_PCI_CONNECT_TYPE_PCIE_ONLY;
+                break;
             default:
                 break;
             }
@@ -2355,6 +2361,12 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
                 /* pcie-root-port can only plug into pcie-root */
                 flags = VIR_PCI_CONNECT_TYPE_PCIE_ROOT;
                 break;
+            case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
+                /* pcie-switch really does need a real PCIe
+                 * port, but it doesn't need to be pcie-root
+                 */
+                flags = VIR_PCI_CONNECT_TYPE_PCIE_ONLY;
+                break;
             default:
                 flags = VIR_PCI_CONNECT_HOTPLUGGABLE | VIR_PCI_CONNECT_TYPE_PCI;
                 break;
@@ -4625,6 +4637,16 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
             virBufferAsprintf(&buf, "ioh3420,port=%d,chassis=%d,id=%s",
                               def->idx, def->idx, def->info.alias);
             break;
+        case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_X3130_UPSTREAM)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("The pcie-switch-upstream-port "
+                                 "(x3130-upstream) controller "
+                                 "is not supported in this QEMU binary"));
+                goto error;
+            }
+            virBufferAsprintf(&buf, "x3130-upstream,id=%s", def->info.alias);
+            break;
         }
         break;
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.args b/tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.args
new file mode 100644
index 0000000..d737b6b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/libexec/qemu-kvm -S -M q35 -m 2048 -smp 2 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \
+-device x3130-upstream,id=pci.3,bus=pcie.0,addr=0x2 \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \
+-device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
+-vga qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=33554432
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 999edff..b15352e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1469,6 +1469,15 @@ mymain(void)
             QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
 
+    DO_TEST("pcie-switch-upstream-port",
+            QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
+            QEMU_CAPS_DEVICE_X3130_UPSTREAM,
+            QEMU_CAPS_DRIVE, QEMU_CAPS_ICH9_AHCI,
+            QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
+
     DO_TEST("hostdev-scsi-lsi", QEMU_CAPS_DRIVE,
             QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
             QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]