virt-manager/virtinst/devices/video.py
Andrea Bolognani 1e3de807a6 video: RISC-V virt guests support virtio-gpu
QXL, on the other hand, is still x86-only for some reason.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-04-04 18:57:39 -04:00

65 lines
1.9 KiB
Python

#
# Copyright 2009, 2013 Red Hat, Inc.
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
from .device import Device
from ..xmlbuilder import XMLProperty
class DeviceVideo(Device):
XML_NAME = "video"
@staticmethod
def get_recommended_models(guest):
if guest.conn.is_xen():
return ["xen", "vga"]
if guest.conn.is_qemu() or guest.conn.is_test():
return ["vga", "qxl", "virtio"]
return []
@staticmethod
def pretty_model(model):
if model in ["qxl", "vmvga", "vga"]:
return model.upper()
return model.capitalize()
_XML_PROP_ORDER = ["model", "vram", "heads", "vgamem"]
model = XMLProperty("./model/@type")
vram = XMLProperty("./model/@vram", is_int=True)
vram64 = XMLProperty("./model/@vram64", is_int=True)
ram = XMLProperty("./model/@ram", is_int=True)
heads = XMLProperty("./model/@heads", is_int=True)
vgamem = XMLProperty("./model/@vgamem", is_int=True)
accel3d = XMLProperty("./model/acceleration/@accel3d", is_yesno=True)
##################
# Default config #
##################
@staticmethod
def default_model(guest):
if guest.os.is_pseries():
return "vga"
if guest.os.is_arm_machvirt() or guest.os.is_riscv_virt():
return "virtio"
if guest.conn.is_qemu() and guest.os.is_s390x():
return "virtio"
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