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 06/11] libxl: implement vdispl get info function
Date: Tue, 27 Jun 2017 13:03:22 +0300 [thread overview]
Message-ID: <1498557807-10810-7-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>
Add implementation of libxl_device_vdispl_getinfo.
This function returns extended information about
selected vdispl device.
Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
---
tools/libxl/libxl_vdispl.c | 115 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 114 insertions(+), 1 deletion(-)
diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c
index 4eceb71..1a6c8b7 100644
--- a/tools/libxl/libxl_vdispl.c
+++ b/tools/libxl/libxl_vdispl.c
@@ -189,11 +189,124 @@ void libxl_device_vdispl_list_free(libxl_device_vdispl* list, int num)
libxl__device_list_free(&libxl__vdispl_devtype, list, num);
}
+static int libxl__device_vdispl_getconnectors(libxl_ctx *ctx,
+ const char *path,
+ libxl_vdisplinfo *info)
+{
+ GC_INIT(ctx);
+ char *connector = NULL;
+ char *connector_path = NULL;
+ int i, rc;
+
+ GCNEW_ARRAY(connector_path, 128);
+
+ info->num_connectors = 0;
+
+ rc = snprintf(connector_path, 128, "%s/%d", path, info->num_connectors);
+ if (rc < 0) goto out;
+
+ while((connector = xs_read(ctx->xsh, XBT_NULL, connector_path, NULL))
+ != NULL) {
+ free(connector);
+
+ rc = snprintf(connector_path, 128, "%s/%d",
+ path, ++info->num_connectors);
+ if (rc < 0) goto out;
+ }
+
+ info->connectors = libxl__calloc(NOGC, info->num_connectors,
+ sizeof(*info->connectors));
+
+ for (i = 0; i < info->num_connectors; i++) {
+ char *value;
+
+ snprintf(connector_path, 128, "%s/%d/id", path, i);
+ info->connectors[i].id = xs_read(ctx->xsh, XBT_NULL,
+ connector_path, NULL);
+ if (info->connectors[i].id == NULL) { rc = ERROR_FAIL; goto out; }
+
+ snprintf(connector_path, 128, "%s/%d/resolution", path, i);
+ value = xs_read(ctx->xsh, XBT_NULL, connector_path, NULL);
+ if (value == NULL) { rc = ERROR_FAIL; goto out; }
+
+ rc = sscanf(value, "%ux%u", &info->connectors[i].width,
+ &info->connectors[i].height);
+ free(value);
+ if (rc != 2) {
+ rc = ERROR_FAIL; goto out;
+ }
+
+ snprintf(connector_path, 128, "%s/%d/req-ring-ref", path, i);
+ value = xs_read(ctx->xsh, XBT_NULL, connector_path, NULL);
+ info->connectors[i].req_rref = value ? strtoul(value, NULL, 10) : -1;
+ free(value);
+
+ snprintf(connector_path, 128, "%s/%d/req-event-channel", path, i);
+ value = xs_read(ctx->xsh, XBT_NULL, connector_path, NULL);
+ info->connectors[i].req_evtch = value ? strtoul(value, NULL, 10) : -1;
+ free(value);
+
+ snprintf(connector_path, 128, "%s/%d/evt-ring-ref", path, i);
+ value = xs_read(ctx->xsh, XBT_NULL, connector_path, NULL);
+ info->connectors[i].evt_rref = value ? strtoul(value, NULL, 10) : -1;
+ free(value);
+
+ snprintf(connector_path, 128, "%s/%d/evt-event-channel", path, i);
+ value = xs_read(ctx->xsh, XBT_NULL, connector_path, NULL);
+ info->connectors[i].evt_evtch = value ? strtoul(value, NULL, 10) : -1;
+ free(value);
+ }
+
+ rc = 0;
+
+out:
+ return rc;
+}
+
int libxl_device_vdispl_getinfo(libxl_ctx *ctx, uint32_t domid,
libxl_device_vdispl *vdispl,
libxl_vdisplinfo *info)
{
- return 0;
+ GC_INIT(ctx);
+ char *libxl_path, *dompath, *devpath;
+ char *val;
+ int rc;
+
+ libxl_vdisplinfo_init(info);
+ dompath = libxl__xs_get_dompath(gc, domid);
+ info->devid = vdispl->devid;
+
+ devpath = GCSPRINTF("%s/device/vdispl/%d", dompath, info->devid);
+ libxl_path = GCSPRINTF("%s/device/vdispl/%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/be_alloc", devpath));
+ info->be_alloc = val ? strtoul(val, NULL, 10) : 0;
+
+ rc = libxl__device_vdispl_getconnectors(ctx, devpath, info);
+ if (rc) goto out;
+
+ rc = 0;
+
+out:
+ GC_FREE;
+ return rc;
}
LIBXL_DEFINE_DEVICE_ADD(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 ` [PATCH v3 05/11] libxl: add vdispl setting xen store configuration Oleksandr Grytsov
2017-06-27 10:03 ` Oleksandr Grytsov [this message]
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-7-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).