From patchwork Wed Apr 5 10:03:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9663627 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 79F836021C for ; Wed, 5 Apr 2017 10:05:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5911227F95 for ; Wed, 5 Apr 2017 10:05:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DB46285AD; Wed, 5 Apr 2017 10:05:48 +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 208CE27F95 for ; Wed, 5 Apr 2017 10:05:46 +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 1cvhmu-0001fb-Mr; Wed, 05 Apr 2017 10:03:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvhmt-0001ek-6h for xen-devel@lists.xenproject.org; Wed, 05 Apr 2017 10:03:39 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id B4/5C-03648-AF0C4E85; Wed, 05 Apr 2017 10:03:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsVyMfS6i+7PA08 iDK69l7X4vmUykwOjx+EPV1gCGKNYM/OS8isSWDNmbbrJUrAuoKKn8wxrA+N6my5GLg4hgWmM ErMvtLCAOCwCL1kkfnQ+YQJxJAT6WSUuN/QDOZxATozE7lVHoewqiR17bzKD2EIC8hIHWy6zQ 4yawiTxdvlrdpAEm4CWxP3bK9hAbBEBJYl7qyaDTWUW6GaUWHV5DiNIQljASuLahs+sIDaLgK rEpEs9YA28AvYSu9adY4HYJidx81wn2DZOAQeJv50X2SE220uc2r6MdQKjwAJGhlWMGsWpRWW pRbpG5npJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bmbGIHhxQAEOxgXrw08xCjJwaQk yqvg8yRCiC8pP6UyI7E4I76oNCe1+BCjBgeHwM+nf1sYpVjy8vNSlSR4XYBhLCRYlJqeWpGWm QOMAJhSCQ4eJRHesv1Aad7igsTc4sx0iNQpRkuOB6d2vWHimDN7N5D81H/4DZMQ2Dwpcd5zIA 0CIA0ZpXlw42BReolRVkqYlxHoWCGegtSi3MwSVPlXjOIcjErCvMwgV/Fk5pXAbX0FdBAT0EF P7jwEOagkESEl1cB4SuVNz2/FS2VrzvoIrFwT9MWJ42iRgcTbUuPTJp6Vfk8CmUM+OG4+WtFt 3zKhQScjReLv7ocTBEoWMWUsCj16puHjyeMTT7y7cIbZPvRDxHapJSp71ErYGJRalDb2bWl3+ sNszKp6NHqZ+1PB3IkRcS+yf4q1FAjKZv5fz197rlrtRF1NApsSS3FGoqEWc1FxIgAeALQFzQ IAAA== X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1491386616!95414075!1 X-Originating-IP: [209.85.215.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62356 invoked from network); 5 Apr 2017 10:03:37 -0000 Received: from mail-lf0-f68.google.com (HELO mail-lf0-f68.google.com) (209.85.215.68) by server-16.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Apr 2017 10:03:37 -0000 Received: by mail-lf0-f68.google.com with SMTP id r36so731714lfi.0 for ; Wed, 05 Apr 2017 03:03:37 -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=Z80SaPsJTAMv8ego/twHJtrHK9azch05jhEj1n6o9Gk=; b=vB4VVw/9ewidPA6Gdvzdcuf3xXpc7Pn+/IVj7jDC8N+41fWMklVxJBtYLNf25vI9Q3 5rsY8Of9rOcHFJ7VdYeGJQ5evDKYzTrxSGivNYnary9fIS5Sz/X7MujBwmsMWEwpELeh x78rDeLD99WKqNg8EM/320P2vSDV3vcL8SezioNopzy0FwGWpcmSdCBYimR2RcFf0ocs OVtGvBceQ+1l7/aw+r50q4l0B192BRx2iWaSGb1AIflve+7yuWg4LV2ibAsPYczwqwzB QZVABoLu8YChgEyN6NlhRcQj8PTZcJQQoSAFZ0qnW4hJFkbfD91n61AQpT1bv2pHR6sK y9yw== 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=Z80SaPsJTAMv8ego/twHJtrHK9azch05jhEj1n6o9Gk=; b=f9yNLJkkMeg06o9rsvDtbli/qkwMX73FfODJJrvs3peZH5h0MjgEENOplK/4FHTFk1 +NEvjL3HAkGxQOudc0JQig+CM4BlMY7mhVOX991x8YUGo6XitBE+PIeScZbWKdO7Ef9e 2+2JUZoa6EwVco0h7ZzyA2Dl9/TukV8Sw/D3sD5OVgHKfLFrqiEbfBLUAp8tDoGiOvxD 1Jbn9skWcbC3Kme23vwjB8MB74T3HqeR0U5ijCTRQ9s/CjLWUXleFcieKgWwglGVSfZI QCKlE2+eKM45AWawqrXybNcmDrtant1AE6QvCcWW5BKrPWnvv7olQ3fQBXywVEApy8PY NCCA== X-Gm-Message-State: AFeK/H1WXHKhbcPVUXIlq+0furJSmcR0dadO2uyHefAfzEUWUyIx9BaO/n9jmWHeEtF2aQ== X-Received: by 10.25.44.139 with SMTP id s133mr7566856lfs.181.1491386616648; Wed, 05 Apr 2017 03:03:36 -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 2sm3644212ljp.36.2017.04.05.03.03.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Apr 2017 03:03:36 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Wed, 5 Apr 2017 13:03:17 +0300 Message-Id: <1491386597-1103-3-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491386597-1103-1-git-send-email-al1img@gmail.com> References: <1491386597-1103-1-git-send-email-al1img@gmail.com> Cc: jgross@suse.com, ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov , andr2000@gmail.com Subject: [Xen-devel] [PATCH v1 2/2] xl: add PV display device commands 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 Signed-off-by: Oleksandr Grytsov --- tools/xl/Makefile | 1 + tools/xl/xl.h | 3 + tools/xl/xl_cmdtable.c | 16 +++++ tools/xl/xl_parse.c | 43 ++++++++++++- tools/xl/xl_parse.h | 2 +- tools/xl/xl_vdispl.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 tools/xl/xl_vdispl.c diff --git a/tools/xl/Makefile b/tools/xl/Makefile index e16f877..5c784b5 100644 --- a/tools/xl/Makefile +++ b/tools/xl/Makefile @@ -21,6 +21,7 @@ XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o XL_OBJS += xl_sched.o xl_pci.o xl_vcpu.o xl_cdrom.o xl_mem.o XL_OBJS += xl_psr.o xl_info.o xl_console.o xl_misc.o XL_OBJS += xl_vmcontrol.o xl_saverestore.o xl_migrate.o +XL_OBJS += xl_vdispl.o $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog) $(XL_OBJS): CFLAGS += $(CFLAGS_XL) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index aa95b77..d361241 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -166,6 +166,9 @@ int main_blockdetach(int argc, char **argv); int main_vtpmattach(int argc, char **argv); int main_vtpmlist(int argc, char **argv); int main_vtpmdetach(int argc, char **argv); +int main_vdisplattach(int argc, char **argv); +int main_vdispllist(int argc, char **argv); +int main_vdispldetach(int argc, char **argv); int main_usbctrl_attach(int argc, char **argv); int main_usbctrl_detach(int argc, char **argv); int main_usbdev_attach(int argc, char **argv); diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 7d97811..34090e1 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -372,6 +372,22 @@ struct cmd_spec cmd_table[] = { "Destroy a domain's virtual TPM device", " ", }, + { "vdispl-attach", + &main_vdisplattach, 1, 1, + "Create a new virtual display device", + " [devId=] [backend=] [beAlloc=]", + " BackAlloc - set to 1 to allow backend allocated display buffers" + }, + { "vdispl-list", + &main_vdispllist, 0, 0, + "List virtual display devices for a domain", + "", + }, + { "vdispl-detach", + &main_vdispldetach, 0, 1, + "Destroy a domain's virtual display device", + " ", + }, { "uptime", &main_uptime, 0, 0, "Print uptime for all/some domains", diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index b72f990..fd6685a 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -803,6 +803,24 @@ int parse_usbdev_config(libxl_device_usbdev *usbdev, char *token) return 0; } +int parse_vdispl_config(libxl_device_vdispl *vdispl, char *token) +{ + char *oparg; + + if (MATCH_OPTION("backend", token, oparg)) { + vdispl->backend_domname = strdup(oparg); + } else if (MATCH_OPTION("devId", token, oparg)) { + vdispl->devid = atoi(oparg); + } else if (MATCH_OPTION("beAlloc", token, oparg)) { + vdispl->be_alloc = strtoul(oparg, NULL, 0); + } else { + fprintf(stderr, "Unknown string `%s' in vdispl spec\n", token); + return 1; + } + + return 0; +} + void parse_config_data(const char *config_source, const char *config_data, int config_len, @@ -812,7 +830,7 @@ void parse_config_data(const char *config_source, long l, vcpus = 0; XLU_Config *config; XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms, - *usbctrls, *usbdevs; + *usbctrls, *usbdevs, *vdispls; XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs; int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian; int pci_power_mgmt = 0; @@ -1390,6 +1408,29 @@ void parse_config_data(const char *config_source, } } + if (!xlu_cfg_get_list(config, "vdispl", &vdispls, 0, 0)) { + d_config->num_vdispls = 0; + d_config->vdispls = NULL; + while ((buf = xlu_cfg_get_listitem(vdispls, d_config->num_vdispls)) != NULL) { + libxl_device_vdispl *vdispl; + char * buf2 = strdup(buf); + char *p; + vdispl = ARRAY_EXTEND_INIT(d_config->vdispls, + d_config->num_vdispls, + libxl_device_vdispl_init); + p = strtok (buf2, ","); + while (p != NULL) + { + while (*p == ' ') p++; + if (parse_vdispl_config(vdispl, p)) { + exit(1); + } + p = strtok (NULL, ","); + } + free(buf2); + } + } + if (!xlu_cfg_get_list (config, "channel", &channels, 0, 0)) { d_config->num_channels = 0; d_config->channels = NULL; diff --git a/tools/xl/xl_parse.h b/tools/xl/xl_parse.h index db8bc3f..cc459fb 100644 --- a/tools/xl/xl_parse.h +++ b/tools/xl/xl_parse.h @@ -33,7 +33,7 @@ int parse_usbctrl_config(libxl_device_usbctrl *usbctrl, char *token); int parse_usbdev_config(libxl_device_usbdev *usbdev, char *token); int parse_cpurange(const char *cpu, libxl_bitmap *cpumap); int parse_nic_config(libxl_device_nic *nic, XLU_Config **config, char *token); - +int parse_vdispl_config(libxl_device_vdispl *vdispl, char *token); int match_option_size(const char *prefix, size_t len, char *arg, char **argopt); diff --git a/tools/xl/xl_vdispl.c b/tools/xl/xl_vdispl.c new file mode 100644 index 0000000..4df90c9 --- /dev/null +++ b/tools/xl/xl_vdispl.c @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2016 EPAM Systems Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include + +#include +#include +#include + +#include "xl.h" +#include "xl_utils.h" +#include "xl_parse.h" + +int main_vdisplattach(int argc, char **argv) +{ + int opt; + int rc; + char *oparg; + uint32_t domid; + libxl_device_vdispl vdispl; + + SWITCH_FOREACH_OPT(opt, "", NULL, "vdispl-attach", 1) { + /* No options */ + } + + libxl_device_vdispl_init(&vdispl); + domid = find_domain(argv[optind++]); + + for (argv += optind, argc -= optind; argc > 0; ++argv, --argc) { + if (MATCH_OPTION("devId", *argv, oparg)) { + vdispl.devid = atoi(oparg); + } else if (MATCH_OPTION("backend", *argv, oparg)) { + vdispl.backend_domid = find_domain(oparg); + replace_string(&vdispl.backend_domname, oparg); + } else if (MATCH_OPTION("beAlloc", *argv, oparg)) { + vdispl.be_alloc = strtoul(oparg, NULL, 0); + } else { + fprintf(stderr, "unrecognized argument `%s'\n", *argv); + rc = 1; + goto out; + } + } + + if (dryrun_only) { + char *json = libxl_device_vdispl_to_json(ctx, &vdispl); + printf("vdispl: %s\n", json); + free(json); + goto out; + } + + if (libxl_device_vdispl_add(ctx, domid, &vdispl, 0)) { + fprintf(stderr, "libxl_device_vdispl_add failed.\n"); + rc = ERROR_FAIL; + } + + rc = 0; + +out: + libxl_device_vdispl_dispose(&vdispl); + return rc; +} + +int main_vdispllist(int argc, char **argv) +{ + int opt; + int i, n; + libxl_device_vdispl *vdispls; + libxl_vdisplinfo vdisplinfo; + + SWITCH_FOREACH_OPT(opt, "", NULL, "vdispl-list", 1) { + /* No options */ + } + + /* vdisplinfo.uuid should be outputted too */ + printf("%-5s %-3s %-6s %-5s %-8s %-40s %-40s\n", + "Vdev", "BE", "handle", "state", "be-alloc", "BE-path", "FE-path"); + for (argv += optind, argc -= optind; argc > 0; --argc, ++argv) { + uint32_t domid; + + if (libxl_domain_qualifier_to_domid(ctx, *argv, &domid) < 0) { + fprintf(stderr, "%s is an invalid domain identifier\n", *argv); + continue; + } + + vdispls = libxl_device_vdispl_list(ctx, domid, &n); + + if (!vdispls) { + continue; + } + + for (i = 0; i < n; i++) { + libxl_vdisplinfo_init(&vdisplinfo); + if (libxl_device_vdispl_getinfo(ctx, domid, &vdispls[i], + &vdisplinfo) == 0) { + /* Vdev BE hdl st be-alloc BE-path FE-path*/ + printf("%-5d %-3d %-6d %-5d %-8d %-40s %-40s\n", + vdisplinfo.devid, vdisplinfo.backend_id, + vdisplinfo.frontend_id, + vdisplinfo.state, vdisplinfo.be_alloc, + vdisplinfo.backend, vdisplinfo.frontend); + } + libxl_vdisplinfo_dispose(&vdisplinfo); + } + + libxl_device_vdispl_list_free(vdispls, n); + } + return 0; +} + +int main_vdispldetach(int argc, char **argv) +{ + uint32_t domid, devid; + int opt, rc; + libxl_device_vdispl vdispl; + + SWITCH_FOREACH_OPT(opt, "", NULL, "vdispl-detach", 2) { + /* No options */ + } + + domid = find_domain(argv[optind++]); + devid = atoi(argv[optind++]); + + libxl_device_vdispl_init(&vdispl); + + if (libxl_devid_to_device_vdispl(ctx, domid, devid, &vdispl)) { + fprintf(stderr, "Error: Device %d not connected.\n", devid); + rc = ERROR_FAIL; + goto out; + } + + rc = libxl_device_vdispl_remove(ctx, domid, &vdispl, 0); + if (rc) { + fprintf(stderr, "libxl_device_vdispl_remove failed.\n"); + rc = ERROR_FAIL; + goto out; + } + + rc = 0; + +out: + libxl_device_vdispl_dispose(&vdispl); + return rc; +} + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */