From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792212022243.28339002116672; Wed, 29 Mar 2017 05:56:52 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 58C5E8C55A; Wed, 29 Mar 2017 12:56:50 +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 29E90B23F4; Wed, 29 Mar 2017 12:56:50 +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 CCDB518523CB; Wed, 29 Mar 2017 12:56:49 +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 v2TCpUUh010059 for ; Wed, 29 Mar 2017 08:51:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F3AB9629F; Wed, 29 Mar 2017 12:51:30 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C6779664F; Wed, 29 Mar 2017 12:51:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 58C5E8C55A Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 58C5E8C55A From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:11 +0200 Message-Id: <3b091d5f94c631f30dfb42abd2ca1d31d5a6b458.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 01/11] nodedev: Fix guideline violations in nodedev modules 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 29 Mar 2017 12:56:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We recently started to enforce certain guideline rule a bit more, e.g. functions delimited by 2 newlines in *.c, by 1 newline in *.h, return types on a separate line, etc. This patch adjusts these issues in all nodedev modules. Signed-off-by: Erik Skultety --- src/node_device/node_device_driver.c | 29 +++- src/node_device/node_device_driver.h | 82 +++++++---- src/node_device/node_device_hal.c | 9 ++ src/node_device/node_device_linux_sysfs.c | 1 + src/node_device/node_device_linux_sysfs.h | 9 +- src/node_device/node_device_udev.c | 233 ++++++++++++++++++--------= ---- 6 files changed, 238 insertions(+), 125 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 99f7bc5476..9b1c5bb5e9 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -47,7 +47,8 @@ =20 virNodeDeviceDriverStatePtr driver; =20 -static int update_caps(virNodeDeviceObjPtr dev) +static int +update_caps(virNodeDeviceObjPtr dev) { virNodeDevCapsDefPtr cap =3D dev->def->caps; =20 @@ -101,7 +102,8 @@ static int update_caps(virNodeDeviceObjPtr dev) * the driver name for a device each time its entry is used, both for * udev *and* HAL backends. */ -static int update_driver_name(virNodeDeviceObjPtr dev) +static int +update_driver_name(virNodeDeviceObjPtr dev) { char *driver_link =3D NULL; char *devpath =3D NULL; @@ -138,22 +140,28 @@ static int update_driver_name(virNodeDeviceObjPtr dev) } #else /* XXX: Implement me for non-linux */ -static int update_driver_name(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED) +static int +update_driver_name(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED) { return 0; } #endif =20 =20 -void nodeDeviceLock(void) +void +nodeDeviceLock(void) { virMutexLock(&driver->lock); } -void nodeDeviceUnlock(void) + + +void +nodeDeviceUnlock(void) { virMutexUnlock(&driver->lock); } =20 + int nodeNumOfDevices(virConnectPtr conn, const char *cap, @@ -182,6 +190,7 @@ nodeNumOfDevices(virConnectPtr conn, return ndevs; } =20 + int nodeListDevices(virConnectPtr conn, const char *cap, @@ -222,6 +231,7 @@ nodeListDevices(virConnectPtr conn, return -1; } =20 + int nodeConnectListAllNodeDevices(virConnectPtr conn, virNodeDevicePtr **devices, @@ -242,6 +252,7 @@ nodeConnectListAllNodeDevices(virConnectPtr conn, return ret; } =20 + virNodeDevicePtr nodeDeviceLookupByName(virConnectPtr conn, const char *name) { @@ -500,6 +511,7 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const n= ames, int maxnames) return ret; } =20 + static int get_time(time_t *t) { @@ -565,6 +577,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, c= onst char *wwpn) return dev; } =20 + virNodeDevicePtr nodeDeviceCreateXML(virConnectPtr conn, const char *xmlDesc, @@ -663,6 +676,7 @@ nodeDeviceDestroy(virNodeDevicePtr dev) return ret; } =20 + int nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn, virNodeDevicePtr dev, @@ -684,6 +698,7 @@ nodeConnectNodeDeviceEventRegisterAny(virConnectPtr con= n, return callbackID; } =20 + int nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn, int callbackID) @@ -704,7 +719,9 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr c= onn, return ret; } =20 -int nodedevRegister(void) + +int +nodedevRegister(void) { #ifdef WITH_UDEV return udevNodeRegister(); diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index bc8af8a9e7..0f55e7b71e 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -30,37 +30,67 @@ =20 # define LINUX_NEW_DEVICE_WAIT_TIME 60 =20 +extern virNodeDeviceDriverStatePtr driver; + # ifdef WITH_HAL -int halNodeRegister(void); +int +halNodeRegister(void); # endif # ifdef WITH_UDEV -int udevNodeRegister(void); +int +udevNodeRegister(void); # endif =20 -void nodeDeviceLock(void); -void nodeDeviceUnlock(void); - -extern virNodeDeviceDriverStatePtr driver; - -int nodedevRegister(void); - -int nodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int fla= gs); -int nodeListDevices(virConnectPtr conn, const char *cap, char **const name= s, - int maxnames, unsigned int flags); -int nodeConnectListAllNodeDevices(virConnectPtr conn, - virNodeDevicePtr **devices, - unsigned int flags); -virNodeDevicePtr nodeDeviceLookupByName(virConnectPtr conn, const char *na= me); -virNodeDevicePtr nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, - const char *wwnn, - const char *wwpn, - unsigned int flags); -char *nodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags); -char *nodeDeviceGetParent(virNodeDevicePtr dev); -int nodeDeviceNumOfCaps(virNodeDevicePtr dev); -int nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxna= mes); -virNodeDevicePtr nodeDeviceCreateXML(virConnectPtr conn, - const char *xmlDesc, unsigned int fla= gs); +void +nodeDeviceLock(void); + +void +nodeDeviceUnlock(void); + +int +nodedevRegister(void); + +int +nodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags); + +int +nodeListDevices(virConnectPtr conn, + const char *cap, + char **const names, + int maxnames, + unsigned int flags); + +int +nodeConnectListAllNodeDevices(virConnectPtr conn, + virNodeDevicePtr **devices, + unsigned int flags); + +virNodeDevicePtr +nodeDeviceLookupByName(virConnectPtr conn, const char *name); + +virNodeDevicePtr +nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, + const char *wwnn, + const char *wwpn, + unsigned int flags); + +char * +nodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags); + +char * +nodeDeviceGetParent(virNodeDevicePtr dev); + +int +nodeDeviceNumOfCaps(virNodeDevicePtr dev); + +int +nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames); + +virNodeDevicePtr +nodeDeviceCreateXML(virConnectPtr conn, + const char *xmlDesc, + unsigned int flags); + int nodeDeviceDestroy(virNodeDevicePtr dev); =20 int diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index 81e5ecc41d..5339218775 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -84,6 +84,7 @@ get_str_prop(LibHalContext *ctxt, const char *udi, return -1; } =20 + static int get_int_prop(LibHalContext *ctxt, const char *udi, const char *prop, int *val_p) @@ -102,6 +103,7 @@ get_int_prop(LibHalContext *ctxt, const char *udi, return rv; } =20 + static int get_bool_prop(LibHalContext *ctxt, const char *udi, const char *prop, int *val_p) @@ -120,6 +122,7 @@ get_bool_prop(LibHalContext *ctxt, const char *udi, return rv; } =20 + static int get_uint64_prop(LibHalContext *ctxt, const char *udi, const char *prop, unsigned long long *val_p) @@ -138,6 +141,7 @@ get_uint64_prop(LibHalContext *ctxt, const char *udi, return rv; } =20 + static int gather_pci_cap(LibHalContext *ctx, const char *udi, virNodeDevCapDataPtr d) @@ -290,6 +294,7 @@ gather_storage_cap(LibHalContext *ctx, const char *udi, return 0; } =20 + static int gather_scsi_generic_cap(LibHalContext *ctx, const char *udi, virNodeDevCapDataPtr d) @@ -446,12 +451,14 @@ gather_capabilities(LibHalContext *ctx, const char *u= di, return rv; } =20 + static void free_udi(void *udi) { VIR_FREE(udi); } =20 + static void dev_create(const char *udi) { @@ -516,6 +523,7 @@ dev_create(const char *udi) nodeDeviceUnlock(); } =20 + static void dev_refresh(const char *udi) { @@ -538,6 +546,7 @@ dev_refresh(const char *udi) dev_create(udi); } =20 + static void device_added(LibHalContext *ctx ATTRIBUTE_UNUSED, const char *udi) diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/no= de_device_linux_sysfs.c index 1b7aa9435c..ff22d6d55c 100644 --- a/src/node_device/node_device_linux_sysfs.c +++ b/src/node_device/node_device_linux_sysfs.c @@ -230,6 +230,7 @@ nodeDeviceSysfsGetSCSIHostCaps(virNodeDevCapSCSIHostPtr= scsi_host ATTRIBUTE_UNUS return -1; } =20 + int nodeDeviceSysfsGetPCIRelatedDevCaps(const char *sysfsPath ATTRIBUTE_UNUSED, virNodeDevCapPCIDevPtr pci_dev ATTRIBU= TE_UNUSED) diff --git a/src/node_device/node_device_linux_sysfs.h b/src/node_device/no= de_device_linux_sysfs.h index 8deea66998..11b96e86b8 100644 --- a/src/node_device/node_device_linux_sysfs.h +++ b/src/node_device/node_device_linux_sysfs.h @@ -25,8 +25,11 @@ =20 # include "node_device_conf.h" =20 -int nodeDeviceSysfsGetSCSIHostCaps(virNodeDevCapSCSIHostPtr scsi_host); -int nodeDeviceSysfsGetPCIRelatedDevCaps(const char *sysfsPath, - virNodeDevCapPCIDevPtr pci_dev); +int +nodeDeviceSysfsGetSCSIHostCaps(virNodeDevCapSCSIHostPtr scsi_host); + +int +nodeDeviceSysfsGetPCIRelatedDevCaps(const char *sysfsPath, + virNodeDevCapPCIDevPtr pci_dev); =20 #endif /* __VIR_NODE_DEVICE_LINUX_SYSFS_H__ */ diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index bcae444d85..4a837e04dc 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -70,8 +70,9 @@ udevHasDeviceProperty(struct udev_device *dev, } =20 =20 -static const char *udevGetDeviceProperty(struct udev_device *udev_device, - const char *property_key) +static const char * +udevGetDeviceProperty(struct udev_device *udev_device, + const char *property_key) { const char *ret =3D NULL; =20 @@ -84,9 +85,10 @@ static const char *udevGetDeviceProperty(struct udev_dev= ice *udev_device, } =20 =20 -static int udevGetStringProperty(struct udev_device *udev_device, - const char *property_key, - char **value) +static int +udevGetStringProperty(struct udev_device *udev_device, + const char *property_key, + char **value) { if (VIR_STRDUP(*value, udevGetDeviceProperty(udev_device, property_key)) < 0) @@ -96,10 +98,11 @@ static int udevGetStringProperty(struct udev_device *ud= ev_device, } =20 =20 -static int udevGetIntProperty(struct udev_device *udev_device, - const char *property_key, - int *value, - int base) +static int +udevGetIntProperty(struct udev_device *udev_device, + const char *property_key, + int *value, + int base) { const char *str =3D NULL; =20 @@ -114,10 +117,11 @@ static int udevGetIntProperty(struct udev_device *ude= v_device, } =20 =20 -static int udevGetUintProperty(struct udev_device *udev_device, - const char *property_key, - unsigned int *value, - int base) +static int +udevGetUintProperty(struct udev_device *udev_device, + const char *property_key, + unsigned int *value, + int base) { const char *str =3D NULL; =20 @@ -132,8 +136,9 @@ static int udevGetUintProperty(struct udev_device *udev= _device, } =20 =20 -static const char *udevGetDeviceSysfsAttr(struct udev_device *udev_device, - const char *attr_name) +static const char * +udevGetDeviceSysfsAttr(struct udev_device *udev_device, + const char *attr_name) { const char *ret =3D NULL; =20 @@ -147,9 +152,10 @@ static const char *udevGetDeviceSysfsAttr(struct udev_= device *udev_device, } =20 =20 -static int udevGetStringSysfsAttr(struct udev_device *udev_device, - const char *attr_name, - char **value) +static int +udevGetStringSysfsAttr(struct udev_device *udev_device, + const char *attr_name, + char **value) { if (VIR_STRDUP(*value, udevGetDeviceSysfsAttr(udev_device, attr_name))= < 0) return -1; @@ -163,10 +169,11 @@ static int udevGetStringSysfsAttr(struct udev_device = *udev_device, } =20 =20 -static int udevGetIntSysfsAttr(struct udev_device *udev_device, - const char *attr_name, - int *value, - int base) +static int +udevGetIntSysfsAttr(struct udev_device *udev_device, + const char *attr_name, + int *value, + int base) { const char *str =3D NULL; =20 @@ -182,10 +189,11 @@ static int udevGetIntSysfsAttr(struct udev_device *ud= ev_device, } =20 =20 -static int udevGetUintSysfsAttr(struct udev_device *udev_device, - const char *attr_name, - unsigned int *value, - int base) +static int +udevGetUintSysfsAttr(struct udev_device *udev_device, + const char *attr_name, + unsigned int *value, + int base) { const char *str =3D NULL; =20 @@ -201,9 +209,10 @@ static int udevGetUintSysfsAttr(struct udev_device *ud= ev_device, } =20 =20 -static int udevGetUint64SysfsAttr(struct udev_device *udev_device, - const char *attr_name, - unsigned long long *value) +static int +udevGetUint64SysfsAttr(struct udev_device *udev_device, + const char *attr_name, + unsigned long long *value) { const char *str =3D NULL; =20 @@ -219,9 +228,10 @@ static int udevGetUint64SysfsAttr(struct udev_device *= udev_device, } =20 =20 -static int udevGenerateDeviceName(struct udev_device *device, - virNodeDeviceDefPtr def, - const char *s) +static int +udevGenerateDeviceName(struct udev_device *device, + virNodeDeviceDefPtr def, + const char *s) { size_t i; virBuffer buf =3D VIR_BUFFER_INITIALIZER; @@ -282,10 +292,11 @@ udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED, #endif =20 =20 -static int udevTranslatePCIIds(unsigned int vendor, - unsigned int product, - char **vendor_string, - char **product_string) +static int +udevTranslatePCIIds(unsigned int vendor, + unsigned int product, + char **vendor_string, + char **product_string) { struct pci_id_match m; const char *vendor_name =3D NULL, *device_name =3D NULL; @@ -313,8 +324,9 @@ static int udevTranslatePCIIds(unsigned int vendor, } =20 =20 -static int udevProcessPCI(struct udev_device *device, - virNodeDeviceDefPtr def) +static int +udevProcessPCI(struct udev_device *device, + virNodeDeviceDefPtr def) { const char *syspath =3D NULL; virNodeDevCapPCIDevPtr pci_dev =3D &def->caps->data.pci_dev; @@ -411,7 +423,9 @@ static int udevProcessPCI(struct udev_device *device, return ret; } =20 -static int drmGetMinorType(int minor) + +static int +drmGetMinorType(int minor) { int type =3D minor >> 6; =20 @@ -428,8 +442,10 @@ static int drmGetMinorType(int minor) } } =20 -static int udevProcessDRMDevice(struct udev_device *device, - virNodeDeviceDefPtr def) + +static int +udevProcessDRMDevice(struct udev_device *device, + virNodeDeviceDefPtr def) { virNodeDevCapDRMPtr drm =3D &def->caps->data.drm; int minor; @@ -448,8 +464,10 @@ static int udevProcessDRMDevice(struct udev_device *de= vice, return 0; } =20 -static int udevProcessUSBDevice(struct udev_device *device, - virNodeDeviceDefPtr def) + +static int +udevProcessUSBDevice(struct udev_device *device, + virNodeDeviceDefPtr def) { virNodeDevCapUSBDevPtr usb_dev =3D &def->caps->data.usb_dev; =20 @@ -490,8 +508,9 @@ static int udevProcessUSBDevice(struct udev_device *dev= ice, } =20 =20 -static int udevProcessUSBInterface(struct udev_device *device, - virNodeDeviceDefPtr def) +static int +udevProcessUSBInterface(struct udev_device *device, + virNodeDeviceDefPtr def) { virNodeDevCapUSBIfPtr usb_if =3D &def->caps->data.usb_if; =20 @@ -518,8 +537,9 @@ static int udevProcessUSBInterface(struct udev_device *= device, } =20 =20 -static int udevProcessNetworkInterface(struct udev_device *device, - virNodeDeviceDefPtr def) +static int +udevProcessNetworkInterface(struct udev_device *device, + virNodeDeviceDefPtr def) { const char *devtype =3D udev_device_get_devtype(device); virNodeDevCapNetPtr net =3D &def->caps->data.net; @@ -581,8 +601,9 @@ static int udevProcessSCSIHost(struct udev_device *devi= ce ATTRIBUTE_UNUSED, } =20 =20 -static int udevProcessSCSITarget(struct udev_device *device ATTRIBUTE_UNUS= ED, - virNodeDeviceDefPtr def) +static int +udevProcessSCSITarget(struct udev_device *device ATTRIBUTE_UNUSED, + virNodeDeviceDefPtr def) { const char *sysname =3D NULL; virNodeDevCapSCSITargetPtr scsi_target =3D &def->caps->data.scsi_targe= t; @@ -599,8 +620,9 @@ static int udevProcessSCSITarget(struct udev_device *de= vice ATTRIBUTE_UNUSED, } =20 =20 -static int udevGetSCSIType(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED, - unsigned int type, char **typestring) +static int +udevGetSCSIType(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED, + unsigned int type, char **typestring) { int ret =3D 0; int foundtype =3D 1; @@ -657,8 +679,9 @@ static int udevGetSCSIType(virNodeDeviceDefPtr def ATTR= IBUTE_UNUSED, } =20 =20 -static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUS= ED, - virNodeDeviceDefPtr def) +static int +udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED, + virNodeDeviceDefPtr def) { int ret =3D -1; unsigned int tmp =3D 0; @@ -700,8 +723,9 @@ static int udevProcessSCSIDevice(struct udev_device *de= vice ATTRIBUTE_UNUSED, } =20 =20 -static int udevProcessDisk(struct udev_device *device, - virNodeDeviceDefPtr def) +static int +udevProcessDisk(struct udev_device *device, + virNodeDeviceDefPtr def) { virNodeDevCapStoragePtr storage =3D &def->caps->data.storage; =20 @@ -718,9 +742,10 @@ static int udevProcessDisk(struct udev_device *device, } =20 =20 -static int udevProcessRemoveableMedia(struct udev_device *device, - virNodeDeviceDefPtr def, - int has_media) +static int +udevProcessRemoveableMedia(struct udev_device *device, + virNodeDeviceDefPtr def, + int has_media) { virNodeDevCapStoragePtr storage =3D &def->caps->data.storage; int is_removable =3D 0; @@ -759,8 +784,10 @@ static int udevProcessRemoveableMedia(struct udev_devi= ce *device, return 0; } =20 -static int udevProcessCDROM(struct udev_device *device, - virNodeDeviceDefPtr def) + +static int +udevProcessCDROM(struct udev_device *device, + virNodeDeviceDefPtr def) { int has_media =3D 0; =20 @@ -779,8 +806,10 @@ static int udevProcessCDROM(struct udev_device *device, return udevProcessRemoveableMedia(device, def, has_media); } =20 -static int udevProcessFloppy(struct udev_device *device, - virNodeDeviceDefPtr def) + +static int +udevProcessFloppy(struct udev_device *device, + virNodeDeviceDefPtr def) { int has_media =3D 0; =20 @@ -797,8 +826,9 @@ static int udevProcessFloppy(struct udev_device *device, } =20 =20 -static int udevProcessSD(struct udev_device *device, - virNodeDeviceDefPtr def) +static int +udevProcessSD(struct udev_device *device, + virNodeDeviceDefPtr def) { virNodeDevCapStoragePtr storage =3D &def->caps->data.storage; =20 @@ -821,7 +851,8 @@ static int udevProcessSD(struct udev_device *device, * not provide a device type in the usual place, but udev told us it's * a storage device, and we can make a good guess at what kind of * storage device it is from other information that is provided. */ -static int udevKludgeStorageType(virNodeDeviceDefPtr def) +static int +udevKludgeStorageType(virNodeDeviceDefPtr def) { VIR_DEBUG("Could not find definitive storage type for device " "with sysfs path '%s', trying to guess it", @@ -842,8 +873,9 @@ static int udevKludgeStorageType(virNodeDeviceDefPtr de= f) } =20 =20 -static int udevProcessStorage(struct udev_device *device, - virNodeDeviceDefPtr def) +static int +udevProcessStorage(struct udev_device *device, + virNodeDeviceDefPtr def) { virNodeDevCapStoragePtr storage =3D &def->caps->data.storage; int ret =3D -1; @@ -938,6 +970,7 @@ static int udevProcessStorage(struct udev_device *devic= e, return ret; } =20 + static int udevProcessSCSIGeneric(struct udev_device *dev, virNodeDeviceDefPtr def) @@ -952,6 +985,7 @@ udevProcessSCSIGeneric(struct udev_device *dev, return 0; } =20 + static int udevGetDeviceNodes(struct udev_device *device, virNodeDeviceDefPtr def) @@ -980,6 +1014,7 @@ udevGetDeviceNodes(struct udev_device *device, return 0; } =20 + static int udevGetDeviceType(struct udev_device *device, virNodeDevCapType *type) @@ -1040,8 +1075,9 @@ udevGetDeviceType(struct udev_device *device, } =20 =20 -static int udevGetDeviceDetails(struct udev_device *device, - virNodeDeviceDefPtr def) +static int +udevGetDeviceDetails(struct udev_device *device, + virNodeDeviceDefPtr def) { int ret =3D 0; =20 @@ -1090,7 +1126,8 @@ static int udevGetDeviceDetails(struct udev_device *d= evice, } =20 =20 -static int udevRemoveOneDevice(struct udev_device *device) +static int +udevRemoveOneDevice(struct udev_device *device) { virNodeDeviceObjPtr dev =3D NULL; virObjectEventPtr event =3D NULL; @@ -1122,8 +1159,9 @@ static int udevRemoveOneDevice(struct udev_device *de= vice) } =20 =20 -static int udevSetParent(struct udev_device *device, - virNodeDeviceDefPtr def) +static int +udevSetParent(struct udev_device *device, + virNodeDeviceDefPtr def) { struct udev_device *parent_device =3D NULL; const char *parent_sysfs_path =3D NULL; @@ -1170,7 +1208,8 @@ static int udevSetParent(struct udev_device *device, } =20 =20 -static int udevAddOneDevice(struct udev_device *device) +static int +udevAddOneDevice(struct udev_device *device) { virNodeDeviceDefPtr def =3D NULL; virNodeDeviceObjPtr dev =3D NULL; @@ -1239,8 +1278,9 @@ static int udevAddOneDevice(struct udev_device *devic= e) } =20 =20 -static int udevProcessDeviceListEntry(struct udev *udev, - struct udev_list_entry *list_entry) +static int +udevProcessDeviceListEntry(struct udev *udev, + struct udev_list_entry *list_entry) { struct udev_device *device; const char *name =3D NULL; @@ -1272,7 +1312,8 @@ const char *subsystem_blacklist[] =3D { "acpi", "tty", "vc", "i2c", }; =20 -static int udevEnumerateAddMatches(struct udev_enumerate *udev_enumerate) +static int +udevEnumerateAddMatches(struct udev_enumerate *udev_enumerate) { size_t i; =20 @@ -1287,7 +1328,8 @@ static int udevEnumerateAddMatches(struct udev_enumer= ate *udev_enumerate) } =20 =20 -static int udevEnumerateDevices(struct udev *udev) +static int +udevEnumerateDevices(struct udev *udev) { struct udev_enumerate *udev_enumerate =3D NULL; struct udev_list_entry *list_entry =3D NULL; @@ -1317,7 +1359,8 @@ static int udevEnumerateDevices(struct udev *udev) } =20 =20 -static void udevPCITranslateDeinit(void) +static void +udevPCITranslateDeinit(void) { #if defined __s390__ || defined __s390x_ /* Nothing was initialized, nothing needs to be cleaned up */ @@ -1329,7 +1372,8 @@ static void udevPCITranslateDeinit(void) } =20 =20 -static int nodeStateCleanup(void) +static int +nodeStateCleanup(void) { udevPrivate *priv =3D NULL; struct udev_monitor *udev_monitor =3D NULL; @@ -1370,10 +1414,11 @@ static int nodeStateCleanup(void) } =20 =20 -static void udevEventHandleCallback(int watch ATTRIBUTE_UNUSED, - int fd, - int events ATTRIBUTE_UNUSED, - void *data ATTRIBUTE_UNUSED) +static void +udevEventHandleCallback(int watch ATTRIBUTE_UNUSED, + int fd, + int events ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED) { struct udev_device *device =3D NULL; struct udev_monitor *udev_monitor =3D DRV_STATE_UDEV_MONITOR(driver); @@ -1474,7 +1519,8 @@ udevGetDMIData(virNodeDevCapSystemPtr syscap) #endif =20 =20 -static int udevSetupSystemDev(void) +static int +udevSetupSystemDev(void) { virNodeDeviceDefPtr def =3D NULL; virNodeDeviceObjPtr dev =3D NULL; @@ -1508,7 +1554,9 @@ static int udevSetupSystemDev(void) return ret; } =20 -static int udevPCITranslateInit(bool privileged ATTRIBUTE_UNUSED) + +static int +udevPCITranslateInit(bool privileged ATTRIBUTE_UNUSED) { #if defined __s390__ || defined __s390x_ /* On s390(x) system there is no PCI bus. @@ -1530,9 +1578,11 @@ static int udevPCITranslateInit(bool privileged ATTR= IBUTE_UNUSED) return 0; } =20 -static int nodeStateInitialize(bool privileged, - virStateInhibitCallback callback ATTRIBUTE_= UNUSED, - void *opaque ATTRIBUTE_UNUSED) + +static int +nodeStateInitialize(bool privileged, + virStateInhibitCallback callback ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) { udevPrivate *priv =3D NULL; struct udev *udev =3D NULL; @@ -1618,7 +1668,8 @@ static int nodeStateInitialize(bool privileged, } =20 =20 -static int nodeStateReload(void) +static int +nodeStateReload(void) { return 0; } @@ -1648,7 +1699,9 @@ static virStateDriver udevStateDriver =3D { .stateReload =3D nodeStateReload, /* 0.7.3 */ }; =20 -int udevNodeRegister(void) + +int +udevNodeRegister(void) { VIR_DEBUG("Registering udev node device backend"); =20 --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792289653799.6857618188533; Wed, 29 Mar 2017 05:58:09 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C6ED0754; Wed, 29 Mar 2017 12:58:07 +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 971E177719; Wed, 29 Mar 2017 12:58:07 +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 4A4C418523C9; Wed, 29 Mar 2017 12:58:07 +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 v2TCpVvR010068 for ; Wed, 29 Mar 2017 08:51:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4CC4E9629F; Wed, 29 Mar 2017 12:51:31 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D123173A8; Wed, 29 Mar 2017 12:51:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C6ED0754 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C6ED0754 From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:12 +0200 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] [RFC PATCH 02/11] nodedev: Make use of the compile-time missing enum in switch error 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 29 Mar 2017 12:58:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" So udevGetDeviceDetails was one those functions using an enum in a switch, but since it had a 'default' case, compiler didn't warn about an unhandled enum. Moreover, the error about an unsupported device type reported in the default case is unnecessary, since by the time we get there, udevGetDeviceType (which was called before) already made sure that any unrecognized device types had been handled properly. Signed-off-by: Erik Skultety --- src/node_device/node_device_udev.c | 45 +++++++++++++---------------------= ---- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 4a837e04dc..976ccad710 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1079,50 +1079,35 @@ static int udevGetDeviceDetails(struct udev_device *device, virNodeDeviceDefPtr def) { - int ret =3D 0; - switch (def->caps->data.type) { - case VIR_NODE_DEV_CAP_SYSTEM: - /* There's no libudev equivalent of system, so ignore it. */ - break; case VIR_NODE_DEV_CAP_PCI_DEV: - ret =3D udevProcessPCI(device, def); - break; + return udevProcessPCI(device, def); case VIR_NODE_DEV_CAP_USB_DEV: - ret =3D udevProcessUSBDevice(device, def); - break; + return udevProcessUSBDevice(device, def); case VIR_NODE_DEV_CAP_USB_INTERFACE: - ret =3D udevProcessUSBInterface(device, def); - break; + return udevProcessUSBInterface(device, def); case VIR_NODE_DEV_CAP_NET: - ret =3D udevProcessNetworkInterface(device, def); - break; + return udevProcessNetworkInterface(device, def); case VIR_NODE_DEV_CAP_SCSI_HOST: - ret =3D udevProcessSCSIHost(device, def); - break; + return udevProcessSCSIHost(device, def); case VIR_NODE_DEV_CAP_SCSI_TARGET: - ret =3D udevProcessSCSITarget(device, def); - break; + return udevProcessSCSITarget(device, def); case VIR_NODE_DEV_CAP_SCSI: - ret =3D udevProcessSCSIDevice(device, def); - break; + return udevProcessSCSIDevice(device, def); case VIR_NODE_DEV_CAP_STORAGE: - ret =3D udevProcessStorage(device, def); - break; + return udevProcessStorage(device, def); case VIR_NODE_DEV_CAP_SCSI_GENERIC: - ret =3D udevProcessSCSIGeneric(device, def); - break; + return udevProcessSCSIGeneric(device, def); case VIR_NODE_DEV_CAP_DRM: - ret =3D udevProcessDRMDevice(device, def); - break; - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown device type %d"), def->caps->data.type); - ret =3D -1; + return udevProcessDRMDevice(device, def); + case VIR_NODE_DEV_CAP_SYSTEM: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_LAST: break; } =20 - return ret; + return 0; } =20 =20 --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 149079229358592.7318933157992; Wed, 29 Mar 2017 05:58:13 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id F03C922BA29; Wed, 29 Mar 2017 12:58:11 +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 C3A27B23E7; Wed, 29 Mar 2017 12:58:11 +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 7989818523CC; Wed, 29 Mar 2017 12:58:11 +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 v2TCpW5Y010076 for ; Wed, 29 Mar 2017 08:51:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8BA6A173A8; Wed, 29 Mar 2017 12:51:32 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D24E96657; Wed, 29 Mar 2017 12:51:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F03C922BA29 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F03C922BA29 From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:13 +0200 Message-Id: <9bc824d0ecef58fff3a6dc142c816ff9a69c7de7.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 03/11] conf: nodedev: Split virNodeDeviceDefFormat into more functions 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 29 Mar 2017 12:58:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make the code look cleaner by moving the capability specific bits into separate functions. Signed-off-by: Erik Skultety --- src/conf/node_device_conf.c | 578 ++++++++++++++++++++++++----------------= ---- 1 file changed, 322 insertions(+), 256 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 7d0baa9d1a..72fb9a5611 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -155,6 +155,320 @@ virPCIEDeviceInfoFormat(virBufferPtr buf, } =20 =20 +static void +virNodeDeviceCapSystemDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + if (data->system.product_name) + virBufferEscapeString(buf, "%s\n", + data->system.product_name); + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + if (data->system.hardware.vendor_name) + virBufferEscapeString(buf, "%s\n", + data->system.hardware.vendor_name); + if (data->system.hardware.version) + virBufferEscapeString(buf, "%s\n", + data->system.hardware.version); + if (data->system.hardware.serial) + virBufferEscapeString(buf, "%s\n", + data->system.hardware.serial); + virUUIDFormat(data->system.hardware.uuid, uuidstr); + virBufferAsprintf(buf, "%s\n", uuidstr); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + if (data->system.firmware.vendor_name) + virBufferEscapeString(buf, "%s\n", + data->system.firmware.vendor_name); + if (data->system.firmware.version) + virBufferEscapeString(buf, "%s\n", + data->system.firmware.version); + if (data->system.firmware.release_date) + virBufferEscapeString(buf, "%s\n", + data->system.firmware.release_date); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); +} + + +static void +virNodeDeviceCapPCIDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + size_t i; + + virBufferAsprintf(buf, "%d\n", + data->pci_dev.domain); + virBufferAsprintf(buf, "%d\n", data->pci_dev.bus); + virBufferAsprintf(buf, "%d\n", + data->pci_dev.slot); + virBufferAsprintf(buf, "%d\n", + data->pci_dev.function); + virBufferAsprintf(buf, "pci_dev.product); + if (data->pci_dev.product_name) + virBufferEscapeString(buf, ">%s\n", + data->pci_dev.product_name); + else + virBufferAddLit(buf, " />\n"); + virBufferAsprintf(buf, "pci_dev.vendor); + if (data->pci_dev.vendor_name) + virBufferEscapeString(buf, ">%s\n", + data->pci_dev.vendor_name); + else + virBufferAddLit(buf, " />\n"); + if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION)= { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, + "
\n", + data->pci_dev.physical_function->domain, + data->pci_dev.physical_function->bus, + data->pci_dev.physical_function->slot, + data->pci_dev.physical_function->function); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) { + virBufferAddLit(buf, "pci_dev.max_virtual_functions) + virBufferAsprintf(buf, " maxCount=3D'%u'", + data->pci_dev.max_virtual_functions); + if (data->pci_dev.num_virtual_functions =3D=3D 0) { + virBufferAddLit(buf, "/>\n"); + } else { + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + for (i =3D 0; i < data->pci_dev.num_virtual_functions; i++) { + virBufferAsprintf(buf, + "
\n= ", + data->pci_dev.virtual_functions[i]->doma= in, + data->pci_dev.virtual_functions[i]->bus, + data->pci_dev.virtual_functions[i]->slot, + data->pci_dev.virtual_functions[i]->func= tion); + } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + } + if (data->pci_dev.hdrType) { + virBufferAsprintf(buf, "\n", + virPCIHeaderTypeToString(data->pci_dev.hdrType)); + } + if (data->pci_dev.nIommuGroupDevices) { + virBufferAsprintf(buf, "\n", + data->pci_dev.iommuGroupNumber); + virBufferAdjustIndent(buf, 2); + for (i =3D 0; i < data->pci_dev.nIommuGroupDevices; i++) { + virBufferAsprintf(buf, + "
\n", + data->pci_dev.iommuGroupDevices[i]->domain, + data->pci_dev.iommuGroupDevices[i]->bus, + data->pci_dev.iommuGroupDevices[i]->slot, + data->pci_dev.iommuGroupDevices[i]->function= ); + } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + if (data->pci_dev.numa_node >=3D 0) + virBufferAsprintf(buf, "\n", + data->pci_dev.numa_node); + + if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE) + virPCIEDeviceInfoFormat(buf, data->pci_dev.pci_express); +} + + +static void +virNodeDeviceCapUSBDevDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + virBufferAsprintf(buf, "%d\n", data->usb_dev.bus); + virBufferAsprintf(buf, "%d\n", + data->usb_dev.device); + virBufferAsprintf(buf, "usb_dev.product); + if (data->usb_dev.product_name) + virBufferEscapeString(buf, ">%s\n", + data->usb_dev.product_name); + else + virBufferAddLit(buf, " />\n"); + virBufferAsprintf(buf, "usb_dev.vendor); + if (data->usb_dev.vendor_name) + virBufferEscapeString(buf, ">%s\n", + data->usb_dev.vendor_name); + else + virBufferAddLit(buf, " />\n"); +} + + +static void +virNodeDeviceCapUSBInterfaceDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + virBufferAsprintf(buf, "%d\n", + data->usb_if.number); + virBufferAsprintf(buf, "%d\n", + data->usb_if._class); + virBufferAsprintf(buf, "%d\n", + data->usb_if.subclass); + virBufferAsprintf(buf, "%d\n", + data->usb_if.protocol); + if (data->usb_if.description) + virBufferEscapeString(buf, + "%s\n", + data->usb_if.description); +} + + +static void +virNodeDeviceCapNetDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + size_t i; + + virBufferEscapeString(buf, "%s\n", + data->net.ifname); + if (data->net.address) + virBufferEscapeString(buf, "
%s
\n", + data->net.address); + virInterfaceLinkFormat(buf, &data->net.lnk); + if (data->net.features) { + for (i =3D 0; i < VIR_NET_DEV_FEAT_LAST; i++) { + if (virBitmapIsBitSet(data->net.features, i)) { + virBufferAsprintf(buf, "\n", + virNetDevFeatureTypeToString(i)); + } + } + } + if (data->net.subtype !=3D VIR_NODE_DEV_CAP_NET_LAST) { + const char *subtyp =3D + virNodeDevNetCapTypeToString(data->net.subtype); + virBufferEscapeString(buf, "\n", + subtyp); + } +} + + +static void +virNodeDeviceCapSCSIHostDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + virBufferAsprintf(buf, "%d\n", + data->scsi_host.host); + if (data->scsi_host.unique_id !=3D -1) + virBufferAsprintf(buf, "%d\n", + data->scsi_host.unique_id); + if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "%s\n", + data->scsi_host.wwnn); + virBufferEscapeString(buf, "%s\n", + data->scsi_host.wwpn); + virBufferEscapeString(buf, "%s\n", + data->scsi_host.fabric_wwn); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "%d\n", + data->scsi_host.max_vports); + virBufferAsprintf(buf, "%d\n", + data->scsi_host.vports); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } +} + + +static void +virNodeDeviceCapSCSIDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + virBufferAsprintf(buf, "%d\n", data->scsi.host); + virBufferAsprintf(buf, "%d\n", data->scsi.bus); + virBufferAsprintf(buf, "%d\n", + data->scsi.target); + virBufferAsprintf(buf, "%d\n", data->scsi.lun); + if (data->scsi.type) + virBufferEscapeString(buf, "%s\n", + data->scsi.type); +} + + +static void +virNodeDeviceCapStorageDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + virBufferEscapeString(buf, "%s\n", + data->storage.block); + if (data->storage.bus) + virBufferEscapeString(buf, "%s\n", + data->storage.bus); + if (data->storage.drive_type) + virBufferEscapeString(buf, "%s\n", + data->storage.drive_type); + if (data->storage.model) + virBufferEscapeString(buf, "%s\n", + data->storage.model); + if (data->storage.vendor) + virBufferEscapeString(buf, "%s\n", + data->storage.vendor); + if (data->storage.serial) + virBufferEscapeString(buf, "%s\n", + data->storage.serial); + if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) { + int avl =3D data->storage.flags & + VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "%d" + "\n", avl ? 1 : 0); + virBufferAsprintf(buf, "%llu\n", + data->storage.removable_media_size); + if (data->storage.media_label) + virBufferEscapeString(buf, + "%s\n", + data->storage.media_label); + if (data->storage.logical_block_size > 0) + virBufferAsprintf(buf, "%llu" + "\n", + data->storage.logical_block_size); + if (data->storage.num_blocks > 0) + virBufferAsprintf(buf, + "%llu\n", + data->storage.num_blocks); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } else { + virBufferAsprintf(buf, "%llu\n", + data->storage.size); + if (data->storage.logical_block_size > 0) + virBufferAsprintf(buf, "%llu" + "\n", + data->storage.logical_block_size); + if (data->storage.num_blocks > 0) + virBufferAsprintf(buf, "%llu\n", + data->storage.num_blocks); + } + if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE) + virBufferAddLit(buf, "\n"); +} + + char * virNodeDeviceDefFormat(const virNodeDeviceDef *def) { @@ -185,7 +499,6 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) } =20 for (caps =3D def->caps; caps; caps =3D caps->next) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; virNodeDevCapDataPtr data =3D &caps->data; =20 virBufferAsprintf(&buf, "\n", @@ -193,279 +506,32 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) virBufferAdjustIndent(&buf, 2); switch (caps->data.type) { case VIR_NODE_DEV_CAP_SYSTEM: - if (data->system.product_name) - virBufferEscapeString(&buf, "%s\n", - data->system.product_name); - virBufferAddLit(&buf, "\n"); - virBufferAdjustIndent(&buf, 2); - if (data->system.hardware.vendor_name) - virBufferEscapeString(&buf, "%s\n", - data->system.hardware.vendor_name); - if (data->system.hardware.version) - virBufferEscapeString(&buf, "%s\n", - data->system.hardware.version); - if (data->system.hardware.serial) - virBufferEscapeString(&buf, "%s\n", - data->system.hardware.serial); - virUUIDFormat(data->system.hardware.uuid, uuidstr); - virBufferAsprintf(&buf, "%s\n", uuidstr); - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); - - virBufferAddLit(&buf, "\n"); - virBufferAdjustIndent(&buf, 2); - if (data->system.firmware.vendor_name) - virBufferEscapeString(&buf, "%s\n", - data->system.firmware.vendor_name); - if (data->system.firmware.version) - virBufferEscapeString(&buf, "%s\n", - data->system.firmware.version); - if (data->system.firmware.release_date) - virBufferEscapeString(&buf, "%s\n", - data->system.firmware.release_date); - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); + virNodeDeviceCapSystemDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_PCI_DEV: - virBufferAsprintf(&buf, "%d\n", - data->pci_dev.domain); - virBufferAsprintf(&buf, "%d\n", data->pci_dev.bus); - virBufferAsprintf(&buf, "%d\n", - data->pci_dev.slot); - virBufferAsprintf(&buf, "%d\n", - data->pci_dev.function); - virBufferAsprintf(&buf, "pci_dev.product); - if (data->pci_dev.product_name) - virBufferEscapeString(&buf, ">%s\n", - data->pci_dev.product_name); - else - virBufferAddLit(&buf, " />\n"); - virBufferAsprintf(&buf, "pci_dev.vendor); - if (data->pci_dev.vendor_name) - virBufferEscapeString(&buf, ">%s\n", - data->pci_dev.vendor_name); - else - virBufferAddLit(&buf, " />\n"); - if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_F= UNCTION) { - virBufferAddLit(&buf, "= \n"); - virBufferAdjustIndent(&buf, 2); - virBufferAsprintf(&buf, - "
\n= ", - data->pci_dev.physical_function->domain, - data->pci_dev.physical_function->bus, - data->pci_dev.physical_function->slot, - data->pci_dev.physical_function->functio= n); - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); - } - if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FU= NCTION) { - virBufferAddLit(&buf, "pci_dev.max_virtual_functions) - virBufferAsprintf(&buf, " maxCount=3D'%u'", - data->pci_dev.max_virtual_functions); - if (data->pci_dev.num_virtual_functions =3D=3D 0) { - virBufferAddLit(&buf, "/>\n"); - } else { - virBufferAddLit(&buf, ">\n"); - virBufferAdjustIndent(&buf, 2); - for (i =3D 0; i < data->pci_dev.num_virtual_functions;= i++) { - virBufferAsprintf(&buf, - "
\n", - data->pci_dev.virtual_functions[= i]->domain, - data->pci_dev.virtual_functions[= i]->bus, - data->pci_dev.virtual_functions[= i]->slot, - data->pci_dev.virtual_functions[= i]->function); - } - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); - } - } - if (data->pci_dev.hdrType) { - virBufferAsprintf(&buf, "\n", - virPCIHeaderTypeToString(data->pci_dev.h= drType)); - } - if (data->pci_dev.nIommuGroupDevices) { - virBufferAsprintf(&buf, "\n", - data->pci_dev.iommuGroupNumber); - virBufferAdjustIndent(&buf, 2); - for (i =3D 0; i < data->pci_dev.nIommuGroupDevices; i++) { - virBufferAsprintf(&buf, - "
\n", - data->pci_dev.iommuGroupDevices[i]->= domain, - data->pci_dev.iommuGroupDevices[i]->= bus, - data->pci_dev.iommuGroupDevices[i]->= slot, - data->pci_dev.iommuGroupDevices[i]->= function); - } - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); - } - if (data->pci_dev.numa_node >=3D 0) - virBufferAsprintf(&buf, "\n", - data->pci_dev.numa_node); - - if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE) - virPCIEDeviceInfoFormat(&buf, data->pci_dev.pci_express); + virNodeDeviceCapPCIDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_USB_DEV: - virBufferAsprintf(&buf, "%d\n", data->usb_dev.bus); - virBufferAsprintf(&buf, "%d\n", - data->usb_dev.device); - virBufferAsprintf(&buf, "usb_dev.product); - if (data->usb_dev.product_name) - virBufferEscapeString(&buf, ">%s\n", - data->usb_dev.product_name); - else - virBufferAddLit(&buf, " />\n"); - virBufferAsprintf(&buf, "usb_dev.vendor); - if (data->usb_dev.vendor_name) - virBufferEscapeString(&buf, ">%s\n", - data->usb_dev.vendor_name); - else - virBufferAddLit(&buf, " />\n"); + virNodeDeviceCapUSBDevDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_USB_INTERFACE: - virBufferAsprintf(&buf, "%d\n", - data->usb_if.number); - virBufferAsprintf(&buf, "%d\n", - data->usb_if._class); - virBufferAsprintf(&buf, "%d\n", - data->usb_if.subclass); - virBufferAsprintf(&buf, "%d\n", - data->usb_if.protocol); - if (data->usb_if.description) - virBufferEscapeString(&buf, - "%s\n", - data->usb_if.description); + virNodeDeviceCapUSBInterfaceDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_NET: - virBufferEscapeString(&buf, "%s\n", - data->net.ifname); - if (data->net.address) - virBufferEscapeString(&buf, "
%s
\n", - data->net.address); - virInterfaceLinkFormat(&buf, &data->net.lnk); - if (data->net.features) { - for (i =3D 0; i < VIR_NET_DEV_FEAT_LAST; i++) { - if (virBitmapIsBitSet(data->net.features, i)) { - virBufferAsprintf(&buf, "\n", - virNetDevFeatureTypeToString(i)); - } - } - } - if (data->net.subtype !=3D VIR_NODE_DEV_CAP_NET_LAST) { - const char *subtyp =3D - virNodeDevNetCapTypeToString(data->net.subtype); - virBufferEscapeString(&buf, "\n", - subtyp); - } + virNodeDeviceCapNetDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_SCSI_HOST: - virBufferAsprintf(&buf, "%d\n", - data->scsi_host.host); - if (data->scsi_host.unique_id !=3D -1) - virBufferAsprintf(&buf, "%d\n", - data->scsi_host.unique_id); - if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST)= { - virBufferAddLit(&buf, "\n"); - virBufferAdjustIndent(&buf, 2); - virBufferEscapeString(&buf, "%s\n", - data->scsi_host.wwnn); - virBufferEscapeString(&buf, "%s\n", - data->scsi_host.wwpn); - virBufferEscapeString(&buf, "%s\n= ", - data->scsi_host.fabric_wwn); - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); - } - if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OP= S) { - virBufferAddLit(&buf, "\n"); - virBufferAdjustIndent(&buf, 2); - virBufferAsprintf(&buf, "%d\n", - data->scsi_host.max_vports); - virBufferAsprintf(&buf, "%d\n", - data->scsi_host.vports); - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); - } - + virNodeDeviceCapSCSIHostDefFormat(&buf, data); break; - case VIR_NODE_DEV_CAP_SCSI_TARGET: virBufferEscapeString(&buf, "%s\n", data->scsi_target.name); break; - case VIR_NODE_DEV_CAP_SCSI: - virBufferAsprintf(&buf, "%d\n", data->scsi.host); - virBufferAsprintf(&buf, "%d\n", data->scsi.bus); - virBufferAsprintf(&buf, "%d\n", - data->scsi.target); - virBufferAsprintf(&buf, "%d\n", data->scsi.lun); - if (data->scsi.type) - virBufferEscapeString(&buf, "%s\n", - data->scsi.type); + virNodeDeviceCapSCSIDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_STORAGE: - virBufferEscapeString(&buf, "%s\n", - data->storage.block); - if (data->storage.bus) - virBufferEscapeString(&buf, "%s\n", - data->storage.bus); - if (data->storage.drive_type) - virBufferEscapeString(&buf, "%s\n= ", - data->storage.drive_type); - if (data->storage.model) - virBufferEscapeString(&buf, "%s\n", - data->storage.model); - if (data->storage.vendor) - virBufferEscapeString(&buf, "%s\n", - data->storage.vendor); - if (data->storage.serial) - virBufferEscapeString(&buf, "%s\n", - data->storage.serial); - if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) { - int avl =3D data->storage.flags & - VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; - virBufferAddLit(&buf, "\n"); - virBufferAdjustIndent(&buf, 2); - virBufferAsprintf(&buf, "%d" - "\n", avl ? 1 : 0); - virBufferAsprintf(&buf, "%llu\n", - data->storage.removable_media_size); - if (data->storage.media_label) - virBufferEscapeString(&buf, - "%s\n= ", - data->storage.media_label); - if (data->storage.logical_block_size > 0) - virBufferAsprintf(&buf, "%llu" - "\n", - data->storage.logical_block_size); - if (data->storage.num_blocks > 0) - virBufferAsprintf(&buf, - "%llu\n", - data->storage.num_blocks); - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); - } else { - virBufferAsprintf(&buf, "%llu\n", - data->storage.size); - if (data->storage.logical_block_size > 0) - virBufferAsprintf(&buf, "%llu" - "\n", - data->storage.logical_block_size); - if (data->storage.num_blocks > 0) - virBufferAsprintf(&buf, "%llu= \n", - data->storage.num_blocks); - } - if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABL= E) - virBufferAddLit(&buf, "= \n"); + virNodeDeviceCapStorageDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_SCSI_GENERIC: virBufferEscapeString(&buf, "%s\n", --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792437785690.6260763796331; Wed, 29 Mar 2017 06:00:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id BD5937572E; Wed, 29 Mar 2017 13:00:35 +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 88CB083863; Wed, 29 Mar 2017 13:00:35 +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 E123718523CA; Wed, 29 Mar 2017 13:00:34 +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 v2TCpXqR010081 for ; Wed, 29 Mar 2017 08:51:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8522A962B7; Wed, 29 Mar 2017 12:51:33 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id D95D7173A8; Wed, 29 Mar 2017 12:51:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BD5937572E Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BD5937572E From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:14 +0200 Message-Id: <662ea539806f1d45010e770798541fb691eba678.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 04/11] nodedev: udevProcessPCI: Drop syspath variable 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 29 Mar 2017 13:00:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we have that information provided by @def which is not a private object, there is really no need for the variable. Signed-off-by: Erik Skultety --- src/node_device/node_device_udev.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 976ccad710..36ed92f712 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -328,7 +328,6 @@ static int udevProcessPCI(struct udev_device *device, virNodeDeviceDefPtr def) { - const char *syspath =3D NULL; virNodeDevCapPCIDevPtr pci_dev =3D &def->caps->data.pci_dev; virPCIEDeviceInfoPtr pci_express =3D NULL; virPCIDevicePtr pciDev =3D NULL; @@ -336,19 +335,17 @@ udevProcessPCI(struct udev_device *device, int ret =3D -1; char *p; =20 - syspath =3D udev_device_get_syspath(device); - if (udevGetUintProperty(device, "PCI_CLASS", &pci_dev->class, 16) < 0) goto cleanup; =20 - if ((p =3D strrchr(syspath, '/')) =3D=3D NULL || + if ((p =3D strrchr(def->sysfs_path, '/')) =3D=3D NULL || virStrToLong_ui(p + 1, &p, 16, &pci_dev->domain) < 0 || p =3D=3D N= ULL || virStrToLong_ui(p + 1, &p, 16, &pci_dev->bus) < 0 || p =3D=3D NULL= || virStrToLong_ui(p + 1, &p, 16, &pci_dev->slot) < 0 || p =3D=3D NUL= L || virStrToLong_ui(p + 1, &p, 16, &pci_dev->function) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse the PCI address from sysfs path:= '%s'"), - syspath); + def->sysfs_path); goto cleanup; } =20 @@ -375,8 +372,7 @@ udevProcessPCI(struct udev_device *device, &pci_dev->numa_node, 10) < 0) goto cleanup; =20 - if (nodeDeviceSysfsGetPCIRelatedDevCaps(syspath, - &def->caps->data.pci_dev) < 0) + if (nodeDeviceSysfsGetPCIRelatedDevCaps(def->sysfs_path, pci_dev) < 0) goto cleanup; =20 if (!(pciDev =3D virPCIDeviceNew(pci_dev->domain, --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792297276118.20158032686413; Wed, 29 Mar 2017 05:58:17 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B354DC05B1E3; Wed, 29 Mar 2017 12:58:15 +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 7E13578496; Wed, 29 Mar 2017 12:58:15 +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 367B318523D1; Wed, 29 Mar 2017 12:58:15 +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 v2TCpYMN010088 for ; Wed, 29 Mar 2017 08:51:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E4429629F; Wed, 29 Mar 2017 12:51:34 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2BB9173A8; Wed, 29 Mar 2017 12:51:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B354DC05B1E3 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B354DC05B1E3 From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:15 +0200 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] [RFC PATCH 05/11] docs: Use our XSLT template to generate list of supported pool types 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 29 Mar 2017 12:58:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we do have this template at hand, why not using it wherever possible. Also, just to be grammatically correct, let's use singular, aka 'pool' instead of plural in the enumerated list of supported types. Signed-off-by: Erik Skultety --- docs/storage.html.in | 62 ++++++++++--------------------------------------= ---- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/docs/storage.html.in b/docs/storage.html.in index 5e18f02c58..2487ede67b 100644 --- a/docs/storage.html.in +++ b/docs/storage.html.in @@ -83,47 +83,7 @@

Libvirt supports the following storage pool types:

- +
    =20

    Directory pool

    @@ -306,7 +266,7 @@

    =20 =20 -

    Logical volume pools

    +

    Logical volume pool

    This provides a pool based on an LVM volume group. For a pre-defined LVM volume group, simply providing the group @@ -343,7 +303,7 @@

    =20 =20 -

    Disk volume pools

    +

    Disk volume pool

    This provides a pool based on a physical disk. Volumes are created by adding partitions to the disk. Disk pools have constraints @@ -434,7 +394,7 @@ =20 =20 -

    iSCSI volume pools

    +

    iSCSI volume pool

    This provides a pool based on an iSCSI target. Volumes must be pre-allocated on the iSCSI server, and cannot be created via @@ -473,7 +433,7 @@ The iSCSI volume pool does not use the volume format type element.

    =20 -

    SCSI volume pools

    +

    SCSI volume pool

    This provides a pool based on a SCSI HBA. Volumes are preexisting SC= SI LUNs, and cannot be created via the libvirt APIs. Since /dev/XXX nam= es @@ -505,7 +465,7 @@ The SCSI volume pool does not use the volume format type element.

    =20 -

    Multipath pools

    +

    Multipath pool

    This provides a pool that contains all the multipath devices on the host. Therefore, only one Multipath pool may be configured per host. @@ -538,7 +498,7 @@ The Multipath volume pool does not use the volume format type elemen= t.

    =20 -

    RBD pools

    +

    RBD pool

    This storage driver provides a pool which contains all RBD images in a RADOS pool. RBD (RADOS Block Device) is part @@ -611,7 +571,7 @@ The RBD pool does not use the volume format type element.

    =20 -

    Sheepdog pools

    +

    Sheepdog pool

    This provides a pool based on a Sheepdog Cluster. Sheepdog is a distributed storage system for QEMU/KVM. @@ -670,7 +630,7 @@ The Sheepdog pool does not use the volume format type element.

    =20 -

    Gluster pools

    +

    Gluster pool

    This provides a pool based on native Gluster access. Gluster is a distributed file system that can be exposed to the user via @@ -756,7 +716,7 @@ pool type.

    =20 -

    ZFS pools

    +

    ZFS pool

    This provides a pool based on the ZFS filesystem. Initially it was d= eveloped for FreeBSD, and since 1.3.2 experiment= al support @@ -794,7 +754,7 @@

    The ZFS volume pool does not use the volume format type element.

    -

    Vstorage pools

    +

    Vstorage pool

    This provides a pool based on Virtuozzo storage. Virtuozzo Storage is a highly available distributed software-defined storage with built-in --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792301278515.6588011638028; Wed, 29 Mar 2017 05:58:21 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5FE937FD42; Wed, 29 Mar 2017 12:58:19 +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 2C0FE7D9F1; Wed, 29 Mar 2017 12:58:19 +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 C4FEF18523D2; Wed, 29 Mar 2017 12:58:18 +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 v2TCpZHG010096 for ; Wed, 29 Mar 2017 08:51:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id A9FC69629F; Wed, 29 Mar 2017 12:51:35 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC165173A8; Wed, 29 Mar 2017 12:51:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5FE937FD42 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5FE937FD42 From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:16 +0200 Message-Id: <46d6174c53c51803fe6474602555ef2d6b1ab577.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 06/11] nodedev: Introduce the mdev capability to the nodedev driver structure 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 29 Mar 2017 12:58:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Besides updating the capability enum, this patch introduces 'virNodeDevCapMdev' structure which will store everything libvirt can gather from sysfs about a mediated device. Since we need to report the info for both the mediated child device it's parent mdev capabilities (merely the mdev types' attributes), this structure serves in both of these cases with the difference being that the amount of data it holds depends on the specific scenario (child vs parent). Signed-off-by: Erik Skultety --- include/libvirt/libvirt-nodedev.h | 1 + src/conf/node_device_conf.c | 19 ++++++++++++++++++- src/conf/node_device_conf.h | 19 ++++++++++++++++++- src/conf/virnodedeviceobj.c | 3 ++- src/libvirt-nodedev.c | 1 + src/libvirt_private.syms | 1 + src/node_device/node_device_driver.c | 1 + src/node_device/node_device_udev.c | 8 +++++++- tools/virsh-nodedev.c | 2 ++ 9 files changed, 51 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-no= dedev.h index 85003903d7..59edf4db02 100644 --- a/include/libvirt/libvirt-nodedev.h +++ b/include/libvirt/libvirt-nodedev.h @@ -79,6 +79,7 @@ typedef enum { VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS =3D 1 << 10, /* Capabl= e of vport */ VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC =3D 1 << 11, /* Capabl= e of scsi_generic */ VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM =3D 1 << 12, /* DRM de= vice */ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV =3D 1 << 13, /* Mediat= ed device */ } virConnectListAllNodeDeviceFlags; =20 int virConnectListAllNodeDevices (virConnectPtr conn, diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 72fb9a5611..03d7993ab1 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -60,7 +60,8 @@ VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST, "fc_host", "vports", "scsi_generic", - "drm") + "drm", + "mdev") =20 VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST, "80203", @@ -542,6 +543,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) break; case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_MDEV: case VIR_NODE_DEV_CAP_LAST: break; } @@ -1591,6 +1593,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, 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: case VIR_NODE_DEV_CAP_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown capability type '%d' for '%s'"), @@ -1905,6 +1908,7 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) case VIR_NODE_DEV_CAP_SCSI_GENERIC: VIR_FREE(data->sg.path); break; + case VIR_NODE_DEV_CAP_MDEV: case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: @@ -1917,6 +1921,19 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) } =20 =20 +void virNodeDevCapMdevFree(virNodeDevCapMdevPtr mdev) +{ + if (!mdev) + return; + + VIR_FREE(mdev->type); + VIR_FREE(mdev->name); + VIR_FREE(mdev->description); + VIR_FREE(mdev->device_api); + VIR_FREE(mdev); +} + + /* virNodeDeviceGetParentName * @conn: Connection pointer * @nodedev_name: Node device to lookup diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index a5d5cdd2a5..b7db35dd50 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -64,6 +64,7 @@ typedef enum { VIR_NODE_DEV_CAP_VPORTS, /* HBA which is capable of vports */ VIR_NODE_DEV_CAP_SCSI_GENERIC, /* SCSI generic device */ VIR_NODE_DEV_CAP_DRM, /* DRM device */ + VIR_NODE_DEV_CAP_MDEV, /* Mediated device */ =20 VIR_NODE_DEV_CAP_LAST } virNodeDevCapType; @@ -131,6 +132,17 @@ struct _virNodeDevCapSystem { virNodeDevCapSystemFirmware firmware; }; =20 +typedef struct _virNodeDevCapMdev virNodeDevCapMdev; +typedef virNodeDevCapMdev *virNodeDevCapMdevPtr; +struct _virNodeDevCapMdev { + char *type; + char *name; + char *description; + char *device_api; + unsigned int available_instances; + unsigned int iommuGroupNumber; +}; + typedef struct _virNodeDevCapPCIDev virNodeDevCapPCIDev; typedef virNodeDevCapPCIDev *virNodeDevCapPCIDevPtr; struct _virNodeDevCapPCIDev { @@ -262,6 +274,7 @@ struct _virNodeDevCapData { virNodeDevCapStorage storage; virNodeDevCapSCSIGeneric sg; virNodeDevCapDRM drm; + virNodeDevCapMdev mdev; }; }; =20 @@ -338,6 +351,9 @@ virNodeDeviceDefFree(virNodeDeviceDefPtr def); void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps); =20 +void +virNodeDevCapMdevFree(virNodeDevCapMdevPtr mdev); + # define VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP \ (VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM | \ VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV | \ @@ -351,7 +367,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps); VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST | \ VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS | \ VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC | \ - VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM) + VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM | \ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV) =20 char * virNodeDeviceGetParentName(virConnectPtr conn, diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 3fe3ae5fe8..1dfb7380c7 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -494,7 +494,8 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj, MATCH(FC_HOST) || MATCH(VPORTS) || MATCH(SCSI_GENERIC) || - MATCH(DRM))) + MATCH(DRM) || + MATCH(MDEV))) return false; } =20 diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c index 83376b0d96..f9d8edf7e5 100644 --- a/src/libvirt-nodedev.c +++ b/src/libvirt-nodedev.c @@ -98,6 +98,7 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, = unsigned int flags) * VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS * VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC * VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM + * VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV * * Returns the number of node devices found or -1 and sets @devices to NUL= L in * case of error. On success, the array stored into @devices is guarantee= d to diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b551cb86a6..2a3e8cb705 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -690,6 +690,7 @@ virNetDevIPRouteParseXML; =20 =20 # conf/node_device_conf.h +virNodeDevCapMdevFree; virNodeDevCapsDefFree; virNodeDevCapTypeFromString; virNodeDevCapTypeToString; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 9b1c5bb5e9..bcf204c7b7 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -83,6 +83,7 @@ update_caps(virNodeDeviceObjPtr dev) 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: case VIR_NODE_DEV_CAP_LAST: break; } diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 36ed92f712..dbbd8e5d06 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -43,6 +43,7 @@ #include "virpci.h" #include "virstring.h" #include "virnetdev.h" +#include "virmdev.h" =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 @@ -1051,12 +1052,16 @@ udevGetDeviceType(struct udev_device *device, if (udevHasDeviceProperty(device, "INTERFACE")) *type =3D VIR_NODE_DEV_CAP_NET; =20 - /* SCSI generic device doesn't set DEVTYPE property */ + /* Neither SCSI generic devices nor mediated devices set DEVTYPE + * property, but they so we need to rely on the SUBSYSTEM property= */ if (udevGetStringProperty(device, "SUBSYSTEM", &subsystem) < 0) return -1; =20 if (STREQ_NULLABLE(subsystem, "scsi_generic")) *type =3D VIR_NODE_DEV_CAP_SCSI_GENERIC; + else if (STREQ_NULLABLE(subsystem, "mdev")) + *type =3D VIR_NODE_DEV_CAP_MDEV; + VIR_FREE(subsystem); } =20 @@ -1096,6 +1101,7 @@ udevGetDeviceDetails(struct udev_device *device, return udevProcessSCSIGeneric(device, def); case VIR_NODE_DEV_CAP_DRM: return udevProcessDRMDevice(device, def); + case VIR_NODE_DEV_CAP_MDEV: case VIR_NODE_DEV_CAP_SYSTEM: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index c691440219..19dcfafa6e 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -454,6 +454,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd A= TTRIBUTE_UNUSED) case VIR_NODE_DEV_CAP_DRM: flags |=3D VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM; break; + case VIR_NODE_DEV_CAP_MDEV: + flags |=3D VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV; case VIR_NODE_DEV_CAP_LAST: break; } --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792215417805.4505184556152; Wed, 29 Mar 2017 05:56:55 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id F11595A71; Wed, 29 Mar 2017 12:56:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6D47B23F5; Wed, 29 Mar 2017 12:56:53 +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 6649F5EC64; Wed, 29 Mar 2017 12:56:53 +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 v2TCpa2d010106 for ; Wed, 29 Mar 2017 08:51:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id A44D99629F; Wed, 29 Mar 2017 12:51:36 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 042EA173A8; Wed, 29 Mar 2017 12:51:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F11595A71 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F11595A71 From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:17 +0200 Message-Id: <0d53e0421890565561dd5624a09ff28f0a0da4a2.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 07/11] nodedev: Fill in the mdev info for the parent PCI device 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 29 Mar 2017 12:56:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The parent device needs to report the generic stuff about the supported mediated devices types, like device API, available instances, and description which might hold some useful data about supported resolutions for the type given, framebuffer size, etc. Unfortunately, these are not standardized yet to be considered for separate elements. Signed-off-by: Erik Skultety --- src/conf/node_device_conf.h | 2 + src/node_device/node_device_udev.c | 115 +++++++++++++++++++++++++++++++++= ++++ 2 files changed, 117 insertions(+) diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index b7db35dd50..d521dd9a4c 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -166,6 +166,8 @@ struct _virNodeDevCapPCIDev { int numa_node; virPCIEDeviceInfoPtr pci_express; int hdrType; /* enum virPCIHeaderType or -1 */ + virNodeDevCapMdevPtr *mdevs; + size_t nmdevs; }; =20 typedef struct _virNodeDevCapUSBDev virNodeDevCapUSBDev; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index dbbd8e5d06..be031fa5a8 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -324,6 +324,115 @@ udevTranslatePCIIds(unsigned int vendor, return 0; } =20 +#define MDEV_GET_SYSFS_ATTR(attr, cb, ...) = \ + do { = \ + if (virAsprintf(&attrpath, "%s/%s", relpath, #attr) < 0) = \ + goto cleanup; = \ + = \ + if (cb(device, attrpath, __VA_ARGS__) < 0) = \ + goto cleanup; = \ + } while (0) = \ + + +static int +udevGetMdevCaps(struct udev_device *device, + const char *sysfspath, + virNodeDevCapMdevPtr mdev) +{ + int ret =3D -1; + char *attrpath =3D NULL; /* relative path to the actual sysfs attribu= te */ + const char *devpath =3D NULL; /* base sysfs path as reported by udev= */ + const char *relpath =3D NULL; /* diff between @sysfspath and @devpat= h */ + char *tmp =3D NULL; + + + /* UDEV doesn't report attributes under subdirectories but can query t= hem + * if specified as relative paths to the device's base path, + * e.g. /sys/devices/../0000:00:01.0/ is the device's base path as udev + * reports it, but we're interested in attributes under + * /sys/devices/../0000:00:01.0/mdev_supported_types//. So, let's + * strip the common part of the path and let udev chew the relative bi= t. + */ + devpath =3D udev_device_get_syspath(device); + relpath =3D sysfspath + strlen(devpath); + + /* When calling from the mdev child device, @sysfspath is a symbolic l= ink + * to the actual mdev type (rather than a physical path), so we need to + * resolve it in order to get the type's name. + */ + if (virFileResolveLink(sysfspath, &tmp) < 0) + goto cleanup; + + if (VIR_STRDUP(mdev->type, last_component(tmp)) < 0) + goto cleanup; + + MDEV_GET_SYSFS_ATTR(name, udevGetStringSysfsAttr, + &mdev->name); + MDEV_GET_SYSFS_ATTR(description, udevGetStringSysfsAttr, + &mdev->description); + MDEV_GET_SYSFS_ATTR(device_api, udevGetStringSysfsAttr, + &mdev->device_api); + MDEV_GET_SYSFS_ATTR(available_instances, udevGetUintSysfsAttr, + &mdev->available_instances, 10); + + ret =3D 0; + cleanup: + VIR_FREE(attrpath); + VIR_FREE(tmp); + return ret; +} +#undef MDEV_GET_SYSFS_ATTR + + +static int +udevPCIGetMdevCaps(struct udev_device *device, + virNodeDevCapPCIDevPtr pcidata) +{ + int ret =3D -1; + DIR *dir =3D NULL; + struct dirent *entry; + char *path =3D NULL; + char *tmppath =3D NULL; + virNodeDevCapMdevPtr mdev =3D NULL; + + if (virAsprintf(&path, "%s/mdev_supported_types", + udev_device_get_syspath(device)) < 0) + return -1; + + if ((ret =3D virDirOpenIfExists(&dir, path)) <=3D 0) + goto cleanup; + + if (VIR_ALLOC(pcidata->mdevs) < 0) + goto cleanup; + + /* since udev doesn't provide means to list other than top-level + * attributes, we need to scan the subdirectories ourselves + */ + while ((ret =3D virDirRead(dir, &entry, path)) > 0) { + if (VIR_ALLOC(mdev) < 0) + goto cleanup; + + if (virAsprintf(&tmppath, "%s/%s", path, entry->d_name) < 0) + goto cleanup; + + if (udevGetMdevCaps(device, tmppath, mdev) < 0) + goto cleanup; + + if (VIR_APPEND_ELEMENT(pcidata->mdevs, pcidata->nmdevs, mdev) < 0) + goto cleanup; + + VIR_FREE(tmppath); + } + + ret =3D 0; + cleanup: + VIR_DIR_CLOSE(dir); + VIR_FREE(path); + VIR_FREE(tmppath); + virNodeDevCapMdevFree(mdev); + return ret; +} + =20 static int udevProcessPCI(struct udev_device *device, @@ -412,6 +521,12 @@ udevProcessPCI(struct udev_device *device, } } =20 + /* check whether the device is mediated devices framework capable, if = so, + * process it + */ + if (udevPCIGetMdevCaps(device, pci_dev) < 0) + goto cleanup; + ret =3D 0; =20 cleanup: --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792444527798.6595857749527; Wed, 29 Mar 2017 06:00:44 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 2BED8C065126; Wed, 29 Mar 2017 13:00:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA3F483867; Wed, 29 Mar 2017 13:00:41 +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 80CAC5EC62; Wed, 29 Mar 2017 13:00:41 +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 v2TCpbR3010117 for ; Wed, 29 Mar 2017 08:51:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF4629629F; Wed, 29 Mar 2017 12:51:37 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F19C962B8; Wed, 29 Mar 2017 12:51:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2BED8C065126 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2BED8C065126 From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:18 +0200 Message-Id: <9be3caba1f901ff52ed0ece3e34becb8ef27e95a.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 08/11] nodedev: Introduce udevProcessMediatedDevice 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 29 Mar 2017 13:00:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Start discovering the mediated devices on the host system and format the attributes for the child device into the XML. Compared to the parent device which reports generic information about the abstract mediated devices types, a child device only reports the type name it has been instantiated from and the iommu group number, since that's device specific compared to the rest of the info that can be gathered about mdevs at the moment. The resulting mdev child device XML: mdev_4b20d080_1b54_4048_85b3_a6a62d165c01 /sys/devices/.../4b20d080-1b54-4048-85b3-a6a62d165c01 pci_0000_06_00_0 vfio_mdev Signed-off-by: Erik Skultety --- src/conf/node_device_conf.c | 6 ++- src/node_device/node_device_udev.c | 87 +++++++++++++++++++++++++++++-----= ---- 2 files changed, 71 insertions(+), 22 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 03d7993ab1..1f13484d9b 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -541,9 +541,13 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) case VIR_NODE_DEV_CAP_DRM: virBufferEscapeString(&buf, "%s\n", virNodeDevDRM= TypeToString(data->drm.type)); break; + case VIR_NODE_DEV_CAP_MDEV: + virBufferEscapeString(&buf, "\n", data->mdev.= type); + virBufferAsprintf(&buf, "\n", + data->mdev.iommuGroupNumber); + break; case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: - case VIR_NODE_DEV_CAP_MDEV: case VIR_NODE_DEV_CAP_LAST: break; } diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index be031fa5a8..092d9456b2 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -324,9 +324,9 @@ udevTranslatePCIIds(unsigned int vendor, return 0; } =20 -#define MDEV_GET_SYSFS_ATTR(attr, cb, ...) = \ +#define MDEV_GET_SYSFS_ATTR(attr_name, dir, cb, ...) = \ do { = \ - if (virAsprintf(&attrpath, "%s/%s", relpath, #attr) < 0) = \ + if (virAsprintf(&attrpath, "%s/%s", dir, #attr_name) < 0) = \ goto cleanup; = \ = \ if (cb(device, attrpath, __VA_ARGS__) < 0) = \ @@ -345,17 +345,6 @@ udevGetMdevCaps(struct udev_device *device, const char *relpath =3D NULL; /* diff between @sysfspath and @devpat= h */ char *tmp =3D NULL; =20 - - /* UDEV doesn't report attributes under subdirectories but can query t= hem - * if specified as relative paths to the device's base path, - * e.g. /sys/devices/../0000:00:01.0/ is the device's base path as udev - * reports it, but we're interested in attributes under - * /sys/devices/../0000:00:01.0/mdev_supported_types//. So, let's - * strip the common part of the path and let udev chew the relative bi= t. - */ - devpath =3D udev_device_get_syspath(device); - relpath =3D sysfspath + strlen(devpath); - /* When calling from the mdev child device, @sysfspath is a symbolic l= ink * to the actual mdev type (rather than a physical path), so we need to * resolve it in order to get the type's name. @@ -366,14 +355,24 @@ udevGetMdevCaps(struct udev_device *device, if (VIR_STRDUP(mdev->type, last_component(tmp)) < 0) goto cleanup; =20 - MDEV_GET_SYSFS_ATTR(name, udevGetStringSysfsAttr, - &mdev->name); - MDEV_GET_SYSFS_ATTR(description, udevGetStringSysfsAttr, - &mdev->description); - MDEV_GET_SYSFS_ATTR(device_api, udevGetStringSysfsAttr, - &mdev->device_api); - MDEV_GET_SYSFS_ATTR(available_instances, udevGetUintSysfsAttr, - &mdev->available_instances, 10); + /* UDEV doesn't report attributes under subdirectories by default but = is + * able to query them if the path to the attribute is relative paths t= o the + * device's base path, e.g. /sys/devices/../0000:00:01.0/ is the devic= e's + * base path as udev reports it, but we're interested in attributes un= der + * /sys/devices/../0000:00:01.0/mdev_supported_types//. So, let's + * strip the common part of the path and let udev chew the relative bi= t. + */ + devpath =3D udev_device_get_syspath(device); + relpath =3D sysfspath + strlen(devpath); + + MDEV_GET_SYSFS_ATTR(name, relpath, + udevGetStringSysfsAttr, &mdev->name); + MDEV_GET_SYSFS_ATTR(description, relpath, + udevGetStringSysfsAttr, &mdev->description); + MDEV_GET_SYSFS_ATTR(device_api, relpath, + udevGetStringSysfsAttr, &mdev->device_api); + MDEV_GET_SYSFS_ATTR(available_instances, relpath, + udevGetUintSysfsAttr, &mdev->available_instances, = 10); =20 ret =3D 0; cleanup: @@ -1099,6 +1098,51 @@ udevProcessSCSIGeneric(struct udev_device *dev, =20 =20 static int +udevProcessMediatedDevice(struct udev_device *dev, + virNodeDeviceDefPtr def) +{ + int ret =3D -1; + const char *uuidstr =3D NULL; + int iommugrp =3D -1; + int model =3D -1; + char *path =3D NULL; + virMediatedDevicePtr mdev =3D NULL; + virNodeDevCapMdevPtr data =3D &def->caps->data.mdev; + + if (virAsprintf(&path, "%s/mdev_type", udev_device_get_syspath(dev)) <= 0) + goto cleanup; + + if (udevGetMdevCaps(dev, path, data) < 0) + goto cleanup; + + if ((model =3D virMediatedDeviceModelTypeFromString(data->device_api))= < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Device API '%s' not supported yet"), + data->device_api); + goto cleanup; + } + + uuidstr =3D udev_device_get_sysname(dev); + if (!(mdev =3D virMediatedDeviceNew(uuidstr, model))) + goto cleanup; + + if ((iommugrp =3D virMediatedDeviceGetIOMMUGroupNum(mdev)) < 0) + goto cleanup; + + if (udevGenerateDeviceName(dev, def, NULL) !=3D 0) + goto cleanup; + + data->iommuGroupNumber =3D iommugrp; + + ret =3D 0; + cleanup: + VIR_FREE(path); + virMediatedDeviceFree(mdev); + return ret; + +} + +static int udevGetDeviceNodes(struct udev_device *device, virNodeDeviceDefPtr def) { @@ -1217,6 +1261,7 @@ udevGetDeviceDetails(struct udev_device *device, case VIR_NODE_DEV_CAP_DRM: return udevProcessDRMDevice(device, def); case VIR_NODE_DEV_CAP_MDEV: + return udevProcessMediatedDevice(device, def); case VIR_NODE_DEV_CAP_SYSTEM: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792219017607.401486074737; Wed, 29 Mar 2017 05:56:59 -0700 (PDT) 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 8788734A6; Wed, 29 Mar 2017 12:56:57 +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 5E71C9665A; Wed, 29 Mar 2017 12:56:57 +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 16F9E18523CA; Wed, 29 Mar 2017 12:56:57 +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 v2TCpdtc010126 for ; Wed, 29 Mar 2017 08:51:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F0DD9629F; Wed, 29 Mar 2017 12:51:39 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 484ED962B8; Wed, 29 Mar 2017 12:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8788734A6 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8788734A6 From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:19 +0200 Message-Id: <9313a0d32d4bb0e2e3a45833caa6128b5cc13190.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 09/11] nodedev: Format the mdev capability of the PCI parent device 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.30]); Wed, 29 Mar 2017 12:56:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This introduces a new nested capability element of type 'mdev' with the resulting XML of the following format: ... ... optional, raw, unstructured resource allocation data vfio-pci NUM ... ... ... Signed-off-by: Erik Skultety --- src/conf/node_device_conf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 1f13484d9b..99211de6f3 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -264,6 +264,30 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "\n", virPCIHeaderTypeToString(data->pci_dev.hdrType)); } + if (data->pci_dev.mdevs) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + for (i =3D 0; i < data->pci_dev.nmdevs; i++) { + virNodeDevCapMdevPtr mdev =3D data->pci_dev.mdevs[i]; + virBufferEscapeString(buf, "\n", mdev->type); + virBufferAdjustIndent(buf, 2); + if (mdev->name) + virBufferAsprintf(buf, "%s\n", + mdev->name); + if (mdev->description) + virBufferAsprintf(buf, "%s\n", + mdev->description); + virBufferAsprintf(buf, "%s\n", + mdev->device_api); + virBufferAsprintf(buf, + "%u\n", + mdev->available_instances); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } if (data->pci_dev.nIommuGroupDevices) { virBufferAsprintf(buf, "\n", data->pci_dev.iommuGroupNumber); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792305107902.7965550556318; Wed, 29 Mar 2017 05:58:25 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 8325A8C54D; Wed, 29 Mar 2017 12:58:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5804685A5F; Wed, 29 Mar 2017 12:58:23 +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 030615EC63; Wed, 29 Mar 2017 12:58:23 +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 v2TCph9g010146 for ; Wed, 29 Mar 2017 08:51:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69925962B8; Wed, 29 Mar 2017 12:51:43 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id E76F2962BF; Wed, 29 Mar 2017 12:51:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8325A8C54D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8325A8C54D From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:20 +0200 Message-Id: <2fb9f428fba2ad5eb535e3b0261f12bd6ff97b37.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 10/11] docs: Provide a nodedev driver stub documentation 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 29 Mar 2017 12:58:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There's lot more to document about the nodedev driver, besides PCI and SR-IOV (even this might need to be extended), but let's start small-ish and at least have a page for it linked from the drivers.html. Signed-off-by: Erik Skultety --- docs/drivers.html.in | 6 +- docs/drvnodedev.html.in | 184 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 docs/drvnodedev.html.in diff --git a/docs/drivers.html.in b/docs/drivers.html.in index be7483b9bc..61993861ee 100644 --- a/docs/drivers.html.in +++ b/docs/drivers.html.in @@ -4,7 +4,11 @@

    Internal drivers

    =20 -
      + =20

      The libvirt public API delegates its implementation to one or diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in new file mode 100644 index 0000000000..ed185c3df3 --- /dev/null +++ b/docs/drvnodedev.html.in @@ -0,0 +1,184 @@ + + + + +

      Host device management

      + +

      + Libvirt provides management of both physical and virtual host devices + (historically also referred to as node devices) like USB, PCI, SCSI,= and + network devices. This also includes various virtualization capabilit= ies + which the aforementioned devices provide for utilization, for example + SR-IOV, NPIV, MDEV, DRM, etc.
      +
      + The node device driver provides means to list and show details about= host + devices (virsh nodedev-list, + virsh nodedev-dumpxml), which are generic and can be us= ed + with all devices. It also provides means to create and destroy devic= es + (virsh nodedev-create, virsh nodedev-destroy) + which are meant to be used to create virtual devices, currently only + supported by NPIV + (more info = about NPIV)).
      +
      + Devices on the host system are arranged in a tree-like hierarchy, wi= th + the root node being called computer. The node device dr= iver + supports two backends to manage the devices, HAL and udev, with the = former + being deprecated in favour of the latter.
      + The generic format of a host device XML can be seen below. + To identify a device both within the host and the device tree hierar= chy, + the following elements are used: +

      +
      +
      name
      +
      + The device's name will be generated by libvirt using the subsyst= em, + like pci and the device's sysfs basename. +
      +
      path
      +
      + Fully qualified sysfs path to the device. +
      +
      parent
      +
      + This element identifies the parent node in the device hierarchy.= The + value of the element will correspond with the device parent's + name element or computer if the device= does + not have any parent. +
      +
      driver
      +
      + This elements reports the driver in use for this device. The pre= sence + of this element in the output XML depends on whether the underly= ing + device manager (most likely udev) exposes information about the + driver. +
      +
      capability
      +
      + Describes the device in terms of feature support. The element ha= s one + mandatory attribute type the value of which determi= nes + the type of the device. Currently recognized values for the attr= ibute + are: + system, + pci, + usb, + usb_device, + net, + scsi, + scsi_host (Since 0.4.7= ), + fc_host, + vports, + scsi_target (Since 0.7.3), + storage (Since 1.0.4), + scsi_generic (Since 1.0.7), + drm (Since 3.1.0), and + mdev (Since 3.2.0). + This element can be nested in which case it further specifies a + device's capability. Refer to specific device types to see more = values + for the type attribute which are exclusive. +
      +
      + +

      Basic structure of a node device

      +
      +<device>
      +  <name>pci_0000_00_17_0</name>
      +  <path>/sys/devices/pci0000:00/0000:00:17.0</path>
      +  <parent>computer</parent>
      +  <driver>
      +    <name>ahci</name>
      +  </driver>
      +  <capability type=3D'pci'>
      +...
      +  </capability>
      +</device>
      + +
        + +

        PCI host devices

        +
        +
        capability
        +
        + When used as top level element, the supported values for the + type attribute are pci and + phys_function (see SR-IOV below= ). +
        +
        +
        +<device>
        +  <name>pci_0000_04_00_1</name>
        +  <path>/sys/devices/pci0000:00/0000:00:06.0/0000:04:00.1</path&g=
        t;
        +  <parent>pci_0000_00_06_0</parent>
        +  <driver>
        +    <name>igb</name>
        +  </driver>
        +  <capability type=3D'pci'>
        +    <domain>0</domain>
        +    <bus>4</bus>
        +    <slot>0</slot>
        +    <function>1</function>
        +    <product id=3D'0x10c9'>82576 Gigabit Network Connection</prod=
        uct>
        +    <vendor id=3D'0x8086'>Intel Corporation</vendor>
        +    <iommuGroup number=3D'15'>
        +      <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x00' function=3D=
        '0x1'/>
        +    </iommuGroup>
        +    <numa node=3D'0'/>
        +    <pci-express>
        +      <link validity=3D'cap' port=3D'1' speed=3D'2.5' width=3D'2'/>
        +      <link validity=3D'sta' speed=3D'2.5' width=3D'2'/>
        +    </pci-express>
        +  </capability>
        +</device>
        + +

        + The XML format for a PCI device stays the same for any further + capabilities it supports, a single nested <capability> + element will be included for each capability the device supports. +

        + +

        SR-IOV capability

        +

        + Single root input/output virtualization (SR-IOV) allows sharing of t= he + PCIe resources by multiple virtual environments. That is achieved by + slicing up a single full-featured physical resource called physical + function (PF) into multiple devices called virtual functions (VFs) s= haring + their configuration with the underlying PF. Despite the SR-IOV + specification, the amount of VFs that can be created on a PF varies = among + manufacturers.
        +
        + Suppose the NIC above was also SR-IOV capable, = it would + also include a nested + <capability> element enumerating all virtual + functions available on the physical device (physical port) like in t= he + example below. +

        + +
        +<capability type=3D'pci'>
        +...
        +  <capability type=3D'virt_functions' maxCount=3D'7'>
        +    <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x10' function=3D'0=
        x1'/>
        +    <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x10' function=3D'0=
        x3'/>
        +    <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x10' function=3D'0=
        x5'/>
        +    <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x10' function=3D'0=
        x7'/>
        +    <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x11' function=3D'0=
        x1'/>
        +    <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x11' function=3D'0=
        x3'/>
        +    <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x11' function=3D'0=
        x5'/>
        +  </capability>
        +...
        +</capability>
        +

        + A SR-IOV child device on the other hand, would then report its top l= evel + capability type as a physical function instead: +

        + +
        +<device>
        +...
        +  <capability type=3D'phys_function'>
        +    <address domain=3D'0x0000' bus=3D'0x04' slot=3D'0x00' function=3D'0=
        x0'/>
        +  </capability>
        +...
        +<device>
        + + + --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 04:53:56 2024 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.zoho.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 1490792448771817.5185770727862; Wed, 29 Mar 2017 06:00:48 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id CA1DD64DB9; Wed, 29 Mar 2017 13:00:46 +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 8E62B81C0A; Wed, 29 Mar 2017 13:00:46 +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 2D24E18523CB; Wed, 29 Mar 2017 13:00:46 +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 v2TCpidL010151 for ; Wed, 29 Mar 2017 08:51:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 65EB8962B7; Wed, 29 Mar 2017 12:51:44 +0000 (UTC) Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAF897E66B; Wed, 29 Mar 2017 12:51:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA1DD64DB9 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CA1DD64DB9 From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 14:51:21 +0200 Message-Id: <6d09fc1bc00b1bf78a5855f2d43e67f8b58cad5d.1490791809.git.eskultet@redhat.com> 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] [RFC PATCH 11/11] docs: Document the mediated devices within the nodedev driver 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 29 Mar 2017 13:00:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Erik Skultety --- docs/drvnodedev.html.in | 91 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 91 insertions(+) diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in index ed185c3df3..776c88cc87 100644 --- a/docs/drvnodedev.html.in +++ b/docs/drvnodedev.html.in @@ -180,5 +180,96 @@ ... <device> =20 +

        MDEV capability

        +

        + A PCI device capable of creating mediated devices will include a nes= ted + capability mdev which enumerates all the supported mdev types on the + physical device, along with the type attributes available through sy= sfs. + For a more info about mediated devices, refer to the + paragraph below. +

        + +
        +<device>
        +...
        +  <driver>
        +    <name>nvidia</name>
        +  </driver>
        +  <capability type=3D'pci'>
        +...
        +    <capability type=3D'mdev'>
        +      <type id=3D'nvidia-11'>
        +        <name>GRID M60-0B</name>
        +        <description>num_heads=3D2, frl_config=3D45, framebuffer=3D5=
        12M,
        +        max_resolution=3D2560x1600, max_instance=3D16</description>
        +        <device_api>vfio-pci</device_api>
        +        <available_instances>16</available_instances>
        +      </type>
        +      <!-- Here would come the rest of the available mdev types -->
        +    </capability>
        +...
        +  </capability>
        +</device>
        + +

        Mediated devices (MDEVs)

        +

        + Mediated devices (Since 3.2.0) are soft= ware + devices defining resource allocation on the backing physical device = which + in turn allows the parent physical device's resources to be divided = into + several mediated devices, thus sharing the physical device's perform= ance + among multiple guests. Unlike SR-IOV however, where a PCIe device ap= pears + as multiple separate PCIe devices on the host's PCI bus, mediated de= vices + only appear on the mdev virtual bus. Therefore, no detach/reattach + procedure from/to the host driver procedure is involved even though + mediated devices are used in a direct device assignment manner.
        +
        + At the moment, libvirt can only list the available mediated devices = on the + host and display all information libvirt can gather about them, see = the + examples below. Because mediated devices are instantiated from vendor + specific templates, simply called 'types', information about the res= ource + allocation for a specific type is contained within the backing physi= cal + parent device (see PCI host devices for an exam= ple). +

        + +

        Example of a mediated device

        +
        +<device>
        +  <name>mdev_4b20d080_1b54_4048_85b3_a6a62d165c01</name>
        +  <path>/sys/devices/pci0000:00/0000:00:02.0/4b20d080-1b54-4048-85b3=
        -a6a62d165c01</path>
        +  <parent>pci_0000_06_00_0</parent>
        +  <driver>
        +    <name>vfio_mdev</name>
        +  </driver>
        +  <capability type=3D'mdev'>
        +    <type id=3D'nvidia-11'/>
        +    <iommuGroup number=3D'12'/>
        +  <capability/>
        +<device/>
        + +

        + To see the supported mediated device types on a specific physical de= vice + use the following: +

        + +
        +$ ls /sys/class/mdev_bus/<device>/mdev_supported_types
        + +

        + To manually instantiate a mediated device, use one of the following = as a + reference: +

        + +
        +$ uuidgen > /sys/class/mdev_bus/<device>/mdev_supported_types/<=
        ;type>/create
        +...
        +$ echo <UUID> > /sys/class/mdev_bus/<device>/mdev_supported=
        _types/<type>/create
        + +

        + Manual removal of a mediated device is then performed as follows: +

        + +
        +$ echo 1 > /sys/bus/mdev/devices/<uuid>/remove
        + --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list