virtinst: use virtio if spice+gl

Use virtio+accel3d by default whenever spice+gl is chosen. This allows
to easily set up accelerated gpu VM.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2016-03-04 12:31:53 +01:00 committed by Cole Robinson
parent 8ba48f5299
commit ea1bd169c1
4 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,70 @@
<domain type="kvm">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<vmport state="off"/>
</features>
<cpu mode="custom" match="exact">
<model>Opteron_G4</model>
</cpu>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
<model type="virtio"/>
</interface>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<gl enable="yes"/>
<image compression="off"/>
</graphics>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
<target type="virtio" name="org.qemu.guest_agent.0"/>
</channel>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="virtio">
<acceleration accel3d="yes"/>
</model>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>

View File

@ -529,6 +529,13 @@ c.add_compare(""" \
""", "many-devices", compare_check=support.SUPPORT_CONN_RBD_FORMAT)
c.add_compare(""" \
--memory 1024 \
--disk none \
--graphics spice,gl=yes \
""", "spice-gl", compare_check=support.SUPPORT_CONN_VMPORT)
####################################################
# CPU/RAM/numa and other singleton VM config tests #

View File

@ -1183,6 +1183,11 @@ class Guest(XMLBuilder):
if gfx.type == gfx.TYPE_SPICE:
return True
def has_gl(self):
for gfx in self.get_devices("graphics"):
if gfx.gl:
return True
def _set_video_defaults(self):
if self.has_spice():
self._add_spice_channels()
@ -1196,3 +1201,5 @@ class Guest(XMLBuilder):
for video in self.get_devices("video"):
if video.model == video.MODEL_DEFAULT:
video.model = video_model
if video.model == 'virtio' and self.has_gl():
video.accel3d = True

View File

@ -522,7 +522,10 @@ class _OsVariant(object):
return "vmvga"
if guest.has_spice() and guest.os.is_x86():
return "qxl"
if guest.has_gl():
return "virtio"
else:
return "qxl"
if self.is_windows():
return "vga"