From nobody Tue Feb 10 07:40:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1689710141; cv=none; d=zohomail.com; s=zohoarc; b=JQchBCJ3LHuScIphd0EcLepeGT+vfSLT9qLB21vHfN1HozzKdd3LG/HeZ6uniX3WE9ouM1bKQ71yWQZATju7RCPy9dxbAcQwMZQ/6PRiufX/Lg59XrcTsocL7FidXfaocFUMz+BJ2fm2B5DskhO2vayK8d7HMHFXIMDwm6m5A9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689710141; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=cCrZhe42XoGDE2srOY0PvbOxku4fxZSll9HCze/ncwk=; b=XpUZ2+hTOr0qyZPC55I52C0HdASJtvhTmIFuWyx01yNn1mIvjHK5puxnd+wnb4N9xvZtlc6UhBPlCpgCuLWvqSa346lLQMprev0j+YfS9NVKTQ0PYw52xX5aOOEzQGvS3MIHPMklAtm/fWo+N5Ixh1V5MfQp+q60DeQgOH8IzDA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1689710141454138.24417240657522; Tue, 18 Jul 2023 12:55:41 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-149-nhFHi28XO-uRjuJ7iWVTEg-1; Tue, 18 Jul 2023 15:55:33 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A606D1C068CC; Tue, 18 Jul 2023 19:55:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 734B44CD0F8; Tue, 18 Jul 2023 19:55:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 41EBC1946594; Tue, 18 Jul 2023 19:55:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5DA55194658F for ; Tue, 18 Jul 2023 19:55:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E90241121315; Tue, 18 Jul 2023 19:55:26 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.32.196]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD89F1121314; Tue, 18 Jul 2023 19:55:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689710140; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cCrZhe42XoGDE2srOY0PvbOxku4fxZSll9HCze/ncwk=; b=PnwQVi3C3WnhhA+kYGKUmocdxtgaKmIQm56bC6Lv9/cUMcfXID4fxG6ZWvCEv/v0ZDbeaB DhrgOXwMW/ak3RrcFU3eC94ZT3oEQ1bcDkYOjsmDUw9t7aaR1TtWDDkfpJFNWpSdRgmbeh CWjq5Fs6K+fgjdrQsJ3l9u7s/l+h7GE= X-MC-Unique: nhFHi28XO-uRjuJ7iWVTEg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH] nodedev: report mdev persistence properly Date: Tue, 18 Jul 2023 14:55:26 -0500 Message-ID: <20230718195526.3995226-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fiuczy@linux.ibm.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689710141979100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Since commit 44a0f2f0, we now query mdevctl for transient (active) mdevs in order to gather attributes for the mdev. Unfortunately, this commit introduced a regression because nodeDeviceUpdateMediatedDevice() assumed that all mdevs returned from mdevctl were actually persistent mdevs but we were using it to update transient mdevs. Refactor the function so that we can use it to update both persistent and transient mdevs. Signed-off-by: Jonathon Jongsma Reviewed-by: Boris Fiuczynski Reviewed-by: Michal Privoznik --- src/node_device/node_device_driver.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index a2d0600560..5dc45ddbb4 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1339,11 +1339,12 @@ nodeDeviceDestroy(virNodeDevicePtr device) /* takes ownership of @def and potentially frees it. @def should not be us= ed * after returning from this function */ static int -nodeDeviceUpdateMediatedDevice(virNodeDeviceDef *def) +nodeDeviceUpdateMediatedDevice(virNodeDeviceDef *def, + bool defined) { virNodeDeviceObj *obj; virObjectEvent *event; - bool defined =3D false; + bool was_defined =3D false; g_autoptr(virNodeDeviceDef) owned =3D def; g_autofree char *name =3D g_strdup(owned->name); =20 @@ -1359,13 +1360,13 @@ nodeDeviceUpdateMediatedDevice(virNodeDeviceDef *de= f) bool changed; virNodeDeviceDef *olddef =3D virNodeDeviceObjGetDef(obj); =20 - defined =3D virNodeDeviceObjIsPersistent(obj); + was_defined =3D virNodeDeviceObjIsPersistent(obj); /* Active devices contain some additional information (e.g. sysfs * path) that is not provided by mdevctl, so re-use the existing * definition and copy over new mdev data */ changed =3D nodeDeviceDefCopyFromMdevctl(olddef, owned); =20 - if (defined && !changed) { + if (was_defined && !changed) { /* if this device was already defined and the definition * hasn't changed, there's nothing to do for this device */ virNodeDeviceObjEndAPI(&obj); @@ -1373,11 +1374,11 @@ nodeDeviceUpdateMediatedDevice(virNodeDeviceDef *de= f) } } =20 - /* all devices returned by virMdevctlListDefined() are persistent */ - virNodeDeviceObjSetPersistent(obj, true); + if (defined) + virNodeDeviceObjSetPersistent(obj, true); virNodeDeviceObjSetAutostart(obj, def->caps->data.mdev.autostart); =20 - if (!defined) + if (!was_defined && defined) event =3D virNodeDeviceEventLifecycleNew(name, VIR_NODE_DEVICE_EVENT_DEFIN= ED, 0); @@ -1447,7 +1448,7 @@ nodeDeviceDefineXML(virConnect *conn, * have already received the uuid from virMdevctlDefine(), we can simp= ly * add the provisional device to the list and return it immediately and * avoid this long delay. */ - if (nodeDeviceUpdateMediatedDevice(g_steal_pointer(&def)) < 0) + if (nodeDeviceUpdateMediatedDevice(g_steal_pointer(&def), true) < 0) return NULL; =20 return virGetNodeDevice(conn, name); @@ -1742,7 +1743,7 @@ nodeDeviceUpdateMediatedDevices(void) removeMissingPersistentMdev, &data); =20 for (i =3D 0; i < data.ndefs; i++) - if (nodeDeviceUpdateMediatedDevice(defs[i]) < 0) + if (nodeDeviceUpdateMediatedDevice(defs[i], true) < 0) return -1; =20 /* Update active/transient mdev devices */ @@ -1753,7 +1754,7 @@ nodeDeviceUpdateMediatedDevices(void) } =20 for (i =3D 0; i < act_ndefs; i++) - if (nodeDeviceUpdateMediatedDevice(act_defs[i]) < 0) + if (nodeDeviceUpdateMediatedDevice(act_defs[i], false) < 0) return -1; =20 return 0; --=20 2.41.0