From: Oliver Kurth Date: Wed, 1 Apr 2020 18:31:37 +0000 (-0700) Subject: Destroy the dedicated RPCI channel set up for the Vmx Guest Logging X-Git-Tag: stable-11.2.0~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39ceb37ce4d6093cb1b64baf6eeddf2532b0b3a1;p=thirdparty%2Fopen-vm-tools.git Destroy the dedicated RPCI channel set up for the Vmx Guest Logging when vmtoolsd process exits. --- 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);