From nobody Tue Feb 10 05:09:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1597762122; cv=none; d=zohomail.com; s=zohoarc; b=NuBA7nxace8TxIC9Q6FwbCbIx8KdNZDI54yGYdp7HqyMK0dwUeQzdGaJssVWDf2JqwIO7y8yEju1rgUhSNPWV635WZVK7yE+U5PSdDEMoemjdDijAVfxyKmDQg2bU5j/caGqZqOEpHwGLNWe7/hjD2x+zOBN8cYFhviLxTD184E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597762122; h=Content-Type:Content-Transfer-Encoding:Cc: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=WXYAK0huD5TjaMKndBZheWE88uJZdhprvv4sewZYC0M=; b=ZFM0calNLsqPjyAKWhRSZe9d+0IYPE51rC5pagbJUlFZs/YLPo6b9HT13FFA9QBmdjsyDmtt7MLFBgOgnfS8JIJuO3aDX+KqneKBsYjknDqQ126NR7e/yF+KY7dcaYdbtv+UqaqOkCrxGYghZf2JqV173a+7hwgSGxFrWn5COYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1597762122149810.9435264630234; Tue, 18 Aug 2020 07:48:42 -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-451-jMOyIkAeMbq3N3lTLUuqUw-1; Tue, 18 Aug 2020 10:48:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F8541DE03; Tue, 18 Aug 2020 14:48:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D7C22CFC6; Tue, 18 Aug 2020 14:48:29 +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 DC806181A07C; Tue, 18 Aug 2020 14:48:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07IEmBi5002736 for ; Tue, 18 Aug 2020 10:48:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 853AC5D6BD; Tue, 18 Aug 2020 14:48:11 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-113-237.phx2.redhat.com [10.3.113.237]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48F937DFC2; Tue, 18 Aug 2020 14:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597762121; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=WXYAK0huD5TjaMKndBZheWE88uJZdhprvv4sewZYC0M=; b=gcmQ3ri1lZeXdunhnGWGKUcBoTeuHBUlJJWqDQ6ZOmKbg7bv3Ckx7v2xHoxaFEhL+HdEwn wzNmZgmfDD6ekL608YdQZ+WK7S+jaRy+CmtwTFt9HiXATztmpCTE98sBY1H829hPeTzJcF yn2Ab/T51x5DS9ZN/L/f0yGCg2uBDls= X-MC-Unique: jMOyIkAeMbq3N3lTLUuqUw-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/16] virsh: Add --active, --inactive, --all to nodedev-list Date: Tue, 18 Aug 2020 09:47:54 -0500 Message-Id: <20200818144806.134738-5-jjongsma@redhat.com> In-Reply-To: <20200818144806.134738-1-jjongsma@redhat.com> References: <20200818144806.134738-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: eskultet@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.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 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 e576b3c847..e87761188f 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -378,6 +378,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 @@ -393,18 +405,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")); @@ -466,6 +488,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.26.2