]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Re-enable vsocket guestrpc in tools.
authorVMware, Inc <>
Wed, 18 Sep 2013 03:30:52 +0000 (20:30 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:13:29 +0000 (22:13 -0700)
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 <dtor@vmware.com>
open-vm-tools/lib/rpcChannel/rpcChannel.c
open-vm-tools/lib/rpcChannel/simpleSocket.c
open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp
open-vm-tools/services/vmtoolsd/mainPosix.c

index f698e178510ceceb092de419c09f5841442254a7..45d9358a7926882c7d8fc73481993617ae7cb673 100644 (file)
@@ -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;
    }
index 2a7d5db7943738ba6faf195f12cd137b3c26ab26..a99d2726a0332e108b08a0708935f55837a05527 100644 (file)
@@ -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;
 }
index 7c77f854cfccd1210c518d71aea3a74ae159df19..5c1260c234a4e4af4481ccc20b06e605df56c9fb 100644 (file)
@@ -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;
 }
 
index 9143a9157f31804126bf1eb76ed16ef4d18a0e38..120f6cfb0d1d0e3d67209e3d88a5500b2e2f17ba 100644 (file)
@@ -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;
 }