guest: Set default rendernode= if spice gl requested

Since this is required to work out of the box with qemu:///system
This commit is contained in:
Cole Robinson 2017-11-25 17:23:59 -05:00
parent bd1c6e55ad
commit 5ac933e98a
3 changed files with 18 additions and 6 deletions

View File

@ -235,12 +235,12 @@
<filetransfer enable="yes"/> <filetransfer enable="yes"/>
</graphics> </graphics>
<graphics type="spice"> <graphics type="spice">
<gl enable="yes"/> <gl enable="yes" rendernode="/dev/dri/by-path/pci-0000:00:02.0-render"/>
<image compression="off"/> <image compression="off"/>
<listen type="socket"/> <listen type="socket"/>
</graphics> </graphics>
<graphics type="spice"> <graphics type="spice">
<gl enable="yes"/> <gl enable="yes" rendernode="/dev/dri/by-path/pci-0000:00:02.0-render"/>
<image compression="off"/> <image compression="off"/>
<listen type="none"/> <listen type="none"/>
</graphics> </graphics>

View File

@ -44,7 +44,7 @@
</interface> </interface>
<input type="tablet" bus="usb"/> <input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"> <graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<gl enable="yes"/> <gl enable="yes" rendernode="/dev/dri/by-path/pci-0000:00:02.0-render"/>
<image compression="off"/> <image compression="off"/>
</graphics> </graphics>
<console type="pty"/> <console type="pty"/>

View File

@ -1174,9 +1174,21 @@ class Guest(XMLBuilder):
if dev.image_compression is None: if dev.image_compression is None:
dev.image_compression = "off" dev.image_compression = "off"
if (dev.type == "spice" and dev.gl and if dev.type == "spice" and dev.gl:
not self.conn.check_support(self.conn.SUPPORT_CONN_SPICE_GL)): if not self.conn.check_support(
raise ValueError(_("Host does not support spice GL")) self.conn.SUPPORT_CONN_SPICE_GL):
raise ValueError(_("Host does not support spice GL"))
# If spice GL but rendernode wasn't specified, hardcode
# the first one
if not dev.rendernode and self.conn.check_support(
self.conn.SUPPORT_CONN_SPICE_RENDERNODE):
for nodedev in self.conn.fetch_all_nodedevs():
if (nodedev.device_type != 'drm' or
nodedev.drm_type != 'render'):
continue
dev.rendernode = nodedev.get_devnode().path
break
def _add_spice_channels(self): def _add_spice_channels(self):
if self.skip_default_channel: if self.skip_default_channel: