From: Oliver Kurth Date: Tue, 26 May 2020 22:32:56 +0000 (-0700) Subject: GuestSDK and vmtoolslib cleanup. X-Git-Tag: stable-11.2.0~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66e52b635938b8c4e5276944daaec1cddc5ae6f9;p=thirdparty%2Fopen-vm-tools.git GuestSDK and vmtoolslib cleanup. * Removed the vmtools dependency for guestsdk. This has been already done for tar tools build/target. The same is being done for OVT builds. * Used various static libraries for building guestlib in OVT instead of depending on vmtoolslib. Similar thing has already been done for appmonitor library in OVT. * GuestSDK_{Panic|Debug|Warning|Log} functions in vmtoolslib are not used anywhere and hence they are completely removed from the code. --- diff --git a/open-vm-tools/lib/include/vmware/tools/utils.h b/open-vm-tools/lib/include/vmware/tools/utils.h index a3292d5c0..cfa35019b 100644 --- a/open-vm-tools/lib/include/vmware/tools/utils.h +++ b/open-vm-tools/lib/include/vmware/tools/utils.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2020 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 @@ -158,9 +158,6 @@ VMTools_GetLibdir(void); GSource * VMTools_CreateTimer(gint timeout); -void -VMTools_SetGuestSDKMode(void); - void VMTools_AcquireLogStateLock(void); diff --git a/open-vm-tools/libguestlib/Makefile.am b/open-vm-tools/libguestlib/Makefile.am index 5181409f3..d2cfb80a5 100644 --- a/open-vm-tools/libguestlib/Makefile.am +++ b/open-vm-tools/libguestlib/Makefile.am @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2007-2018 VMware, Inc. All rights reserved. +### Copyright (C) 2007-2018,2020 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -21,15 +21,38 @@ AM_CFLAGS = AM_CFLAGS += -I$(top_srcdir)/include libguestlib_la_LIBADD = -libguestlib_la_LIBADD += @VMTOOLS_LIBS@ +libguestlib_la_LIBADD += ../lib/backdoor/libBackdoor.la +libguestlib_la_LIBADD += ../lib/dataMap/libDataMap.la +libguestlib_la_LIBADD += ../lib/dynxdr/libDynxdr.la +libguestlib_la_LIBADD += ../lib/err/libErr.la +libguestlib_la_LIBADD += ../lib/hashMap/libHashMap.la +libguestlib_la_LIBADD += ../lib/message/libMessage.la +libguestlib_la_LIBADD += ../lib/misc/libMisc.la +libguestlib_la_LIBADD += ../lib/rpcOut/libRpcOut.la +libguestlib_la_LIBADD += ../lib/string/libString.la +libguestlib_la_LIBADD += ../lib/unicode/libUnicode.la +libguestlib_la_LIBADD += ../lib/vmCheck/libVmCheck.la +libguestlib_la_LIBADD += ../lib/vmSignal/libVmSignal.la libguestlib_la_LIBADD += @XDR_LIBS@ +libguestlib_rpcchanneldir = $(top_srcdir)/lib/rpcChannel + libguestlib_la_SOURCES = libguestlib_la_SOURCES += guestlibV3_xdr.c libguestlib_la_SOURCES += guestlibIoctl_xdr.c +libguestlib_la_SOURCES += guestSDKLog.c libguestlib_la_SOURCES += vmGuestLib.c +libguestlib_la_SOURCES += $(libguestlib_rpcchanneldir)/bdoorChannel.c +libguestlib_la_SOURCES += $(libguestlib_rpcchanneldir)/rpcChannel.c +libguestlib_la_SOURCES += $(libguestlib_rpcchanneldir)/glib_stubs.c +if HAVE_VSOCK +libguestlib_la_SOURCES += $(libguestlib_rpcchanneldir)/vsockChannel.c +libguestlib_la_SOURCES += $(libguestlib_rpcchanneldir)/simpleSocket.c +endif libguestlib_la_LDFLAGS = +libguestlib_la_LDFLAGS += -Wl,-ldl +libguestlib_la_LDFLAGS += -Wl,-lrt # We require GCC, so we're fine passing compiler-specific flags. # Needed for OS's that don't link shared libraries against libc by default, e.g. FreeBSD libguestlib_la_LDFLAGS += -Wl,-lc @@ -56,6 +79,7 @@ CFLAGS += -Wno-unused libguestlib_la_CPPFLAGS = libguestlib_la_CPPFLAGS += -DVMTOOLS_USE_GLIB +libguestlib_la_CPPFLAGS += -DUSE_RPCI_ONLY libguestlib_la_CPPFLAGS += @GLIB2_CPPFLAGS@ libguestlib_la_CPPFLAGS += @XDR_CPPFLAGS@ diff --git a/open-vm-tools/libvmtools/guestSDKLog.c b/open-vm-tools/libguestlib/guestSDKLog.c similarity index 89% rename from open-vm-tools/libvmtools/guestSDKLog.c rename to open-vm-tools/libguestlib/guestSDKLog.c index 39119d3fb..a8c797bc0 100644 --- a/open-vm-tools/libvmtools/guestSDKLog.c +++ b/open-vm-tools/libguestlib/guestSDKLog.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013-2016,2019 VMware, Inc. All rights reserved. + * Copyright (C) 2013-2015,2020 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 @@ -30,7 +30,7 @@ /* *----------------------------------------------------------------------------- * - * GuestSDK_Debug -- + * Debug -- * * Log debug messages. * @@ -38,13 +38,13 @@ * None. * * Side effects: - * Death. + * Stderr. * *----------------------------------------------------------------------------- */ void -GuestSDK_Debug(const char *fmt, ...) +Debug(const char *fmt, ...) { #ifdef VMX86_LOG /* only do logging on OBJ builds */ va_list args; @@ -59,7 +59,7 @@ GuestSDK_Debug(const char *fmt, ...) /* *----------------------------------------------------------------------------- * - * GuestSDK_Log -- + * Log -- * * Log messages. * @@ -67,13 +67,13 @@ GuestSDK_Debug(const char *fmt, ...) * None. * * Side effects: - * Death. + * Stderr. * *----------------------------------------------------------------------------- */ void -GuestSDK_Log(const char *fmt, ...) +Log(const char *fmt, ...) { #ifdef VMX86_LOG /* only do logging on OBJ builds */ va_list args; @@ -88,7 +88,7 @@ GuestSDK_Log(const char *fmt, ...) /* *----------------------------------------------------------------------------- * - * GuestSDK_Warning -- + * Warning -- * * Log warning messages. * @@ -96,13 +96,13 @@ GuestSDK_Log(const char *fmt, ...) * None. * * Side effects: - * Death. + * Stderr. * *----------------------------------------------------------------------------- */ void -GuestSDK_Warning(const char *fmt, ...) +Warning(const char *fmt, ...) { #ifdef VMX86_LOG /* only do logging on OBJ builds */ va_list args; @@ -117,7 +117,7 @@ GuestSDK_Warning(const char *fmt, ...) /* *----------------------------------------------------------------------------- * - * GuestSDK_Panic -- + * Panic -- * * Panic. Apps have to implement this for themselves. * @@ -131,7 +131,7 @@ GuestSDK_Warning(const char *fmt, ...) */ void -GuestSDK_Panic(const char *fmt, ...) // IN +Panic(const char *fmt, ...) // IN { va_list args; char buffer[1024]; diff --git a/open-vm-tools/libvmtools/Makefile.am b/open-vm-tools/libvmtools/Makefile.am index 347b8c7d9..290e87d61 100644 --- a/open-vm-tools/libvmtools/Makefile.am +++ b/open-vm-tools/libvmtools/Makefile.am @@ -1,5 +1,5 @@ ################################################################################ -### Copyright (C) 2008-2019 VMware, Inc. All rights reserved. +### Copyright (C) 2008-2020 VMware, Inc. All rights reserved. ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of version 2 of the GNU General Public License as @@ -70,7 +70,6 @@ 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/vmtoolsInt.h b/open-vm-tools/libvmtools/vmtoolsInt.h index daa09176c..eed25cc66 100644 --- a/open-vm-tools/libvmtools/vmtoolsInt.h +++ b/open-vm-tools/libvmtools/vmtoolsInt.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2016,2020 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 @@ -52,17 +52,5 @@ 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 6b8154408..780c0e1e7 100644 --- a/open-vm-tools/libvmtools/vmtoolsLog.c +++ b/open-vm-tools/libvmtools/vmtoolsLog.c @@ -157,7 +157,6 @@ static guint gDroppedLogCount = 0; static gint gMaxCacheEntries = DEFAULT_MAX_CACHE_ENTRIES; static gboolean gEnableCoreDump = TRUE; static gboolean gLogEnabled = FALSE; -static gboolean gGuestSDKMode = FALSE; static guint gPanicCount = 0; static LogHandler *gDefaultData; static LogHandler *gErrorData; @@ -2107,17 +2106,6 @@ VMTools_ResumeLogIO() } -/** - * 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. * @@ -2129,16 +2117,12 @@ Debug(const char *fmt, ...) { va_list args; va_start(args, fmt); - if (gGuestSDKMode) { - GuestSDK_Debug(fmt, args); - } else { - /* - * Preserve errno/lastError. - * This keeps compatibility with bora/lib Log(), preventing - * Log() calls in bora/lib code from clobbering errno/lastError. - */ - WITH_ERRNO(err, VMToolsLogWrapper(G_LOG_LEVEL_DEBUG, fmt, args)); - } + /* + * Preserve errno/lastError. + * This keeps compatibility with bora/lib Log(), preventing + * Log() calls in bora/lib code from clobbering errno/lastError. + */ + WITH_ERRNO(err, VMToolsLogWrapper(G_LOG_LEVEL_DEBUG, fmt, args)); va_end(args); } @@ -2154,16 +2138,12 @@ Log(const char *fmt, ...) { va_list args; va_start(args, fmt); - if (gGuestSDKMode) { - GuestSDK_Log(fmt, args); - } else { - /* - * Preserve errno/lastError. - * This keeps compatibility with bora/lib Log(), preventing - * Log() calls in bora/lib code from clobbering errno/lastError. - */ - WITH_ERRNO(err, VMToolsLogWrapper(G_LOG_LEVEL_INFO, fmt, args)); - } + /* + * Preserve errno/lastError. + * This keeps compatibility with bora/lib Log(), preventing + * Log() calls in bora/lib code from clobbering errno/lastError. + */ + WITH_ERRNO(err, VMToolsLogWrapper(G_LOG_LEVEL_INFO, fmt, args)); va_end(args); } @@ -2240,33 +2220,29 @@ Panic(const char *fmt, ...) va_start(args, fmt); - if (gGuestSDKMode) { - GuestSDK_Panic(fmt, args); - } else { - 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); + 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 @@ -2289,16 +2265,12 @@ Warning(const char *fmt, ...) { va_list args; va_start(args, fmt); - if (gGuestSDKMode) { - GuestSDK_Warning(fmt, args); - } else { - /* - * Preserve errno/lastError. - * This keeps compatibility with bora/lib Log(), preventing - * Log() calls in bora/lib code from clobbering errno/lastError. - */ - WITH_ERRNO(err, VMToolsLogWrapper(G_LOG_LEVEL_WARNING, fmt, args)); - } + /* + * Preserve errno/lastError. + * This keeps compatibility with bora/lib Log(), preventing + * Log() calls in bora/lib code from clobbering errno/lastError. + */ + WITH_ERRNO(err, VMToolsLogWrapper(G_LOG_LEVEL_WARNING, fmt, args)); va_end(args); } @@ -2357,12 +2329,8 @@ WarningToHost(const char *fmt, ...) { va_list args; va_start(args, fmt); - if (gGuestSDKMode) { - GuestSDK_Warning(fmt, args); - } else { - WITH_ERRNO(err, - VmwareLogWrapper(TO_HOST, G_LOG_LEVEL_WARNING, fmt, args)); - } + WITH_ERRNO(err, + VmwareLogWrapper(TO_HOST, G_LOG_LEVEL_WARNING, fmt, args)); va_end(args); } @@ -2383,12 +2351,8 @@ WarningToGuest(const char *fmt, ...) { va_list args; va_start(args, fmt); - if (gGuestSDKMode) { - GuestSDK_Warning(fmt, args); - } else { - WITH_ERRNO(err, - VmwareLogWrapper(IN_GUEST, G_LOG_LEVEL_WARNING, fmt, args)); - } + WITH_ERRNO(err, + VmwareLogWrapper(IN_GUEST, G_LOG_LEVEL_WARNING, fmt, args)); va_end(args); }