now that we have a new global vboxDriver object, remove the old vboxGlobalData struct and all references to it. --- src/vbox/vbox_common.c | 168 +++++++++---------- src/vbox/vbox_common.h | 2 +- src/vbox/vbox_network.c | 24 +-- src/vbox/vbox_storage.c | 20 +-- src/vbox/vbox_tmpl.c | 375 +++++++++++++++++++++--------------------- src/vbox/vbox_uniformed_api.h | 96 ++++------- 6 files changed, 317 insertions(+), 368 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 78e0194..6947922 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -278,7 +278,7 @@ vboxDestroyDriverConnection(void) virMutexUnlock(&vbox_driver_lock); } -static int openSessionForMachine(vboxGlobalData *data, const unsigned char *dom_uuid, vboxIIDUnion *iid, +static int openSessionForMachine(vboxDriverPtr data, const unsigned char *dom_uuid, vboxIIDUnion *iid, IMachine **machine, bool checkflag) { VBOX_IID_INITIALIZE(iid); @@ -539,7 +539,7 @@ static int vboxConnectClose(virConnectPtr conn) static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IConsole *console = NULL; vboxIIDUnion iid; IMachine *machine = NULL; @@ -591,24 +591,14 @@ vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) return ret; } -static void vboxDriverLock(vboxGlobalData *data) -{ - virMutexLock(&data->lock); -} - -static void vboxDriverUnlock(vboxGlobalData *data) -{ - virMutexUnlock(&data->lock); -} - static int vboxConnectGetVersion(virConnectPtr conn, unsigned long *version) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; VIR_DEBUG("%s: in vboxGetVersion", conn->driver->name); - vboxDriverLock(data); + virObjectLock(data); *version = data->version; - vboxDriverUnlock(data); + virObjectUnlock(data); return 0; } @@ -638,7 +628,7 @@ static int vboxConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED) static int vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; PRUint32 maxCPUCount = 0; int ret = -1; @@ -665,22 +655,22 @@ vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED) static char *vboxConnectGetCapabilities(virConnectPtr conn) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; char *ret = NULL; if (!data->vboxObj) return ret; - vboxDriverLock(data); + virObjectLock(data); ret = virCapabilitiesFormatXML(data->caps); - vboxDriverUnlock(data); + virObjectUnlock(data); return ret; } static int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; PRUint32 state; nsresult rc; @@ -722,7 +712,7 @@ static int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids) static int vboxConnectNumOfDomains(virConnectPtr conn) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; PRUint32 state; nsresult rc; @@ -761,7 +751,7 @@ static int vboxConnectNumOfDomains(virConnectPtr conn) static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; IMachine *machine; PRBool isAccessible = PR_FALSE; @@ -839,7 +829,7 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; vboxIIDUnion iid; char *machineNameUtf8 = NULL; @@ -916,7 +906,7 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; vboxIIDUnion iid; char *machineNameUtf8 = NULL; @@ -988,7 +978,7 @@ vboxDomainLookupByName(virConnectPtr conn, const char *name) } static void -vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data, +vboxSetBootDeviceOrder(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { ISystemProperties *systemProperties = NULL; @@ -1045,7 +1035,7 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data, } static void -vboxAttachDrivesNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxAttachDrivesNew(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { /* AttachDrives for 3.0 and later */ size_t i; @@ -1254,7 +1244,7 @@ vboxAttachDrivesNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine } static void -vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { /* Here, About the vboxAttachDrives. In fact,there is * three different implementations. We name it as @@ -1325,7 +1315,7 @@ vboxAttachSound(virDomainDefPtr def, IMachine *machine) } static int -vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { ISystemProperties *systemProperties = NULL; PRUint32 chipsetType = ChipsetType_Null; @@ -1471,7 +1461,7 @@ vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) } static void -vboxAttachSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxAttachSerial(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { ISystemProperties *systemProperties = NULL; PRUint32 serialPortCount = 0; @@ -1547,7 +1537,7 @@ vboxAttachSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) } static void -vboxAttachParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxAttachParallel(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { ISystemProperties *systemProperties = NULL; PRUint32 parallelPortCount = 0; @@ -1636,7 +1626,7 @@ vboxAttachVideo(virDomainDefPtr def, IMachine *machine) } static void -vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxAttachDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { int vrdpPresent = 0; int sdlPresent = 0; @@ -1783,7 +1773,7 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) } static void -vboxAttachUSB(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxAttachUSB(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { IUSBCommon *USBCommon = NULL; size_t i = 0; @@ -1887,7 +1877,7 @@ vboxAttachUSB(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) } static void -vboxAttachSharedFolder(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxAttachSharedFolder(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { size_t i; PRUnichar *nameUtf16; @@ -1916,7 +1906,7 @@ vboxAttachSharedFolder(virDomainDefPtr def, vboxGlobalData *data, IMachine *mach static virDomainPtr vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; IMachine *machine = NULL; IBIOSSettings *bios = NULL; vboxIIDUnion mchiid; @@ -2064,7 +2054,7 @@ vboxDomainDefineXML(virConnectPtr conn, const char *xml) } static void -detachDevices_common(vboxGlobalData *data, vboxIIDUnion *iidu) +detachDevices_common(vboxDriverPtr data, vboxIIDUnion *iidu) { /* Block for checking if HDD's are attched to VM. * considering just IDE bus for now. Also skipped @@ -2101,7 +2091,7 @@ detachDevices_common(vboxGlobalData *data, vboxIIDUnion *iidu) static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; nsresult rc; @@ -2144,7 +2134,7 @@ static int vboxDomainUndefine(virDomainPtr dom) static int vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion *iid) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; int vrdpPresent = 0; int sdlPresent = 0; int guiPresent = 0; @@ -2296,7 +2286,7 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; unsigned char uuid[VIR_UUID_BUFLEN] = {0}; nsresult rc; @@ -2401,7 +2391,7 @@ static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml, static int vboxDomainIsActive(virDomainPtr dom) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; vboxIIDUnion iid; char *machineNameUtf8 = NULL; @@ -2473,7 +2463,7 @@ static int vboxDomainIsPersistent(virDomainPtr dom) { /* All domains are persistent. However, we do want to check for * existence. */ - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; int ret = -1; @@ -2496,7 +2486,7 @@ static int vboxDomainIsUpdated(virDomainPtr dom) { /* VBox domains never have a persistent state that differs from * current state. However, we do want to check for existence. */ - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; int ret = -1; @@ -2517,7 +2507,7 @@ static int vboxDomainIsUpdated(virDomainPtr dom) static int vboxDomainSuspend(virDomainPtr dom) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; IConsole *console = NULL; @@ -2568,7 +2558,7 @@ static int vboxDomainSuspend(virDomainPtr dom) static int vboxDomainResume(virDomainPtr dom) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; IConsole *console = NULL; @@ -2619,7 +2609,7 @@ static int vboxDomainResume(virDomainPtr dom) static int vboxDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; IConsole *console = NULL; @@ -2676,7 +2666,7 @@ static int vboxDomainShutdown(virDomainPtr dom) static int vboxDomainReboot(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; IConsole *console = NULL; @@ -2724,7 +2714,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags) static int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; IConsole *console = NULL; @@ -2790,7 +2780,7 @@ static char *vboxDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) { static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; PRUint32 state; @@ -2848,7 +2838,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) static int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; char *machineName = NULL; PRUnichar *machineNameUtf16 = NULL; @@ -2932,7 +2922,7 @@ static int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) static int vboxDomainGetState(virDomainPtr dom, int *state, int *reason, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion domiid; IMachine *machine = NULL; PRUint32 mstate; @@ -2963,7 +2953,7 @@ static int vboxDomainGetState(virDomainPtr dom, int *state, static int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; PRUint32 CPUCount = nvcpus; @@ -3017,7 +3007,7 @@ static int vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) static int vboxDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; ISystemProperties *systemProperties = NULL; PRUint32 maxCPUCount = 0; int ret = -1; @@ -3054,7 +3044,7 @@ static int vboxDomainGetMaxVcpus(virDomainPtr dom) } static void -vboxHostDeviceGetXMLDesc(vboxGlobalData *data, virDomainDefPtr def, IMachine *machine) +vboxHostDeviceGetXMLDesc(vboxDriverPtr data, virDomainDefPtr def, IMachine *machine) { IUSBCommon *USBCommon = NULL; PRBool enabled = PR_FALSE; @@ -3160,7 +3150,7 @@ vboxHostDeviceGetXMLDesc(vboxGlobalData *data, virDomainDefPtr def, IMachine *ma } static void -vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { /* dump IDE hdds if present */ vboxArray mediumAttachments = VBOX_ARRAY_INITIALIZER; @@ -3321,7 +3311,7 @@ vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) } static int -vboxDumpVideo(virDomainDefPtr def, vboxGlobalData *data ATTRIBUTE_UNUSED, +vboxDumpVideo(virDomainDefPtr def, vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine) { /* dump video options vram/2d/3d/directx/etc. */ @@ -3359,7 +3349,7 @@ vboxDumpVideo(virDomainDefPtr def, vboxGlobalData *data ATTRIBUTE_UNUSED, } static int -vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { /* dump display options vrdp/gui/sdl */ PRUnichar *keyUtf16 = NULL; @@ -3479,7 +3469,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) } static void -vboxDumpSharedFolders(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +vboxDumpSharedFolders(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { /* shared folders */ vboxArray sharedFolders = VBOX_ARRAY_INITIALIZER; @@ -3540,7 +3530,7 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxGlobalData *data, IMachine *machi } static void -vboxDumpNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRUint32 networkAdapterCount) +vboxDumpNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine, PRUint32 networkAdapterCount) { PRUint32 netAdpIncCnt = 0; size_t i = 0; @@ -3679,7 +3669,7 @@ vboxDumpNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PR } static void -vboxDumpAudio(virDomainDefPtr def, vboxGlobalData *data ATTRIBUTE_UNUSED, +vboxDumpAudio(virDomainDefPtr def, vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine) { /* dump sound card if active */ @@ -3719,7 +3709,7 @@ vboxDumpAudio(virDomainDefPtr def, vboxGlobalData *data ATTRIBUTE_UNUSED, } static void -vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRUint32 serialPortCount) +vboxDumpSerial(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine, PRUint32 serialPortCount) { PRUint32 serialPortIncCount = 0; size_t i = 0; @@ -3807,7 +3797,7 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU } static void -vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRUint32 parallelPortCount) +vboxDumpParallel(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine, PRUint32 parallelPortCount) { PRUint32 parallelPortIncCount = 0; size_t i = 0; @@ -3882,7 +3872,7 @@ vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, P static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; virDomainDefPtr def = NULL; IMachine *machine = NULL; vboxIIDUnion iid; @@ -4050,7 +4040,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) static int vboxConnectListDefinedDomains(virConnectPtr conn, char ** const names, int maxnames) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; char *machineName = NULL; PRUnichar *machineNameUtf16 = NULL; @@ -4112,7 +4102,7 @@ static int vboxConnectListDefinedDomains(virConnectPtr conn, static int vboxConnectNumOfDefinedDomains(virConnectPtr conn) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; PRUint32 state; nsresult rc; @@ -4157,7 +4147,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, const char *xml, int mediaChangeOnly ATTRIBUTE_UNUSED) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; PRUint32 state; @@ -4288,7 +4278,7 @@ static int vboxDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml, static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; vboxIIDUnion iid; PRUint32 state; @@ -4401,7 +4391,7 @@ static int vboxDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, static int vboxCloseDisksRecursively(virDomainPtr dom, char *location) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; nsresult rc; size_t i = 0; PRUnichar *locationUtf = NULL; @@ -4502,7 +4492,7 @@ vboxSnapshotRedefine(virDomainPtr dom, * * Finally, we register the machine with the new virtualbox description file. */ - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion domiid; IMachine *machine = NULL; nsresult rc; @@ -5361,7 +5351,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, const char *xmlDesc, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; virDomainSnapshotDefPtr def = NULL; vboxIIDUnion domiid; IMachine *machine = NULL; @@ -5562,7 +5552,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, } static ISnapshot * -vboxDomainSnapshotGet(vboxGlobalData *data, +vboxDomainSnapshotGet(vboxDriverPtr data, virDomainPtr dom, IMachine *machine, const char *name) @@ -5615,7 +5605,7 @@ static int vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def, virDomainSnapshotPtr snapshot) { virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion domiid; IMachine *machine = NULL; ISnapshot *snap = NULL; @@ -5836,7 +5826,7 @@ int vboxSnapshotGetReadOnlyDisks(virDomainSnapshotPtr snapshot, virDomainSnapshotDefPtr def) { virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion domiid; ISnapshot *snap = NULL; IMachine *machine = NULL; @@ -6055,7 +6045,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned int flags) { virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion domiid; IMachine *machine = NULL; ISnapshot *snap = NULL; @@ -6200,7 +6190,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, static int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; nsresult rc; @@ -6245,7 +6235,7 @@ static int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags) static int vboxDomainSnapshotListNames(virDomainPtr dom, char **names, int nameslen, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; nsresult rc; @@ -6326,7 +6316,7 @@ static virDomainSnapshotPtr vboxDomainSnapshotLookupByName(virDomainPtr dom, const char *name, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; ISnapshot *snapshot = NULL; @@ -6355,7 +6345,7 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom, const char *name, static int vboxDomainHasCurrentSnapshot(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; ISnapshot *snapshot = NULL; @@ -6393,7 +6383,7 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned int flags) { virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; ISnapshot *snap = NULL; @@ -6456,7 +6446,7 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, static virDomainSnapshotPtr vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; ISnapshot *snapshot = NULL; @@ -6514,7 +6504,7 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned int flags) { virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; ISnapshot *snap = NULL; @@ -6575,7 +6565,7 @@ static int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, unsigned int flags) { virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion iid; IMachine *machine = NULL; ISnapshot *snap = NULL; @@ -6606,7 +6596,7 @@ static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags) { virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion domiid; IMachine *machine = NULL; ISnapshot *newSnapshot = NULL; @@ -6676,7 +6666,7 @@ static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, } static int -vboxDomainSnapshotDeleteSingle(vboxGlobalData *data, +vboxDomainSnapshotDeleteSingle(vboxDriverPtr data, IConsole *console, ISnapshot *snapshot) { @@ -6723,7 +6713,7 @@ vboxDomainSnapshotDeleteSingle(vboxGlobalData *data, } static int -vboxDomainSnapshotDeleteTree(vboxGlobalData *data, +vboxDomainSnapshotDeleteTree(vboxDriverPtr data, IConsole *console, ISnapshot *snapshot) { @@ -6770,7 +6760,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) */ virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; virDomainSnapshotDefPtr def = NULL; char *defXml = NULL; vboxIIDUnion domiid; @@ -7207,7 +7197,7 @@ static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags) { virDomainPtr dom = snapshot->domain; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIIDUnion domiid; IMachine *machine = NULL; ISnapshot *snap = NULL; @@ -7293,7 +7283,7 @@ vboxDomainScreenshot(virDomainPtr dom, unsigned int screen, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IConsole *console = NULL; vboxIIDUnion iid; IMachine *machine = NULL; @@ -7434,7 +7424,7 @@ vboxConnectListAllDomains(virConnectPtr conn, virDomainPtr **domains, unsigned int flags) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; char *machineNameUtf8 = NULL; PRUnichar *machineNameUtf16 = NULL; @@ -7646,7 +7636,7 @@ vboxNodeAllocPages(virConnectPtr conn ATTRIBUTE_UNUSED, static int vboxDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; vboxIIDUnion iid; char *machineNameUtf8 = NULL; @@ -7722,7 +7712,7 @@ vboxDomainSendKey(virDomainPtr dom, unsigned int flags) { int ret = -1; - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; IConsole *console = NULL; vboxIIDUnion iid; IMachine *machine = NULL; diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index b178878..3be1aa4 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -397,7 +397,7 @@ typedef nsISupports IKeyboard; # define vboxIIDToUUID(iid, uuid) gVBoxAPI.UIID.vboxIIDToUUID(data, iid, uuid) # define vboxIIDFromUUID(iid, uuid) gVBoxAPI.UIID.vboxIIDFromUUID(data, iid, uuid) # define vboxIIDIsEqual(iid1, iid2) gVBoxAPI.UIID.vboxIIDIsEqual(data, iid1, iid2) -# define DEBUGIID(msg, iid) gVBoxAPI.UIID.DEBUGIID(msg, iid) +# define DEBUGIID(msg, iid) gVBoxAPI.UIID.DEBUGIID(data, msg, iid) # define vboxIIDFromArrayItem(iid, array, idx) \ gVBoxAPI.UIID.vboxIIDFromArrayItem(data, iid, array, idx) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 0b944b6..0884b74 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -46,7 +46,7 @@ static vboxUniformedAPI gVBoxAPI; static int vboxConnectNumOfNetworks(virConnectPtr conn) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; IHost *host = NULL; size_t i = 0; @@ -91,7 +91,7 @@ static int vboxConnectNumOfNetworks(virConnectPtr conn) static int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; IHost *host = NULL; size_t i = 0; @@ -148,7 +148,7 @@ static int vboxConnectListNetworks(virConnectPtr conn, char **const names, int n static int vboxConnectNumOfDefinedNetworks(virConnectPtr conn) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; IHost *host = NULL; size_t i = 0; @@ -193,7 +193,7 @@ static int vboxConnectNumOfDefinedNetworks(virConnectPtr conn) static int vboxConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER; IHost *host = NULL; size_t i = 0; @@ -250,7 +250,7 @@ static int vboxConnectListDefinedNetworks(virConnectPtr conn, char **const names static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; PRUint32 interfaceType = 0; char *nameUtf8 = NULL; PRUnichar *nameUtf16 = NULL; @@ -302,7 +302,7 @@ static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned static virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *name) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; PRUnichar *nameUtf16 = NULL; IHostNetworkInterface *networkInterface = NULL; PRUint32 interfaceType = 0; @@ -350,7 +350,7 @@ static virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *nam } static PRUnichar * -vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr) +vboxSocketFormatAddrUtf16(vboxDriverPtr data, virSocketAddrPtr addr) { char *utf8 = NULL; PRUnichar *utf16 = NULL; @@ -369,7 +369,7 @@ vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr) static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; PRUnichar *networkInterfaceNameUtf16 = NULL; char *networkInterfaceNameUtf8 = NULL; PRUnichar *networkNameUtf16 = NULL; @@ -563,7 +563,7 @@ static virNetworkPtr vboxNetworkDefineXML(virConnectPtr conn, const char *xml) static int vboxNetworkUndefineDestroy(virNetworkPtr network, bool removeinterface) { - vboxGlobalData *data = network->conn->privateData; + vboxDriverPtr data = network->conn->privateData; char *networkNameUtf8 = NULL; PRUnichar *networkInterfaceNameUtf16 = NULL; IHostNetworkInterface *networkInterface = NULL; @@ -668,7 +668,7 @@ static int vboxNetworkDestroy(virNetworkPtr network) static int vboxNetworkCreate(virNetworkPtr network) { - vboxGlobalData *data = network->conn->privateData; + vboxDriverPtr data = network->conn->privateData; char *networkNameUtf8 = NULL; PRUnichar *networkInterfaceNameUtf16 = NULL; IHostNetworkInterface *networkInterface = NULL; @@ -739,7 +739,7 @@ static int vboxNetworkCreate(virNetworkPtr network) } static int -vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16, +vboxSocketParseAddrUtf16(vboxDriverPtr data, const PRUnichar *utf16, virSocketAddrPtr addr) { int result = -1; @@ -760,7 +760,7 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16, static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) { - vboxGlobalData *data = network->conn->privateData; + vboxDriverPtr data = network->conn->privateData; virNetworkDefPtr def = NULL; virNetworkIPDefPtr ipdef = NULL; char *networkNameUtf8 = NULL; diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index c849505..7954e9d 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -86,7 +86,7 @@ vboxStoragePoolLookupByName(virConnectPtr conn, const char *name) static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool) { - vboxGlobalData *data = pool->conn->privateData; + vboxDriverPtr data = pool->conn->privateData; vboxArray hardDisks = VBOX_ARRAY_INITIALIZER; PRUint32 hardDiskAccessible = 0; nsresult rc; @@ -127,7 +127,7 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool) static int vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nnames) { - vboxGlobalData *data = pool->conn->privateData; + vboxDriverPtr data = pool->conn->privateData; vboxArray hardDisks = VBOX_ARRAY_INITIALIZER; PRUint32 numActive = 0; nsresult rc; @@ -183,7 +183,7 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nname static virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) { - vboxGlobalData *data = pool->conn->privateData; + vboxDriverPtr data = pool->conn->privateData; vboxArray hardDisks = VBOX_ARRAY_INITIALIZER; nsresult rc; size_t i; @@ -256,7 +256,7 @@ vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char *key) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; vboxIIDUnion hddIID; unsigned char uuid[VIR_UUID_BUFLEN]; IHardDisk *hardDisk = NULL; @@ -323,7 +323,7 @@ vboxStorageVolLookupByKey(virConnectPtr conn, const char *key) static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const char *path) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; PRUnichar *hddPathUtf16 = NULL; IHardDisk *hardDisk = NULL; PRUnichar *hddNameUtf16 = NULL; @@ -401,7 +401,7 @@ static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool, const char *xml, unsigned int flags) { - vboxGlobalData *data = pool->conn->privateData; + vboxDriverPtr data = pool->conn->privateData; virStorageVolDefPtr def = NULL; PRUnichar *hddFormatUtf16 = NULL; PRUnichar *hddNameUtf16 = NULL; @@ -508,7 +508,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) { - vboxGlobalData *data = vol->conn->privateData; + vboxDriverPtr data = vol->conn->privateData; unsigned char uuid[VIR_UUID_BUFLEN]; IHardDisk *hardDisk = NULL; int deregister = 0; @@ -663,7 +663,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info) { - vboxGlobalData *data = vol->conn->privateData; + vboxDriverPtr data = vol->conn->privateData; IHardDisk *hardDisk = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; PRUint32 hddstate; @@ -718,7 +718,7 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) { - vboxGlobalData *data = vol->conn->privateData; + vboxDriverPtr data = vol->conn->privateData; IHardDisk *hardDisk = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; PRUnichar *hddFormatUtf16 = NULL; @@ -810,7 +810,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) static char *vboxStorageVolGetPath(virStorageVolPtr vol) { - vboxGlobalData *data = vol->conn->privateData; + vboxDriverPtr data = vol->conn->privateData; IHardDisk *hardDisk = NULL; PRUnichar *hddLocationUtf16 = NULL; char *hddLocationUtf8 = NULL; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 5de3ec7..998f20a 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -144,10 +144,10 @@ if (arg)\ if (strUtf16) {\ char *strUtf8 = NULL;\ \ - g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8);\ + data->pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8);\ if (strUtf8) {\ VIR_DEBUG("%s: %s", msg, strUtf8);\ - g_pVBoxGlobalData->pFuncs->pfnUtf8Free(strUtf8);\ + data->pFuncs->pfnUtf8Free(strUtf8);\ }\ } @@ -167,22 +167,6 @@ if (strUtf16) {\ (unsigned)(iid)->m3[7]);\ }\ -#if VBOX_API_VERSION > 2002000 - -/* g_pVBoxGlobalData has to be global variable, - * there is no other way to make the callbacks - * work other then having g_pVBoxGlobalData as - * global, because the functions namely AddRef, - * Release, etc consider it as global and you - * can't change the function definition as it - * is XPCOM nsISupport::* function and it expects - * them that way - */ - -static vboxGlobalData *g_pVBoxGlobalData; - -#endif /* !(VBOX_API_VERSION == 2002000) */ - #if VBOX_API_VERSION < 4000000 # define VBOX_SESSION_OPEN(/* in */ iid_value, /* unused */ machine) \ @@ -201,23 +185,6 @@ static vboxGlobalData *g_pVBoxGlobalData; #endif /* VBOX_API_VERSION >= 4000000 */ -#if VBOX_API_VERSION > 2002000 && VBOX_API_VERSION < 4000000 -/* Since vboxConnectGetCapabilities has been rewritten, - * vboxDriverLock and vboxDriverUnlock only be used in code for - * 3.x release. */ - -static void vboxDriverLock(vboxGlobalData *data) -{ - virMutexLock(&data->lock); -} - -static void vboxDriverUnlock(vboxGlobalData *data) -{ - virMutexUnlock(&data->lock); -} - -#endif - #if VBOX_API_VERSION == 2002000 static void nsIDtoChar(unsigned char *uuid, const nsID *iid) @@ -309,14 +276,14 @@ typedef struct _vboxIID_v2_x_WIN32 vboxIID_v2_x_WIN32; # define IID_MEMBER(name) (iidu->vboxIID_v2_x_WIN32.name) static void -vboxIIDUnalloc_v2_x_WIN32(vboxGlobalData *data ATTRIBUTE_UNUSED, +vboxIIDUnalloc_v2_x_WIN32(vboxDriverPtr data ATTRIBUTE_UNUSED, vboxIID_v2_x_WIN32 *iid ATTRIBUTE_UNUSED) { /* Nothing to free */ } static void -_vboxIIDUnalloc(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vboxIIDUnalloc(vboxDriverPtr data ATTRIBUTE_UNUSED, vboxIIDUnion *iid ATTRIBUTE_UNUSED) { /* Nothing to free */ @@ -329,13 +296,13 @@ vboxIIDToUUID_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid, unsigned char *uuid) } static void -_vboxIIDToUUID(vboxGlobalData *data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu, unsigned char *uuid) +_vboxIIDToUUID(vboxDriverPtr data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu, unsigned char *uuid) { vboxIIDToUUID_v2_x_WIN32(&iidu->vboxIID_v2_x_WIN32, uuid); } static void -vboxIIDFromUUID_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid, +vboxIIDFromUUID_v2_x_WIN32(vboxDriverPtr data, vboxIID_v2_x_WIN32 *iid, const unsigned char *uuid) { vboxIIDUnalloc_v2_x_WIN32(data, iid); @@ -344,7 +311,7 @@ vboxIIDFromUUID_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid, } static void -_vboxIIDFromUUID(vboxGlobalData *data, vboxIIDUnion *iidu, +_vboxIIDFromUUID(vboxDriverPtr data, vboxIIDUnion *iidu, const unsigned char *uuid) { vboxIIDFromUUID_v2_x_WIN32(data, &iidu->vboxIID_v2_x_WIN32, uuid); @@ -357,13 +324,13 @@ vboxIIDIsEqual_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid1, vboxIID_v2_x_WIN32 *iid2) } static bool -_vboxIIDIsEqual(vboxGlobalData *data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2) +_vboxIIDIsEqual(vboxDriverPtr data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2) { return vboxIIDIsEqual_v2_x_WIN32(&iidu1->vboxIID_v2_x_WIN32, &iidu2->vboxIID_v2_x_WIN32); } static void -vboxIIDFromArrayItem_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid, +vboxIIDFromArrayItem_v2_x_WIN32(vboxDriverPtr data, vboxIID_v2_x_WIN32 *iid, vboxArray *array, int idx) { GUID *items = (GUID *)array->items; @@ -374,7 +341,7 @@ vboxIIDFromArrayItem_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid, } static void -_vboxIIDFromArrayItem(vboxGlobalData *data, vboxIIDUnion *iidu, +_vboxIIDFromArrayItem(vboxDriverPtr data, vboxIIDUnion *iidu, vboxArray *array, int idx) { vboxIIDFromArrayItem_v2_x_WIN32(data, &iidu->vboxIID_v2_x_WIN32, array, idx); @@ -397,7 +364,7 @@ typedef struct _vboxIID_v2_x vboxIID_v2_x; # define IID_MEMBER(name) (iidu->vboxIID_v2_x.name) static void -vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid) +vboxIIDUnalloc_v2_x(vboxDriverPtr data, vboxIID_v2_x *iid) { if (iid->value == NULL) return; @@ -409,7 +376,7 @@ vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid) } static void -_vboxIIDUnalloc(vboxGlobalData *data, vboxIIDUnion *iidu) +_vboxIIDUnalloc(vboxDriverPtr data, vboxIIDUnion *iidu) { vboxIIDUnalloc_v2_x(data, &iidu->vboxIID_v2_x); } @@ -421,14 +388,14 @@ vboxIIDToUUID_v2_x(vboxIID_v2_x *iid, unsigned char *uuid) } static void -_vboxIIDToUUID(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vboxIIDToUUID(vboxDriverPtr data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu, unsigned char *uuid) { vboxIIDToUUID_v2_x(&iidu->vboxIID_v2_x, uuid); } static void -vboxIIDFromUUID_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid, +vboxIIDFromUUID_v2_x(vboxDriverPtr data, vboxIID_v2_x *iid, const unsigned char *uuid) { vboxIIDUnalloc_v2_x(data, iid); @@ -440,7 +407,7 @@ vboxIIDFromUUID_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid, } static void -_vboxIIDFromUUID(vboxGlobalData *data, vboxIIDUnion *iidu, +_vboxIIDFromUUID(vboxDriverPtr data, vboxIIDUnion *iidu, const unsigned char *uuid) { vboxIIDFromUUID_v2_x(data, &iidu->vboxIID_v2_x, uuid); @@ -453,14 +420,14 @@ vboxIIDIsEqual_v2_x(vboxIID_v2_x *iid1, vboxIID_v2_x *iid2) } static bool -_vboxIIDIsEqual(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vboxIIDIsEqual(vboxDriverPtr data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2) { return vboxIIDIsEqual_v2_x(&iidu1->vboxIID_v2_x, &iidu2->vboxIID_v2_x); } static void -vboxIIDFromArrayItem_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid, +vboxIIDFromArrayItem_v2_x(vboxDriverPtr data, vboxIID_v2_x *iid, vboxArray *array, int idx) { vboxIIDUnalloc_v2_x(data, iid); @@ -471,7 +438,7 @@ vboxIIDFromArrayItem_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid, } static void -_vboxIIDFromArrayItem(vboxGlobalData *data, vboxIIDUnion *iidu, +_vboxIIDFromArrayItem(vboxDriverPtr data, vboxIIDUnion *iidu, vboxArray *array, int idx) { vboxIIDFromArrayItem_v2_x(data, &iidu->vboxIID_v2_x, array, idx); @@ -496,7 +463,7 @@ typedef struct _vboxIID_v3_x vboxIID_v3_x; # define IID_MEMBER(name) (iidu->vboxIID_v3_x.name) static void -vboxIIDUnalloc_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid) +vboxIIDUnalloc_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid) { if (iid->value != NULL && iid->owner) data->pFuncs->pfnUtf16Free(iid->value); @@ -506,13 +473,13 @@ vboxIIDUnalloc_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid) } static void -_vboxIIDUnalloc(vboxGlobalData *data, vboxIIDUnion *iidu) +_vboxIIDUnalloc(vboxDriverPtr data, vboxIIDUnion *iidu) { vboxIIDUnalloc_v3_x(data, &iidu->vboxIID_v3_x); } static void -vboxIIDToUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid, +vboxIIDToUUID_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid, unsigned char *uuid) { char *utf8 = NULL; @@ -525,14 +492,14 @@ vboxIIDToUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid, } static void -_vboxIIDToUUID(vboxGlobalData *data, vboxIIDUnion *iidu, +_vboxIIDToUUID(vboxDriverPtr data, vboxIIDUnion *iidu, unsigned char *uuid) { vboxIIDToUUID_v3_x(data, &iidu->vboxIID_v3_x, uuid); } static void -vboxIIDFromUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid, +vboxIIDFromUUID_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid, const unsigned char *uuid) { char utf8[VIR_UUID_STRING_BUFLEN]; @@ -545,14 +512,14 @@ vboxIIDFromUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid, } static void -_vboxIIDFromUUID(vboxGlobalData *data, vboxIIDUnion *iidu, +_vboxIIDFromUUID(vboxDriverPtr data, vboxIIDUnion *iidu, const unsigned char *uuid) { vboxIIDFromUUID_v3_x(data, &iidu->vboxIID_v3_x, uuid); } static bool -vboxIIDIsEqual_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid1, +vboxIIDIsEqual_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid1, vboxIID_v3_x *iid2) { unsigned char uuid1[VIR_UUID_BUFLEN]; @@ -570,14 +537,14 @@ vboxIIDIsEqual_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid1, } static bool -_vboxIIDIsEqual(vboxGlobalData *data, vboxIIDUnion *iidu1, +_vboxIIDIsEqual(vboxDriverPtr data, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2) { return vboxIIDIsEqual_v3_x(data, &iidu1->vboxIID_v3_x, &iidu2->vboxIID_v3_x); } static void -vboxIIDFromArrayItem_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid, +vboxIIDFromArrayItem_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid, vboxArray *array, int idx) { vboxIIDUnalloc_v3_x(data, iid); @@ -587,7 +554,7 @@ vboxIIDFromArrayItem_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid, } static void -_vboxIIDFromArrayItem(vboxGlobalData *data, vboxIIDUnion *iidu, +_vboxIIDFromArrayItem(vboxDriverPtr data, vboxIIDUnion *iidu, vboxArray *array, int idx) { vboxIIDFromArrayItem_v3_x(data, &iidu->vboxIID_v3_x, array, idx); @@ -730,7 +697,7 @@ static bool vboxGetMaxPortSlotValues(IVirtualBox *vbox, /** * Converts Utf-16 string to int */ -static int PRUnicharToInt(PRUnichar *strUtf16) +static int PRUnicharToInt(PCVBOXXPCOM pFuncs, PRUnichar *strUtf16) { char *strUtf8 = NULL; int ret = 0; @@ -738,14 +705,14 @@ static int PRUnicharToInt(PRUnichar *strUtf16) if (!strUtf16) return -1; - g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8); + pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8); if (!strUtf8) return -1; if (virStrToLong_i(strUtf8, NULL, 10, &ret) < 0) ret = -1; - g_pVBoxGlobalData->pFuncs->pfnUtf8Free(strUtf8); + pFuncs->pfnUtf8Free(strUtf8); return ret; } @@ -753,13 +720,13 @@ static int PRUnicharToInt(PRUnichar *strUtf16) /** * Converts int to Utf-16 string */ -static PRUnichar *PRUnicharFromInt(int n) { +static PRUnichar *PRUnicharFromInt(PCVBOXXPCOM pFuncs, int n) { PRUnichar *strUtf16 = NULL; char s[24]; snprintf(s, sizeof(s), "%d", n); - g_pVBoxGlobalData->pFuncs->pfnUtf8ToUtf16(s, &strUtf16); + pFuncs->pfnUtf8ToUtf16(s, &strUtf16); return strUtf16; } @@ -791,7 +758,7 @@ static virDomainState _vboxConvertState(PRUint32 state) #if VBOX_API_VERSION < 3001000 static void -_vboxAttachDrivesOld(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +_vboxAttachDrivesOld(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { size_t i; nsresult rc; @@ -1037,7 +1004,7 @@ _vboxAttachDrivesOld(virDomainDefPtr def, vboxGlobalData *data, IMachine *machin #elif VBOX_API_VERSION < 4000000 static void -_vboxAttachDrivesOld(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +_vboxAttachDrivesOld(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { size_t i; nsresult rc = 0; @@ -1264,7 +1231,7 @@ _vboxAttachDrivesOld(virDomainDefPtr def, vboxGlobalData *data, IMachine *machin static void _vboxAttachDrivesOld(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxGlobalData *data ATTRIBUTE_UNUSED, + vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED) { vboxUnsupported(); @@ -1278,7 +1245,7 @@ _vboxDomainSnapshotRestore(virDomainPtr dom, IMachine *machine, ISnapshot *snapshot) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; vboxIID iid = VBOX_IID_INITIALIZER; nsresult rc; int ret = -1; @@ -1312,7 +1279,7 @@ _vboxDomainSnapshotRestore(virDomainPtr dom, IMachine *machine, ISnapshot *snapshot) { - vboxGlobalData *data = dom->conn->privateData; + vboxDriverPtr data = dom->conn->privateData; # if VBOX_API_VERSION < 5000000 IConsole *console = NULL; # endif /*VBOX_API_VERSION < 5000000*/ @@ -1418,23 +1385,26 @@ static nsresult PR_COM_METHOD vboxCallbackOnMachineStateChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId, PRUint32 state) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; virDomainPtr dom = NULL; + int event = 0; int detail = 0; - vboxDriverLock(g_pVBoxGlobalData); + virObjectLock(data); - VIR_DEBUG("IVirtualBoxCallback: %p, State: %d", pThis, state); + VIR_DEBUG("IVirtualBoxCallback: %p, State: %d", callback, state); DEBUGPRUnichar("machineId", machineId); if (machineId) { char *machineIdUtf8 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; - g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(machineId, &machineIdUtf8); + data->pFuncs->pfnUtf16ToUtf8(machineId, &machineIdUtf8); ignore_value(virUUIDParse(machineIdUtf8, uuid)); - dom = vboxDomainLookupByUUID(g_pVBoxGlobalData->conn, uuid); + dom = vboxDomainLookupByUUID(callback->conn, uuid); if (dom) { virObjectEventPtr ev; @@ -1470,11 +1440,11 @@ vboxCallbackOnMachineStateChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, ev = virDomainEventLifecycleNewFromDom(dom, event, detail); if (ev) - virObjectEventStateQueue(g_pVBoxGlobalData->domainEvents, ev); + virObjectEventStateQueue(data->domainEventState, ev); } } - vboxDriverUnlock(g_pVBoxGlobalData); + virObjectUnlock(data); return NS_OK; } @@ -1483,6 +1453,9 @@ static nsresult PR_COM_METHOD vboxCallbackOnMachineDataChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p", pThis); DEBUGPRUnichar("machineId", machineId); @@ -1496,6 +1469,9 @@ vboxCallbackOnExtraDataCanChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar **error ATTRIBUTE_UNUSED, PRBool *allowChange ATTRIBUTE_UNUSED) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p, allowChange: %s", pThis, *allowChange ? "true" : "false"); DEBUGPRUnichar("machineId", machineId); DEBUGPRUnichar("key", key); @@ -1509,6 +1485,9 @@ vboxCallbackOnExtraDataChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId, PRUnichar *key, PRUnichar *value) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p", pThis); DEBUGPRUnichar("machineId", machineId); DEBUGPRUnichar("key", key); @@ -1524,24 +1503,28 @@ vboxCallbackOnMediaRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUint32 mediaType ATTRIBUTE_UNUSED, PRBool registered ATTRIBUTE_UNUSED) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false"); VIR_DEBUG("mediaType: %d", mediaType); DEBUGPRUnichar("mediaId", mediaId); return NS_OK; } -# else /* VBOX_API_VERSION >= 3001000 */ # endif /* VBOX_API_VERSION >= 3001000 */ static nsresult PR_COM_METHOD vboxCallbackOnMachineRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId, PRBool registered) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; virDomainPtr dom = NULL; int event = 0; int detail = 0; - vboxDriverLock(g_pVBoxGlobalData); + virObjectLock(data); VIR_DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false"); DEBUGPRUnichar("machineId", machineId); @@ -1550,10 +1533,10 @@ vboxCallbackOnMachineRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, char *machineIdUtf8 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; - g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(machineId, &machineIdUtf8); + data->pFuncs->pfnUtf16ToUtf8(machineId, &machineIdUtf8); ignore_value(virUUIDParse(machineIdUtf8, uuid)); - dom = vboxDomainLookupByUUID(g_pVBoxGlobalData->conn, uuid); + dom = vboxDomainLookupByUUID(callback->conn, uuid); if (dom) { virObjectEventPtr ev; @@ -1574,11 +1557,11 @@ vboxCallbackOnMachineRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, ev = virDomainEventLifecycleNewFromDom(dom, event, detail); if (ev) - virObjectEventStateQueue(g_pVBoxGlobalData->domainEvents, ev); + virObjectEventStateQueue(data->domainEventState, ev); } } - vboxDriverUnlock(g_pVBoxGlobalData); + virObjectUnlock(data); return NS_OK; } @@ -1588,6 +1571,9 @@ vboxCallbackOnSessionStateChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId, PRUint32 state ATTRIBUTE_UNUSED) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p, state: %d", pThis, state); DEBUGPRUnichar("machineId", machineId); @@ -1599,6 +1585,9 @@ vboxCallbackOnSnapshotTaken(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId, PRUnichar *snapshotId) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p", pThis); DEBUGPRUnichar("machineId", machineId); DEBUGPRUnichar("snapshotId", snapshotId); @@ -1611,6 +1600,9 @@ vboxCallbackOnSnapshotDiscarded(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId, PRUnichar *snapshotId) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p", pThis); DEBUGPRUnichar("machineId", machineId); DEBUGPRUnichar("snapshotId", snapshotId); @@ -1623,6 +1615,9 @@ vboxCallbackOnSnapshotChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId, PRUnichar *snapshotId) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p", pThis); DEBUGPRUnichar("machineId", machineId); DEBUGPRUnichar("snapshotId", snapshotId); @@ -1635,6 +1630,9 @@ vboxCallbackOnGuestPropertyChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, PRUnichar *machineId, PRUnichar *name, PRUnichar *value, PRUnichar *flags) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; + vboxDriverPtr data = callback->conn->privateData; + VIR_DEBUG("IVirtualBoxCallback: %p", pThis); DEBUGPRUnichar("machineId", machineId); DEBUGPRUnichar("name", name); @@ -1647,9 +1645,10 @@ vboxCallbackOnGuestPropertyChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, static nsresult PR_COM_METHOD vboxCallbackAddRef(nsISupports *pThis ATTRIBUTE_UNUSED) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; nsresult c; - c = ++g_pVBoxGlobalData->vboxCallBackRefCount; + c = ++callback->vboxCallBackRefCount; VIR_DEBUG("pThis: %p, vboxCallback AddRef: %d", pThis, c); @@ -1659,9 +1658,10 @@ vboxCallbackAddRef(nsISupports *pThis ATTRIBUTE_UNUSED) static nsresult PR_COM_METHOD vboxCallbackRelease(nsISupports *pThis) { + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; nsresult c; - c = --g_pVBoxGlobalData->vboxCallBackRefCount; + c = --callback->vboxCallBackRefCount; if (c == 0) { /* delete object */ VIR_FREE(pThis->vtbl); @@ -1676,17 +1676,17 @@ vboxCallbackRelease(nsISupports *pThis) static nsresult PR_COM_METHOD vboxCallbackQueryInterface(nsISupports *pThis, const nsID *iid, void **resultp) { - IVirtualBoxCallback *that = (IVirtualBoxCallback *)pThis; + vboxCallbackPtr callback = (vboxCallbackPtr) pThis; static const nsID ivirtualboxCallbackUUID = IVIRTUALBOXCALLBACK_IID; static const nsID isupportIID = NS_ISUPPORTS_IID; /* Match UUID for IVirtualBoxCallback class */ if (memcmp(iid, &ivirtualboxCallbackUUID, sizeof(nsID)) == 0 || memcmp(iid, &isupportIID, sizeof(nsID)) == 0) { - g_pVBoxGlobalData->vboxCallBackRefCount++; - *resultp = that; + callback->vboxCallBackRefCount++; + *resultp = callback; - VIR_DEBUG("pThis: %p, vboxCallback QueryInterface: %d", pThis, g_pVBoxGlobalData->vboxCallBackRefCount); + VIR_DEBUG("pThis: %p, vboxCallback QueryInterface: %d", pThis, callback->vboxCallBackRefCount); return NS_OK; } @@ -1699,60 +1699,64 @@ vboxCallbackQueryInterface(nsISupports *pThis, const nsID *iid, void **resultp) } -static IVirtualBoxCallback *vboxAllocCallbackObj(void) { - IVirtualBoxCallback *vboxCallback = NULL; +static vboxCallbackPtr +vboxAllocCallbackObj(virConnectPtr conn) +{ + vboxCallbackPtr callback = NULL; /* Allocate, Initialize and return a valid * IVirtualBoxCallback object here */ - if ((VIR_ALLOC(vboxCallback) < 0) || (VIR_ALLOC(vboxCallback->vtbl) < 0)) { - VIR_FREE(vboxCallback); + if ((VIR_ALLOC(callback) < 0) || (VIR_ALLOC(callback->vtbl) < 0)) { + VIR_FREE(callback); return NULL; } { - vboxCallback->vtbl->nsisupports.AddRef = &vboxCallbackAddRef; - vboxCallback->vtbl->nsisupports.Release = &vboxCallbackRelease; - vboxCallback->vtbl->nsisupports.QueryInterface = &vboxCallbackQueryInterface; - vboxCallback->vtbl->OnMachineStateChange = &vboxCallbackOnMachineStateChange; - vboxCallback->vtbl->OnMachineDataChange = &vboxCallbackOnMachineDataChange; - vboxCallback->vtbl->OnExtraDataCanChange = &vboxCallbackOnExtraDataCanChange; - vboxCallback->vtbl->OnExtraDataChange = &vboxCallbackOnExtraDataChange; + callback->vtbl->nsisupports.AddRef = &vboxCallbackAddRef; + callback->vtbl->nsisupports.Release = &vboxCallbackRelease; + callback->vtbl->nsisupports.QueryInterface = &vboxCallbackQueryInterface; + callback->vtbl->OnMachineStateChange = &vboxCallbackOnMachineStateChange; + callback->vtbl->OnMachineDataChange = &vboxCallbackOnMachineDataChange; + callback->vtbl->OnExtraDataCanChange = &vboxCallbackOnExtraDataCanChange; + callback->vtbl->OnExtraDataChange = &vboxCallbackOnExtraDataChange; # if VBOX_API_VERSION < 3001000 - vboxCallback->vtbl->OnMediaRegistered = &vboxCallbackOnMediaRegistered; + callback->vtbl->OnMediaRegistered = &vboxCallbackOnMediaRegistered; # else /* VBOX_API_VERSION >= 3001000 */ # endif /* VBOX_API_VERSION >= 3001000 */ - vboxCallback->vtbl->OnMachineRegistered = &vboxCallbackOnMachineRegistered; - vboxCallback->vtbl->OnSessionStateChange = &vboxCallbackOnSessionStateChange; - vboxCallback->vtbl->OnSnapshotTaken = &vboxCallbackOnSnapshotTaken; + callback->vtbl->OnMachineRegistered = &vboxCallbackOnMachineRegistered; + callback->vtbl->OnSessionStateChange = &vboxCallbackOnSessionStateChange; + callback->vtbl->OnSnapshotTaken = &vboxCallbackOnSnapshotTaken; # if VBOX_API_VERSION < 3002000 - vboxCallback->vtbl->OnSnapshotDiscarded = &vboxCallbackOnSnapshotDiscarded; + callback->vtbl->OnSnapshotDiscarded = &vboxCallbackOnSnapshotDiscarded; # else /* VBOX_API_VERSION >= 3002000 */ - vboxCallback->vtbl->OnSnapshotDeleted = &vboxCallbackOnSnapshotDiscarded; + callback->vtbl->OnSnapshotDeleted = &vboxCallbackOnSnapshotDiscarded; # endif /* VBOX_API_VERSION >= 3002000 */ - vboxCallback->vtbl->OnSnapshotChange = &vboxCallbackOnSnapshotChange; - vboxCallback->vtbl->OnGuestPropertyChange = &vboxCallbackOnGuestPropertyChange; - g_pVBoxGlobalData->vboxCallBackRefCount = 1; - + callback->vtbl->OnSnapshotChange = &vboxCallbackOnSnapshotChange; + callback->vtbl->OnGuestPropertyChange = &vboxCallbackOnGuestPropertyChange; + callback->vboxCallBackRefCount = 1; } - return vboxCallback; + callback->conn = conn; + + return callback; } static void vboxReadCallback(int watch ATTRIBUTE_UNUSED, int fd, int events ATTRIBUTE_UNUSED, - void *opaque ATTRIBUTE_UNUSED) + void *opaque) { + vboxDriverPtr data = (vboxDriverPtr) opaque; if (fd >= 0) { - g_pVBoxGlobalData->vboxQueue->vtbl->ProcessPendingEvents(g_pVBoxGlobalData->vboxQueue); + data->vboxQueue->vtbl->ProcessPendingEvents(data->vboxQueue); } else { nsresult rc; PLEvent *pEvent = NULL; - rc = g_pVBoxGlobalData->vboxQueue->vtbl->WaitForEvent(g_pVBoxGlobalData->vboxQueue, &pEvent); + rc = data->vboxQueue->vtbl->WaitForEvent(data->vboxQueue, &pEvent); if (NS_SUCCEEDED(rc)) - g_pVBoxGlobalData->vboxQueue->vtbl->HandleEvent(g_pVBoxGlobalData->vboxQueue, pEvent); + data->vboxQueue->vtbl->HandleEvent(data->vboxQueue, pEvent); } } @@ -1762,7 +1766,7 @@ vboxConnectDomainEventRegister(virConnectPtr conn, void *opaque, virFreeCallback freecb) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; int vboxRet = -1; nsresult rc; int ret = -1; @@ -1773,12 +1777,13 @@ vboxConnectDomainEventRegister(virConnectPtr conn, /* Locking has to be there as callbacks are not * really fully thread safe */ - vboxDriverLock(data); + virObjectLock(data); if (data->vboxCallback == NULL) { - data->vboxCallback = vboxAllocCallbackObj(); + data->vboxCallback = vboxAllocCallbackObj(conn); if (data->vboxCallback != NULL) { - rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback); + rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, + (IVirtualBoxCallback *) data->vboxCallback); if (NS_SUCCEEDED(rc)) vboxRet = 0; } @@ -1794,7 +1799,7 @@ vboxConnectDomainEventRegister(virConnectPtr conn, PRInt32 vboxFileHandle; vboxFileHandle = data->vboxQueue->vtbl->GetEventQueueSelectFD(data->vboxQueue); - data->fdWatch = virEventAddHandle(vboxFileHandle, VIR_EVENT_HANDLE_READABLE, vboxReadCallback, NULL, NULL); + data->fdWatch = virEventAddHandle(vboxFileHandle, VIR_EVENT_HANDLE_READABLE, vboxReadCallback, data, NULL); } if (data->fdWatch >= 0) { @@ -1803,7 +1808,7 @@ vboxConnectDomainEventRegister(virConnectPtr conn, * later you can iterate over them */ - ret = virDomainEventStateRegister(conn, data->domainEvents, + ret = virDomainEventStateRegister(conn, data->domainEventState, callback, opaque, freecb); VIR_DEBUG("virObjectEventStateRegister (ret = %d) (conn: %p, " "callback: %p, opaque: %p, " @@ -1812,13 +1817,14 @@ vboxConnectDomainEventRegister(virConnectPtr conn, } } - vboxDriverUnlock(data); + virObjectUnlock(data); if (ret >= 0) { return 0; } else { if (data->vboxObj && data->vboxCallback) - data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback); + data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, + (IVirtualBoxCallback *) data->vboxCallback); return -1; } } @@ -1827,7 +1833,7 @@ static int vboxConnectDomainEventDeregister(virConnectPtr conn, virConnectDomainEventCallback callback) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; int cnt; int ret = -1; @@ -1837,13 +1843,14 @@ vboxConnectDomainEventDeregister(virConnectPtr conn, /* Locking has to be there as callbacks are not * really fully thread safe */ - vboxDriverLock(data); + virObjectLock(data); - cnt = virDomainEventStateDeregister(conn, data->domainEvents, + cnt = virDomainEventStateDeregister(conn, data->domainEventState, callback); if (data->vboxCallback && cnt == 0) { - data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback); + data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, + (IVirtualBoxCallback *) data->vboxCallback); VBOX_RELEASE(data->vboxCallback); /* Remove the Event file handle on which we are listening as well */ @@ -1851,7 +1858,7 @@ vboxConnectDomainEventDeregister(virConnectPtr conn, data->fdWatch = -1; } - vboxDriverUnlock(data); + virObjectUnlock(data); if (cnt >= 0) ret = 0; @@ -1866,7 +1873,7 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, void *opaque, virFreeCallback freecb) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; int vboxRet = -1; nsresult rc; int ret = -1; @@ -1877,12 +1884,13 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, /* Locking has to be there as callbacks are not * really fully thread safe */ - vboxDriverLock(data); + virObjectLock(data); if (data->vboxCallback == NULL) { - data->vboxCallback = vboxAllocCallbackObj(); + data->vboxCallback = vboxAllocCallbackObj(conn); if (data->vboxCallback != NULL) { - rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback); + rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, + (IVirtualBoxCallback *) data->vboxCallback); if (NS_SUCCEEDED(rc)) vboxRet = 0; } @@ -1898,7 +1906,7 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, PRInt32 vboxFileHandle; vboxFileHandle = data->vboxQueue->vtbl->GetEventQueueSelectFD(data->vboxQueue); - data->fdWatch = virEventAddHandle(vboxFileHandle, VIR_EVENT_HANDLE_READABLE, vboxReadCallback, NULL, NULL); + data->fdWatch = virEventAddHandle(vboxFileHandle, VIR_EVENT_HANDLE_READABLE, vboxReadCallback, data, NULL); } if (data->fdWatch >= 0) { @@ -1907,7 +1915,7 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, * later you can iterate over them */ - if (virDomainEventStateRegisterID(conn, data->domainEvents, + if (virDomainEventStateRegisterID(conn, data->domainEventState, dom, eventID, callback, opaque, freecb, &ret) < 0) ret = -1; @@ -1918,13 +1926,14 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, } } - vboxDriverUnlock(data); + virObjectUnlock(data); if (ret >= 0) { return ret; } else { if (data->vboxObj && data->vboxCallback) - data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback); + data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, + (IVirtualBoxCallback *) data->vboxCallback); return -1; } } @@ -1933,7 +1942,7 @@ static int vboxConnectDomainEventDeregisterAny(virConnectPtr conn, int callbackID) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; int cnt; int ret = -1; @@ -1943,13 +1952,14 @@ vboxConnectDomainEventDeregisterAny(virConnectPtr conn, /* Locking has to be there as callbacks are not * really fully thread safe */ - vboxDriverLock(data); + virObjectLock(data); - cnt = virObjectEventStateDeregisterID(conn, data->domainEvents, + cnt = virObjectEventStateDeregisterID(conn, data->domainEventState, callbackID); if (data->vboxCallback && cnt == 0) { - data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback); + data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, + (IVirtualBoxCallback *) data->vboxCallback); VBOX_RELEASE(data->vboxCallback); /* Remove the Event file handle on which we are listening as well */ @@ -1957,7 +1967,7 @@ vboxConnectDomainEventDeregisterAny(virConnectPtr conn, data->fdWatch = -1; } - vboxDriverUnlock(data); + virObjectUnlock(data); if (cnt >= 0) ret = 0; @@ -1995,21 +2005,11 @@ _initializeDomainEvent(vboxDriverPtr data ATTRIBUTE_UNUSED) return 0; } -static -void _registerGlobalData(vboxGlobalData *data ATTRIBUTE_UNUSED) -{ -#if VBOX_API_VERSION == 2002000 - vboxUnsupported(); -#else /* VBOX_API_VERSION != 2002000 */ - g_pVBoxGlobalData = data; -#endif /* VBOX_API_VERSION != 2002000 */ -} - #if VBOX_API_VERSION < 4000000 # if VBOX_API_VERSION < 3001000 static void -_detachDevices(vboxGlobalData *data ATTRIBUTE_UNUSED, +_detachDevices(vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine, PRUnichar *hddcnameUtf16) { /* Disconnect all the drives if present */ @@ -2019,7 +2019,7 @@ _detachDevices(vboxGlobalData *data ATTRIBUTE_UNUSED, } # else /* VBOX_API_VERSION >= 3001000 */ static void -_detachDevices(vboxGlobalData *data, IMachine *machine, +_detachDevices(vboxDriverPtr data, IMachine *machine, PRUnichar *hddcnameUtf16 ATTRIBUTE_UNUSED) { /* get all the controller first, then the attachments and @@ -2071,7 +2071,7 @@ _detachDevices(vboxGlobalData *data, IMachine *machine, # endif /* VBOX_API_VERSION >= 3001000 */ static nsresult -_unregisterMachine(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine **machine) +_unregisterMachine(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine **machine) { return data->vboxObj->vtbl->UnregisterMachine(data->vboxObj, IID_MEMBER(value), machine); } @@ -2085,7 +2085,7 @@ _deleteConfig(IMachine *machine) #else /* VBOX_API_VERSION >= 4000000 */ static void -_detachDevices(vboxGlobalData *data ATTRIBUTE_UNUSED, +_detachDevices(vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED, PRUnichar *hddcnameUtf16 ATTRIBUTE_UNUSED) { @@ -2093,7 +2093,7 @@ _detachDevices(vboxGlobalData *data ATTRIBUTE_UNUSED, } static nsresult -_unregisterMachine(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine **machine) +_unregisterMachine(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine **machine) { nsresult rc; vboxArray media = VBOX_ARRAY_INITIALIZER; @@ -2157,7 +2157,7 @@ _deleteConfig(IMachine *machine) static void _dumpIDEHDDsOld(virDomainDefPtr def, - vboxGlobalData *data, + vboxDriverPtr data, IMachine *machine) { PRInt32 hddNum = 0; @@ -2266,7 +2266,7 @@ _dumpIDEHDDsOld(virDomainDefPtr def, static void _dumpDVD(virDomainDefPtr def, - vboxGlobalData *data, + vboxDriverPtr data, IMachine *machine) { IDVDDrive *dvdDrive = NULL; @@ -2321,7 +2321,7 @@ _dumpDVD(virDomainDefPtr def, } static int -_attachDVD(vboxGlobalData *data, IMachine *machine, const char *src) +_attachDVD(vboxDriverPtr data, IMachine *machine, const char *src) { IDVDDrive *dvdDrive = NULL; IDVDImage *dvdImage = NULL; @@ -2405,7 +2405,7 @@ _detachDVD(IMachine *machine) static void _dumpFloppy(virDomainDefPtr def, - vboxGlobalData *data, + vboxDriverPtr data, IMachine *machine) { IFloppyDrive *floppyDrive = NULL; @@ -2463,7 +2463,7 @@ _dumpFloppy(virDomainDefPtr def, } static int -_attachFloppy(vboxGlobalData *data, IMachine *machine, const char *src) +_attachFloppy(vboxDriverPtr data, IMachine *machine, const char *src) { IFloppyDrive *floppyDrive; IFloppyImage *floppyImage = NULL; @@ -2560,7 +2560,7 @@ _detachFloppy(IMachine *machine) static void _dumpIDEHDDsOld(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxGlobalData *data ATTRIBUTE_UNUSED, + vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED) { vboxUnsupported(); @@ -2568,14 +2568,14 @@ _dumpIDEHDDsOld(virDomainDefPtr def ATTRIBUTE_UNUSED, static void _dumpDVD(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxGlobalData *data ATTRIBUTE_UNUSED, + vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED) { vboxUnsupported(); } static int -_attachDVD(vboxGlobalData *data ATTRIBUTE_UNUSED, +_attachDVD(vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED, const char *src ATTRIBUTE_UNUSED) { @@ -2592,14 +2592,14 @@ _detachDVD(IMachine *machine ATTRIBUTE_UNUSED) static void _dumpFloppy(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxGlobalData *data ATTRIBUTE_UNUSED, + vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED) { vboxUnsupported(); } static int -_attachFloppy(vboxGlobalData *data ATTRIBUTE_UNUSED, +_attachFloppy(vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED, const char *src ATTRIBUTE_UNUSED) { @@ -2694,7 +2694,7 @@ static void _vboxIIDInitialize(vboxIIDUnion *iidu) memset(iidu, 0, sizeof(vboxIIDUnion)); } -static void _DEBUGIID(const char *msg, vboxIIDUnion *iidu) +static void _DEBUGIID(vboxDriverPtr driver ATTRIBUTE_UNUSED, const char *msg, vboxIIDUnion *iidu) { # ifdef WIN32 DEBUGUUID(msg, (nsID *)&IID_MEMBER(value)); @@ -2711,7 +2711,7 @@ static void _vboxIIDInitialize(vboxIIDUnion *iidu) IID_MEMBER(owner) = true; } -static void _DEBUGIID(const char *msg, vboxIIDUnion *iidu) +static void _DEBUGIID(vboxDriverPtr data, const char *msg, vboxIIDUnion *iidu) { DEBUGPRUnichar(msg, IID_MEMBER(value)); } @@ -2719,7 +2719,7 @@ static void _DEBUGIID(const char *msg, vboxIIDUnion *iidu) #endif /* VBOX_API_VERSION != 2002000 */ static void -_vboxIIDToUtf8(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vboxIIDToUtf8(vboxDriverPtr data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, char **utf8 ATTRIBUTE_UNUSED) { @@ -2848,7 +2848,7 @@ _virtualboxGetHost(IVirtualBox *vboxObj, IHost **host) } static nsresult -_virtualboxCreateMachine(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr ATTRIBUTE_UNUSED) +_virtualboxCreateMachine(vboxDriverPtr data, virDomainDefPtr def, IMachine **machine, char *uuidstr ATTRIBUTE_UNUSED) { vboxIID iid = VBOX_IID_INITIALIZER; PRUnichar *machineNameUtf16 = NULL; @@ -3058,7 +3058,7 @@ _machineRemoveSharedFolder(IMachine *machine, PRUnichar *name) } static nsresult -_machineLaunchVMProcess(vboxGlobalData *data, +_machineLaunchVMProcess(vboxDriverPtr data, IMachine *machine ATTRIBUTE_UNUSED, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, PRUnichar *sessionType, PRUnichar *env, @@ -3356,13 +3356,13 @@ _machineSaveSettings(IMachine *machine) #if VBOX_API_VERSION < 4000000 static nsresult -_sessionOpen(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine *machine ATTRIBUTE_UNUSED) +_sessionOpen(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine *machine ATTRIBUTE_UNUSED) { return data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, IID_MEMBER(value)); } static nsresult -_sessionOpenExisting(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine *machine ATTRIBUTE_UNUSED) +_sessionOpenExisting(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine *machine ATTRIBUTE_UNUSED) { return data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, IID_MEMBER(value)); } @@ -3376,13 +3376,13 @@ _sessionClose(ISession *session) #else /* VBOX_API_VERSION >= 4000000 */ static nsresult -_sessionOpen(vboxGlobalData *data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine) +_sessionOpen(vboxDriverPtr data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine) { return machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write); } static nsresult -_sessionOpenExisting(vboxGlobalData *data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine) +_sessionOpenExisting(vboxDriverPtr data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine) { return machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Shared); } @@ -3957,7 +3957,7 @@ _vrdxServerSetEnabled(IVRDxServer *VRDxServer, PRBool enabled) } static nsresult -_vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vrdxServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) { nsresult rc; @@ -3974,7 +3974,7 @@ _vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, rc = VRDxServer->vtbl->GetPorts(VRDxServer, &VRDPport); if (VRDPport) { /* even if vbox supports mutilpe ports, single port for now here */ - graphics->data.rdp.port = PRUnicharToInt(VRDPport); + graphics->data.rdp.port = PRUnicharToInt(data->pFuncs, VRDPport); VBOX_UTF16_FREE(VRDPport); } else { graphics->data.rdp.autoport = true; @@ -3987,7 +3987,7 @@ _vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, VBOX_UTF16_FREE(VRDEPortsKey); if (VRDEPortsValue) { /* even if vbox supports mutilpe ports, single port for now here */ - graphics->data.rdp.port = PRUnicharToInt(VRDEPortsValue); + graphics->data.rdp.port = PRUnicharToInt(data->pFuncs, VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsValue); } else { graphics->data.rdp.autoport = true; @@ -3997,7 +3997,7 @@ _vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, } static nsresult -_vrdxServerSetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vrdxServerSetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) { nsresult rc = 0; @@ -4016,14 +4016,14 @@ _vrdxServerSetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, } #elif VBOX_API_VERSION < 4000000 /* 3001000 <= VBOX_API_VERSION < 4000000 */ PRUnichar *portUtf16 = NULL; - portUtf16 = PRUnicharFromInt(graphics->data.rdp.port); + portUtf16 = PRUnicharFromInt(data->pFuncs, graphics->data.rdp.port); rc = VRDxServer->vtbl->SetPorts(VRDxServer, portUtf16); VBOX_UTF16_FREE(portUtf16); #else /* VBOX_API_VERSION >= 4000000 */ PRUnichar *VRDEPortsKey = NULL; PRUnichar *VRDEPortsValue = NULL; VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey); - VRDEPortsValue = PRUnicharFromInt(graphics->data.rdp.port); + VRDEPortsValue = PRUnicharFromInt(data->pFuncs, graphics->data.rdp.port); rc = VRDxServer->vtbl->SetVRDEProperty(VRDxServer, VRDEPortsKey, VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsKey); @@ -4057,7 +4057,7 @@ _vrdxServerSetAllowMultiConnection(IVRDxServer *VRDxServer, PRBool enabled) } static nsresult -_vrdxServerGetNetAddress(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vrdxServerGetNetAddress(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, PRUnichar **netAddress) { #if VBOX_API_VERSION >= 4000000 @@ -4073,7 +4073,7 @@ _vrdxServerGetNetAddress(vboxGlobalData *data ATTRIBUTE_UNUSED, } static nsresult -_vrdxServerSetNetAddress(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vrdxServerSetNetAddress(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, PRUnichar *netAddress) { #if VBOX_API_VERSION < 4000000 @@ -4483,7 +4483,7 @@ _hostFindHostNetworkInterfaceByName(IHost *host, PRUnichar *name, } static nsresult -_hostCreateHostOnlyNetworkInterface(vboxGlobalData *data ATTRIBUTE_UNUSED, +_hostCreateHostOnlyNetworkInterface(vboxDriverPtr data ATTRIBUTE_UNUSED, IHost *host, char *name ATTRIBUTE_UNUSED, IHostNetworkInterface **networkInterface) { @@ -5087,7 +5087,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->APIVersion = VBOX_API_VERSION; pVBoxAPI->XPCOMCVersion = VBOX_XPCOMC_VERSION; pVBoxAPI->initializeDomainEvent = _initializeDomainEvent; - pVBoxAPI->registerGlobalData = _registerGlobalData; pVBoxAPI->detachDevices = _detachDevices; pVBoxAPI->unregisterMachine = _unregisterMachine; pVBoxAPI->deleteConfig = _deleteConfig; @@ -5139,12 +5138,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->domainEventCallbacks = 1; #endif /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */ -#if VBOX_API_VERSION == 2002000 - pVBoxAPI->hasStaticGlobalData = 0; -#else /* VBOX_API_VERSION > 2002000 */ - pVBoxAPI->hasStaticGlobalData = 1; -#endif /* VBOX_API_VERSION > 2002000 */ - #if VBOX_API_VERSION >= 4000000 /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */ pVBoxAPI->getMachineForSession = 1; diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 704c377..dae2cf1 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -96,45 +96,14 @@ typedef union { PRInt32 resultCode; } resultCodeUnion; -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 for domainEvent */ -# if defined(VBOX_API_VERSION) && VBOX_API_VERSION > 2002000 && VBOX_API_VERSION < 4000000 - - /* Async event handling */ - virObjectEventStatePtr domainEvents; - int fdWatch; - IVirtualBoxCallback *vboxCallback; - nsIEventQueue *vboxQueue; - - int volatile vboxCallBackRefCount; - - /* pointer back to the connection */ +struct _vboxCallback { + struct IVirtualBoxCallback_vtbl *vtbl; virConnectPtr conn; + int vboxCallBackRefCount; +}; -# else /* VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 || VBOX_API_VERSION undefined */ - - virObjectEventStatePtr domainEvents; - int fdWatch; - void *vboxCallback; - void *vboxQueue; - int volatile vboxCallBackRefCount; - virConnectPtr conn; - -# endif /* VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 || VBOX_API_VERSION undefined */ - -} vboxGlobalData; +typedef struct _vboxCallback vboxCallback; +typedef struct _vboxCallback *vboxCallbackPtr; struct _vboxDriver { virObjectLockable parent; @@ -152,11 +121,10 @@ struct _vboxDriver { # endif int fdWatch; + vboxCallbackPtr vboxCallback; # if VBOX_API_VERSION > 2002000 && VBOX_API_VERSION < 4000000 - IVirtualBoxCallback *vboxCallback; nsIEventQueue *vboxQueue; # else - void *vboxCallback; void *vboxQueue; # endif unsigned long version; @@ -186,13 +154,13 @@ typedef struct { /* Functions for vboxIID */ typedef struct { void (*vboxIIDInitialize)(vboxIIDUnion *iidu); - void (*vboxIIDUnalloc)(vboxGlobalData *data, vboxIIDUnion *iidu); - void (*vboxIIDToUUID)(vboxGlobalData *data, vboxIIDUnion *iidu, unsigned char *uuid); - void (*vboxIIDFromUUID)(vboxGlobalData *data, vboxIIDUnion *iidu, const unsigned char *uuid); - bool (*vboxIIDIsEqual)(vboxGlobalData *data, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2); - void (*vboxIIDFromArrayItem)(vboxGlobalData *data, vboxIIDUnion *iidu, vboxArray *array, int idx); - void (*vboxIIDToUtf8)(vboxGlobalData *data, vboxIIDUnion *iidu, char **utf8); - void (*DEBUGIID)(const char *msg, vboxIIDUnion *iidu); + void (*vboxIIDUnalloc)(vboxDriverPtr driver, vboxIIDUnion *iidu); + void (*vboxIIDToUUID)(vboxDriverPtr driver, vboxIIDUnion *iidu, unsigned char *uuid); + void (*vboxIIDFromUUID)(vboxDriverPtr driver, vboxIIDUnion *iidu, const unsigned char *uuid); + bool (*vboxIIDIsEqual)(vboxDriverPtr driver, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2); + void (*vboxIIDFromArrayItem)(vboxDriverPtr driver, vboxIIDUnion *iidu, vboxArray *array, int idx); + void (*vboxIIDToUtf8)(vboxDriverPtr driver, vboxIIDUnion *iidu, char **utf8); + void (*DEBUGIID)(vboxDriverPtr driver, const char *msg, vboxIIDUnion *iidu); } vboxUniformedIID; /* Functions for vboxArray */ @@ -227,7 +195,7 @@ typedef struct { nsresult (*OpenMachine)(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine); nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties); nsresult (*GetHost)(IVirtualBox *vboxObj, IHost **host); - nsresult (*CreateMachine)(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr); + nsresult (*CreateMachine)(vboxDriverPtr driver, virDomainDefPtr def, IMachine **machine, char *uuidstr); nsresult (*CreateHardDisk)(IVirtualBox *vboxObj, PRUnichar *format, PRUnichar *location, IHardDisk **hardDisk); nsresult (*RegisterMachine)(IVirtualBox *vboxObj, IMachine *machine); nsresult (*FindHardDisk)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, @@ -252,7 +220,7 @@ typedef struct { PRUnichar *hostPath, PRBool writable, PRBool automount); nsresult (*RemoveSharedFolder)(IMachine *machine, PRUnichar *name); - nsresult (*LaunchVMProcess)(vboxGlobalData *data, IMachine *machine, + nsresult (*LaunchVMProcess)(vboxDriverPtr driver, IMachine *machine, vboxIIDUnion *iidu, PRUnichar *sessionType, PRUnichar *env, IProgress **progress); @@ -299,8 +267,8 @@ typedef struct { /* Functions for ISession */ typedef struct { - nsresult (*Open)(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine *machine); - nsresult (*OpenExisting)(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine *machine); + nsresult (*Open)(vboxDriverPtr driver, vboxIIDUnion *iidu, IMachine *machine); + nsresult (*OpenExisting)(vboxDriverPtr driver, vboxIIDUnion *iidu, IMachine *machine); nsresult (*GetConsole)(ISession *session, IConsole **console); nsresult (*GetMachine)(ISession *session, IMachine **machine); nsresult (*Close)(ISession *session); @@ -410,17 +378,17 @@ typedef struct { typedef struct { nsresult (*GetEnabled)(IVRDxServer *VRDxServer, PRBool *enabled); nsresult (*SetEnabled)(IVRDxServer *VRDxServer, PRBool enabled); - nsresult (*GetPorts)(vboxGlobalData *data, IVRDxServer *VRDxServer, + nsresult (*GetPorts)(vboxDriverPtr driver, IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics); - nsresult (*SetPorts)(vboxGlobalData *data, IVRDxServer *VRDxServer, + nsresult (*SetPorts)(vboxDriverPtr driver, IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics); nsresult (*GetReuseSingleConnection)(IVRDxServer *VRDxServer, PRBool *enabled); nsresult (*SetReuseSingleConnection)(IVRDxServer *VRDxServer, PRBool enabled); nsresult (*GetAllowMultiConnection)(IVRDxServer *VRDxServer, PRBool *enabled); nsresult (*SetAllowMultiConnection)(IVRDxServer *VRDxServer, PRBool enabled); - nsresult (*GetNetAddress)(vboxGlobalData *data, IVRDxServer *VRDxServer, + nsresult (*GetNetAddress)(vboxDriverPtr driver, IVRDxServer *VRDxServer, PRUnichar **netAddress); - nsresult (*SetNetAddress)(vboxGlobalData *data, IVRDxServer *VRDxServer, + nsresult (*SetNetAddress)(vboxDriverPtr driver, IVRDxServer *VRDxServer, PRUnichar *netAddress); } vboxUniformedIVRDxServer; @@ -518,7 +486,7 @@ typedef struct { IHostNetworkInterface **networkInterface); nsresult (*FindHostNetworkInterfaceByName)(IHost *host, PRUnichar *name, IHostNetworkInterface **networkInterface); - nsresult (*CreateHostOnlyNetworkInterface)(vboxGlobalData *data, + nsresult (*CreateHostOnlyNetworkInterface)(vboxDriverPtr driver, IHost *host, char *name, IHostNetworkInterface **networkInterface); nsresult (*RemoveHostOnlyNetworkInterface)(IHost *host, vboxIIDUnion *iidu, @@ -587,18 +555,17 @@ typedef struct { uint32_t XPCOMCVersion; /* vbox APIs */ int (*initializeDomainEvent)(vboxDriverPtr driver); - void (*registerGlobalData)(vboxGlobalData *data); - void (*detachDevices)(vboxGlobalData *data, IMachine *machine, PRUnichar *hddcnameUtf16); - nsresult (*unregisterMachine)(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine **machine); + void (*detachDevices)(vboxDriverPtr driver, IMachine *machine, PRUnichar *hddcnameUtf16); + nsresult (*unregisterMachine)(vboxDriverPtr driver, vboxIIDUnion *iidu, IMachine **machine); void (*deleteConfig)(IMachine *machine); - void (*vboxAttachDrivesOld)(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine); + void (*vboxAttachDrivesOld)(virDomainDefPtr def, vboxDriverPtr driver, IMachine *machine); virDomainState (*vboxConvertState)(PRUint32 state); - void (*dumpIDEHDDsOld)(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine); - void (*dumpDVD)(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine); - int (*attachDVD)(vboxGlobalData *data, IMachine *machine, const char *src); + void (*dumpIDEHDDsOld)(virDomainDefPtr def, vboxDriverPtr driver, IMachine *machine); + void (*dumpDVD)(virDomainDefPtr def, vboxDriverPtr driver, IMachine *machine); + int (*attachDVD)(vboxDriverPtr driver, IMachine *machine, const char *src); int (*detachDVD)(IMachine *machine); - void (*dumpFloppy)(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine); - int (*attachFloppy)(vboxGlobalData *data, IMachine *machine, const char *src); + void (*dumpFloppy)(virDomainDefPtr def, vboxDriverPtr driver, IMachine *machine); + int (*attachFloppy)(vboxDriverPtr driver, IMachine *machine, const char *src); int (*detachFloppy)(IMachine *machine); int (*snapshotRestore)(virDomainPtr dom, IMachine *machine, ISnapshot *snapshot); void (*registerDomainEvent)(virHypervisorDriverPtr driver); @@ -634,7 +601,6 @@ typedef struct { uniformedMachineStateChecker machineStateChecker; /* vbox API features */ bool domainEventCallbacks; - bool hasStaticGlobalData; bool getMachineForSession; bool detachDevicesExplicitly; bool chipsetType; -- 2.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list