[Spice-devel] [spice-gtk] usb: Don't use GUdevClient::redirecting on Linux

Christophe Fergeau cfergeau at redhat.com
Fri Jul 1 09:31:06 UTC 2016


On Windows, spice-gtk implements a fake GUdevClient class which has a
'redirecting' property, but this property does not use on linux when
libgudev is used. This causes runtime warnings on Linux when using the
gudev backend USB redirection (nowadays libusb hotplug API is preferred
over gudev).

(virt-viewer:3714): GLib-GObject-WARNING **: g_object_get_valist: object
class 'GUdevClient' has no property named 'redirecting'

This commit fixes this by only using GUdevClient::redirecting on
Windows.
---
 src/usb-device-manager.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 53505fa..a579921 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -121,13 +121,14 @@ struct _SpiceUsbDeviceManagerPrivate {
     GUdevClient *udev;
     libusb_device **coldplug_list; /* Avoid needless reprobing during init */
 #else
-    gboolean redirecting; /* Handled by GUdevClient in the gudev case */
     libusb_hotplug_callback_handle hp_handle;
 #endif
 #ifdef G_OS_WIN32
     usbdk_api_wrapper     *usbdk_api;
     HANDLE                 usbdk_hider_handle;
     SpiceWinUsbDriver     *installer;
+#else
+    gboolean redirecting; /* Handled by the fake GUdevClient in the Windows case */
 #endif
     gboolean               use_usbclerk;
 #endif
@@ -220,7 +221,7 @@ G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device,
 static void
 _set_redirecting(SpiceUsbDeviceManager *self, gboolean is_redirecting)
 {
-#ifdef USE_GUDEV
+#ifdef G_OS_WIN32
     g_object_set(self->priv->udev, "redirecting", is_redirecting, NULL);
 #else
     self->priv->redirecting = is_redirecting;
@@ -245,7 +246,7 @@ gboolean spice_usb_device_manager_is_redirecting(SpiceUsbDeviceManager *self)
 {
 #ifdef USE_USBREDIR
 
-#ifdef USE_GUDEV
+#ifdef G_OS_WIN32
     gboolean redirecting;
     g_object_get(self->priv->udev, "redirecting", &redirecting, NULL);
     return redirecting;
-- 
2.7.4



More information about the Spice-devel mailing list