From patchwork Mon Jul 3 06:34:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Schmoll X-Patchwork-Id: 9822049 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 7670760237 for ; Mon, 3 Jul 2017 06:36:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6146224B5B for ; Mon, 3 Jul 2017 06:36:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 563EC2810E; Mon, 3 Jul 2017 06:36:50 +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 C369924B5B for ; Mon, 3 Jul 2017 06:36:49 +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 1dRuwM-00022i-LV; Mon, 03 Jul 2017 06:34:34 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRuwL-00022Y-9v for xen-devel@lists.xenproject.org; Mon, 03 Jul 2017 06:34:33 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 07/8A-03582-875E9595; Mon, 03 Jul 2017 06:34:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRWlGSWpSXmKPExsXiVRvkqFvxNDL SYNlJRovvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPm3AssBR8NKi51/GNtYNyr2sXIxSEkMINR 4sXxV6wgDovAJRaJd4u+M4M4EgLvWCQmX53L2MXICeQkSfxf/40Fwi6XOPf7IJgtJKAp8aW7i xFi1HImiae9O9lAEmwCBhKzV15kBrFFBJQk7q2azARiMwu4SHTNawarERYwlnjY+w9sEIuAqk TfnmawZbwCdhJr/r5nglgmL7Gr7SLrBEa+BYwMqxg1ilOLylKLdA0N9ZKKMtMzSnITM3N0DQ3 M9HJTi4sT01NzEpOK9ZLzczcxAoOFAQh2MH5aFnCIUZKDSUmU1/VmZKQQX1J+SmVGYnFGfFFp TmrxIUYZDg4lCd6qJ0A5waLU9NSKtMwcYNjCpCU4eJREeA/cA0rzFhck5hZnpkOkTjFacmxYv f4LE8ekA9uB5KsJ/78xCbHk5eelSonz9oLMEwBpyCjNgxsHi61LjLJSwryMQAcK8RSkFuVmlq DKv2IU52BUEubNBpnCk5lXArf1FdBBTEAHNfREgBxUkoiQkmpg1Kty+JHG929dePsDw01Jnba 7JrjM28PBpTunTlG46q5C+LuPp57fkOXS2pFYef3MrZhryv26xSudwmPO7eVr+Zd5Q+vsw8V7 hU/nL2urOTJNIjb4UE7JP7GT7zpzj53S3eZx9p3tkUWesS99bqjpNaWuNNIKkHjyahW/M3t8h hVLSXWd4h19JZbijERDLeai4kQAF2DEW6gCAAA= X-Env-Sender: eggi.innovations@gmail.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1499063671!71393821!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29508 invoked from network); 3 Jul 2017 06:34:32 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 3 Jul 2017 06:34:32 -0000 Received: by mail-wm0-f65.google.com with SMTP id j85so18488352wmj.0 for ; Sun, 02 Jul 2017 23:34:31 -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; bh=U3eIu7n2K1vCg69usj+k6hf0IVV7za45C1vUAysZsvQ=; b=k5bOdfrLgIxVXCvXvxKinvdrkjUhBVXNMMpx/Pk1sjwwS7IVzD4STTJk4Q8FihnHTb kZVx4hYCi3ZmKoMM1URU47Xk5yqmQQWXZQq/wowEtbzfVMiU2hQtvspd/uqTJrkBfrGw Cn58/I2K4JSHa7MWwZ0W5mFnLosrqEzbhZ2biUYQfXRFd0P20Cq/7d3+gMDAJvDCuS4E DUGdXM+jx4NrewghUBfwzmMEQSjd+N1mU6uJZv8Pb+g6L3cJcge5OFMMVDm7ULtkUkby qluZR3zc+NzM710s9ldDa+h6tT9HqztVZbNwrEbsl8XkP8SW+QqOASxPKrE8NipkATCp LvJA== 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; bh=U3eIu7n2K1vCg69usj+k6hf0IVV7za45C1vUAysZsvQ=; b=frKhV0/AWJTzggEhmMDf8vBOJDRdZr5A9XzAXh3CSJ9nawaZiZCmJ5bp/NTQExYvqj EnrTwGrCVBgs6rM9emxTzl4p3Peu5ehF9UvgWn4VvnZNhL0vgwOCsqG4P1f7V8MMat0p jUH06usmFFY0NODxpkMsafS9GG59eqLEXTMRc8xuid4G7iXgCH9vscBcUGeutPraYhRb qQu0Dq8NtxFX4jHwEWid4XH3CxeDmCqJN34eAmVkiUTvLwDG6P2wgS7HMgH9OtuySXLe QbWzDCEEbaPOIKRxcF0OqAu/u0faf4plti2dCmGriLnUjLy6e6CinU/F7l6Mluj+tlGh reBQ== X-Gm-Message-State: AKS2vOxEzF9MDFLaavBQBqsEmFMkcjJDrCD5TUkfY3KUE3UoxeOvE+ie s9WfeaXjk0xJQ0MK8EE= X-Received: by 10.80.153.69 with SMTP id l5mr13457646edb.7.1499063671175; Sun, 02 Jul 2017 23:34:31 -0700 (PDT) Received: from localhost.localdomain (ip1f12fb3a.dynamic.kabel-deutschland.de. [31.18.251.58]) by smtp.gmail.com with ESMTPSA id z58sm7969125edb.50.2017.07.02.23.34.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jul 2017 23:34:30 -0700 (PDT) From: Felix Schmoll To: xen-devel@lists.xenproject.org Date: Mon, 3 Jul 2017 08:34:22 +0200 Message-Id: <20170703063422.1558-1-eggi.innovations@gmail.com> X-Mailer: git-send-email 2.11.0 Cc: wei.liu2@citrix.com, Felix Schmoll Subject: [Xen-devel] [PATCH] xl console: Add interactive option 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 Added an interactive option to the 'xl console'-command that forwards the input stream of the console to the underlying pty. Made corresponding changes to libxl, xl and xenconsole. Signed-off-by: Felix Schmoll --- tools/console/client/main.c | 4 ++++ tools/libxl/libxl.h | 5 +++-- tools/libxl/libxl_console.c | 19 ++++++++++++++----- tools/xl/xl_console.c | 11 +++++++---- tools/xl/xl_vmcontrol.c | 2 +- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index 977779f034..a3c4b00835 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -334,6 +334,7 @@ int main(int argc, char **argv) { "num", 1, 0, 'n' }, { "help", 0, 0, 'h' }, { "start-notify-fd", 1, 0, 's' }, + { "pipe", 0, 0, 'p' }, { 0 }, }; @@ -370,6 +371,9 @@ int main(int argc, char **argv) case 's': start_notify_fd = atoi(optarg); break; + case 'p': + interactive = 1; + break; default: fprintf(stderr, "Invalid argument\n"); fprintf(stderr, "Try `%s --help' for more information.\n", diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index cf8687aa7e..a55f9b1cc7 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -1499,7 +1499,8 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass); * the caller that it has connected to the guest console. */ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, - libxl_console_type type, int notify_fd); + libxl_console_type type, int notify_fd, + int interactive); /* libxl_primary_console_exec finds the domid and console number * corresponding to the primary console of the given vm, then calls * libxl_console_exec with the right arguments (domid might be different @@ -1511,7 +1512,7 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, * the caller that it has connected to the guest console. */ int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm, - int notify_fd); + int notify_fd, int interactive); #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040800 diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 446e766911..86b8062be6 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -51,7 +51,8 @@ out: } int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, - libxl_console_type type, int notify_fd) + libxl_console_type type, int notify_fd, + int interactive) { GC_INIT(ctx); char *p = GCSPRINTF("%s/xenconsole", libxl__private_bindir_path()); @@ -59,6 +60,7 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, char *cons_num_s = GCSPRINTF("%d", cons_num); char *notify_fd_s; char *cons_type_s; + char interactive_str[] = "--pipe"; switch (type) { case LIBXL_CONSOLE_TYPE_PV: @@ -71,13 +73,18 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, goto out; } + if(!interactive) { + interactive_str[0] = '\0'; + } + if (notify_fd != -1) { notify_fd_s = GCSPRINTF("%d", notify_fd); execl(p, p, domid_s, "--num", cons_num_s, "--type", cons_type_s, - "--start-notify-fd", notify_fd_s, (void *)NULL); + "--start-notify-fd", notify_fd_s, interactive_str, + (void *)NULL); } else { execl(p, p, domid_s, "--num", cons_num_s, "--type", cons_type_s, - (void *)NULL); + interactive_str, (void *)NULL); } out: @@ -151,7 +158,8 @@ out: return rc; } -int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm, int notify_fd) +int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm, + int notify_fd, int interactive) { uint32_t domid; int cons_num; @@ -160,7 +168,8 @@ int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm, int notify_fd) rc = libxl__primary_console_find(ctx, domid_vm, &domid, &cons_num, &type); if ( rc ) return rc; - return libxl_console_exec(ctx, domid, cons_num, type, notify_fd); + return libxl_console_exec(ctx, domid, cons_num, type, notify_fd, + interactive); } int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm, diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c index 0508ddaa32..68a2096dfc 100644 --- a/tools/xl/xl_console.c +++ b/tools/xl/xl_console.c @@ -25,10 +25,10 @@ int main_console(int argc, char **argv) { uint32_t domid; - int opt = 0, num = 0; + int opt = 0, num = 0, interactive = 0; libxl_console_type type = 0; - SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) { + SWITCH_FOREACH_OPT(opt, "n:t:i", NULL, "console", 1) { case 't': if (!strcmp(optarg, "pv")) type = LIBXL_CONSOLE_TYPE_PV; @@ -42,13 +42,16 @@ int main_console(int argc, char **argv) case 'n': num = atoi(optarg); break; + case 'i': + interactive = 1; + break; } domid = find_domain(argv[optind]); if (!type) - libxl_primary_console_exec(ctx, domid, -1); + libxl_primary_console_exec(ctx, domid, -1, interactive); else - libxl_console_exec(ctx, domid, num, type, -1); + libxl_console_exec(ctx, domid, num, type, -1, interactive); fprintf(stderr, "Unable to attach console\n"); return EXIT_FAILURE; } diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index 89c2b25ded..5472f43e6f 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -632,7 +632,7 @@ static void autoconnect_console(libxl_ctx *ctx_ignored, postfork(); sleep(1); - libxl_primary_console_exec(ctx, bldomid, notify_fd); + libxl_primary_console_exec(ctx, bldomid, notify_fd, 0); /* Do not return. xl continued in child process */ perror("xl: unable to exec console client"); _exit(1);