[PATCH 9/9] remove un-connected shared CD devices upon usb-device-widget construction

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

 



From: Alexander Nezhinsky <anezhins@xxxxxxxxxx>

Some corner error scenarios may leave dangling not connected shared CD devices.
As the current flow precludes maintenance of such devices, it may be prudent
to identify and remove them.

Signed-off-by: Alexander Nezhinsky <anezhins@xxxxxxxxxx>
---
 src/usb-device-widget.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index 724b7b5..6e8150c 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -295,9 +295,19 @@ static void spice_usb_device_widget_constructed(GObject *gobject)
 
     devices = spice_usb_device_manager_get_devices(priv->manager);
     if (devices != NULL) {
+        SpiceUsbDevice *device;
         int i;
+
         for (i = 0; i < devices->len; i++) {
-            device_added_cb(NULL, g_ptr_array_index(devices, i), self);
+            device = g_ptr_array_index(devices, i);
+
+            if (spice_usb_device_manager_is_device_shared_cd(priv->manager, device) &&
+                !spice_usb_device_manager_is_device_connected(priv->manager, device)) {
+                spice_usb_device_manager_remove_shared_cd_device(priv->manager, device, NULL);
+                continue;
+            }
+
+            device_added_cb(NULL, device, self);
         }
 
         g_ptr_array_unref(devices);
-- 
2.20.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]