]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Hgfs Server: Clean up logging macros and enable Hgfs Server tools logging
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:29 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:29 +0000 (11:23 -0700)
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"

open-vm-tools/lib/hgfsServer/hgfsServer.c
open-vm-tools/lib/hgfsServer/hgfsServerInt.h
open-vm-tools/lib/hgfsServer/hgfsServerLinux.c
open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c
open-vm-tools/lib/hgfsServer/hgfsServerParameters.c
open-vm-tools/lib/hgfsServerPolicyGuest/hgfsServerPolicyGuest.c
open-vm-tools/lib/include/loglevel_user.h

index 409247cbbf5b08a5a264c02ebfe63f579a7f93bb..214fa42b9cb8e0c941c0ca3da03041f64cdfc4d3 100644 (file)
@@ -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.
     */
index dcac80536bc4aa819d406ecbfda623e24223c229..f7b61074ecb00003abf1f4a2657fc505091af96a 100644 (file)
@@ -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;
index bb080dc3752f18aeb7acc11c2cf027769f9d77ed..813720fd2236070fa899ecd2735b3fc7cb6292fb 100644 (file)
@@ -78,9 +78,6 @@
 #   include "config.h"
 #endif
 
-#define LOGLEVEL_MODULE hgfs
-#include "loglevel_user.h"
-
 #if defined(__APPLE__)
 #include <CoreServices/CoreServices.h> // for the alias manager
 #include <CoreFoundation/CoreFoundation.h> // for CFString and CFURL
index 9fa48fdec492128fce7b9c328d503d0ee8b0c1db..51a36eb38252f79864e8a0f0852451708d4ef1b2 100644 (file)
@@ -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,
index 3efd457f7059f9a71021dbb84e1edca085af879b..c5a442625ce6330009301549e69aac2809e75bc5 100644 (file)
@@ -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
index dc0b1ee5c0d9697ddd68b4ae07610bc8845f3235..2fe3fdd7b064a693067a3fbe75a829b24886a549 100644 (file)
 #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 {
index 2c8611545b805afc03df12e2b0469c5631b5d546..fc7ee664eb9f8f24d2e777ccba412175a183bce6 100644 (file)
    LOGLEVEL_VAR(backdoor), \
    LOGLEVEL_VAR(buslogicMdev), \
    LOGLEVEL_VAR(hgfs), \
+   LOGLEVEL_VAR(hgfsServer), \
    LOGLEVEL_VAR(memspace), \
    LOGLEVEL_VAR(dnd), \
    LOGLEVEL_VAR(appstate), \