From patchwork Mon Feb 27 17:48:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9593661 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 8371160471 for ; Mon, 27 Feb 2017 17:50:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78CFA2840E for ; Mon, 27 Feb 2017 17:50:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D72B28488; Mon, 27 Feb 2017 17:50:57 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 D4C062840E for ; Mon, 27 Feb 2017 17:50:56 +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 1ciPPh-0002Ii-Dz; Mon, 27 Feb 2017 17:48: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 1ciPPf-0002IR-KY for xen-devel@lists.xenproject.org; Mon, 27 Feb 2017 17:48:43 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id B0/79-15112-A7664B85; Mon, 27 Feb 2017 17:48:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHRDpG5V2pY Ig/OXeS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox7U96zFzx3rmi6+Je5gfGMYRcjJ4eEgL/E 9MVHWEFsNgFliZ+dvWwgtoiAnkTTgeeMIDazgJfEjxU97CC2sIC9xLynE8FsFgFVidtr9rKA2 LwCFhLTf6xhhJgpL7Gr7SLYTE4BS4n29avBaoQE8iRWz1/GBmErSHRMP8YE0SsocXLmExaIXR ISB1+8YJ7AyDsLSWoWktQCRqZVjBrFqUVlqUW6xsZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTm JScV6yfm5mxiBwcMABDsYd64PPMQoycGkJMo7NXlLhBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ 3o2pQDnBotT01Iq0zBxgGMOkJTh4lER4a0HSvMUFibnFmekQqVOMuhxzZu9+wyTEkpeflyolz tsDUiQAUpRRmgc3AhZTlxhlpYR5GYGOEuIpSC3KzSxBlX/FKM7BqCTMew9kCk9mXgncpldARz ABHTHbeCPIESWJCCmpBsYbrgssz8itbPhzi3FZkt6q1ENbHe/y3FALc8j8v8XGRnv+Tb2Wr0s mhh9TXflgocb5ozxeu5mMTRd7H7+7dutpTcvNiep83ZeYL3ebWW9kKjP8HtYrobl1cqiR8Ypn i5Y6slcxqNgomc8qmSxl3SAhvq7bYfcHj+yK2rOakTe0P9Wpn7yTs0iJpTgj0VCLuag4EQAsJ KHQpAIAAA== X-Env-Sender: prvs=2241cd559=wei.liu2@citrix.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1488217720!56265064!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5062 invoked from network); 27 Feb 2017 17:48:41 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 27 Feb 2017 17:48:41 -0000 X-IronPort-AV: E=Sophos;i="5.35,215,1484006400"; d="scan'208";a="410056652" From: Wei Liu To: Xen-devel Date: Mon, 27 Feb 2017 17:48:39 +0000 Message-ID: <20170227174839.19841-2-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170227174839.19841-1-wei.liu2@citrix.com> References: <22708.19672.270064.432049@mariner.uk.xensource.com> <20170227174839.19841-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: Wei Liu , Ian Jackson Subject: [Xen-devel] [PATCH 2/2] xl: split out vnc and console related code 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The new file also contains code for channel, which is just a console in disguise. Replace the call to vncviewer() with libxl_vncviewer_exec() directly in main_vncviewer. Signed-off-by: Wei Liu Acked-by: Ian Jackson --- tools/xl/Makefile | 2 +- tools/xl/xl_cmdimpl.c | 99 -------------------------------------- tools/xl/xl_console.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 100 deletions(-) create mode 100644 tools/xl/xl_console.c diff --git a/tools/xl/Makefile b/tools/xl/Makefile index bc8cfb3de9..7375d2bfda 100644 --- a/tools/xl/Makefile +++ b/tools/xl/Makefile @@ -19,7 +19,7 @@ XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o xl_sxp.o xl_utils.o XL_OBJS += xl_tmem.o xl_parse.o xl_cpupool.o xl_flask.o 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_OBJS += xl_psr.o xl_info.o xl_console.o $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog) $(XL_OBJS): CFLAGS += $(CFLAGS_XL) diff --git a/tools/xl/xl_cmdimpl.c b/tools/xl/xl_cmdimpl.c index a42b972d60..958058cadb 100644 --- a/tools/xl/xl_cmdimpl.c +++ b/tools/xl/xl_cmdimpl.c @@ -1071,61 +1071,6 @@ void help(const char *command) } } -int main_console(int argc, char **argv) -{ - uint32_t domid; - int opt = 0, num = 0; - libxl_console_type type = 0; - - SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) { - case 't': - if (!strcmp(optarg, "pv")) - type = LIBXL_CONSOLE_TYPE_PV; - else if (!strcmp(optarg, "serial")) - type = LIBXL_CONSOLE_TYPE_SERIAL; - else { - fprintf(stderr, "console type supported are: pv, serial\n"); - return EXIT_FAILURE; - } - break; - case 'n': - num = atoi(optarg); - break; - } - - domid = find_domain(argv[optind]); - if (!type) - libxl_primary_console_exec(ctx, domid, -1); - else - libxl_console_exec(ctx, domid, num, type, -1); - fprintf(stderr, "Unable to attach console\n"); - return EXIT_FAILURE; -} - -int main_vncviewer(int argc, char **argv) -{ - static const struct option opts[] = { - {"autopass", 0, 0, 'a'}, - {"vncviewer-autopass", 0, 0, 'a'}, - COMMON_LONG_OPTS - }; - uint32_t domid; - int opt, autopass = 0; - - SWITCH_FOREACH_OPT(opt, "a", opts, "vncviewer", 1) { - case 'a': - autopass = 1; - break; - } - - domid = find_domain(argv[optind]); - - libxl_vncviewer_exec(ctx, domid, autopass); - fprintf(stderr, "Unable to execute vncviewer\n"); - - return EXIT_FAILURE; -} - static void pause_domain(uint32_t domid) { libxl_domain_pause(ctx, domid); @@ -2515,50 +2460,6 @@ int main_debug_keys(int argc, char **argv) return EXIT_SUCCESS; } -int main_channellist(int argc, char **argv) -{ - int opt; - libxl_device_channel *channels; - libxl_channelinfo channelinfo; - int nb, i; - - SWITCH_FOREACH_OPT(opt, "", NULL, "channel-list", 1) { - /* No options */ - } - - /* Idx BE state evt-ch ring-ref connection params*/ - printf("%-3s %-2s %-5s %-6s %8s %-10s %-30s\n", - "Idx", "BE", "state", "evt-ch", "ring-ref", "connection", ""); - for (argv += optind, argc -= optind; argc > 0; --argc, ++argv) { - uint32_t domid = find_domain(*argv); - channels = libxl_device_channel_list(ctx, domid, &nb); - if (!channels) - continue; - for (i = 0; i < nb; ++i) { - if (!libxl_device_channel_getinfo(ctx, domid, &channels[i], - &channelinfo)) { - printf("%-3d %-2d ", channels[i].devid, channelinfo.backend_id); - printf("%-5d ", channelinfo.state); - printf("%-6d %-8d ", channelinfo.evtch, channelinfo.rref); - printf("%-10s ", libxl_channel_connection_to_string( - channels[i].connection)); - switch (channels[i].connection) { - case LIBXL_CHANNEL_CONNECTION_PTY: - printf("%-30s ", channelinfo.u.pty.path); - break; - default: - break; - } - printf("\n"); - libxl_channelinfo_dispose(&channelinfo); - } - libxl_device_channel_dispose(&channels[i]); - } - free(channels); - } - return 0; -} - #ifndef LIBXL_HAVE_NO_SUSPEND_RESUME int main_remus(int argc, char **argv) { diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c new file mode 100644 index 0000000000..0508ddaa32 --- /dev/null +++ b/tools/xl/xl_console.c @@ -0,0 +1,130 @@ +/* + * Copyright 2009-2017 Citrix Ltd and other contributors + * + * 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_console(int argc, char **argv) +{ + uint32_t domid; + int opt = 0, num = 0; + libxl_console_type type = 0; + + SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) { + case 't': + if (!strcmp(optarg, "pv")) + type = LIBXL_CONSOLE_TYPE_PV; + else if (!strcmp(optarg, "serial")) + type = LIBXL_CONSOLE_TYPE_SERIAL; + else { + fprintf(stderr, "console type supported are: pv, serial\n"); + return EXIT_FAILURE; + } + break; + case 'n': + num = atoi(optarg); + break; + } + + domid = find_domain(argv[optind]); + if (!type) + libxl_primary_console_exec(ctx, domid, -1); + else + libxl_console_exec(ctx, domid, num, type, -1); + fprintf(stderr, "Unable to attach console\n"); + return EXIT_FAILURE; +} + +int main_vncviewer(int argc, char **argv) +{ + static const struct option opts[] = { + {"autopass", 0, 0, 'a'}, + {"vncviewer-autopass", 0, 0, 'a'}, + COMMON_LONG_OPTS + }; + uint32_t domid; + int opt, autopass = 0; + + SWITCH_FOREACH_OPT(opt, "a", opts, "vncviewer", 1) { + case 'a': + autopass = 1; + break; + } + + domid = find_domain(argv[optind]); + + libxl_vncviewer_exec(ctx, domid, autopass); + + return EXIT_FAILURE; +} + +/* Channel is just a console in disguise, so put it here */ +int main_channellist(int argc, char **argv) +{ + int opt; + libxl_device_channel *channels; + libxl_channelinfo channelinfo; + int nb, i; + + SWITCH_FOREACH_OPT(opt, "", NULL, "channel-list", 1) { + /* No options */ + } + + /* Idx BE state evt-ch ring-ref connection params*/ + printf("%-3s %-2s %-5s %-6s %8s %-10s %-30s\n", + "Idx", "BE", "state", "evt-ch", "ring-ref", "connection", ""); + for (argv += optind, argc -= optind; argc > 0; --argc, ++argv) { + uint32_t domid = find_domain(*argv); + channels = libxl_device_channel_list(ctx, domid, &nb); + if (!channels) + continue; + for (i = 0; i < nb; ++i) { + if (!libxl_device_channel_getinfo(ctx, domid, &channels[i], + &channelinfo)) { + printf("%-3d %-2d ", channels[i].devid, channelinfo.backend_id); + printf("%-5d ", channelinfo.state); + printf("%-6d %-8d ", channelinfo.evtch, channelinfo.rref); + printf("%-10s ", libxl_channel_connection_to_string( + channels[i].connection)); + switch (channels[i].connection) { + case LIBXL_CHANNEL_CONNECTION_PTY: + printf("%-30s ", channelinfo.u.pty.path); + break; + default: + break; + } + printf("\n"); + libxl_channelinfo_dispose(&channelinfo); + } + libxl_device_channel_dispose(&channels[i]); + } + free(channels); + } + return 0; +} + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */