diff mbox

[3/6] libxl: add backend type to vkb

Message ID 1507194431-17588-4-git-send-email-al1img@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oleksandr Grytsov Oct. 5, 2017, 9:07 a.m. UTC
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(-)

Comments

Wei Liu Oct. 30, 2017, 6:11 p.m. UTC | #1
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.
Oleksandr Grytsov Oct. 31, 2017, 11:01 a.m. UTC | #2
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.
diff mbox

Patch

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);