From 0d210c47f94e91da09bb1a4acd7e651f8bc7601f Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Mon, 23 Nov 2015 14:50:31 -0500 Subject: [PATCH] conf: support reporting maxCount attribute for virtual_functions cap Report the maximum possible number of VFs for an SRIOV PF, like this: ... I've just discovered that the virtual_functions and physical_functions capabilities are not supported in the virNodeDeviceParse functions, only in virNodeDeviceFormat (I suppose because they are only reported, not set from XML). This should probably be remedied, but is less immediately useful than the current patch. --- docs/formatnode.html.in | 11 ++++++++++- src/conf/node_device_conf.c | 32 ++++++++++++++++++++------------ src/conf/node_device_conf.h | 1 + 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index ed00af59d4..6c12227b89 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -108,7 +108,16 @@ the type is virtual_functions, then this device is an SRIOV PF, and the capability element will have a list of address subelements, one - for each VF on this PF. + for each VF on this PF. If the host system supports + reporting it (via the "sriov_maxvfs" file in the + device's sysfs directory) the capability element will + also have an attribute named maxCount + which is the maximum number of SRIOV VFs supported by + this device, which could be higher than the number of + VFs that are curently active since + 1.3.0; in this case, even if there are + currently no active VFs the virtual_functions + capabililty will still be shown.
numa
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index e6f3f272e0..c04739f901 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -361,19 +361,27 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def) virBufferAddLit(&buf, "\n"); } if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) { - virBufferAddLit(&buf, "\n"); - virBufferAdjustIndent(&buf, 2); - for (i = 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); + virBufferAddLit(&buf, "pci_dev.max_virtual_functions) + virBufferAsprintf(&buf, " maxCount='%u'", + data->pci_dev.max_virtual_functions); + if (data->pci_dev.num_virtual_functions == 0) { + virBufferAddLit(&buf, "/>\n"); + } else { + virBufferAddLit(&buf, ">\n"); + virBufferAdjustIndent(&buf, 2); + for (i = 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"); } - virBufferAdjustIndent(&buf, -2); - virBufferAddLit(&buf, "\n"); } if (data->pci_dev.nIommuGroupDevices) { virBufferAsprintf(&buf, "\n", diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 7dd39ca963..d0071867cc 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -112,6 +112,7 @@ typedef struct _virNodeDevCapData { virPCIDeviceAddressPtr physical_function; virPCIDeviceAddressPtr *virtual_functions; size_t num_virtual_functions; + unsigned int max_virtual_functions; unsigned int flags; virPCIDeviceAddressPtr *iommuGroupDevices; size_t nIommuGroupDevices; -- GitLab