[spice-gtk v3 2/4] usb-redir: pass GError to hotplug registration procedure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In case of possible error the procedure of hotplug
registration does not return error information, just
issues warning to the stderr, so the reason of the problem,
if any, is not visible. Current commit adds GError parameter
to the procedure to return the error details conventionally.

Signed-off-by: Yuri Benditovich <yuri.benditovich@xxxxxxxxxx>
---
 src/usb-backend.c        | 5 ++++-
 src/usb-backend.h        | 3 ++-
 src/usb-device-manager.c | 3 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/usb-backend.c b/src/usb-backend.c
index 3f99739..2a2f9fa 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -446,7 +446,8 @@ void spice_usb_backend_deregister_hotplug(SpiceUsbBackend *be)
 
 gboolean spice_usb_backend_register_hotplug(SpiceUsbBackend *be,
                                             void *user_data,
-                                            usb_hot_plug_callback proc)
+                                            usb_hot_plug_callback proc,
+                                            GError **error)
 {
     int rc;
     const char *desc;
@@ -460,6 +461,8 @@ gboolean spice_usb_backend_register_hotplug(SpiceUsbBackend *be,
     if (rc != LIBUSB_SUCCESS) {
         g_warning("Error initializing USB hotplug support: %s [%i]", desc, rc);
         be->hotplug_callback = NULL;
+        g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
+                    _("Error on USB hotplug detection: %s [%i]"), desc, rc);
         return FALSE;
     }
     return TRUE;
diff --git a/src/usb-backend.h b/src/usb-backend.h
index 6da3981..814da46 100644
--- a/src/usb-backend.h
+++ b/src/usb-backend.h
@@ -60,7 +60,8 @@ gboolean spice_usb_backend_handle_events(SpiceUsbBackend *be);
 void spice_usb_backend_interrupt_event_handler(SpiceUsbBackend *be);
 gboolean spice_usb_backend_register_hotplug(SpiceUsbBackend *be,
                                             void *user_data,
-                                            usb_hot_plug_callback proc);
+                                            usb_hot_plug_callback proc,
+                                            GError **error);
 void spice_usb_backend_deregister_hotplug(SpiceUsbBackend *be);
 
 /* Spice USB backend device API */
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 9300ad2..857d057 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -257,7 +257,8 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
 
     /* Start listening for usb devices plug / unplug */
     if (!spice_usb_backend_register_hotplug(priv->context, self,
-                                            spice_usb_device_manager_hotplug_cb)) {
+                                            spice_usb_device_manager_hotplug_cb,
+                                            err)) {
         return FALSE;
     }
 #ifndef G_OS_WIN32
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]