From nobody Mon Feb 9 17:34:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1588283046; cv=none; d=zohomail.com; s=zohoarc; b=n9A3FpGzM3vaYCzS545AfnTi/mrXe18QQG3GI8VKKYL1Ifr1ssoGflITKERE07xG5ugpTxvVFUwjQjnJF5mc9bgkdnJOKxLvwAVIDLx4vHD4lYVIgkUJ0/w+io6HfQm9lB/n8e9SCuMHOzeQ9WdvQjB/N68TGLDr6StIbJSKNqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588283046; 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=lvXJ0vfBRAP5gp78GjopOeb4DTiehGR/jy5SAktIa5c=; b=KROQBs77Dm8XVVAdl4siT08v0c4T8ErPt0PSSMVygI6esHZpzjCncvUWRyR1k6GJlC87pPrb2MdF4ByO47w/bYl/QQbrUB1R/2ZN7YwDgNIXTF+6l3sAKJGE8MwWZwWPLien3vvIFLxKiE3xm+OS53jcTC23BKE8t/ap2pnWzHQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588283046306439.61169223960985; Thu, 30 Apr 2020 14:44:06 -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-309-qyPu7xMVNHOJzo5rHAFGIA-1; Thu, 30 Apr 2020 17:43:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C48E19200C1; Thu, 30 Apr 2020 21:43:24 +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 463D65C1D0; Thu, 30 Apr 2020 21:43:24 +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 004B44CAB0; Thu, 30 Apr 2020 21:43:23 +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 03ULh2dZ003322 for ; Thu, 30 Apr 2020 17:43:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 645251001281; Thu, 30 Apr 2020 21:43:02 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-112-99.phx2.redhat.com [10.3.112.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36C8B10013BD for ; Thu, 30 Apr 2020 21:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588283044; 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=lvXJ0vfBRAP5gp78GjopOeb4DTiehGR/jy5SAktIa5c=; b=PybDYUDcaH9NjNfkdTBG9ELjeza6bnXtpDWsAVJpMgScmUpIxNwEd9AZNRq2P6t2zOhTka f0EwJ76mgyZxX5MaVkUs3bICLN25eG3rk40ORNO5DfqLjtBS/hCqQHz8NQVso9PLAhF2eA 7vzSq0ApO+bClodJ1yC5DS8e13cxyHg= X-MC-Unique: qyPu7xMVNHOJzo5rHAFGIA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 3/6] nodedev: refactor nodeDeviceFindNewDevice() Date: Thu, 30 Apr 2020 16:42:55 -0500 Message-Id: <20200430214258.18498-4-jjongsma@redhat.com> In-Reply-To: <20200430214258.18498-1-jjongsma@redhat.com> References: <20200430214258.18498-1-jjongsma@redhat.com> 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.16 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" In preparation for creating mediated devices in libvirt, we will need to wait for new mediated devices to be created as well. Refactor nodeDeviceFindNewDevice() so that we can re-use the main logic from this function to wait for different device types by passing a different 'find' function. Signed-off-by: Jonathon Jongsma --- src/node_device/node_device_driver.c | 33 +++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 6a96a77d92..f948dfbf69 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -446,7 +446,8 @@ nodeDeviceGetTime(time_t *t) return ret; } =20 - +typedef virNodeDevicePtr (*nodeDeviceFindNewDeviceFunc)(virConnectPtr conn, + const void* opaque= ); /* When large numbers of devices are present on the host, it's * possible for udev not to realize that it has work to do before we * get here. We thus keep trying to find the new device we just @@ -462,8 +463,8 @@ nodeDeviceGetTime(time_t *t) */ static virNodeDevicePtr nodeDeviceFindNewDevice(virConnectPtr conn, - const char *wwnn, - const char *wwpn) + nodeDeviceFindNewDeviceFunc func, + const void *opaque) { virNodeDevicePtr device =3D NULL; time_t start =3D 0, now =3D 0; @@ -474,7 +475,7 @@ nodeDeviceFindNewDevice(virConnectPtr conn, =20 virWaitForDevices(); =20 - device =3D nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0); + device =3D func(conn, opaque); =20 if (device !=3D NULL) break; @@ -487,6 +488,28 @@ nodeDeviceFindNewDevice(virConnectPtr conn, return device; } =20 +typedef struct _NewSCISHostFuncData +{ + const char *wwnn; + const char *wwpn; +} NewSCSIHostFuncData; +static virNodeDevicePtr +nodeDeviceFindNewSCSIHostFunc(virConnectPtr conn, + const void *opaque) +{ + const NewSCSIHostFuncData *data =3D opaque; + return nodeDeviceLookupSCSIHostByWWN(conn, data->wwnn, data->wwpn, 0); +} + +static virNodeDevicePtr +nodeDeviceFindNewSCSIHost(virConnectPtr conn, + const char *wwnn, + const char *wwpn) +{ + NewSCSIHostFuncData data =3D { .wwnn =3D wwnn, .wwpn =3D wwpn}; + return nodeDeviceFindNewDevice(conn, nodeDeviceFindNewSCSIHostFunc, &d= ata); +} + static bool nodeDeviceHasCapability(virNodeDeviceDefPtr def, virNodeDevCapType type) { @@ -537,7 +560,7 @@ nodeDeviceCreateXML(virConnectPtr conn, if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_CREATE) < 0) return NULL; =20 - device =3D nodeDeviceFindNewDevice(conn, wwnn, wwpn); + device =3D nodeDeviceFindNewSCSIHost(conn, wwnn, wwpn); /* We don't check the return value, because one way or another, * we're returning what we get... */ =20 --=20 2.21.1