From patchwork Tue Jun 27 10:03:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9811281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 375616020A for ; Tue, 27 Jun 2017 10:05:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29E2528111 for ; Tue, 27 Jun 2017 10:05:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C82C2860C; Tue, 27 Jun 2017 10:05:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E99D28111 for ; Tue, 27 Jun 2017 10:05:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPnLV-0007Ii-6D; Tue, 27 Jun 2017 10:03:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPnLT-0007GM-8d for xen-devel@lists.xenproject.org; Tue, 27 Jun 2017 10:03:43 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id E8/24-03557-E7D22595; Tue, 27 Jun 2017 10:03:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRWlGSWpSXmKPExsVyMfS6k26tblC kwcdJ5hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aXli1MBe/UKnbsfsXewLhTpouRi0NIYDqj xPqeVSwgDovASxaJp8/2MYE4EgL9rBIrL25j62LkBHKSJLZOOsQIYZdIzH3WD2YLCchLHGy5z A5hT2WSOPW6EMRmE9CSuH97BViviICSxL1Vk4GGcnAwC6RI7PztBBIWFnCWePnwBlgJi4CqxN 5Nj5hBbF4BB4lr+64yQ6ySk7h5rpMZpJVTwFHiyhN1iE0OEl8bprJOYBRYwMiwilGjOLWoLLV I19BCL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMKwYgGAH482NAYcYJTmYlER5 V0sERQrxJeWnVGYkFmfEF5XmpBYfYtTg4BD4+fRvC6MUS15+XqqSBO8XbaA6waLU9NSKtMwcY ODDlEpw8CiJ8JYdD4wU4i0uSMwtzkyHSJ1iNOa4cmXdFyaOKQe2f2ESApskJc7rpQM0SQCkNK M0D24QLCIvMcpKCfMyAp0pxFOQWpSbWYIq/4pRnINRSZh3Isg9PJl5JXD7XgGdwgR0Csu8AJB TShIRUlINjDVCxkdmKx3TtxeTll5zL23ljvLQpf8+96rtvVzaGxDIv+bFfA/jjwtSF7ibzynd 8GbV0x3b7TfFFVXslI1JSDyRVTi3tUT5gsXCfl/m2FqWiRJiH4779JvoikYbmE28srKUd41xw 9NthZ9vrJy88+OtP/tTsh1yZYp/7/4r9ShE310kPvxVgxJLcUaioRZzUXEiAIoVVXzDAgAA X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1498557821!108154192!1 X-Originating-IP: [209.85.215.66] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46915 invoked from network); 27 Jun 2017 10:03:41 -0000 Received: from mail-lf0-f66.google.com (HELO mail-lf0-f66.google.com) (209.85.215.66) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Jun 2017 10:03:41 -0000 Received: by mail-lf0-f66.google.com with SMTP id g21so2306448lfk.1 for ; Tue, 27 Jun 2017 03:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=69RaeoX48INNWKQ5G6ThKaJOlOlallt7KvBekviESwM=; b=Q7WZ4ygAqvGmGvlovbwO4SnYNfxAFv76BrTSo9eWDbvwybyP6LJqY4hk/tCjAaI1/i ME3WpdCk+SRov0uVAKOPXpeCfhFxlFMgYgDw/JdQGjhTg+CoVf6awDYZTTcV7yKo1+Qi dPEmNdohmcaZGOmjj33SDqcoajEmRZJwJZR4WGvh0XNtxJeX5If8qAR6LmUzWjf21YA4 AZS+7uPkuCU3DEmbd2wBw42U/HK1L2qxZysbXCzF3/V+bfAxWahsGzFFBmKr7XM5ggJt 46QaSd9bcQ0k/lvcMH1qtNt/YlmIs9FgI0/Sbh4qwLZ3PMBu2YPwM6DC5L0GsRrDVK3l 9kkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=69RaeoX48INNWKQ5G6ThKaJOlOlallt7KvBekviESwM=; b=VlzmZhyhC83jioQ7cuk72SRCC0qVbTh7MYwRhoyP4XBYJGwGGXV43yphvT3ZoQ/1i3 143Vm3wC6owxiTSum+qCVT6S5em6uQ46qj6tUn1L9GjJweTtN/sFz0TLhhjK7ONoCrip 5FGMDyFiLbdRKH15eZUI3ABR09EnJFU8DAXdAK/0sY40azWgbSB9/oM2zVAnvIpinHAR woKTOd1RBKN08ix4MvRLbmw2cnsr+hOmaLw7oFwAPlc8tLfkS4PxrKl/urco+n5Shuyn USMMgw/dKuMoYmHBcBJjCGnVBIVjHZ4hn4rj/6kgIgTPBwq09GI6RMcGMDpmvjSpd8eY HfSw== X-Gm-Message-State: AKS2vOz/IkcW2eJSye3PnaTmTf13eXKeyjRunwuLHtWm4hpKfXql1vtA PjbEA3kM+IpPTcCiQKE= X-Received: by 10.46.13.9 with SMTP id 9mr1275453ljn.12.1498557820941; Tue, 27 Jun 2017 03:03:40 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id r82sm751763lfr.57.2017.06.27.03.03.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 03:03:40 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Tue, 27 Jun 2017 13:03:22 +0300 Message-Id: <1498557807-10810-7-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498557807-10810-1-git-send-email-al1img@gmail.com> References: <1498557807-10810-1-git-send-email-al1img@gmail.com> Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH v3 06/11] libxl: implement vdispl get info function X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Grytsov Add implementation of libxl_device_vdispl_getinfo. This function returns extended information about selected vdispl device. Signed-off-by: Oleksandr Grytsov --- 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)