From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:29 +0000 (-0700) Subject: Hgfs Server: Clean up logging macros and enable Hgfs Server tools logging X-Git-Tag: stable-10.2.0~306 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3393f1082b454052a37e33f241e6ceb20fcb29f2;p=thirdparty%2Fopen-vm-tools.git Hgfs Server: Clean up logging macros and enable Hgfs Server tools logging The HGFS server logging macros are scattered throughout and repeated in each source file. This makes it difficult to modify between the VMX implementation and the tools. The tools side suffers currently and is thus hard to debug. This is the first in a couple of small changes to clean up the logging. First the cleanup by moving the server logging statements for LOG to a centralized private header file for the server code and not repeated in every source file. Second, move the HgfsServer LOG from hgfs to its own HgfsServer setting. New VMX file setting is: Loglevel.hgfsServer = "10" The current existing setting of "hgfs" will capture logging for the VMX such as the HGFS manager, policy and transport interfaces (VMCI/Backdoor). Third, the HgfsServer LOG statements for the tools builds (which go into both instances of the vmtoolsd sevice/daemon) and the upgrader application are now mapped to g_debug and Debug function calls respectively. This now allows the tools configuration logging to set the following which will capture all the Hgfs server logging: hgfsServer.level = "debug" Follow up changes will be made to check the tools backdoor transport interface log setting which currently uses something like: hgfsd.level = "debug" --- diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index 409247cbb..214fa42b9 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -63,9 +63,6 @@ #endif // _WIN32 #define HGFS_PARENT_DIR_LEN 3 -#define LOGLEVEL_MODULE hgfs -#include "loglevel_user.h" - /* * Define this to enable an ASSERT on HGFS_STATUS_PROTOCOL_ERROR. @@ -201,6 +198,7 @@ static MXUserCondVar *gHgfsAsyncVar; static HgfsServerMgrCallbacks *gHgfsMgrData = NULL; + /* * Session usage and locking. * @@ -3934,6 +3932,7 @@ HgfsServer_ExitState(void) } HgfsPlatformDestroy(); + /* * Reset the server manager callbacks. */ diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h index dcac80536..f7b61074e 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h +++ b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h @@ -40,6 +40,57 @@ struct DirectoryEntry; #include "userlock.h" #include "hgfsServer.h" // for the server public types + +#ifndef VMX86_TOOLS + +#define LOGLEVEL_MODULE hgfsServer +#include "loglevel_user.h" + +#else // VMX86_TOOLS + +#undef DOLOG +#undef LOG + +/* + * Map all LOG statements to a Debug or g_debug tools log. + * Set the level to a default log level of 10 so that we will + * capture everything if tools logging is set to debug. + * + * Note, for future work would be to go through the log + * statements and set the levels correctly so that we can + * map to info, error and warnings. +*/ +#define LGLEVEL (10) +#define LGPFX_FMT "%s:%s:" +#define LGPFX "hgfsServer" + +#if defined VMTOOLS_USE_GLIB +#define Debug g_debug +#define Warning g_warning + +#define G_LOG_DOMAIN LGPFX + +#include "vmware/tools/utils.h" +#include "vmware/tools/log.h" + +#else // VMTOOLS_USE_GLIB + +#include "debug.h" + +#endif // VMTOOLS_USE_GLIB + +#define DOLOG(_min) ((_min) <= LGLEVEL) + +#define LOG(_level, args) \ + do { \ + if (DOLOG(_level)) { \ + Debug(LGPFX_FMT, LGPFX, __FUNCTION__); \ + Debug args; \ + } \ + } while (0) + +#endif // VNMX86_TOOLS + #define HGFS_DEBUG_ASYNC (0) typedef struct HgfsTransportSessionInfo HgfsTransportSessionInfo; diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c index bb080dc37..813720fd2 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c @@ -78,9 +78,6 @@ # include "config.h" #endif -#define LOGLEVEL_MODULE hgfs -#include "loglevel_user.h" - #if defined(__APPLE__) #include // for the alias manager #include // for CFString and CFURL diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c b/open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c index 9fa48fdec..51a36eb38 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c @@ -30,9 +30,6 @@ #include "hgfsServerInt.h" #include "util.h" -#define LOGLEVEL_MODULE hgfs -#include "loglevel_user.h" - static void *HSPUGetBuf(HgfsServerChannelCallbacks *chanCb, MappingType mappingType, HgfsVmxIov *iov, diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c index 3efd457f7..c5a442625 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c @@ -33,9 +33,6 @@ #include "vm_basic_asm.h" #include "hgfsServerParameters.h" -#define LOGLEVEL_MODULE hgfs -#include "loglevel_user.h" - #ifdef _WIN32 #define HGFS_REQUEST_WIN32_SUPPORTED HGFS_REQUEST_SUPPORTED #define HGFS_REQUEST_POSIX_SUPPORTED HGFS_REQUEST_NOT_SUPPORTED diff --git a/open-vm-tools/lib/hgfsServerPolicyGuest/hgfsServerPolicyGuest.c b/open-vm-tools/lib/hgfsServerPolicyGuest/hgfsServerPolicyGuest.c index dc0b1ee5c..2fe3fdd7b 100644 --- a/open-vm-tools/lib/hgfsServerPolicyGuest/hgfsServerPolicyGuest.c +++ b/open-vm-tools/lib/hgfsServerPolicyGuest/hgfsServerPolicyGuest.c @@ -33,8 +33,11 @@ #include "vmware.h" #include "hgfsServerPolicy.h" -#define LOGLEVEL_MODULE hgfs -#include "loglevel_user.h" +/* + * XXX: Transitioning over to the general tools logging mechanism. + */ +#undef LOG +#define LOG(level, args) typedef struct HgfsServerPolicyState { diff --git a/open-vm-tools/lib/include/loglevel_user.h b/open-vm-tools/lib/include/loglevel_user.h index 2c8611545..fc7ee664e 100644 --- a/open-vm-tools/lib/include/loglevel_user.h +++ b/open-vm-tools/lib/include/loglevel_user.h @@ -199,6 +199,7 @@ LOGLEVEL_VAR(backdoor), \ LOGLEVEL_VAR(buslogicMdev), \ LOGLEVEL_VAR(hgfs), \ + LOGLEVEL_VAR(hgfsServer), \ LOGLEVEL_VAR(memspace), \ LOGLEVEL_VAR(dnd), \ LOGLEVEL_VAR(appstate), \