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>
GSource *
VMTools_CreateTimer(gint timeout);
+void
+VMTools_SetGuestSDKMode(void);
+
GArray *
VMTools_WrapArray(gconstpointer data,
guint elemSize,
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
#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"
{
VMGuestLibHandleType *data;
+ VMTools_SetGuestSDKMode();
+
if (!VmCheck_IsVirtualWorld()) {
Debug("VMGuestLib_OpenHandle: Not in a VM.\n");
return VMGUESTLIB_ERROR_NOT_RUNNING_IN_VM;
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);
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;
}
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
--- /dev/null
+/*********************************************************
+ * 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
+}
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_ */
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;
}
+/**
+ * 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.
*
{
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);
}
{
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);
}
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
}
{
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);
}