From nobody Mon Feb 9 10:27:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594938139; cv=none; d=zohomail.com; s=zohoarc; b=EG4Zed95oMJVfGPIbBmmrJVn+p6eXkp0jnv67qJLDmh5lZEsvsqs+1mOuI5CUWgxV954HU7tLOu2G120UHyPXsUGgca3zwv8z7Ezoktdo+PzW0C9FIuFjX4vBSVIYA5TnFSFfA5otrOq3YkTci3lmxsr6CnFVbMi9vmWOhrVBP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594938139; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2JWWOAeq5FD/5e6wkT1wVnjPz3p1/u8zZyiX+Tg2DSc=; b=Nt7dzgz4EJcmPZMvj+zpf3lqSIlMQ5aKwtzrM+nBtsb4jjAoNk9Z0YFvFDJ6R1k+pdMjmMEorJ5/K3bHDkwyexCyD7PyAheV8VOd3fRXp6eQb+rrgwBElsDwzd0OfAeycyINDRHFpHHxwZsc3wXQ2keybm8HreX1pPHt54+c3EM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594938139486142.44408442211136; Thu, 16 Jul 2020 15:22:19 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391-Qjgt-DgRMvWPzdmK-rfpww-1; Thu, 16 Jul 2020 18:22:14 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7AEC100AA22; Thu, 16 Jul 2020 22:22:08 +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 A386F10013D7; Thu, 16 Jul 2020 22:22:08 +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 721F896242; Thu, 16 Jul 2020 22:22:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06GMLpPb022282 for ; Thu, 16 Jul 2020 18:21:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 722DF71664; Thu, 16 Jul 2020 22:21:51 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-112-38.phx2.redhat.com [10.3.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43EBE6FED1 for ; Thu, 16 Jul 2020 22:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594938138; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2JWWOAeq5FD/5e6wkT1wVnjPz3p1/u8zZyiX+Tg2DSc=; b=VxQ2DWtYnWeGh2Gq0TJbTB+crfrsw7hmgduFEMXNgqVHaQUr4TDolDOYm5T+S2YydsJc3J Xc0f2IhLfOLbrqiV6M7TqW34LGRAyBRG/cWYOTunNP0/7+wLtARFbK3X4pNRg57nuIGCjV b2V8m6fyaGx00m7YcTfG1CDYaDDUtvs= X-MC-Unique: Qjgt-DgRMvWPzdmK-rfpww-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 04/16] virsh: Add --active, --inactive, --all to nodedev-list Date: Thu, 16 Jul 2020 17:21:34 -0500 Message-Id: <20200716222146.1241-5-jjongsma@redhat.com> In-Reply-To: <20200716222146.1241-1-jjongsma@redhat.com> References: <20200716222146.1241-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now that we can filter active and inactive node devices in virConnectListAllNodeDevices(), add these switches to the virsh command. Eventual output (once everything is hooked up): virsh # nodedev-list --inactive --cap mdev mdev_07d8b8b0_7e04_4c0f_97ed_9214ce12723c mdev_927c040f_ae7d_4a35_966e_286ba6ebbe1c virsh # nodedev-list --active --cap mdev mdev_bd2ea955_3402_4252_8c17_7468083a0f26 virsh # nodedev-list --all --cap mdev mdev_07d8b8b0_7e04_4c0f_97ed_9214ce12723c mdev_927c040f_ae7d_4a35_966e_286ba6ebbe1c mdev_bd2ea955_3402_4252_8c17_7468083a0f26 Signed-off-by: Jonathon Jongsma --- tools/virsh-nodedev.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 7f091d7cf8..2fb6be504b 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -379,6 +379,18 @@ static const vshCmdOptDef opts_node_list_devices[] =3D= { .completer =3D virshNodeDeviceCapabilityNameCompleter, .help =3D N_("capability names, separated by comma") }, + {.name =3D "active", + .type =3D VSH_OT_BOOL, + .help =3D N_("list active devices") + }, + {.name =3D "inactive", + .type =3D VSH_OT_BOOL, + .help =3D N_("list inactive devices") + }, + {.name =3D "all", + .type =3D VSH_OT_BOOL, + .help =3D N_("list inactive & active devices") + }, {.name =3D NULL} }; =20 @@ -394,18 +406,28 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd= G_GNUC_UNUSED) int ncaps =3D 0; virshNodeDeviceListPtr list =3D NULL; int cap_type =3D -1; + bool active, inactive, all; =20 + active =3D vshCommandOptBool(cmd, "active"); + inactive =3D vshCommandOptBool(cmd, "inactive"); + all =3D vshCommandOptBool(cmd, "all"); ignore_value(vshCommandOptStringQuiet(ctl, cmd, "cap", &cap_str)); =20 if (cap_str) { - if (tree) { - vshError(ctl, "%s", _("Options --tree and --cap are incompatib= le")); - return false; - } if ((ncaps =3D vshStringToArray(cap_str, &caps)) < 0) return false; } =20 + if (all && (inactive || active)) { + vshError(ctl, "%s", _("Option --all is incompatible with --active = and --inactive")); + return false; + } + + if (tree && (cap_str || active || inactive)) { + vshError(ctl, "%s", _("Option --tree is incompatible with other op= tions")); + return false; + } + for (i =3D 0; i < ncaps; i++) { if ((cap_type =3D virNodeDevCapTypeFromString(caps[i])) < 0) { vshError(ctl, "%s", _("Invalid capability type")); @@ -467,6 +489,11 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd = G_GNUC_UNUSED) } } =20 + if (inactive || all) + flags |=3D VIR_CONNECT_LIST_NODE_DEVICES_INACTIVE; + if (active || all) + flags |=3D VIR_CONNECT_LIST_NODE_DEVICES_ACTIVE; + if (!(list =3D virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) { ret =3D false; goto cleanup; --=20 2.21.3