All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/7] libxl: create standalone vkb device
@ 2018-07-17 16:07 Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 1/7] libxl: move vkb device to libxl_vkb.c Oleksandr Grytsov
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Oleksandr Grytsov @ 2018-07-17 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Changes since v2:

* fix indentation in libxl__device_vkb_dm_needed
* add LIBXL_HAVE_EXTENDED_VKB define to indicates that libxl__device_vkb
  has extended fields

Oleksandr Grytsov (7):
  libxl: move vkb device to libxl_vkb.c
  libxl: add backend type and id to vkb
  libxl: vkb add list and info functions
  xl: add vkb config parser and CLI
  docs: add vkb device to xl.cfg and xl
  libxl: vkb add extended parameters
  libxl: add LIBXL_HAVE_EXTENDED_VKB define

 docs/man/xl.cfg.pod.5.in    |  64 +++++++
 docs/man/xl.pod.1.in        |  22 +++
 tools/libxl/Makefile        |   2 +-
 tools/libxl/libxl.h         |  26 +++
 tools/libxl/libxl_console.c |  53 ------
 tools/libxl/libxl_create.c  |   3 +
 tools/libxl/libxl_dm.c      |   1 +
 tools/libxl/libxl_types.idl |  29 +++
 tools/libxl/libxl_utils.h   |   3 +
 tools/libxl/libxl_vkb.c     | 342 ++++++++++++++++++++++++++++++++++++
 tools/xl/Makefile           |   2 +-
 tools/xl/xl.h               |   3 +
 tools/xl/xl_cmdtable.c      |  16 ++
 tools/xl/xl_parse.c         | 109 +++++++++++-
 tools/xl/xl_parse.h         |   1 +
 tools/xl/xl_vkb.c           | 161 +++++++++++++++++
 16 files changed, 781 insertions(+), 56 deletions(-)
 create mode 100644 tools/libxl/libxl_vkb.c
 create mode 100644 tools/xl/xl_vkb.c

-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 1/7] libxl: move vkb device to libxl_vkb.c
  2018-07-17 16:07 [PATCH v3 0/7] libxl: create standalone vkb device Oleksandr Grytsov
@ 2018-07-17 16:07 ` Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 2/7] libxl: add backend type and id to vkb Oleksandr Grytsov
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Grytsov @ 2018-07-17 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Logically it is better to move vkb to separate file as vkb device used not only
by vfb and console.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/Makefile        |  2 +-
 tools/libxl/libxl_console.c | 53 ---------------------------------
 tools/libxl/libxl_vkb.c     | 59 +++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 54 deletions(-)
 create mode 100644 tools/libxl/libxl_vkb.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 684db995ca..6da342ed61 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -140,7 +140,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
 			libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
 			libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-			libxl_pvcalls.o libxl_vsnd.o $(LIBXL_OBJS-y)
+			libxl_pvcalls.o libxl_vsnd.o libxl_vkb.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 9a02a23c2a..36d79f5adc 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -638,45 +638,6 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid,
     return rc;
 }
 
-static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
-                                        libxl_device_vkb *vkb, bool hotplug)
-{
-    return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid);
-}
-
-static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
-                                  libxl_device_vkb *vkb,
-                                  libxl__device *device)
-{
-    device->backend_devid = vkb->devid;
-    device->backend_domid = vkb->backend_domid;
-    device->backend_kind = LIBXL__DEVICE_KIND_VKBD;
-    device->devid = vkb->devid;
-    device->domid = domid;
-    device->kind = LIBXL__DEVICE_KIND_VKBD;
-
-    return 0;
-}
-
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
-                         const libxl_asyncop_how *ao_how)
-{
-    AO_CREATE(ctx, domid, ao_how);
-    int rc;
-
-    rc = libxl__device_add(gc, domid, &libxl__vkb_devtype, vkb);
-    if (rc) {
-        LOGD(ERROR, domid, "Unable to add vkb device");
-        goto out;
-    }
-
-out:
-    libxl__ao_complete(egc, ao, rc);
-    return AO_INPROGRESS;
-}
-
-static LIBXL_DEFINE_UPDATE_DEVID(vkb)
-
 static int libxl__device_vfb_setdefault(libxl__gc *gc, uint32_t domid,
                                         libxl_device_vfb *vfb, bool hotplug)
 {
@@ -746,8 +707,6 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid,
 }
 
 /* The following functions are defined:
- * libxl_device_vkb_remove
- * libxl_device_vkb_destroy
  * libxl_device_vfb_remove
  * libxl_device_vfb_destroy
  */
@@ -756,18 +715,6 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid,
  * 1. add support for secondary consoles to xenconsoled
  * 2. dynamically add/remove qemu chardevs via qmp messages. */
 
-/* vkb */
-
-#define libxl__add_vkbs NULL
-#define libxl_device_vkb_list NULL
-#define libxl_device_vkb_compare NULL
-
-LIBXL_DEFINE_DEVICE_REMOVE(vkb)
-
-DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
-    .skip_attach = 1
-);
-
 #define libxl__add_vfbs NULL
 #define libxl_device_vfb_list NULL
 #define libxl_device_vfb_compare NULL
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
new file mode 100644
index 0000000000..7652ad23ce
--- /dev/null
+++ b/tools/libxl/libxl_vkb.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 EPAM Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_internal.h"
+
+static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
+                                        libxl_device_vkb *vkb, bool hotplug)
+{
+    return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid);
+}
+
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+                         const libxl_asyncop_how *ao_how)
+{
+    AO_CREATE(ctx, domid, ao_how);
+    int rc;
+
+    rc = libxl__device_add(gc, domid, &libxl__vkb_devtype, vkb);
+    if (rc) {
+        LOGD(ERROR, domid, "Unable to add vkb device");
+        goto out;
+    }
+
+out:
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
+}
+
+static LIBXL_DEFINE_DEVICE_FROM_TYPE(vkb)
+static LIBXL_DEFINE_UPDATE_DEVID(vkb)
+
+#define libxl__add_vkbs NULL
+#define libxl_device_vkb_list NULL
+#define libxl_device_vkb_compare NULL
+
+LIBXL_DEFINE_DEVICE_REMOVE(vkb)
+
+DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
+    .skip_attach = 1
+);
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 2/7] libxl: add backend type and id to vkb
  2018-07-17 16:07 [PATCH v3 0/7] libxl: create standalone vkb device Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 1/7] libxl: move vkb device to libxl_vkb.c Oleksandr Grytsov
@ 2018-07-17 16:07 ` Oleksandr Grytsov
  2018-07-25  8:31   ` Wei Liu
  2018-07-17 16:07 ` [PATCH v3 3/7] libxl: vkb add list and info functions Oleksandr Grytsov
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: Oleksandr Grytsov @ 2018-07-17 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

New field backend_type is added to vkb device in order to have QEMU and user
space backend simultaneously. Each vkb backend shall read appropriate XS entry
and service only own frontends. Id is a string field which used by the backend
to indentify the frontend.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
---
 tools/libxl/libxl_create.c  |  3 +++
 tools/libxl/libxl_dm.c      |  1 +
 tools/libxl/libxl_types.idl |  8 ++++++++
 tools/libxl/libxl_vkb.c     | 31 ++++++++++++++++++++++++++++++-
 4 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 7d46824eac..1ccb3e35d3 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1421,6 +1421,9 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         for (i = 0; i < d_config->num_vfbs; i++) {
             libxl__device_add(gc, domid, &libxl__vfb_devtype,
                               &d_config->vfbs[i]);
+        }
+
+        for (i = 0; i < d_config->num_vkbs; i++) {
             libxl__device_add(gc, domid, &libxl__vkb_devtype,
                               &d_config->vkbs[i]);
         }
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index bd187463ec..fdd7fa3ba4 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1790,6 +1790,7 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
 
     vkb->backend_domid = 0;
     vkb->devid = 0;
+
     return 0;
 }
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index f1e50a0c0c..c01cf06035 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -247,6 +247,12 @@ libxl_vuart_type = Enumeration("vuart_type", [
     (1, "sbsa_uart"),
     ])
 
+libxl_vkb_backend = Enumeration("vkb_backend", [
+    (0, "UNKNOWN"),
+    (1, "QEMU"),
+    (2, "LINUX")
+    ])
+
 #
 # Complex libxl types
 #
@@ -626,6 +632,8 @@ libxl_device_vkb = Struct("device_vkb", [
     ("backend_domid", libxl_domid),
     ("backend_domname", string),
     ("devid", libxl_devid),
+    ("backend_type", libxl_vkb_backend),
+    ("unique_id", string)
     ])
 
 libxl_device_disk = Struct("device_disk", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 7652ad23ce..e271edc23f 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -14,12 +14,38 @@
 
 #include "libxl_internal.h"
 
+#include <xen/io/kbdif.h>
+
 static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
                                         libxl_device_vkb *vkb, bool hotplug)
 {
+    if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
+        vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
+    }
+
     return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid);
 }
 
+static int libxl__device_vkb_dm_needed(libxl_device_vkb *vkb, uint32_t domid)
+{
+    return vkb->backend_type == LIBXL_VKB_BACKEND_QEMU;
+}
+
+static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid,
+                                   libxl_device_vkb *vkb,
+                                   flexarray_t *back, flexarray_t *front,
+                                   flexarray_t *ro_front)
+{
+    flexarray_append_pair(back, "backend-type",
+                          (char *)libxl_vkb_backend_to_string(vkb->backend_type));
+
+    if (vkb->unique_id) {
+        flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id);
+    }
+
+    return 0;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
                          const libxl_asyncop_how *ao_how)
 {
@@ -47,7 +73,10 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb)
 LIBXL_DEFINE_DEVICE_REMOVE(vkb)
 
 DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
-    .skip_attach = 1
+    .skip_attach = 1,
+    .dm_needed = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed,
+    .set_xenstore_config = (device_set_xenstore_config_fn_t)
+                           libxl__set_xenstore_vkb
 );
 
 /*
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 3/7] libxl: vkb add list and info functions
  2018-07-17 16:07 [PATCH v3 0/7] libxl: create standalone vkb device Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 1/7] libxl: move vkb device to libxl_vkb.c Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 2/7] libxl: add backend type and id to vkb Oleksandr Grytsov
@ 2018-07-17 16:07 ` Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 4/7] xl: add vkb config parser and CLI Oleksandr Grytsov
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Grytsov @ 2018-07-17 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl.h         |  10 +++
 tools/libxl/libxl_types.idl |  11 ++++
 tools/libxl/libxl_utils.h   |   3 +
 tools/libxl/libxl_vkb.c     | 127 +++++++++++++++++++++++++++++++++++-
 4 files changed, 149 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index bfc788594c..919f660c51 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2037,6 +2037,16 @@ int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid,
                              const libxl_asyncop_how *ao_how)
                             LIBXL_EXTERNAL_CALLERS_ONLY;
 
+libxl_device_vkb *libxl_device_vkb_list(libxl_ctx *ctx,
+                                        uint32_t domid, int *num)
+                                        LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_vkb_list_free(libxl_device_vkb* list, int num)
+                                LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vkb_getinfo(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_vkb *vkb,
+                             libxl_vkbinfo *vkbinfo)
+                             LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* Framebuffer */
 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
                          const libxl_asyncop_how *ao_how)
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index c01cf06035..4b4dc9eb5d 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -1046,6 +1046,17 @@ libxl_vsndinfo = Struct("vsndinfo", [
     ("pcms", Array(libxl_pcminfo, "num_vsnd_pcms"))
     ])
 
+libxl_vkbinfo = Struct("vkbinfo", [
+    ("backend", string),
+    ("backend_id", uint32),
+    ("frontend", string),
+    ("frontend_id", uint32),
+    ("devid", libxl_devid),
+    ("state", integer),
+    ("evtch", integer),
+    ("rref", integer)
+    ], dir=DIR_OUT)
+
 # NUMA node characteristics: size and free are how much memory it has, and how
 # much of it is free, respectively. dists is an array of distances from this
 # node to each other node.
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index 5455752c6e..44409afdc4 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -79,6 +79,9 @@ int libxl_devid_to_device_vtpm(libxl_ctx *ctx, uint32_t domid,
 int libxl_devid_to_device_usbctrl(libxl_ctx *ctx, uint32_t domid,
                                   int devid, libxl_device_usbctrl *usbctrl);
 
+int libxl_devid_to_device_vkb(libxl_ctx *ctx, uint32_t domid,
+                              int devid, libxl_device_vkb *vkb);
+
 int libxl_devid_to_device_vdispl(libxl_ctx *ctx, uint32_t domid,
                                  int devid, libxl_device_vdispl *vdispl);
 
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index e271edc23f..1262dbc7bd 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -46,6 +46,45 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid,
     return 0;
 }
 
+static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path,
+                                    libxl_devid devid,
+                                    libxl_device_vkb *vkb)
+{
+    const char *be_path, *be_type, *fe_path;
+    int rc;
+
+    vkb->devid = devid;
+
+    rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+                                  GCSPRINTF("%s/backend", libxl_path),
+                                  &be_path);
+    if (rc) goto out;
+
+    rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+                                  GCSPRINTF("%s/frontend", libxl_path),
+                                  &fe_path);
+    if (rc) goto out;
+
+    rc = libxl__backendpath_parse_domid(gc, be_path, &vkb->backend_domid);
+    if (rc) goto out;
+
+    rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+                                  GCSPRINTF("%s/backend-type", be_path),
+                                  &be_type);
+    if (rc) goto out;
+
+    rc = libxl_vkb_backend_from_string(be_type, &vkb->backend_type);
+    if (rc) goto out;
+
+    vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL);
+
+    rc = 0;
+
+out:
+
+    return rc;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
                          const libxl_asyncop_how *ao_how)
 {
@@ -63,20 +102,104 @@ out:
     return AO_INPROGRESS;
 }
 
+int libxl_devid_to_device_vkb(libxl_ctx *ctx, uint32_t domid,
+                              int devid, libxl_device_vkb *vkb)
+{
+    GC_INIT(ctx);
+
+    libxl_device_vkb *vkbs = NULL;
+    int n, i;
+    int rc;
+
+    libxl_device_vkb_init(vkb);
+
+    vkbs = libxl__device_list(gc, &libxl__vkb_devtype, domid, &n);
+
+    if (!vkbs) { rc = ERROR_NOTFOUND; goto out; }
+
+    for (i = 0; i < n; ++i) {
+        if (devid == vkbs[i].devid) {
+            libxl_device_vkb_copy(ctx, vkb, &vkbs[i]);
+            rc = 0;
+            goto out;
+        }
+    }
+
+    rc = ERROR_NOTFOUND;
+
+out:
+
+    if (vkbs)
+        libxl__device_list_free(&libxl__vkb_devtype, vkbs, n);
+
+    GC_FREE;
+    return rc;
+}
+
+int libxl_device_vkb_getinfo(libxl_ctx *ctx, uint32_t domid,
+                             libxl_device_vkb *vkb,
+                             libxl_vkbinfo *info)
+{
+    GC_INIT(ctx);
+    char *libxl_path, *dompath, *devpath;
+    char *val;
+    int rc;
+
+    libxl_vkbinfo_init(info);
+    dompath = libxl__xs_get_dompath(gc, domid);
+    info->devid = vkb->devid;
+
+    devpath = libxl__domain_device_frontend_path(gc, domid, info->devid,
+                                                 LIBXL__DEVICE_KIND_VKBD);
+    libxl_path = libxl__domain_device_libxl_path(gc, domid, info->devid,
+                                                 LIBXL__DEVICE_KIND_VKBD);
+
+    info->backend = xs_read(ctx->xsh, XBT_NULL,
+                            GCSPRINTF("%s/backend", libxl_path),
+                            NULL);
+    if (!info->backend) { rc = ERROR_FAIL; goto out; }
+
+    rc = libxl__backendpath_parse_domid(gc, info->backend, &info->backend_id);
+    if (rc) goto out;
+
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/state", devpath));
+    info->state = val ? strtoul(val, NULL, 10) : -1;
+
+    info->frontend = xs_read(ctx->xsh, XBT_NULL,
+                             GCSPRINTF("%s/frontend", libxl_path),
+                             NULL);
+    info->frontend_id = domid;
+
+    val = libxl__xs_read(gc, XBT_NULL,
+          GCSPRINTF("%s/"XENKBD_FIELD_EVT_CHANNEL, devpath));
+    info->evtch = val ? strtoul(val, NULL, 10) : -1;
+
+    val = libxl__xs_read(gc, XBT_NULL,
+          GCSPRINTF("%s/"XENKBD_FIELD_RING_GREF, devpath));
+    info->rref = val ? strtoul(val, NULL, 10) : -1;
+
+    rc = 0;
+
+out:
+     GC_FREE;
+     return rc;
+}
+
 static LIBXL_DEFINE_DEVICE_FROM_TYPE(vkb)
 static LIBXL_DEFINE_UPDATE_DEVID(vkb)
 
 #define libxl__add_vkbs NULL
-#define libxl_device_vkb_list NULL
 #define libxl_device_vkb_compare NULL
 
+LIBXL_DEFINE_DEVICE_LIST(vkb)
 LIBXL_DEFINE_DEVICE_REMOVE(vkb)
 
 DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
     .skip_attach = 1,
     .dm_needed = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed,
     .set_xenstore_config = (device_set_xenstore_config_fn_t)
-                           libxl__set_xenstore_vkb
+                           libxl__set_xenstore_vkb,
+    .from_xenstore = (device_from_xenstore_fn_t)libxl__vkb_from_xenstore
 );
 
 /*
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 4/7] xl: add vkb config parser and CLI
  2018-07-17 16:07 [PATCH v3 0/7] libxl: create standalone vkb device Oleksandr Grytsov
                   ` (2 preceding siblings ...)
  2018-07-17 16:07 ` [PATCH v3 3/7] libxl: vkb add list and info functions Oleksandr Grytsov
@ 2018-07-17 16:07 ` Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 5/7] docs: add vkb device to xl.cfg and xl Oleksandr Grytsov
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Grytsov @ 2018-07-17 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/xl/Makefile      |   2 +-
 tools/xl/xl.h          |   3 +
 tools/xl/xl_cmdtable.c |  16 +++++
 tools/xl/xl_parse.c    |  76 ++++++++++++++++++++-
 tools/xl/xl_parse.h    |   1 +
 tools/xl/xl_vkb.c      | 147 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 243 insertions(+), 2 deletions(-)
 create mode 100644 tools/xl/xl_vkb.c

diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index 66bdbdef13..2769295515 100644
--- a/tools/xl/Makefile
+++ b/tools/xl/Makefile
@@ -22,7 +22,7 @@ XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o
 XL_OBJS += xl_sched.o xl_pci.o xl_vcpu.o xl_cdrom.o xl_mem.o
 XL_OBJS += xl_info.o xl_console.o xl_misc.o
 XL_OBJS += xl_vmcontrol.o xl_saverestore.o xl_migrate.o
-XL_OBJS += xl_vdispl.o xl_vsnd.o
+XL_OBJS += xl_vdispl.o xl_vsnd.o xl_vkb.o
 
 $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
 $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index a6b85f6db2..15943f95dd 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -173,6 +173,9 @@ int main_vdispldetach(int argc, char **argv);
 int main_vsndattach(int argc, char **argv);
 int main_vsndlist(int argc, char **argv);
 int main_vsnddetach(int argc, char **argv);
+int main_vkbattach(int argc, char **argv);
+int main_vkblist(int argc, char **argv);
+int main_vkbdetach(int argc, char **argv);
 int main_usbctrl_attach(int argc, char **argv);
 int main_usbctrl_detach(int argc, char **argv);
 int main_usbdev_attach(int argc, char **argv);
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 10426a2ffd..50d3e2e4a3 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -15,6 +15,7 @@
 #include <string.h>
 
 #include <libxl.h>
+
 #include "xl.h"
 
 struct cmd_spec cmd_table[] = {
@@ -380,6 +381,21 @@ struct cmd_spec cmd_table[] = {
       "Destroy a domain's virtual TPM device",
       "<Domain> <DevId|uuid>",
     },
+    { "vkb-attach",
+      &main_vkbattach, 1, 1,
+      "Create a new virtual keyboard device",
+      "<Domain> <vkb-spec-component(s)>...",
+    },
+    { "vkb-list",
+      &main_vkblist, 0, 0,
+      "List virtual keyboard devices for a domain",
+      "<Domain(s)>",
+    },
+    { "vkb-detach",
+      &main_vkbdetach, 0, 1,
+      "Destroy a domain's virtual keyboard device",
+      "<Domain> <DevId>",
+    },
     { "vdispl-attach",
       &main_vdisplattach, 1, 1,
       "Create a new virtual display device",
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index f9147f6a5c..9b7b78c2a1 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -20,6 +20,7 @@
 #include <xen/hvm/e820.h>
 #include <xen/hvm/params.h>
 #include <xen/io/sndif.h>
+#include <xen/io/kbdif.h>
 
 #include <libxl.h>
 #include <libxl_utils.h>
@@ -1095,6 +1096,77 @@ static void parse_vsnd_config(const XLU_Config *config,
     }
 }
 
+int parse_vkb_config(libxl_device_vkb *vkb, char *token)
+{
+    char *oparg;
+
+    if (MATCH_OPTION("backend", token, oparg)) {
+        vkb->backend_domname = strdup(oparg);
+    } else if (MATCH_OPTION("backend-type", token, oparg)) {
+        libxl_vkb_backend backend_type;
+        if (libxl_vkb_backend_from_string(oparg, &backend_type)) {
+            fprintf(stderr, "Unknown backend_type \"%s\" in vkb spec\n",
+                            oparg);
+            return -1;
+        }
+        vkb->backend_type = backend_type;
+    } else if (MATCH_OPTION(XENKBD_FIELD_UNIQUE_ID, token, oparg)) {
+        vkb->unique_id = strdup(oparg);
+    } else {
+        fprintf(stderr, "Unknown string \"%s\" in vkb spec\n", token);
+        return -1;
+    }
+
+    return 0;
+}
+
+static void parse_vkb_list(const XLU_Config *config,
+                           libxl_domain_config *d_config)
+{
+    XLU_ConfigList *vkbs;
+    const char *item;
+    char *buf = NULL;
+    int rc;
+
+    if (!xlu_cfg_get_list (config, "vkb", &vkbs, 0, 0)) {
+        int entry = 0;
+        while ((item = xlu_cfg_get_listitem(vkbs, entry)) != NULL) {
+            libxl_device_vkb *vkb;
+            char *p;
+
+            vkb = ARRAY_EXTEND_INIT(d_config->vkbs,
+                                    d_config->num_vkbs,
+                                    libxl_device_vkb_init);
+
+            buf = strdup(item);
+
+            p = strtok (buf, ",");
+            while (p != NULL)
+            {
+                while (*p == ' ') p++;
+
+                rc = parse_vkb_config(vkb, p);
+                if (rc) goto out;
+
+                p = strtok (NULL, ",");
+            }
+
+            if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
+                fprintf(stderr, "backend-type should be set in vkb spec\n");
+                rc = -1; goto out;
+            }
+
+            entry++;
+        }
+    }
+
+    rc = 0;
+
+out:
+    free(buf);
+    if (rc) exit(EXIT_FAILURE);
+}
+
 void parse_config_data(const char *config_source,
                        const char *config_data,
                        int config_len,
@@ -2577,7 +2649,9 @@ skip_usbdev:
                     "Unknown gic_version \"%s\" specified\n", buf);
             exit(-ERROR_FAIL);
         }
-     }
+    }
+
+    parse_vkb_list(config, d_config);
 
     xlu_cfg_destroy(config);
 }
diff --git a/tools/xl/xl_parse.h b/tools/xl/xl_parse.h
index 9a948ea4f7..bab2861f8c 100644
--- a/tools/xl/xl_parse.h
+++ b/tools/xl/xl_parse.h
@@ -35,6 +35,7 @@ int parse_cpurange(const char *cpu, libxl_bitmap *cpumap);
 int parse_nic_config(libxl_device_nic *nic, XLU_Config **config, char *token);
 int parse_vdispl_config(libxl_device_vdispl *vdispl, char *token);
 int parse_vsnd_item(libxl_device_vsnd *vsnd, const char *spec);
+int parse_vkb_config(libxl_device_vkb *vkb, char *token);
 
 int match_option_size(const char *prefix, size_t len,
                       char *arg, char **argopt);
diff --git a/tools/xl/xl_vkb.c b/tools/xl/xl_vkb.c
new file mode 100644
index 0000000000..dcf828e156
--- /dev/null
+++ b/tools/xl/xl_vkb.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2016 EPAM Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include <stdlib.h>
+
+#include <libxl.h>
+#include <libxl_utils.h>
+#include <libxlutil.h>
+
+#include "xl.h"
+#include "xl_utils.h"
+#include "xl_parse.h"
+
+int main_vkbattach(int argc, char **argv)
+{
+    int opt;
+    int rc;
+    uint32_t domid;
+    libxl_device_vkb vkb;
+
+    SWITCH_FOREACH_OPT(opt, "", NULL, "vkb-attach", 2) {
+        /* No options */
+    }
+
+    libxl_device_vkb_init(&vkb);
+    domid = find_domain(argv[optind++]);
+
+    for (argv += optind, argc -= optind; argc > 0; ++argv, --argc) {
+        rc = parse_vkb_config(&vkb, *argv);
+        if (rc) goto out;
+    }
+
+    if (vkb.backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
+        fprintf(stderr, "backend-type should be set\n");
+        rc = ERROR_FAIL; goto out;
+    }
+
+    if (dryrun_only) {
+        char *json = libxl_device_vkb_to_json(ctx, &vkb);
+        printf("vkb: %s\n", json);
+        free(json);
+        goto out;
+    }
+
+    if (libxl_device_vkb_add(ctx, domid, &vkb, 0)) {
+        fprintf(stderr, "libxl_device_vkb_add failed.\n");
+        rc = ERROR_FAIL; goto out;
+    }
+
+    rc = 0;
+
+out:
+    libxl_device_vkb_dispose(&vkb);
+    return rc;
+}
+
+int main_vkblist(int argc, char **argv)
+{
+    int opt;
+    libxl_device_vkb *vkbs;
+    libxl_vkbinfo vkbinfo;
+    int nb, i;
+
+    SWITCH_FOREACH_OPT(opt, "", NULL, "vkb-list", 1) {
+        /* No options */
+    }
+
+    /*      Idx  BE   Hdl  Sta  evch ref ID    BE-type BE-path */
+    printf("%-3s %-2s %-6s %-5s %-6s %6s %-10s %-10s %-30s\n",
+           "Idx", "BE", "handle", "state", "evt-ch", "ref",
+           "ID", "BE-type", "BE-path");
+    for (argv += optind, argc -= optind; argc > 0; --argc, ++argv) {
+        uint32_t domid = find_domain(*argv);
+        vkbs = libxl_device_vkb_list(ctx, domid, &nb);
+        if (!vkbs) {
+            continue;
+        }
+        for (i = 0; i < nb; ++i) {
+            if (libxl_device_vkb_getinfo(ctx, domid, &vkbs[i], &vkbinfo) == 0) {
+                printf("%-3d %-2d %6d %5d %6d %6d %-10s %-10s %-30s\n",
+                       vkbinfo.devid, vkbinfo.backend_id,
+                       vkbinfo.devid, vkbinfo.state, vkbinfo.evtch,
+                       vkbinfo.rref, vkbs[i].unique_id,
+                       libxl_vkb_backend_to_string(vkbs[i].backend_type),
+                       vkbinfo.backend);
+                libxl_vkbinfo_dispose(&vkbinfo);
+            }
+        }
+        libxl_device_vkb_list_free(vkbs, nb);
+    }
+    return 0;
+}
+
+int main_vkbdetach(int argc, char **argv)
+{
+    uint32_t domid, devid;
+    int opt, rc;
+    libxl_device_vkb vkb;
+
+    SWITCH_FOREACH_OPT(opt, "", NULL, "vkb-detach", 2) {
+        /* No options */
+    }
+
+    domid = find_domain(argv[optind++]);
+    devid = atoi(argv[optind++]);
+
+    libxl_device_vkb_init(&vkb);
+
+    if (libxl_devid_to_device_vkb(ctx, domid, devid, &vkb)) {
+        fprintf(stderr, "Error: Device %d not connected.\n", devid);
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = libxl_device_vkb_remove(ctx, domid, &vkb, 0);
+    if (rc) {
+        fprintf(stderr, "libxl_device_vkb_remove failed.\n");
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    rc = 0;
+
+out:
+    libxl_device_vkb_dispose(&vkb);
+    return rc;
+}
+
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 5/7] docs: add vkb device to xl.cfg and xl
  2018-07-17 16:07 [PATCH v3 0/7] libxl: create standalone vkb device Oleksandr Grytsov
                   ` (3 preceding siblings ...)
  2018-07-17 16:07 ` [PATCH v3 4/7] xl: add vkb config parser and CLI Oleksandr Grytsov
@ 2018-07-17 16:07 ` Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 6/7] libxl: vkb add extended parameters Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 7/7] libxl: add LIBXL_HAVE_EXTENDED_VKB define Oleksandr Grytsov
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Grytsov @ 2018-07-17 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 docs/man/xl.cfg.pod.5.in | 24 ++++++++++++++++++++++++
 docs/man/xl.pod.1.in     | 22 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 099a28dc7a..cc98b6003f 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1563,6 +1563,30 @@ I<EXAMPLE:>
         ]
     ]
 
+=item B<vkb=[ "VKB_SPEC_STRING", "VKB_SPEC_STRING", ...]>
+
+Specifies the virtual keyboard device to be provided to the guest.
+
+Each B<VKB_SPEC_STRING> is a comma-separated list of C<KEY=VALUE>
+settings from the following list:
+
+=over 4
+
+=item B<unique-id=STRING>
+
+Specifies the unique input device id.
+
+=item B<backend=domain-id>
+
+Specifies the backend domain name or id.
+
+=item B<backend-type=type>
+
+Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV
+domain.
+
+=back
+
 =back
 
 =head2 Paravirtualised (PV) Guest Specific Options
diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 90423bf3df..b74764dcd3 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -1522,6 +1522,28 @@ List vsnd devices for a domain.
 
 =back
 
+=head2 KEYBOARD DEVICES
+
+=over 4
+
+=item B<vkb-attach> I<domain-id> I<vkb-device>
+
+Creates a new keyboard device in the domain specified by I<domain-id>.
+I<vkb-device> describes the device to attach, using the same format as the
+B<VKB_SPEC_STRING> string in the domain config file. See L<xl.cfg(5)>
+for more informations.
+
+=item B<vkb-detach> I<domain-id> I<devid>
+
+Removes the keyboard device from the domain specified by I<domain-id>.
+I<devid> is the virtual interface device number within the domain
+
+=item B<vkb-list> I<domain-id>
+
+List virtual network interfaces for a domain.
+
+=back
+
 =head1 PCI PASS-THROUGH
 
 =over 4
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 6/7] libxl: vkb add extended parameters
  2018-07-17 16:07 [PATCH v3 0/7] libxl: create standalone vkb device Oleksandr Grytsov
                   ` (4 preceding siblings ...)
  2018-07-17 16:07 ` [PATCH v3 5/7] docs: add vkb device to xl.cfg and xl Oleksandr Grytsov
@ 2018-07-17 16:07 ` Oleksandr Grytsov
  2018-07-17 16:07 ` [PATCH v3 7/7] libxl: add LIBXL_HAVE_EXTENDED_VKB define Oleksandr Grytsov
  6 siblings, 0 replies; 10+ messages in thread
From: Oleksandr Grytsov @ 2018-07-17 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Add parsing and adding to xen store following extended parameters:
* feature-disable-keyboard
* feature-disable-pointer
* feature-abs-pointer
* feature-multi-touch
* feature-raw-pointer
* width
* height
* multi-touch-width
* multi-touch-height
* multi-touch-num-contacts

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 docs/man/xl.cfg.pod.5.in    |  40 +++++++++++
 tools/libxl/libxl_types.idl |  12 +++-
 tools/libxl/libxl_vkb.c     | 133 +++++++++++++++++++++++++++++++++++-
 tools/xl/xl_parse.c         |  35 +++++++++-
 tools/xl/xl_vkb.c           |  14 ++++
 5 files changed, 231 insertions(+), 3 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index cc98b6003f..b72718151b 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1585,6 +1585,46 @@ Specifies the backend domain name or id.
 Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV
 domain.
 
+=item B<feature-disable-keyboard=BOOLEAN>
+
+Indicates if keyboard device is disabled.
+
+=item B<feature-disable-pointer=BOOLEAN>
+
+Indicates if pointer device is disabled.
+
+=item B<feature-abs-pointer=BOOLEAN>
+
+Indicates if pointer device can return absolute coordinates.
+
+=item B<feature-raw-pointer=BOOLEAN>
+
+Indicates if pointer device can return raw (unscaled) absolute coordinates.
+
+=item B<feature-multi-touch=BOOLEAN>
+
+Indicates if input device supports multi touch.
+
+=item B<multi-touch-width=MULTI_TOUCH_WIDTH>
+
+Set maximum width for multi touch device.
+
+=item B<multi-touch-height=MULTI_TOUCH_HEIGHT>
+
+Set maximum height for multi touch device.
+
+=item B<multi-touch-num-contacts=MULTI_TOUCH_NUM_CONTACTS>
+
+Set maximum contacts number for multi touch device.
+
+=item B<width=WIDTH>
+
+Set maximum width for pointer device.
+
+=item B<height=HEIGHT>
+
+Set maximum height for pointer device.
+
 =back
 
 =back
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 4b4dc9eb5d..4a385801ba 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -633,7 +633,17 @@ libxl_device_vkb = Struct("device_vkb", [
     ("backend_domname", string),
     ("devid", libxl_devid),
     ("backend_type", libxl_vkb_backend),
-    ("unique_id", string)
+    ("unique_id", string),
+    ("feature_disable_keyboard", bool),
+    ("feature_disable_pointer", bool),
+    ("feature_abs_pointer", bool),
+    ("feature_raw_pointer", bool),
+    ("feature_multi_touch", bool),
+    ("width", uint32),
+    ("height", uint32),
+    ("multi_touch_width", uint32),
+    ("multi_touch_height", uint32),
+    ("multi_touch_num_contacts", uint32)
     ])
 
 libxl_device_disk = Struct("device_disk", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 1262dbc7bd..e928839cfb 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -43,6 +43,47 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid,
         flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id);
     }
 
+    if (vkb->feature_disable_keyboard) {
+        flexarray_append_pair(back, XENKBD_FIELD_FEAT_DSBL_KEYBRD,
+                              GCSPRINTF("%u", vkb->feature_disable_keyboard));
+    }
+
+    if (vkb->feature_disable_pointer) {
+        flexarray_append_pair(back, XENKBD_FIELD_FEAT_DSBL_POINTER,
+                              GCSPRINTF("%u", vkb->feature_disable_pointer));
+    }
+
+    if (vkb->feature_abs_pointer) {
+        flexarray_append_pair(back, XENKBD_FIELD_FEAT_ABS_POINTER,
+                              GCSPRINTF("%u", vkb->feature_abs_pointer));
+    }
+
+    if (vkb->feature_raw_pointer) {
+        flexarray_append_pair(back, XENKBD_FIELD_FEAT_RAW_POINTER,
+                              GCSPRINTF("%u", vkb->feature_raw_pointer));
+    }
+
+    if (vkb->feature_multi_touch) {
+        flexarray_append_pair(back, XENKBD_FIELD_FEAT_MTOUCH,
+                              GCSPRINTF("%u", vkb->feature_multi_touch));
+        flexarray_append_pair(back, XENKBD_FIELD_MT_WIDTH,
+                              GCSPRINTF("%u", vkb->multi_touch_width));
+        flexarray_append_pair(back, XENKBD_FIELD_MT_HEIGHT,
+                              GCSPRINTF("%u", vkb->multi_touch_height));
+        flexarray_append_pair(back, XENKBD_FIELD_MT_NUM_CONTACTS,
+                              GCSPRINTF("%u", vkb->multi_touch_num_contacts));
+    }
+
+    if (vkb->width) {
+        flexarray_append_pair(back, XENKBD_FIELD_WIDTH,
+                              GCSPRINTF("%u", vkb->width));
+    }
+
+    if (vkb->height) {
+        flexarray_append_pair(back, XENKBD_FIELD_HEIGHT,
+                              GCSPRINTF("%u", vkb->height));
+    }
+
     return 0;
 }
 
@@ -50,7 +91,7 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path,
                                     libxl_devid devid,
                                     libxl_device_vkb *vkb)
 {
-    const char *be_path, *be_type, *fe_path;
+    const char *be_path, *be_type, *fe_path, *tmp;
     int rc;
 
     vkb->devid = devid;
@@ -78,6 +119,96 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path,
 
     vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL);
 
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_FEAT_DSBL_KEYBRD,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->feature_disable_keyboard = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_FEAT_DSBL_POINTER,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->feature_disable_pointer = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_FEAT_ABS_POINTER,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->feature_abs_pointer = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_FEAT_RAW_POINTER,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->feature_raw_pointer = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_FEAT_MTOUCH,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->feature_multi_touch = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_MT_WIDTH,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->multi_touch_width = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_MT_HEIGHT,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->multi_touch_height = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_MT_NUM_CONTACTS,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->multi_touch_num_contacts = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_WIDTH,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->width = strtoul(tmp, NULL, 0);
+    }
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/"XENKBD_FIELD_HEIGHT,
+                                be_path), &tmp);
+    if (rc) goto out;
+
+    if (tmp) {
+        vkb->height = strtoul(tmp, NULL, 0);
+    }
+
     rc = 0;
 
 out:
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 9b7b78c2a1..971ec1bc56 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1112,6 +1112,26 @@ int parse_vkb_config(libxl_device_vkb *vkb, char *token)
         vkb->backend_type = backend_type;
     } else if (MATCH_OPTION(XENKBD_FIELD_UNIQUE_ID, token, oparg)) {
         vkb->unique_id = strdup(oparg);
+    } else if (MATCH_OPTION(XENKBD_FIELD_FEAT_DSBL_KEYBRD, token, oparg)) {
+        vkb->feature_disable_keyboard = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_FEAT_DSBL_POINTER, token, oparg)) {
+        vkb->feature_disable_pointer = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_FEAT_ABS_POINTER, token, oparg)) {
+        vkb->feature_abs_pointer = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_FEAT_RAW_POINTER, token, oparg)) {
+        vkb->feature_raw_pointer = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_FEAT_MTOUCH, token, oparg)) {
+        vkb->feature_multi_touch = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_MT_WIDTH, token, oparg)) {
+        vkb->multi_touch_width = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_MT_HEIGHT, token, oparg)) {
+        vkb->multi_touch_height = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_MT_NUM_CONTACTS, token, oparg)) {
+        vkb->multi_touch_num_contacts = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_WIDTH, token, oparg)) {
+        vkb->width = strtoul(oparg, NULL, 0);
+    } else if (MATCH_OPTION(XENKBD_FIELD_HEIGHT, token, oparg)) {
+        vkb->height = strtoul(oparg, NULL, 0);
     } else {
         fprintf(stderr, "Unknown string \"%s\" in vkb spec\n", token);
         return -1;
@@ -1153,7 +1173,20 @@ static void parse_vkb_list(const XLU_Config *config,
 
             if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
                 fprintf(stderr, "backend-type should be set in vkb spec\n");
-                rc = -1; goto out;
+                rc = ERROR_FAIL; goto out;
+            }
+
+            if (vkb->multi_touch_height || vkb->multi_touch_width ||
+                vkb->multi_touch_num_contacts) {
+                vkb->feature_multi_touch = true;
+            }
+
+            if (vkb->feature_multi_touch && !(vkb->multi_touch_height ||
+                vkb->multi_touch_width || vkb->multi_touch_num_contacts)) {
+                fprintf(stderr, XENKBD_FIELD_MT_WIDTH", "XENKBD_FIELD_MT_HEIGHT", "
+                                XENKBD_FIELD_MT_NUM_CONTACTS" should be set for "
+                                "multi touch in vkb spec\n");
+                rc = ERROR_FAIL; goto out;
             }
 
             entry++;
diff --git a/tools/xl/xl_vkb.c b/tools/xl/xl_vkb.c
index dcf828e156..f6ed9e05ee 100644
--- a/tools/xl/xl_vkb.c
+++ b/tools/xl/xl_vkb.c
@@ -18,6 +18,8 @@
 #include <libxl_utils.h>
 #include <libxlutil.h>
 
+#include <xen/io/kbdif.h>
+
 #include "xl.h"
 #include "xl_utils.h"
 #include "xl_parse.h"
@@ -46,6 +48,18 @@ int main_vkbattach(int argc, char **argv)
         rc = ERROR_FAIL; goto out;
     }
 
+    if (vkb.multi_touch_height || vkb.multi_touch_width ||
+        vkb.multi_touch_num_contacts) {
+        vkb.feature_multi_touch = true;
+    }
+
+    if (vkb.feature_multi_touch && !(vkb.multi_touch_height ||
+        vkb.multi_touch_width || vkb.multi_touch_num_contacts)) {
+        fprintf(stderr, XENKBD_FIELD_MT_WIDTH", "XENKBD_FIELD_MT_HEIGHT", "
+                        XENKBD_FIELD_MT_NUM_CONTACTS" should be set\n");
+        rc = ERROR_FAIL; goto out;
+    }
+
     if (dryrun_only) {
         char *json = libxl_device_vkb_to_json(ctx, &vkb);
         printf("vkb: %s\n", json);
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 7/7] libxl: add LIBXL_HAVE_EXTENDED_VKB define
  2018-07-17 16:07 [PATCH v3 0/7] libxl: create standalone vkb device Oleksandr Grytsov
                   ` (5 preceding siblings ...)
  2018-07-17 16:07 ` [PATCH v3 6/7] libxl: vkb add extended parameters Oleksandr Grytsov
@ 2018-07-17 16:07 ` Oleksandr Grytsov
  2018-07-25  8:31   ` Wei Liu
  6 siblings, 1 reply; 10+ messages in thread
From: Oleksandr Grytsov @ 2018-07-17 16:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

LIBXL_HAVE_EXTENDED_VKB define indicates that libxl_device_vkb structure has
extended fields.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
---
 tools/libxl/libxl.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 919f660c51..ae2d63df0c 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -354,6 +354,22 @@
 #define LIBXL_HAVE_BUILDINFO_BOOTLOADER 1
 #define LIBXL_HAVE_BUILDINFO_BOOTLOADER_ARGS 1
 
+/*
+ * LIBXL_HAVE_EXTENDED_VKB indicates that libxl_device_vkb has extended fields:
+ *  - unique_id;
+ *  - feature_disable_keyboard;
+ *  - feature_disable_pointer;
+ *  - feature_abs_pointer;
+ *  - feature_raw_pointer;
+ *  - feature_multi_touch;
+ *  - width;
+ *  - height;
+ *  - multi_touch_width;
+ *  - multi_touch_height;
+ *  - multi_touch_num_contacts.
+ */
+#define LIBXL_HAVE_EXTENDED_VKB 1
+
 /*
  * libxl ABI compatibility
  *
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 2/7] libxl: add backend type and id to vkb
  2018-07-17 16:07 ` [PATCH v3 2/7] libxl: add backend type and id to vkb Oleksandr Grytsov
@ 2018-07-25  8:31   ` Wei Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Wei Liu @ 2018-07-25  8:31 UTC (permalink / raw)
  To: Oleksandr Grytsov; +Cc: xen-devel, wei.liu2, ian.jackson, Oleksandr Grytsov

On Tue, Jul 17, 2018 at 07:07:35PM +0300, Oleksandr Grytsov wrote:
> From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
> 
> New field backend_type is added to vkb device in order to have QEMU and user
> space backend simultaneously. Each vkb backend shall read appropriate XS entry
> and service only own frontends. Id is a string field which used by the backend
> to indentify the frontend.
> 
> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 7/7] libxl: add LIBXL_HAVE_EXTENDED_VKB define
  2018-07-17 16:07 ` [PATCH v3 7/7] libxl: add LIBXL_HAVE_EXTENDED_VKB define Oleksandr Grytsov
@ 2018-07-25  8:31   ` Wei Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Wei Liu @ 2018-07-25  8:31 UTC (permalink / raw)
  To: Oleksandr Grytsov; +Cc: xen-devel, wei.liu2, ian.jackson, Oleksandr Grytsov

On Tue, Jul 17, 2018 at 07:07:40PM +0300, Oleksandr Grytsov wrote:
> From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
> 
> LIBXL_HAVE_EXTENDED_VKB define indicates that libxl_device_vkb structure has
> extended fields.
> 
> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-07-25  8:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 16:07 [PATCH v3 0/7] libxl: create standalone vkb device Oleksandr Grytsov
2018-07-17 16:07 ` [PATCH v3 1/7] libxl: move vkb device to libxl_vkb.c Oleksandr Grytsov
2018-07-17 16:07 ` [PATCH v3 2/7] libxl: add backend type and id to vkb Oleksandr Grytsov
2018-07-25  8:31   ` Wei Liu
2018-07-17 16:07 ` [PATCH v3 3/7] libxl: vkb add list and info functions Oleksandr Grytsov
2018-07-17 16:07 ` [PATCH v3 4/7] xl: add vkb config parser and CLI Oleksandr Grytsov
2018-07-17 16:07 ` [PATCH v3 5/7] docs: add vkb device to xl.cfg and xl Oleksandr Grytsov
2018-07-17 16:07 ` [PATCH v3 6/7] libxl: vkb add extended parameters Oleksandr Grytsov
2018-07-17 16:07 ` [PATCH v3 7/7] libxl: add LIBXL_HAVE_EXTENDED_VKB define Oleksandr Grytsov
2018-07-25  8:31   ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.