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

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Currently vkb device is the part of FB and console.
In embedded application we use vkb protocol to communicate
with user space backend. For this purpose we need to have
possibility to enable vkb device without QEMU, FB etc.

This particular issue was already discussed int the mail
thread [1]. There were few possible solutions. We've implemented
one suggested by Stefano: add "type" field for vkb.
Each backend (QEMU or user space) shall read this field and
serve frontend only for own type. I will provide the patch
for QEMU backend, once this solution is submitted to libxl.

This patchset consist of following changes:

* vkb related code is moved to libxl_vkb.c - as it now 
  used not only by console and FB;
* add backend type support in order to support QEMU and
  user space backends;
* add getting vkb list and getting device by id in order
  to implement CLI commands to attach, detach and list
  vkb devices;
* add new vkb entry in xl.cfg to handle separate vkb
  configuration;
* add CLI vkb-attach, vkb-detach and vkb-list commands;
* update documentation accordingly.

[1] https://marc.info/?l=qemu-devel&m=149219237030212&w=2

Oleksandr Grytsov (6):
  libxl: move vkb device to libxl_vkb.c
  libxl: fix vkb XS entry and type
  libxl: add backend type 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

 docs/man/xl.cfg.pod.5.in    |  24 ++++++
 docs/man/xl.pod.1.in        |  22 ++++++
 tools/libxl/Makefile        |   1 +
 tools/libxl/libxl.h         |  10 +++
 tools/libxl/libxl_console.c |  53 -------------
 tools/libxl/libxl_create.c  |   4 +
 tools/libxl/libxl_dm.c      |   2 +
 tools/libxl/libxl_types.idl |  18 +++++s
 tools/libxl/libxl_utils.h   |   3 +
 tools/libxl/libxl_vkb.c     | 180 ++++++++++++++++++++++++++++++++++++++++++++
 tools/xl/Makefile           |   2 +-
 tools/xl/xl.h               |   3 +
 tools/xl/xl_cmdtable.c      |  15 ++++
 tools/xl/xl_parse.c         |  77 ++++++++++++++++++-
 tools/xl/xl_parse.h         |   2 +-
 tools/xl/xl_vkb.c           | 141 ++++++++++++++++++++++++++++++++++
 16 files changed, 501 insertions(+), 56 deletions(-)
 create mode 100644 tools/libxl/libxl_vkb.c
 create mode 100644 tools/xl/xl_vkb.c

-- 
2.7.4


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

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

* [PATCH 1/6] libxl: move vkb device to libxl_vkb.c
  2017-10-05  9:07 [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
@ 2017-10-05  9:07 ` Oleksandr Grytsov
  2017-10-30 18:05   ` Wei Liu
  2017-10-05  9:07 ` [PATCH 2/6] libxl: fix vkb XS entry and type Oleksandr Grytsov
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-05  9: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>
---
 tools/libxl/Makefile        |  1 +
 tools/libxl/libxl_console.c | 53 ---------------------------------
 tools/libxl/libxl_vkb.c     | 72 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 53 deletions(-)
 create mode 100644 tools/libxl/libxl_vkb.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 2d52435..df1b710 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -139,6 +139,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_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 624bd01..09facaf 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -583,45 +583,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, "vkb")
-
 static int libxl__device_vfb_setdefault(libxl__gc *gc, uint32_t domid,
                                         libxl_device_vfb *vfb, bool hotplug)
 {
@@ -706,8 +667,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
  */
@@ -716,18 +675,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,
-    .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 0000000..0d01262
--- /dev/null
+++ b/tools/libxl/libxl_vkb.c
@@ -0,0 +1,72 @@
+/*
+ * 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);
+}
+
+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, "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,
+    .skip_attach = 1
+);
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.7.4


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

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

* [PATCH 2/6] libxl: fix vkb XS entry and type
  2017-10-05  9:07 [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
  2017-10-05  9:07 ` [PATCH 1/6] libxl: move vkb device to libxl_vkb.c Oleksandr Grytsov
@ 2017-10-05  9:07 ` Oleksandr Grytsov
  2017-10-05  9:32   ` Wei Liu
  2017-10-30 18:05   ` Wei Liu
  2017-10-05  9:07 ` [PATCH 3/6] libxl: add backend type to vkb Oleksandr Grytsov
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-05  9:07 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, wei.liu2, Oleksandr Grytsov

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

vkb has vkbd name in XS.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
---
 tools/libxl/libxl_vkb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 0d01262..ea6fca8 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -51,7 +51,7 @@ out:
     return AO_INPROGRESS;
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkb")
+static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkbd")
 
 #define libxl__add_vkbs NULL
 #define libxl_device_vkb_list NULL
@@ -59,7 +59,7 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkb")
 
 LIBXL_DEFINE_DEVICE_REMOVE(vkb)
 
-DEFINE_DEVICE_TYPE_STRUCT(vkb,
+DEFINE_DEVICE_TYPE_STRUCT_X(vkb, vkb, vkbd
     .skip_attach = 1
 );
 
-- 
2.7.4


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

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

* [PATCH 3/6] libxl: add backend type to vkb
  2017-10-05  9:07 [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
  2017-10-05  9:07 ` [PATCH 1/6] libxl: move vkb device to libxl_vkb.c Oleksandr Grytsov
  2017-10-05  9:07 ` [PATCH 2/6] libxl: fix vkb XS entry and type Oleksandr Grytsov
@ 2017-10-05  9:07 ` Oleksandr Grytsov
  2017-10-30 18:11   ` Wei Liu
  2017-10-05  9:07 ` [PATCH 4/6] libxl: vkb add list and info functions Oleksandr Grytsov
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-05  9: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.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
---
 tools/libxl/libxl_create.c  |  4 ++++
 tools/libxl/libxl_dm.c      |  2 ++
 tools/libxl/libxl_types.idl |  7 +++++++
 tools/libxl/libxl_vkb.c     | 10 +++++++++-
 tools/xl/xl_parse.c         |  4 ++++
 5 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index f813114..7268f7f 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1349,6 +1349,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         }
 
         libxl_device_vkb_init(&vkb);
+        vkb.backend_type = LIBXL_VKB_BACKEND_QEMU;
         libxl__device_add(gc, domid, &libxl__vkb_devtype, &vkb);
         libxl_device_vkb_dispose(&vkb);
 
@@ -1376,6 +1377,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 98f89a9..d8b0ee7 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1728,6 +1728,8 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
 
     vkb->backend_domid = 0;
     vkb->devid = 0;
+    vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
+
     return 0;
 }
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index cd0c06f..65cd81a 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -240,6 +240,12 @@ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
     (2, "COLO"),
     ])
 
+libxl_vkb_backend = Enumeration("vkb_backend", [
+    (0, "UNKNOWN"),
+    (1, "QEMU"),
+    (2, "LINUX")
+    ])
+
 #
 # Complex libxl types
 #
@@ -603,6 +609,7 @@ libxl_device_vkb = Struct("device_vkb", [
     ("backend_domid", libxl_domid),
     ("backend_domname", string),
     ("devid", libxl_devid),
+    ("backend_type", libxl_vkb_backend)
     ])
 
 libxl_device_disk = Struct("device_disk", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index ea6fca8..07b5428 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -34,6 +34,13 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
     return 0;
 }
 
+static int libxl__device_vkb_dm_needed(libxl_device_vkb *vkb, uint32_t domid)
+{
+   if (vkb->backend_type == LIBXL_VKB_BACKEND_QEMU)
+        return 1;
+    return 0;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
                          const libxl_asyncop_how *ao_how)
 {
@@ -60,7 +67,8 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkbd")
 LIBXL_DEFINE_DEVICE_REMOVE(vkb)
 
 DEFINE_DEVICE_TYPE_STRUCT_X(vkb, vkb, vkbd
-    .skip_attach = 1
+    .skip_attach = 1,
+    .dm_needed   = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed
 );
 
 /*
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index d4c2efb..7cfd7fd 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1941,6 +1941,8 @@ skip_nic:
             vkb = ARRAY_EXTEND_INIT(d_config->vkbs, d_config->num_vkbs,
                                     libxl_device_vkb_init);
 
+            vkb->backend_type = LIBXL_VKBD_BACKEND_QEMU;
+
             p = strtok(buf2, ",");
             if (!p)
                 goto skip_vfb;
@@ -2272,6 +2274,8 @@ skip_usbdev:
             vkb = ARRAY_EXTEND_INIT(d_config->vkbs, d_config->num_vkbs,
                                     libxl_device_vkb_init);
 
+            vkb->backend_type = LIBXL_VKBD_BACKEND_QEMU;
+
             parse_top_level_vnc_options(config, &vfb->vnc);
             parse_top_level_sdl_options(config, &vfb->sdl);
             xlu_cfg_replace_string (config, "keymap", &vfb->keymap, 0);
-- 
2.7.4


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

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

* [PATCH 4/6] libxl: vkb add list and info functions
  2017-10-05  9:07 [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
                   ` (2 preceding siblings ...)
  2017-10-05  9:07 ` [PATCH 3/6] libxl: add backend type to vkb Oleksandr Grytsov
@ 2017-10-05  9:07 ` Oleksandr Grytsov
  2017-10-05  9:07 ` [PATCH 5/6] xl: add vkb config parser and CLI Oleksandr Grytsov
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-05  9: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>
---
 tools/libxl/libxl.h         |  10 +++++
 tools/libxl/libxl_types.idl |  11 +++++
 tools/libxl/libxl_utils.h   |   3 ++
 tools/libxl/libxl_vkb.c     | 106 ++++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 127 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index acb73ce..f2f8442 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1950,6 +1950,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 65cd81a..a647bfc 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -1014,6 +1014,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 5455752..44409af 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 07b5428..276cc8a 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -13,6 +13,7 @@
  */
 
 #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)
@@ -41,6 +42,22 @@ static int libxl__device_vkb_dm_needed(libxl_device_vkb *vkb, 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;
+    int rc;
+
+    vkb->devid = devid;
+    rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+                                  GCSPRINTF("%s/backend", libxl_path),
+                                  &be_path);
+    if (rc) return rc;
+
+    return libxl__backendpath_parse_domid(gc, be_path, &vkb->backend_domid);
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
                          const libxl_asyncop_how *ao_how)
 {
@@ -58,17 +75,100 @@ 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 = GCSPRINTF("%s/device/vkbd/%d", dompath, info->devid);
+    libxl_path = GCSPRINTF("%s/device/vkbd/%d",
+                           libxl__xs_libxl_path(gc, domid),
+                           info->devid);
+    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_UPDATE_DEVID(vkb, "vkbd")
 
 #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_X(vkb, vkb, vkbd
+DEFINE_DEVICE_TYPE_STRUCT_X(vkb, vkb, vkbd,
     .skip_attach = 1,
-    .dm_needed   = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed
+    .dm_needed   = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed,
+    .from_xenstore = (device_from_xenstore_fn_t)libxl__vkb_from_xenstore
 );
 
 /*
-- 
2.7.4


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

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

* [PATCH 5/6] xl: add vkb config parser and CLI
  2017-10-05  9:07 [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
                   ` (3 preceding siblings ...)
  2017-10-05  9:07 ` [PATCH 4/6] libxl: vkb add list and info functions Oleksandr Grytsov
@ 2017-10-05  9:07 ` Oleksandr Grytsov
  2017-10-05  9:07 ` [PATCH 6/6] docs: add vkb device to xl.cfg and xl Oleksandr Grytsov
  2017-10-24  7:40 ` [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
  6 siblings, 0 replies; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-05  9: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>
---
 tools/xl/Makefile      |   2 +-
 tools/xl/xl.h          |   3 ++
 tools/xl/xl_cmdtable.c |  15 ++++++
 tools/xl/xl_parse.c    |  77 +++++++++++++++++++++++++--
 tools/xl/xl_parse.h    |   2 +-
 tools/xl/xl_vkb.c      | 141 +++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 235 insertions(+), 5 deletions(-)
 create mode 100644 tools/xl/xl_vkb.c

diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index 66bdbde..2769295 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 703caa6..826e9c1 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -170,6 +170,9 @@ int main_vtpmdetach(int argc, char **argv);
 int main_vdisplattach(int argc, char **argv);
 int main_vdispllist(int argc, char **argv);
 int main_vdispldetach(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_vsndattach(int argc, char **argv);
 int main_vsndlist(int argc, char **argv);
 int main_vsnddetach(int argc, char **argv);
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 8e162ce..f495e55 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -378,6 +378,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> [backend-type=<BackendType>] [backend=<BackDomain>]",
+    },
+    { "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 7cfd7fd..5f90634 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1099,6 +1099,75 @@ 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 {
+        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,
@@ -1941,7 +2010,7 @@ skip_nic:
             vkb = ARRAY_EXTEND_INIT(d_config->vkbs, d_config->num_vkbs,
                                     libxl_device_vkb_init);
 
-            vkb->backend_type = LIBXL_VKBD_BACKEND_QEMU;
+            vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
 
             p = strtok(buf2, ",");
             if (!p)
@@ -2274,7 +2343,7 @@ skip_usbdev:
             vkb = ARRAY_EXTEND_INIT(d_config->vkbs, d_config->num_vkbs,
                                     libxl_device_vkb_init);
 
-            vkb->backend_type = LIBXL_VKBD_BACKEND_QEMU;
+            vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
 
             parse_top_level_vnc_options(config, &vfb->vnc);
             parse_top_level_sdl_options(config, &vfb->sdl);
@@ -2423,7 +2492,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 9a948ea..19f453a 100644
--- a/tools/xl/xl_parse.h
+++ b/tools/xl/xl_parse.h
@@ -35,7 +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);
 #define MATCH_OPTION(prefix, arg, oparg) \
diff --git a/tools/xl/xl_vkb.c b/tools/xl/xl_vkb.c
new file mode 100644
index 0000000..6ec4b28
--- /dev/null
+++ b/tools/xl/xl_vkb.c
@@ -0,0 +1,141 @@
+/*
+ * 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 (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  BE-path */
+    printf("%-3s %-2s %-6s %-5s %-6s %6s %-30s\n",
+           "Idx", "BE", "handle", "state", "evt-ch", "ref", "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)) {
+                /* Idx BE */
+                printf("%-3d %-2d ", vkbinfo.devid, vkbinfo.backend_id);
+                /* Hdl  Sta  evch ref  BE-path */
+                printf("%6d %5d %6d %6d %-30s\n",
+                        vkbinfo.devid, vkbinfo.state, vkbinfo.evtch,
+                        vkbinfo.rref, 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.7.4


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

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

* [PATCH 6/6] docs: add vkb device to xl.cfg and xl
  2017-10-05  9:07 [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
                   ` (4 preceding siblings ...)
  2017-10-05  9:07 ` [PATCH 5/6] xl: add vkb config parser and CLI Oleksandr Grytsov
@ 2017-10-05  9:07 ` Oleksandr Grytsov
  2017-10-24  7:40 ` [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
  6 siblings, 0 replies; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-05  9: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>
---
 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 4948dd7..a9e10aa 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1317,6 +1317,30 @@ I<EXAMPLE:>
 
 =back
 
+=over 4
+
+=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<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
 
 The following options apply only to Paravirtual (PV) guests.
diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 0a88fd5..17b1e53 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -1506,6 +1506,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.7.4


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

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

* Re: [PATCH 2/6] libxl: fix vkb XS entry and type
  2017-10-05  9:07 ` [PATCH 2/6] libxl: fix vkb XS entry and type Oleksandr Grytsov
@ 2017-10-05  9:32   ` Wei Liu
  2017-10-05  9:49     ` Oleksandr Grytsov
  2017-10-30 18:05   ` Wei Liu
  1 sibling, 1 reply; 16+ messages in thread
From: Wei Liu @ 2017-10-05  9:32 UTC (permalink / raw)
  To: Oleksandr Grytsov; +Cc: xen-devel, wei.liu2, ian.jackson, Oleksandr Grytsov

On Thu, Oct 05, 2017 at 12:07:07PM +0300, Oleksandr Grytsov wrote:
> From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
> 
> vkb has vkbd name in XS.
> 
> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

This series won't make it to 4.10 but this issue should be fixed right
away -- assuming the patch is correct.

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

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

* Re: [PATCH 2/6] libxl: fix vkb XS entry and type
  2017-10-05  9:32   ` Wei Liu
@ 2017-10-05  9:49     ` Oleksandr Grytsov
  2017-10-05  9:54       ` Oleksandr Grytsov
  0 siblings, 1 reply; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-05  9:49 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Ian Jackson, Oleksandr Grytsov

On Thu, Oct 5, 2017 at 12:32 PM, Wei Liu <wei.liu2@citrix.com> wrote:
> On Thu, Oct 05, 2017 at 12:07:07PM +0300, Oleksandr Grytsov wrote:
>> From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
>>
>> vkb has vkbd name in XS.
>>
>> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
>
> This series won't make it to 4.10 but this issue should be fixed right
> away -- assuming the patch is correct.

Ok. I will send just this fix as another patchset.


-- 
Best Regards,
Oleksandr Grytsov.

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

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

* Re: [PATCH 2/6] libxl: fix vkb XS entry and type
  2017-10-05  9:49     ` Oleksandr Grytsov
@ 2017-10-05  9:54       ` Oleksandr Grytsov
  0 siblings, 0 replies; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-05  9:54 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Ian Jackson, Oleksandr Grytsov

On Thu, Oct 5, 2017 at 12:49 PM, Oleksandr Grytsov <al1img@gmail.com> wrote:
> On Thu, Oct 5, 2017 at 12:32 PM, Wei Liu <wei.liu2@citrix.com> wrote:
>> On Thu, Oct 05, 2017 at 12:07:07PM +0300, Oleksandr Grytsov wrote:
>>> From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
>>>
>>> vkb has vkbd name in XS.
>>>
>>> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
>>
>> This series won't make it to 4.10 but this issue should be fixed right
>> away -- assuming the patch is correct.
>
> Ok. I will send just this fix as another patchset.
>
>
> --
> Best Regards,
> Oleksandr Grytsov.

Actually in current implementation it is not possible to create more
than one vkb per domain.
It means this issue will not happen any case.

So, I'm ok to wait with all this patchset for next release.

-- 
Best Regards,
Oleksandr Grytsov.

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

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

* Re: [PATCH 0/6] libxl: create standalone vkb device
  2017-10-05  9:07 [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
                   ` (5 preceding siblings ...)
  2017-10-05  9:07 ` [PATCH 6/6] docs: add vkb device to xl.cfg and xl Oleksandr Grytsov
@ 2017-10-24  7:40 ` Oleksandr Grytsov
  2017-10-30 12:36   ` Oleksandr Grytsov
  6 siblings, 1 reply; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-24  7:40 UTC (permalink / raw)
  To: Xen-devel; +Cc: Ian Jackson, Wei Liu, Oleksandr Grytsov


[-- Attachment #1.1: Type: text/plain, Size: 2551 bytes --]

On Thu, Oct 5, 2017 at 12:07 PM, Oleksandr Grytsov <al1img@gmail.com> wrote:

> From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
>
> Currently vkb device is the part of FB and console.
> In embedded application we use vkb protocol to communicate
> with user space backend. For this purpose we need to have
> possibility to enable vkb device without QEMU, FB etc.
>
> This particular issue was already discussed int the mail
> thread [1]. There were few possible solutions. We've implemented
> one suggested by Stefano: add "type" field for vkb.
> Each backend (QEMU or user space) shall read this field and
> serve frontend only for own type. I will provide the patch
> for QEMU backend, once this solution is submitted to libxl.
>
> This patchset consist of following changes:
>
> * vkb related code is moved to libxl_vkb.c - as it now
>   used not only by console and FB;
> * add backend type support in order to support QEMU and
>   user space backends;
> * add getting vkb list and getting device by id in order
>   to implement CLI commands to attach, detach and list
>   vkb devices;
> * add new vkb entry in xl.cfg to handle separate vkb
>   configuration;
> * add CLI vkb-attach, vkb-detach and vkb-list commands;
> * update documentation accordingly.
>
> [1] https://marc.info/?l=qemu-devel&m=149219237030212&w=2
>
> Oleksandr Grytsov (6):
>   libxl: move vkb device to libxl_vkb.c
>   libxl: fix vkb XS entry and type
>   libxl: add backend type 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
>
>  docs/man/xl.cfg.pod.5.in    |  24 ++++++
>  docs/man/xl.pod.1.in        |  22 ++++++
>  tools/libxl/Makefile        |   1 +
>  tools/libxl/libxl.h         |  10 +++
>  tools/libxl/libxl_console.c |  53 -------------
>  tools/libxl/libxl_create.c  |   4 +
>  tools/libxl/libxl_dm.c      |   2 +
>  tools/libxl/libxl_types.idl |  18 +++++s
>  tools/libxl/libxl_utils.h   |   3 +
>  tools/libxl/libxl_vkb.c     | 180 ++++++++++++++++++++++++++++++
> ++++++++++++++
>  tools/xl/Makefile           |   2 +-
>  tools/xl/xl.h               |   3 +
>  tools/xl/xl_cmdtable.c      |  15 ++++
>  tools/xl/xl_parse.c         |  77 ++++++++++++++++++-
>  tools/xl/xl_parse.h         |   2 +-
>  tools/xl/xl_vkb.c           | 141 ++++++++++++++++++++++++++++++++++
>  16 files changed, 501 insertions(+), 56 deletions(-)
>  create mode 100644 tools/libxl/libxl_vkb.c
>  create mode 100644 tools/xl/xl_vkb.c
>
> --
> 2.7.4
>
>
ping

-- 
Best Regards,
Oleksandr Grytsov.

[-- Attachment #1.2: Type: text/html, Size: 3683 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

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

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

* Re: [PATCH 0/6] libxl: create standalone vkb device
  2017-10-24  7:40 ` [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
@ 2017-10-30 12:36   ` Oleksandr Grytsov
  0 siblings, 0 replies; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-30 12:36 UTC (permalink / raw)
  To: Xen-devel; +Cc: Ian Jackson, Wei Liu, Oleksandr Grytsov


[-- Attachment #1.1: Type: text/plain, Size: 2752 bytes --]

On Tue, Oct 24, 2017 at 10:40 AM, Oleksandr Grytsov <al1img@gmail.com>
wrote:

> On Thu, Oct 5, 2017 at 12:07 PM, Oleksandr Grytsov <al1img@gmail.com>
> wrote:
>
>> From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
>>
>> Currently vkb device is the part of FB and console.
>> In embedded application we use vkb protocol to communicate
>> with user space backend. For this purpose we need to have
>> possibility to enable vkb device without QEMU, FB etc.
>>
>> This particular issue was already discussed int the mail
>> thread [1]. There were few possible solutions. We've implemented
>> one suggested by Stefano: add "type" field for vkb.
>> Each backend (QEMU or user space) shall read this field and
>> serve frontend only for own type. I will provide the patch
>> for QEMU backend, once this solution is submitted to libxl.
>>
>> This patchset consist of following changes:
>>
>> * vkb related code is moved to libxl_vkb.c - as it now
>>   used not only by console and FB;
>> * add backend type support in order to support QEMU and
>>   user space backends;
>> * add getting vkb list and getting device by id in order
>>   to implement CLI commands to attach, detach and list
>>   vkb devices;
>> * add new vkb entry in xl.cfg to handle separate vkb
>>   configuration;
>> * add CLI vkb-attach, vkb-detach and vkb-list commands;
>> * update documentation accordingly.
>>
>> [1] https://marc.info/?l=qemu-devel&m=149219237030212&w=2
>>
>> Oleksandr Grytsov (6):
>>   libxl: move vkb device to libxl_vkb.c
>>   libxl: fix vkb XS entry and type
>>   libxl: add backend type 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
>>
>>  docs/man/xl.cfg.pod.5.in    |  24 ++++++
>>  docs/man/xl.pod.1.in        |  22 ++++++
>>  tools/libxl/Makefile        |   1 +
>>  tools/libxl/libxl.h         |  10 +++
>>  tools/libxl/libxl_console.c |  53 -------------
>>  tools/libxl/libxl_create.c  |   4 +
>>  tools/libxl/libxl_dm.c      |   2 +
>>  tools/libxl/libxl_types.idl |  18 +++++s
>>  tools/libxl/libxl_utils.h   |   3 +
>>  tools/libxl/libxl_vkb.c     | 180 ++++++++++++++++++++++++++++++
>> ++++++++++++++
>>  tools/xl/Makefile           |   2 +-
>>  tools/xl/xl.h               |   3 +
>>  tools/xl/xl_cmdtable.c      |  15 ++++
>>  tools/xl/xl_parse.c         |  77 ++++++++++++++++++-
>>  tools/xl/xl_parse.h         |   2 +-
>>  tools/xl/xl_vkb.c           | 141 ++++++++++++++++++++++++++++++++++
>>  16 files changed, 501 insertions(+), 56 deletions(-)
>>  create mode 100644 tools/libxl/libxl_vkb.c
>>  create mode 100644 tools/xl/xl_vkb.c
>>
>> --
>> 2.7.4
>>
>>
> ping
>
> --
> Best Regards,
> Oleksandr Grytsov.
>

ping

-- 
Best Regards,
Oleksandr Grytsov.

[-- Attachment #1.2: Type: text/html, Size: 4454 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

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

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

* Re: [PATCH 1/6] libxl: move vkb device to libxl_vkb.c
  2017-10-05  9:07 ` [PATCH 1/6] libxl: move vkb device to libxl_vkb.c Oleksandr Grytsov
@ 2017-10-30 18:05   ` Wei Liu
  0 siblings, 0 replies; 16+ messages in thread
From: Wei Liu @ 2017-10-30 18:05 UTC (permalink / raw)
  To: Oleksandr Grytsov; +Cc: xen-devel, wei.liu2, ian.jackson, Oleksandr Grytsov

On Thu, Oct 05, 2017 at 12:07:06PM +0300, Oleksandr Grytsov wrote:
> 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>

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

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

* Re: [PATCH 2/6] libxl: fix vkb XS entry and type
  2017-10-05  9:07 ` [PATCH 2/6] libxl: fix vkb XS entry and type Oleksandr Grytsov
  2017-10-05  9:32   ` Wei Liu
@ 2017-10-30 18:05   ` Wei Liu
  1 sibling, 0 replies; 16+ messages in thread
From: Wei Liu @ 2017-10-30 18:05 UTC (permalink / raw)
  To: Oleksandr Grytsov; +Cc: xen-devel, wei.liu2, ian.jackson, Oleksandr Grytsov

On Thu, Oct 05, 2017 at 12:07:07PM +0300, Oleksandr Grytsov wrote:
> From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
> 
> vkb has vkbd name in XS.
> 
> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

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

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

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

* Re: [PATCH 3/6] libxl: add backend type to vkb
  2017-10-05  9:07 ` [PATCH 3/6] libxl: add backend type to vkb Oleksandr Grytsov
@ 2017-10-30 18:11   ` Wei Liu
  2017-10-31 11:01     ` Oleksandr Grytsov
  0 siblings, 1 reply; 16+ messages in thread
From: Wei Liu @ 2017-10-30 18:11 UTC (permalink / raw)
  To: Oleksandr Grytsov; +Cc: xen-devel, wei.liu2, ian.jackson, Oleksandr Grytsov

On Thu, Oct 05, 2017 at 12:07:08PM +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.
> 
> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
> ---
>  tools/libxl/libxl_create.c  |  4 ++++
>  tools/libxl/libxl_dm.c      |  2 ++
>  tools/libxl/libxl_types.idl |  7 +++++++
>  tools/libxl/libxl_vkb.c     | 10 +++++++++-
>  tools/xl/xl_parse.c         |  4 ++++
>  5 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index f813114..7268f7f 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -1349,6 +1349,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
>          }
>  
>          libxl_device_vkb_init(&vkb);
> +        vkb.backend_type = LIBXL_VKB_BACKEND_QEMU;

Hmm... See below.

>          libxl__device_add(gc, domid, &libxl__vkb_devtype, &vkb);
>          libxl_device_vkb_dispose(&vkb);
>  
> @@ -1376,6 +1377,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 98f89a9..d8b0ee7 100644
> --- a/tools/libxl/libxl_dm.c
> +++ b/tools/libxl/libxl_dm.c
> @@ -1728,6 +1728,8 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
>  
>      vkb->backend_domid = 0;
>      vkb->devid = 0;
> +    vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
> +
>      return 0;
>  }
>  
> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> index cd0c06f..65cd81a 100644
> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -240,6 +240,12 @@ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [
>      (2, "COLO"),
>      ])
>  
> +libxl_vkb_backend = Enumeration("vkb_backend", [
> +    (0, "UNKNOWN"),
> +    (1, "QEMU"),
> +    (2, "LINUX")
> +    ])

Originally this is only internal detail, but now you want to expose
this.  You need to set the default value for this; otherwise you could
break migration.

And then you also need to provide a setdefault function for
libxl_device_vkb.

Also I'm a bit confused because the LINUX type is not used in this
series.

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

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

* Re: [PATCH 3/6] libxl: add backend type to vkb
  2017-10-30 18:11   ` Wei Liu
@ 2017-10-31 11:01     ` Oleksandr Grytsov
  0 siblings, 0 replies; 16+ messages in thread
From: Oleksandr Grytsov @ 2017-10-31 11:01 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Ian Jackson, Oleksandr Grytsov


[-- Attachment #1.1: Type: text/plain, Size: 3227 bytes --]

On Mon, Oct 30, 2017 at 8:11 PM, Wei Liu <wei.liu2@citrix.com> wrote:

> On Thu, Oct 05, 2017 at 12:07:08PM +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.
> >
> > Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
> > ---
> >  tools/libxl/libxl_create.c  |  4 ++++
> >  tools/libxl/libxl_dm.c      |  2 ++
> >  tools/libxl/libxl_types.idl |  7 +++++++
> >  tools/libxl/libxl_vkb.c     | 10 +++++++++-
> >  tools/xl/xl_parse.c         |  4 ++++
> >  5 files changed, 26 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> > index f813114..7268f7f 100644
> > --- a/tools/libxl/libxl_create.c
> > +++ b/tools/libxl/libxl_create.c
> > @@ -1349,6 +1349,7 @@ static void domcreate_launch_dm(libxl__egc *egc,
> libxl__multidev *multidev,
> >          }
> >
> >          libxl_device_vkb_init(&vkb);
> > +        vkb.backend_type = LIBXL_VKB_BACKEND_QEMU;
>
> Hmm... See below.
>
> >          libxl__device_add(gc, domid, &libxl__vkb_devtype, &vkb);
> >          libxl_device_vkb_dispose(&vkb);
> >
> > @@ -1376,6 +1377,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 98f89a9..d8b0ee7 100644
> > --- a/tools/libxl/libxl_dm.c
> > +++ b/tools/libxl/libxl_dm.c
> > @@ -1728,6 +1728,8 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc
> *gc,
> >
> >      vkb->backend_domid = 0;
> >      vkb->devid = 0;
> > +    vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
> > +
> >      return 0;
> >  }
> >
> > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> > index cd0c06f..65cd81a 100644
> > --- a/tools/libxl/libxl_types.idl
> > +++ b/tools/libxl/libxl_types.idl
> > @@ -240,6 +240,12 @@ libxl_checkpointed_stream =
> Enumeration("checkpointed_stream", [
> >      (2, "COLO"),
> >      ])
> >
> > +libxl_vkb_backend = Enumeration("vkb_backend", [
> > +    (0, "UNKNOWN"),
> > +    (1, "QEMU"),
> > +    (2, "LINUX")
> > +    ])
>
> Originally this is only internal detail, but now you want to expose
> this.  You need to set the default value for this; otherwise you could
> break migration.
>

Yes, I will set default to QEMU.


>
> And then you also need to provide a setdefault function for
> libxl_device_vkb.
>
> Also I'm a bit confused because the LINUX type is not used in this
> series.
>

LINUX type will be used by the linux backend. libxl just set the xenstore
entry.
The linux backend will service only frontend which has LINUX type.

-- 
Best Regards,
Oleksandr Grytsov.

[-- Attachment #1.2: Type: text/html, Size: 4708 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

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

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

end of thread, other threads:[~2017-10-31 11:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05  9:07 [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
2017-10-05  9:07 ` [PATCH 1/6] libxl: move vkb device to libxl_vkb.c Oleksandr Grytsov
2017-10-30 18:05   ` Wei Liu
2017-10-05  9:07 ` [PATCH 2/6] libxl: fix vkb XS entry and type Oleksandr Grytsov
2017-10-05  9:32   ` Wei Liu
2017-10-05  9:49     ` Oleksandr Grytsov
2017-10-05  9:54       ` Oleksandr Grytsov
2017-10-30 18:05   ` Wei Liu
2017-10-05  9:07 ` [PATCH 3/6] libxl: add backend type to vkb Oleksandr Grytsov
2017-10-30 18:11   ` Wei Liu
2017-10-31 11:01     ` Oleksandr Grytsov
2017-10-05  9:07 ` [PATCH 4/6] libxl: vkb add list and info functions Oleksandr Grytsov
2017-10-05  9:07 ` [PATCH 5/6] xl: add vkb config parser and CLI Oleksandr Grytsov
2017-10-05  9:07 ` [PATCH 6/6] docs: add vkb device to xl.cfg and xl Oleksandr Grytsov
2017-10-24  7:40 ` [PATCH 0/6] libxl: create standalone vkb device Oleksandr Grytsov
2017-10-30 12:36   ` Oleksandr Grytsov

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.