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 912c716..7ae3dc7 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -282,7 +282,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); @@ -543,7 +543,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; @@ -595,24 +595,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; } @@ -642,7 +632,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; @@ -669,22 +659,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; @@ -726,7 +716,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; @@ -765,7 +755,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; @@ -843,7 +833,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; @@ -920,7 +910,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; @@ -992,7 +982,7 @@ vboxDomainLookupByName(virConnectPtr conn, const char *name) } static void -vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data, +vboxSetBootDeviceOrder(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { ISystemProperties *systemProperties = NULL; @@ -1049,7 +1039,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; @@ -1258,7 +1248,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 @@ -1329,7 +1319,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; @@ -1475,7 +1465,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; @@ -1551,7 +1541,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; @@ -1640,7 +1630,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; @@ -1787,7 +1777,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; @@ -1891,7 +1881,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; @@ -1920,7 +1910,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; @@ -2068,7 +2058,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 @@ -2105,7 +2095,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; @@ -2148,7 +2138,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; @@ -2300,7 +2290,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; @@ -2405,7 +2395,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; @@ -2477,7 +2467,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; @@ -2500,7 +2490,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; @@ -2521,7 +2511,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; @@ -2572,7 +2562,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; @@ -2623,7 +2613,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; @@ -2680,7 +2670,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; @@ -2728,7 +2718,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; @@ -2794,7 +2784,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; @@ -2852,7 +2842,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; @@ -2936,7 +2926,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; @@ -2967,7 +2957,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; @@ -3021,7 +3011,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; @@ -3058,7 +3048,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; @@ -3164,7 +3154,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; @@ -3325,7 +3315,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. */ @@ -3363,7 +3353,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; @@ -3483,7 +3473,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; @@ -3544,7 +3534,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; @@ -3683,7 +3673,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 */ @@ -3723,7 +3713,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; @@ -3811,7 +3801,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; @@ -3886,7 +3876,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; @@ -4054,7 +4044,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; @@ -4116,7 +4106,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; @@ -4161,7 +4151,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; @@ -4292,7 +4282,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; @@ -4405,7 +4395,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; @@ -4506,7 +4496,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; @@ -5365,7 +5355,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; @@ -5566,7 +5556,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, } static ISnapshot * -vboxDomainSnapshotGet(vboxGlobalData *data, +vboxDomainSnapshotGet(vboxDriverPtr data, virDomainPtr dom, IMachine *machine, const char *name) @@ -5619,7 +5609,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; @@ -5840,7 +5830,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; @@ -6059,7 +6049,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; @@ -6204,7 +6194,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; @@ -6249,7 +6239,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; @@ -6330,7 +6320,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; @@ -6359,7 +6349,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; @@ -6397,7 +6387,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; @@ -6460,7 +6450,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; @@ -6518,7 +6508,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; @@ -6579,7 +6569,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; @@ -6610,7 +6600,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; @@ -6680,7 +6670,7 @@ static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, } static int -vboxDomainSnapshotDeleteSingle(vboxGlobalData *data, +vboxDomainSnapshotDeleteSingle(vboxDriverPtr data, IConsole *console, ISnapshot *snapshot) { @@ -6727,7 +6717,7 @@ vboxDomainSnapshotDeleteSingle(vboxGlobalData *data, } static int -vboxDomainSnapshotDeleteTree(vboxGlobalData *data, +vboxDomainSnapshotDeleteTree(vboxDriverPtr data, IConsole *console, ISnapshot *snapshot) { @@ -6774,7 +6764,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; @@ -7211,7 +7201,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; @@ -7297,7 +7287,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; @@ -7438,7 +7428,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; @@ -7650,7 +7640,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; @@ -7726,7 +7716,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 f68bf1b..e29a7bd 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 743c5d3..27d38ad 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 d44b58b..38d01f4 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -146,10 +146,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);\ }\ } @@ -169,22 +169,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) \ @@ -203,23 +187,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) @@ -311,14 +278,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 */ @@ -331,13 +298,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); @@ -346,7 +313,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); @@ -359,13 +326,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; @@ -376,7 +343,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); @@ -399,7 +366,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; @@ -411,7 +378,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); } @@ -423,14 +390,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); @@ -442,7 +409,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); @@ -455,14 +422,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); @@ -473,7 +440,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); @@ -498,7 +465,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); @@ -508,13 +475,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; @@ -527,14 +494,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]; @@ -547,14 +514,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]; @@ -572,14 +539,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); @@ -589,7 +556,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); @@ -732,7 +699,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; @@ -740,14 +707,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; } @@ -755,13 +722,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; } @@ -793,7 +760,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; @@ -1039,7 +1006,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; @@ -1266,7 +1233,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(); @@ -1280,7 +1247,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; @@ -1314,7 +1281,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*/ @@ -1420,23 +1387,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; @@ -1472,11 +1442,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; } @@ -1485,6 +1455,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); @@ -1498,6 +1471,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); @@ -1511,6 +1487,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); @@ -1526,24 +1505,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); @@ -1552,10 +1535,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; @@ -1576,11 +1559,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; } @@ -1590,6 +1573,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); @@ -1601,6 +1587,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); @@ -1613,6 +1602,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); @@ -1625,6 +1617,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); @@ -1637,6 +1632,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); @@ -1649,9 +1647,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); @@ -1661,9 +1660,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); @@ -1678,17 +1678,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; } @@ -1701,60 +1701,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); } } @@ -1764,7 +1768,7 @@ vboxConnectDomainEventRegister(virConnectPtr conn, void *opaque, virFreeCallback freecb) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; int vboxRet = -1; nsresult rc; int ret = -1; @@ -1775,12 +1779,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; } @@ -1796,7 +1801,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) { @@ -1805,7 +1810,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, " @@ -1814,13 +1819,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; } } @@ -1829,7 +1835,7 @@ static int vboxConnectDomainEventDeregister(virConnectPtr conn, virConnectDomainEventCallback callback) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; int cnt; int ret = -1; @@ -1839,13 +1845,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 */ @@ -1853,7 +1860,7 @@ vboxConnectDomainEventDeregister(virConnectPtr conn, data->fdWatch = -1; } - vboxDriverUnlock(data); + virObjectUnlock(data); if (cnt >= 0) ret = 0; @@ -1868,7 +1875,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; @@ -1879,12 +1886,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; } @@ -1900,7 +1908,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) { @@ -1909,7 +1917,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; @@ -1920,13 +1928,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; } } @@ -1935,7 +1944,7 @@ static int vboxConnectDomainEventDeregisterAny(virConnectPtr conn, int callbackID) { - vboxGlobalData *data = conn->privateData; + vboxDriverPtr data = conn->privateData; int cnt; int ret = -1; @@ -1945,13 +1954,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 */ @@ -1959,7 +1969,7 @@ vboxConnectDomainEventDeregisterAny(virConnectPtr conn, data->fdWatch = -1; } - vboxDriverUnlock(data); + virObjectUnlock(data); if (cnt >= 0) ret = 0; @@ -1997,21 +2007,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 */ @@ -2021,7 +2021,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 @@ -2073,7 +2073,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); } @@ -2087,7 +2087,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) { @@ -2095,7 +2095,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; @@ -2159,7 +2159,7 @@ _deleteConfig(IMachine *machine) static void _dumpIDEHDDsOld(virDomainDefPtr def, - vboxGlobalData *data, + vboxDriverPtr data, IMachine *machine) { PRInt32 hddNum = 0; @@ -2268,7 +2268,7 @@ _dumpIDEHDDsOld(virDomainDefPtr def, static void _dumpDVD(virDomainDefPtr def, - vboxGlobalData *data, + vboxDriverPtr data, IMachine *machine) { IDVDDrive *dvdDrive = NULL; @@ -2323,7 +2323,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; @@ -2407,7 +2407,7 @@ _detachDVD(IMachine *machine) static void _dumpFloppy(virDomainDefPtr def, - vboxGlobalData *data, + vboxDriverPtr data, IMachine *machine) { IFloppyDrive *floppyDrive = NULL; @@ -2465,7 +2465,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; @@ -2562,7 +2562,7 @@ _detachFloppy(IMachine *machine) static void _dumpIDEHDDsOld(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxGlobalData *data ATTRIBUTE_UNUSED, + vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED) { vboxUnsupported(); @@ -2570,14 +2570,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) { @@ -2594,14 +2594,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) { @@ -2696,7 +2696,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)); @@ -2713,7 +2713,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)); } @@ -2721,7 +2721,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) { @@ -2850,7 +2850,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; @@ -3060,7 +3060,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, @@ -3358,13 +3358,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)); } @@ -3378,13 +3378,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); } @@ -3959,7 +3959,7 @@ _vrdxServerSetEnabled(IVRDxServer *VRDxServer, PRBool enabled) } static nsresult -_vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, +_vrdxServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) { nsresult rc; @@ -3976,7 +3976,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; @@ -3989,7 +3989,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; @@ -3999,7 +3999,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; @@ -4018,14 +4018,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); @@ -4059,7 +4059,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 @@ -4075,7 +4075,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 @@ -4485,7 +4485,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) { @@ -5089,7 +5089,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; @@ -5141,12 +5140,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 075d4f6..6a8b6bc 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