All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr Grytsov <al1img@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com,
	Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Subject: [PATCH v4 07/13] libxl: change vkb to use generec add function
Date: Tue, 18 Jul 2017 17:25:24 +0300	[thread overview]
Message-ID: <1500387930-16317-8-git-send-email-al1img@gmail.com> (raw)
In-Reply-To: <1500387930-16317-1-git-send-email-al1img@gmail.com>

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
---
 tools/libxl/libxl_console.c  | 79 ++++++++------------------------------------
 tools/libxl/libxl_create.c   |  5 +--
 tools/libxl/libxl_dm.c       |  3 +-
 tools/libxl/libxl_internal.h |  6 +---
 4 files changed, 19 insertions(+), 74 deletions(-)

diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 446e766..48fccec 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -583,11 +583,10 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid,
     return rc;
 }
 
-int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb)
+static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
+                                        libxl_device_vkb *vkb, bool hotplug)
 {
-    int rc;
-    rc = libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid);
-    return rc;
+    return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid);
 }
 
 static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
@@ -604,68 +603,6 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
     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_vkb_add(gc, domid, vkb);
-    if (rc) {
-        LOGD(ERROR, domid, "Unable to add vkb device");
-        goto out;
-    }
-
-out:
-    libxl__ao_complete(egc, ao, rc);
-    return AO_INPROGRESS;
-}
-
-int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid,
-                          libxl_device_vkb *vkb)
-{
-    flexarray_t *front;
-    flexarray_t *back;
-    libxl__device device;
-    int rc;
-
-    rc = libxl__device_vkb_setdefault(gc, vkb);
-    if (rc) goto out;
-
-    front = flexarray_make(gc, 16, 1);
-    back = flexarray_make(gc, 16, 1);
-
-    if (vkb->devid == -1) {
-        if ((vkb->devid = libxl__device_nextid(gc, domid, "vkb")) < 0) {
-            rc = ERROR_FAIL;
-            goto out;
-        }
-    }
-
-    rc = libxl__device_from_vkb(gc, domid, vkb, &device);
-    if (rc != 0) goto out;
-
-    flexarray_append(back, "frontend-id");
-    flexarray_append(back, GCSPRINTF("%d", domid));
-    flexarray_append(back, "online");
-    flexarray_append(back, "1");
-    flexarray_append(back, "state");
-    flexarray_append(back, GCSPRINTF("%d", XenbusStateInitialising));
-
-    flexarray_append(front, "backend-id");
-    flexarray_append(front, GCSPRINTF("%d", vkb->backend_domid));
-    flexarray_append(front, "state");
-    flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising));
-
-    libxl__device_generic_add(gc, XBT_NULL, &device,
-                              libxl__xs_kvs_of_flexarray(gc, back),
-                              libxl__xs_kvs_of_flexarray(gc, front),
-                              NULL);
-    rc = 0;
-out:
-    return rc;
-}
-
 int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb)
 {
     int rc;
@@ -789,7 +726,17 @@ out:
  * 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)
+static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkbd")
+
+DEFINE_DEVICE_TYPE_STRUCT(vkb,
+    .skip_attach = 1
+);
 
 /* vfb */
 LIBXL_DEFINE_DEVICE_REMOVE(vfb)
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index f483475..9634811 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1346,7 +1346,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         }
 
         libxl_device_vkb_init(&vkb);
-        libxl__device_vkb_add(gc, domid, &vkb);
+        libxl__device_add(gc, domid, &libxl__vkb_devtype, &vkb);
         libxl_device_vkb_dispose(&vkb);
 
         dcs->sdss.dm.guest_domid = domid;
@@ -1372,7 +1372,8 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
 
         for (i = 0; i < d_config->num_vfbs; i++) {
             libxl__device_vfb_add(gc, domid, &d_config->vfbs[i]);
-            libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]);
+            libxl__device_add(gc, domid, &libxl__vkb_devtype,
+                              &d_config->vkbs[i]);
         }
 
         init_console_info(gc, &console, 0);
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 44ebd70..b37f47e 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1978,7 +1978,8 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
     ret = libxl__device_vfb_add(gc, dm_domid, &dm_config->vfbs[0]);
     if (ret)
         goto out;
-    ret = libxl__device_vkb_add(gc, dm_domid, &dm_config->vkbs[0]);
+    ret = libxl__device_add(gc, dm_domid, &libxl__vkb_devtype,
+                            &dm_config->vkbs[0]);
     if (ret)
         goto out;
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c53bbd1..49440d7 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1248,7 +1248,6 @@ _hidden int libxl__device_disk_setdefault(libxl__gc *gc,
 _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
                                          uint32_t domid, bool hotplug);
 _hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb);
-_hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb);
 _hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci);
 _hidden void libxl__rdm_setdefault(libxl__gc *gc,
                                    libxl_domain_build_info *b_info);
@@ -2658,10 +2657,6 @@ struct libxl__multidev {
  * it's a valid state.
  */
 
-/* Internal function to connect a vkb device */
-_hidden int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid,
-                                  libxl_device_vkb *vkb);
-
 /* Internal function to connect a vfb device */
 _hidden int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid,
                                   libxl_device_vfb *vfb);
@@ -3552,6 +3547,7 @@ static inline int *libxl__device_type_get_num(
     return (int *)((void *)d_config + dt->num_offset);
 }
 
+extern const struct libxl_device_type libxl__vkb_devtype;
 extern const struct libxl_device_type libxl__disk_devtype;
 extern const struct libxl_device_type libxl__nic_devtype;
 extern const struct libxl_device_type libxl__vtpm_devtype;
-- 
2.7.4


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

  parent reply	other threads:[~2017-07-18 14:25 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 14:25 [PATCH v4 00/13] libxl: add PV display device driver interface Oleksandr Grytsov
2017-07-18 14:25 ` [PATCH v4 01/13] libxl: add generic function to add device Oleksandr Grytsov
2017-09-05 11:47   ` Wei Liu
2017-09-05 16:44     ` Oleksandr Grytsov
2017-09-06  9:36       ` Wei Liu
2017-09-06 12:08         ` Oleksandr Grytsov
2017-07-18 14:25 ` [PATCH v4 02/13] libxl: add generic functions to get and free device list Oleksandr Grytsov
2017-09-05 11:51   ` Wei Liu
2017-09-06 12:31     ` Oleksandr Grytsov
2017-07-18 14:25 ` [PATCH v4 03/13] libxl: add vdispl device Oleksandr Grytsov
2017-09-05 12:52   ` Wei Liu
2017-09-05 12:58     ` Ian Jackson
2017-09-05 13:04       ` Wei Liu
2017-09-06 13:02         ` Oleksandr Grytsov
2017-09-06 13:39           ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 04/13] xl: add PV display device commands Oleksandr Grytsov
2017-07-28 14:11   ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 05/13] docs: add PV display driver information Oleksandr Grytsov
2017-07-28 14:11   ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 06/13] libxl: change p9 to use generec add function Oleksandr Grytsov
2017-07-28 14:11   ` Wei Liu
2017-07-28 16:23     ` Wei Liu
2017-07-30 18:42       ` Oleksandr Grytsov
2017-07-31 14:36         ` Wei Liu
2017-08-01 11:58           ` Oleksandr Grytsov
2017-08-01 13:00             ` Wei Liu
2017-08-02 11:37               ` Oleksandr Grytsov
2017-08-04 11:53                 ` Wei Liu
2017-08-08 12:39                   ` Oleksandr Grytsov
2017-08-08 15:05                     ` Wei Liu
2017-09-05 12:53   ` Wei Liu
2017-07-18 14:25 ` Oleksandr Grytsov [this message]
2017-09-05 12:54   ` [PATCH v4 07/13] libxl: change vkb " Wei Liu
2017-07-18 14:25 ` [PATCH v4 08/13] libxl: change vfb " Oleksandr Grytsov
2017-09-05 12:55   ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 09/13] libxl: change disk to use generic getting list functions Oleksandr Grytsov
2017-09-05 12:58   ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 10/13] libxl: change nic to use generec add function Oleksandr Grytsov
2017-09-05 13:03   ` Wei Liu
2017-09-06 15:39     ` Oleksandr Grytsov
2017-07-18 14:25 ` [PATCH v4 11/13] libxl: change vtpm " Oleksandr Grytsov
2017-09-05 13:05   ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 12/13] libxl: remove unneeded DEVICE_ADD macro Oleksandr Grytsov
2017-09-05 13:05   ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 13/13] libxl: make pci and usb setdefault function generic Oleksandr Grytsov
2017-09-05 13:06   ` Wei Liu
2017-09-06 15:53     ` Oleksandr Grytsov
2017-09-07  9:05       ` Wei Liu
2017-07-27 11:30 ` [PATCH v4 00/13] libxl: add PV display device driver interface Oleksandr Andrushchenko
2017-07-27 14:49   ` Wei Liu
2017-07-28 14:13 ` Wei Liu
2017-08-17 10:13   ` Oleksandr Grytsov
2017-08-17 11:11     ` Wei Liu
2017-08-30 15:49       ` Oleksandr Grytsov
2017-08-30 15:52         ` Ian Jackson
2017-08-31  9:01           ` Oleksandr Grytsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1500387930-16317-8-git-send-email-al1img@gmail.com \
    --to=al1img@gmail.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=oleksandr_grytsov@epam.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.