]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
This is part 17 (this is getting ridiculous) of a
authorVMware, Inc <>
Tue, 29 Mar 2011 20:25:10 +0000 (13:25 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 29 Mar 2011 20:25:10 +0000 (13:25 -0700)
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 <mvanzin@vmware.com>
open-vm-tools/modules/linux/shared/vmci_kernel_if.h
open-vm-tools/modules/linux/vmci/common/vmciDriver.c
open-vm-tools/modules/linux/vmci/common/vmciDriver.h
open-vm-tools/modules/linux/vmci/common/vmciEvent.c
open-vm-tools/modules/linux/vmci/common/vmciHashtable.c
open-vm-tools/modules/linux/vmci/common/vmciQueuePair.c

index 023149878db75bc1fbe347ba34cd32981da9118f..5a389f3162ab5b840599471449f8cd1ee65c16a0 100644 (file)
@@ -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);
index a2b3edd01d36a54c467a4a4853dedc210a219dad..0edf22cc78dd78f7f099f88cbb57f5297d3950f2 100644 (file)
@@ -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;
-}
-
-
 /*
  *----------------------------------------------------------------------
  *
index cfd4a821faa8a09f41c9bf4ac2a9e165b4347921..9ce7995b03977d4dd6504937d30a34b869243855 100644 (file)
@@ -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,
index d009ab6a9565d489e251385f2b530cf4a8b63fff..fbd397976114b89a6cb684f74f6845ab8e5255a2 100644 (file)
@@ -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;
    }
 
index fcfb0870cb39697df70677dd26d4167b405ed059..9173e4910dcd0007967526aef33b2ae8d25593c9 100644 (file)
@@ -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)) {
index a70430812118dd9eea663b4eeca8e2e1ff473d4a..0a476b4c9042ee2331034d5194c2e0452cf1d26c 100644 (file)
@@ -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) {