From nobody Mon Feb 9 03:14:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1618308137; cv=none; d=zohomail.com; s=zohoarc; b=N0omEy/iphpk5xVD9mm++wIcI9vIQQILfWuX6FfHJDghCvOhSe0HgzB0K4nrfrw27I06vz9CmD85sKlh3FYqsvdnsff/HGjar0/mt5/VJVxCqW670NMeNsv0nRj0lybaTBY4VOL5q9KHmHSe8wEY5tPLZWGhvh0zKfLkxbs88U8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618308137; 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=WACPOGLefKgBd3gRvLKneWy/6bZiNpOhs235POaeowA=; b=BlxM62INdz4Tgw5emmPZUtUsUYqbsXv+JNByW2l5at2IFK6FgGE56jOwWYuCKeB7/DlcCvFL0isQ6gw6jyTLYTjDsJhzSNnbtvN0ycRVSKErmJrBAxkcVazmyYHWODX1JHAvNEFT8wUxE06svVBfJ9TZJ/L0aTkyKWWdZEhrZY4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1618308137831902.5060276012543; Tue, 13 Apr 2021 03:02:17 -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-22-a3orEb1gOtS7X3kDvIB3MA-1; Tue, 13 Apr 2021 06:02:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 800FC107ACCD; Tue, 13 Apr 2021 10:02:09 +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 E875760C04; Tue, 13 Apr 2021 10:02:08 +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 5CA001806D15; Tue, 13 Apr 2021 10:02:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DA26OB011366 for ; Tue, 13 Apr 2021 06:02:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A7EE1000324; Tue, 13 Apr 2021 10:02:06 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id B138210023B0 for ; Tue, 13 Apr 2021 10:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618308136; 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=WACPOGLefKgBd3gRvLKneWy/6bZiNpOhs235POaeowA=; b=S3gOIy6mAuzbK5PMgrIvoGOZTjbYkGc+4+hsOwQMXsEvAZsTfofto9kyWAUR4nBMP7OjM9 2hMx5y+FRUX51LtuQBpQGSvzvHJs26Cj+TOpY85YzIwxNP5mBGYpVFE9Df1eHyS19PIzY7 86SnAa18ujokdI7c3/nZBdvo9cgR3Ng= X-MC-Unique: a3orEb1gOtS7X3kDvIB3MA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/6] nodedev: Wait for device initialization in nodeDeviceCreate() Date: Tue, 13 Apr 2021 12:01:53 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.12 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" Although I have not experienced this in real life, there is a possible race condition when creating new device. If the nodedev driver is still enumerating devices (in a separate thread) and virNodeDeviceCreate() is called then it can lead to spurious results because the device enumeration thread is removing devices from or adding them to the internal list of devices (among with their states). Therefore, wait for things to settle down before proceeding with nodeDeviceCreate(). Signed-off-by: Michal Privoznik --- src/node_device/node_device_driver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 4678a0fc01..bc8a758c1c 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1399,6 +1399,9 @@ nodeDeviceCreate(virNodeDevice *device, =20 virCheckFlags(0, -1); =20 + if (nodeDeviceInitWait() < 0) + return -1; + if (!(obj =3D nodeDeviceObjFindByName(device->name))) return -1; =20 --=20 2.26.3