From nobody Tue Feb 10 13:16:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614724384; cv=none; d=zohomail.com; s=zohoarc; b=aGHOGW7f5vVWu0XU3DDMZsJz54JBgS4qwkg2jLwJucNET704G6tK01VdoTOzgqipyPFL3QDrUAmxIkkrpEDaAchgorZJumMrOWJbKMZMkbqjdRUSgXKhbiCKISlg3RIlezIgwnSkUWB/OQw8sI5QsjnlF6CEOj8ANTN1DUi2mqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614724384; 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=fQzWlox56rwsFkLHl5aYd7TUGm+l0tjZcGcHDQV39uU=; b=P/9rCnvSzcWRm9i2DCxfU/Snbfs8iEKFhhrjnf97hMgxCY+3CHFl1PmPVANish08gUMamfwjlvW1UYCuWW0r+amS62QfSc4z0ILvNHmrZEqsr3k/LNvYv413vkXKgtrqV/pHVByO6ThIgf75jVBRZzABoBzWJzwr80M3P7fuF0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614724384466960.3344824393281; Tue, 2 Mar 2021 14:33:04 -0800 (PST) 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-485-_UORiPljP1WQu84PfSZUyg-1; Tue, 02 Mar 2021 17:31:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF86280404A; Tue, 2 Mar 2021 22:31:48 +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 CEDDD29AB7; Tue, 2 Mar 2021 22:31:48 +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 929FD18077CF; Tue, 2 Mar 2021 22:31:48 +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 122MVImV007879 for ; Tue, 2 Mar 2021 17:31:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0143860C6D; Tue, 2 Mar 2021 22:31:18 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-115-28.phx2.redhat.com [10.3.115.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF60E60BFA; Tue, 2 Mar 2021 22:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614724383; 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=fQzWlox56rwsFkLHl5aYd7TUGm+l0tjZcGcHDQV39uU=; b=dd4oiQKp1FHdcJePvM0+uiyewIEnWQ+7fivLpjWvYveBwtCiEGCzm6yqDoIwdXbXegv3ya yb7HZnqIlGt+V9mRkju60P6FujZQnAkE52GoVT1fEqW0FjqVgedILhOTyfSou74gK0upUl OVl8PLPwvaDhrXJtOKL1pyw01IOGVB8= X-MC-Unique: _UORiPljP1WQu84PfSZUyg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v5 22/30] virsh: add nodedev-undefine command Date: Tue, 2 Mar 2021 16:30:57 -0600 Message-Id: <20210302223105.314580-23-jjongsma@redhat.com> In-Reply-To: <20210302223105.314580-1-jjongsma@redhat.com> References: <20210302223105.314580-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Add a virsh command that maps to virNodeDeviceUndefine(). Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety --- tools/virsh-nodedev.c | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index ed45ceea5e..fda955988b 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1007,6 +1007,59 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cm= d) } =20 =20 +/* + * "nodedev-undefine" command + */ +static const vshCmdInfo info_node_device_undefine[] =3D { + {.name =3D "help", + .data =3D N_("Undefine an inactive node device") + }, + {.name =3D "desc", + .data =3D N_("Undefines the configuration for an inactive node device= ") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_node_device_undefine[] =3D { + {.name =3D "device", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("device name or wwn pair in 'wwnn,wwpn' format"), + .completer =3D virshNodeDeviceNameCompleter, + }, + {.name =3D NULL} +}; + +static bool +cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) +{ + virNodeDevicePtr dev =3D NULL; + bool ret =3D false; + const char *device_value =3D NULL; + + if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) + return false; + + dev =3D vshFindNodeDevice(ctl, device_value); + + if (!dev) + goto cleanup; + + if (virNodeDeviceUndefine(dev) =3D=3D 0) { + vshPrintExtra(ctl, _("Undefined node device '%s'\n"), device_value= ); + } else { + vshError(ctl, _("Failed to undefine node device '%s'"), device_val= ue); + goto cleanup; + } + + ret =3D true; + cleanup: + if (dev) + virNodeDeviceFree(dev); + return ret; +} + + /* * "nodedev-define" command */ @@ -1118,5 +1171,11 @@ const vshCmdDef nodedevCmds[] =3D { .info =3D info_node_device_define, .flags =3D 0 }, + {.name =3D "nodedev-undefine", + .handler =3D cmdNodeDeviceUndefine, + .opts =3D opts_node_device_undefine, + .info =3D info_node_device_undefine, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.26.2