[PATCH 1/5] domaincaps: Report graphics type enum

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

 



Requires adding the plumbing for <device><graphics>
Wire it up for qemu too
---
I stuck the <graphics> element between <disk> and <hostdev> to match
the ordering in <domain> XML

 docs/formatdomaincaps.html.in                      | 30 +++++++++++++++++++++-
 docs/schemas/domaincaps.rng                        |  8 ++++++
 src/conf/domain_capabilities.c                     | 13 ++++++++++
 src/conf/domain_capabilities.h                     |  8 ++++++
 src/qemu/qemu_capabilities.c                       | 22 +++++++++++++++-
 tests/domaincapsschemadata/domaincaps-basic.xml    |  1 +
 tests/domaincapsschemadata/domaincaps-full.xml     |  9 +++++++
 .../domaincaps-qemu_1.6.50-1.xml                   |  7 +++++
 .../domaincaps-qemu_2.6.0-1.xml                    |  7 +++++
 .../domaincaps-qemu_2.6.0-2.xml                    |  6 +++++
 .../domaincaps-qemu_2.6.0-3.xml                    |  6 +++++
 .../domaincaps-qemu_2.6.0-4.xml                    |  6 +++++
 .../domaincaps-qemu_2.6.0-5.xml                    |  6 +++++
 tests/domaincapstest.c                             |  4 +++
 14 files changed, 131 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomaincaps.html.in b/docs/formatdomaincaps.html.in
index edbb948..52e4463 100644
--- a/docs/formatdomaincaps.html.in
+++ b/docs/formatdomaincaps.html.in
@@ -175,7 +175,7 @@
     <code>floppy</code>, or <code>lun</code>.</p>
 
     <h4><a name="elementsDisks">Hard drives, floppy disks, CDROMs</a></h4>
-    <p>Disk capabilities are exposed under <code>disk</code> element. For
+    <p>Disk capabilities are exposed under the <code>disk</code> element. For
     instance:</p>
 
 <pre>
@@ -216,6 +216,34 @@
       element for a &lt;disk/&gt;.</dd>
     </dl>
 
+
+    <h4><a name="elementsGraphics">Graphical framebuffers</a></h4>
+    <p>Graphics device capabilities are exposed under the
+    <code>graphics</code> element. For instance:</p>
+
+<pre>
+&lt;domainCapabilities&gt;
+  ...
+  &lt;devices&gt;
+    &lt;graphics supported='yes'&gt;
+      &lt;enum name='type'&gt;
+        &lt;value&gt;sdl&lt;/value&gt;
+        &lt;value&gt;vnc&lt;/value&gt;
+        &lt;value&gt;spice&lt;/value&gt;
+      &lt;/enum&gt;
+    &lt;/graphics&gt;
+    ...
+  &lt;/devices&gt;
+&lt;/domainCapabilities&gt;
+</pre>
+
+    <dl>
+      <dt><code>type</code></dt>
+      <dd>Options for the <code>type</code> attribute of the &lt;graphics/&gt;
+      element.</dd>
+    </dl>
+
+
     <h4><a name="elementsHostDev">Host device assignment</a></h4>
     <p>Some host devices can be passed through to a guest (e.g. USB, PCI and
     SCSI). Well, only if the following is enabled:</p>
diff --git a/docs/schemas/domaincaps.rng b/docs/schemas/domaincaps.rng
index 0d2777b..3e82b57 100644
--- a/docs/schemas/domaincaps.rng
+++ b/docs/schemas/domaincaps.rng
@@ -72,6 +72,7 @@
     <element name='devices'>
       <interleave>
         <ref name='disk'/>
+        <ref name='graphics'/>
         <ref name='hostdev'/>
       </interleave>
     </element>
@@ -84,6 +85,13 @@
     </element>
   </define>
 
+  <define name='graphics'>
+    <element name='graphics'>
+      <ref name='supported'/>
+      <ref name='enum'/>
+    </element>
+  </define>
+
   <define name='hostdev'>
     <element name='hostdev'>
       <ref name='supported'/>
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index eb880ae..232acd5 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -247,6 +247,18 @@ virDomainCapsDeviceDiskFormat(virBufferPtr buf,
 
 
 static void
+virDomainCapsDeviceGraphicsFormat(virBufferPtr buf,
+                                  virDomainCapsDeviceGraphicsPtr const graphics)
+{
+    FORMAT_PROLOGUE(graphics);
+
+    ENUM_PROCESS(graphics, type, virDomainGraphicsTypeToString);
+
+    FORMAT_EPILOGUE(graphics);
+}
+
+
+static void
 virDomainCapsDeviceHostdevFormat(virBufferPtr buf,
                                  virDomainCapsDeviceHostdevPtr const hostdev)
 {
@@ -314,6 +326,7 @@ virDomainCapsFormatInternal(virBufferPtr buf,
     virBufferAdjustIndent(buf, 2);
 
     virDomainCapsDeviceDiskFormat(buf, &caps->disk);
+    virDomainCapsDeviceGraphicsFormat(buf, &caps->graphics);
     virDomainCapsDeviceHostdevFormat(buf, &caps->hostdev);
 
     virBufferAdjustIndent(buf, -2);
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index 95afe5e..545ada7 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -69,6 +69,13 @@ struct _virDomainCapsDeviceDisk {
     /* add new fields here */
 };
 
+typedef struct _virDomainCapsDeviceGraphics virDomainCapsDeviceGraphics;
+typedef virDomainCapsDeviceGraphics *virDomainCapsDeviceGraphicsPtr;
+struct _virDomainCapsDeviceGraphics {
+    bool supported;
+    virDomainCapsEnum type;   /* virDomainGraphicsType */
+};
+
 typedef struct _virDomainCapsDeviceHostdev virDomainCapsDeviceHostdev;
 typedef virDomainCapsDeviceHostdev *virDomainCapsDeviceHostdevPtr;
 struct _virDomainCapsDeviceHostdev {
@@ -101,6 +108,7 @@ struct _virDomainCaps {
 
     virDomainCapsOS os;
     virDomainCapsDeviceDisk disk;
+    virDomainCapsDeviceGraphics graphics;
     virDomainCapsDeviceHostdev hostdev;
     /* add new domain devices here */
 
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 30dc33a..c675f9f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4171,6 +4171,23 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
 
 
 static int
+virQEMUCapsFillDomainDeviceGraphicsCaps(virQEMUCapsPtr qemuCaps,
+                                        virDomainCapsDeviceGraphicsPtr dev)
+{
+    dev->supported = true;
+
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL))
+        VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_SDL);
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC))
+        VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_VNC);
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE))
+        VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_SPICE);
+
+    return 0;
+}
+
+
+static int
 virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
                                        virDomainCapsDeviceHostdevPtr hostdev)
 {
@@ -4281,13 +4298,16 @@ virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
     virDomainCapsOSPtr os = &domCaps->os;
     virDomainCapsDeviceDiskPtr disk = &domCaps->disk;
     virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev;
+    virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics;
     int maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, domCaps->machine);
 
     domCaps->maxvcpus = maxvcpus;
 
     if (virQEMUCapsFillDomainOSCaps(qemuCaps, os,
                                     loader, nloader) < 0 ||
-        virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, domCaps->machine, disk) < 0 ||
+        virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps,
+                                            domCaps->machine, disk) < 0 ||
+        virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics) < 0 ||
         virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev) < 0 ||
         virQEMUCapsFillDomainFeatureGICCaps(qemuCaps, domCaps) < 0)
         return -1;
diff --git a/tests/domaincapsschemadata/domaincaps-basic.xml b/tests/domaincapsschemadata/domaincaps-basic.xml
index 6587d56..f0f0864 100644
--- a/tests/domaincapsschemadata/domaincaps-basic.xml
+++ b/tests/domaincapsschemadata/domaincaps-basic.xml
@@ -6,6 +6,7 @@
   <os supported='no'/>
   <devices>
     <disk supported='no'/>
+    <graphics supported='no'/>
     <hostdev supported='no'/>
   </devices>
   <features>
diff --git a/tests/domaincapsschemadata/domaincaps-full.xml b/tests/domaincapsschemadata/domaincaps-full.xml
index d4f91fa..b3b8855 100644
--- a/tests/domaincapsschemadata/domaincaps-full.xml
+++ b/tests/domaincapsschemadata/domaincaps-full.xml
@@ -39,6 +39,15 @@
         <value>sd</value>
       </enum>
     </disk>
+    <graphics supported='yes'>
+      <enum name='type'>
+        <value>sdl</value>
+        <value>vnc</value>
+        <value>rdp</value>
+        <value>desktop</value>
+        <value>spice</value>
+      </enum>
+    </graphics>
     <hostdev supported='yes'>
       <enum name='mode'>
         <value>subsystem</value>
diff --git a/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml b/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
index 1e73ff1..147424d 100644
--- a/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
+++ b/tests/domaincapsschemadata/domaincaps-qemu_1.6.50-1.xml
@@ -34,6 +34,13 @@
         <value>usb</value>
       </enum>
     </disk>
+    <graphics supported='yes'>
+      <enum name='type'>
+        <value>sdl</value>
+        <value>vnc</value>
+        <value>spice</value>
+      </enum>
+    </graphics>
     <hostdev supported='yes'>
       <enum name='mode'>
         <value>subsystem</value>
diff --git a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-1.xml b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-1.xml
index 244700a..f8f7465 100644
--- a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-1.xml
+++ b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-1.xml
@@ -34,6 +34,13 @@
         <value>usb</value>
       </enum>
     </disk>
+    <graphics supported='yes'>
+      <enum name='type'>
+        <value>sdl</value>
+        <value>vnc</value>
+        <value>spice</value>
+      </enum>
+    </graphics>
     <hostdev supported='yes'>
       <enum name='mode'>
         <value>subsystem</value>
diff --git a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-2.xml b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-2.xml
index 411c6b7..7913703 100644
--- a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-2.xml
+++ b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-2.xml
@@ -34,6 +34,12 @@
         <value>usb</value>
       </enum>
     </disk>
+    <graphics supported='yes'>
+      <enum name='type'>
+        <value>sdl</value>
+        <value>vnc</value>
+      </enum>
+    </graphics>
     <hostdev supported='yes'>
       <enum name='mode'>
         <value>subsystem</value>
diff --git a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-3.xml b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-3.xml
index 21c59a8..6f30819 100644
--- a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-3.xml
+++ b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-3.xml
@@ -34,6 +34,12 @@
         <value>usb</value>
       </enum>
     </disk>
+    <graphics supported='yes'>
+      <enum name='type'>
+        <value>sdl</value>
+        <value>vnc</value>
+      </enum>
+    </graphics>
     <hostdev supported='yes'>
       <enum name='mode'>
         <value>subsystem</value>
diff --git a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-4.xml b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-4.xml
index c972d5e..6845e92 100644
--- a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-4.xml
+++ b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-4.xml
@@ -34,6 +34,12 @@
         <value>usb</value>
       </enum>
     </disk>
+    <graphics supported='yes'>
+      <enum name='type'>
+        <value>sdl</value>
+        <value>vnc</value>
+      </enum>
+    </graphics>
     <hostdev supported='yes'>
       <enum name='mode'>
         <value>subsystem</value>
diff --git a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-5.xml b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-5.xml
index e4b8c3a..68d88d1 100644
--- a/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-5.xml
+++ b/tests/domaincapsschemadata/domaincaps-qemu_2.6.0-5.xml
@@ -32,6 +32,12 @@
         <value>usb</value>
       </enum>
     </disk>
+    <graphics supported='yes'>
+      <enum name='type'>
+        <value>sdl</value>
+        <value>vnc</value>
+      </enum>
+    </graphics>
     <hostdev supported='yes'>
       <enum name='mode'>
         <value>subsystem</value>
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index ee78555..6bef682 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -61,6 +61,7 @@ fillAllCaps(virDomainCapsPtr domCaps)
     virDomainCapsOSPtr os = &domCaps->os;
     virDomainCapsLoaderPtr loader = &os->loader;
     virDomainCapsDeviceDiskPtr disk = &domCaps->disk;
+    virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics;
     virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev;
     domCaps->maxvcpus = 255;
 
@@ -79,6 +80,9 @@ fillAllCaps(virDomainCapsPtr domCaps)
     SET_ALL_BITS(disk->diskDevice);
     SET_ALL_BITS(disk->bus);
 
+    graphics->supported = true;
+    SET_ALL_BITS(graphics->type);
+
     hostdev->supported = true;
     SET_ALL_BITS(hostdev->mode);
     SET_ALL_BITS(hostdev->startupPolicy);
-- 
2.7.4

--
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]