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

[Xen-devel] [PATCH v2] libxl: spice usbredirection support for upstream qemu



Usage: spiceusbredirection=NUMBER (default=0)

Enables spice usbredirection. It requires an usb controller and creates
NUMBER usbredirection channels for redirection of up to 4 usb devices
from spice client to domU's qemu. The default is disabled (0).

Signed-off-by: Fabio Fantoni <fabio.fantoni@xxxxxxx>
---
 docs/man/xl.cfg.pod.5       |    6 ++++++
 tools/libxl/libxl.h         |   11 +++++++++++
 tools/libxl/libxl_dm.c      |   14 ++++++++++++++
 tools/libxl/libxl_types.idl |    1 +
 tools/libxl/xl_cmdimpl.c    |    2 ++
 5 files changed, 34 insertions(+)

diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
index f768784..8640384 100644
--- a/docs/man/xl.cfg.pod.5
+++ b/docs/man/xl.cfg.pod.5
@@ -1144,6 +1144,12 @@ requires vdagent service installed on domU o.s. to work. 
The default is 0.
 Enables Spice clipboard sharing (copy/paste). It requires spicevdagent
 enabled. The default is false (0).
 
+=item B<spiceusbredirection=NUMBER>
+
+Enables spice usbredirection. It requires an usb controller and creates
+NUMBER usbredirection channels for redirection of up to 4 usb devices
+from spice client to domU's qemu. The default is disabled (0).
+
 =back
 
 =head3 Miscellaneous Emulated Hardware
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index e27308e..5a50421 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -369,6 +369,17 @@
  */
 #define LIBXL_HAVE_SPICE_VDAGENT 1
 
+/*
+ * LIBXL_HAVE_SPICE_USBREDIRECTION
+ *
+ * If defined, then the libxl_spice_info structure will contain an integer type
+ * field: usbredirection. This value defines if Spice usbredirection is enabled
+ * and with how much channels.
+ *
+ * If this is not defined, the Spice usbredirection support is ignored.
+ */
+#define LIBXL_HAVE_SPICE_USBREDIREDIRECTION 1
+
 /* Functions annotated with LIBXL_EXTERNAL_CALLERS_ONLY may not be
  * called from within libxl itself. Callers outside libxl, who
  * do not #include libxl_internal.h, are fine. */
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index e0123b7..204ff29 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -535,6 +535,20 @@ static char ** 
libxl__build_device_model_args_new(libxl__gc *gc,
                     "usbversion parameter is invalid must be between 1 and 3");
                 return NULL;
             }
+
+            if (b_info->u.hvm.spice.usbredirection >= 0 &&
+                b_info->u.hvm.spice.usbredirection < 5) {
+                for (i = 1; i <= b_info->u.hvm.spice.usbredirection; i++)
+                    flexarray_vappend(dm_args, "-chardev", libxl__sprintf(gc,
+                        "spicevmc,name=usbredir,id=usbrc%d", i), "-device",
+                        libxl__sprintf(gc, "usb-redir,chardev=usbrc%d,"
+                        "id=usbrc%d", i, i), NULL);
+            } else {
+                    LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
+                        "usbredirection parameter must be between 1 and 4");
+                    return NULL;
+            }
+
             if (b_info->u.hvm.usbdevice) {
                 flexarray_vappend(dm_args,
                                   "-usbdevice", b_info->u.hvm.usbdevice, NULL);
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 34010ee..7b1b749 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -183,6 +183,7 @@ libxl_spice_info = Struct("spice_info", [
     ("agent_mouse", libxl_defbool),
     ("vdagent",     libxl_defbool),
     ("clipboard_sharing", libxl_defbool),
+    ("usbredirection", integer),
     ])
 
 libxl_sdl_info = Struct("sdl_info", [
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 0be71be..4f82039 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -1499,6 +1499,8 @@ skip_vfb:
                             &b_info->u.hvm.spice.vdagent, 0);
         xlu_cfg_get_defbool(config, "spice_clipboard_sharing",
                             &b_info->u.hvm.spice.clipboard_sharing, 0);
+        if (!xlu_cfg_get_long (config, "spiceusbredirection", &l, 0))
+            b_info->u.hvm.spice.usbredirection = l;
         xlu_cfg_get_defbool(config, "nographic", &b_info->u.hvm.nographic, 0);
         xlu_cfg_get_defbool(config, "gfx_passthru", 
                             &b_info->u.hvm.gfx_passthru, 0);
-- 
1.7.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.