From nobody Wed May 8 06:47:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554145482415287.7357306306301; Mon, 1 Apr 2019 12:04:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BF8E5414B; Mon, 1 Apr 2019 19:04:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D25366061B; Mon, 1 Apr 2019 19:04:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0BDB041F3D; Mon, 1 Apr 2019 19:04:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x31J4ZhY018779 for ; Mon, 1 Apr 2019 15:04:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA82660C8A; Mon, 1 Apr 2019 19:04:35 +0000 (UTC) Received: from lpt.redhat.com (ovpn-204-36.brq.redhat.com [10.40.204.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6557360BFC for ; Mon, 1 Apr 2019 19:04:33 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 1 Apr 2019 21:04:52 +0200 Message-Id: <6981cc5ba7df8157442f1bbba30559525794d467.1554145474.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] virsh: cmdConsole: make --domain optional X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 01 Apr 2019 19:04:41 +0000 (UTC) In the absence of a domain parameter, console the user instead. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index afcd0a5f8d..de41f6312d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -49,6 +49,7 @@ #include "virsh-console.h" #include "virsh-domain-monitor.h" #include "virerror.h" +#include "virrandom.h" #include "virtime.h" #include "virtypedparam.h" #include "virxml.h" @@ -2972,7 +2973,7 @@ static const vshCmdInfo info_console[] =3D { }; =20 static const vshCmdOptDef opts_console[] =3D { - VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), + VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(0, VIR_CONNECT_LIST_DOMAINS_ACT= IVE), {.name =3D "devname", /* sc_prohibit_devname */ .type =3D VSH_OT_STRING, .help =3D N_("character device name") @@ -3023,6 +3024,23 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, return ret; } =20 +static const char * +constellation_phrases[] =3D { + "Everything is going to be all right.", + "Things are going to work out in the end.", + "Imagine pleasant nonsense", /* https://www.instagram.com/p/BuRfmkrBig= I/ */ + "Ursa Major", + "There, there.", +}; + +static void +cmdConsoleUser(vshControl *ctl) +{ + uint32_t die =3D virRandomInt(ARRAY_CARDINALITY(constellation_phrases)= ); + + vshPrintExtra(ctl, "%s", constellation_phrases[die]); +} + static bool cmdConsole(vshControl *ctl, const vshCmd *cmd) { @@ -3033,6 +3051,11 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) unsigned int flags =3D 0; const char *name =3D NULL; =20 + if (!vshCommandOptBool(cmd, "domain")) { + cmdConsoleUser(ctl); + return true; + } + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list