]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: reduce debug log in virPCIGetVirtualFunctions()
authorLaine Stump <laine@laine.org>
Sun, 20 Dec 2015 22:58:58 +0000 (17:58 -0500)
committerLaine Stump <laine@laine.org>
Mon, 4 Jan 2016 20:17:20 +0000 (15:17 -0500)
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
src/util/virpci.h

index 9eee783a4b87d594302efea44469bf168835c731..5ebd408700b3d6818cfe07be6bc6bf577a834c4a 100644 (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;
index 16067315d591e9aef9e450fc56044450ca104a1a..d1ac94271f39ced5d38f10eca33e62ed591e118c 100644 (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,