From: VMware, Inc <> Date: Tue, 24 Aug 2010 17:49:44 +0000 (-0700) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2010.08.24-292196~83 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e217ba2c742e197e09b5602cb64d8594f7f0d98;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/modules/linux/shared/vmciKernelAPI.h b/open-vm-tools/modules/linux/shared/vmciKernelAPI.h index 2633907a8..953c31758 100644 --- a/open-vm-tools/modules/linux/shared/vmciKernelAPI.h +++ b/open-vm-tools/modules/linux/shared/vmciKernelAPI.h @@ -132,7 +132,8 @@ ssize_t VMCIQPair_Peek(VMCIQPair *qpair, int mode); #if defined (SOLARIS) || (defined(__APPLE__) && !defined (VMX86_TOOLS)) || \ - (defined(__linux__) && defined(__KERNEL__)) + (defined(__linux__) && defined(__KERNEL__)) || \ + (defined(_WIN32) && defined(WINNT_DDK)) /* * Environments that support struct iovec */ diff --git a/open-vm-tools/modules/linux/shared/vmci_infrastructure.h b/open-vm-tools/modules/linux/shared/vmci_infrastructure.h index 9de8600a2..b05892f4e 100644 --- a/open-vm-tools/modules/linux/shared/vmci_infrastructure.h +++ b/open-vm-tools/modules/linux/shared/vmci_infrastructure.h @@ -46,6 +46,12 @@ typedef enum { VMCIOBJ_NOT_SET, } VMCIObjType; +/* For storing VMCI structures in file handles. */ +typedef struct VMCIObj { + void *ptr; + VMCIObjType type; +} VMCIObj; + /* Guestcalls currently support a maximum of 8 uint64 arguments. */ #define VMCI_GUESTCALL_MAX_ARGS_SIZE 64 diff --git a/open-vm-tools/modules/linux/shared/vmci_iocontrols.h b/open-vm-tools/modules/linux/shared/vmci_iocontrols.h index ef3b9d42c..d2e94e436 100644 --- a/open-vm-tools/modules/linux/shared/vmci_iocontrols.h +++ b/open-vm-tools/modules/linux/shared/vmci_iocontrols.h @@ -362,14 +362,6 @@ enum IOCTLCmd_VMCI { VMCIIOCTL_BUFFERED(SOCKETS_SHUTDOWN) /* END VMCI SOCKETS */ - -/* - * For accessing VMCIOBJ_SOCKET in IOCTLs. Both functions take a file object's - * fs context and get or set the socket. - */ -PVOID VMCIFsContext_GetSocket(PVOID fsContext); -void VMCIFsContext_SetSocket(PVOID fsContext, PVOID socket); - #endif // _WIN32 diff --git a/open-vm-tools/modules/linux/vmci/vmciQPair.c b/open-vm-tools/modules/linux/vmci/vmciQPair.c index 6ea9a3fd9..92ac7e167 100644 --- a/open-vm-tools/modules/linux/vmci/vmciQPair.c +++ b/open-vm-tools/modules/linux/vmci/vmciQPair.c @@ -815,7 +815,8 @@ EXPORT_SYMBOL(VMCIQPair_Peek); #if defined (SOLARIS) || (defined(__APPLE__) && !defined (VMX86_TOOLS)) || \ - (defined(__linux__) && defined(__KERNEL__)) + (defined(__linux__) && defined(__KERNEL__)) || \ + (defined(_WIN32) && defined(WINNT_DDK)) /* *----------------------------------------------------------------------------- @@ -840,7 +841,7 @@ VMCIQPair_EnqueueV(VMCIQPair *qpair, // IN size_t iovSize, // IN int bufType) // IN { - int64 result; + ssize_t result; VMCIQPairLock(qpair); @@ -879,7 +880,7 @@ VMCIQPair_DequeueV(VMCIQPair *qpair, // IN size_t iovSize, // IN int bufType) // IN { - int64 result; + ssize_t result; VMCIQPairLock(qpair); @@ -920,7 +921,7 @@ VMCIQPair_PeekV(VMCIQPair *qpair, // IN size_t iovSize, // IN int bufType) // IN { - int64 result; + ssize_t result; VMCIQPairLock(qpair); diff --git a/open-vm-tools/modules/linux/vmci/vmciQueue.h b/open-vm-tools/modules/linux/vmci/vmciQueue.h index c991f804c..b75dd06e5 100644 --- a/open-vm-tools/modules/linux/vmci/vmciQueue.h +++ b/open-vm-tools/modules/linux/vmci/vmciQueue.h @@ -102,6 +102,18 @@ typedef int VMCIMemcpyFromQueueFunc(void *dest, size_t destOffset, size_t size, BUF_TYPE bufType); +#if defined(_WIN32) && defined(WINNT_DDK) +/* + * Windows needs iovec for the V functions. We use an MDL for the actual + * buffers, but we also have an offset that comes from WSK_BUF. + */ +typedef struct iovec { + PMDL mdl; // List of memory descriptors. + ULONG offset; // Base offset. +}; +#endif // _WIN32 && WINNT_DDK + + /* *----------------------------------------------------------------------------- * @@ -128,12 +140,8 @@ int VMCIMemcpyFromQueue(void *dest, size_t destOffset, const VMCIQueue *queue, #if defined VMKERNEL || defined (SOLARIS) || \ (defined(__APPLE__) && !defined (VMX86_TOOLS)) || \ - (defined(__linux__) && defined(__KERNEL__)) - - /* - * Solaris/Mac/Linux vmciKernelIf.c files provide these functions - */ - + (defined(__linux__) && defined(__KERNEL__)) || \ + (defined(_WIN32) && defined(WINNT_DDK)) int VMCIMemcpyToQueueV(VMCIQueue *queue, uint64 queueOffset, const void *src, size_t srcOffset, size_t size, BUF_TYPE bufType); int VMCIMemcpyFromQueueV(void *dest, size_t destOffset, const VMCIQueue *queue, diff --git a/open-vm-tools/modules/linux/vsock/linux/vsockCommon.h b/open-vm-tools/modules/linux/vsock/linux/vsockCommon.h index 411843073..aa79747ea 100644 --- a/open-vm-tools/modules/linux/vsock/linux/vsockCommon.h +++ b/open-vm-tools/modules/linux/vsock/linux/vsockCommon.h @@ -81,6 +81,7 @@ #include "vmware.h" #include "vmci_defs.h" #include "vmci_call_defs.h" +#include "vmci_infrastructure.h" #include "vmci_sockets_int.h" #include "vmci_sockets.h" diff --git a/open-vm-tools/modules/linux/vsock/linux/vsockVmci.h b/open-vm-tools/modules/linux/vsock/linux/vsockVmci.h index bedefdef6..88331b34b 100644 --- a/open-vm-tools/modules/linux/vsock/linux/vsockVmci.h +++ b/open-vm-tools/modules/linux/vsock/linux/vsockVmci.h @@ -100,5 +100,61 @@ VSockVmci_ErrorToVSockError(int32 vmciError) // IN } +/* + *---------------------------------------------------------------------------- + * + * VSockVmci_GetVmciObjSocket -- + * + * Get a socket from a VMCI object, but only if the object is of the + * appropriate type. + * + * Results: + * A socket if the object is of the correct type, NULL otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +static INLINE void * +VSockVmci_GetVmciObjSocket(VMCIObj *obj) // IN +{ + ASSERT(obj); + if (NULL != obj->ptr && VMCIOBJ_SOCKET == obj->type) { + return obj->ptr; + } + return NULL; +} + + +/* + *---------------------------------------------------------------------------- + * + * VSockVmci_SetVmciObjSocket -- + * + * Set the socket in a VMCI object. This will also set the type + * accordingly. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------------- + */ + +static INLINE void +VSockVmci_SetVmciObjSocket(VMCIObj *obj, // OUT + void *s) // IN +{ + ASSERT(obj); + ASSERT(s); + obj->ptr = s; + obj->type = VMCIOBJ_SOCKET; +} + + #endif // _VSOCK_VMCI_H_