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

[Xen-devel] [PATCH v3 2/7] libxl: add backend type and id to vkb



From: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx>

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@xxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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