From nobody Mon Feb 9 23:39:23 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=1608819484; cv=none; d=zohomail.com; s=zohoarc; b=g73wnuSzytOAGHeGLSz+rEVPbcBRGxojkMD8cfAaqHeLl/C7sqYTij2FsKwhasJAVP9o6coSsKKxccOhX6K6Jg7fIw+c6TigkSZC7OoL4/zZIjEuNdlMCk2RkGhF4/OMoUjfcHY1tp5E2gfeVdAntmEJBYPmqoYy/pUnawEMRik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608819484; 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=2odeIo/PkFoTZWAhph0M4hfG+X2GuLgSFW71dGNypk8=; b=c4lkSTZjTfZ9gG916sEQTwsoxWBy7aABs55d6lXyK3oHv+QbY39nCDsyado+cNnrox1s6ds7ljRyE73xn4h5oOkCDttWIs2Z6ByZvNEOE9JoVXLp8UC145rgLC7+SoXSMdivGhhvSOQEoDyaLYSx6KvBjpB97zwQEBKOz4yDeF8= 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 1608819484280106.3362873336157; Thu, 24 Dec 2020 06:18: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-240-9YKgt5e6OACUMEVzbwtFTA-1; Thu, 24 Dec 2020 09:15:28 -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 2B77A190D349; Thu, 24 Dec 2020 14:15:23 +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 095F45D9C6; Thu, 24 Dec 2020 14:15:23 +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 C673C5003D; Thu, 24 Dec 2020 14:15:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BOEEvjm005725 for ; Thu, 24 Dec 2020 09:14:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 41CCC5C253; Thu, 24 Dec 2020 14:14:57 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-112-15.phx2.redhat.com [10.3.112.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0E265C1A3; Thu, 24 Dec 2020 14:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608819483; 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=2odeIo/PkFoTZWAhph0M4hfG+X2GuLgSFW71dGNypk8=; b=NeMVEIPfexnVws7PIH0qOdASpDkLelyNJLl5i4Kyy4lFf/ACh2Z1gS5/FCrDPx/2iIzYIy Crr6EojlirqGjahZ1UHIipUwIZNT8tojHsoVYZL6EWrjr5/pNpomRW3ldc64TaUSbNc82S 8xME79vnyyPDK5uTzMxt4KRk9dN+5KQ= X-MC-Unique: 9YKgt5e6OACUMEVzbwtFTA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v3 18/21] virsh: add nodedev-undefine command Date: Thu, 24 Dec 2020 08:14:42 -0600 Message-Id: <20201224141445.163819-19-jjongsma@redhat.com> In-Reply-To: <20201224141445.163819-1-jjongsma@redhat.com> References: <20201224141445.163819-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 5df75013de..97d2a34056 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1012,6 +1012,65 @@ 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 "name", + .type =3D VSH_OT_ALIAS, + .help =3D "device" + }, + {.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) { + vshError(ctl, "%s '%s'", _("Could not find matching device"), devi= ce_value); + 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 */ @@ -1123,5 +1182,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