[Spice-devel] [PATCH 8/9] auto-connect shared CD devices added using command line
alexander at daynix.com
alexander at daynix.com
Thu Dec 5 17:49:14 UTC 2019
From: Alexander Nezhinsky <anezhins at redhat.com>
Turn shared CD devices added using command line into hot-plugged devices
which are redirected according to 'auto-connect' filter rules.
By default command line devices are added using 'redirect-on-connect' filter,
which do not fit the shard CD connecting requirements.
Signed-off-by: Alexander Nezhinsky <anezhins at redhat.com>
---
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 0961ef9..a69a346 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_backend_device_get_libdev(bdev) == NULL;
+
+ 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
More information about the Spice-devel
mailing list