From nobody Thu May 15 03:52:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516872289643384.5765461064193; Thu, 25 Jan 2018 01:24:49 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF5B7DB958; Thu, 25 Jan 2018 09:24:48 +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 9E68A65608; Thu, 25 Jan 2018 09:24:48 +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 5A28918033DB; Thu, 25 Jan 2018 09:24:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9OlMV032748 for ; Thu, 25 Jan 2018 04:24:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id CB7985D6A8; Thu, 25 Jan 2018 09:24:47 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAC2D46E63; Thu, 25 Jan 2018 09:24:33 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 10:23:53 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 06/15] nodedev: Export nodeDeviceUpdateCaps from node_device_conf.c 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jan 2018 09:24:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we moved the helpers from nodedev driver to src/conf, the actual 'update' function using those helpers should be moved as well so that we don't need to call back into the driver. Signed-off-by: Erik Skultety --- src/conf/node_device_conf.c | 54 ++++++++++++++++++++++++++++++++= ++++ src/conf/node_device_conf.h | 3 ++ src/libvirt_private.syms | 1 + src/node_device/node_device_driver.c | 54 +-------------------------------= ---- 4 files changed, 59 insertions(+), 53 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 5b0af559a..217673a56 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2433,6 +2433,60 @@ virNodeDeviceDeleteVport(virConnectPtr conn, } =20 =20 +int +virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def) +{ + virNodeDevCapsDefPtr cap =3D def->caps; + + while (cap) { + switch (cap->data.type) { + case VIR_NODE_DEV_CAP_SCSI_HOST: + virNodeDeviceGetSCSIHostCaps(&cap->data.scsi_host); + break; + case VIR_NODE_DEV_CAP_SCSI_TARGET: + virNodeDeviceGetSCSITargetCaps(def->sysfs_path, + &cap->data.scsi_target); + break; + case VIR_NODE_DEV_CAP_NET: + if (virNetDevGetLinkInfo(cap->data.net.ifname, + &cap->data.net.lnk) < 0) + return -1; + virBitmapFree(cap->data.net.features); + if (virNetDevGetFeatures(cap->data.net.ifname, + &cap->data.net.features) < 0) + return -1; + break; + case VIR_NODE_DEV_CAP_PCI_DEV: + if (virNodeDeviceGetPCIDynamicCaps(def->sysfs_path, + &cap->data.pci_dev) < 0) + return -1; + break; + + /* all types that (supposedly) don't require any updates + * relative to what's in the cache. + */ + case VIR_NODE_DEV_CAP_DRM: + case VIR_NODE_DEV_CAP_SYSTEM: + case VIR_NODE_DEV_CAP_USB_DEV: + case VIR_NODE_DEV_CAP_USB_INTERFACE: + case VIR_NODE_DEV_CAP_SCSI: + case VIR_NODE_DEV_CAP_STORAGE: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_SCSI_GENERIC: + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_MDEV: + case VIR_NODE_DEV_CAP_CCW_DEV: + case VIR_NODE_DEV_CAP_LAST: + break; + } + cap =3D cap->next; + } + + return 0; +} + + #ifdef __linux__ =20 int diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 4e3154875..7e32f5c05 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -400,4 +400,7 @@ virNodeDeviceGetSCSITargetCaps(const char *sysfsPath, int virNodeDeviceGetPCIDynamicCaps(const char *sysfsPath, virNodeDevCapPCIDevPtr pci_dev); + +int +virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def); #endif /* __VIR_NODE_DEVICE_CONF_H__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0cd8086a6..6098cf121 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -711,6 +711,7 @@ virNodeDeviceGetPCIDynamicCaps; virNodeDeviceGetSCSIHostCaps; virNodeDeviceGetSCSITargetCaps; virNodeDeviceGetWWNs; +virNodeDeviceUpdateCaps; =20 =20 # conf/node_device_event.h diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 2e42d3527..48f45474c 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -47,58 +47,6 @@ virNodeDeviceDriverStatePtr driver; =20 =20 -static int -nodeDeviceUpdateCaps(virNodeDeviceDefPtr def) -{ - virNodeDevCapsDefPtr cap =3D def->caps; - - while (cap) { - switch (cap->data.type) { - case VIR_NODE_DEV_CAP_SCSI_HOST: - virNodeDeviceGetSCSIHostCaps(&cap->data.scsi_host); - break; - case VIR_NODE_DEV_CAP_SCSI_TARGET: - virNodeDeviceGetSCSITargetCaps(def->sysfs_path, - &cap->data.scsi_target); - break; - case VIR_NODE_DEV_CAP_NET: - if (virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.= lnk) < 0) - return -1; - virBitmapFree(cap->data.net.features); - if (virNetDevGetFeatures(cap->data.net.ifname, &cap->data.net.= features) < 0) - return -1; - break; - case VIR_NODE_DEV_CAP_PCI_DEV: - if (virNodeDeviceGetPCIDynamicCaps(def->sysfs_path, - &cap->data.pci_dev) < 0) - return -1; - break; - - /* all types that (supposedly) don't require any updates - * relative to what's in the cache. - */ - case VIR_NODE_DEV_CAP_DRM: - case VIR_NODE_DEV_CAP_SYSTEM: - case VIR_NODE_DEV_CAP_USB_DEV: - case VIR_NODE_DEV_CAP_USB_INTERFACE: - case VIR_NODE_DEV_CAP_SCSI: - case VIR_NODE_DEV_CAP_STORAGE: - case VIR_NODE_DEV_CAP_FC_HOST: - case VIR_NODE_DEV_CAP_VPORTS: - case VIR_NODE_DEV_CAP_SCSI_GENERIC: - case VIR_NODE_DEV_CAP_MDEV_TYPES: - case VIR_NODE_DEV_CAP_MDEV: - case VIR_NODE_DEV_CAP_CCW_DEV: - case VIR_NODE_DEV_CAP_LAST: - break; - } - cap =3D cap->next; - } - - return 0; -} - - #if defined (__linux__) && ( defined (WITH_HAL) || defined(WITH_UDEV)) /* NB: It was previously believed that changes in driver name were * relayed to libvirt as "change" events by udev, and the udev event @@ -314,7 +262,7 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr device, if (nodeDeviceUpdateDriverName(def) < 0) goto cleanup; =20 - if (nodeDeviceUpdateCaps(def) < 0) + if (virNodeDeviceUpdateCaps(def) < 0) goto cleanup; =20 ret =3D virNodeDeviceDefFormat(def); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list