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

Frediano Ziglio fziglio at redhat.com
Fri Dec 6 10:32:56 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>

This patch and code seems to indicate a workaround for a bug in
the implementation.

> ---
>  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);

Frediano



More information about the Spice-devel mailing list