From nobody Sat Apr 27 14:32:25 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 1492693978252261.3667662165418; Thu, 20 Apr 2017 06:12:58 -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 13DB875ECC; Thu, 20 Apr 2017 13:12:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D568179582; Thu, 20 Apr 2017 13:12:55 +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 5D12C5EC63; Thu, 20 Apr 2017 13:12:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6Akb027875 for ; Thu, 20 Apr 2017 09:06:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 394E24DA37; Thu, 20 Apr 2017 13:06:10 +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 878FB17110; Thu, 20 Apr 2017 13:06:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13DB875ECC 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 13DB875ECC From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:51 +0200 Message-Id: <11fe4671b6c0423e4d60df867a838a4469dbc67e.1492692115.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 01/10] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 20 Apr 2017 13:12:57 +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 bcae444d8..591da8db2 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1043,50 +1043,35 @@ udevGetDeviceType(struct udev_device *device, 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 Sat Apr 27 14:32:25 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 1492694113196327.4176752422628; Thu, 20 Apr 2017 06:15:13 -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 B7BE981240; Thu, 20 Apr 2017 13:15:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DEEA2189F3; Thu, 20 Apr 2017 13:15:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 51EB65EC62; Thu, 20 Apr 2017 13:14:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6BNF027886 for ; Thu, 20 Apr 2017 09:06:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D55977E55; Thu, 20 Apr 2017 13:06:11 +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 8E2EB5C886; Thu, 20 Apr 2017 13:06:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B7BE981240 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 B7BE981240 From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:52 +0200 Message-Id: <4f047973cec6f1c3bb658152ca88d2168f2b3426.1492692115.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 02/10] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 20 Apr 2017 13:15:11 +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 d2ad6352b..85cfd8396 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 Sat Apr 27 14:32:25 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 1492694002547192.33283563412635; Thu, 20 Apr 2017 06:13:22 -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 92F5BC0010A2; Thu, 20 Apr 2017 13:13:20 +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 4082277E56; Thu, 20 Apr 2017 13:13:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BE72D18523CF; Thu, 20 Apr 2017 13:13:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6Cdt027891 for ; Thu, 20 Apr 2017 09:06:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 665A577E55; Thu, 20 Apr 2017 13:06:12 +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 AB5DA5C886; Thu, 20 Apr 2017 13:06:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 92F5BC0010A2 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 92F5BC0010A2 From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:53 +0200 Message-Id: <32547d0d26b3a0e6ed524f6c55a8156a3104d4e5.1492692115.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 03/10] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 20 Apr 2017 13:13:21 +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 591da8db2..6e706a10b 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -316,7 +316,6 @@ static int udevTranslatePCIIds(unsigned int vendor, 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; @@ -324,19 +323,17 @@ static int 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 @@ -363,8 +360,7 @@ static int 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 Sat Apr 27 14:32:25 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 1492694024587342.61370560461523; Thu, 20 Apr 2017 06:13:44 -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 9D0218FD15; Thu, 20 Apr 2017 13:13:42 +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 714CE8FF7F; Thu, 20 Apr 2017 13:13:42 +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 1EE2618523D2; Thu, 20 Apr 2017 13:13:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6Dtk027908 for ; Thu, 20 Apr 2017 09:06:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id C73D14DA37; Thu, 20 Apr 2017 13:06:13 +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 277485C886; Thu, 20 Apr 2017 13:06:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9D0218FD15 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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 9D0218FD15 From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 04/10] docs: Utilize our XSLT list generating template more 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.26]); Thu, 20 Apr 2017 13:13:43 +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 (list of supported pool types and remote access section). Also, perform some stylistic micro adjustments. Signed-off-by: Erik Skultety --- docs/remote.html.in | 106 +++++++++++++++--------------------------------= ---- docs/storage.html.in | 62 ++++++------------------------ 2 files changed, 41 insertions(+), 127 deletions(-) diff --git a/docs/remote.html.in b/docs/remote.html.in index 443683d51..117ee3477 100644 --- a/docs/remote.html.in +++ b/docs/remote.html.in @@ -7,57 +7,11 @@ Libvirt allows you to access hypervisors running on remote machines through authenticated and encrypted connections.

- -

+
    + +

    Basic usage -

    +

    On the remote machine, libvirtd should be running in general. See the section @@ -95,9 +49,9 @@ relating to failures in the remote transport itself.

  • Remote calls are handled synchronously, so they will be much slower than, say, direct hypervisor calls.
  • -

    +

    Transports -

    +

    Remote libvirt supports a range of transports:

    @@ -156,9 +110,9 @@ netcat is required on the remote side.

    The default transport, if no other is specified, is tls.

    -

    +

    Remote URIs -

    +

    See also: documentation on ordinary ("local") URIs.

    @@ -203,9 +157,9 @@ and use a different known_hosts file. Connect to a remote host using a ssh connection with the libssh driver and use a different known_hosts file. -

    +

    Extra parameters -

    +

    Extra parameters can be added to remote URIs as part of the query string (the part following ?). @@ -409,12 +363,12 @@ Note that parameter values must be Example: sshauth=3Dprivkey,agent -

    +

    Generating TLS certificates -

    -

    +

    +

    Public Key Infrastructure set up -

    +

    If you are unsure how to create TLS certificates, skip to the next section. @@ -517,9 +471,9 @@ next section.

  • For the root user, the global default locations will always be = used.
  • -

    +

    Background to TLS certificates -

    +

    Libvirt supports TLS certificates for verifying the identity of the server and clients. There are two distinct checks involved: @@ -552,9 +506,9 @@ they have a valid certificate issued by the CA for thei= r own IP address. You may want to change this to make it less (or more) permissive, depending on your needs.

    -

    +

    Setting up a Certificate Authority (CA) -

    +

    You will need the GnuTLS certtool program documented here. In Fedora, it is in the @@ -623,9 +577,9 @@ This is all that is required to set up your CA. Keep t= he CA's private key carefully as you will need it when you come to issue certificates for your clients and servers.

    -

    +

    Issuing server certificat= es -

    +

    For each server (libvirtd) you need to issue a certificate with the X.509 CommonName (CN) field set to the hostname @@ -706,9 +660,9 @@ which can be installed on the server as /etc/pki/libvirt/servercert.pem. -

    +

    Issuing client certificat= es -

    +

    For each client (ie. any program linked with libvirt, such as virt-manager) @@ -759,9 +713,9 @@ cp clientcert.pem /etc/pki/libvirt/clientcert.pem -

    +

    Troubleshooting TLS certifica= te problems -

    +
    failed to verify client's certificate
    @@ -777,9 +731,9 @@ tell you enough to diagnose the problem. to analyze the setup on the client or server machines, preferably as root. It will try to point out the possible problems and provide solutions to fix the set up up to a point where you have secure remote access.

    -

    +

    libvirtd configuration fil= e -

    +

    Libvirtd (the remote daemon) is configured from a file called /etc/libvirt/libvirtd.conf, or specified on @@ -945,9 +899,9 @@ Blank lines and comments beginning with # = are ignored. -

    +

    IPv6 support -

    +

    The libvirtd service and libvirt remote client driver both use the getaddrinfo() functions for name resolution and are @@ -958,9 +912,9 @@ address resolved for a service is reachable over IPv6, = then an IPv6 connection will be made, otherwise IPv4 will be used. In summary it should just 'do the right thing(tm)'.

    -

    +

    Limitations -

    + =20 =20 -

    iSCSI volume pools

    +

    iSCSI 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 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 Sat Apr 27 14:32:25 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 1492694048485823.1941998435198; Thu, 20 Apr 2017 06:14:08 -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 8B0E4C05B1CB; Thu, 20 Apr 2017 13:14:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 680447FB72; Thu, 20 Apr 2017 13:14:05 +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 5F3665EC63; Thu, 20 Apr 2017 13:13:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6E9H027916 for ; Thu, 20 Apr 2017 09:06:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id E83A477E55; Thu, 20 Apr 2017 13:06:14 +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 1D26F4DA37; Thu, 20 Apr 2017 13:06:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B0E4C05B1CB 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 8B0E4C05B1CB From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:55 +0200 Message-Id: <6ba125a955916b259b24554e9bd13394ed083666.1492692115.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 05/10] nodedev: conf: Split PCI sub-capability parsing to a separate method 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.32]); Thu, 20 Apr 2017 13:14:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since there's at least SRIOV and MDEV sub-capabilities to be parsed, let's make the code more readable by splitting it to several logical blocks. Signed-off-by: Erik Skultety --- src/conf/node_device_conf.c | 84 ++++++++++++++++++++++++++++-------------= ---- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 85cfd8396..de346597a 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1286,76 +1286,100 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, =20 =20 static int -virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, - xmlNodePtr node, - virNodeDevCapPCIDevPtr pci_dev) +virNodeDevPCICapSRIOVParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virNodeDevCapPCIDevPtr pci_dev, + unsigned int cap) { + int ret =3D -1; char *maxFuncsStr =3D virXMLPropString(node, "maxCount"); - char *type =3D virXMLPropString(node, "type"); xmlNodePtr *addresses =3D NULL; - xmlNodePtr orignode =3D ctxt->node; - int ret =3D -1; - size_t i =3D 0; =20 - ctxt->node =3D node; - - if (!type) { - virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing capability type= ")); - goto out; - } - - if (STREQ(type, "phys_function")) { + if (cap =3D=3D VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION) { xmlNodePtr address =3D virXPathNode("./address[1]", ctxt); =20 if (VIR_ALLOC(pci_dev->physical_function) < 0) - goto out; + goto cleanup; =20 if (!address) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing address in 'phys_function' capabilit= y")); - goto out; + goto cleanup; } =20 if (virPCIDeviceAddressParseXML(address, pci_dev->physical_function) < 0) - goto out; - - pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; - } else if (STREQ(type, "virt_functions")) { + goto cleanup; + } else { + size_t i; int naddresses; =20 if ((naddresses =3D virXPathNodeSet("./address", ctxt, &addresses)= ) < 0) - goto out; + goto cleanup; =20 if (maxFuncsStr && virStrToLong_uip(maxFuncsStr, NULL, 10, &pci_dev->max_virtual_functions) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Malformed 'maxCount' parameter")); - goto out; + goto cleanup; } =20 if (VIR_ALLOC_N(pci_dev->virtual_functions, naddresses) < 0) - goto out; + goto cleanup; =20 for (i =3D 0; i < naddresses; i++) { virPCIDeviceAddressPtr addr =3D NULL; =20 if (VIR_ALLOC(addr) < 0) - goto out; + goto cleanup; =20 if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) { VIR_FREE(addr); - goto out; + goto cleanup; } =20 if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions, pci_dev->num_virtual_functions, addr) < 0) - goto out; + goto cleanup; } + } =20 - pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; + pci_dev->flags |=3D cap; + ret =3D 0; + cleanup: + VIR_FREE(addresses); + VIR_FREE(maxFuncsStr); + return ret; +} + + +static int +virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virNodeDevCapPCIDevPtr pci_dev) +{ + char *type =3D virXMLPropString(node, "type"); + xmlNodePtr orignode =3D ctxt->node; + unsigned int sriov_cap =3D 0; + int ret =3D -1; + + ctxt->node =3D node; + + if (!type) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing capability type= ")); + goto cleanup; + } + + if (STREQ(type, "phys_function")) + sriov_cap =3D VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; + else if (STREQ(type, "virt_functions")) + sriov_cap =3D VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; + + if (sriov_cap && + virNodeDevPCICapSRIOVParseXML(ctxt, node, pci_dev, sriov_cap) < 0)= { + goto cleanup; } else { int hdrType =3D virPCIHeaderTypeFromString(type); =20 @@ -1364,9 +1388,7 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ct= xt, } =20 ret =3D 0; - out: - VIR_FREE(addresses); - VIR_FREE(maxFuncsStr); + cleanup: VIR_FREE(type); ctxt->node =3D orignode; return ret; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 14:32:25 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 1492694134884611.8601814790777; Thu, 20 Apr 2017 06:15:34 -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 BC35D9C0B9; Thu, 20 Apr 2017 13:15:32 +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 90B987F6D2; Thu, 20 Apr 2017 13:15:32 +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 2FBF618523CE; Thu, 20 Apr 2017 13:15:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6GYe027924 for ; Thu, 20 Apr 2017 09:06:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0AE214DA37; Thu, 20 Apr 2017 13:06:16 +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 3FF745C886; Thu, 20 Apr 2017 13:06:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC35D9C0B9 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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 BC35D9C0B9 From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:56 +0200 Message-Id: <9b7b7c5d66a0a95443d6299821ed657d96414303.1492692116.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 06/10] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 20 Apr 2017 13:15:33 +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 and its 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 | 6 +++++- src/conf/node_device_conf.h | 4 +++- src/conf/virnodedeviceobj.c | 3 ++- src/libvirt-nodedev.c | 1 + src/node_device/node_device_driver.c | 1 + src/node_device/node_device_udev.c | 8 +++++++- tools/virsh-nodedev.c | 2 ++ 8 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-no= dedev.h index 85003903d..59edf4db0 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 de346597a..fdddc97eb 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; } @@ -1613,6 +1615,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'"), @@ -1928,6 +1931,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: diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index a5d5cdd2a..375f97256 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; @@ -351,7 +352,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 4f47b4e41..442914b27 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -550,7 +550,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 83376b0d9..f9d8edf7e 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/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index c3997c922..fa1993e43 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -82,6 +82,7 @@ static int 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 6e706a10b..95c1aee29 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 @@ -1016,12 +1017,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, therefore 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 @@ -1060,6 +1065,7 @@ static int udevGetDeviceDetails(struct udev_device *d= evice, 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 c69144021..19dcfafa6 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 Sat Apr 27 14:32:25 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 1492693765664534.4749422474011; Thu, 20 Apr 2017 06:09:25 -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 8DFEF75EAE; Thu, 20 Apr 2017 13:09:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AA5417110; Thu, 20 Apr 2017 13:09: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 D66B25EC62; Thu, 20 Apr 2017 13:09:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6H77027936 for ; Thu, 20 Apr 2017 09:06:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0108E4DA37; Thu, 20 Apr 2017 13:06:17 +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 569365C886; Thu, 20 Apr 2017 13:06:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8DFEF75EAE 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 8DFEF75EAE From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:57 +0200 Message-Id: <1c35dd502560708964c2b49a649262ba59761bbf.1492692116.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 07/10] nodedev: Introduce the mdev capability to a 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 20 Apr 2017 13:09:24 +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, type name, etc. Therefore this patch 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 --- docs/schemas/nodedev.rng | 24 ++++ src/conf/node_device_conf.c | 103 +++++++++++++++++ src/conf/node_device_conf.h | 17 +++ src/libvirt_private.syms | 1 + src/node_device/node_device_udev.c | 133 ++++++++++++++++++= ++++ tests/nodedevschemadata/pci_0000_02_10_7_mdev.xml | 27 +++++ 6 files changed, 305 insertions(+) create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_mdev.xml diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 0f90a73c8..4b5dca777 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -205,6 +205,30 @@ =20 + + + mdev + + + + + + + + + + + vfio-pci + + + + + + + + + + diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index fdddc97eb..fe4f1bc60 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -87,6 +87,26 @@ virNodeDevCapsDefParseString(const char *xpath, } =20 =20 +static void +virNodeDevCapMdevClear(virNodeDevCapMdevPtr mdev) +{ + VIR_FREE(mdev->type); + VIR_FREE(mdev->name); + VIR_FREE(mdev->device_api); +} + + +void +virNodeDevCapMdevFree(virNodeDevCapMdevPtr mdev) +{ + if (!mdev) + return; + + virNodeDevCapMdevClear(mdev); + VIR_FREE(mdev); +} + + void virNodeDeviceDefFree(virNodeDeviceDefPtr def) { @@ -264,6 +284,27 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "\n", virPCIHeaderTypeToString(data->pci_dev.hdrType)); } + if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) { + 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); + 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); @@ -1358,6 +1399,62 @@ virNodeDevPCICapSRIOVParseXML(xmlXPathContextPtr ctx= t, =20 =20 static int +virNodeDevPCICapMediatedDevParseXML(xmlXPathContextPtr ctxt, + virNodeDevCapPCIDevPtr pci_dev) +{ + int ret =3D -1; + xmlNodePtr orignode =3D NULL; + xmlNodePtr *nodes =3D NULL; + int nmdevs =3D virXPathNodeSet("./type", ctxt, &nodes); + virNodeDevCapMdevPtr mdev =3D NULL; + size_t i; + + orignode =3D ctxt->node; + for (i =3D 0; i < nmdevs; i++) { + ctxt->node =3D nodes[i]; + + if (VIR_ALLOC(mdev) < 0) + goto cleanup; + + if (!(mdev->type =3D virXPathString("string(./@id[1])", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing 'id' attribute for mediated device's= " + " element")); + goto cleanup; + } + + if (!(mdev->device_api =3D virXPathString("string(./deviceAPI[1])"= , ctxt))) { + virReportError(VIR_ERR_XML_ERROR, + _("missing device API for mediated device type = '%s'"), + mdev->type); + goto cleanup; + } + + if (virXPathUInt("number(./availableInstances)", ctxt, + &mdev->available_instances) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("missing number of available instances for " + "mediated device type '%s'"), + mdev->type); + goto cleanup; + } + + mdev->name =3D virXPathString("string(./name)", ctxt); + + if (VIR_APPEND_ELEMENT(pci_dev->mdevs, pci_dev->nmdevs, mdev) < 0) + goto cleanup; + } + + pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; + ret =3D 0; + cleanup: + virNodeDevCapMdevFree(mdev); + ctxt->node =3D orignode; + return ret; +} + + +static int virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapPCIDevPtr pci_dev) @@ -1382,6 +1479,9 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ct= xt, if (sriov_cap && virNodeDevPCICapSRIOVParseXML(ctxt, node, pci_dev, sriov_cap) < 0)= { goto cleanup; + } if (STREQ(type, "mdev") && + virNodeDevPCICapMediatedDevParseXML(ctxt, pci_dev)) { + goto cleanup; } else { int hdrType =3D virPCIHeaderTypeFromString(type); =20 @@ -1894,6 +1994,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) VIR_FREE(data->pci_dev.iommuGroupDevices[i]); VIR_FREE(data->pci_dev.iommuGroupDevices); virPCIEDeviceInfoFree(data->pci_dev.pci_express); + for (i =3D 0; i < data->pci_dev.nmdevs; i++) + virNodeDevCapMdevFree(data->pci_dev.mdevs[i]); + VIR_FREE(data->pci_dev.mdevs); break; case VIR_NODE_DEV_CAP_USB_DEV: VIR_FREE(data->usb_dev.product_name); diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 375f97256..883fa017e 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -94,6 +94,7 @@ typedef enum { VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION =3D (1 << 0), VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION =3D (1 << 1), VIR_NODE_DEV_CAP_FLAG_PCIE =3D (1 << 2), + VIR_NODE_DEV_CAP_FLAG_PCI_MDEV =3D (1 << 3), } virNodeDevPCICapFlags; =20 typedef enum { @@ -132,6 +133,16 @@ struct _virNodeDevCapSystem { virNodeDevCapSystemFirmware firmware; }; =20 +typedef struct _virNodeDevCapMdev virNodeDevCapMdev; +typedef virNodeDevCapMdev *virNodeDevCapMdevPtr; +struct _virNodeDevCapMdev { + char *type; + char *name; + char *device_api; + unsigned int available_instances; + unsigned int iommuGroupNumber; +}; + typedef struct _virNodeDevCapPCIDev virNodeDevCapPCIDev; typedef virNodeDevCapPCIDev *virNodeDevCapPCIDevPtr; struct _virNodeDevCapPCIDev { @@ -155,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; @@ -263,6 +276,7 @@ struct _virNodeDevCapData { virNodeDevCapStorage storage; virNodeDevCapSCSIGeneric sg; virNodeDevCapDRM drm; + virNodeDevCapMdev mdev; }; }; =20 @@ -339,6 +353,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 | \ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 181e17875..d1e872e60 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -665,6 +665,7 @@ virNetDevIPRouteParseXML; =20 =20 # conf/node_device_conf.h +virNodeDevCapMdevFree; virNodeDevCapsDefFree; virNodeDevCapTypeFromString; virNodeDevCapTypeToString; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 95c1aee29..79f1537d9 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -314,6 +314,133 @@ static int udevTranslatePCIIds(unsigned int vendor, } =20 =20 +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; + +#define MDEV_GET_SYSFS_ATTR(attr_name, dir, cb, ...) = \ + do { = \ + if (virAsprintf(&attrpath, "%s/%s", dir, #attr_name) < 0) = \ + goto cleanup; = \ + = \ + if (cb(device, attrpath, __VA_ARGS__) < 0) = \ + goto cleanup; = \ + = \ + VIR_FREE(attrpath); = \ + } while (0) = \ + + /* UDEV doesn't report attributes under subdirectories by default but = is + * able to query them if the path to the attribute is relative to 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); + + /* 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, relpath, + udevGetStringSysfsAttr, &mdev->name); + MDEV_GET_SYSFS_ATTR(device_api, relpath, + udevGetStringSysfsAttr, &mdev->device_api); + MDEV_GET_SYSFS_ATTR(available_instances, relpath, + udevGetUintSysfsAttr, &mdev->available_instances, = 10); + +#undef MDEV_GET_SYSFS_ATTR + + ret =3D 0; + cleanup: + VIR_FREE(attrpath); + VIR_FREE(tmp); + return ret; +} + + +static int +udevPCIGetMdevCaps(struct udev_device *device, + virNodeDevCapPCIDevPtr pcidata) +{ + int ret =3D -1; + int direrr =3D -1; + DIR *dir =3D NULL; + struct dirent *entry; + char *path =3D NULL; + char *tmppath =3D NULL; + virNodeDevCapMdevPtr mdev =3D NULL; + virNodeDevCapMdevPtr *mdevs =3D NULL; + size_t nmdevs =3D 0; + size_t i; + + if (virAsprintf(&path, "%s/mdev_supported_types", + udev_device_get_syspath(device)) < 0) + return -1; + + if ((direrr =3D virDirOpenIfExists(&dir, path)) < 0) + goto cleanup; + + if (direrr =3D=3D 0) { + ret =3D 0; + goto cleanup; + } + + if (VIR_ALLOC(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 ((direrr =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(mdevs, nmdevs, mdev) < 0) + goto cleanup; + + VIR_FREE(tmppath); + } + + if (direrr < 0) + goto cleanup; + + VIR_STEAL_PTR(pcidata->mdevs, mdevs); + pcidata->nmdevs =3D nmdevs; + nmdevs =3D 0; + ret =3D 0; + cleanup: + virNodeDevCapMdevFree(mdev); + for (i =3D 0; i < nmdevs; i++) + virNodeDevCapMdevFree(mdevs[i]); + VIR_FREE(mdevs); + VIR_FREE(path); + VIR_FREE(tmppath); + VIR_DIR_CLOSE(dir); + return ret; +} + + static int udevProcessPCI(struct udev_device *device, virNodeDeviceDefPtr def) { @@ -400,6 +527,12 @@ static int 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: diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_mdev.xml b/tests/node= devschemadata/pci_0000_02_10_7_mdev.xml new file mode 100644 index 000000000..b745686d3 --- /dev/null +++ b/tests/nodedevschemadata/pci_0000_02_10_7_mdev.xml @@ -0,0 +1,27 @@ + + pci_0000_02_10_7 + pci_0000_00_04_0 + + 0 + 2 + 16 + 7 + 82576 Virtual Function + Intel Corporation + + + bar + vfio-pci + 1 + + + +

    + + + + + + + + --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 14:32:25 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 1492694071292357.07451896456655; Thu, 20 Apr 2017 06:14:31 -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 7BD7961D28; Thu, 20 Apr 2017 13:14:29 +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 4E9428FF8B; Thu, 20 Apr 2017 13:14:29 +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 EA07918523D1; Thu, 20 Apr 2017 13:14:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6It0027942 for ; Thu, 20 Apr 2017 09:06:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 100A417110; Thu, 20 Apr 2017 13:06:18 +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 676484DA37; Thu, 20 Apr 2017 13:06:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7BD7961D28 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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 7BD7961D28 From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:58 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 08/10] nodedev: Introduce mdev capability for child devices 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.39]); Thu, 20 Apr 2017 13:14:30 +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. This patch introduces both the formatting and parsing routines, updates nodedev.rng schema, adding a testcase for mdev child device as well. 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 --- docs/schemas/nodedev.rng | 17 ++++++++ src/conf/node_device_conf.c | 43 ++++++++++++++++++= +- src/node_device/node_device_udev.c | 46 ++++++++++++++++++= ++++ .../mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 8 ++++ tests/nodedevxml2xmltest.c | 1 + 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1= da537d301b.xml diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 4b5dca777..8466d504d 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -83,6 +83,7 @@ + @@ -578,6 +579,22 @@ =20 + + + mdev + + + + + + + + + + + + + diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index fe4f1bc60..757e4bed7 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -582,9 +582,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; } @@ -1645,6 +1649,39 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, } =20 =20 +static int +virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapMdevPtr mdev) +{ + xmlNodePtr orignode; + int ret =3D -1; + + orignode =3D ctxt->node; + ctxt->node =3D node; + + if (!(mdev->type =3D virXPathString("string(./type[1]/@id)", ctxt))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("missing type id attribute for '%s'"), def->name); + goto out; + } + + if (virNodeDevCapsDefParseULong("number(./iommuGroup[1]/@number)", ctx= t, + &mdev->iommuGroupNumber, def, + _("missing iommuGroup number atribute = for " + "'%s'"), + _("invalid iommuGroup number attribute= for " + "'%s'")) < 0) + goto out; + + ret =3D 0; + out: + ctxt->node =3D orignode; + return ret; +} + + static virNodeDevCapsDefPtr virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, virNodeDeviceDefPtr def, @@ -1716,6 +1753,8 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_SCSI_GENERIC: case VIR_NODE_DEV_CAP_MDEV: + ret =3D virNodeDevCapMdevParseXML(ctxt, def, node, &caps->data.mde= v); + break; case VIR_NODE_DEV_CAP_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown capability type '%d' for '%s'"), @@ -2035,6 +2074,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) VIR_FREE(data->sg.path); break; case VIR_NODE_DEV_CAP_MDEV: + virNodeDevCapMdevClear(&data->mdev); + break; case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 79f1537d9..a04009110 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1083,6 +1083,51 @@ udevProcessSCSIGeneric(struct udev_device *dev, } =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) { @@ -1199,6 +1244,7 @@ static int udevGetDeviceDetails(struct udev_device *d= evice, 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: diff --git a/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d3= 01b.xml b/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b= .xml new file mode 100644 index 000000000..470e5917e --- /dev/null +++ b/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml @@ -0,0 +1,8 @@ + + mdev_3627463d_b7f0_4fea_b468_f1da537d301b + computer + + + + + diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index f023d8a13..88c75ea78 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -101,6 +101,7 @@ mymain(void) DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all"); DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type"); DO_TEST("drm_renderD129"); + DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b"); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 14:32:25 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 1492694157562109.63357310051231; Thu, 20 Apr 2017 06:15:57 -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 A0FB889C33; Thu, 20 Apr 2017 13:15:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 594F379580; Thu, 20 Apr 2017 13:15:55 +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 0986B4BB74; Thu, 20 Apr 2017 13:15:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6JZS027949 for ; Thu, 20 Apr 2017 09:06:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0594F4DA37; Thu, 20 Apr 2017 13:06:19 +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 5BED45C886; Thu, 20 Apr 2017 13:06:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A0FB889C33 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 A0FB889C33 From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:05:59 +0200 Message-Id: <567d9d1fd0d3468235f873d832168d335d912d6c.1492692116.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 09/10] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Apr 2017 13:15:56 +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 be7483b9b..61993861e 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 000000000..ed185c3df --- /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 Sat Apr 27 14:32:25 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 1492693786642318.8918814515871; Thu, 20 Apr 2017 06:09:46 -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 A41F8B0805; Thu, 20 Apr 2017 13:09:44 +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 723D77F6B7; Thu, 20 Apr 2017 13:09:44 +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 0FE7F18523CF; Thu, 20 Apr 2017 13:09:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3KD6JfW027961 for ; Thu, 20 Apr 2017 09:06:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id EE65617110; Thu, 20 Apr 2017 13:06:19 +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 50DE44DA37; Thu, 20 Apr 2017 13:06:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A41F8B0805 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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 A41F8B0805 From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 20 Apr 2017 15:06:00 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 10/10] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 20 Apr 2017 13:09:45 +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 | 164 ++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 162 insertions(+), 2 deletions(-) diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in index ed185c3df..6dece3806 100644 --- a/docs/drvnodedev.html.in +++ b/docs/drvnodedev.html.in @@ -71,7 +71,7 @@ storage (Since 1.0.4), scsi_generic (Since 1.0.7), drm (Since 3.1.0), and - mdev (Since 3.2.0). + mdev (Since 3.3.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. @@ -168,7 +168,7 @@ </capability>

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

        =20
        @@ -180,5 +180,165 @@
         ...
         <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: +

        + +
        +
        type
        +
        + This element describes a mediated device type which acts as an + abstract template defining a resource allocation for instances of = this + device type. The element has one attribute id which h= olds + an official vendor-supplied identifier for the type. + Since 3.3.0 +
        + +
        name
        +
        + The name element holds a vendor-supplied code name for + the given mediated device type. This is an optional element. + Since 3.3.0 +
        + +
        deviceAPI
        +
        + The value of this element describes how an instance of the given t= ype + will be presented to the guest by the VFIO framework. + Since 3.3.0 +
        + +
        availableInstances
        +
        + This element reports the current state of resource allocation. In = other + words, how many instances of the given type can still be successfu= lly + created on the physical device. + Since 3.3.0 +
        +
        + +

        + 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>
        +        <deviceAPI>vfio-pci</deviceAPI>
        +        <availableInstances>16</availableInstances>
        +      </type>
        +      <!-- Here would come the rest of the available mdev types -->
        +    </capability>
        +...
        +  </capability>
        +</device>
        + +

        Mediated devices (MDEVs)

        +

        + Mediated devices (Since 3.3.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.
        + + The following sub-elements and attributes are exposed within the + capability element: +

        + +
        +
        type
        +
        + This element describes a mediated device type which acts as an + abstract template defining a resource allocation for instances of = this + device type. The element has one attribute id which h= olds + an official vendor-supplied identifier for the type. + Since 3.3.0 +
        + +
        iommuGroup
        +
        + This element supports a single attribute number which= holds + the IOMMU group number the mediated device belongs to. + Since 3.3.0 +
        +
        + +

        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/>
        + +

        + The support of mediated device's framework in libvirt's node device = driver + covers the following features: +

        + +
          +
        • + list available mediated devices on the host + (Since 3.3.0) +
        • +
        • + display device details + (Since 3.3.0) +
        • +
        + +

        + Because mediated devices are instantiated from vendor specific templ= ates, + simply called 'types', information describing these types is contain= ed + within the parent device's capabilities + (see the example in PCI host devices).

        + + 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