]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Split VMCI_Init() into shared and host part.
authorVMware, Inc <>
Tue, 29 Mar 2011 18:56:33 +0000 (11:56 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 29 Mar 2011 18:56:33 +0000 (11:56 -0700)
The initialization routine for the VMCI components in
vmciDriver.c covers both components shared between guest and
host, and components only relevant to the host. This change
splits them into two routines, and updates the host drivers to
use the new two routines.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/modules/linux/vmci/vmciDriver.c
open-vm-tools/modules/linux/vmci/vmciDriver.h

index 9b980392292b30255832352d62afafcccb2c9ad6..81e8fc04d27010eb3e1960d5f76e0478951270e8 100644 (file)
@@ -56,9 +56,9 @@ static VMCIContext *hostContext;
 /*
  *----------------------------------------------------------------------
  *
- * VMCI_Init --
+ * VMCI_HostInit --
  *
- *      Initializes VMCI. This registers core hypercalls.
+ *      Initializes the host driver specific components of VMCI.
  *
  * Results:
  *      VMCI_SUCCESS if successful, appropriate error code otherwise.
@@ -70,31 +70,10 @@ static VMCIContext *hostContext;
  */
 
 int
-VMCI_Init(void)
+VMCI_HostInit(void)
 {
    int result;
 
-   result = VMCIResource_Init();
-   if (result < VMCI_SUCCESS) {
-      VMCI_WARNING((LGPFX"Failed to initialize VMCIResource (result=%d)",
-                    result));
-      goto errorExit;
-   }
-
-   result = VMCIContext_Init();
-   if (result < VMCI_SUCCESS) {
-      VMCI_WARNING((LGPFX"Failed to initialize VMCIContext (result=%d)",
-                    result));
-      goto resourceExit;
-   }
-
-   result = VMCIDatagram_Init();
-   if (result < VMCI_SUCCESS) {
-      VMCI_WARNING((LGPFX"Failed to initialize VMCIDatagram (result=%d)",
-                    result));
-      goto contextExit;
-   }
-
    /*
     * In theory, it is unsafe to pass an eventHnd of -1 to platforms which use
     * it (VMKernel/Windows/Mac OS at the time of this writing). In practice we
@@ -107,12 +86,9 @@ VMCI_Init(void)
    if (result < VMCI_SUCCESS) {
       VMCI_WARNING((LGPFX"Failed to initialize VMCIContext (result=%d)",
                     result));
-      goto datagramExit;
+      goto errorExit;
    }
 
-   VMCIEvent_Init();
-   VMCIDoorbell_Init();
-
    result = VMCIQPBroker_Init();
    if (result < VMCI_SUCCESS) {
       goto hostContextExit;
@@ -122,15 +98,7 @@ VMCI_Init(void)
    return VMCI_SUCCESS;
 
   hostContextExit:
-   VMCIDoorbell_Exit();
-   VMCIEvent_Exit();
    VMCIContext_ReleaseContext(hostContext);
-  datagramExit:
-   VMCIDatagram_Exit();
-  contextExit:
-   VMCIContext_Exit();
-  resourceExit:
-   VMCIResource_Exit();
   errorExit:
    return result;
 }
@@ -139,9 +107,9 @@ VMCI_Init(void)
 /*
  *----------------------------------------------------------------------
  *
- * VMCI_Cleanup --
+ * VMCI_HostCleanup --
  *
- *      Cleanup the  VMCI module.
+ *      Cleans up the host specific components of the VMCI module.
  *
  * Results:
  *      None.
@@ -153,14 +121,9 @@ VMCI_Init(void)
  */
 
 void
-VMCI_Cleanup(void)
+VMCI_HostCleanup(void)
 {
-   VMCIDoorbell_Exit();
-   VMCIEvent_Exit();
    VMCIContext_ReleaseContext(hostContext);
-   VMCIDatagram_Exit();
-   VMCIContext_Exit();
-   VMCIResource_Exit();
    VMCIQPBroker_Exit();
 }
 
@@ -726,3 +689,89 @@ VMCI_Version()
 {
    return VMCI_VERSION;
 }
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCI_SharedInit --
+ *
+ *      Initializes VMCI components shared between guest and host
+ *      driver. This registers core hypercalls.
+ *
+ * Results:
+ *      VMCI_SUCCESS if successful, appropriate error code otherwise.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+VMCI_SharedInit(void)
+{
+   int result;
+
+   result = VMCIResource_Init();
+   if (result < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to initialize VMCIResource (result=%d)",
+                    result));
+      goto errorExit;
+   }
+
+   result = VMCIContext_Init();
+   if (result < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to initialize VMCIContext (result=%d)",
+                    result));
+      goto resourceExit;
+   }
+
+   result = VMCIDatagram_Init();
+   if (result < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to initialize VMCIDatagram (result=%d)",
+                    result));
+      goto contextExit;
+   }
+
+   VMCIEvent_Init();
+   VMCIDoorbell_Init();
+
+   VMCI_LOG((LGPFX"Driver initialized."));
+   return VMCI_SUCCESS;
+
+  contextExit:
+   VMCIContext_Exit();
+  resourceExit:
+   VMCIResource_Exit();
+  errorExit:
+   return result;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCI_SharedCleanup --
+ *
+ *      Cleans up VMCI components shared between guest and host
+ *      driver.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+VMCI_SharedCleanup(void)
+{
+   VMCIDoorbell_Exit();
+   VMCIEvent_Exit();
+   VMCIDatagram_Exit();
+   VMCIContext_Exit();
+   VMCIResource_Exit();
+}
index cf18e9eac4f251bc8fe2c02d8459308759452eba..52b010a51673fdca30799abe3d5bbddc6f39ac9c 100644 (file)
 #endif // _WIN32
 
 
-int VMCI_Init(void);
-void VMCI_Cleanup(void);
+int VMCI_SharedInit(void);
+void VMCI_SharedCleanup(void);
+int VMCI_HostInit(void);
+void VMCI_HostCleanup(void);
 VMCIId VMCI_GetContextID(void);
 int VMCI_SendDatagram(VMCIDatagram *dg);