[Spice-devel] [PATCH 9/9] remove un-connected shared CD devices upon usb-device-widget construction
alexander at daynix.com
alexander at daynix.com
Thu Dec 5 17:49:15 UTC 2019
From: Alexander Nezhinsky <anezhins at redhat.com>
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 at redhat.com>
---
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
More information about the Spice-devel
mailing list