From nobody Mon Feb 9 20:10:26 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=1616777342; cv=none; d=zohomail.com; s=zohoarc; b=FTkZA4YEGaHZodVLDf0ofPMunzXuYHYdhJBa0Bx1GwKlNLF9mbbzEWeBQW5s2kIFblE+cPgxC3CI4kj3f8bQH3btWdhyM37eTfvnNk+miSJYq0+mGjLPjL4r8THVF3A0yGotn4Q78Rx3guSejC44ZiauyKDobJSLFfukU1h97LY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616777342; 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=yfGLAM/L98gEsJYvSo5Zw+FQ4vaAi79fEs7+DpzHF88=; b=d/kvQNj2ECHVH9A5EzUkA30OP+ryQw+VEpyEt3RlvKyqQCSv78vqXVcDKK9IRfHyaMDXv5HZ7x5R6HnJTnpBAC0uRaaxA7vPXT0RQeeubJexWNhK3PJ8Yb2Wz2s/0PuXsTkE4sdFkcE+Ndfi5r6458nsxO38aBN4XFvoAmtMP70= 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 161677734295297.75136274162787; Fri, 26 Mar 2021 09:49:02 -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-565-VC_J0llEPMGJFv_vcesCQg-1; Fri, 26 Mar 2021 12:48:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE1E9814339; Fri, 26 Mar 2021 16:48:52 +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 9AD5C5D756; Fri, 26 Mar 2021 16:48:52 +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 59F0C4A707; Fri, 26 Mar 2021 16:48:52 +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 12QGmd18003041 for ; Fri, 26 Mar 2021 12:48:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id C50A05D72E; Fri, 26 Mar 2021 16:48:39 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-113-51.phx2.redhat.com [10.3.113.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D4365D6DC; Fri, 26 Mar 2021 16:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616777342; 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=yfGLAM/L98gEsJYvSo5Zw+FQ4vaAi79fEs7+DpzHF88=; b=Q/b61h4Ug481diDh4uP1D2pVB7hCjcRM5PohFOkTQRcje1V0QlPmoE20HFF8yBOGhfq0fK TGwBBO9cfRHT3mvigBvDZiYbCKiyUBcCIe/ODU4Ue5/6qB2AeFmpJsDnVwcDP8YPXmILb4 DeWrjTYK0Ll+XHNZi2+u105a3gVl5zE= X-MC-Unique: VC_J0llEPMGJFv_vcesCQg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 18/30] virsh: add nodedev-define command Date: Fri, 26 Mar 2021 11:48:14 -0500 Message-Id: <20210326164826.1720062-19-jjongsma@redhat.com> In-Reply-To: <20210326164826.1720062-1-jjongsma@redhat.com> References: <20210326164826.1720062-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.15 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 virNodeDeviceDefineXML(). Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety --- tools/virsh-nodedev.c | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 7ab5b264fc..1cbf2e082b 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1013,6 +1013,58 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cm= d) } =20 =20 +/* + * "nodedev-define" command + */ +static const vshCmdInfo info_node_device_define[] =3D { + {.name =3D "help", + .data =3D N_("Define a device by an xml file on a node") + }, + {.name =3D "desc", + .data =3D N_("Defines a persistent device on the node that can be " + "assigned to a domain. The device must be started before " + "it can be assigned to a domain.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_node_device_define[] =3D { + VIRSH_COMMON_OPT_FILE(N_("file containing an XML description " + "of the device")), + {.name =3D NULL} +}; + +static bool +cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) +{ + virNodeDevice *dev =3D NULL; + const char *from =3D NULL; + bool ret =3D true; + char *buffer; + virshControl *priv =3D ctl->privData; + + if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) + return false; + + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) + return false; + + dev =3D virNodeDeviceDefineXML(priv->conn, buffer, 0); + VIR_FREE(buffer); + + if (dev !=3D NULL) { + vshPrintExtra(ctl, _("Node device '%s' defined from '%s'\n"), + virNodeDeviceGetName(dev), from); + virNodeDeviceFree(dev); + } else { + vshError(ctl, _("Failed to define node device from '%s'"), from); + ret =3D false; + } + + return ret; +} + + const vshCmdDef nodedevCmds[] =3D { {.name =3D "nodedev-create", .handler =3D cmdNodeDeviceCreate, @@ -1066,5 +1118,11 @@ const vshCmdDef nodedevCmds[] =3D { .info =3D info_node_device_event, .flags =3D 0 }, + {.name =3D "nodedev-define", + .handler =3D cmdNodeDeviceDefine, + .opts =3D opts_node_device_define, + .info =3D info_node_device_define, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.26.3