2013-03-18 01:06:52 +04:00
#
2013-10-28 00:59:46 +04:00
# Copyright 2009, 2013 Red Hat, Inc.
2013-03-18 01:06:52 +04:00
#
2018-04-04 16:35:41 +03:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 22:00:02 +03:00
# See the COPYING file in the top-level directory.
2013-03-18 01:06:52 +04:00
2018-03-20 19:18:35 +03:00
from . device import Device
2018-03-20 19:27:37 +03:00
from . . xmlbuilder import XMLProperty
2013-03-18 01:06:52 +04:00
2013-04-13 22:34:52 +04:00
2018-03-20 19:18:35 +03:00
class DeviceVideo ( Device ) :
2018-03-21 17:53:34 +03:00
XML_NAME = " video "
2013-03-18 01:06:52 +04:00
2014-12-01 17:56:29 +03:00
_XML_PROP_ORDER = [ " model " , " vram " , " heads " , " vgamem " ]
2018-09-02 00:01:46 +03:00
model = XMLProperty ( " ./model/@type " )
2013-09-19 21:27:30 +04:00
vram = XMLProperty ( " ./model/@vram " , is_int = True )
2017-03-05 22:51:25 +03:00
vram64 = XMLProperty ( " ./model/@vram64 " , is_int = True )
2013-09-19 21:27:30 +04:00
ram = XMLProperty ( " ./model/@ram " , is_int = True )
heads = XMLProperty ( " ./model/@heads " , is_int = True )
2014-12-01 17:56:29 +03:00
vgamem = XMLProperty ( " ./model/@vgamem " , is_int = True )
2016-03-04 14:31:52 +03:00
accel3d = XMLProperty ( " ./model/acceleration/@accel3d " , is_yesno = True )
2018-09-02 00:01:46 +03:00
##################
# Default config #
##################
@staticmethod
def default_model ( guest ) :
if guest . os . is_pseries ( ) :
return " vga "
2019-04-04 13:49:48 +03:00
if guest . os . is_arm_machvirt ( ) or guest . os . is_riscv_virt ( ) :
2018-09-02 00:01:46 +03:00
return " virtio "
2018-12-14 00:39:43 +03:00
if guest . conn . is_qemu ( ) and guest . os . is_s390x ( ) :
return " virtio "
2018-09-02 00:01:46 +03:00
if guest . has_spice ( ) and guest . os . is_x86 ( ) :
if guest . has_gl ( ) :
return " virtio "
return " qxl "
if guest . os . is_hvm ( ) :
if guest . conn . is_qemu ( ) :
return " qxl "
return " vga "
return None
def set_defaults ( self , guest ) :
if not self . model :
self . model = self . default_model ( guest )
if self . model == ' virtio ' and guest . has_gl ( ) :
self . accel3d = True