From: VMware, Inc <> Date: Wed, 20 Jan 2010 21:26:16 +0000 (-0800) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2010.01.19-226760~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bf6bffc3e5f28cb1e14a70ef49aeb462659dd84;p=thirdparty%2Fopen-vm-tools.git Changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/foundryMsg/foundryMsg.c b/open-vm-tools/lib/foundryMsg/foundryMsg.c index 0987467f8..c9f532dca 100644 --- a/open-vm-tools/lib/foundryMsg/foundryMsg.c +++ b/open-vm-tools/lib/foundryMsg/foundryMsg.c @@ -1648,3 +1648,95 @@ VixMsg_ParseGenericRequestMsg(const VixCommandGenericRequest *request, // IN return err; } // VixMsg_ParseGenericRequestMsg + + +/* + *----------------------------------------------------------------------------- + * + * VixMsg_MallocClientData -- + * + * Allocates the memory needed to copy from a client-provided buffer. + * + * Results: + * Pointer to allocated memory + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +void * +VixMsg_MallocClientData(size_t size) // IN +{ + return malloc(size); +} // VixMsg_MallocClientData + + +/* + *----------------------------------------------------------------------------- + * + * VixMsg_ReallocClientData -- + * + * Reallocates the memory needed to copy from a client-provided buffer. + * + * Results: + * Pointer to allocated memory + * + * Side effects: + * Frees memory pointed to by ptr. + * + *----------------------------------------------------------------------------- + */ + +void * +VixMsg_ReallocClientData(void *ptr, // IN + size_t size) // IN +{ + return realloc(ptr, size); +} // VixMsg_ReallocClientData + + +/* + *----------------------------------------------------------------------------- + * + * VixMsg_StrdupClientData -- + * + * Allocates memory and copies client-provided string. + * + * Results: + * Pointer to allocated string + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +char * +VixMsg_StrdupClientData(const char *s, // IN + Bool *allocateFailed) // OUT +{ + char* newString = NULL; + + ASSERT(allocateFailed); + if (NULL == allocateFailed) { + goto abort; + } + + *allocateFailed = FALSE; + + if (NULL != s) { +#if defined(_WIN32) + newString = _strdup(s); +#else + newString = strdup(s); +#endif + if (NULL == newString) { + *allocateFailed = TRUE; + } + } + +abort: + return newString; +} // VixMsg_StrdupClientData diff --git a/open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c b/open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c index 66e36dd25..b00612d14 100644 --- a/open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c +++ b/open-vm-tools/lib/foundryMsg/foundryPropertyListCommon.c @@ -31,6 +31,7 @@ #include "vm_version.h" #include "util.h" #include "str.h" +#include "vixCommands.h" #include "vixOpenSource.h" @@ -456,6 +457,7 @@ VixPropertyListDeserializeImpl(VixPropertyListImpl *propList, // IN size_t propertyValueLengthSize; size_t headerSize; VixPropertyType *propertyTypePtr; + Bool allocateFailed; if ((NULL == propList) || (NULL == buffer)) { @@ -536,7 +538,13 @@ VixPropertyListDeserializeImpl(VixPropertyListImpl *propList, // IN goto abort; } free(property->value.strValue); - property->value.strValue = Util_SafeStrdup(strPtr); + + property->value.strValue = + VixMsg_StrdupClientData(strPtr, &allocateFailed); + if (allocateFailed) { + err = VIX_E_OUT_OF_MEMORY; + goto abort; + } break; //////////////////////////////////////////////////////// @@ -569,7 +577,8 @@ VixPropertyListDeserializeImpl(VixPropertyListImpl *propList, // IN * pretty easy to handle. */ free(property->value.blobValue.blobContents); - property->value.blobValue.blobContents = malloc(*lengthPtr); + property->value.blobValue.blobContents = + VixMsg_MallocClientData(*lengthPtr); if (NULL == property->value.blobValue.blobContents) { err = VIX_E_OUT_OF_MEMORY; goto abort; diff --git a/open-vm-tools/lib/include/vixCommands.h b/open-vm-tools/lib/include/vixCommands.h index 2019882e3..f5ecff103 100644 --- a/open-vm-tools/lib/include/vixCommands.h +++ b/open-vm-tools/lib/include/vixCommands.h @@ -2613,6 +2613,10 @@ VixError VixMsg_ParseGenericRequestMsg(const VixCommandGenericRequest *request, int *options, VixPropertyListImpl *propertyList); +void *VixMsg_MallocClientData(size_t size); +void *VixMsg_ReallocClientData(void *ptr, size_t size); +char *VixMsg_StrdupClientData(const char *s, Bool *allocateFailed); + #endif // VIX_HIDE_FROM_JAVA diff --git a/open-vm-tools/modules/linux/shared/vmci_infrastructure.h b/open-vm-tools/modules/linux/shared/vmci_infrastructure.h index 9f8cebae8..35a5b5329 100644 --- a/open-vm-tools/modules/linux/shared/vmci_infrastructure.h +++ b/open-vm-tools/modules/linux/shared/vmci_infrastructure.h @@ -62,6 +62,7 @@ typedef enum { #define VMCI_DEV_QUIESCE 0x03 #define VMCI_DEV_UNQUIESCE 0x04 #define VMCI_DEV_QP_BREAK_SHARING 0x05 // DEPRECATED +#define VMCI_DEV_RESTORE_SYNC 0x06 /* diff --git a/open-vm-tools/modules/linux/shared/vmci_kernel_if.h b/open-vm-tools/modules/linux/shared/vmci_kernel_if.h index 8448e1cb5..87ff609b7 100644 --- a/open-vm-tools/modules/linux/shared/vmci_kernel_if.h +++ b/open-vm-tools/modules/linux/shared/vmci_kernel_if.h @@ -188,7 +188,10 @@ typedef void * VMCIBuffer; typedef struct VMCIHost { #if defined(VMKERNEL) - World_ID vmmWorldID; + World_ID vmmWorldID[2]; /* + * First one is the active one and the second + * one is shadow world during FSR. + */ #elif defined(linux) wait_queue_head_t waitQueue; #elif defined(__APPLE__) @@ -223,6 +226,10 @@ Bool VMCIHost_WaitForCallLocked(VMCIHost *hostContext, Bool useBH); #ifdef VMKERNEL int VMCIHost_ContextToHostVmID(VMCIHost *hostContext, VMCIHostVmID *hostVmID); +void VMCIHost_SetActiveHnd(VMCIHost *hostContext, uintptr_t eventHnd); +Bool VMCIHost_RemoveHnd(VMCIHost *hostContext, uintptr_t eventHnd); +Bool VMCIHost_IsActiveHnd(VMCIHost *hostContext, uintptr_t eventHnd); +uint32 VMCIHost_NumHnds(VMCIHost *hostContext); #endif void *VMCI_AllocKernelMem(size_t size, int flags); diff --git a/open-vm-tools/modules/linux/vsock/linux/vmciContext.h b/open-vm-tools/modules/linux/vsock/linux/vmciContext.h index 16f402212..602bcc755 100644 --- a/open-vm-tools/modules/linux/vsock/linux/vmciContext.h +++ b/open-vm-tools/modules/linux/vsock/linux/vmciContext.h @@ -48,6 +48,21 @@ int VMCIContext_InitContext(VMCIId cid, VMCIPrivilegeFlags flags, int VMCIContext_SetDomainName(VMCIContext *context, const char *domainName); int VMCIContext_GetDomainName(VMCIId contextID, char *domainName, size_t domainNameBufSize); +void VMCIContext_SetFSRState(VMCIContext *context, + Bool isQuiesced, + VMCIId migrateCid, + uintptr_t eventHnd, + Bool isLocked); +VMCIContext *VMCIContext_FindAndUpdateSrcFSR(VMCIId migrateCid, + uintptr_t eventHnd); +Bool VMCIContext_IsActiveHnd(VMCIContext *context, + uintptr_t eventHnd); +Bool VMCIContext_RemoveHnd(VMCIContext *context, + uintptr_t eventHnd, + uint32 *numOld, + uint32 *numNew); +void VMCIContext_ClearDatagrams(VMCIContext *context); +void VMCIContext_SetId(VMCIContext *context, VMCIId cid); #endif Bool VMCIContext_SupportsHostQP(VMCIContext *context); void VMCIContext_ReleaseContext(VMCIContext *context);