From: VMware, Inc <> Date: Wed, 18 Sep 2013 03:30:52 +0000 (-0700) Subject: Re-enable vsocket guestrpc in tools. X-Git-Tag: 2013.09.16-1328054~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=566b7aa41af9f0c40b2c53f8a19f1e718c8bb3d5;p=thirdparty%2Fopen-vm-tools.git Re-enable vsocket guestrpc in tools. 1) Fix some assertion for reconnect. 2) Call VMCISock_GetAFValueFd so we do not hold vsock usage all the time. 2) Cut off the dependency of SIGUSR1 with dndcp plugin. 3) Change function name vmware_unblock_vmware_user to send_vmware_user_sigusr1. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/rpcChannel/rpcChannel.c b/open-vm-tools/lib/rpcChannel/rpcChannel.c index f698e1785..45d9358a7 100644 --- a/open-vm-tools/lib/rpcChannel/rpcChannel.c +++ b/open-vm-tools/lib/rpcChannel/rpcChannel.c @@ -633,8 +633,7 @@ RpcChannel * RpcChannel_New(void) { RpcChannel *chan; -#if 0 /* defined(linux) || defined(_WIN32) - This is a temporarily workaround for bug 1053489 */ +#if defined(linux) || defined(_WIN32) chan = VSockChannel_New(); #else chan = BackdoorChannel_New(); @@ -661,8 +660,16 @@ RpcChannel_Shutdown(RpcChannel *chan) if (chan != NULL && chan->funcs != NULL && chan->funcs->shutdown != NULL) { if (chan->in != NULL) { + if (chan->inStarted) { + RpcIn_stop(chan->in); + } + chan->inStarted = FALSE; RpcIn_Destruct(chan->in); + chan->in = NULL; + } else { + ASSERT(!chan->inStarted); } + if (chan->mainCtx != NULL) { g_main_context_unref(chan->mainCtx); } @@ -694,11 +701,9 @@ RpcChannel_Start(RpcChannel *chan) /* Already started. Make sure both channels are in sync and return. */ ASSERT(chan->in == NULL || chan->inStarted); return TRUE; - } else { - ASSERT(chan->in == NULL || !chan->inStarted); } - if (chan->in != NULL) { + if (chan->in != NULL && !chan->inStarted) { ok = RpcIn_start(chan->in, RPCIN_MAX_DELAY, RpcChannel_Error, chan); chan->inStarted = ok; } diff --git a/open-vm-tools/lib/rpcChannel/simpleSocket.c b/open-vm-tools/lib/rpcChannel/simpleSocket.c index 2a7d5db79..a99d2726a 100644 --- a/open-vm-tools/lib/rpcChannel/simpleSocket.c +++ b/open-vm-tools/lib/rpcChannel/simpleSocket.c @@ -300,6 +300,8 @@ Socket_ConnectVMCI(unsigned int cid, // IN SockConnError error = SOCKERR_GENERIC; int sysErr; socklen_t addrLen = sizeof addr; + int vsockDev = -1; + int family = VMCISock_GetAFValueFd(&vsockDev); if (outError) { *outError = SOCKERR_SUCCESS; @@ -309,8 +311,13 @@ Socket_ConnectVMCI(unsigned int cid, // IN goto error; } + if (family == -1) { + g_warning(LGPFX "Couldn't get VMCI socket family info."); + goto error; + } + memset((char *)&addr, 0, sizeof addr); - addr.svm_family = VMCISock_GetAFValue(); + addr.svm_family = family; addr.svm_cid = cid; addr.svm_port = port; @@ -383,6 +390,7 @@ Socket_ConnectVMCI(unsigned int cid, // IN goto error; } + VMCISock_ReleaseAFValueFd(vsockDev); g_debug(LGPFX "socket %d connected\n", fd); return fd; @@ -390,6 +398,7 @@ error: if (outError) { *outError = error; } + VMCISock_ReleaseAFValueFd(vsockDev); return INVALID_SOCKET; } diff --git a/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp b/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp index 7c77f854c..5c1260c23 100644 --- a/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp +++ b/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp @@ -154,17 +154,11 @@ gboolean BlockService::ShutdownSignalHandler(const siginfo_t *siginfo, gpointer data) { - ToolsAppCtx *ctx = (ToolsAppCtx *)data; TRACE_CALL(); + g_debug("Shutting down block service on SIGUSR1 ...\n"); GetInstance()->Shutdown(); - /* shutdown rpc channel to free up VMCI/VSOCKET module usage */ - if (ctx->rpc != NULL) { - RpcChannel_Shutdown(ctx->rpc); - ctx->rpc = NULL; - } - return FALSE; } diff --git a/open-vm-tools/services/vmtoolsd/mainPosix.c b/open-vm-tools/services/vmtoolsd/mainPosix.c index 9143a9157..120f6cfb0 100644 --- a/open-vm-tools/services/vmtoolsd/mainPosix.c +++ b/open-vm-tools/services/vmtoolsd/mainPosix.c @@ -89,6 +89,7 @@ ToolsCoreSigHandler(const siginfo_t *info, /** * Handles a USR1 signal; logs the current service state. + * Also shutdown rpc connection so we can do tools upgrade. * * @param[in] info Unused. * @param[in] data Unused. @@ -101,6 +102,13 @@ ToolsCoreSigUsrHandler(const siginfo_t *info, gpointer data) { ToolsCore_DumpState(&gState); + + g_info("Shutting down guestrpc on signal USR1 ...\n"); + if (strcmp(gState.ctx.name, VMTOOLS_USER_SERVICE) == 0) { + RpcChannel_Shutdown(gState.ctx.rpc); + gState.ctx.rpc = NULL; + } + return TRUE; }