]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
VMCI: switch to upstreamed Linux VMCI API for internal users, pt 2
authorVMware, Inc <>
Fri, 12 Apr 2013 19:48:49 +0000 (12:48 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Wed, 17 Apr 2013 19:16:54 +0000 (12:16 -0700)
Second part of the change to switch to the upstreamed API.  This one
tweaks the API for Linux only so that it matches exactly the one that
is upstreamed.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/modules/linux/shared/vmciKernelAPI1.h
open-vm-tools/modules/linux/vmci/common/vmciContext.c
open-vm-tools/modules/linux/vmci/common/vmciDriver.c
open-vm-tools/modules/linux/vmci/common/vmciEvent.c
open-vm-tools/modules/linux/vmci/linux/vmci_version.h
open-vm-tools/modules/linux/vsock/linux/af_vsock.c
open-vm-tools/modules/linux/vsock/linux/vsock_version.h

index bf8a00de30902fc44ae311918f63cc8b732c9f38..992c642daa7617fb2d2997e79c08b641a3ec7c2b 100644 (file)
@@ -84,7 +84,14 @@ int vmci_datagram_send(VMCIDatagram *msg);
 /* VMCI Utility API. */
 
 VMCIId vmci_get_context_id(void);
+
+#if defined(linux) && !defined(VMKERNEL)
+/* Returned value is a bool, 0 for false, 1 for true. */
+int vmci_is_context_owner(VMCIId contextID, uid_t uid);
+#else // !linux || VMKERNEL
+/* Returned value is a VMCI error code. */
 int vmci_is_context_owner(VMCIId contextID, void *hostUser);
+#endif // !linux || VMKERNEL
 
 uint32 vmci_version(void);
 int vmci_cid_2_host_vm_id(VMCIId contextID, void *hostVmID,
@@ -95,7 +102,10 @@ int vmci_cid_2_host_vm_id(VMCIId contextID, void *hostVmID,
 typedef void (*VMCI_EventCB)(VMCIId subID, VMCI_EventData *ed,
                              void *clientData);
 
-int vmci_event_subscribe(VMCI_Event event, uint32 flags,
+int vmci_event_subscribe(VMCI_Event event,
+#if !defined(linux) || defined(VMKERNEL)
+                         uint32 flags,
+#endif // !linux || VMKERNEL
                          VMCI_EventCB callback,
                          void *callbackData, VMCIId *subID);
 int vmci_event_unsubscribe(VMCIId subID);
index 147098d446dc249bad5ff183ae257ef672ba44ee..5a698e34e8a98e4333ab2325981293c5b43ebc85 100644 (file)
@@ -2195,7 +2195,8 @@ vmci_cid_2_host_vm_id(VMCIId contextID,    // IN
  *      user is the owner of the VM/VMX.
  *
  * Results:
- *      VMCI_SUCCESS if the hostUser is owner, error code otherwise.
+ *      Linux: 1 (true) if hostUser is owner, 0 (false) otherwise.
+ *      Other: VMCI_SUCCESS if the hostUser is owner, error code otherwise.
  *
  * Side effects:
  *      None.
@@ -2204,6 +2205,29 @@ vmci_cid_2_host_vm_id(VMCIId contextID,    // IN
  */
 
 VMCI_EXPORT_SYMBOL(vmci_is_context_owner)
+#if defined(linux) && !defined(VMKERNEL)
+int
+vmci_is_context_owner(VMCIId contextID,   // IN
+                      uid_t uid)          // IN
+{
+   int isOwner = 0;
+
+   if (VMCI_HostPersonalityActive()) {
+      VMCIContext *context = VMCIContext_Get(contextID);
+      if (context) {
+         if (context->validUser) {
+            if (VMCIHost_CompareUser((VMCIHostUser *)&uid,
+                                     &context->user) == VMCI_SUCCESS) {
+               isOwner = 1;
+            }
+         }
+         VMCIContext_Release(context);
+      }
+   }
+
+   return isOwner;
+}
+#else // !linux || VMKERNEL
 int
 vmci_is_context_owner(VMCIId contextID,   // IN
                       void *hostUser)     // IN
@@ -2237,6 +2261,7 @@ vmci_is_context_owner(VMCIId contextID,   // IN
    }
    return VMCI_ERROR_UNAVAILABLE;
 }
+#endif // !linux || VMKERNEL
 
 
 /*
index 73af8260e3fa9141c3c3880dcb2ad21f9df28842..1933019c021ea31ac5351c38bd43db972a41b1b6 100644 (file)
@@ -252,7 +252,10 @@ VMCIUtil_Init(void)
     * We subscribe to the VMCI_EVENT_CTX_ID_UPDATE here so we can update the
     * internal context id when needed.
     */
-   if (vmci_event_subscribe(VMCI_EVENT_CTX_ID_UPDATE, VMCI_FLAG_EVENT_NONE,
+   if (vmci_event_subscribe(VMCI_EVENT_CTX_ID_UPDATE,
+#if !defined(linux) || defined(VMKERNEL)
+                            VMCI_FLAG_EVENT_NONE,
+#endif // !linux || VMKERNEL
                             VMCIUtilCidUpdate, NULL,
                             &ctxUpdateSubID) < VMCI_SUCCESS) {
       VMCI_WARNING((LGPFX"Failed to subscribe to event (type=%d).\n",
index 750440a3e5b2846cbb8a2d36e47aa730bd5c365e..0d6a569c0b0a4ca5815acb5b195c4f04832ae2d6 100644 (file)
@@ -715,12 +715,17 @@ VMCIEventUnregisterSubscription(VMCIId subID)    // IN
 VMCI_EXPORT_SYMBOL(vmci_event_subscribe)
 int
 vmci_event_subscribe(VMCI_Event event,        // IN
+#if !defined(linux) || defined(VMKERNEL)
                      uint32 flags,            // IN
+#endif // !linux || VMKERNEL
                      VMCI_EventCB callback,   // IN
                      void *callbackData,      // IN
                      VMCIId *subscriptionID)  // OUT
 {
    int retval;
+#if defined(linux) && !defined(VMKERNEL)
+   uint32 flags = VMCI_FLAG_EVENT_NONE;
+#endif // linux && !VMKERNEL
    VMCISubscription *s = NULL;
 
    if (subscriptionID == NULL) {
index 1d189b79cf2e050c1d05dd30ac27bcbb5fc06fcc..441fb74946a0b1a2b450af3a01e1f8c09f04270b 100644 (file)
@@ -25,8 +25,8 @@
 #ifndef _VMCI_VERSION_H_
 #define _VMCI_VERSION_H_
 
-#define VMCI_DRIVER_VERSION          9.5.15.0
-#define VMCI_DRIVER_VERSION_COMMAS   9,5,15,0
-#define VMCI_DRIVER_VERSION_STRING   "9.5.15.0"
+#define VMCI_DRIVER_VERSION          9.5.16.0
+#define VMCI_DRIVER_VERSION_COMMAS   9,5,16,0
+#define VMCI_DRIVER_VERSION_STRING   "9.5.16.0"
 
 #endif /* _VMCI_VERSION_H_ */
index 288be550795f5cef24c8650cf145eaab8860bb07..c3a0e4dc57f0db1e5ef3b3e0c24e65ac4fe0e88e 100644 (file)
@@ -541,15 +541,7 @@ Bool
 VSockVmciTrusted(VSockVmciSock *vsock, // IN: Local socket
                  VMCIId peerCid)       // IN: Context ID of peer
 {
-   int res;
-
-   if (vsock->trusted) {
-      return TRUE;
-   }
-
-   res = vmci_is_context_owner(peerCid, &vsock->owner);
-
-   return res == VMCI_SUCCESS;
+   return vsock->trusted || vmci_is_context_owner(peerCid, vsock->owner);
 }
 
 
@@ -1848,7 +1840,6 @@ VSockVmciRecvConnectingServer(struct sock *listener, // IN: the listening socket
     * specifying the ATTACH_ONLY flag below.
     */
    err = vmci_event_subscribe(VMCI_EVENT_QP_PEER_DETACH,
-                              VMCI_FLAG_EVENT_NONE,
                               VSockVmciPeerDetachCB,
                               pending,
                               &detachSubId);
@@ -2196,7 +2187,6 @@ VSockVmciRecvConnectingClientNegotiate(struct sock *sk,   // IN: socket
     * once and add a way to lookup sockets by queue pair handle.
     */
    err = vmci_event_subscribe(VMCI_EVENT_QP_PEER_ATTACH,
-                              VMCI_FLAG_EVENT_NONE,
                               VSockVmciPeerAttachCB,
                               sk,
                               &attachSubId);
@@ -2206,7 +2196,6 @@ VSockVmciRecvConnectingClientNegotiate(struct sock *sk,   // IN: socket
    }
 
    err = vmci_event_subscribe(VMCI_EVENT_QP_PEER_DETACH,
-                              VMCI_FLAG_EVENT_NONE,
                               VSockVmciPeerDetachCB,
                               sk,
                               &detachSubId);
@@ -3284,7 +3273,6 @@ VSockVmciRegisterWithVmci(void)
    }
 
    err = vmci_event_subscribe(VMCI_EVENT_QP_RESUMED,
-                              VMCI_FLAG_EVENT_NONE,
                               VSockVmciQPResumedCB,
                               NULL,
                               &qpResumedSubId);
index 7d2514c953dc11bd87df149286a1e2049cc93ce3..49b3ba2db421265f2eeef06fe4e43a01086d265a 100644 (file)
@@ -25,8 +25,8 @@
 #ifndef _VSOCK_VERSION_H_
 #define _VSOCK_VERSION_H_
 
-#define VSOCK_DRIVER_VERSION          9.5.8.0
-#define VSOCK_DRIVER_VERSION_COMMAS   9,5,8,0
-#define VSOCK_DRIVER_VERSION_STRING   "9.5.8.0"
+#define VSOCK_DRIVER_VERSION          9.5.9.0
+#define VSOCK_DRIVER_VERSION_COMMAS   9,5,9,0
+#define VSOCK_DRIVER_VERSION_STRING   "9.5.9.0"
 
 #endif /* _VSOCK_VERSION_H_ */