[libvirt] [PATCH 0/5] Outline of rewriting vbox driver, with common code support.

Michal asked me to try working out a sample of vbox driver's common code. Here it is. As the PATCHv2 is pending, I merged it. Taowei (5): define interface with vbox_common a sample of vbox_common function : vboxInitialize implement vboxUniformedAPI in vbox_tmpl.c and remove common codes install vbox api register in vbox_driver make new files be compiled by libvirt po/POTFILES.in | 1 + src/Makefile.am | 4 +- src/vbox/vbox_common.c | 89 ++++++++++++++++++++++++++++ src/vbox/vbox_common.h | 108 ++++++++++++++++++++++++++++++++++ src/vbox/vbox_commondef.h | 32 ++++++++++ src/vbox/vbox_driver.c | 35 +++++++++-- src/vbox/vbox_tmpl.c | 142 +++++++++++++++++---------------------------- 7 files changed, 316 insertions(+), 95 deletions(-) create mode 100644 src/vbox/vbox_common.c create mode 100644 src/vbox/vbox_common.h create mode 100644 src/vbox/vbox_commondef.h -- 1.7.9.5

The vboxGlobalData and the vboxUniformedAPI is defined here. It defines the middle layer interface. When using this file, it needs a context to explain how *.c files treat vbox structs in vboxGlobalData(vboxObj, vboxSession and so on). See annotate in this file. --- src/vbox/vbox_common.h | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/vbox/vbox_common.h diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h new file mode 100644 index 0000000..eba360e --- /dev/null +++ b/src/vbox/vbox_common.h @@ -0,0 +1,108 @@ +/* + * Copyright 2014, Taowei Luo (uaedante@gmail.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include "internal.h" + +/* This file may be used in three place. That is vbox_tmpl.c, + * vbox_common.c and vbox_driver.c. Two important things is defined + * here, which is vboxGlobalData and vboxUniformedAPI. + * + * The vbox_tmpl.c is the only place where the driver knows the inside + * architecture of those vbox structs(vboxObj, vboxSession, + * pFuncs, vboxCallback and vboxQueue). The file should be included + * after the currect vbox_CAPI_v*.h, then we can use the vbox structs + * in vboxGlobalData. The vbox_tmpl.c should implement functions + * defined in vboxUniformedAPI. + * + * In vbox_driver.c, it is used to define the struct vboxUniformedAPI. + * The vbox_driver.c collects vboxUniformedAPI for all versions. + * Then vboxRegister calls the vboxRegisterUniformedAPI to register. + * Note: In vbox_driver.c, the vbox structs in vboxGlobalData is + * defined by vbox_CAPI_v2.2.h. + * + * The vbox_common.c, it is used to generate common codes for all vbox + * versions. Bacause the same member varible's offset in a vbox struct + * may change between different vbox versions. The vbox_common.c + * shouldn't directly use struct's member varibles defined in + * vbox_CAPI_v*.h. To make things safety, we include the + * vbox_commondef.h in vbox_common.c. In this case, we treat structs + * defined by vbox as a void*. The common codes don't concern about + * the inside of this structs(actually, we can't, in the common level). + * With the help of vboxUniformed API, we call VirtualBox's API and + * implement the vbox driver in a high level. + * + * In conclusion: + * * In vbox_tmpl.c, this file is included after vbox_CAPI_v*.h + * * In vbox_driver.c, this file is included after vbox_glue.h + * * In vbox_common.c, this file is included after vbox_commondef.h + * + */ + +typedef struct { + virMutex lock; + unsigned long version; + + virCapsPtr caps; + virDomainXMLOptionPtr xmlopt; + + IVirtualBox *vboxObj; + ISession *vboxSession; + + /** Our version specific API table pointer. */ + PCVBOXXPCOM pFuncs; + + /* The next is used when VBOX_API_VERSION > 2002000 */ + /* Async event handling */ + virObjectEventStatePtr domainEvents; + int fdWatch; +# if VBOX_API_VERSION > 2002000 && VBOX_API_VERSION <= 3002000 + /* IVirtualBoxCallback is used in VirtualBox 3.x only */ + IVirtualBoxCallback *vboxCallback; +# else /* VBOX_API_VERSION > 2002000 && VBOX_API_VERSION <= 3002000 */ + void *vboxCallback; +# endif /* VBOX_API_VERSION > 2002000 && VBOX_API_VERSION <= 3002000 */ + +# if VBOX_API_VERSION > 2002000 + nsIEventQueue *vboxQueue; +# else /* VBOX_API_VERSION == 2002000 or undefined */ + void *vboxQueue; +# endif /* VBOX_API_VERSION == 2002000 or undefined */ + int volatile vboxCallBackRefCount; + + /* pointer back to the connection */ + virConnectPtr conn; + +} vboxGlobalData; + +/* vboxUniformedAPI gives vbox_common.c a uniformed layer to see + * vbox API. + */ +typedef struct { + /* vbox API version */ + uint32_t uVersion; + /* vbox APIs */ + int (*pfnInitialize)(vboxGlobalData *data); + int (*initializeFWatch)(vboxGlobalData *data); + /* vbox API features */ + bool fWatchNeedInitialize; +} vboxUniformedAPI; + +/* Register the vboxUniformedAPI based on the current vbox version */ +void vboxRegisterUniformedAPI(vboxUniformedAPI *vboxAPI); + +int vboxInitialize(vboxGlobalData *data); -- 1.7.9.5

On 23.06.2014 06:25, Taowei wrote:
The vboxGlobalData and the vboxUniformedAPI is defined here. It defines the middle layer interface. When using this file, it needs a context to explain how *.c files treat vbox structs in vboxGlobalData(vboxObj, vboxSession and so on). See annotate in this file.
--- src/vbox/vbox_common.h | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/vbox/vbox_common.h
Introducing a new file should be followed by Makefile.am change not a separate patch like 5/5.
diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h new file mode 100644 index 0000000..eba360e --- /dev/null +++ b/src/vbox/vbox_common.h @@ -0,0 +1,108 @@ +/* + * Copyright 2014, Taowei Luo (uaedante@gmail.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include "internal.h" + +/* This file may be used in three place. That is vbox_tmpl.c, + * vbox_common.c and vbox_driver.c. Two important things is defined + * here, which is vboxGlobalData and vboxUniformedAPI. + * + * The vbox_tmpl.c is the only place where the driver knows the inside + * architecture of those vbox structs(vboxObj, vboxSession, + * pFuncs, vboxCallback and vboxQueue). The file should be included + * after the currect vbox_CAPI_v*.h, then we can use the vbox structs + * in vboxGlobalData. The vbox_tmpl.c should implement functions + * defined in vboxUniformedAPI. + * + * In vbox_driver.c, it is used to define the struct vboxUniformedAPI. + * The vbox_driver.c collects vboxUniformedAPI for all versions. + * Then vboxRegister calls the vboxRegisterUniformedAPI to register. + * Note: In vbox_driver.c, the vbox structs in vboxGlobalData is + * defined by vbox_CAPI_v2.2.h. + * + * The vbox_common.c, it is used to generate common codes for all vbox + * versions. Bacause the same member varible's offset in a vbox struct + * may change between different vbox versions. The vbox_common.c + * shouldn't directly use struct's member varibles defined in + * vbox_CAPI_v*.h. To make things safety, we include the + * vbox_commondef.h in vbox_common.c. In this case, we treat structs + * defined by vbox as a void*. The common codes don't concern about + * the inside of this structs(actually, we can't, in the common level). + * With the help of vboxUniformed API, we call VirtualBox's API and + * implement the vbox driver in a high level. + * + * In conclusion: + * * In vbox_tmpl.c, this file is included after vbox_CAPI_v*.h + * * In vbox_driver.c, this file is included after vbox_glue.h + * * In vbox_common.c, this file is included after vbox_commondef.h + * + */ + +typedef struct { + virMutex lock; + unsigned long version; + + virCapsPtr caps; + virDomainXMLOptionPtr xmlopt; + + IVirtualBox *vboxObj; + ISession *vboxSession; + + /** Our version specific API table pointer. */ + PCVBOXXPCOM pFuncs; + + /* The next is used when VBOX_API_VERSION > 2002000 */ + /* Async event handling */ + virObjectEventStatePtr domainEvents; + int fdWatch; +# if VBOX_API_VERSION > 2002000 && VBOX_API_VERSION <= 3002000 + /* IVirtualBoxCallback is used in VirtualBox 3.x only */ + IVirtualBoxCallback *vboxCallback; +# else /* VBOX_API_VERSION > 2002000 && VBOX_API_VERSION <= 3002000 */ + void *vboxCallback; +# endif /* VBOX_API_VERSION > 2002000 && VBOX_API_VERSION <= 3002000 */ + +# if VBOX_API_VERSION > 2002000 + nsIEventQueue *vboxQueue; +# else /* VBOX_API_VERSION == 2002000 or undefined */ + void *vboxQueue; +# endif /* VBOX_API_VERSION == 2002000 or undefined */
Consider installing ccpi to catch errors like these. We are not in a ifdef block, so there's no need to put a space in between hash and if.
+ int volatile vboxCallBackRefCount; + + /* pointer back to the connection */ + virConnectPtr conn; + +} vboxGlobalData; + +/* vboxUniformedAPI gives vbox_common.c a uniformed layer to see + * vbox API. + */ +typedef struct { + /* vbox API version */ + uint32_t uVersion; + /* vbox APIs */ + int (*pfnInitialize)(vboxGlobalData *data); + int (*initializeFWatch)(vboxGlobalData *data); + /* vbox API features */ + bool fWatchNeedInitialize; +} vboxUniformedAPI; + +/* Register the vboxUniformedAPI based on the current vbox version */ +void vboxRegisterUniformedAPI(vboxUniformedAPI *vboxAPI); + +int vboxInitialize(vboxGlobalData *data);

This is a example of how common codes work. The file vbox_commondef.h tells the common codes to treat vbox structs defined in vbox_common.h as a void* type. --- src/vbox/vbox_common.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ src/vbox/vbox_commondef.h | 32 ++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/vbox/vbox_common.c create mode 100644 src/vbox/vbox_commondef.h diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c new file mode 100644 index 0000000..1bf4292 --- /dev/null +++ b/src/vbox/vbox_common.c @@ -0,0 +1,89 @@ +/* + * Copyright 2014, Taowei Luo (uaedante@gmail.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include <config.h> + +#include <unistd.h> + +#include "internal.h" +#include "datatypes.h" +#include "domain_conf.h" +#include "network_conf.h" +#include "virerror.h" +#include "domain_event.h" +#include "storage_conf.h" +#include "virstoragefile.h" +#include "viruuid.h" +#include "viralloc.h" +#include "nodeinfo.h" +#include "virlog.h" +#include "vbox_driver.h" +#include "configmake.h" +#include "virfile.h" +#include "fdstream.h" +#include "viruri.h" +#include "virstring.h" +#include "virtime.h" +#include "virutil.h" + +#include "vbox_commondef.h" +#include "vbox_common.h" + +/* Common codes for vbox driver. With the define of vbox_commondef.h, + * it treats vbox structs as a void*. Though vboxUniformedAPI + * it call vbox functions. This file is a high level implement about + * the vbox driver. + */ + +#define VIR_FROM_THIS VIR_FROM_VBOX + +VIR_LOG_INIT("vbox.vbox_common"); + +static vboxUniformedAPI *pVBoxAPI; + +void vboxRegisterUniformedAPI(vboxUniformedAPI *vboxAPI) +{ + VIR_DEBUG("VirtualBox Uniformed API has been registered"); + pVBoxAPI = vboxAPI; +} + +int vboxInitialize(vboxGlobalData *data) +{ + if (pVBoxAPI->pfnInitialize(data) != 0) + goto cleanup; + + if (pVBoxAPI->fWatchNeedInitialize && pVBoxAPI->initializeFWatch(data) != 0) + goto cleanup; + + if (data->vboxObj == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("IVirtualBox object is null")); + goto cleanup; + } + + if (data->vboxSession == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("ISession object is null")); + goto cleanup; + } + + return 0; + + cleanup: + return -1; +} diff --git a/src/vbox/vbox_commondef.h b/src/vbox/vbox_commondef.h new file mode 100644 index 0000000..e54e729 --- /dev/null +++ b/src/vbox/vbox_commondef.h @@ -0,0 +1,32 @@ +/* + * Copyright 2014, Taowei Luo (uaedante@gmail.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include "internal.h" + +/* This is a pesudo-define of some types in vboxGlobalData + * It is ONLY used to generate vboxGlobalData for + * vbox_common.h. It can't be included with files such as + * vbox_CAPI_v*.h, which may cause type conflicts. + * You can see the more information in vbox_common.h + */ + +typedef void IVirtualBox; +typedef void ISession; +typedef void const *PCVBOXXPCOM; +typedef void IVirtualBoxCallback; +typedef void nsIEventQueue; -- 1.7.9.5

On 23.06.2014 06:25, Taowei wrote:
This is a example of how common codes work. The file vbox_commondef.h tells the common codes to treat vbox structs defined in vbox_common.h as a void* type.
--- src/vbox/vbox_common.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ src/vbox/vbox_commondef.h | 32 ++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 src/vbox/vbox_common.c create mode 100644 src/vbox/vbox_commondef.h
Again, src/Makefile.am change is missing.
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c new file mode 100644 index 0000000..1bf4292 --- /dev/null +++ b/src/vbox/vbox_common.c @@ -0,0 +1,89 @@ +/* + * Copyright 2014, Taowei Luo (uaedante@gmail.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include <config.h> + +#include <unistd.h> + +#include "internal.h" +#include "datatypes.h" +#include "domain_conf.h" +#include "network_conf.h" +#include "virerror.h" +#include "domain_event.h" +#include "storage_conf.h" +#include "virstoragefile.h" +#include "viruuid.h" +#include "viralloc.h" +#include "nodeinfo.h" +#include "virlog.h" +#include "vbox_driver.h" +#include "configmake.h" +#include "virfile.h" +#include "fdstream.h" +#include "viruri.h" +#include "virstring.h" +#include "virtime.h" +#include "virutil.h"
Wow, so much include. I'd say many of this is unused.
+ +#include "vbox_commondef.h" +#include "vbox_common.h" + +/* Common codes for vbox driver. With the define of vbox_commondef.h, + * it treats vbox structs as a void*. Though vboxUniformedAPI + * it call vbox functions. This file is a high level implement about + * the vbox driver. + */ + +#define VIR_FROM_THIS VIR_FROM_VBOX + +VIR_LOG_INIT("vbox.vbox_common"); + +static vboxUniformedAPI *pVBoxAPI; + +void vboxRegisterUniformedAPI(vboxUniformedAPI *vboxAPI) +{ + VIR_DEBUG("VirtualBox Uniformed API has been registered"); + pVBoxAPI = vboxAPI; +} + +int vboxInitialize(vboxGlobalData *data) +{ + if (pVBoxAPI->pfnInitialize(data) != 0) + goto cleanup; + + if (pVBoxAPI->fWatchNeedInitialize && pVBoxAPI->initializeFWatch(data) != 0) + goto cleanup; + + if (data->vboxObj == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("IVirtualBox object is null"));
This implies the change you made in 5/5. However, the change needs to be dragged into this patch.
+ goto cleanup; + } + + if (data->vboxSession == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("ISession object is null")); + goto cleanup; + } + + return 0; + + cleanup: + return -1; +} diff --git a/src/vbox/vbox_commondef.h b/src/vbox/vbox_commondef.h new file mode 100644 index 0000000..e54e729 --- /dev/null +++ b/src/vbox/vbox_commondef.h @@ -0,0 +1,32 @@ +/* + * Copyright 2014, Taowei Luo (uaedante@gmail.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include "internal.h" + +/* This is a pesudo-define of some types in vboxGlobalData + * It is ONLY used to generate vboxGlobalData for + * vbox_common.h. It can't be included with files such as + * vbox_CAPI_v*.h, which may cause type conflicts. + * You can see the more information in vbox_common.h + */ + +typedef void IVirtualBox; +typedef void ISession; +typedef void const *PCVBOXXPCOM; +typedef void IVirtualBoxCallback; +typedef void nsIEventQueue;

Version specified codes for vboxUniformedAPI is implemented here, almost the same as PATCHv2. Common codes are moved to vbox_common.h and vbox_common.c. --- src/vbox/vbox_tmpl.c | 142 ++++++++++++++++++-------------------------------- 1 file changed, 52 insertions(+), 90 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 4ba9ad7..c2a83d1 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -87,9 +87,9 @@ # error "Unsupport VBOX_API_VERSION" #endif -/* Include this *last* or we'll get the wrong vbox_CAPI_*.h. */ +/* Include thses *last* or we'll get the wrong vbox_CAPI_*.h. */ #include "vbox_glue.h" - +#include "vbox_common.h" #define VIR_FROM_THIS VIR_FROM_VBOX @@ -203,42 +203,6 @@ if (strUtf16) {\ (unsigned)(iid)->m3[7]);\ }\ -typedef struct { - virMutex lock; - unsigned long version; - - virCapsPtr caps; - virDomainXMLOptionPtr xmlopt; - - IVirtualBox *vboxObj; - ISession *vboxSession; - - /** Our version specific API table pointer. */ - PCVBOXXPCOM pFuncs; - -#if VBOX_API_VERSION == 2002000 - -} vboxGlobalData; - -#else /* !(VBOX_API_VERSION == 2002000) */ - - /* Async event handling */ - virObjectEventStatePtr domainEvents; - int fdWatch; - -# if VBOX_API_VERSION <= 3002000 - /* IVirtualBoxCallback is used in VirtualBox 3.x only */ - IVirtualBoxCallback *vboxCallback; -# endif /* VBOX_API_VERSION <= 3002000 */ - - nsIEventQueue *vboxQueue; - int volatile vboxCallBackRefCount; - - /* pointer back to the connection */ - virConnectPtr conn; - -} vboxGlobalData; - /* g_pVBoxGlobalData has to be global variable, * there is no other way to make the callbacks * work other then having g_pVBoxGlobalData as @@ -249,6 +213,8 @@ typedef struct { * them that way */ +#if VBOX_API_VERSION > 2002000 + static vboxGlobalData *g_pVBoxGlobalData = NULL; #endif /* !(VBOX_API_VERSION == 2002000) */ @@ -826,6 +792,54 @@ static PRUnichar *PRUnicharFromInt(int n) { #endif /* !(VBOX_API_VERSION == 2002000) */ +/* Begin of vboxUniformedAPI */ + +static int _pfnInitialize(vboxGlobalData *data) +{ + data->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION); + if (data->pFuncs == NULL) + return -1; +#if VBOX_XPCOMC_VERSION == 0x00010000U + data->pFuncs->pfnComInitialize(&data->vboxObj, &data->vboxSession); +#else /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ + data->pFuncs->pfnComInitialize(IVIRTUALBOX_IID_STR, &data->vboxObj, ISESSION_IID_STR, &data->vboxSession); +#endif /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ + return 0; +} + +static int +_initializeFWatch(vboxGlobalData *data ATTRIBUTE_UNUSED) +{ +#if (VBOX_XPCOMC_VERSION == 0x00010000U) || (VBOX_API_VERSION == 2002000) + /* No event queue functionality in 2.2.* as of now */ + VIR_WARN("There is no fWatch initical in current version"); +#else /* (VBOX_XPCOMC_VERSION != 0x00010000U && VBOX_API_VERSION != 2002000) */ + /* Initialize the fWatch needed for Event Callbacks */ + data->fdWatch = -1; + data->pFuncs->pfnGetEventQueue(&data->vboxQueue); + if (data->vboxQueue == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nsIEventQueue object is null")); + return -1; + } +#endif /* (VBOX_XPCOMC_VERSION != 0x00010000U && VBOX_API_VERSION != 2002000) */ + return 0; +} + +vboxUniformedAPI NAME(UniformedAPI) = { + .uVersion = VBOX_API_VERSION, + .pfnInitialize = _pfnInitialize, + .initializeFWatch = _initializeFWatch, +#if (VBOX_XPCOMC_VERSION == 0x00010000U) || (VBOX_API_VERSION == 2002000) + /* No event queue functionality in 2.2.* as of now */ + .fWatchNeedInitialize = 0, +#else /* (VBOX_XPCOMC_VERSION != 0x00010000U && VBOX_API_VERSION != 2002000) */ + .fWatchNeedInitialize = 1, +#endif /* (VBOX_XPCOMC_VERSION != 0x00010000U && VBOX_API_VERSION != 2002000) */ +}; + +/* End of vboxUniformedAPI and Begin of common codes */ + static PRUnichar * vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr) { @@ -915,58 +929,6 @@ static virCapsPtr vboxCapsInit(void) return NULL; } -static int -vboxInitialize(vboxGlobalData *data) -{ - data->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION); - - if (data->pFuncs == NULL) - goto cleanup; - -#if VBOX_XPCOMC_VERSION == 0x00010000U - data->pFuncs->pfnComInitialize(&data->vboxObj, &data->vboxSession); -#else /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ - data->pFuncs->pfnComInitialize(IVIRTUALBOX_IID_STR, &data->vboxObj, - ISESSION_IID_STR, &data->vboxSession); - -# if VBOX_API_VERSION == 2002000 - - /* No event queue functionality in 2.2.* as of now */ - -# else /* !(VBOX_API_VERSION == 2002000) */ - - /* Initial the fWatch needed for Event Callbacks */ - data->fdWatch = -1; - - data->pFuncs->pfnGetEventQueue(&data->vboxQueue); - - if (data->vboxQueue == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("nsIEventQueue object is null")); - goto cleanup; - } - -# endif /* !(VBOX_API_VERSION == 2002000) */ -#endif /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ - - if (data->vboxObj == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("IVirtualBox object is null")); - goto cleanup; - } - - if (data->vboxSession == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("ISession object is null")); - goto cleanup; - } - - return 0; - - cleanup: - return -1; -} - static int vboxExtractVersion(vboxGlobalData *data) { int ret = -1; -- 1.7.9.5

On 23.06.2014 06:25, Taowei wrote:
Version specified codes for vboxUniformedAPI is implemented here, almost the same as PATCHv2. Common codes are moved to vbox_common.h and vbox_common.c.
--- src/vbox/vbox_tmpl.c | 142 ++++++++++++++++++-------------------------------- 1 file changed, 52 insertions(+), 90 deletions(-)
See? we can even shrink the code size. Isn't that just nice?
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 4ba9ad7..c2a83d1 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -87,9 +87,9 @@ # error "Unsupport VBOX_API_VERSION" #endif
-/* Include this *last* or we'll get the wrong vbox_CAPI_*.h. */ +/* Include thses *last* or we'll get the wrong vbox_CAPI_*.h. */
s/thses/these/
#include "vbox_glue.h" - +#include "vbox_common.h"
#define VIR_FROM_THIS VIR_FROM_VBOX
@@ -203,42 +203,6 @@ if (strUtf16) {\ (unsigned)(iid)->m3[7]);\ }\
-typedef struct { - virMutex lock; - unsigned long version; - - virCapsPtr caps; - virDomainXMLOptionPtr xmlopt; - - IVirtualBox *vboxObj; - ISession *vboxSession; - - /** Our version specific API table pointer. */ - PCVBOXXPCOM pFuncs; - -#if VBOX_API_VERSION == 2002000 - -} vboxGlobalData; - -#else /* !(VBOX_API_VERSION == 2002000) */ - - /* Async event handling */ - virObjectEventStatePtr domainEvents; - int fdWatch; - -# if VBOX_API_VERSION <= 3002000 - /* IVirtualBoxCallback is used in VirtualBox 3.x only */ - IVirtualBoxCallback *vboxCallback; -# endif /* VBOX_API_VERSION <= 3002000 */ - - nsIEventQueue *vboxQueue; - int volatile vboxCallBackRefCount; - - /* pointer back to the connection */ - virConnectPtr conn; - -} vboxGlobalData; - /* g_pVBoxGlobalData has to be global variable, * there is no other way to make the callbacks * work other then having g_pVBoxGlobalData as @@ -249,6 +213,8 @@ typedef struct { * them that way */
+#if VBOX_API_VERSION > 2002000 + static vboxGlobalData *g_pVBoxGlobalData = NULL;
#endif /* !(VBOX_API_VERSION == 2002000) */ @@ -826,6 +792,54 @@ static PRUnichar *PRUnicharFromInt(int n) {
#endif /* !(VBOX_API_VERSION == 2002000) */
+/* Begin of vboxUniformedAPI */ + +static int _pfnInitialize(vboxGlobalData *data) +{ + data->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION); + if (data->pFuncs == NULL) + return -1; +#if VBOX_XPCOMC_VERSION == 0x00010000U + data->pFuncs->pfnComInitialize(&data->vboxObj, &data->vboxSession); +#else /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ + data->pFuncs->pfnComInitialize(IVIRTUALBOX_IID_STR, &data->vboxObj, ISESSION_IID_STR, &data->vboxSession); +#endif /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ + return 0; +} + +static int +_initializeFWatch(vboxGlobalData *data ATTRIBUTE_UNUSED) +{ +#if (VBOX_XPCOMC_VERSION == 0x00010000U) || (VBOX_API_VERSION == 2002000) + /* No event queue functionality in 2.2.* as of now */ + VIR_WARN("There is no fWatch initical in current version"); +#else /* (VBOX_XPCOMC_VERSION != 0x00010000U && VBOX_API_VERSION != 2002000) */ + /* Initialize the fWatch needed for Event Callbacks */ + data->fdWatch = -1; + data->pFuncs->pfnGetEventQueue(&data->vboxQueue); + if (data->vboxQueue == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nsIEventQueue object is null")); + return -1; + } +#endif /* (VBOX_XPCOMC_VERSION != 0x00010000U && VBOX_API_VERSION != 2002000) */ + return 0; +} + +vboxUniformedAPI NAME(UniformedAPI) = { + .uVersion = VBOX_API_VERSION, + .pfnInitialize = _pfnInitialize, + .initializeFWatch = _initializeFWatch, +#if (VBOX_XPCOMC_VERSION == 0x00010000U) || (VBOX_API_VERSION == 2002000) + /* No event queue functionality in 2.2.* as of now */ + .fWatchNeedInitialize = 0, +#else /* (VBOX_XPCOMC_VERSION != 0x00010000U && VBOX_API_VERSION != 2002000) */ + .fWatchNeedInitialize = 1, +#endif /* (VBOX_XPCOMC_VERSION != 0x00010000U && VBOX_API_VERSION != 2002000) */ +}; + +/* End of vboxUniformedAPI and Begin of common codes */ + static PRUnichar * vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr) { @@ -915,58 +929,6 @@ static virCapsPtr vboxCapsInit(void) return NULL; }
-static int -vboxInitialize(vboxGlobalData *data) -{ - data->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION); - - if (data->pFuncs == NULL) - goto cleanup; - -#if VBOX_XPCOMC_VERSION == 0x00010000U - data->pFuncs->pfnComInitialize(&data->vboxObj, &data->vboxSession); -#else /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ - data->pFuncs->pfnComInitialize(IVIRTUALBOX_IID_STR, &data->vboxObj, - ISESSION_IID_STR, &data->vboxSession); - -# if VBOX_API_VERSION == 2002000 - - /* No event queue functionality in 2.2.* as of now */ - -# else /* !(VBOX_API_VERSION == 2002000) */ - - /* Initial the fWatch needed for Event Callbacks */ - data->fdWatch = -1; - - data->pFuncs->pfnGetEventQueue(&data->vboxQueue); - - if (data->vboxQueue == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("nsIEventQueue object is null")); - goto cleanup; - } - -# endif /* !(VBOX_API_VERSION == 2002000) */ -#endif /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ - - if (data->vboxObj == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("IVirtualBox object is null")); - goto cleanup; - } - - if (data->vboxSession == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("ISession object is null")); - goto cleanup; - } - - return 0; - - cleanup: - return -1; -} - static int vboxExtractVersion(vboxGlobalData *data) { int ret = -1;

Register pVBoxAPI in vbox_common.c with the current vbox version. --- src/vbox/vbox_driver.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index 7d004b2..4eb3c04 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -39,6 +39,9 @@ #include "vbox_glue.h" #include "virerror.h" #include "virutil.h" +#include "domain_event.h" +#include "domain_conf.h" +#include "vbox_common.h" #define VIR_FROM_THIS VIR_FROM_VBOX @@ -47,33 +50,43 @@ VIR_LOG_INIT("vbox.vbox_driver"); extern virDriver vbox22Driver; extern virNetworkDriver vbox22NetworkDriver; extern virStorageDriver vbox22StorageDriver; +extern vboxUniformedAPI vbox22UniformedAPI; extern virDriver vbox30Driver; extern virNetworkDriver vbox30NetworkDriver; extern virStorageDriver vbox30StorageDriver; +extern vboxUniformedAPI vbox30UniformedAPI; extern virDriver vbox31Driver; extern virNetworkDriver vbox31NetworkDriver; extern virStorageDriver vbox31StorageDriver; +extern vboxUniformedAPI vbox31UniformedAPI; extern virDriver vbox32Driver; extern virNetworkDriver vbox32NetworkDriver; extern virStorageDriver vbox32StorageDriver; +extern vboxUniformedAPI vbox32UniformedAPI; extern virDriver vbox40Driver; extern virNetworkDriver vbox40NetworkDriver; extern virStorageDriver vbox40StorageDriver; +extern vboxUniformedAPI vbox40UniformedAPI; extern virDriver vbox41Driver; extern virNetworkDriver vbox41NetworkDriver; extern virStorageDriver vbox41StorageDriver; +extern vboxUniformedAPI vbox41UniformedAPI; extern virDriver vbox42Driver; extern virNetworkDriver vbox42NetworkDriver; extern virStorageDriver vbox42StorageDriver; +extern vboxUniformedAPI vbox42UniformedAPI; extern virDriver vbox42_20Driver; extern virNetworkDriver vbox42_20NetworkDriver; extern virStorageDriver vbox42_20StorageDriver; +extern vboxUniformedAPI vbox42_20UniformedAPI; extern virDriver vbox43Driver; extern virNetworkDriver vbox43NetworkDriver; extern virStorageDriver vbox43StorageDriver; +extern vboxUniformedAPI vbox43UniformedAPI; extern virDriver vbox43_4Driver; extern virNetworkDriver vbox43_4NetworkDriver; extern virStorageDriver vbox43_4StorageDriver; +extern vboxUniformedAPI vbox43_4UniformedAPI; static virDriver vboxDriverDummy; @@ -84,6 +97,7 @@ int vboxRegister(void) virDriverPtr driver; virNetworkDriverPtr networkDriver; virStorageDriverPtr storageDriver; + vboxUniformedAPI *vboxAPI; uint32_t uVersion; /* @@ -95,6 +109,7 @@ int vboxRegister(void) driver = &vboxDriverDummy; networkDriver = &vbox22NetworkDriver; storageDriver = &vbox22StorageDriver; + vboxAPI = &vbox22UniformedAPI; /* Init the glue and get the API version. */ if (VBoxCGlueInit(&uVersion) == 0) { @@ -113,51 +128,61 @@ int vboxRegister(void) driver = &vbox22Driver; networkDriver = &vbox22NetworkDriver; storageDriver = &vbox22StorageDriver; + vboxAPI = &vbox22UniformedAPI; } else if (uVersion >= 2002051 && uVersion < 3000051) { VIR_DEBUG("VirtualBox API version: 3.0"); driver = &vbox30Driver; networkDriver = &vbox30NetworkDriver; storageDriver = &vbox30StorageDriver; + vboxAPI = &vbox30UniformedAPI; } else if (uVersion >= 3000051 && uVersion < 3001051) { VIR_DEBUG("VirtualBox API version: 3.1"); driver = &vbox31Driver; networkDriver = &vbox31NetworkDriver; storageDriver = &vbox31StorageDriver; + vboxAPI = &vbox31UniformedAPI; } else if (uVersion >= 3001051 && uVersion < 3002051) { VIR_DEBUG("VirtualBox API version: 3.2"); driver = &vbox32Driver; networkDriver = &vbox32NetworkDriver; storageDriver = &vbox32StorageDriver; + vboxAPI = &vbox32UniformedAPI; } else if (uVersion >= 3002051 && uVersion < 4000051) { VIR_DEBUG("VirtualBox API version: 4.0"); driver = &vbox40Driver; networkDriver = &vbox40NetworkDriver; storageDriver = &vbox40StorageDriver; + vboxAPI = &vbox40UniformedAPI; } else if (uVersion >= 4000051 && uVersion < 4001051) { VIR_DEBUG("VirtualBox API version: 4.1"); driver = &vbox41Driver; networkDriver = &vbox41NetworkDriver; storageDriver = &vbox41StorageDriver; + vboxAPI = &vbox41UniformedAPI; } else if (uVersion >= 4001051 && uVersion < 4002020) { VIR_DEBUG("VirtualBox API version: 4.2"); driver = &vbox42Driver; networkDriver = &vbox42NetworkDriver; storageDriver = &vbox42StorageDriver; + vboxAPI = &vbox42UniformedAPI; } else if (uVersion >= 4002020 && uVersion < 4002051) { - VIR_DEBUG("VirtualBox API version: 4.2.20 or higher"); - driver = &vbox42_20Driver; - networkDriver = &vbox42_20NetworkDriver; - storageDriver = &vbox42_20StorageDriver; + VIR_DEBUG("VirtualBox API version: 4.2.20 or higher"); + driver = &vbox42_20Driver; + networkDriver = &vbox42_20NetworkDriver; + storageDriver = &vbox42_20StorageDriver; + vboxAPI = &vbox42_20UniformedAPI; } else if (uVersion >= 4002051 && uVersion < 4003004) { VIR_DEBUG("VirtualBox API version: 4.3"); driver = &vbox43Driver; networkDriver = &vbox43NetworkDriver; storageDriver = &vbox43StorageDriver; + vboxAPI = &vbox43UniformedAPI; } else if (uVersion >= 4003004 && uVersion < 4003051) { VIR_DEBUG("VirtualBox API version: 4.3.4 or higher"); driver = &vbox43_4Driver; networkDriver = &vbox43_4NetworkDriver; storageDriver = &vbox43_4StorageDriver; + vboxAPI = &vbox43_4UniformedAPI; } else { VIR_DEBUG("Unsupported VirtualBox API version: %u", uVersion); } @@ -172,6 +197,8 @@ int vboxRegister(void) if (virRegisterStorageDriver(storageDriver) < 0) return -1; + vboxRegisterUniformedAPI(vboxAPI); + return 0; } -- 1.7.9.5

On 23.06.2014 06:25, Taowei wrote:
Register pVBoxAPI in vbox_common.c with the current vbox version.
--- src/vbox/vbox_driver.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index 7d004b2..4eb3c04 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -39,6 +39,9 @@ #include "vbox_glue.h" #include "virerror.h" #include "virutil.h" +#include "domain_event.h" +#include "domain_conf.h" +#include "vbox_common.h"
#define VIR_FROM_THIS VIR_FROM_VBOX
@@ -47,33 +50,43 @@ VIR_LOG_INIT("vbox.vbox_driver"); extern virDriver vbox22Driver; extern virNetworkDriver vbox22NetworkDriver; extern virStorageDriver vbox22StorageDriver; +extern vboxUniformedAPI vbox22UniformedAPI;
I assume as the code is rewritten, these vbox22StorageDriver and vbox22NetworkDriver and others will go away, right?
extern virDriver vbox30Driver; extern virNetworkDriver vbox30NetworkDriver; extern virStorageDriver vbox30StorageDriver; +extern vboxUniformedAPI vbox30UniformedAPI; extern virDriver vbox31Driver; extern virNetworkDriver vbox31NetworkDriver; extern virStorageDriver vbox31StorageDriver; +extern vboxUniformedAPI vbox31UniformedAPI; extern virDriver vbox32Driver; extern virNetworkDriver vbox32NetworkDriver; extern virStorageDriver vbox32StorageDriver; +extern vboxUniformedAPI vbox32UniformedAPI; extern virDriver vbox40Driver; extern virNetworkDriver vbox40NetworkDriver; extern virStorageDriver vbox40StorageDriver; +extern vboxUniformedAPI vbox40UniformedAPI; extern virDriver vbox41Driver; extern virNetworkDriver vbox41NetworkDriver; extern virStorageDriver vbox41StorageDriver; +extern vboxUniformedAPI vbox41UniformedAPI; extern virDriver vbox42Driver; extern virNetworkDriver vbox42NetworkDriver; extern virStorageDriver vbox42StorageDriver; +extern vboxUniformedAPI vbox42UniformedAPI; extern virDriver vbox42_20Driver; extern virNetworkDriver vbox42_20NetworkDriver; extern virStorageDriver vbox42_20StorageDriver; +extern vboxUniformedAPI vbox42_20UniformedAPI; extern virDriver vbox43Driver; extern virNetworkDriver vbox43NetworkDriver; extern virStorageDriver vbox43StorageDriver; +extern vboxUniformedAPI vbox43UniformedAPI; extern virDriver vbox43_4Driver; extern virNetworkDriver vbox43_4NetworkDriver; extern virStorageDriver vbox43_4StorageDriver; +extern vboxUniformedAPI vbox43_4UniformedAPI;
static virDriver vboxDriverDummy;
@@ -84,6 +97,7 @@ int vboxRegister(void) virDriverPtr driver; virNetworkDriverPtr networkDriver; virStorageDriverPtr storageDriver; + vboxUniformedAPI *vboxAPI; uint32_t uVersion;
/* @@ -95,6 +109,7 @@ int vboxRegister(void) driver = &vboxDriverDummy; networkDriver = &vbox22NetworkDriver; storageDriver = &vbox22StorageDriver; + vboxAPI = &vbox22UniformedAPI;
/* Init the glue and get the API version. */ if (VBoxCGlueInit(&uVersion) == 0) { @@ -113,51 +128,61 @@ int vboxRegister(void) driver = &vbox22Driver; networkDriver = &vbox22NetworkDriver; storageDriver = &vbox22StorageDriver; + vboxAPI = &vbox22UniformedAPI; } else if (uVersion >= 2002051 && uVersion < 3000051) { VIR_DEBUG("VirtualBox API version: 3.0"); driver = &vbox30Driver; networkDriver = &vbox30NetworkDriver; storageDriver = &vbox30StorageDriver; + vboxAPI = &vbox30UniformedAPI; } else if (uVersion >= 3000051 && uVersion < 3001051) { VIR_DEBUG("VirtualBox API version: 3.1"); driver = &vbox31Driver; networkDriver = &vbox31NetworkDriver; storageDriver = &vbox31StorageDriver; + vboxAPI = &vbox31UniformedAPI; } else if (uVersion >= 3001051 && uVersion < 3002051) { VIR_DEBUG("VirtualBox API version: 3.2"); driver = &vbox32Driver; networkDriver = &vbox32NetworkDriver; storageDriver = &vbox32StorageDriver; + vboxAPI = &vbox32UniformedAPI; } else if (uVersion >= 3002051 && uVersion < 4000051) { VIR_DEBUG("VirtualBox API version: 4.0"); driver = &vbox40Driver; networkDriver = &vbox40NetworkDriver; storageDriver = &vbox40StorageDriver; + vboxAPI = &vbox40UniformedAPI; } else if (uVersion >= 4000051 && uVersion < 4001051) { VIR_DEBUG("VirtualBox API version: 4.1"); driver = &vbox41Driver; networkDriver = &vbox41NetworkDriver; storageDriver = &vbox41StorageDriver; + vboxAPI = &vbox41UniformedAPI; } else if (uVersion >= 4001051 && uVersion < 4002020) { VIR_DEBUG("VirtualBox API version: 4.2"); driver = &vbox42Driver; networkDriver = &vbox42NetworkDriver; storageDriver = &vbox42StorageDriver; + vboxAPI = &vbox42UniformedAPI; } else if (uVersion >= 4002020 && uVersion < 4002051) { - VIR_DEBUG("VirtualBox API version: 4.2.20 or higher"); - driver = &vbox42_20Driver; - networkDriver = &vbox42_20NetworkDriver; - storageDriver = &vbox42_20StorageDriver; + VIR_DEBUG("VirtualBox API version: 4.2.20 or higher"); + driver = &vbox42_20Driver; + networkDriver = &vbox42_20NetworkDriver; + storageDriver = &vbox42_20StorageDriver; + vboxAPI = &vbox42_20UniformedAPI; } else if (uVersion >= 4002051 && uVersion < 4003004) { VIR_DEBUG("VirtualBox API version: 4.3"); driver = &vbox43Driver; networkDriver = &vbox43NetworkDriver; storageDriver = &vbox43StorageDriver; + vboxAPI = &vbox43UniformedAPI; } else if (uVersion >= 4003004 && uVersion < 4003051) { VIR_DEBUG("VirtualBox API version: 4.3.4 or higher"); driver = &vbox43_4Driver; networkDriver = &vbox43_4NetworkDriver; storageDriver = &vbox43_4StorageDriver; + vboxAPI = &vbox43_4UniformedAPI; } else { VIR_DEBUG("Unsupported VirtualBox API version: %u", uVersion); } @@ -172,6 +197,8 @@ int vboxRegister(void) if (virRegisterStorageDriver(storageDriver) < 0) return -1;
+ vboxRegisterUniformedAPI(vboxAPI); + return 0; }

Changes in makefile and make new files to be compiled. --- po/POTFILES.in | 1 + src/Makefile.am | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 31a8381..d20107d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -212,6 +212,7 @@ src/util/virutil.c src/util/virxml.c src/vbox/vbox_MSCOMGlue.c src/vbox/vbox_XPCOMCGlue.c +src/vbox/vbox_common.c src/vbox/vbox_driver.c src/vbox/vbox_snapshot_conf.c src/vbox/vbox_tmpl.c diff --git a/src/Makefile.am b/src/Makefile.am index 2b9ac61..282c62c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -673,7 +673,9 @@ VBOX_DRIVER_SOURCES = \ vbox/vbox_V4_2.c vbox/vbox_CAPI_v4_2.h \ vbox/vbox_V4_2_20.c vbox/vbox_CAPI_v4_2_20.h \ vbox/vbox_V4_3.c vbox/vbox_CAPI_v4_3.h \ - vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h + vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \ + vbox/vbox_common.c vbox/vbox_common.h \ + vbox/vbox_commondef.h VBOX_DRIVER_EXTRA_DIST = \ vbox/vbox_tmpl.c vbox/README \ -- 1.7.9.5

On 23.06.2014 06:25, Taowei wrote:
Changes in makefile and make new files to be compiled.
--- po/POTFILES.in | 1 + src/Makefile.am | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in index 31a8381..d20107d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -212,6 +212,7 @@ src/util/virutil.c src/util/virxml.c src/vbox/vbox_MSCOMGlue.c src/vbox/vbox_XPCOMCGlue.c +src/vbox/vbox_common.c src/vbox/vbox_driver.c src/vbox/vbox_snapshot_conf.c src/vbox/vbox_tmpl.c diff --git a/src/Makefile.am b/src/Makefile.am index 2b9ac61..282c62c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -673,7 +673,9 @@ VBOX_DRIVER_SOURCES = \ vbox/vbox_V4_2.c vbox/vbox_CAPI_v4_2.h \ vbox/vbox_V4_2_20.c vbox/vbox_CAPI_v4_2_20.h \ vbox/vbox_V4_3.c vbox/vbox_CAPI_v4_3.h \ - vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h + vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \ + vbox/vbox_common.c vbox/vbox_common.h \ + vbox/vbox_commondef.h
VBOX_DRIVER_EXTRA_DIST = \ vbox/vbox_tmpl.c vbox/README \
NACK, this should have been done in the previous patches. Michal

On 23.06.2014 06:25, Taowei wrote:
Michal asked me to try working out a sample of vbox driver's common code. Here it is. As the PATCHv2 is pending, I merged it.
Taowei (5): define interface with vbox_common a sample of vbox_common function : vboxInitialize implement vboxUniformedAPI in vbox_tmpl.c and remove common codes install vbox api register in vbox_driver make new files be compiled by libvirt
po/POTFILES.in | 1 + src/Makefile.am | 4 +- src/vbox/vbox_common.c | 89 ++++++++++++++++++++++++++++ src/vbox/vbox_common.h | 108 ++++++++++++++++++++++++++++++++++ src/vbox/vbox_commondef.h | 32 ++++++++++ src/vbox/vbox_driver.c | 35 +++++++++-- src/vbox/vbox_tmpl.c | 142 +++++++++++++++++---------------------------- 7 files changed, 316 insertions(+), 95 deletions(-) create mode 100644 src/vbox/vbox_common.c create mode 100644 src/vbox/vbox_common.h create mode 100644 src/vbox/vbox_commondef.h
Unfortunately you're not outlining any rework of internal implementation of a public API. Can you just pick one so we can have an idea how exhaustive is that going to be? Michal
participants (2)
-
Michal Privoznik
-
Taowei