summaryrefslogtreecommitdiff
path: root/open-vm-tools
diff options
context:
space:
mode:
authorVMware, Inc <>2013-09-17 20:32:52 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-09-22 22:19:59 -0700
commitedffc5fad3c601e1ee3e391532fbc623f8b19519 (patch)
tree3e62dfcd365bd87c5eacea229171ff144fdfcdc2 /open-vm-tools
parente55039cb8452777c2024ce3a13cd3439f36fd554 (diff)
Change GuestLIB SDK to use new RpcChannel API.
Change GuestLIB SDK to use new RpcChannel API. 1) Change RpcOut_* calls to RpcChanneel_* calls. 2) guestlib SDK now has extra dependency on GLIB and vmtoolslib as secure guestRPC brings a lot new dependencies (rpcin, asyncsocket, ssl, datamap, hashmap etc). 3) ship new glib and vmtoolslib for linux and windows packages. 4) merge logging functions (Debug(), Warning()) in vmtools and guestlib into one to avoid having same function names defined in two libs. 5) update build in open vm tools. 6) app monitor needs to do similar thing, which will be handled by HA team. Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
Diffstat (limited to 'open-vm-tools')
-rw-r--r--open-vm-tools/lib/include/vmware/tools/utils.h3
-rw-r--r--open-vm-tools/libguestlib/Makefile.am4
-rw-r--r--open-vm-tools/libguestlib/vmGuestLib.c9
-rw-r--r--open-vm-tools/libvmtools/Makefile.am1
-rw-r--r--open-vm-tools/libvmtools/guestSDKLog.c149
-rw-r--r--open-vm-tools/libvmtools/vmtoolsInt.h12
-rw-r--r--open-vm-tools/libvmtools/vmtoolsLog.c80
7 files changed, 230 insertions, 28 deletions
diff --git a/open-vm-tools/lib/include/vmware/tools/utils.h b/open-vm-tools/lib/include/vmware/tools/utils.h
index 13a5e3d8..6e1931d2 100644
--- a/open-vm-tools/lib/include/vmware/tools/utils.h
+++ b/open-vm-tools/lib/include/vmware/tools/utils.h
@@ -139,6 +139,9 @@ VMTools_GetLibdir(void);
GSource *
VMTools_CreateTimer(gint timeout);
+void
+VMTools_SetGuestSDKMode(void);
+
GArray *
VMTools_WrapArray(gconstpointer data,
guint elemSize,
diff --git a/open-vm-tools/libguestlib/Makefile.am b/open-vm-tools/libguestlib/Makefile.am
index 0ebe8c6e..0d24743a 100644
--- a/open-vm-tools/libguestlib/Makefile.am
+++ b/open-vm-tools/libguestlib/Makefile.am
@@ -52,6 +52,10 @@ CLEANFILES += $(BUILT_SOURCES)
CFLAGS += -Wno-unused
+libguestlib_la_CPPFLAGS =
+libguestlib_la_CPPFLAGS += -DVMTOOLS_USE_GLIB
+libguestlib_la_CPPFLAGS += @GLIB2_CPPFLAGS@
+
EXTRA_DIST = vmguestlib.pc.in
pkgconfigdir = $(libdir)/pkgconfig
diff --git a/open-vm-tools/libguestlib/vmGuestLib.c b/open-vm-tools/libguestlib/vmGuestLib.c
index 29c7161c..4328ea73 100644
--- a/open-vm-tools/libguestlib/vmGuestLib.c
+++ b/open-vm-tools/libguestlib/vmGuestLib.c
@@ -27,7 +27,7 @@
#include "vmGuestLib.h"
#include "vmGuestLibInt.h"
#include "str.h"
-#include "rpcout.h"
+#include "vmware/tools/guestrpc.h"
#include "vmcheck.h"
#include "util.h"
#include "debug.h"
@@ -259,6 +259,8 @@ VMGuestLib_OpenHandle(VMGuestLibHandle *handle) // OUT
{
VMGuestLibHandleType *data;
+ VMTools_SetGuestSDKMode();
+
if (!VmCheck_IsVirtualWorld()) {
Debug("VMGuestLib_OpenHandle: Not in a VM.\n");
return VMGUESTLIB_ERROR_NOT_RUNNING_IN_VM;
@@ -379,7 +381,7 @@ VMGuestLibUpdateInfo(VMGuestLibHandle handle) // IN
hostVersion);
/* Send the request. */
- if (RpcOut_sendOne(&reply, &replyLen, commandBuf)) {
+ if (RpcChannel_SendOne(&reply, &replyLen, commandBuf)) {
VMGuestLibDataV2 *v2reply = (VMGuestLibDataV2 *)reply;
VMSessionId sessionId = HANDLE_SESSIONID(handle);
@@ -1798,7 +1800,8 @@ VMGuestLibIoctl(const GuestLibIoctlParam *param,
DynXdr_Destroy(&xdrs, TRUE);
return FALSE;
}
- ret = RpcOut_SendOneRaw(DynXdr_Get(&xdrs), xdr_getpos(&xdrs), reply, replySize);
+ ret = RpcChannel_SendOneRaw(DynXdr_Get(&xdrs), xdr_getpos(&xdrs),
+ reply, replySize);
DynXdr_Destroy(&xdrs, TRUE);
return ret;
}
diff --git a/open-vm-tools/libvmtools/Makefile.am b/open-vm-tools/libvmtools/Makefile.am
index 2bc00dc3..d01a9717 100644
--- a/open-vm-tools/libvmtools/Makefile.am
+++ b/open-vm-tools/libvmtools/Makefile.am
@@ -67,6 +67,7 @@ libvmtools_la_SOURCES += vmtools.c
libvmtools_la_SOURCES += vmtoolsConfig.c
libvmtools_la_SOURCES += vmtoolsLog.c
libvmtools_la_SOURCES += vmxLogger.c
+libvmtools_la_SOURCES += guestSDKLog.c
# Recompile the stub for Log_* functions, but not Log() itself (see -DNO_LOG_STUB).
libvmtools_la_SOURCES += $(top_srcdir)/lib/stubs/stub-log.c
diff --git a/open-vm-tools/libvmtools/guestSDKLog.c b/open-vm-tools/libvmtools/guestSDKLog.c
new file mode 100644
index 00000000..b19f3a5a
--- /dev/null
+++ b/open-vm-tools/libvmtools/guestSDKLog.c
@@ -0,0 +1,149 @@
+/*********************************************************
+ * Copyright (C) 2013 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * guestSDKLog.c --
+ *
+ * guestSDK logging stubs. In guestSDK, we only do logging in OBJ builds.
+ *
+ */
+
+#include <stdio.h>
+#include "str.h"
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * GuestSDK_Debug --
+ *
+ * Log debug messages.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Death.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+GuestSDK_Debug(const char *fmt, ...)
+{
+#ifdef VMX86_LOG /* only do logging on OBJ builds */
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+#endif
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * GuestSDK_Log --
+ *
+ * Log messages.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Death.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+GuestSDK_Log(const char *fmt, ...)
+{
+#ifdef VMX86_LOG /* only do logging on OBJ builds */
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+#endif
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * GuestSDK_Warning --
+ *
+ * Log warning messages.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Death.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+GuestSDK_Warning(const char *fmt, ...)
+{
+#ifdef VMX86_LOG /* only do logging on OBJ builds */
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+#endif
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * GuestSDK_Panic --
+ *
+ * Panic. Apps have to implement this for themselves.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Death.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+GuestSDK_Panic(const char *fmt, ...) // IN
+{
+ va_list args;
+ char buffer[1024];
+ volatile char *p = NULL;
+
+ va_start(args, fmt);
+ Str_Vsnprintf(buffer, sizeof buffer, fmt, args);
+ va_end(args);
+
+ printf("PANIC: %s", buffer);
+
+ /* force segfault */
+ buffer[0] = *p;
+ while (1) ; // avoid compiler warning
+}
diff --git a/open-vm-tools/libvmtools/vmtoolsInt.h b/open-vm-tools/libvmtools/vmtoolsInt.h
index cc512217..a2ff9c64 100644
--- a/open-vm-tools/libvmtools/vmtoolsInt.h
+++ b/open-vm-tools/libvmtools/vmtoolsInt.h
@@ -52,5 +52,17 @@ VMToolsAsprintf(gchar **string,
gchar const *format,
...) PRINTF_DECL(2, 3);
+void
+GuestSDK_Debug(const char *fmt, ...);
+
+void
+GuestSDK_Log(const char *fmt, ...);
+
+void
+GuestSDK_Warning(const char *fmt, ...);
+
+void
+GuestSDK_Panic(const char *fmt, ...);
+
#endif /* _VMTOOLSINT_H_ */
diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c
index b576724a..2a093c4a 100644
--- a/open-vm-tools/libvmtools/vmtoolsLog.c
+++ b/open-vm-tools/libvmtools/vmtoolsLog.c
@@ -108,6 +108,7 @@ typedef struct LogHandler {
static gchar *gLogDomain = NULL;
static gboolean gEnableCoreDump = TRUE;
static gboolean gLogEnabled = FALSE;
+static gboolean gGuestSDKMode = FALSE;
static guint gPanicCount = 0;
static LogHandler *gDefaultData;
static LogHandler *gErrorData;
@@ -918,6 +919,17 @@ VMToolsLogWrapper(GLogLevelFlags level,
/**
+ * Called if vmtools lib is used along with Guestlib SDK.
+ */
+
+void
+VMTools_SetGuestSDKMode(void)
+{
+ gGuestSDKMode = TRUE;
+}
+
+
+/**
* Logs a message using the G_LOG_LEVEL_DEBUG level.
*
* @param[in] fmt Log message format.
@@ -928,7 +940,11 @@ Debug(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
- VMToolsLogWrapper(G_LOG_LEVEL_DEBUG, fmt, args);
+ if (gGuestSDKMode) {
+ GuestSDK_Debug(fmt, args);
+ } else {
+ VMToolsLogWrapper(G_LOG_LEVEL_DEBUG, fmt, args);
+ }
va_end(args);
}
@@ -944,7 +960,11 @@ Log(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
- VMToolsLogWrapper(G_LOG_LEVEL_INFO, fmt, args);
+ if (gGuestSDKMode) {
+ GuestSDK_Log(fmt, args);
+ } else {
+ VMToolsLogWrapper(G_LOG_LEVEL_INFO, fmt, args);
+ }
va_end(args);
}
@@ -1010,31 +1030,37 @@ Panic(const char *fmt, ...)
va_list args;
va_start(args, fmt);
- if (gPanicCount == 0) {
- char *msg = Str_Vasprintf(NULL, fmt, args);
- if (msg != NULL) {
- g_log(gLogDomain, G_LOG_LEVEL_ERROR, "%s", msg);
- free(msg);
- }
- /*
- * In case an user-installed custom handler doesn't panic on error, force a
- * core dump. Also force a dump in the recursive case.
- */
- VMToolsLogPanic();
- } else if (gPanicCount == 1) {
- /*
- * Use a stack allocated string since we're in a recursive panic, so
- * probably already in a weird state.
- */
- gchar msg[1024];
- Str_Vsnprintf(msg, sizeof msg, fmt, args);
- fprintf(stderr, "Recursive panic: %s\n", msg);
- VMToolsLogPanic();
+
+ if (gGuestSDKMode) {
+ GuestSDK_Panic(fmt, args);
} else {
- fprintf(stderr, "Recursive panic, giving up.\n");
- exit(-1);
+ if (gPanicCount == 0) {
+ char *msg = Str_Vasprintf(NULL, fmt, args);
+ if (msg != NULL) {
+ g_log(gLogDomain, G_LOG_LEVEL_ERROR, "%s", msg);
+ free(msg);
+ }
+ /*
+ * In case an user-installed custom handler doesn't panic on error,
+ * force a core dump. Also force a dump in the recursive case.
+ */
+ VMToolsLogPanic();
+ } else if (gPanicCount == 1) {
+ /*
+ * Use a stack allocated string since we're in a recursive panic, so
+ * probably already in a weird state.
+ */
+ gchar msg[1024];
+ Str_Vsnprintf(msg, sizeof msg, fmt, args);
+ fprintf(stderr, "Recursive panic: %s\n", msg);
+ VMToolsLogPanic();
+ } else {
+ fprintf(stderr, "Recursive panic, giving up.\n");
+ exit(-1);
+ }
}
va_end(args);
+ while (1) ; // avoid compiler warning
}
@@ -1049,7 +1075,11 @@ Warning(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
- VMToolsLogWrapper(G_LOG_LEVEL_WARNING, fmt, args);
+ if (gGuestSDKMode) {
+ GuestSDK_Warning(fmt, args);
+ } else {
+ VMToolsLogWrapper(G_LOG_LEVEL_WARNING, fmt, args);
+ }
va_end(args);
}