From nobody Sun May 19 03:02:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 171197999623257.85776925570656; Mon, 1 Apr 2024 06:59:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0C74F1BBC; Mon, 1 Apr 2024 09:59:55 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5A0821B2A; Mon, 1 Apr 2024 09:58:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3696C19EF; Mon, 1 Apr 2024 09:58:41 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A153C1AE8 for ; Mon, 1 Apr 2024 09:58:40 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-0xfrmCa9ONC3Q3I-ON-mfA-1; Mon, 01 Apr 2024 09:58:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75197800262 for ; Mon, 1 Apr 2024 13:58:38 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.36]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06D522166B31 for ; Mon, 1 Apr 2024 13:58:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 0xfrmCa9ONC3Q3I-ON-mfA-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 1/2] virsh: Show 'connected to console' message later Date: Mon, 1 Apr 2024 15:58:30 +0200 Message-ID: <20240401135831.1058306-2-abologna@redhat.com> In-Reply-To: <20240401135831.1058306-1-abologna@redhat.com> References: <20240401135831.1058306-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: OE546DQ3SG25P7YRZR5V5YSEWXNO2HZB X-Message-ID-Hash: OE546DQ3SG25P7YRZR5V5YSEWXNO2HZB X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1711979997618100001 Right now, we display the message before actually attempting to connect to the VM console. That operation, however, can fail for a number of reasons: for example, is the VM doesn't have a serial device, the output ends up looking like $ virsh console cirros Connected to domain 'cirros' Escape character is ^] (Ctrl + ]) error: internal error: cannot find character device The initial message is misleading. Change things so that it's only printed if we actually successfully connected to the VM console. Signed-off-by: Andrea Bolognani Reviewed-by: Peter Krempa --- tools/virsh-console.c | 19 +++++++++++++------ tools/virsh-domain.c | 7 ------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/virsh-console.c b/tools/virsh-console.c index 7c561a11f3..27f2d09f5f 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -418,12 +418,6 @@ virshRunConsole(vshControl *ctl, =20 sigemptyset(&sighandler.sa_mask); =20 - /* Put STDIN into raw mode so that stuff typed does not echo to the sc= reen - * (the TTY reads will result in it being echoed back already), and al= so - * ensure Ctrl-C, etc is blocked, and misc other bits */ - if (vshTTYMakeRaw(ctl, true) < 0) - goto resettty; - if (!(con =3D virConsoleNew())) goto resettty; =20 @@ -447,6 +441,19 @@ virshRunConsole(vshControl *ctl, if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0) goto cleanup; =20 + vshPrintExtra(ctl, _("Connected to domain '%1$s'\n"), virDomainGetName= (dom)); + vshPrintExtra(ctl, _("Escape character is %1$s"), priv->escapeChar); + if (priv->escapeChar[0] =3D=3D '^') + vshPrintExtra(ctl, " (Ctrl + %c)", priv->escapeChar[1]); + vshPrintExtra(ctl, "\n"); + fflush(stdout); + + /* Put STDIN into raw mode so that stuff typed does not echo to the sc= reen + * (the TTY reads will result in it being echoed back already), and al= so + * ensure Ctrl-C, etc is blocked, and misc other bits */ + if (vshTTYMakeRaw(ctl, true) < 0) + goto cleanup; + virObjectRef(con); if ((con->stdinWatch =3D virEventAddHandle(STDIN_FILENO, VIR_EVENT_HANDLE_READABLE, diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index cd37828660..148b78e878 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2987,7 +2987,6 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, unsigned int flags) { int state; - virshControl *priv =3D ctl->privData; =20 if ((state =3D virshDomainState(ctl, dom, NULL)) < 0) { vshError(ctl, "%s", _("Unable to get domain status")); @@ -3004,12 +3003,6 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, return false; } =20 - vshPrintExtra(ctl, _("Connected to domain '%1$s'\n"), virDomainGetName= (dom)); - vshPrintExtra(ctl, _("Escape character is %1$s"), priv->escapeChar); - if (priv->escapeChar[0] =3D=3D '^') - vshPrintExtra(ctl, " (Ctrl + %c)", priv->escapeChar[1]); - vshPrintExtra(ctl, "\n"); - fflush(stdout); if (virshRunConsole(ctl, dom, name, resume_domain, flags) =3D=3D 0) return true; =20 --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sun May 19 03:02:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1711980029697736.5650021458117; Mon, 1 Apr 2024 07:00:29 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 771A0175D; Mon, 1 Apr 2024 10:00:28 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6F0161C2B; Mon, 1 Apr 2024 09:58:51 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B49F91AE8; Mon, 1 Apr 2024 09:58:41 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5371319EF for ; Mon, 1 Apr 2024 09:58:41 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-RI50Hi3GO7ORCaBrLpsVcg-1; Mon, 01 Apr 2024 09:58:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B9BF1C54070 for ; Mon, 1 Apr 2024 13:58:39 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.36]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9BC62166B35 for ; Mon, 1 Apr 2024 13:58:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: RI50Hi3GO7ORCaBrLpsVcg-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH 2/2] virsh: Display more empathy towards inconsolable VMs :( Date: Mon, 1 Apr 2024 15:58:31 +0200 Message-ID: <20240401135831.1058306-3-abologna@redhat.com> In-Reply-To: <20240401135831.1058306-1-abologna@redhat.com> References: <20240401135831.1058306-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: OK3NP6P4YCL5YDNAHWTHYMLH46EDA5VH X-Message-ID-Hash: OK3NP6P4YCL5YDNAHWTHYMLH46EDA5VH X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1711980031931100001 After attempting, and failing, to console a sad VM, we get back to the user with a fairly sterile message such as error: internal error: character device serial0 is not using a PTY That doesn't properly communicate the extent of our regret for having been unable to cheer up the poor VM despite our best efforts. Try to put this sentiment into words; to further carry the message, also include a tasteful ASCII rendition of our sorrow. Signed-off-by: Andrea Bolognani --- tools/virsh-console.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/virsh-console.c b/tools/virsh-console.c index 27f2d09f5f..db67e3f974 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -438,8 +438,11 @@ virshRunConsole(vshControl *ctl, if (!con->st) goto cleanup; =20 - if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0) + if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0) { + vshError(ctl, _("Domain '%1$s' is utterly inconsolable :("), + virDomainGetName(dom)); goto cleanup; + } =20 vshPrintExtra(ctl, _("Connected to domain '%1$s'\n"), virDomainGetName= (dom)); vshPrintExtra(ctl, _("Escape character is %1$s"), priv->escapeChar); --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org