From 9dbcfe022c01b032bf8a92ef2bdc569bcbd3da50 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Wed, 1 Apr 2020 11:34:06 -0700 Subject: [PATCH] Destroy the dedicated RPCI channel set up for the Vmx Guest Logging when vmtoolsd process exits. --- open-vm-tools/lib/include/vmware/tools/log.h | 5 ++- open-vm-tools/libvmtools/vmtoolsLog.c | 37 +++++++++++++++++++- open-vm-tools/services/vmtoolsd/mainPosix.c | 4 ++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/open-vm-tools/lib/include/vmware/tools/log.h b/open-vm-tools/lib/include/vmware/tools/log.h index 4cb4bcb33..222ed1658 100644 --- a/open-vm-tools/lib/include/vmware/tools/log.h +++ b/open-vm-tools/lib/include/vmware/tools/log.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2011-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 @@ -332,6 +332,9 @@ void VMTools_SetupVmxGuestLog(gboolean refreshRpcChannel, GKeyFile *cfg, const gchar *level); +void +VMTools_TeardownVmxGuestLog(void); + typedef enum { TO_HOST, IN_GUEST diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c index 725fa3103..3c331b5a8 100644 --- a/open-vm-tools/libvmtools/vmtoolsLog.c +++ b/open-vm-tools/libvmtools/vmtoolsLog.c @@ -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 @@ -2594,6 +2594,41 @@ done: } +/* + ******************************************************************************* + * VMTools_TeardownVmxGuestLog -- */ /** + * + * Destroy the dedicated RPCI channel set up for the Vmx Guest Logging. + * This function is called from the tools process exit code path. + * + ******************************************************************************* + */ + +void +VMTools_TeardownVmxGuestLog(void) +{ + /* + * In case VMTools_UseVmxGuestLog() is never called. + */ + if (!gUseVmxGuestLog) { + return; + } + + /* + * Acquire the same locks as VMTools_SetupVmxGuestLog. + */ + VMTools_AcquireLogStateLock(); + + g_rec_mutex_lock(&gVmxGuestLogMutex); + + DestroyRpcChannel(); + + g_rec_mutex_unlock(&gVmxGuestLogMutex); + + VMTools_ReleaseLogStateLock(); +} + + /** * Helper function to return the matching LogHandler for a domain name * diff --git a/open-vm-tools/services/vmtoolsd/mainPosix.c b/open-vm-tools/services/vmtoolsd/mainPosix.c index cfe679842..f46e9e77e 100644 --- a/open-vm-tools/services/vmtoolsd/mainPosix.c +++ b/open-vm-tools/services/vmtoolsd/mainPosix.c @@ -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 @@ -187,6 +187,8 @@ main(int argc, setlocale(LC_ALL, ""); + i = atexit(VMTools_TeardownVmxGuestLog); + ASSERT(i == 0); VMTools_UseVmxGuestLog(VMTOOLS_APP_NAME); VMTools_ConfigLogging(G_LOG_DOMAIN, NULL, TRUE, FALSE); VMTools_SetupVmxGuestLog(FALSE, NULL, NULL); -- 2.47.3