From nobody Tue Feb 10 09:24:35 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=1629498964; cv=none; d=zohomail.com; s=zohoarc; b=k3BsBi2PmUgxZ8+SFoDoL4A7oZS/M4K6GYrGSPoDZvKgPBJ3g+rp9AH7gjuvaFxn9mU/JY6oyoKmBx9QtFVR9PiZSYm4bOauwlXqZeRz7NQ/M3DYLRsNecoJLU6Nl04Jo+t3lnh4FPCprm/uL2iZxI0CZCE827o5IphUu6pXkKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629498964; 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=0M0yX9VUg+Q25cDgIxUHrCufNOWAbjPWpuG2EsSaU78=; b=Rf1vqErsteRQY/bi5Q7tdasKW1HcAs2sL+0871PpkMLX8F22DViKavgMr/oC/ZPjXFvy+xoENTToZKY7Wo3EEOi7ojGs6nt2vKcFYoeHrozInewJEu03ckqyb3QsGGeuf49MU2u8Ev23Nfobry3P/k2GZc8rxxPFqknvwBNC/gA= 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) 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 1629498964138973.9726411153073; Fri, 20 Aug 2021 15:36:04 -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-453-mTYEMwp3OWq1PyVk5nfV5w-1; Fri, 20 Aug 2021 18:35:18 -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 DAE6E1082921; Fri, 20 Aug 2021 22:35:13 +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 B52EB10190AA; Fri, 20 Aug 2021 22:35:13 +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 7EB58181A1D3; Fri, 20 Aug 2021 22:35:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KMTgXU028161 for ; Fri, 20 Aug 2021 18:29:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 16F8590BA; Fri, 20 Aug 2021 22:29:42 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-114-57.phx2.redhat.com [10.3.114.57]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD4281F5; Fri, 20 Aug 2021 22:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629498963; 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=0M0yX9VUg+Q25cDgIxUHrCufNOWAbjPWpuG2EsSaU78=; b=WVF4sOyPS58WqVwPItonORQPliWB+UHIjtx/0xNnm2QYwzpwRicD+RLkdPBuV8U/ORyICs pU4HFVHj7c8HUzqvhe3mYskhBfZvfwrucy48CVJVKWjY0CUzJ3rDRCtAfVcA5rvGJNdhni TipAhKExnOovwmXY9Fr/vYyAw2Klo1g= X-MC-Unique: mTYEMwp3OWq1PyVk5nfV5w-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v3 4/7] virsh: add nodedev-autostart Date: Fri, 20 Aug 2021 17:29:32 -0500 Message-Id: <20210820222935.3414029-5-jjongsma@redhat.com> In-Reply-To: <20210820222935.3414029-1-jjongsma@redhat.com> References: <20210820222935.3414029-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629498965042100001 Add ability to set node devices to autostart on boot or parent device availability. Signed-off-by: Jonathon Jongsma Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/manpages/virsh.rst | 15 +++++++++ tools/virsh-nodedev.c | 71 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e0cdabf3aa..08097a45bf 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5131,6 +5131,21 @@ When *--timestamp* is used, a human-readable timesta= mp will be printed before the event. =20 =20 +nodedev-autostart +----------------- + +**Syntax:** + +:: + + nodedev-autostart [--disable] device + +Configure a device to be automatically started when the host machine boots= or +the parent device becomes available. With *--disable*, the device will be = set +to manual mode and will no longer be automatically started by the host. Th= is +command is only supported for persistently-defined mediated devices. + + VIRTUAL NETWORK COMMANDS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 945ccc7f45..0a70029fc7 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1153,6 +1153,71 @@ cmdNodeDeviceStart(vshControl *ctl, const vshCmd *cm= d) } =20 =20 +/* + * "nodedev-autostart" command + */ +static const vshCmdInfo info_node_device_autostart[] =3D { + {.name =3D "help", + .data =3D N_("autostart a defined node device") + }, + {.name =3D "desc", + .data =3D N_("Configure a node device to be automatically started at = boot.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_node_device_autostart[] =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 "disable", + .type =3D VSH_OT_BOOL, + .help =3D N_("disable autostarting") + }, + {.name =3D NULL} +}; + +static bool +cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd) +{ + virNodeDevice *dev =3D NULL; + bool ret =3D false; + const char *name =3D NULL; + int autostart; + + if (vshCommandOptStringReq(ctl, cmd, "device", &name) < 0) + return false; + + dev =3D vshFindNodeDevice(ctl, name); + + if (!dev) goto cleanup; + + autostart =3D !vshCommandOptBool(cmd, "disable"); + + if (virNodeDeviceSetAutostart(dev, autostart) < 0) { + if (autostart) + vshError(ctl, _("failed to mark device %s as autostarted"), na= me); + else + vshError(ctl, _("failed to unmark device %s as autostarted"), = name); + goto cleanup; + } + + if (autostart) + vshPrintExtra(ctl, _("Device %s marked as autostarted\n"), name); + else + vshPrintExtra(ctl, _("Device %s unmarked as autostarted\n"), name); + + ret =3D true; + cleanup: + if (dev) + virNodeDeviceFree(dev); + return ret; +} + + const vshCmdDef nodedevCmds[] =3D { {.name =3D "nodedev-create", .handler =3D cmdNodeDeviceCreate, @@ -1224,5 +1289,11 @@ const vshCmdDef nodedevCmds[] =3D { .info =3D info_node_device_start, .flags =3D 0 }, + {.name =3D "nodedev-autostart", + .handler =3D cmdNodeDeviceAutostart, + .opts =3D opts_node_device_autostart, + .info =3D info_node_device_autostart, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.31.1