From nobody Sat Nov 23 15:21:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1723635425; cv=none; d=zohomail.com; s=zohoarc; b=YyfSZztEXZbqwxLuAL4Uu/Ma16i63Du4xNw4SjUsLxt8K6G72rIrCKt56qTK0RqSjHP6zSCg/WC7UlVezqbBFr4L9kyycbbpGrA4Grd5ZwkROwx200S28ipfCDICKsFAYTQ2NV7wDd3fz3EyXtWfgqJHu0UmINmEsGeRKP5vXIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723635425; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=RPsbIq7IDip/NUU1AfdaXAU3dpwbeaJDWgBGEc2M4Bc=; b=GEan+51qpCFdTw36H7u1p/7HVFG4dhATphrh4xzqCgNUEfXzGqNZsb35pFbF/H6YEC2YC7qlWZvzLCugvQ61mKNUThetyvHdfpxuKcpA9oBkhYB2rbI7zgifuwt72WN+TkBePJLeW/nZGaFEUOVBOlwu8fheao9dJIRYx/y51fI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172363542504574.27114120339525; Wed, 14 Aug 2024 04:37:05 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EA92312B1; Wed, 14 Aug 2024 07:37:03 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id F343D13D9; Wed, 14 Aug 2024 07:36:26 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B7BAC127C; Wed, 14 Aug 2024 07:36:23 -0400 (EDT) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (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 2226B127B for ; Wed, 14 Aug 2024 07:36:23 -0400 (EDT) Received: from [130.117.225.1] (helo=vz9-barybin-2.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1seCGw-00GWTt-12; Wed, 14 Aug 2024 13:36:09 +0200 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=5NUuYrUiwN0CoNTOYMBOjHTgK2pmDPSEr2rVYpqtKZM=; b=LZGpHT/Plutw mLUUm0jCgmFKGuyL8JjiEXilscyVP95FD/fFHGlkxrgkA+ps2/+3AiRPK73xyD9TxVb7eVbrgJ9sd KnYCrpqZoVwMwy6I9lv86Tki0MOCv6jZS6pSi462aTnbCxdT3d1rhM1sQNVDn3iqh/l52foUZ8vDI IJkqWBceWvWbiw8Pfy0rVKhcFaPfN6U69Tf/bbRXRquQxzzzA3hTrxgVQsA/O2aNJsyqeY5rh0tzU NSnkIHUdb/p3+V9gG8P+U9oiA5OB0w9xX606+aEnHUGYe+lmcxQqzS5Nuw3M52XcRyYD0wb9ru3Nz UJ2vVXRogZXtNUIGXLuXVQ==; To: devel@lists.libvirt.org Subject: [PATCH 1/1] virsh: allow both --table and --uuid at the same time Date: Wed, 14 Aug 2024 14:30:02 +0300 Message-ID: <20240814113617.76612-2-nikolai.barybin@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240814113617.76612-1-nikolai.barybin@virtuozzo.com> References: <20240814113617.76612-1-nikolai.barybin@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5HCUINWFGXS2MA3IEVDHR27D3ZMWTVYN X-Message-ID-Hash: 5HCUINWFGXS2MA3IEVDHR27D3ZMWTVYN X-MailFrom: nikolai.barybin@virtuozzo.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 CC: den@openvz.org, Nikolai Barybin 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: From: Nikolai Barybin via Devel Reply-To: Nikolai Barybin X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1723635426751116600 Content-Type: text/plain; charset="utf-8" This will allow to print full domains info: Id Name State UUID Reviewed-by: Michal Privoznik --------------------------- Signed-off-by: Nikolai Barybin --- docs/manpages/virsh.rst | 14 +++++++------- tools/virsh-domain-monitor.c | 37 ++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index fa038e4547..f02a28156d 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -648,7 +648,7 @@ list =20 list [--inactive | --all] [--managed-save] [--title] - { [--table] | --name | --uuid | --id } + { [--table] | --name | --id } [--uuid] [--persistent] [--transient] [--with-managed-save] [--without-managed-save] [--autostart] [--no-autostart] @@ -791,12 +791,12 @@ are printed instead of names. If *--id* is specified = then domain's ID's are printed indead of names. However, it is possible to combine *--name*, *--uuid* and *--id* to select only desired fields for printing. Flag *--table* specifies that the legacy table-formatted -output should be used, but it is mutually exclusive with *--name*, -*--uuid* and *--id*. This is the default and will be used if neither of -*--name*, *--uuid* or *--id* is specified. If neither *--name* nor *--uuid= * is -specified, but *--id* is, then only active domains are listed, even with t= he -*--all* parameter as otherwise the output would just contain bunch of lines -with just *-1*. +output should be used, but it is mutually exclusive with *--name*, and *--= id*. +This is the default and will be used if neither of *--name*, *--uuid* or *= --id* +is specified. If neither *--name* nor *--uuid* is specified, but *--id* is, +then only active domains are listed, even with the *--all* parameter as ot= herwise +the output would just contain bunch of lines with just *-1*. If *--table* = is +combined with *--uuid*, then domain uuid is printed as an extra column. =20 If *--title* is specified, then the short domain description (title) is printed in an extra column. This flag is usable only with the default diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index ef07ace577..74deca2f94 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1855,10 +1855,9 @@ cmdList(vshControl *ctl, const vshCmd *cmd) FILTER("state-other", VIR_CONNECT_LIST_DOMAINS_OTHER); =20 VSH_EXCLUSIVE_OPTIONS("table", "name"); - VSH_EXCLUSIVE_OPTIONS("table", "uuid"); VSH_EXCLUSIVE_OPTIONS("table", "id"); =20 - if (!optUUID && !optName && !optID) + if (!optName && !optID) optTable =3D true; =20 if (!(list =3D virshDomainListCollect(ctl, flags))) @@ -1866,8 +1865,12 @@ cmdList(vshControl *ctl, const vshCmd *cmd) =20 /* print table header in legacy mode */ if (optTable) { - if (optTitle) + if (optTitle && !optUUID) table =3D vshTableNew(_("Id"), _("Name"), _("State"), _("Title= "), NULL); + else if (optUUID && !optTitle) + table =3D vshTableNew(_("Id"), _("Name"), _("State"), _("UUID"= ), NULL); + else if (optUUID && optTitle) + table =3D vshTableNew(_("Id"), _("Name"), _("State"), _("Title= "), _("UUID"), NULL); else table =3D vshTableNew(_("Id"), _("Name"), _("State"), NULL); =20 @@ -1896,7 +1899,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd) virDomainHasManagedSaveImage(dom, 0) > 0) state =3D -2; =20 - if (optTitle) { + if (optTitle && !optUUID) { g_autofree char *title =3D NULL; =20 if (!(title =3D virshGetDomainDescription(ctl, dom, true, = 0))) @@ -1907,6 +1910,32 @@ cmdList(vshControl *ctl, const vshCmd *cmd) : virshDomainStateToString(state), title, NULL) < 0) goto cleanup; + } else if (optUUID && !optTitle) { + if (virDomainGetUUIDString(dom, uuid) < 0) { + vshError(ctl, "%s", _("Failed to get domain's UUID")); + goto cleanup; + } + if (vshTableRowAppend(table, id_buf, + virDomainGetName(dom), + state =3D=3D -2 ? _("saved") + : virshDomainStateToString(state), + uuid, NULL) < 0) + goto cleanup; + } else if (optUUID && optTitle) { + g_autofree char *title =3D NULL; + + if (!(title =3D virshGetDomainDescription(ctl, dom, true, = 0))) + goto cleanup; + if (virDomainGetUUIDString(dom, uuid) < 0) { + vshError(ctl, "%s", _("Failed to get domain's UUID")); + goto cleanup; + } + if (vshTableRowAppend(table, id_buf, + virDomainGetName(dom), + state =3D=3D -2 ? _("saved") + : virshDomainStateToString(state), + title, uuid, NULL) < 0) + goto cleanup; } else { if (vshTableRowAppend(table, id_buf, virDomainGetName(dom), --=20 2.43.5