From: Oleksandr Grytsov <al1img@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com,
Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Subject: [PATCH v3 05/11] libxl: add vdispl setting xen store configuration
Date: Tue, 27 Jun 2017 13:03:21 +0300 [thread overview]
Message-ID: <1498557807-10810-6-git-send-email-al1img@gmail.com> (raw)
In-Reply-To: <1498557807-10810-1-git-send-email-al1img@gmail.com>
From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Implemet set_xenstore_config callback for vdispl
device driver.
Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
---
tools/libxl/libxl_device.c | 2 +-
tools/libxl/libxl_internal.h | 1 +
tools/libxl/libxl_vdispl.c | 117 ++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 118 insertions(+), 2 deletions(-)
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index e202503..5d7e189 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -18,7 +18,7 @@
#include "libxl_internal.h"
-static char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device)
+char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device)
{
char *dom_path = libxl__xs_get_dompath(gc, device->domid);
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 3397655..c0dd17e 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1209,6 +1209,7 @@ _hidden int libxl__device_exists(libxl__gc *gc, xs_transaction_t t,
libxl__device *device);
_hidden int libxl__device_generic_add(libxl__gc *gc, xs_transaction_t t,
libxl__device *device, char **bents, char **fents, char **ro_fents);
+_hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device);
_hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device);
_hidden char *libxl__device_libxl_path(libxl__gc *gc, libxl__device *device);
_hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path,
diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c
index c79bcda..4eceb71 100644
--- a/tools/libxl/libxl_vdispl.c
+++ b/tools/libxl/libxl_vdispl.c
@@ -65,6 +65,119 @@ static void libxl__device_vdispl_add(libxl__egc *egc, uint32_t domid,
libxl__device_add(egc, domid, &libxl__vdispl_devtype, vdispl, aodev);
}
+static int libxl__set_xenstore_connectors(libxl__gc *gc, xs_transaction_t t,
+ libxl__device *device,
+ libxl_device_vdispl *vdispl)
+{
+ struct xs_permissions perms[2];
+ char *frontend_path = NULL;
+ flexarray_t *connector;
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+ int i;
+ int rc;
+
+ frontend_path = libxl__device_frontend_path(gc, device);
+
+ perms[0].id = device->domid;
+ perms[0].perms = XS_PERM_NONE;
+ perms[1].id = device->backend_domid;
+ perms[1].perms = XS_PERM_READ;
+
+ connector = flexarray_make(gc, 2, 1);
+ flexarray_append(connector, "resolution");
+ flexarray_append(connector, "");
+ flexarray_append(connector, "id");
+ flexarray_append(connector, "");
+
+ for (i = 0; i < vdispl->num_connectors; i++) {
+ char *connector_path = GCSPRINTF("%s/%d", frontend_path, i);
+
+ if (!xs_mkdir(ctx->xsh, t, connector_path)) {
+ rc = ERROR_FAIL; goto out;
+ }
+
+ if (!xs_set_permissions(ctx->xsh, t, connector_path, perms,
+ ARRAY_SIZE(perms))) {
+ rc = ERROR_FAIL; goto out;
+ }
+
+ flexarray_set(connector, 1,
+ GCSPRINTF("%dx%d", vdispl->connectors[i].width,
+ vdispl->connectors[i].height));
+ flexarray_set(connector, 3, vdispl->connectors[i].id);
+
+ rc = libxl__xs_writev(gc, t, connector_path,
+ libxl__xs_kvs_of_flexarray(gc, connector));
+ if (rc) goto out;
+ }
+
+ rc = 0;
+
+out:
+ return rc;
+}
+
+static int libxl__set_xenstore_vdispl(libxl__gc *gc, uint32_t domid,
+ libxl_device_vdispl *vdispl)
+{
+ flexarray_t *front;
+ flexarray_t *back;
+
+ front = flexarray_make(gc, 16, 1);
+ back = flexarray_make(gc, 16, 1);
+
+ 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(back, "handle");
+ flexarray_append(back, GCSPRINTF("%d", vdispl->devid));
+
+ flexarray_append(front, "backend-id");
+ flexarray_append(front, GCSPRINTF("%d", vdispl->backend_domid));
+ flexarray_append(front, "state");
+ flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising));
+ flexarray_append(front, "handle");
+ flexarray_append(front, GCSPRINTF("%d", vdispl->devid));
+ flexarray_append(front, "be_alloc");
+ flexarray_append(front, GCSPRINTF("%d", vdispl->be_alloc));
+
+ libxl__device *device;
+ xs_transaction_t t = XBT_NULL;
+ int rc;
+
+ GCNEW(device);
+
+ rc = libxl__device_from_vdispl(gc, domid, vdispl, device);
+ if (rc) goto out;
+
+ for (;;) {
+ rc = libxl__xs_transaction_start(gc, &t);
+ if (rc) goto out;
+
+ rc = libxl__device_generic_add(gc, t, device,
+ libxl__xs_kvs_of_flexarray(gc, back),
+ libxl__xs_kvs_of_flexarray(gc, front),
+ NULL);
+ if (rc) goto out;
+
+ rc = libxl__set_xenstore_connectors(gc, t, device, vdispl);
+ if (rc) goto out;
+
+ rc = libxl__xs_transaction_commit(gc, &t);
+ if (!rc) break;
+ if (rc < 0) goto out;
+ }
+
+ rc = 0;
+
+out:
+ libxl__xs_transaction_abort(gc, &t);
+ return rc;
+}
+
libxl_device_vdispl *libxl_device_vdispl_list(libxl_ctx *ctx, uint32_t domid,
int *num)
{
@@ -91,7 +204,9 @@ DEFINE_DEVICE_TYPE_STRUCT(vdispl,
.update_config = (void (*)(libxl__gc *, void *, void *))
libxl__update_config_vdispl,
.from_xenstore = (int (*)(libxl__gc *, const char *, uint32_t, void *))
- libxl__from_xenstore_vdispl
+ libxl__from_xenstore_vdispl,
+ .set_xenstore_config = (int (*)(libxl__gc *, uint32_t, void *))
+ libxl__set_xenstore_vdispl
);
/*
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-06-27 10:03 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-27 10:03 [PATCH v3 00/11] libxl: add PV display device driver interface Oleksandr Grytsov
2017-06-27 10:03 ` [PATCH v3 01/11] libxl: add vdispl structures to idl Oleksandr Grytsov
2017-06-29 17:36 ` Wei Liu
2017-06-30 10:36 ` Oleksandr Grytsov
2017-06-30 14:15 ` Wei Liu
2017-06-27 10:03 ` [PATCH v3 02/11] libxl: add API for PV display device driver Oleksandr Grytsov
2017-06-27 10:03 ` [PATCH v3 03/11] libxl: add generic function to get and free device list Oleksandr Grytsov
2017-06-29 17:36 ` Wei Liu
2017-06-30 13:24 ` Oleksandr Grytsov
2017-07-06 15:29 ` Wei Liu
2017-07-10 12:22 ` Oleksandr Grytsov
2017-07-10 12:26 ` Oleksandr Grytsov
2017-07-12 9:51 ` Wei Liu
2017-07-12 13:43 ` Oleksandr Grytsov
2017-07-12 14:06 ` Wei Liu
2017-07-12 9:50 ` Wei Liu
2017-06-27 10:03 ` [PATCH v3 04/11] libxl: add generic function to add device Oleksandr Grytsov
2017-06-29 17:36 ` Wei Liu
2017-06-30 13:24 ` Oleksandr Grytsov
2017-06-30 14:16 ` Wei Liu
2017-06-30 14:18 ` Wei Liu
2017-07-03 12:53 ` Oleksandr Grytsov
2017-07-03 12:57 ` Wei Liu
2017-07-04 9:41 ` Oleksandr Grytsov
2017-07-12 16:13 ` Oleksandr Grytsov
2017-07-18 13:35 ` Wei Liu
2017-07-06 15:51 ` Wei Liu
2017-07-07 9:49 ` Oleksandr Grytsov
2017-07-07 10:29 ` Oleksandr Grytsov
2017-07-07 10:32 ` Wei Liu
2017-07-07 10:56 ` Oleksandr Grytsov
2017-07-10 12:41 ` Oleksandr Grytsov
2017-07-12 10:12 ` Wei Liu
2017-06-27 10:03 ` Oleksandr Grytsov [this message]
2017-06-27 10:03 ` [PATCH v3 06/11] libxl: implement vdispl get info function Oleksandr Grytsov
2017-06-27 10:03 ` [PATCH v3 07/11] libxl: implement device_from_vdispl and update_config_vdispl Oleksandr Grytsov
2017-06-27 10:03 ` [PATCH v3 08/11] libxl: add libxl__vdispl_devtype to device_type_tbl Oleksandr Grytsov
2017-06-27 10:03 ` [PATCH v3 09/11] libxl: add libxl_devid_to_device_vdispl interface function Oleksandr Grytsov
2017-06-27 10:03 ` [PATCH v3 10/11] xl: add PV display device commands Oleksandr Grytsov
2017-06-27 10:03 ` [PATCH v3 11/11] docs: add PV display driver information Oleksandr Grytsov
2017-06-29 17:36 ` Wei Liu
2017-06-30 10:43 ` Oleksandr Grytsov
2017-06-29 17:38 ` [PATCH v3 00/11] libxl: add PV display device driver interface Wei Liu
2017-06-30 10:45 ` Oleksandr Grytsov
2017-06-30 14:20 ` Wei Liu
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=1498557807-10810-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).