mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
osdict: Turn videomodel check into a function
The previous setup of having an OS register a preferred videomodel is overly simplistic and doesn't cover all our needs. Rework it without any logic change for now, we will alter the logic in subsequent commits.
This commit is contained in:
parent
d1f46a75e7
commit
0759a31acc
@ -507,6 +507,14 @@ class Guest(XMLBuilder):
|
||||
# Guest Dictionary Helper methods #
|
||||
###################################
|
||||
|
||||
def _get_os_object(self):
|
||||
ret = osdict.lookup_os(self.os_variant)
|
||||
if ret is None:
|
||||
ret = osdict.lookup_os("generic")
|
||||
return ret
|
||||
_os_object = property(_get_os_object)
|
||||
|
||||
|
||||
def _lookup_osdict_key(self, key, default):
|
||||
"""
|
||||
Use self.os_variant to find key in OSTYPES
|
||||
@ -960,24 +968,18 @@ class Guest(XMLBuilder):
|
||||
dev.type = "spicevmc"
|
||||
self.add_device(dev)
|
||||
|
||||
def _set_video_defaults(self):
|
||||
def has_spice():
|
||||
for gfx in self.get_devices("graphics"):
|
||||
if gfx.type == gfx.TYPE_SPICE:
|
||||
return True
|
||||
def has_spice(self):
|
||||
for gfx in self.get_devices("graphics"):
|
||||
if gfx.type == gfx.TYPE_SPICE:
|
||||
return True
|
||||
|
||||
if has_spice():
|
||||
def _set_video_defaults(self):
|
||||
if self.has_spice():
|
||||
self._add_spice_channels()
|
||||
self._add_spice_sound()
|
||||
self._add_spice_usbredir()
|
||||
|
||||
if has_spice() and self.os.is_x86():
|
||||
video_model = "qxl"
|
||||
elif self.os.is_ppc64() and self.os.machine == "pseries":
|
||||
video_model = "vga"
|
||||
else:
|
||||
video_model = self._lookup_osdict_key("videomodel", "cirrus")
|
||||
|
||||
video_model = self._os_object.get_videomodel(self) or "cirrus"
|
||||
for video in self.get_devices("video"):
|
||||
if video.model == video.MODEL_DEFAULT:
|
||||
video.model = video_model
|
||||
|
@ -157,6 +157,8 @@ class _OSVariant(object):
|
||||
based on the OS. They should be self explanatory. See guest.py for
|
||||
their usage.
|
||||
"""
|
||||
_os = None
|
||||
|
||||
def __init__(self, name, label, is_type=False,
|
||||
sortby=None, parent=_SENTINEL, typename=_SENTINEL,
|
||||
urldistro=_SENTINEL, supported=_SENTINEL,
|
||||
@ -164,7 +166,7 @@ class _OSVariant(object):
|
||||
acpi=_SENTINEL, apic=_SENTINEL, clock=_SENTINEL,
|
||||
netmodel=_SENTINEL, diskbus=_SENTINEL,
|
||||
inputtype=_SENTINEL, inputbus=_SENTINEL,
|
||||
videomodel=_SENTINEL, virtionet=_SENTINEL,
|
||||
virtionet=_SENTINEL,
|
||||
virtiodisk=_SENTINEL, virtiommio=_SENTINEL,
|
||||
virtioconsole=_SENTINEL, xen_disable_acpi=_SENTINEL,
|
||||
qemu_ga=_SENTINEL, hyperv_features=_SENTINEL):
|
||||
@ -218,7 +220,6 @@ class _OSVariant(object):
|
||||
self.clock = _get_default("clock", clock)
|
||||
|
||||
self.netmodel = _get_default("netmodel", netmodel)
|
||||
self.videomodel = _get_default("videomodel", videomodel)
|
||||
self.diskbus = _get_default("diskbus", diskbus)
|
||||
self.inputtype = _get_default("inputtype", inputtype)
|
||||
self.inputbus = _get_default("inputbus", inputbus)
|
||||
@ -236,6 +237,19 @@ class _OSVariant(object):
|
||||
ignore1 = arch
|
||||
return None
|
||||
|
||||
def get_videomodel(self, guest):
|
||||
if guest.has_spice() and guest.os.is_x86():
|
||||
return "qxl"
|
||||
if guest.os.is_ppc64() and guest.os.machine == "pseries":
|
||||
return "vga"
|
||||
|
||||
if self._os:
|
||||
if self._os.get_short_id() in {"ubuntu13.10", "ubuntu13.04"}:
|
||||
return "vmvga"
|
||||
if _OsVariantOsInfo.is_windows(self._os):
|
||||
return "vga"
|
||||
return None
|
||||
|
||||
|
||||
def _add_type(*args, **kwargs):
|
||||
kwargs["is_type"] = True
|
||||
@ -286,23 +300,6 @@ class _OsVariantOsInfo(_OSVariant):
|
||||
return devs.get_nth(0).get_name()
|
||||
return _SENTINEL
|
||||
|
||||
def _get_videomodel(self):
|
||||
if self._os.get_short_id() in {"ubuntu13.10", "ubuntu13.04"}:
|
||||
return "vmvga"
|
||||
|
||||
if _OsVariantOsInfo.is_windows(self._os):
|
||||
return "vga"
|
||||
|
||||
if self._os.get_distro() == "fedora":
|
||||
return _SENTINEL
|
||||
|
||||
fltr = libosinfo.Filter()
|
||||
fltr.add_constraint("class", "video")
|
||||
devs = self._os.get_all_devices(fltr)
|
||||
if devs.get_length():
|
||||
return devs.get_nth(0).get_name()
|
||||
return _SENTINEL
|
||||
|
||||
def _get_inputtype(self):
|
||||
fltr = libosinfo.Filter()
|
||||
fltr.add_constraint("class", "input")
|
||||
@ -477,7 +474,6 @@ class _OsVariantOsInfo(_OSVariant):
|
||||
hyperv_features = self._is_hyperv_features()
|
||||
virtioconsole = lambda: self._is_virtioconsole()
|
||||
netmodel = lambda: self._get_netmodel()
|
||||
videomodel = lambda: self._get_videomodel()
|
||||
diskbus = lambda: self._get_diskbus()
|
||||
inputtype = lambda: self._get_inputtype()
|
||||
inputbus = lambda: self.get_inputbus()
|
||||
@ -488,7 +484,7 @@ class _OsVariantOsInfo(_OSVariant):
|
||||
urldistro=urldistro, supported=supported,
|
||||
three_stage_install=three_stage_install, acpi=acpi, apic=apic,
|
||||
clock=clock, netmodel=netmodel, diskbus=diskbus,
|
||||
inputtype=inputtype, inputbus=inputbus, videomodel=videomodel,
|
||||
inputtype=inputtype, inputbus=inputbus,
|
||||
virtionet=virtionet, virtiodisk=virtiodisk,
|
||||
virtiommio=virtiommio, virtioconsole=virtioconsole,
|
||||
xen_disable_acpi=xen_disable_acpi, qemu_ga=qemu_ga,
|
||||
@ -511,8 +507,9 @@ class _OsVariantOsInfo(_OSVariant):
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
_add_type("linux", "Linux")
|
||||
_add_type("windows", "Windows", clock="localtime", three_stage_install=True, inputtype="tablet", inputbus="usb", videomodel="vga")
|
||||
_add_type("windows", "Windows", clock="localtime", three_stage_install=True, inputtype="tablet", inputbus="usb")
|
||||
_add_type("solaris", "Solaris", clock="localtime")
|
||||
_add_type("unix", "UNIX")
|
||||
_add_type("other", "Other")
|
||||
|
Loading…
Reference in New Issue
Block a user