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>
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)
# 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);
static VMCIId ctxUpdateSubID = VMCI_INVALID_ID;
static VMCIContext *hostContext;
static Atomic_uint32 vmContextID = { VMCI_INVALID_ID };
-static Atomic_uint32 vmciClientCount;
/*
}
+#if !defined(_WIN32)
/*
*----------------------------------------------------------------------
*
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;
}
void
VMCI_DeviceRelease(void)
{
- Atomic_Dec32(&vmciClientCount);
}
+#endif // !_WIN32
/*
}
-/*
- *----------------------------------------------------------------------
- *
- * 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;
-}
-
-
/*
*----------------------------------------------------------------------
*
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,
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;
}
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)) {
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;
}
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) {