From: VMware, Inc <> Date: Tue, 29 Mar 2011 20:25:10 +0000 (-0700) Subject: This is part 17 (this is getting ridiculous) of a X-Git-Tag: 2011.03.28-387002~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2ffd451156663b1a56e8e80da0e952114fa68e82;p=thirdparty%2Fopen-vm-tools.git This is part 17 (this is getting ridiculous) of a change to support Nested VMs. This change switches over the HasPeronality() and DeviceEnabled() rules to match those of the Linux driver. This allows it to handle *always* having two devices in a guest, even if a hosted product is not installed, which is now a restriction imposed by the installer. DeviceShutdown() and InUse() are redundant on platforms that don't have retarded stop/removal rules, so moved that functionality out of the common code and into the Windows driver code. Signed-off-by: Marcelo Vanzin --- 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 023149878..5a389f316 100644 --- a/open-vm-tools/modules/linux/shared/vmci_kernel_if.h +++ b/open-vm-tools/modules/linux/shared/vmci_kernel_if.h @@ -391,9 +391,7 @@ int VMCI_ConvertToLocalQueue(struct VMCIQueue *queueInfo, void VMCI_RevertToNonLocalQueue(struct VMCIQueue *queueInfo, void *nonLocalQueue, uint64 size); void VMCI_FreeQueueBuffer(void *queue, uint64 size); -void VMCI_DeviceShutdownBegin(void); -void VMCI_DeviceShutdownEnd(void); -Bool VMCI_DeviceShutdown(void); +Bool VMCI_CanCreate(void); #else // _WIN32 # define VMCI_InitQueueMutex(_pq, _cq) # define VMCI_AcquireQueueMutex(_q) @@ -402,7 +400,7 @@ Bool VMCI_DeviceShutdown(void); # define VMCI_ConvertToLocalQueue(_pq, _cq, _s, _oq, _kc) VMCI_ERROR_UNAVAILABLE # define VMCI_RevertToNonLocalQueue(_q, _nlq, _s) # define VMCI_FreeQueueBuffer(_q, _s) -# define VMCI_DeviceShutdown() FALSE +# define VMCI_CanCreate() TRUE #endif // !_WIN32 #if defined(_WIN32) || (defined(linux) && !defined(VMKERNEL)) Bool VMCI_GuestPersonalityActive(void); diff --git a/open-vm-tools/modules/linux/vmci/common/vmciDriver.c b/open-vm-tools/modules/linux/vmci/common/vmciDriver.c index a2b3edd01..0edf22cc7 100644 --- a/open-vm-tools/modules/linux/vmci/common/vmciDriver.c +++ b/open-vm-tools/modules/linux/vmci/common/vmciDriver.c @@ -47,7 +47,6 @@ static VMCIId ctxUpdateSubID = VMCI_INVALID_ID; static VMCIContext *hostContext; static Atomic_uint32 vmContextID = { VMCI_INVALID_ID }; -static Atomic_uint32 vmciClientCount; /* @@ -125,6 +124,7 @@ VMCI_HostCleanup(void) } +#if !defined(_WIN32) /* *---------------------------------------------------------------------- * @@ -147,26 +147,16 @@ VMCI_EXPORT_SYMBOL(VMCI_DeviceGet) Bool VMCI_DeviceGet(uint32 *apiVersion) { - Atomic_Inc32(&vmciClientCount); - if (*apiVersion > VMCI_KERNEL_API_VERSION) { *apiVersion = VMCI_KERNEL_API_VERSION; - goto release; + return FALSE; } if (!VMCI_DeviceEnabled()) { - goto release; - } - - if (VMCI_DeviceShutdown()) { - goto release; + return FALSE; } return TRUE; - -release: - Atomic_Dec32(&vmciClientCount); - return FALSE; } @@ -190,8 +180,8 @@ VMCI_EXPORT_SYMBOL(VMCI_DeviceRelease) void VMCI_DeviceRelease(void) { - Atomic_Dec32(&vmciClientCount); } +#endif // !_WIN32 /* @@ -374,30 +364,6 @@ VMCI_CheckHostCapabilities(void) } -/* - *---------------------------------------------------------------------- - * - * VMCI_DeviceInUse -- - * - * Report whether the device is in-use by a client. - * - * Results: - * TRUE if the device is in-use (reference count greater than zero), - * FALSE otherwise. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Bool -VMCI_DeviceInUse(void) -{ - return Atomic_Read32(&vmciClientCount) > 0 ? TRUE : FALSE; -} - - /* *---------------------------------------------------------------------- * diff --git a/open-vm-tools/modules/linux/vmci/common/vmciDriver.h b/open-vm-tools/modules/linux/vmci/common/vmciDriver.h index cfd4a821f..9ce7995b0 100644 --- a/open-vm-tools/modules/linux/vmci/common/vmciDriver.h +++ b/open-vm-tools/modules/linux/vmci/common/vmciDriver.h @@ -88,7 +88,6 @@ void VMCIUtil_Exit(void); Bool VMCI_CheckHostCapabilities(void); void VMCI_ReadDatagramsFromPort(VMCIIoHandle ioHandle, VMCIIoPort dgInPort, uint8 *dgInBuffer, size_t dgInBufferSize); -Bool VMCI_DeviceInUse(void); Bool VMCI_DeviceEnabled(void); #if defined(_WIN64) int VMCIDoSendDatagram(unsigned int dgSize, ULONG *dataPort, ULONG *resultPort, diff --git a/open-vm-tools/modules/linux/vmci/common/vmciEvent.c b/open-vm-tools/modules/linux/vmci/common/vmciEvent.c index d009ab6a9..fbd397976 100644 --- a/open-vm-tools/modules/linux/vmci/common/vmciEvent.c +++ b/open-vm-tools/modules/linux/vmci/common/vmciEvent.c @@ -562,9 +562,9 @@ VMCIEventRegisterSubscription(VMCISubscription *sub, // IN VMCIEventGrabLock(&subscriberLock, &lockFlags); - /* Do not allow a new subscription if the device is being shutdown. */ - if (VMCI_DeviceShutdown()) { - result = VMCI_ERROR_DEVICE_NOT_FOUND; + /* Check if creation of a new event is allowed. */ + if (!VMCI_CanCreate()) { + result = VMCI_ERROR_UNAVAILABLE; goto exit; } diff --git a/open-vm-tools/modules/linux/vmci/common/vmciHashtable.c b/open-vm-tools/modules/linux/vmci/common/vmciHashtable.c index fcfb0870c..9173e4910 100644 --- a/open-vm-tools/modules/linux/vmci/common/vmciHashtable.c +++ b/open-vm-tools/modules/linux/vmci/common/vmciHashtable.c @@ -191,10 +191,10 @@ VMCIHashTable_AddEntry(VMCIHashTable *table, // IN VMCIHashTableGrabLock(&table->lock, &flags); - /* Do not allow addition of a new entry if the device is being shutdown. */ - if (VMCI_DeviceShutdown()) { + /* Check if creation of a new hashtable entry is allowed. */ + if (!VMCI_CanCreate()) { VMCIHashTableReleaseLock(&table->lock, flags); - return VMCI_ERROR_DEVICE_NOT_FOUND; + return VMCI_ERROR_UNAVAILABLE; } if (VMCIHashTableEntryExistsLocked(table, entry->handle)) { diff --git a/open-vm-tools/modules/linux/vmci/common/vmciQueuePair.c b/open-vm-tools/modules/linux/vmci/common/vmciQueuePair.c index a70430812..0a476b4c9 100644 --- a/open-vm-tools/modules/linux/vmci/common/vmciQueuePair.c +++ b/open-vm-tools/modules/linux/vmci/common/vmciQueuePair.c @@ -1982,9 +1982,9 @@ VMCIQueuePairAllocGuestWork(VMCIHandle *handle, // IN/OUT VMCIQPLock_Acquire(&qpGuestEndpoints.lock); - /* Do not allow alloc/attach if the device is being shutdown. */ - if (VMCI_DeviceShutdown()) { - result = VMCI_ERROR_DEVICE_NOT_FOUND; + /* Check if creation/attachment of a queuepair is allowed. */ + if (!VMCI_CanCreate()) { + result = VMCI_ERROR_UNAVAILABLE; goto error; } @@ -2001,8 +2001,8 @@ VMCIQueuePairAllocGuestWork(VMCIHandle *handle, // IN/OUT goto error; } - if ((queuePairEntry = (QPGuestEndpoint *)QueuePairList_FindEntry( - &qpGuestEndpoints, *handle))) { + if ((queuePairEntry = (QPGuestEndpoint *) + QueuePairList_FindEntry(&qpGuestEndpoints, *handle))) { if (queuePairEntry->qp.flags & VMCI_QPFLAG_LOCAL) { /* Local attach case. */ if (queuePairEntry->qp.refCount > 1) {