From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:29 +0000 (-0700) Subject: Hgfs VMCI Transport: Part I fix the shared memory interface to not assert X-Git-Tag: stable-10.2.0~305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04af878bf5b1c56a9513b606895c41c46def687c;p=thirdparty%2Fopen-vm-tools.git Hgfs VMCI Transport: Part I fix the shared memory interface to not assert THe HGFS VMCI transport uses the shared memory access functions to extract HGFS protocol packets for the HGFS server processing and for returning results. This interface recently changed to add thread tracking for these operations with the addition of register and unregister functions. The HGFS transport interface was missed on the initial change and hence now triggers an assert as the register function call has not been made. This is the first part of a change which addresses the assertion failure by adding the register and unregister calls for the HGFS VMCI transport interface which uses this shared memory. The calls are part of a set of callbacks provided by the supported transports to the HGFS server code for the VMX and tools. Since the backdoor transport does not make use of the shared memory and access calls it just sets the function callbacks to NULL. This is done for both the VMX backdoor channel and tools backdoor channel for packets routed into the HGFS server. This change does the following: - Adds the register and unregister callbacks to the channel callback table. - Modified the VMX VMCI channel to add the register and unregister callbacks and initialize the callback table with these new functions which are then passed to the HGFS server. - Modified the VMX and tools backdoor channels to NULL out the function pointers for the register and unregister callback functions. - Add the Hgfs server directory notification callbacks for register and unregister which are termporarily protected by ifdef statements as they are not yet called from the directory notification component. These simply callback to the channel register and unregister functions to do the real work if present for the channel in use. (Only VMCI will use this.) --- diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index 214fa42b9..33d7ec52f 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -8887,6 +8887,74 @@ HgfsServerGetTargetRelativePath(const char* source, // IN: source file name } +#ifdef HGFS_NOTIFY_THREAD_REGISTER_SUPPORTED +/* + *----------------------------------------------------------------------------- + * + * HgfsServerNotifyRegisterThreadCb -- + * + * The callback is invoked by the file system change notification component + * thread for generating change notification events. + * This simply calls back to the channel's register thread function, if present, + * which does the actual work. + * + * Results: + * None. + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +static void +HgfsServerNotifyRegisterThreadCb(struct HgfsSessionInfo *session) // IN: session info +{ + HgfsTransportSessionInfo *transportSession; + + ASSERT(session); + transportSession = session->transportSession; + + if (transportSession->channelCbTable->registerThread != NULL) { + transportSession->channelCbTable->registerThread(); + } +} + + +/* + *----------------------------------------------------------------------------- + * + * HgfsServerNotifyUnregisterThreadCb -- + * + * The callback is invoked by the file system change notification component + * thread for generating change notification events. + * This simply calls back to the channel's unregister thread function, if present, + * which does the actual work. + * + * Results: + * None. + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +static void +HgfsServerNotifyUnregisterThreadCb(struct HgfsSessionInfo *session) // IN: session info +{ + HgfsTransportSessionInfo *transportSession; + + ASSERT(session); + transportSession = session->transportSession; + + if (transportSession->channelCbTable->unregisterThread != NULL) { + transportSession->channelCbTable->unregisterThread(); + } +} +#endif // HGFS_NOTIFY_THREAD_REGISTER_SUPPORTED + + /* *----------------------------------------------------------------------------- * diff --git a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c index 93579602d..601d3e9a4 100644 --- a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c +++ b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c @@ -348,6 +348,8 @@ HgfsChannelGuestConnConnect(HgfsGuestConn *connData) // IN: our connection data HGFS_LARGE_PACKET_MAX }; + connData->channelCbTable.registerThread = NULL; + connData->channelCbTable.unregisterThread = NULL; connData->channelCbTable.getWriteVa = NULL; connData->channelCbTable.getReadVa = NULL; connData->channelCbTable.putVa = NULL; diff --git a/open-vm-tools/lib/include/hgfsServer.h b/open-vm-tools/lib/include/hgfsServer.h index abf69c64a..4901c255b 100644 --- a/open-vm-tools/lib/include/hgfsServer.h +++ b/open-vm-tools/lib/include/hgfsServer.h @@ -175,12 +175,16 @@ typedef Bool (*HgfsChannelSendFunc)(void *opaqueSession, HgfsSendFlags flags); typedef void * (*HgfsChannelMapVirtAddrFunc)(uint64 pa, uint32 size, void **context); typedef void (*HgfsChannelUnmapVirtAddrFunc)(void **context); +typedef void (*HgfsChannelRegisterThreadFunc)(void); +typedef void (*HgfsChannelUnregisterThreadFunc)(void); typedef struct HgfsServerChannelCallbacks { - HgfsChannelMapVirtAddrFunc getReadVa; - HgfsChannelMapVirtAddrFunc getWriteVa; - HgfsChannelUnmapVirtAddrFunc putVa; - HgfsChannelSendFunc send; + HgfsChannelRegisterThreadFunc registerThread; + HgfsChannelUnregisterThreadFunc unregisterThread; + HgfsChannelMapVirtAddrFunc getReadVa; + HgfsChannelMapVirtAddrFunc getWriteVa; + HgfsChannelUnmapVirtAddrFunc putVa; + HgfsChannelSendFunc send; }HgfsServerChannelCallbacks; typedef struct HgfsServerSessionCallbacks {