[PATCH shared-cd v1 8/9] auto-connect shared CD devices added using command line

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

 



From: Alexander Nezhinsky <anezhins@xxxxxxxxxx>

Turn shared CD devices added using command line into hot-plugged devices
which are redirected according to 'auto-connect' filter rules.

Shared CD devices have special lifecycle requirements: they are always
auto-redirected after being created and always destroyed after being
disconnected. Thus the intermediate state of an existing but not connected
device, which is normal for the physical devices, is not supported for
emulated shared CDs.

For the devices added using the corresponding command line options it
means that they should be auto-connected on the viewer start.

By default command line devices are added using 'redirect-on-connect' filter,
which do not fit the shared CD connecting requirements above.

Signed-off-by: Alexander Nezhinsky <anezhins@xxxxxxxxxx>
---
 src/usb-device-manager.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index f5ff54c..1d0f657 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -889,11 +889,9 @@ static void spice_usb_device_manager_check_redir_on_connect(
     GTask *task;
     SpiceUsbDevice *device;
     SpiceUsbBackendDevice *bdev;
+    gboolean is_cd, shall_redirect;
     guint i;
 
-    if (priv->redirect_on_connect == NULL)
-        return;
-
     for (i = 0; i < priv->devices->len; i++) {
         device = g_ptr_array_index(priv->devices, i);
 
@@ -901,10 +899,23 @@ static void spice_usb_device_manager_check_redir_on_connect(
             continue;
 
         bdev = spice_usb_device_manager_device_to_bdev(self, device);
-        if (spice_usb_backend_device_check_filter(
-                            bdev,
-                            priv->redirect_on_connect_rules,
-                            priv->redirect_on_connect_rules_count) == 0) {
+        is_cd = spice_usb_device_manager_is_device_shared_cd(self, device);
+
+        if (priv->redirect_on_connect) {
+            shall_redirect = !spice_usb_backend_device_check_filter(
+                                bdev,
+                                priv->redirect_on_connect_rules,
+                                priv->redirect_on_connect_rules_count);
+        } else if (is_cd) {
+            shall_redirect = !spice_usb_backend_device_check_filter(
+                                bdev,
+                                priv->auto_conn_filter_rules,
+                                priv->auto_conn_filter_rules_count);
+        } else {
+            shall_redirect = FALSE;
+        }
+
+        if (shall_redirect) {
             /* Note: re-uses spice_usb_device_manager_connect_device_async's
                completion handling code! */
             task = g_task_new(self,
-- 
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]