util: reduce debug log in virPCIGetVirtualFunctions()

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.
This commit is contained in:
Laine Stump 2015-12-20 17:58:58 -05:00
parent 36e244f308
commit 3d64a9d783
2 changed files with 11 additions and 30 deletions

View File

@ -2370,12 +2370,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;
}
@ -2436,11 +2432,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;
}
@ -2465,14 +2458,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);
@ -2484,22 +2470,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;
@ -2521,9 +2505,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;
@ -2558,13 +2539,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);
@ -2749,7 +2730,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;

View File

@ -175,8 +175,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,