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