Due to debug logs like this:
virPCIGetDeviceAddressFromSysfsLink:2432 : Attempting to resolve device path from device
link '/sys/class/net/eth1/device/virtfn6'
logStrToLong_ui:2369 : Converted '0000:07:00.7' to unsigned int 0
logStrToLong_ui:2369 : Converted '07:00.7' to unsigned int 7
logStrToLong_ui:2369 : Converted '00.7' to unsigned int 0
logStrToLong_ui:2369 : Converted '7' to unsigned int 7
virPCIGetDeviceAddressFromSysfs:1947 : virPCIDeviceAddress 0000:07:00.7
virPCIGetVirtualFunctions:2554 : Found virtual function 7
printed *once for each SR-IOV Virtual Function* of a Physical Function
each time libvirt retrieved the list of VFs (so if the system has 128
VFs, there would be 900 lines of log for each call), the debug logs on
any system with a large number of VFs was dominated by "information"
that was possibly useful for debugging when the code was being
written, but is now useless for debugging of any problem on a running
system, and only serves to obscure the real useful information. This
overkill has no place in production code, so this patch removes it.
---
src/util/virpci.c | 37 +++++++++----------------------------
src/util/virpci.h | 4 ++--
2 files changed, 11 insertions(+), 30 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 6f0cb8c..d7d2b92 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2363,12 +2363,8 @@ logStrToLong_ui(char const *s,
int ret = 0;
ret = virStrToLong_ui(s, end_ptr, base, result);
- if (ret != 0) {
+ if (ret != 0)
VIR_ERROR(_("Failed to convert '%s' to unsigned int"), s);
- } else {
- VIR_DEBUG("Converted '%s' to unsigned int %u", s, *result);
- }
-
return ret;
}
@@ -2429,11 +2425,8 @@ virPCIGetDeviceAddressFromSysfsLink(const char *device_link,
char errbuf[64];
int ret = -1;
- VIR_DEBUG("Attempting to resolve device path from device link
'%s'",
- device_link);
-
if (!virFileExists(device_link)) {
- VIR_DEBUG("sysfs_path '%s' does not exist", device_link);
+ VIR_DEBUG("'%s' does not exist", device_link);
return ret;
}
@@ -2458,14 +2451,7 @@ virPCIGetDeviceAddressFromSysfsLink(const char *device_link,
goto out;
}
- VIR_DEBUG("virPCIDeviceAddress %.4x:%.2x:%.2x.%.1x",
- (*bdf)->domain,
- (*bdf)->bus,
- (*bdf)->slot,
- (*bdf)->function);
-
ret = 0;
-
out:
VIR_FREE(device_path);
@@ -2477,22 +2463,20 @@ virPCIGetDeviceAddressFromSysfsLink(const char *device_link,
*/
int
virPCIGetPhysicalFunction(const char *vf_sysfs_path,
- virPCIDeviceAddressPtr *physical_function)
+ virPCIDeviceAddressPtr *pf)
{
int ret = -1;
char *device_link = NULL;
- VIR_DEBUG("Attempting to get SR IOV physical function for device "
- "with sysfs path '%s'", vf_sysfs_path);
-
if (virBuildPath(&device_link, vf_sysfs_path, "physfn") == -1) {
virReportOOMError();
return ret;
- } else {
- ret = virPCIGetDeviceAddressFromSysfsLink(device_link,
- physical_function);
}
+ if ((ret = virPCIGetDeviceAddressFromSysfsLink(device_link, pf)) >= 0) {
+ VIR_DEBUG("PF for VF device '%s': %.4x:%.2x:%.2x.%.1x",
vf_sysfs_path,
+ (*pf)->domain, (*pf)->bus, (*pf)->slot, (*pf)->function);
+ }
VIR_FREE(device_link);
return ret;
@@ -2514,9 +2498,6 @@ virPCIGetVirtualFunctions(const char *sysfs_path,
virPCIDeviceAddress *config_addr = NULL;
char *totalvfs_file = NULL, *totalvfs_str = NULL;
- VIR_DEBUG("Attempting to get SR IOV virtual functions for device"
- "with sysfs path '%s'", sysfs_path);
-
*virtual_functions = NULL;
*num_virtual_functions = 0;
*max_virtual_functions = 0;
@@ -2551,13 +2532,13 @@ virPCIGetVirtualFunctions(const char *sysfs_path,
goto error;
}
- VIR_DEBUG("Found virtual function %zu", *num_virtual_functions);
if (VIR_APPEND_ELEMENT(*virtual_functions, *num_virtual_functions, config_addr)
< 0)
goto error;
VIR_FREE(device_link);
} while (1);
+ VIR_DEBUG("Found %zu virtual functions for %s", *num_virtual_functions,
sysfs_path);
ret = 0;
cleanup:
VIR_FREE(device_link);
@@ -2742,7 +2723,7 @@ static const char *unsupported = N_("not supported on non-linux
platforms");
int
virPCIGetPhysicalFunction(const char *vf_sysfs_path ATTRIBUTE_UNUSED,
- virPCIDeviceAddressPtr *physical_function ATTRIBUTE_UNUSED)
+ virPCIDeviceAddressPtr *pf ATTRIBUTE_UNUSED)
{
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
diff --git a/src/util/virpci.h b/src/util/virpci.h
index f3d5676..8930133 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -166,8 +166,8 @@ int virPCIDeviceIsAssignable(virPCIDevicePtr dev,
int strict_acs_check);
int virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher);
-int virPCIGetPhysicalFunction(const char *sysfs_path,
- virPCIDeviceAddressPtr *phys_fn);
+int virPCIGetPhysicalFunction(const char *vf_sysfs_path,
+ virPCIDeviceAddressPtr *pf);
int virPCIGetVirtualFunctions(const char *sysfs_path,
virPCIDeviceAddressPtr **virtual_functions,
--
2.5.0