[Spice-devel] [PATCH] desktop_layout: ignore unconnected video devices

Ian Pilcher arequipeno at gmail.com
Tue Nov 3 20:22:45 UTC 2020


Currently, the Windows agent does not function properly if it detects a
non-QXL video adapter connected to the guest.  See:

   https://gitlab.freedesktop.org/spice/win32/vd_agent/-/issues/15
   https://gitlab.freedesktop.org/spice/win32/vd_agent/-/issues/13

This is true even when the non-QXL adapter does not have any displays
attached, such as when a physical GPU is passed through to the guest for
AI/ML workloads.

With this patch, the agent ignores the presence of unconnected video
outputs and the mouse works as expected.  If a display is connected to
a non-QXL adapter, the behavior is unchanged.  (Tested on Windows 10 Pro
x64.)

---
  vdagent/desktop_layout.cpp | 13 +++++++++++++
  1 file changed, 13 insertions(+)

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index 07074da..8b538a1 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -48,6 +48,16 @@ DesktopLayout::~DesktopLayout()
      delete _display_config;
  }

+static BOOL
+dev_has_monitor(DISPLAY_DEVICE &dev_info)
+{
+    DISPLAY_DEVICE mon_info;
+
+    ZeroMemory(&mon_info, sizeof(mon_info));
+    mon_info.cb = sizeof(mon_info);
+    return EnumDisplayDevices(dev_info.DeviceName, 0, &mon_info, 0);
+}
+
  static bool
  get_next_display(DWORD &dev_id, DISPLAY_DEVICE &dev_info)
  {
@@ -64,6 +74,9 @@ get_next_display(DWORD &dev_id, DISPLAY_DEVICE &dev_info)
          if (wcsstr(dev_info.DeviceString, L"Citrix Indirect Display")) {
              continue;
          }
+        if (!dev_has_monitor(dev_info)) {
+            continue;
+        }
          return true;
      }
      return false;
-- 
2.26.2

-- 
========================================================================
                  In Soviet Russia, Google searches you!
========================================================================



More information about the Spice-devel mailing list