mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
conf: gfx: egl-headless: Introduce a new <gl> subelement
Unlike with SPICE and SDL which use the <gl> subelement to enable OpenGL acceleration, specifying egl-headless graphics in the XML has essentially the same meaning, thus in case of egl-headless we don't have a need for the 'enable' element attribute and we'll only be interested in the 'rendernode' one further down the road. Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
0a75de2219
commit
5f931fe391
@ -6704,12 +6704,17 @@ qemu-kvm -net nic,model=? /dev/null
|
||||
the other types, for practical reasons it should be paired with
|
||||
either <code>vnc</code> or <code>spice</code> graphics types.
|
||||
This display type is only supported by QEMU domains
|
||||
(needs QEMU <span class="since">2.10</span> or newer) and doesn't
|
||||
accept any attributes.
|
||||
(needs QEMU <span class="since">2.10</span> or newer).
|
||||
<span class="Since">5.0.0</span> this element accepts a
|
||||
<code><gl/></code> sub-element with an optional attribute
|
||||
<code>rendernode</code> which can be used to specify an absolute
|
||||
path to a host's DRI device to be used for OpenGL rendering.
|
||||
</p>
|
||||
<pre>
|
||||
<graphics type='spice' autoport='yes'/>
|
||||
<graphics type='egl-headless'/>
|
||||
<graphics type='egl-headless'>
|
||||
<gl rendernode='/dev/dri/renderD128'/>
|
||||
</graphics>
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
|
@ -3418,9 +3418,20 @@
|
||||
</attribute>
|
||||
</optional>
|
||||
</group>
|
||||
<attribute name="type">
|
||||
<value>egl-headless</value>
|
||||
</attribute>
|
||||
<group>
|
||||
<attribute name="type">
|
||||
<value>egl-headless</value>
|
||||
</attribute>
|
||||
<optional>
|
||||
<element name="gl">
|
||||
<optional>
|
||||
<attribute name="rendernode">
|
||||
<ref name="absFilePath"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
</element>
|
||||
</optional>
|
||||
</group>
|
||||
</choice>
|
||||
</element>
|
||||
</define>
|
||||
|
@ -14074,6 +14074,24 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainGraphicsDefParseXMLEGLHeadless(virDomainGraphicsDefPtr def,
|
||||
xmlNodePtr node,
|
||||
xmlXPathContextPtr ctxt)
|
||||
{
|
||||
xmlNodePtr save = ctxt->node;
|
||||
xmlNodePtr glNode;
|
||||
|
||||
ctxt->node = node;
|
||||
|
||||
if ((glNode = virXPathNode("./gl", ctxt)))
|
||||
def->data.egl_headless.rendernode = virXMLPropString(glNode,
|
||||
"rendernode");
|
||||
ctxt->node = save;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Parse the XML definition for a graphics device */
|
||||
static virDomainGraphicsDefPtr
|
||||
virDomainGraphicsDefParseXML(xmlNodePtr node,
|
||||
@ -14123,6 +14141,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
|
||||
goto error;
|
||||
break;
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
|
||||
if (virDomainGraphicsDefParseXMLEGLHeadless(def, node, ctxt) < 0)
|
||||
goto error;
|
||||
break;
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
||||
break;
|
||||
}
|
||||
@ -26852,6 +26873,20 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
|
||||
if (!def->data.egl_headless.rendernode)
|
||||
break;
|
||||
|
||||
if (!children) {
|
||||
virBufferAddLit(buf, ">\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
children = true;
|
||||
}
|
||||
|
||||
virBufferAddLit(buf, "<gl");
|
||||
virBufferEscapeString(buf, " rendernode='%s'",
|
||||
def->data.egl_headless.rendernode);
|
||||
virBufferAddLit(buf, "/>\n");
|
||||
break;
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
||||
break;
|
||||
}
|
||||
@ -30938,7 +30973,13 @@ virDomainGraphicsDefHasOpenGL(const virDomainDef *def)
|
||||
bool
|
||||
virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics)
|
||||
{
|
||||
return graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
|
||||
bool ret = false;
|
||||
|
||||
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE ||
|
||||
graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS)
|
||||
ret = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -30953,6 +30994,8 @@ virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics)
|
||||
ret = graphics->data.spice.rendernode;
|
||||
break;
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS:
|
||||
ret = graphics->data.egl_headless.rendernode;
|
||||
break;
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
|
||||
|
@ -4788,14 +4788,25 @@ static int
|
||||
qemuProcessGraphicsSetupRenderNode(virDomainGraphicsDefPtr graphics,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
char **rendernode = NULL;
|
||||
|
||||
if (!virDomainGraphicsNeedsAutoRenderNode(graphics))
|
||||
return 0;
|
||||
|
||||
/* Don't bother picking a DRM node if QEMU doesn't support it. */
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_RENDERNODE))
|
||||
return 0;
|
||||
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_RENDERNODE))
|
||||
return 0;
|
||||
|
||||
if (!(graphics->data.spice.rendernode = virHostGetDRMRenderNode()))
|
||||
rendernode = &graphics->data.spice.rendernode;
|
||||
} else {
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS_RENDERNODE))
|
||||
return 0;
|
||||
|
||||
rendernode = &graphics->data.egl_headless.rendernode;
|
||||
}
|
||||
|
||||
if (!(*rendernode = virHostGetDRMRenderNode()))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
33
tests/qemuxml2argvdata/graphics-egl-headless-rendernode.xml
Normal file
33
tests/qemuxml2argvdata/graphics-egl-headless-rendernode.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
<currentMemory unit='KiB'>219100</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-i686</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='usb' index='0'/>
|
||||
<controller type='ide' index='0'/>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='egl-headless'>
|
||||
<gl rendernode='/dev/dri/foo'/>
|
||||
</graphics>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -0,0 +1,41 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
<currentMemory unit='KiB'>219100</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-i686</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='usb' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||
</controller>
|
||||
<controller type='ide' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||
</controller>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='egl-headless'>
|
||||
<gl rendernode='/dev/dri/foo'/>
|
||||
</graphics>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1' primary='yes'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||
</video>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -413,6 +413,8 @@ mymain(void)
|
||||
cfg->spiceAutoUnixSocket = false;
|
||||
DO_TEST("graphics-spice-egl-headless", NONE);
|
||||
|
||||
DO_TEST("graphics-egl-headless-rendernode", NONE);
|
||||
|
||||
DO_TEST("input-usbmouse", NONE);
|
||||
DO_TEST("input-usbtablet", NONE);
|
||||
DO_TEST("misc-acpi", NONE);
|
||||
|
Loading…
Reference in New Issue
Block a user