From 4208fa53a856826e89ab8c9ad4949e1d5d4f4e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= Date: Tue, 5 Apr 2022 15:37:30 +0200 Subject: [PATCH] Backport 4.x change to default to virtio video driver --- ...-video-Use-virtio-default-more-often.patch | 173 ++++++++++++++++++ virt-manager.spec | 14 +- 2 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 0001-devices-video-Use-virtio-default-more-often.patch diff --git a/0001-devices-video-Use-virtio-default-more-often.patch b/0001-devices-video-Use-virtio-default-more-often.patch new file mode 100644 index 0000000..f310645 --- /dev/null +++ b/0001-devices-video-Use-virtio-default-more-often.patch @@ -0,0 +1,173 @@ +From eea16141b79aeee41986b48b66311da89e504f2f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= +Date: Tue, 5 Apr 2022 15:57:42 +0200 +Subject: [PATCH] devices: video: Use virtio default more often + +--- + .../virt-install-graphics-usb-disable.xml | 2 +- + .../virt-install-kvm-fedoralatest-url.xml | 4 ++-- + .../virt-install-singleton-config-2.xml | 4 ++-- + .../compare/virt-install-x86_64-graphics.xml | 2 +- + virtinst/devices/video.py | 9 +++++++ + virtinst/domcapabilities.py | 24 +++++++++++++++++++ + virtinst/osdict.py | 5 ++++ + 7 files changed, 44 insertions(+), 6 deletions(-) + +diff --git a/tests/data/cli/compare/virt-install-graphics-usb-disable.xml b/tests/data/cli/compare/virt-install-graphics-usb-disable.xml +index d594851..0ffcd26 100644 +--- a/tests/data/cli/compare/virt-install-graphics-usb-disable.xml ++++ b/tests/data/cli/compare/virt-install-graphics-usb-disable.xml +@@ -54,7 +54,7 @@ + + + + + +diff --git a/tests/data/cli/compare/virt-install-kvm-fedoralatest-url.xml b/tests/data/cli/compare/virt-install-kvm-fedoralatest-url.xml +index a55e7ce..9d689de 100644 +--- a/tests/data/cli/compare/virt-install-kvm-fedoralatest-url.xml ++++ b/tests/data/cli/compare/virt-install-kvm-fedoralatest-url.xml +@@ -49,7 +49,7 @@ + + + + + +@@ -106,7 +106,7 @@ + + + + + +diff --git a/tests/data/cli/compare/virt-install-singleton-config-2.xml b/tests/data/cli/compare/virt-install-singleton-config-2.xml +index d524fba..10c8897 100644 +--- a/tests/data/cli/compare/virt-install-singleton-config-2.xml ++++ b/tests/data/cli/compare/virt-install-singleton-config-2.xml +@@ -198,7 +198,7 @@ + + + + + +@@ -442,7 +442,7 @@ + + + + + +diff --git a/tests/data/cli/compare/virt-install-x86_64-graphics.xml b/tests/data/cli/compare/virt-install-x86_64-graphics.xml +index c1b06ca..6121ca3 100644 +--- a/tests/data/cli/compare/virt-install-x86_64-graphics.xml ++++ b/tests/data/cli/compare/virt-install-x86_64-graphics.xml +@@ -48,7 +48,7 @@ + + + + + +diff --git a/virtinst/devices/video.py b/virtinst/devices/video.py +index f938313..585820a 100644 +--- a/virtinst/devices/video.py ++++ b/virtinst/devices/video.py +@@ -38,6 +38,15 @@ class DeviceVideo(Device): + if guest.has_spice() and guest.os.is_x86(): + if guest.has_gl(): + return "virtio" ++ if (guest.lookup_domcaps().supports_video_virtio() and ++ guest.osinfo.supports_virtiogpu()): ++ # When the guest supports it, this is the top preference ++ return "virtio" ++ if (guest.os.is_x86() and ++ guest.has_spice() and ++ guest.lookup_domcaps().supports_video_qxl()): ++ # qxl is only beneficial over regular vga when paired with spice. ++ # The device still may not be available though + return "qxl" + if (guest.is_uefi() and + guest.lookup_domcaps().supports_video_bochs()): +diff --git a/virtinst/domcapabilities.py b/virtinst/domcapabilities.py +index 81f664e..ed01a91 100644 +--- a/virtinst/domcapabilities.py ++++ b/virtinst/domcapabilities.py +@@ -44,6 +44,9 @@ class _CapsBlock(_HasValues): + def enum_names(self): + return [e.name for e in self.enums] + ++ def has_enum(self, name): ++ return name in self.enum_names() ++ + def get_enum(self, name): + for enum in self.enums: + if enum.name == name: +@@ -100,6 +103,7 @@ class _Devices(_CapsBlock): + hostdev = XMLChildProperty(_make_capsblock("hostdev"), is_single=True) + disk = XMLChildProperty(_make_capsblock("disk"), is_single=True) + video = XMLChildProperty(_make_capsblock("video"), is_single=True) ++ graphics = XMLChildProperty(_make_capsblock("graphics"), is_single=True) + + + class _Features(_CapsBlock): +@@ -342,6 +346,26 @@ class DomainCapabilities(XMLBuilder): + models = self.devices.video.get_enum("modelType").get_values() + return bool("bochs" in models) + ++ def supports_video_qxl(self): ++ if not self.devices.video.has_enum("modelType"): ++ # qxl long predates modelType in domcaps, so if it is missing, ++ # use spice support as a rough value ++ return self.supports_graphics_spice() ++ return "qxl" in self.devices.video.get_enum("modelType").get_values() ++ ++ def supports_video_virtio(self): ++ return "virtio" in self.devices.video.get_enum("modelType").get_values() ++ ++ def supports_graphics_spice(self): ++ if not self.devices.graphics.supported: ++ # domcaps is too old, or the driver doesn't advertise graphics ++ # support. Use our pre-existing logic ++ if not self.conn.is_qemu() and not self.conn.is_test(): ++ return False ++ return self.conn.caps.host.cpu.arch in ["i686", "x86_64"] ++ ++ return self.devices.graphics.get_enum("type").has_value("spice") ++ + XML_NAME = "domainCapabilities" + os = XMLChildProperty(_OS, is_single=True) + cpu = XMLChildProperty(_CPU, is_single=True) +diff --git a/virtinst/osdict.py b/virtinst/osdict.py +index 1273b93..1d83823 100644 +--- a/virtinst/osdict.py ++++ b/virtinst/osdict.py +@@ -513,6 +513,11 @@ class _OsVariant(object): + devids = ["http://usb.org/usb/80ee/0021"] + return bool(self._device_filter(devids=devids, extra_devs=extra_devs)) + ++ def supports_virtiogpu(self, extra_devs=None): ++ # virtio1.0-gpu and virtio1.0 ++ devids = ["http://pcisig.com/pci/1af4/1050"] ++ return bool(self._device_filter(devids=devids, extra_devs=extra_devs)) ++ + def supports_virtiodisk(self, extra_devs=None): + # virtio-block and virtio1.0-block + devids = ["http://pcisig.com/pci/1af4/1001", +-- +2.35.1 + diff --git a/virt-manager.spec b/virt-manager.spec index 85df9cd..888d517 100644 --- a/virt-manager.spec +++ b/virt-manager.spec @@ -8,7 +8,7 @@ Name: virt-manager Version: 3.2.0 -Release: 4%{?dist} +Release: 5%{?dist} %global verrel %{version}-%{release} Summary: Desktop tool for managing virtual machines via libvirt @@ -20,6 +20,10 @@ Source0: https://virt-manager.org/download/sources/%{name}/%{name}-%{version}.ta # Fix 'domain not found' race (bz #1901081) Patch0001: 0001-virtinst-Fix-TOCTOU-in-domain-enumeration.patch +# Use virtio as a video adapter by default +# Backport of https://github.com/virt-manager/virt-manager/commit/1ab6dd50bec5e6d8a36b4295b3051045c703402d +Patch0002: 0001-devices-video-Use-virtio-default-more-often.patch + Requires: virt-manager-common = %{verrel} Requires: python3-gobject @@ -103,6 +107,8 @@ machine). %prep %setup -q +%patch0001 -p1 +%patch0002 -p1 %build %if %{default_hvs} @@ -170,6 +176,10 @@ done %changelog +* Tue Apr 05 2022 Frantisek Zatloukal - 3.2.0-5 +- Backport 4.x change to default to virtio video driver +- Works around RHBZ#2063156 and RHBZ#2071226 + * Fri Jul 23 2021 Fedora Release Engineering - 3.2.0-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild @@ -1098,7 +1108,7 @@ done - Disable wizard sensitivity while creating VM * Thu Oct 19 2006 Daniel P. Berrange - 0.2.5-1.fc7 -- Switch to use python-virtinst instead of python-xeninst due to +- Switch to use python-virtinst instead of python-xeninst due to renaming of original package - Disable keyboard accelerators when grabbing mouse to avoid things like Ctrl-W closing the local window, instead of remote window bz 210364