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

[libvirt] [PATCH] qemu: qxl devices don't support multifunction yet



This is a workaround for QXL bug RHBZ#728174.
---
 src/qemu/qemu_command.c                            |   33 +++++++++++---------
 .../qemuxml2argv-graphics-spice-qxl-vga.args       |    2 +-
 tests/qemuxml2argvtest.c                           |    3 +-
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c7c183a..1bb136d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1350,7 +1350,8 @@ qemuUsbId(virBufferPtr buf, int idx)
 static int
 qemuBuildDeviceAddressStr(virBufferPtr buf,
                           virDomainDeviceInfoPtr info,
-                          virBitmapPtr qemuCaps)
+                          virBitmapPtr qemuCaps,
+                          bool multiFunc)
 {
     if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
         if (info->addr.pci.domain != 0) {
@@ -1389,7 +1390,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
             virBufferAsprintf(buf, ",bus=pci.0");
         else
             virBufferAsprintf(buf, ",bus=pci");
-        if (qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIFUNCTION))
+        if (qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIFUNCTION) && multiFunc)
             virBufferAsprintf(buf, ",multifunction=on,addr=0x%x.0x%x",
                               info->addr.pci.slot, info->addr.pci.function);
         else
@@ -1697,7 +1698,7 @@ qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
             virBufferAsprintf(&opt, ",event_idx=%s",
                               virDomainVirtioEventIdxTypeToString(disk->event_idx));
         }
-        qemuBuildDeviceAddressStr(&opt, &disk->info, qemuCaps);
+        qemuBuildDeviceAddressStr(&opt, &disk->info, qemuCaps, true);
         break;
     case VIR_DOMAIN_DISK_BUS_USB:
         virBufferAddLit(&opt, "usb-storage");
@@ -1776,7 +1777,7 @@ qemuBuildFSDevStr(virDomainFSDefPtr fs,
     virBufferAsprintf(&opt, ",id=%s", fs->info.alias);
     virBufferAsprintf(&opt, ",fsdev=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
     virBufferAsprintf(&opt, ",mount_tag=%s", fs->dst);
-    qemuBuildDeviceAddressStr(&opt, &fs->info, qemuCaps);
+    qemuBuildDeviceAddressStr(&opt, &fs->info, qemuCaps, true);
 
     if (virBufferError(&opt)) {
         virReportOOMError();
@@ -1904,7 +1905,7 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def,
         goto error;
     }
 
-    if (qemuBuildDeviceAddressStr(&buf, &def->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &def->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2007,7 +2008,7 @@ qemuBuildNicDevStr(virDomainNetDefPtr net,
                       net->mac[0], net->mac[1],
                       net->mac[2], net->mac[3],
                       net->mac[4], net->mac[5]);
-    if (qemuBuildDeviceAddressStr(&buf, &net->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &net->info, qemuCaps, true) < 0)
         goto error;
     if (bootindex && qemuCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
         virBufferAsprintf(&buf, ",bootindex=%d", bootindex);
@@ -2141,7 +2142,7 @@ qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev,
     }
 
     virBufferAsprintf(&buf, "%s,id=%s", model, dev->info.alias);
-    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2165,7 +2166,7 @@ qemuBuildMemballoonDevStr(virDomainMemballoonDefPtr dev,
 
     virBufferAddLit(&buf, "virtio-balloon-pci");
     virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
-    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2191,7 +2192,7 @@ qemuBuildUSBInputDevStr(virDomainInputDefPtr dev,
                       dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
                       "usb-mouse" : "usb-tablet", dev->info.alias);
 
-    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2229,7 +2230,7 @@ qemuBuildSoundDevStr(virDomainSoundDefPtr sound,
         model = "intel-hda";
 
     virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias);
-    if (qemuBuildDeviceAddressStr(&buf, &sound->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &sound->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2272,6 +2273,7 @@ qemuBuildVideoDevStr(virDomainVideoDefPtr video,
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     const char *model = qemuVideoTypeToString(video->type);
+    bool multiFunc = true;
 
     if (!model) {
         qemuReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2291,9 +2293,10 @@ qemuBuildVideoDevStr(virDomainVideoDefPtr video,
 
         /* QEMU accepts bytes for vram_size. */
         virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024);
+        multiFunc = false;
     }
 
-    if (qemuBuildDeviceAddressStr(&buf, &video->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &video->info, qemuCaps, multiFunc) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2350,7 +2353,7 @@ qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev, const char *configfd,
         virBufferAsprintf(&buf, ",configfd=%s", configfd);
     if (dev->bootIndex)
         virBufferAsprintf(&buf, ",bootindex=%d", dev->bootIndex);
-    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2405,7 +2408,7 @@ qemuBuildRedirdevDevStr(virDomainRedirdevDefPtr dev,
                       dev->info.alias,
                       dev->info.alias);
 
-    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2438,7 +2441,7 @@ qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev,
                       dev->source.subsys.u.usb.device,
                       dev->info.alias);
 
-    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
@@ -2475,7 +2478,7 @@ qemuBuildHubDevStr(virDomainHubDefPtr dev,
 
     virBufferAddLit(&buf, "usb-hub");
     virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
-    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps) < 0)
+    if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCaps, true) < 0)
         goto error;
 
     if (virBufferError(&buf)) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
index 18013a5..5cd36f8 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
@@ -4,4 +4,4 @@ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
 /dev/HostVG/QEMUGuest1 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
 x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs -vga \
 qxl -global qxl-vga.vram_size=33554432 -device qxl,id=video1,vram_size=67108864,bus=pci.0,addr=0x4 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,multifunction=on,addr=0x3.0x0
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 335af4a..a453511 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -402,7 +402,8 @@ mymain(void)
     DO_TEST("graphics-spice-qxl-vga", false,
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
             QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
-            QEMU_CAPS_DEVICE_QXL_VGA);
+            QEMU_CAPS_DEVICE_QXL_VGA,
+            QEMU_CAPS_PCI_MULTIFUNCTION);
 
     DO_TEST("input-usbmouse", false, NONE);
     DO_TEST("input-usbtablet", false, NONE);
-- 
1.7.6


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