From nobody Tue May 21 21:00:58 2024 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=1618308148; cv=none; d=zohomail.com; s=zohoarc; b=W0K4M5C9dtrcpfzbktwTSUZ2r3rPhPwnDa6GNL5bZSLHCezbJLlXGi2yMUCq5Xl0gmon73R8kA4LbrnFqzbJCEr0Aa+cezr/6k6/VSU6+qZ71hc3W8PMd5X99NpgP4+4KWIpiD2LCnyXat2Qz2VPkQOkqrWaHKEFTcMy9jsC8Eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618308148; 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=VpI9U0txO+Vn3oDljz2e6PcWmSwu0QQUV1860ATOZ3Y=; b=Gnc3ZWxU/eJuLKv0zg8ojXcjmS4JYd25INsOO2zqp+kQcrYkr54Pea0BbIdNp/xcrQPFNTnojkvIgXuN7Ju7DQPBn3QpygYycb/e8K+WWV92BJGM9aiLmZkGJimiQw2NGG8m6FcpHL1IcfrBOrqhFuMiy/hNG1E4x813uDkMZ3o= 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 1618308148897201.15131370474398; Tue, 13 Apr 2021 03:02:28 -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-392-JHRBrP25N6GwV5_wld7HKA-1; Tue, 13 Apr 2021 06:02:22 -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 188C681746C; Tue, 13 Apr 2021 10:02:18 +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 D726319C46; Tue, 13 Apr 2021 10:02:17 +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 96BB244A5F; Tue, 13 Apr 2021 10:02:17 +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 13DA2518011353 for ; Tue, 13 Apr 2021 06:02:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F5DD10023B0; Tue, 13 Apr 2021 10:02:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id D60B41045D23 for ; Tue, 13 Apr 2021 10:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618308145; 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=VpI9U0txO+Vn3oDljz2e6PcWmSwu0QQUV1860ATOZ3Y=; b=iL4Hj/0OEDURZwxbTP5D59g6qb1DGMZSn5SaRAdih7x+gUQf4L3C0WoTdfeMXYHPiaxjJh nR6/LNnFCLTF8LJee6SIzlFBsDm09CALqpToproil2viCHItYMAyHBa/n7GxPTDNYok3ma WdNBsvH31rU0f35KLWsPMVwvBysjHMU= X-MC-Unique: JHRBrP25N6GwV5_wld7HKA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/6] nodedev: Rename nodeDeviceWaitInit() Date: Tue, 13 Apr 2021 12:01:52 +0200 Message-Id: <59a7b65b7f037ddfafd545d70727280f9292d133.1618307981.git.mprivozn@redhat.com> 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.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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The consensus is to put the verb last. Therefore, the new name is nodeDeviceInitWait(). This allows us to introduce new function (done later in a separate commit) that will "complete" the device initialization. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/node_device/node_device_driver.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index c11b8d89ab..4678a0fc01 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -158,7 +158,7 @@ nodeDeviceUnlock(void) =20 =20 static int -nodeDeviceWaitInit(void) +nodeDeviceInitWait(void) { nodeDeviceLock(); while (!driver->initialized) { @@ -183,7 +183,7 @@ nodeNumOfDevices(virConnectPtr conn, =20 virCheckFlags(0, -1); =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return -1; =20 return virNodeDeviceObjListNumOfDevices(driver->devs, conn, cap, @@ -203,7 +203,7 @@ nodeListDevices(virConnectPtr conn, =20 virCheckFlags(0, -1); =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return -1; =20 return virNodeDeviceObjListGetNames(driver->devs, conn, @@ -222,7 +222,7 @@ nodeConnectListAllNodeDevices(virConnectPtr conn, if (virConnectListAllNodeDevicesEnsureACL(conn) < 0) return -1; =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return -1; =20 return virNodeDeviceObjListExport(conn, driver->devs, devices, @@ -254,7 +254,7 @@ nodeDeviceLookupByName(virConnectPtr conn, virNodeDeviceDefPtr def; virNodeDevicePtr device =3D NULL; =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return NULL; =20 if (!(obj =3D nodeDeviceObjFindByName(name))) @@ -285,7 +285,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, =20 virCheckFlags(0, NULL); =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return NULL; =20 if (!(obj =3D virNodeDeviceObjListFindSCSIHostByWWNs(driver->devs, @@ -844,7 +844,7 @@ nodeDeviceCreateXML(virConnectPtr conn, =20 virCheckFlags(0, NULL); =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return NULL; =20 virt_type =3D virConnectGetType(conn); @@ -1144,7 +1144,7 @@ nodeDeviceDestroy(virNodeDevicePtr device) g_autofree char *wwpn =3D NULL; unsigned int parent_host; =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return -1; =20 if (!(obj =3D nodeDeviceObjFindByName(device->name))) @@ -1288,7 +1288,7 @@ nodeDeviceDefineXML(virConnect *conn, =20 virCheckFlags(0, NULL); =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return NULL; =20 virt_type =3D virConnectGetType(conn); @@ -1350,7 +1350,7 @@ nodeDeviceUndefine(virNodeDevice *device, =20 virCheckFlags(0, -1); =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return -1; =20 if (!(obj =3D nodeDeviceObjFindByName(device->name))) @@ -1446,7 +1446,7 @@ nodeConnectNodeDeviceEventRegisterAny(virConnectPtr c= onn, if (virConnectNodeDeviceEventRegisterAnyEnsureACL(conn) < 0) return -1; =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return -1; =20 if (virNodeDeviceEventStateRegisterID(conn, driver->nodeDeviceEventSta= te, @@ -1465,7 +1465,7 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr= conn, if (virConnectNodeDeviceEventDeregisterAnyEnsureACL(conn) < 0) return -1; =20 - if (nodeDeviceWaitInit() < 0) + if (nodeDeviceInitWait() < 0) return -1; =20 if (virObjectEventStateDeregisterID(conn, --=20 2.26.3 From nobody Tue May 21 21:00:58 2024 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 From nobody Tue May 21 21:00:58 2024 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=1618308151; cv=none; d=zohomail.com; s=zohoarc; b=OVV6fV2OjPgEBRxUgnWHfrgYPcqmWTSVEHAjepLIQ80KcMw/dZAkCs4Zxz8o7S8YM6eqwFQR4+m929+50/QaOJIb2pZfJOZ2f9viRRPNFj8HPeJSvp/fPXo2NVBXZL9ctzKvKaphXOvrJJsMZYahuM7GiIVlbTG/KLu9zzVNFLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618308151; 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=AA4vzWMtAWaDRJFIukVSMd+vjfJTBvva7A9WJ3o05lc=; b=Via2lLuNYcUhVnGZ6jQrgY0o6iKmfDGC9ilgqUxFCmQMXITg1/ro2W3U05Hsef2FIqNsElZGfnrutKifB3wcpoIYFo80cPvOs81AAwNYN1j6/5KnMWMKNVEiLHo25anpQbLlQ4E5eGhiUoVd19HyXyZMasYo6KHGFKO0ipHM9hc= 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 1618308151184107.64475707104327; Tue, 13 Apr 2021 03:02:31 -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-477-wkLeNIxkMziG36FPDaYEkA-1; Tue, 13 Apr 2021 06:02:27 -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 3E62C8030BB; Tue, 13 Apr 2021 10:02:21 +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 0C3FF1A870; Tue, 13 Apr 2021 10:02:21 +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 C3B3F1806D18; Tue, 13 Apr 2021 10:02:20 +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 13DA27Zl011374 for ; Tue, 13 Apr 2021 06:02:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 179C21045E95; Tue, 13 Apr 2021 10:02:07 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C9CF1000324 for ; Tue, 13 Apr 2021 10:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618308149; 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=AA4vzWMtAWaDRJFIukVSMd+vjfJTBvva7A9WJ3o05lc=; b=EvaB9x9X0VN5ae2pOloB/ve+YjPxFzQPkxFfX5cVAjEiCvbZWzKkb3eCpnO32cPuPlxCmb mGDXOHR2WDd1RwFVKBjIieStdjwoIMU67ii9YdPud0/Pxc+64p7WJi6cMHcrRR6HhIcEnR UIcPq324csWG/eZmXML7nkMDSFfi9Mg= X-MC-Unique: wkLeNIxkMziG36FPDaYEkA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/6] nodedev: Signal initCond with driver locked Date: Tue, 13 Apr 2021 12:01:54 +0200 Message-Id: <7ee86799a8c03be4224ed58a3fef27484ed72795.1618307981.git.mprivozn@redhat.com> 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.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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is more academic dispute than a real bug, but this is taken from pthread_cond_broadcast(3p) man: The pthread_cond_broadcast() or pthread_cond_signal() functions may be called by a thread whether or not it currently owns the mutex that threads calling pthread_cond_wait() or pthread_cond_timedwait() have associated with the condition variable during their waits; however, if predictable scheduling behavior is required, then that mutex shall be locked by the thread calling pthread_cond_broadcast() or pthread_cond_signal(). Therefore, broadcast the initCond while the nodedev driver is still locked. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/node_device/node_device_udev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 44f96f5ff9..20a13211a0 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1986,8 +1986,8 @@ nodeStateInitializeEnumerate(void *opaque) =20 nodeDeviceLock(); driver->initialized =3D true; - nodeDeviceUnlock(); virCondBroadcast(&driver->initCond); + nodeDeviceUnlock(); =20 return; =20 --=20 2.26.3 From nobody Tue May 21 21:00:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1618308140; cv=none; d=zohomail.com; s=zohoarc; b=d4e9hJoBQkfbJbRMSgEp3Q5LCBRc4nSNucegYrQP+IMAuwOicl/uyYSzFhu1IDbJXQaVlO+pNhfgp2qAnsMh6wyCJjR9MDOplN0phLH2MhJ1IdvrmLe+d9Z2PtjJe0B9GY/IiMWL1exknRqT4+KgMIHIxo2+0cvKEUkJI8dF+dU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618308140; 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=FD6BqgaJK/m25Ynci2rHsqUkUZKgJGt9WGugY2DORkM=; b=AHRg2OIp49wnPJIAkIIHB+YWJLE4UdZgxouFZPMZkyfEOgmbXcCEPchlZaYCZLagd7IvE/ybdyy+PmygwaZj0CxbCaFKxk7yT3lAUbMfsl1wMB546yy+Tw0TN85EWcwD1Tqj1Tcd+Sw7hHUh9ZBJiRZza50LO0bJO+l7ZzsDuhc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618308140094462.35194112886415; Tue, 13 Apr 2021 03:02:20 -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-572-Uyw8yDBgM4G0wdO-E-nL2w-1; Tue, 13 Apr 2021 06:02:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E59AB881286; Tue, 13 Apr 2021 10:02:10 +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 BFBCA5D9DE; Tue, 13 Apr 2021 10:02:10 +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 753C11806D17; Tue, 13 Apr 2021 10:02:10 +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 13DA27KX011379 for ; Tue, 13 Apr 2021 06:02:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id E71FC1042A9C; Tue, 13 Apr 2021 10:02:07 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 693E810429F0 for ; Tue, 13 Apr 2021 10:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618308138; 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=FD6BqgaJK/m25Ynci2rHsqUkUZKgJGt9WGugY2DORkM=; b=TCVgs9cuMgKRLQfBxWmzKLY5WNRAhSBlefsixPolSix+uDyhc7tmuOAXSfX4hj3aqFg9Hk x4pHz8usEQjFOra6C2wNKViN7j0GJ5XaytueeOnWfwB1ug1V3Jq7/eprxneDZETUTtvZSa wU83tcqcP24GFnt6b2hRhX9GmJC1AFo= X-MC-Unique: Uyw8yDBgM4G0wdO-E-nL2w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/6] nodedev: Introduce nodeDeviceInitComplete() Date: Tue, 13 Apr 2021 12:01:55 +0200 Message-Id: <6e85181cfb34a61a226e079f5391df0df749135a.1618307981.git.mprivozn@redhat.com> 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.14 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" When the device enumeration thread finishes it sets the driver->initialized boolean and signals condition to wake up other threads that are waiting for the initialization to complete. Move this code into a separate function so that it can be re-used from other places too. Signed-off-by: Michal Privoznik --- src/node_device/node_device_driver.c | 10 ++++++++++ src/node_device/node_device_driver.h | 2 ++ src/node_device/node_device_udev.c | 5 +---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index bc8a758c1c..2bb83c19f2 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -157,6 +157,16 @@ nodeDeviceUnlock(void) } =20 =20 +void +nodeDeviceInitComplete(void) +{ + nodeDeviceLock(); + driver->initialized =3D true; + virCondBroadcast(&driver->initCond); + nodeDeviceUnlock(); +} + + static int nodeDeviceInitWait(void) { diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index 8a935ffed6..7160f551db 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -39,6 +39,8 @@ nodeDeviceLock(void); void nodeDeviceUnlock(void); =20 +void nodeDeviceInitComplete(void); + extern virNodeDeviceDriverStatePtr driver; =20 int diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 20a13211a0..68547c6986 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1984,10 +1984,7 @@ nodeStateInitializeEnumerate(void *opaque) if (nodeDeviceUpdateMediatedDevices() !=3D 0) goto error; =20 - nodeDeviceLock(); - driver->initialized =3D true; - virCondBroadcast(&driver->initCond); - nodeDeviceUnlock(); + nodeDeviceInitComplete(); =20 return; =20 --=20 2.26.3 From nobody Tue May 21 21:00:58 2024 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=1618308146; cv=none; d=zohomail.com; s=zohoarc; b=XJI9bhJbZL7yIkgu+1mJCaPpNcEYcQUQKN36DALw3LNtyFaeGtVslRmxQDxoZRHzY+3NWOrG6t8LzJr7QyigMGdcPPa5Muqac7+DjCyQ2dQJir9A494THOj+SJjR2PfXmpt1wPBcUpWftbYB7Pc1bC6eykUwCNMNnmO0zXbuqmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618308146; 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=8HqW8uEz4nqNsPqCWFRn8+7lnR0liiG4VBT7UHkJbAQ=; b=foQ5PoKhUoI+Myk9R0Bg+UdS8lrBrIKQJoO3/Np3b65al//RavVQslfAQMFVW7enN+wRnqNUnc9ViXJrkY5r0+UEP8yVH1bUMUCNF2GWlJvsanILlHXuIBmw3P3LyfDln8NOAcxa+FSvMA62ft4bEQsYt1Oz7GklexWmBI2rojQ= 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 1618308146470331.3987353107185; Tue, 13 Apr 2021 03:02:26 -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-412-Afs_dG4KOcmXwALrBxH0kg-1; Tue, 13 Apr 2021 06:02:22 -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 8F31681746A; Tue, 13 Apr 2021 10:02:17 +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 6880A6F13B; Tue, 13 Apr 2021 10:02:17 +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 2A07F1806D1B; Tue, 13 Apr 2021 10:02:17 +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 13DA28Kj011388 for ; Tue, 13 Apr 2021 06:02:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id C236410023B5; Tue, 13 Apr 2021 10:02:08 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44CC810023B0 for ; Tue, 13 Apr 2021 10:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618308144; 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=8HqW8uEz4nqNsPqCWFRn8+7lnR0liiG4VBT7UHkJbAQ=; b=Ks9bPHEkGafSRT6xK1xZs0TexcfKYl05FK84mtYrPms4/vRap6YfNZfY1KbLogdQNhBLWf WZe2ox3WTEKJb5FKb9zpcIFl+mkx3mG8UFcYhn7GopouvdD8PgHKiaHBY50k2VtgLPCQTz SDUn3+6+M8nkrW01uw7UKeqpHT8Aybs= X-MC-Unique: Afs_dG4KOcmXwALrBxH0kg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/6] nodedev: Mark device initialization complete even in case of an error Date: Tue, 13 Apr 2021 12:01:56 +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.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" To speed up nodedev driver initialization, the device enumeration is done in a separate thread. Once finished, the thread sets a boolean variable that allows public APIs to be called (instead of waiting for the thread to finish). However, if there's an error in the device enumeration thread then the control jumps over at the 'error' label and the boolean is never set. This means, that any virNodeDev*() API is stuck forever. Mark the initialization as complete (the thread is quitting anyway) and let the APIs proceed. Signed-off-by: Michal Privoznik --- src/node_device/node_device_udev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 68547c6986..1c5b80ea58 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1995,6 +1995,8 @@ nodeStateInitializeEnumerate(void *opaque) priv->threadQuit =3D true; virCondSignal(&priv->threadCond); virObjectUnlock(priv); + + nodeDeviceInitComplete(); } =20 =20 --=20 2.26.3 From nobody Tue May 21 21:00:58 2024 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=1618308152; cv=none; d=zohomail.com; s=zohoarc; b=fmy/XvRBKGuY7YjWA6kXtpb/kyvYqE6SRTXdab/W3TC6Ig09YqD18KShTfOMHj70JmAQqhikwBLC5VvuP7cklabh3Lw3KarJO4T6PEsFBFcsdp01tIsd7kkNEu6Vj3ArIAvDx3kCg04M2uLh6D50SzfiGGRaAON8OlaskUivXk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618308152; 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=IDO9wPbI35k0wBurzKXnSXpJBGI2rTZr7VXvLtY0J1o=; b=n3/ATc7FmhvyOZbdz4yJrw70y8eHiR0jdw75oYZJ8B8IhekBcV0debGhORNVh+C7wZ0Ye9kRZzPTmMl8EMt1OXQ6ZTZS4WlKTvsamukhhPC7GV82Y6wXF2MjpHPv1aSMOR96lvZcfYrIwxvTJT7+Rl0JXkorLTz4gBYdD1fwzOg= 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 1618308152197451.0244872355238; Tue, 13 Apr 2021 03:02:32 -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-431-PJ4L7erTPVW_gtTZTAla-A-1; Tue, 13 Apr 2021 06:02:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 05572107ACE8; Tue, 13 Apr 2021 10:02:21 +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 D410C6C333; Tue, 13 Apr 2021 10:02: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 9878444A62; Tue, 13 Apr 2021 10:02:20 +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 13DA29xq011404 for ; Tue, 13 Apr 2021 06:02:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9C6D910023B5; Tue, 13 Apr 2021 10:02:09 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F72810023B0 for ; Tue, 13 Apr 2021 10:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618308149; 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=IDO9wPbI35k0wBurzKXnSXpJBGI2rTZr7VXvLtY0J1o=; b=ae7iy08BIXPVOGXcqikd8Kbrtz95FSw2mQ3850fMYOlDL0XXL/59RfeONyqNEQmW2viD1G VcaW0tSmfadRxA0MWNs2GEiJgj+BY/1cg5/pCFXu0zVnkTmwQ/CNddPPxViOtyfHyPvOAs gmUXOBHS4F2v3AQYvD3ujJRqI3YFjsU= X-MC-Unique: PJ4L7erTPVW_gtTZTAla-A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/6] nodedev: Don't fail device enumeration if MDEVCTL is missing Date: Tue, 13 Apr 2021 12:01:57 +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.11 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" After all devices were enumerated, the enumeration thread call nodeDeviceUpdateMediatedDevices() to refresh the state of mediated devices. This means that 'mdevctl' will be executed. But it may be missing on some systems (e.g. mine) in which case we should just skip the update of mdevs instead of failing whole device enumeration. Signed-off-by: Michal Privoznik --- src/node_device/node_device_driver.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 2bb83c19f2..fab830c596 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -42,9 +42,12 @@ #include "virnetdev.h" #include "virutil.h" #include "vircommand.h" +#include "virlog.h" =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 +VIR_LOG_INIT("node_device.node_device_driver"); + virNodeDeviceDriverStatePtr driver; =20 virDrvOpenStatus @@ -1605,6 +1608,13 @@ nodeDeviceUpdateMediatedDevices(void) virMdevctlForEachData data =3D { 0, }; size_t i; =20 + /* The code below assumes MDEVCTL to exist. Well, if it doesn't then e= xit + * early. */ + if (!virFileExists(MDEVCTL)) { + VIR_DEBUG(MDEVCTL " does not exist. Skipping update of mediated de= vices."); + return 0; + } + if ((data.ndefs =3D virMdevctlListDefined(&defs, &errmsg)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to query mdevs from mdevctl: %s"), errmsg= ); --=20 2.26.3