From nobody Mon Feb 9 17:58:36 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=1629498880; cv=none; d=zohomail.com; s=zohoarc; b=ITTvhljKoGUftj/6PgoEoIosY2OGgHFyajflYaJDEZnOHwK9Af4K4Y66N7+75Bn8rkNiq1nUQl1NEuzNwZ9diHV3HeB6WT8Xfwpz19oaiTqm71ENQFGMkhfZqKcZJlNRfIg4LPrBTEBzCG1V3sIH4Isr15gbmbr1JJaUSbVlTBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629498880; 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=v9aBS8vzwLhXihyCdV0EpLVWV44klfGx+xxhucVVeBw=; b=ezLs6sIldqH7LCcAOYohqUkcBlP7Ntt63l2Cc9EZ2DRaWXIdafxOu04u9UoSykWu9GRI9Hr1xPbw7mszlUsTR/tjtLvsAc+MBE801xMYHcdmmXSfThR+bDdyYnzwj6Nr/OXkKnRO1oMnvWSqizqnvxqBofosLxX6da5UPJDWUT8= 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 1629498880220413.1092038979824; Fri, 20 Aug 2021 15:34:40 -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-39-GHtb9mZNOeShrfXVdDxinA-1; Fri, 20 Aug 2021 18:34:37 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B011E2E76; Fri, 20 Aug 2021 22:34:32 +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 4EC371F5; Fri, 20 Aug 2021 22:34:32 +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 CB6514A7CA; Fri, 20 Aug 2021 22:34:30 +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 17KMTeZG028144 for ; Fri, 20 Aug 2021 18:29:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id E57511F5; Fri, 20 Aug 2021 22:29:40 +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 980141971B; Fri, 20 Aug 2021 22:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629498879; 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=v9aBS8vzwLhXihyCdV0EpLVWV44klfGx+xxhucVVeBw=; b=HzDdMro2RuOB6ZcLgsPhjRtsPtkWMSMwniLAO1A9QLDRRlL+WUuYm6lpjDsgO39/+LX43z WQ/m9fGv/lgqbaHK9AmVunAfmCJWoq7h3MKWZYrhoITzqhiDgyGmzfTkLequyuL6UFWvjn 9gc0BwGsXbo23XKStkYribbJzs8aLug= X-MC-Unique: GHtb9mZNOeShrfXVdDxinA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v3 1/7] api: add virNodeDevice(Get|Set)Autostart() Date: Fri, 20 Aug 2021 17:29:29 -0500 Message-Id: <20210820222935.3414029-2-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.23 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: 1629498881139100001 This will allow persistent mediated devices to be configured to be restarted automatically when the host reboots. Signed-off-by: Jonathon Jongsma Reviewed-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-nodedev.h | 6 +++ src/driver-nodedev.h | 10 ++++ src/libvirt-nodedev.c | 76 +++++++++++++++++++++++++++++++ src/libvirt_public.syms | 2 + src/remote/remote_driver.c | 4 +- src/remote/remote_protocol.x | 29 +++++++++++- src/remote_protocol-structs | 12 +++++ 7 files changed, 137 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-no= dedev.h index 067d914d37..0e841ada8a 100644 --- a/include/libvirt/libvirt-nodedev.h +++ b/include/libvirt/libvirt-nodedev.h @@ -141,6 +141,12 @@ int virNodeDeviceUndefine(virNodeDevicePtr dev, int virNodeDeviceCreate(virNodeDevicePtr dev, unsigned int flags); =20 +int virNodeDeviceSetAutostart(virNodeDevicePtr dev, + int autostart); + +int virNodeDeviceGetAutostart(virNodeDevicePtr dev, + int *autostart); + /** * VIR_NODE_DEVICE_EVENT_CALLBACK: * diff --git a/src/driver-nodedev.h b/src/driver-nodedev.h index dd56421a54..125f4cfd9e 100644 --- a/src/driver-nodedev.h +++ b/src/driver-nodedev.h @@ -87,6 +87,14 @@ typedef int (*virDrvNodeDeviceCreate)(virNodeDevicePtr dev, unsigned int flags); =20 +typedef int +(*virDrvNodeDeviceSetAutostart)(virNodeDevicePtr dev, + int autostart); + +typedef int +(*virDrvNodeDeviceGetAutostart)(virNodeDevicePtr dev, + int *autostart); + typedef int (*virDrvConnectNodeDeviceEventRegisterAny)(virConnectPtr conn, virNodeDevicePtr dev, @@ -128,4 +136,6 @@ struct _virNodeDeviceDriver { virDrvNodeDeviceDefineXML nodeDeviceDefineXML; virDrvNodeDeviceUndefine nodeDeviceUndefine; virDrvNodeDeviceCreate nodeDeviceCreate; + virDrvNodeDeviceSetAutostart nodeDeviceSetAutostart; + virDrvNodeDeviceGetAutostart nodeDeviceGetAutostart; }; diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c index e416c12534..68fc83203d 100644 --- a/src/libvirt-nodedev.c +++ b/src/libvirt-nodedev.c @@ -979,3 +979,79 @@ virConnectNodeDeviceEventDeregisterAny(virConnectPtr c= onn, virDispatchError(conn); return -1; } + +/** + * virNodeDeviceSetAutostart: + * @dev: the device object + * @autostart: whether the device should be automatically started + * + * Configure the node device to be automatically started when the host mac= hine + * boots or the parent device becomes available. + * + * Returns -1 in case of error, 0 in case of success + */ +int +virNodeDeviceSetAutostart(virNodeDevicePtr dev, + int autostart) +{ + VIR_DEBUG("dev=3D%p", dev); + + virResetLastError(); + + virCheckNodeDeviceReturn(dev, -1); + virCheckReadOnlyGoto(dev->conn->flags, error); + + if (dev->conn->nodeDeviceDriver && + dev->conn->nodeDeviceDriver->nodeDeviceSetAutostart) { + int retval =3D dev->conn->nodeDeviceDriver->nodeDeviceSetAutostart= (dev, autostart); + if (retval < 0) + goto error; + + return 0; + } + + virReportUnsupportedError(); + + error: + virDispatchError(dev->conn); + return -1; +} + + +/** + * virNodeDeviceGetAutostart: + * @dev: the device object + * @autostart: the value returned + * + * Provides a boolean value indicating whether the node device is configur= ed to + * be automatically started when the host machine boots or the parent devi= ce + * becomes available. + * + * Returns -1 in case of error, 0 in case of success + */ +int +virNodeDeviceGetAutostart(virNodeDevicePtr dev, + int *autostart) +{ + VIR_DEBUG("dev=3D%p", dev); + + virResetLastError(); + + virCheckNodeDeviceReturn(dev, -1); + virCheckReadOnlyGoto(dev->conn->flags, error); + + if (dev->conn->nodeDeviceDriver && + dev->conn->nodeDeviceDriver->nodeDeviceGetAutostart) { + int retval =3D dev->conn->nodeDeviceDriver->nodeDeviceGetAutostart= (dev, autostart); + if (retval < 0) + goto error; + + return 0; + } + + virReportUnsupportedError(); + + error: + virDispatchError(dev->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 68f5e9c900..206b20f773 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -899,6 +899,8 @@ LIBVIRT_7.3.0 { LIBVIRT_7.7.0 { global: virNWFilterDefineXMLFlags; + virNodeDeviceSetAutostart; + virNodeDeviceGetAutostart; } LIBVIRT_7.3.0; =20 # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9ee22e7e15..d8febcf46f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8672,7 +8672,9 @@ static virNodeDeviceDriver node_device_driver =3D { .nodeDeviceCreate =3D remoteNodeDeviceCreate, /* 7.3.0 */ .nodeDeviceDefineXML =3D remoteNodeDeviceDefineXML, /* 7.3.0 */ .nodeDeviceUndefine =3D remoteNodeDeviceUndefine, /* 7.3.0 */ - .nodeDeviceDestroy =3D remoteNodeDeviceDestroy /* 0.6.3 */ + .nodeDeviceDestroy =3D remoteNodeDeviceDestroy, /* 0.6.3 */ + .nodeDeviceGetAutostart =3D remoteNodeDeviceGetAutostart, /* 7.7.0 */ + .nodeDeviceSetAutostart =3D remoteNodeDeviceSetAutostart, /* 7.7.0 */ }; =20 static virNWFilterDriver nwfilter_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 56f610839e..c4f26ecb4c 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2173,6 +2173,19 @@ struct remote_node_device_create_args { unsigned int flags; }; =20 +struct remote_node_device_get_autostart_args { + remote_nonnull_string name; +}; + +struct remote_node_device_get_autostart_ret { + int autostart; +}; + +struct remote_node_device_set_autostart_args { + remote_nonnull_string name; + int autostart; +}; + =20 /* * Events Register/Deregister: @@ -6801,5 +6814,19 @@ enum remote_procedure { * @acl: nwfilter:write * @acl: nwfilter:save */ - REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS =3D 431 + REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS =3D 431, + + /** + * @generate: both + * @priority: high + * @acl: node_device:read + */ + REMOTE_PROC_NODE_DEVICE_GET_AUTOSTART =3D 432, + + /** + * @generate: both + * @priority: high + * @acl: node_device:write + */ + REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART =3D 433 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index d51f12f781..dad3a418cb 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1622,6 +1622,16 @@ struct remote_node_device_create_args { remote_nonnull_string name; u_int flags; }; +struct remote_node_device_get_autostart_args { + remote_nonnull_string name; +}; +struct remote_node_device_get_autostart_ret { + int autostart; +}; +struct remote_node_device_set_autostart_args { + remote_nonnull_string name; + int autostart; +}; struct remote_connect_domain_event_register_ret { int cb_registered; }; @@ -3631,4 +3641,6 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_UNDEFINE =3D 429, REMOTE_PROC_NODE_DEVICE_CREATE =3D 430, REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS =3D 431, + REMOTE_PROC_NODE_DEVICE_GET_AUTOSTART =3D 432, + REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART =3D 433, }; --=20 2.31.1