From nobody Mon Feb 9 17:58:22 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=1622751183; cv=none; d=zohomail.com; s=zohoarc; b=KLFYqPYwQ8Da5tulj9UbOjb0G+uLsq1VHpVtQkBRvkLtvVGzUuTfaFqyi1GWeHKGdM4FxJf9jGkZnSGkmW34k0UWoj4LuB/Kcy/9y0UM6JzvB/4at/axyVKGgW/TqrZ2nFddoy/GvA6hg3eD6NWrKVkSS2GOwM10SrutCFEyZF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622751183; 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=WAjNdMEYNL1MfAHimsZUdP6ICxe2+qrsvcdbW9uKiO0=; b=Fxl2B9aelGLAN+rxY/Py4LsLo7USqtMDe7MSvC4f/5xiJE9/yOwSt+c/krXFv+FBSnRFpU8Xg6SY445QBqZIFKbkk1INYvPvzmb+CzK4m7lSX9JQnRpu4dJ3j9/uMX9+emiASE9uobIbua7GQdDNkpkMeK0hTen5xJdnkXRz8dM= 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 1622751183000647.739206495051; Thu, 3 Jun 2021 13:13:03 -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-351-ro00oS-LPPOVH8J7qH1m6Q-1; Thu, 03 Jun 2021 16:12:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF142107ACE3; Thu, 3 Jun 2021 20:12:20 +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 91259687C5; Thu, 3 Jun 2021 20:12:20 +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 5688D180B651; Thu, 3 Jun 2021 20:12:20 +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 153KC2WX000768 for ; Thu, 3 Jun 2021 16:12:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 64C5119D7D; Thu, 3 Jun 2021 20:12:02 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-114-235.phx2.redhat.com [10.3.114.235]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 353B019C44 for ; Thu, 3 Jun 2021 20:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622751182; 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=WAjNdMEYNL1MfAHimsZUdP6ICxe2+qrsvcdbW9uKiO0=; b=PejUFeaHFXCYIaAkYSHlcYa50jo+omXSuYCl6blppgyMhRLQYNeVxcK6sELTGhAHOusxTh u5qVWrXOjmzxuBKpQOeM5R4qXzZUBFfCfwA+khpc/9zIuZtyHgkjT8VwF4uusZxP0tOOti x40xW56ESAGAKa+ZOQKpdXlHH30Dvb0= X-MC-Unique: ro00oS-LPPOVH8J7qH1m6Q-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 6/7] nodedev: Implement virNodeDeviceIsPersistent()/IsActive() Date: Thu, 3 Jun 2021 15:11:55 -0500 Message-Id: <20210603201156.3571972-7-jjongsma@redhat.com> In-Reply-To: <20210603201156.3571972-1-jjongsma@redhat.com> References: <20210603201156.3571972-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.79 on 10.5.11.13 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" Implement these new API functions in the nodedev driver. Signed-off-by: Jonathon Jongsma --- src/node_device/node_device_driver.c | 50 ++++++++++++++++++++++++++++ src/node_device/node_device_driver.h | 6 ++++ src/node_device/node_device_udev.c | 21 +++++++----- 3 files changed, 69 insertions(+), 8 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 9ebe609aa4..75391f18b8 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1804,3 +1804,53 @@ nodeDeviceGetAutostart(virNodeDevice *device, virNodeDeviceObjEndAPI(&obj); return ret; } + + +int +nodeDeviceIsPersistent(virNodeDevice *device) +{ + virNodeDeviceObj *obj =3D NULL; + virNodeDeviceDef *def =3D NULL; + int ret =3D -1; + + if (nodeDeviceInitWait() < 0) + return -1; + + if (!(obj =3D nodeDeviceObjFindByName(device->name))) + return -1; + def =3D virNodeDeviceObjGetDef(obj); + + if (virNodeDeviceIsPersistentEnsureACL(device->conn, def) < 0) + goto cleanup; + + ret =3D virNodeDeviceObjIsPersistent(obj); + + cleanup: + virNodeDeviceObjEndAPI(&obj); + return ret; +} + + +int +nodeDeviceIsActive(virNodeDevice *device) +{ + virNodeDeviceObj *obj =3D NULL; + virNodeDeviceDef *def =3D NULL; + int ret =3D -1; + + if (nodeDeviceInitWait() < 0) + return -1; + + if (!(obj =3D nodeDeviceObjFindByName(device->name))) + return -1; + def =3D virNodeDeviceObjGetDef(obj); + + if (virNodeDeviceIsActiveEnsureACL(device->conn, def) < 0) + goto cleanup; + + ret =3D virNodeDeviceObjIsActive(obj); + + cleanup: + virNodeDeviceObjEndAPI(&obj); + return ret; +} diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index d178a18180..744dd42632 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -180,6 +180,12 @@ int nodeDeviceGetAutostart(virNodeDevice *dev, int *autostart); =20 +int +nodeDeviceIsPersistent(virNodeDevice *dev); + +int +nodeDeviceIsActive(virNodeDevice *dev); + virCommand* nodeDeviceGetMdevctlSetAutostartCommand(virNodeDeviceDef *def, bool autostart, diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 21273083a6..eb15ccce7f 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1487,7 +1487,7 @@ udevAddOneDevice(struct udev_device *device) virObjectEvent *event =3D NULL; bool new_device =3D true; int ret =3D -1; - bool was_persistent =3D false; + bool persistent =3D true; bool autostart =3D true; bool is_mdev; =20 @@ -1518,7 +1518,8 @@ udevAddOneDevice(struct udev_device *device) =20 if (is_mdev) nodeDeviceDefCopyFromMdevctl(def, objdef); - was_persistent =3D virNodeDeviceObjIsPersistent(obj); + + persistent =3D virNodeDeviceObjIsPersistent(obj); autostart =3D virNodeDeviceObjIsAutostart(obj); =20 /* If the device was defined by mdevctl and was never instantiated= , it @@ -1527,11 +1528,12 @@ udevAddOneDevice(struct udev_device *device) =20 virNodeDeviceObjEndAPI(&obj); } else { - /* All non-mdev devices report themselves as autostart since they - * should still be present and active after a reboot unless the de= vice - * is removed from the host. Mediated devices can only be persiste= nt if - * they are in already in the device list from parsing the mdevctl - * output. */ + /* All non-mdev devices report themselves as persistent and autost= art + * since they should still be present and active after a reboot un= less + * the device is removed from the host. Mediated devices can only = be + * persistent if they are in already in the device list from parsi= ng + * the mdevctl output. */ + persistent =3D !is_mdev; autostart =3D !is_mdev; } =20 @@ -1539,7 +1541,7 @@ udevAddOneDevice(struct udev_device *device) * and the current definition will take its place. */ if (!(obj =3D virNodeDeviceObjListAssignDef(driver->devs, def))) goto cleanup; - virNodeDeviceObjSetPersistent(obj, was_persistent); + virNodeDeviceObjSetPersistent(obj, persistent); virNodeDeviceObjSetAutostart(obj, autostart); objdef =3D virNodeDeviceObjGetDef(obj); =20 @@ -1945,6 +1947,7 @@ udevSetupSystemDev(void) =20 virNodeDeviceObjSetActive(obj, true); virNodeDeviceObjSetAutostart(obj, true); + virNodeDeviceObjSetPersistent(obj, true); =20 virNodeDeviceObjEndAPI(&obj); =20 @@ -2348,6 +2351,8 @@ static virNodeDeviceDriver udevNodeDeviceDriver =3D { .nodeDeviceCreate =3D nodeDeviceCreate, /* 7.3.0 */ .nodeDeviceSetAutostart =3D nodeDeviceSetAutostart, /* 7.5.0 */ .nodeDeviceGetAutostart =3D nodeDeviceGetAutostart, /* 7.5.0 */ + .nodeDeviceIsPersistent =3D nodeDeviceIsPersistent, /* 7.5.0 */ + .nodeDeviceIsActive =3D nodeDeviceIsActive, /* 7.5.0 */ }; =20 =20 --=20 2.31.1