397dc2
From 9a993a7d566b7acdc548c1f0114b99fe17ba3c12 Mon Sep 17 00:00:00 2001
397dc2
Message-Id: <9a993a7d566b7acdc548c1f0114b99fe17ba3c12@dist-git>
397dc2
From: Jonathon Jongsma <jjongsma@redhat.com>
397dc2
Date: Fri, 4 Dec 2020 15:02:42 -0600
397dc2
Subject: [PATCH] qemu: format 'ramfb' attribute for mediated devices
397dc2
MIME-Version: 1.0
397dc2
Content-Type: text/plain; charset=UTF-8
397dc2
Content-Transfer-Encoding: 8bit
397dc2
397dc2
It's possible to use ramfb as the boot display of an assigned vgpu
397dc2
device. This was introduced in 4b95738c, but unfortunately the attribute
397dc2
was not formatted into the xml output for such a device. This patch
397dc2
fixes that oversight and adds a xml2xml test to verify proper behavior.
397dc2
397dc2
https://bugzilla.redhat.com/show_bug.cgi?id=1847791
397dc2
397dc2
(the expected test results were massaged slightly due to the fact that
397dc2
commit 3b8feb4793cef66f5dbfb9bdabe4d40834f1e90e is not present in this
397dc2
build).
397dc2
397dc2
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
397dc2
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
397dc2
Signed-off-by: Ján Tomko <jtomko@redhat.com>
397dc2
Reviewed-by: Ján Tomko <jtomko@redhat.com>
397dc2
(cherry picked from commit c5815b31976f3982d18c7f6c1367ab6e403eb7eb)
397dc2
397dc2
https://bugzilla.redhat.com/show_bug.cgi?id=1876297
397dc2
397dc2
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
397dc2
Message-Id: <20201204210242.822641-2-jjongsma@redhat.com>
397dc2
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
397dc2
---
397dc2
 src/conf/domain_conf.c                        |  3 ++
397dc2
 ...stdev-mdev-display-ramfb.x86_64-latest.xml | 41 +++++++++++++++++++
397dc2
 tests/qemuxml2xmltest.c                       |  1 +
397dc2
 3 files changed, 45 insertions(+)
397dc2
 create mode 100644 tests/qemuxml2xmloutdata/hostdev-mdev-display-ramfb.x86_64-latest.xml
397dc2
397dc2
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
397dc2
index cd5c15f297..c5a0442c6f 100644
397dc2
--- a/src/conf/domain_conf.c
397dc2
+++ b/src/conf/domain_conf.c
397dc2
@@ -27603,6 +27603,9 @@ virDomainHostdevDefFormat(virBufferPtr buf,
397dc2
             if (mdevsrc->display != VIR_TRISTATE_SWITCH_ABSENT)
397dc2
                 virBufferAsprintf(buf, " display='%s'",
397dc2
                                   virTristateSwitchTypeToString(mdevsrc->display));
397dc2
+            if (mdevsrc->ramfb != VIR_TRISTATE_SWITCH_ABSENT)
397dc2
+                virBufferAsprintf(buf, " ramfb='%s'",
397dc2
+                                  virTristateSwitchTypeToString(mdevsrc->ramfb));
397dc2
         }
397dc2
 
397dc2
     }
397dc2
diff --git a/tests/qemuxml2xmloutdata/hostdev-mdev-display-ramfb.x86_64-latest.xml b/tests/qemuxml2xmloutdata/hostdev-mdev-display-ramfb.x86_64-latest.xml
397dc2
new file mode 100644
397dc2
index 0000000000..90c49842a5
397dc2
--- /dev/null
397dc2
+++ b/tests/qemuxml2xmloutdata/hostdev-mdev-display-ramfb.x86_64-latest.xml
397dc2
@@ -0,0 +1,41 @@
397dc2
+<domain type='qemu'>
397dc2
+  <name>QEMUGuest2</name>
397dc2
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
397dc2
+  <memory unit='KiB'>219136</memory>
397dc2
+  <currentMemory unit='KiB'>219136</currentMemory>
397dc2
+  <vcpu placement='static'>1</vcpu>
397dc2
+  <os>
397dc2
+    <type arch='i686' machine='pc'>hvm</type>
397dc2
+    <boot dev='hd'/>
397dc2
+  </os>
397dc2
+  <clock offset='utc'/>
397dc2
+  <on_poweroff>destroy</on_poweroff>
397dc2
+  <on_reboot>restart</on_reboot>
397dc2
+  <on_crash>destroy</on_crash>
397dc2
+  <devices>
397dc2
+    <emulator>/usr/bin/qemu-system-i386</emulator>
397dc2
+    <controller type='usb' index='0' model='piix3-uhci'>
397dc2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
397dc2
+    </controller>
397dc2
+    <controller type='pci' index='0' model='pci-root'/>
397dc2
+    <controller type='ide' index='0'>
397dc2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
397dc2
+    </controller>
397dc2
+    <input type='mouse' bus='ps2'/>
397dc2
+    <input type='keyboard' bus='ps2'/>
397dc2
+    <graphics type='vnc' port='-1' autoport='yes'>
397dc2
+      <listen type='address'/>
397dc2
+    </graphics>
397dc2
+    <video>
397dc2
+      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
397dc2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
397dc2
+    </video>
397dc2
+    <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='on' ramfb='on'>
397dc2
+      <source>
397dc2
+        <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
397dc2
+      </source>
397dc2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
397dc2
+    </hostdev>
397dc2
+    <memballoon model='none'/>
397dc2
+  </devices>
397dc2
+</domain>
397dc2
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
397dc2
index f790bbc6f1..60efcac6c8 100644
397dc2
--- a/tests/qemuxml2xmltest.c
397dc2
+++ b/tests/qemuxml2xmltest.c
397dc2
@@ -524,6 +524,7 @@ mymain(void)
397dc2
             QEMU_CAPS_VFIO_PCI_DISPLAY,
397dc2
             QEMU_CAPS_DEVICE_VFIO_PCI,
397dc2
             QEMU_CAPS_VNC);
397dc2
+    DO_TEST_CAPS_LATEST("hostdev-mdev-display-ramfb");
397dc2
     DO_TEST("pci-rom", NONE);
397dc2
     DO_TEST("pci-rom-disabled", NONE);
397dc2
     DO_TEST("pci-rom-disabled-invalid", NONE);
397dc2
-- 
397dc2
2.29.2
397dc2