From: VMware, Inc <> Date: Tue, 29 Mar 2011 18:56:33 +0000 (-0700) Subject: Split VMCI_Init() into shared and host part. X-Git-Tag: 2011.03.28-387002~71 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ca1a673f8d4ca5bcbaea5915a42571ef28443f7;p=thirdparty%2Fopen-vm-tools.git Split VMCI_Init() into shared and host part. 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 --- diff --git a/open-vm-tools/modules/linux/vmci/vmciDriver.c b/open-vm-tools/modules/linux/vmci/vmciDriver.c index 9b9803922..81e8fc04d 100644 --- a/open-vm-tools/modules/linux/vmci/vmciDriver.c +++ b/open-vm-tools/modules/linux/vmci/vmciDriver.c @@ -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(); +} diff --git a/open-vm-tools/modules/linux/vmci/vmciDriver.h b/open-vm-tools/modules/linux/vmci/vmciDriver.h index cf18e9eac..52b010a51 100644 --- a/open-vm-tools/modules/linux/vmci/vmciDriver.h +++ b/open-vm-tools/modules/linux/vmci/vmciDriver.h @@ -76,8 +76,10 @@ #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);