[libvirt] [PATCH 00/12] vbox: remove support for vbox 3.x and older.

Hello, This series removes support for legacy VirtualBox versions (3.x and older) that did not have upstream support for a while and won't even work on any relatively recent distro. The idea for doing this was first mentioned here [1] and this makes the driver code cleaner as the APIs for those old versions were quite different from v4.0+ and required abstractions to handle the differences. Please note that the first patch in the series is sent to ML as a compressed attachment because it deletes VirtualBox SDK header files for those old verions which are large and the patch would not pass ML message size limit. [1] https://www.redhat.com/archives/libvir-list/2016-November/msg01133.html Regards, Dawid Dawid Zamirski (12): vbox: remove SDK header files for vbox 3 and older. vbox: remove calls to *InstallUniformedAPI macros. vbox: remove code for old API versions. vbox: remove _vboxAttachDrivesOld vbox: do not use IHardDisk anymore. vbox: remove getMachineForSession flag. vbox: remove domain events support. vbox: remove code dealing with oldMediumInterface vbox: IVRDxServer to IVRDEServer. vbox: fix _displayTakeScreenShotPNGToArray vbox: consolidate vbox IID structures. docs: add news entry in improvements section. docs/news.html.in | 8 + src/Makefile.am | 4 - src/vbox/vbox_CAPI_v2_2.h | 4869 ----------------------------------- src/vbox/vbox_CAPI_v3_0.h | 5396 --------------------------------------- src/vbox/vbox_CAPI_v3_1.h | 5297 -------------------------------------- src/vbox/vbox_CAPI_v3_2.h | 5625 ----------------------------------------- src/vbox/vbox_V2_2.c | 37 - src/vbox/vbox_V3_0.c | 37 - src/vbox/vbox_V3_1.c | 37 - src/vbox/vbox_V3_2.c | 37 - src/vbox/vbox_XPCOMCGlue.h | 2 +- src/vbox/vbox_common.c | 402 +-- src/vbox/vbox_common.h | 13 +- src/vbox/vbox_network.c | 12 +- src/vbox/vbox_storage.c | 76 +- src/vbox/vbox_tmpl.c | 3006 ++-------------------- src/vbox/vbox_uniformed_api.h | 171 +- 17 files changed, 438 insertions(+), 24591 deletions(-) delete mode 100644 src/vbox/vbox_CAPI_v2_2.h delete mode 100644 src/vbox/vbox_CAPI_v3_0.h delete mode 100644 src/vbox/vbox_CAPI_v3_1.h delete mode 100644 src/vbox/vbox_CAPI_v3_2.h delete mode 100644 src/vbox/vbox_V2_2.c delete mode 100644 src/vbox/vbox_V3_0.c delete mode 100644 src/vbox/vbox_V3_1.c delete mode 100644 src/vbox/vbox_V3_2.c -- 2.9.3

That is, for versions older than 4.0. Also do not try to include headers for those old versions. --- src/vbox/vbox_common.h | 10 +--------- src/vbox/vbox_storage.c | 10 +--------- src/vbox/vbox_uniformed_api.h | 4 ---- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index e29a7bd..7bbab8d 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -410,15 +410,7 @@ typedef nsISupports IKeyboard; # define installUniformedAPI(gVBoxAPI, result) \ do { \ result = 0; \ - if (uVersion >= 2001052 && uVersion < 2002051) { \ - vbox22InstallUniformedAPI(&gVBoxAPI); \ - } else if (uVersion >= 2002051 && uVersion < 3000051) { \ - vbox30InstallUniformedAPI(&gVBoxAPI); \ - } else if (uVersion >= 3000051 && uVersion < 3001051) { \ - vbox31InstallUniformedAPI(&gVBoxAPI); \ - } else if (uVersion >= 3001051 && uVersion < 3002051) { \ - vbox32InstallUniformedAPI(&gVBoxAPI); \ - } else if (uVersion >= 3002051 && uVersion < 4000051) { \ + if (uVersion >= 3002051 && uVersion < 4000051) { \ vbox40InstallUniformedAPI(&gVBoxAPI); \ } else if (uVersion >= 4000051 && uVersion < 4001051) { \ vbox41InstallUniformedAPI(&gVBoxAPI); \ diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 27d38ad..c286753 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -888,15 +888,7 @@ virStorageDriverPtr vboxGetStorageDriver(uint32_t uVersion) /* Install gVBoxAPI according to the vbox API version. * Return -1 for unsupported version. */ - if (uVersion >= 2001052 && uVersion < 2002051) { - vbox22InstallUniformedAPI(&gVBoxAPI); - } else if (uVersion >= 2002051 && uVersion < 3000051) { - vbox30InstallUniformedAPI(&gVBoxAPI); - } else if (uVersion >= 3000051 && uVersion < 3001051) { - vbox31InstallUniformedAPI(&gVBoxAPI); - } else if (uVersion >= 3001051 && uVersion < 3002051) { - vbox32InstallUniformedAPI(&gVBoxAPI); - } else if (uVersion >= 3002051 && uVersion < 4000051) { + if (uVersion >= 3002051 && uVersion < 4000051) { vbox40InstallUniformedAPI(&gVBoxAPI); } else if (uVersion >= 4000051 && uVersion < 4001051) { vbox41InstallUniformedAPI(&gVBoxAPI); diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 6a8b6bc..3b2b7a8 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -616,10 +616,6 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid); /* Version specified functions for installing uniformed API */ -void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); -void vbox30InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); -void vbox31InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); -void vbox32InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); void vbox40InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); void vbox41InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); void vbox42InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); -- 2.9.3

This removes most of the code wrapped in VBOX_API_VERSION < 4000000 preprocessor checks. Those are the ones that can be safely removed without needing to update driver code to accomodate it. --- src/vbox/vbox_tmpl.c | 1390 +++----------------------------------------------- 1 file changed, 57 insertions(+), 1333 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 0e22e1c..7fcf213 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -72,11 +72,8 @@ /* Include this *last* or we'll get the wrong vbox_CAPI_*.h. */ #include "vbox_glue.h" -#if VBOX_API_VERSION < 4000000 -typedef IVRDPServer IVRDxServer; -#else /* VBOX_API_VERSION >= 4000000 */ typedef IVRDEServer IVRDxServer; -#endif /* VBOX_API_VERSION >= 4000000 */ +typedef IMedium IHardDisk; #if VBOX_API_VERSION < 4003000 typedef IUSBController IUSBCommon; @@ -84,11 +81,6 @@ typedef IUSBController IUSBCommon; typedef IUSBDeviceFilters IUSBCommon; #endif /* VBOX_API_VERSION >= 4003000 */ -#if VBOX_API_VERSION < 3001000 -typedef IHardDiskAttachment IMediumAttachment; -#else /* VBOX_API_VERSION >= 3001000 */ -typedef IMedium IHardDisk; -#endif /* VBOX_API_VERSION >= 3001000 */ #include "vbox_uniformed_api.h" @@ -126,13 +118,7 @@ VIR_LOG_INIT("vbox.vbox_tmpl"); } \ } while (0) -#if VBOX_API_VERSION < 3001000 -# define VBOX_MEDIUM_RELEASE(arg) \ -if (arg)\ - (arg)->vtbl->imedium.nsisupports.Release((nsISupports *)(arg)) -#else /* VBOX_API_VERSION >= 3001000 */ -# define VBOX_MEDIUM_RELEASE(arg) VBOX_RELEASE(arg) -#endif /* VBOX_API_VERSION >= 3001000 */ +#define VBOX_MEDIUM_RELEASE(arg) VBOX_RELEASE(arg) #define DEBUGPRUnichar(msg, strUtf16) \ if (strUtf16) {\ @@ -161,295 +147,12 @@ if (strUtf16) {\ (unsigned)(iid)->m3[7]);\ }\ -#if VBOX_API_VERSION < 4000000 - -# define VBOX_SESSION_OPEN(/* in */ iid_value, /* unused */ machine) \ - data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid_value) - -# define VBOX_SESSION_CLOSE() \ - data->vboxSession->vtbl->Close(data->vboxSession) - -#else /* VBOX_API_VERSION >= 4000000 */ - -# define VBOX_SESSION_OPEN(/* unused */ iid_value, /* in */ machine) \ +#define VBOX_SESSION_OPEN(/* unused */ iid_value, /* in */ machine) \ machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write) -# define VBOX_SESSION_CLOSE() \ +#define VBOX_SESSION_CLOSE() \ data->vboxSession->vtbl->UnlockMachine(data->vboxSession) -#endif /* VBOX_API_VERSION >= 4000000 */ - -#if VBOX_API_VERSION == 2002000 - -static void nsIDtoChar(unsigned char *uuid, const nsID *iid) -{ - char uuidstrsrc[VIR_UUID_STRING_BUFLEN]; - char uuidstrdst[VIR_UUID_STRING_BUFLEN]; - unsigned char uuidinterim[VIR_UUID_BUFLEN]; - size_t i; - - memcpy(uuidinterim, iid, VIR_UUID_BUFLEN); - virUUIDFormat(uuidinterim, uuidstrsrc); - - uuidstrdst[0] = uuidstrsrc[6]; - uuidstrdst[1] = uuidstrsrc[7]; - uuidstrdst[2] = uuidstrsrc[4]; - uuidstrdst[3] = uuidstrsrc[5]; - uuidstrdst[4] = uuidstrsrc[2]; - uuidstrdst[5] = uuidstrsrc[3]; - uuidstrdst[6] = uuidstrsrc[0]; - uuidstrdst[7] = uuidstrsrc[1]; - - uuidstrdst[8] = uuidstrsrc[8]; - - uuidstrdst[9] = uuidstrsrc[11]; - uuidstrdst[10] = uuidstrsrc[12]; - uuidstrdst[11] = uuidstrsrc[9]; - uuidstrdst[12] = uuidstrsrc[10]; - - uuidstrdst[13] = uuidstrsrc[13]; - - uuidstrdst[14] = uuidstrsrc[16]; - uuidstrdst[15] = uuidstrsrc[17]; - uuidstrdst[16] = uuidstrsrc[14]; - uuidstrdst[17] = uuidstrsrc[15]; - - for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++) - uuidstrdst[i] = uuidstrsrc[i]; - - uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0'; - ignore_value(virUUIDParse(uuidstrdst, uuid)); -} - -static void nsIDFromChar(nsID *iid, const unsigned char *uuid) -{ - char uuidstrsrc[VIR_UUID_STRING_BUFLEN]; - char uuidstrdst[VIR_UUID_STRING_BUFLEN]; - unsigned char uuidinterim[VIR_UUID_BUFLEN]; - size_t i; - - virUUIDFormat(uuid, uuidstrsrc); - - uuidstrdst[0] = uuidstrsrc[6]; - uuidstrdst[1] = uuidstrsrc[7]; - uuidstrdst[2] = uuidstrsrc[4]; - uuidstrdst[3] = uuidstrsrc[5]; - uuidstrdst[4] = uuidstrsrc[2]; - uuidstrdst[5] = uuidstrsrc[3]; - uuidstrdst[6] = uuidstrsrc[0]; - uuidstrdst[7] = uuidstrsrc[1]; - - uuidstrdst[8] = uuidstrsrc[8]; - - uuidstrdst[9] = uuidstrsrc[11]; - uuidstrdst[10] = uuidstrsrc[12]; - uuidstrdst[11] = uuidstrsrc[9]; - uuidstrdst[12] = uuidstrsrc[10]; - - uuidstrdst[13] = uuidstrsrc[13]; - - uuidstrdst[14] = uuidstrsrc[16]; - uuidstrdst[15] = uuidstrsrc[17]; - uuidstrdst[16] = uuidstrsrc[14]; - uuidstrdst[17] = uuidstrsrc[15]; - - for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++) - uuidstrdst[i] = uuidstrsrc[i]; - - uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0'; - ignore_value(virUUIDParse(uuidstrdst, uuidinterim)); - memcpy(iid, uuidinterim, VIR_UUID_BUFLEN); -} - -# ifdef WIN32 - -typedef struct _vboxIID_v2_x_WIN32 vboxIID; -typedef struct _vboxIID_v2_x_WIN32 vboxIID_v2_x_WIN32; - -# define VBOX_IID_INITIALIZER { { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } } } -# define IID_MEMBER(name) (iidu->vboxIID_v2_x_WIN32.name) - -static void -vboxIIDUnalloc_v2_x_WIN32(vboxDriverPtr data ATTRIBUTE_UNUSED, - vboxIID_v2_x_WIN32 *iid ATTRIBUTE_UNUSED) -{ - /* Nothing to free */ -} - -static void -_vboxIIDUnalloc(vboxDriverPtr data ATTRIBUTE_UNUSED, - vboxIIDUnion *iid ATTRIBUTE_UNUSED) -{ - /* Nothing to free */ -} - -static void -vboxIIDToUUID_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid, unsigned char *uuid) -{ - nsIDtoChar(uuid, (nsID *)&iid->value); -} - -static void -_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(vboxDriverPtr data, vboxIID_v2_x_WIN32 *iid, - const unsigned char *uuid) -{ - vboxIIDUnalloc_v2_x_WIN32(data, iid); - - nsIDFromChar((nsID *)&iid->value, uuid); -} - -static void -_vboxIIDFromUUID(vboxDriverPtr data, vboxIIDUnion *iidu, - const unsigned char *uuid) -{ - vboxIIDFromUUID_v2_x_WIN32(data, &iidu->vboxIID_v2_x_WIN32, uuid); -} - -static bool -vboxIIDIsEqual_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid1, vboxIID_v2_x_WIN32 *iid2) -{ - return memcmp(&iid1->value, &iid2->value, sizeof(GUID)) == 0; -} - -static bool -_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(vboxDriverPtr data, vboxIID_v2_x_WIN32 *iid, - vboxArray *array, int idx) -{ - GUID *items = (GUID *)array->items; - - vboxIIDUnalloc_v2_x_WIN32(data, iid); - - memcpy(&iid->value, &items[idx], sizeof(GUID)); -} - -static void -_vboxIIDFromArrayItem(vboxDriverPtr data, vboxIIDUnion *iidu, - vboxArray *array, int idx) -{ - vboxIIDFromArrayItem_v2_x_WIN32(data, &iidu->vboxIID_v2_x_WIN32, array, idx); -} - -# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v2_x_WIN32(data, iid) -# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v2_x_WIN32(iid, uuid) -# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v2_x_WIN32(data, iid, uuid) -# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v2_x_WIN32(iid1, iid2) -# define vboxIIDFromArrayItem(iid, array, idx) \ - vboxIIDFromArrayItem_v2_x_WIN32(data, iid, array, idx) -# define DEBUGIID(msg, iid) DEBUGUUID(msg, (nsID *)&(iid)) - -# else /* !WIN32 */ - -typedef struct _vboxIID_v2_x vboxIID; -typedef struct _vboxIID_v2_x vboxIID_v2_x; - -# define VBOX_IID_INITIALIZER { NULL, { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } } } -# define IID_MEMBER(name) (iidu->vboxIID_v2_x.name) - -static void -vboxIIDUnalloc_v2_x(vboxDriverPtr data, vboxIID_v2_x *iid) -{ - if (iid->value == NULL) - return; - - if (iid->value != &iid->backing) - data->pFuncs->pfnComUnallocMem(iid->value); - - iid->value = NULL; -} - -static void -_vboxIIDUnalloc(vboxDriverPtr data, vboxIIDUnion *iidu) -{ - vboxIIDUnalloc_v2_x(data, &iidu->vboxIID_v2_x); -} - -static void -vboxIIDToUUID_v2_x(vboxIID_v2_x *iid, unsigned char *uuid) -{ - nsIDtoChar(uuid, iid->value); -} - -static void -_vboxIIDToUUID(vboxDriverPtr data ATTRIBUTE_UNUSED, - vboxIIDUnion *iidu, unsigned char *uuid) -{ - vboxIIDToUUID_v2_x(&iidu->vboxIID_v2_x, uuid); -} - -static void -vboxIIDFromUUID_v2_x(vboxDriverPtr data, vboxIID_v2_x *iid, - const unsigned char *uuid) -{ - vboxIIDUnalloc_v2_x(data, iid); - - iid->value = &iid->backing; - - sa_assert(iid->value); - nsIDFromChar(iid->value, uuid); -} - -static void -_vboxIIDFromUUID(vboxDriverPtr data, vboxIIDUnion *iidu, - const unsigned char *uuid) -{ - vboxIIDFromUUID_v2_x(data, &iidu->vboxIID_v2_x, uuid); -} - -static bool -vboxIIDIsEqual_v2_x(vboxIID_v2_x *iid1, vboxIID_v2_x *iid2) -{ - return memcmp(iid1->value, iid2->value, sizeof(nsID)) == 0; -} - -static bool -_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(vboxDriverPtr data, vboxIID_v2_x *iid, - vboxArray *array, int idx) -{ - vboxIIDUnalloc_v2_x(data, iid); - - iid->value = &iid->backing; - - memcpy(iid->value, array->items[idx], sizeof(nsID)); -} - -static void -_vboxIIDFromArrayItem(vboxDriverPtr data, vboxIIDUnion *iidu, - vboxArray *array, int idx) -{ - vboxIIDFromArrayItem_v2_x(data, &iidu->vboxIID_v2_x, array, idx); -} - -# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v2_x(data, iid) -# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v2_x(iid, uuid) -# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v2_x(data, iid, uuid) -# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v2_x(iid1, iid2) -# define vboxIIDFromArrayItem(iid, array, idx) \ - vboxIIDFromArrayItem_v2_x(data, iid, array, idx) -# define DEBUGIID(msg, iid) DEBUGUUID(msg, iid) - -# endif /* !WIN32 */ - -#else /* VBOX_API_VERSION != 2002000 */ - typedef struct _vboxIID_v3_x vboxIID; typedef struct _vboxIID_v3_x vboxIID_v3_x; @@ -562,132 +265,6 @@ _vboxIIDFromArrayItem(vboxDriverPtr data, vboxIIDUnion *iidu, vboxIIDFromArrayItem_v3_x(data, iid, array, idx) # define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16) -#endif /* !(VBOX_API_VERSION == 2002000) */ - -/** - * function to get the StorageBus, Port number - * and Device number for the given devicename - * e.g: hda has StorageBus = IDE, port = 0, - * device = 0 - * - * @returns true on Success, false on failure. - * @param deviceName Input device name - * @param aMaxPortPerInst Input array of max port per device instance - * @param aMaxSlotPerPort Input array of max slot per device port - * @param storageBus Input storage bus type - * @param deviceInst Output device instance number - * @param devicePort Output port number - * @param deviceSlot Output slot number - * - */ -#if VBOX_API_VERSION >= 3001000 -# if VBOX_API_VERSION < 4000000 -/* Only 3.x will use this function. */ -static bool vboxGetDeviceDetails(const char *deviceName, - PRUint32 *aMaxPortPerInst, - PRUint32 *aMaxSlotPerPort, - PRUint32 storageBus, - PRInt32 *deviceInst, - PRInt32 *devicePort, - PRInt32 *deviceSlot) -{ - int total = 0; - PRUint32 maxPortPerInst = 0; - PRUint32 maxSlotPerPort = 0; - - if (!deviceName || - !deviceInst || - !devicePort || - !deviceSlot || - !aMaxPortPerInst || - !aMaxSlotPerPort) - return false; - - if ((storageBus < StorageBus_IDE) || - (storageBus > StorageBus_Floppy)) - return false; - - total = virDiskNameToIndex(deviceName); - - maxPortPerInst = aMaxPortPerInst[storageBus]; - maxSlotPerPort = aMaxSlotPerPort[storageBus]; - - if (!maxPortPerInst || - !maxSlotPerPort || - (total < 0)) - return false; - - *deviceInst = total / (maxPortPerInst * maxSlotPerPort); - *devicePort = (total % (maxPortPerInst * maxSlotPerPort)) / maxSlotPerPort; - *deviceSlot = (total % (maxPortPerInst * maxSlotPerPort)) % maxSlotPerPort; - - VIR_DEBUG("name=%s, total=%d, storageBus=%u, deviceInst=%d, " - "devicePort=%d deviceSlot=%d, maxPortPerInst=%u maxSlotPerPort=%u", - deviceName, total, storageBus, *deviceInst, *devicePort, - *deviceSlot, maxPortPerInst, maxSlotPerPort); - - return true; -} - -/** - * function to get the values for max port per - * instance and max slots per port for the devices - * - * @returns true on Success, false on failure. - * @param vbox Input IVirtualBox pointer - * @param maxPortPerInst Output array of max port per instance - * @param maxSlotPerPort Output array of max slot per port - * - */ - -/* This function would not be used in 4.1 and later since - * vboxDomainSnapshotGetXMLDesc is written*/ -static bool vboxGetMaxPortSlotValues(IVirtualBox *vbox, - PRUint32 *maxPortPerInst, - PRUint32 *maxSlotPerPort) -{ - ISystemProperties *sysProps = NULL; - - if (!vbox) - return false; - - vbox->vtbl->GetSystemProperties(vbox, &sysProps); - - if (!sysProps) - return false; - - sysProps->vtbl->GetMaxPortCountForStorageBus(sysProps, - StorageBus_IDE, - &maxPortPerInst[StorageBus_IDE]); - sysProps->vtbl->GetMaxPortCountForStorageBus(sysProps, - StorageBus_SATA, - &maxPortPerInst[StorageBus_SATA]); - sysProps->vtbl->GetMaxPortCountForStorageBus(sysProps, - StorageBus_SCSI, - &maxPortPerInst[StorageBus_SCSI]); - sysProps->vtbl->GetMaxPortCountForStorageBus(sysProps, - StorageBus_Floppy, - &maxPortPerInst[StorageBus_Floppy]); - - sysProps->vtbl->GetMaxDevicesPerPortForStorageBus(sysProps, - StorageBus_IDE, - &maxSlotPerPort[StorageBus_IDE]); - sysProps->vtbl->GetMaxDevicesPerPortForStorageBus(sysProps, - StorageBus_SATA, - &maxSlotPerPort[StorageBus_SATA]); - sysProps->vtbl->GetMaxDevicesPerPortForStorageBus(sysProps, - StorageBus_SCSI, - &maxSlotPerPort[StorageBus_SCSI]); - sysProps->vtbl->GetMaxDevicesPerPortForStorageBus(sysProps, - StorageBus_Floppy, - &maxSlotPerPort[StorageBus_Floppy]); - - VBOX_RELEASE(sysProps); - - return true; -} -# endif /* VBOX_API_VERSION < 4000000 */ - /** * Converts Utf-16 string to int */ @@ -725,8 +302,6 @@ static PRUnichar *PRUnicharFromInt(PCVBOXXPCOM pFuncs, int n) { return strUtf16; } -#endif /* VBOX_API_VERSION >= 3001000 */ - static virDomainState _vboxConvertState(PRUint32 state) { switch (state) { @@ -1233,41 +808,6 @@ _vboxAttachDrivesOld(virDomainDefPtr def ATTRIBUTE_UNUSED, #endif /* VBOX_API_VERSION >= 4000000 */ -#if VBOX_API_VERSION < 3001000 -static int -_vboxDomainSnapshotRestore(virDomainPtr dom, - IMachine *machine, - ISnapshot *snapshot) -{ - vboxDriverPtr data = dom->conn->privateData; - vboxIID iid = VBOX_IID_INITIALIZER; - nsresult rc; - int ret = -1; - - if (!data->vboxObj) - return ret; - - rc = snapshot->vtbl->GetId(snapshot, &iid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get snapshot UUID")); - goto cleanup; - } - - rc = machine->vtbl->SetCurrentSnapshot(machine, iid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not restore snapshot for domain %s"), dom->name); - goto cleanup; - } - - ret = 0; - - cleanup: - vboxIIDUnalloc(&iid); - return ret; -} -#else static int _vboxDomainSnapshotRestore(virDomainPtr dom, IMachine *machine, @@ -1357,7 +897,6 @@ _vboxDomainSnapshotRestore(virDomainPtr dom, vboxIIDUnalloc(&domiid); return ret; } -#endif #if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 /* No Callback support for VirtualBox 2.2.* series */ @@ -1999,85 +1538,6 @@ _initializeDomainEvent(vboxDriverPtr data ATTRIBUTE_UNUSED) return 0; } -#if VBOX_API_VERSION < 4000000 - -# if VBOX_API_VERSION < 3001000 -static void -_detachDevices(vboxDriverPtr data ATTRIBUTE_UNUSED, - IMachine *machine, PRUnichar *hddcnameUtf16) -{ - /* Disconnect all the drives if present */ - machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 0, 0); - machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 0, 1); - machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 1, 1); -} -# else /* VBOX_API_VERSION >= 3001000 */ -static void -_detachDevices(vboxDriverPtr data, IMachine *machine, - PRUnichar *hddcnameUtf16 ATTRIBUTE_UNUSED) -{ - /* get all the controller first, then the attachments and - * remove them all so that the machine can be undefined - */ - vboxArray storageControllers = VBOX_ARRAY_INITIALIZER; - size_t i = 0, j = 0; - - vboxArrayGet(&storageControllers, machine, - machine->vtbl->GetStorageControllers); - - for (i = 0; i < storageControllers.count; i++) { - IStorageController *strCtl = storageControllers.items[i]; - PRUnichar *strCtlName = NULL; - vboxArray mediumAttachments = VBOX_ARRAY_INITIALIZER; - - if (!strCtl) - continue; - - strCtl->vtbl->GetName(strCtl, &strCtlName); - vboxArrayGetWithPtrArg(&mediumAttachments, machine, - machine->vtbl->GetMediumAttachmentsOfController, - strCtlName); - - for (j = 0; j < mediumAttachments.count; j++) { - IMediumAttachment *medAtt = mediumAttachments.items[j]; - PRInt32 port = ~0U; - PRInt32 device = ~0U; - - if (!medAtt) - continue; - - medAtt->vtbl->GetPort(medAtt, &port); - medAtt->vtbl->GetDevice(medAtt, &device); - - if ((port != ~0U) && (device != ~0U)) { - machine->vtbl->DetachDevice(machine, - strCtlName, - port, - device); - } - } - vboxArrayRelease(&storageControllers); - machine->vtbl->RemoveStorageController(machine, strCtlName); - VBOX_UTF16_FREE(strCtlName); - } - vboxArrayRelease(&storageControllers); -} -# endif /* VBOX_API_VERSION >= 3001000 */ - -static nsresult -_unregisterMachine(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine **machine) -{ - return data->vboxObj->vtbl->UnregisterMachine(data->vboxObj, IID_MEMBER(value), machine); -} - -static void -_deleteConfig(IMachine *machine) -{ - machine->vtbl->DeleteSettings(machine); -} - -#else /* VBOX_API_VERSION >= 4000000 */ - static void _detachDevices(vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED, @@ -2108,450 +1568,43 @@ _unregisterMachine(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine **machine) return rc; } -static void -_deleteConfig(IMachine *machine) -{ - IProgress *progress = NULL; - - /* The IMachine Delete method takes an array of IMedium items to be - * deleted along with the virtual machine. We just want to pass an - * empty array. But instead of adding a full vboxArraySetWithReturn to - * the glue layer (in order to handle the required signature of the - * Delete method) we use a local solution here. */ -# ifdef WIN32 - SAFEARRAY *safeArray = NULL; - typedef HRESULT __stdcall (*IMachine_Delete)(IMachine *self, - SAFEARRAY **media, - IProgress **progress); - -# if VBOX_API_VERSION < 4003000 - ((IMachine_Delete)machine->vtbl->Delete)(machine, &safeArray, &progress); -# else - ((IMachine_Delete)machine->vtbl->DeleteConfig)(machine, &safeArray, &progress); -# endif -# else - /* XPCOM doesn't like NULL as an array, even when the array size is 0. - * Instead pass it a dummy array to avoid passing NULL. */ - IMedium *array[] = { NULL }; -# if VBOX_API_VERSION < 4003000 - machine->vtbl->Delete(machine, 0, array, &progress); -# else - machine->vtbl->DeleteConfig(machine, 0, array, &progress); -# endif -# endif - if (progress != NULL) { - progress->vtbl->WaitForCompletion(progress, -1); - VBOX_RELEASE(progress); - } -} - -#endif /* VBOX_API_VERSION >= 4000000 */ - -#if VBOX_API_VERSION < 3001000 - -static void -_dumpIDEHDDsOld(virDomainDefPtr def, - vboxDriverPtr data, - IMachine *machine) -{ - PRInt32 hddNum = 0; - IHardDisk *hardDiskPM = NULL; - IHardDisk *hardDiskPS = NULL; - IHardDisk *hardDiskSS = NULL; - const char *hddBus = "IDE"; - PRUnichar *hddBusUtf16 = NULL; - - /* dump IDE hdds if present */ - VBOX_UTF8_TO_UTF16(hddBus, &hddBusUtf16); - - def->ndisks = 0; - machine->vtbl->GetHardDisk(machine, hddBusUtf16, 0, 0, &hardDiskPM); - if (hardDiskPM) - def->ndisks++; - - machine->vtbl->GetHardDisk(machine, hddBusUtf16, 0, 1, &hardDiskPS); - if (hardDiskPS) - def->ndisks++; - - machine->vtbl->GetHardDisk(machine, hddBusUtf16, 1, 1, &hardDiskSS); - if (hardDiskSS) - def->ndisks++; - - VBOX_UTF16_FREE(hddBusUtf16); - - if ((def->ndisks > 0) && (VIR_ALLOC_N(def->disks, def->ndisks) >= 0)) { - size_t i; - for (i = 0; i < def->ndisks; i++) { - if ((def->disks[i] = virDomainDiskDefNew(NULL))) { - def->disks[i]->device = VIR_DOMAIN_DISK_DEVICE_DISK; - def->disks[i]->bus = VIR_DOMAIN_DISK_BUS_IDE; - virDomainDiskSetType(def->disks[i], - VIR_STORAGE_TYPE_FILE); - } - } - } - - if (hardDiskPM) { - PRUnichar *hddlocationUtf16 = NULL; - char *hddlocation = NULL; - PRUint32 hddType = HardDiskType_Normal; - - hardDiskPM->vtbl->imedium.GetLocation((IMedium *)hardDiskPM, &hddlocationUtf16); - VBOX_UTF16_TO_UTF8(hddlocationUtf16, &hddlocation); - - hardDiskPM->vtbl->GetType(hardDiskPM, &hddType); - - if (hddType == HardDiskType_Immutable) - def->disks[hddNum]->src->readonly = true; - ignore_value(virDomainDiskSetSource(def->disks[hddNum], - hddlocation)); - ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hda")); - hddNum++; - - VBOX_UTF8_FREE(hddlocation); - VBOX_UTF16_FREE(hddlocationUtf16); - VBOX_MEDIUM_RELEASE(hardDiskPM); - } - - if (hardDiskPS) { - PRUnichar *hddlocationUtf16 = NULL; - char *hddlocation = NULL; - PRUint32 hddType = HardDiskType_Normal; - - hardDiskPS->vtbl->imedium.GetLocation((IMedium *)hardDiskPS, &hddlocationUtf16); - VBOX_UTF16_TO_UTF8(hddlocationUtf16, &hddlocation); - - hardDiskPS->vtbl->GetType(hardDiskPS, &hddType); - - if (hddType == HardDiskType_Immutable) - def->disks[hddNum]->src->readonly = true; - ignore_value(virDomainDiskSetSource(def->disks[hddNum], - hddlocation)); - ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hdb")); - hddNum++; - - VBOX_UTF8_FREE(hddlocation); - VBOX_UTF16_FREE(hddlocationUtf16); - VBOX_MEDIUM_RELEASE(hardDiskPS); - } - - if (hardDiskSS) { - PRUnichar *hddlocationUtf16 = NULL; - char *hddlocation = NULL; - PRUint32 hddType = HardDiskType_Normal; - - hardDiskSS->vtbl->imedium.GetLocation((IMedium *)hardDiskSS, &hddlocationUtf16); - VBOX_UTF16_TO_UTF8(hddlocationUtf16, &hddlocation); - - hardDiskSS->vtbl->GetType(hardDiskSS, &hddType); - - if (hddType == HardDiskType_Immutable) - def->disks[hddNum]->src->readonly = true; - ignore_value(virDomainDiskSetSource(def->disks[hddNum], - hddlocation)); - ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hdd")); - hddNum++; - - VBOX_UTF8_FREE(hddlocation); - VBOX_UTF16_FREE(hddlocationUtf16); - VBOX_MEDIUM_RELEASE(hardDiskSS); - } -} - -static void -_dumpDVD(virDomainDefPtr def, - vboxDriverPtr data, - IMachine *machine) -{ - IDVDDrive *dvdDrive = NULL; - IDVDImage *dvdImage = NULL; - PRUnichar *locationUtf16 = NULL; - char *location = NULL; - - - /* dump CDROM/DVD if the drive is attached and has DVD/CD in it */ - machine->vtbl->GetDVDDrive(machine, &dvdDrive); - if (!dvdDrive) - return; - - PRUint32 state = DriveState_Null; - - dvdDrive->vtbl->GetState(dvdDrive, &state); - if (state != DriveState_ImageMounted) - goto cleanupDVDDrive; - - - dvdDrive->vtbl->GetImage(dvdDrive, &dvdImage); - if (!dvdImage) - goto cleanupDVDDrive; - - dvdImage->vtbl->imedium.GetLocation((IMedium *)dvdImage, &locationUtf16); - VBOX_UTF16_TO_UTF8(locationUtf16, &location); - - def->ndisks++; - if (VIR_REALLOC_N(def->disks, def->ndisks) >= 0) { - if ((def->disks[def->ndisks - 1] = virDomainDiskDefNew(NULL))) { - def->disks[def->ndisks - 1]->device = VIR_DOMAIN_DISK_DEVICE_CDROM; - def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_IDE; - virDomainDiskSetType(def->disks[def->ndisks - 1], - VIR_STORAGE_TYPE_FILE); - def->disks[def->ndisks - 1]->src->readonly = true; - ignore_value(virDomainDiskSetSource(def->disks[def->ndisks - 1], location)); - ignore_value(VIR_STRDUP(def->disks[def->ndisks - 1]->dst, "hdc")); - def->ndisks--; - } else { - def->ndisks--; - } - } else { - def->ndisks--; - } - - VBOX_UTF8_FREE(location); - VBOX_UTF16_FREE(locationUtf16); - VBOX_MEDIUM_RELEASE(dvdImage); - - cleanupDVDDrive: - VBOX_RELEASE(dvdDrive); -} - -static int -_attachDVD(vboxDriverPtr data, IMachine *machine, const char *src) -{ - IDVDDrive *dvdDrive = NULL; - IDVDImage *dvdImage = NULL; - PRUnichar *dvdfileUtf16 = NULL; - vboxIID dvduuid = VBOX_IID_INITIALIZER; - vboxIID dvdemptyuuid = VBOX_IID_INITIALIZER; - nsresult rc; - int ret = -1; - - /* Currently CDROM/DVD Drive is always IDE - * Secondary Master so neglecting the following - * parameter dev->data.disk->bus - */ - machine->vtbl->GetDVDDrive(machine, &dvdDrive); - if (!dvdDrive) - return ret; - - VBOX_UTF8_TO_UTF16(src, &dvdfileUtf16); - - data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage); - if (!dvdImage) - data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuid.value, &dvdImage); - - if (!dvdImage) - goto cleanup; - - rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("can't get the uuid of the file to " - "be attached to cdrom: %s, rc=%08x"), - src, (unsigned)rc); - } else { - /* unmount the previous mounted image */ - dvdDrive->vtbl->Unmount(dvdDrive); - rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach the file to cdrom: %s, rc=%08x"), - src, (unsigned)rc); - } else { - ret = 0; - DEBUGIID("CD/DVD Image UUID:", dvduuid.value); - } - } - - VBOX_MEDIUM_RELEASE(dvdImage); - cleanup: - vboxIIDUnalloc(&dvduuid); - VBOX_UTF16_FREE(dvdfileUtf16); - VBOX_RELEASE(dvdDrive); - return ret; -} - -static int -_detachDVD(IMachine *machine) -{ - IDVDDrive *dvdDrive = NULL; - int ret = -1; - nsresult rc; - /* Currently CDROM/DVD Drive is always IDE - * Secondary Master so neglecting the following - * parameter dev->data.disk->bus - */ - machine->vtbl->GetDVDDrive(machine, &dvdDrive); - if (!dvdDrive) - return ret; - - rc = dvdDrive->vtbl->Unmount(dvdDrive); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not de-attach the mounted ISO, rc=%08x"), - (unsigned)rc); - } else { - ret = 0; - } - VBOX_RELEASE(dvdDrive); - - return ret; -} - -static void -_dumpFloppy(virDomainDefPtr def, - vboxDriverPtr data, - IMachine *machine) -{ - IFloppyDrive *floppyDrive = NULL; - IFloppyImage *floppyImage = NULL; - PRUnichar *locationUtf16 = NULL; - char *location = NULL; - PRBool enabled = PR_FALSE; - PRUint32 state = DriveState_Null; - - /* dump Floppy if the drive is attached and has floppy in it */ - machine->vtbl->GetFloppyDrive(machine, &floppyDrive); - if (!floppyDrive) - return; - - floppyDrive->vtbl->GetEnabled(floppyDrive, &enabled); - if (!enabled) - goto cleanupFloppyDrive; - - - floppyDrive->vtbl->GetState(floppyDrive, &state); - if (state != DriveState_ImageMounted) - goto cleanupFloppyDrive; - - floppyDrive->vtbl->GetImage(floppyDrive, &floppyImage); - if (!floppyImage) - goto cleanupFloppyDrive; - - floppyImage->vtbl->imedium.GetLocation((IMedium *)floppyImage, &locationUtf16); - VBOX_UTF16_TO_UTF8(locationUtf16, &location); - - def->ndisks++; - if (VIR_REALLOC_N(def->disks, def->ndisks) >= 0) { - if ((def->disks[def->ndisks - 1] = virDomainDiskDefNew(NULL))) { - def->disks[def->ndisks - 1]->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY; - def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_FDC; - virDomainDiskSetType(def->disks[def->ndisks - 1], - VIR_STORAGE_TYPE_FILE); - def->disks[def->ndisks - 1]->src->readonly = false; - ignore_value(virDomainDiskSetSource(def->disks[def->ndisks - 1], location)); - ignore_value(VIR_STRDUP(def->disks[def->ndisks - 1]->dst, "fda")); - def->ndisks--; - } else { - def->ndisks--; - } - } else { - def->ndisks--; - } - - VBOX_UTF8_FREE(location); - VBOX_UTF16_FREE(locationUtf16); - VBOX_MEDIUM_RELEASE(floppyImage); - - cleanupFloppyDrive: - VBOX_RELEASE(floppyDrive); -} - -static int -_attachFloppy(vboxDriverPtr data, IMachine *machine, const char *src) -{ - IFloppyDrive *floppyDrive; - IFloppyImage *floppyImage = NULL; - PRUnichar *fdfileUtf16 = NULL; - vboxIID fduuid = VBOX_IID_INITIALIZER; - vboxIID fdemptyuuid = VBOX_IID_INITIALIZER; - nsresult rc; - int ret = -1; - - machine->vtbl->GetFloppyDrive(machine, &floppyDrive); - if (!floppyDrive) - return ret; - - rc = floppyDrive->vtbl->SetEnabled(floppyDrive, 1); - if (NS_FAILED(rc)) - goto cleanup; - - VBOX_UTF8_TO_UTF16(src, &fdfileUtf16); - rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj, - fdfileUtf16, - &floppyImage); - - if (!floppyImage) { - data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj, - fdfileUtf16, - fdemptyuuid.value, - &floppyImage); - } - - if (floppyImage) { - rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, &fduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("can't get the uuid of the file to be " - "attached to floppy drive: %s, rc=%08x"), - src, (unsigned)rc); - } else { - rc = floppyDrive->vtbl->MountImage(floppyDrive, fduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach the file to floppy drive: %s, rc=%08x"), - src, (unsigned)rc); - } else { - ret = 0; - DEBUGIID("attached floppy, UUID:", fduuid.value); - } - } - VBOX_MEDIUM_RELEASE(floppyImage); - } - vboxIIDUnalloc(&fduuid); - VBOX_UTF16_FREE(fdfileUtf16); - - cleanup: - VBOX_RELEASE(floppyDrive); - return ret; -} - -static int -_detachFloppy(IMachine *machine) -{ - IFloppyDrive *floppyDrive; - int ret = -1; - nsresult rc; - - machine->vtbl->GetFloppyDrive(machine, &floppyDrive); - if (!floppyDrive) - return ret; +static void +_deleteConfig(IMachine *machine) +{ + IProgress *progress = NULL; - PRBool enabled = PR_FALSE; + /* The IMachine Delete method takes an array of IMedium items to be + * deleted along with the virtual machine. We just want to pass an + * empty array. But instead of adding a full vboxArraySetWithReturn to + * the glue layer (in order to handle the required signature of the + * Delete method) we use a local solution here. */ +# ifdef WIN32 + SAFEARRAY *safeArray = NULL; + typedef HRESULT __stdcall (*IMachine_Delete)(IMachine *self, + SAFEARRAY **media, + IProgress **progress); - floppyDrive->vtbl->GetEnabled(floppyDrive, &enabled); - if (enabled) { - rc = floppyDrive->vtbl->Unmount(floppyDrive); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach the file " - "to floppy drive, rc=%08x"), - (unsigned)rc); - } else { - ret = 0; - } - } else { - /* If you are here means floppy drive is already unmounted - * so don't flag error, just say everything is fine and quit - */ - ret = 0; +# if VBOX_API_VERSION < 4003000 + ((IMachine_Delete)machine->vtbl->Delete)(machine, &safeArray, &progress); +# else + ((IMachine_Delete)machine->vtbl->DeleteConfig)(machine, &safeArray, &progress); +# endif +# else + /* XPCOM doesn't like NULL as an array, even when the array size is 0. + * Instead pass it a dummy array to avoid passing NULL. */ + IMedium *array[] = { NULL }; +# if VBOX_API_VERSION < 4003000 + machine->vtbl->Delete(machine, 0, array, &progress); +# else + machine->vtbl->DeleteConfig(machine, 0, array, &progress); +# endif +# endif + if (progress != NULL) { + progress->vtbl->WaitForCompletion(progress, -1); + VBOX_RELEASE(progress); } - VBOX_RELEASE(floppyDrive); - - return ret; } -#else /* VBOX_API_VERSION >= 3001000 */ - static void _dumpIDEHDDsOld(virDomainDefPtr def ATTRIBUTE_UNUSED, vboxDriverPtr data ATTRIBUTE_UNUSED, @@ -2608,8 +1661,6 @@ _detachFloppy(IMachine *machine ATTRIBUTE_UNUSED) return 0; } -#endif /* VBOX_API_VERSION >= 3001000 */ - static int _pfnInitialize(vboxDriverPtr driver) { if (!(driver->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION))) @@ -2626,16 +1677,9 @@ static int _pfnInitialize(vboxDriverPtr driver) driver->vboxClient->vtbl->GetVirtualBox(driver->vboxClient, &driver->vboxObj); driver->vboxClient->vtbl->GetSession(driver->vboxClient, &driver->vboxSession); } - #else - -# if VBOX_XPCOMC_VERSION == 0x00010000U - driver->pFuncs->pfnComInitialize(&driver->vboxObj, &driver->vboxSession); -# else /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ driver->pFuncs->pfnComInitialize(IVIRTUALBOX_IID_STR, &driver->vboxObj, ISESSION_IID_STR, &driver->vboxSession); -# endif /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */ - #endif return 0; @@ -2681,24 +1725,6 @@ static int _pfnUtf8ToUtf16(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar return pFuncs->pfnUtf8ToUtf16(pszString, ppwszString); } -#if VBOX_API_VERSION == 2002000 - -static void _vboxIIDInitialize(vboxIIDUnion *iidu) -{ - memset(iidu, 0, sizeof(vboxIIDUnion)); -} - -static void _DEBUGIID(vboxDriverPtr driver ATTRIBUTE_UNUSED, const char *msg, vboxIIDUnion *iidu) -{ -# ifdef WIN32 - DEBUGUUID(msg, (nsID *)&IID_MEMBER(value)); -# else /* !WIN32 */ - DEBUGUUID(msg, IID_MEMBER(value)); -# endif /* !WIN32 */ -} - -#else /* VBOX_API_VERSION != 2002000 */ - static void _vboxIIDInitialize(vboxIIDUnion *iidu) { memset(iidu, 0, sizeof(vboxIIDUnion)); @@ -2710,18 +1736,12 @@ static void _DEBUGIID(vboxDriverPtr data, const char *msg, vboxIIDUnion *iidu) DEBUGPRUnichar(msg, IID_MEMBER(value)); } -#endif /* VBOX_API_VERSION != 2002000 */ - static void _vboxIIDToUtf8(vboxDriverPtr data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, char **utf8 ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION == 2002000 - vboxUnsupported(); -#else /* !(VBOX_API_VERSION == 2002000) */ data->pFuncs->pfnUtf16ToUtf8(IID_MEMBER(value), utf8); -#endif /* !(VBOX_API_VERSION == 2002000) */ } static nsresult @@ -2747,11 +1767,7 @@ static void* _handleUSBGetDeviceFilters(IUSBCommon *USBCommon) static void* _handleMachineGetMediumAttachments(IMachine *machine) { -#if VBOX_API_VERSION < 3001000 - return machine->vtbl->GetHardDiskAttachments; -#else /* VBOX_API_VERSION >= 3001000 */ return machine->vtbl->GetMediumAttachments; -#endif /* VBOX_API_VERSION >= 3001000 */ } static void* _handleMachineGetSharedFolders(IMachine *machine) @@ -2766,12 +1782,7 @@ static void* _handleSnapshotGetChildren(ISnapshot *snapshot) static void* _handleMediumGetChildren(IMedium *medium ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION < 3001000 - vboxUnsupported(); - return 0; -#else /* VBOX_API_VERSION >= 3001000 */ return medium->vtbl->GetChildren; -#endif /* VBOX_API_VERSION >= 3001000 */ } static void* _handleMediumGetSnapshotIds(IMedium *medium) @@ -2805,24 +1816,12 @@ _virtualboxGetVersion(IVirtualBox *vboxObj, PRUnichar **versionUtf16) return vboxObj->vtbl->GetVersion(vboxObj, versionUtf16); } -#if VBOX_API_VERSION < 4000000 - -static nsresult -_virtualboxGetMachine(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine) -{ - return vboxObj->vtbl->GetMachine(vboxObj, IID_MEMBER(value), machine); -} - -#else /* VBOX_API_VERSION >= 4000000 */ - static nsresult _virtualboxGetMachine(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine) { return vboxObj->vtbl->FindMachine(vboxObj, IID_MEMBER(value), machine); } -#endif /* VBOX_API_VERSION >= 4000000 */ - static nsresult _virtualboxOpenMachine(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine) { @@ -2851,23 +1850,7 @@ _virtualboxCreateMachine(vboxDriverPtr data, virDomainDefPtr def, IMachine **mac VBOX_UTF8_TO_UTF16(def->name, &machineNameUtf16); vboxIIDFromUUID(&iid, def->uuid); { -#if VBOX_API_VERSION < 3002000 - rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj, - machineNameUtf16, - NULL, - NULL, - iid.value, - machine); -#elif VBOX_API_VERSION < 4000000 /* 3002000 <= VBOX_API_VERSION < 4000000 */ - PRBool override = PR_FALSE; - rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj, - machineNameUtf16, - NULL, - NULL, - iid.value, - override, - machine); -#elif VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000 +#if VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000 PRBool override = PR_FALSE; rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj, NULL, @@ -2927,12 +1910,7 @@ _virtualboxFindHardDisk(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 accessMode ATTRIBUTE_UNUSED, IHardDisk **hardDisk) { - /* In vbox 2.2 and 3.0, this function will create a IHardDisk object. - * In vbox 3.1 and later, this function will create a IMedium object. - */ -#if VBOX_API_VERSION < 4000000 - return vboxObj->vtbl->FindHardDisk(vboxObj, location, hardDisk); -#elif VBOX_API_VERSION < 4002000 +#if VBOX_API_VERSION < 4002000 return vboxObj->vtbl->FindMedium(vboxObj, location, deviceType, hardDisk); #else /* VBOX_API_VERSION >= 4002000 */ @@ -2959,18 +1937,13 @@ _virtualboxOpenMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED, deviceType, accessMode, false, medium); -#else - vboxUnsupported(); - return 0; #endif } static nsresult _virtualboxGetHardDiskByIID(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IHardDisk **hardDisk) { -#if VBOX_API_VERSION < 4000000 - return vboxObj->vtbl->GetHardDisk(vboxObj, IID_MEMBER(value), hardDisk); -#elif VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000 +#if VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000 return vboxObj->vtbl->FindMedium(vboxObj, IID_MEMBER(value), DeviceType_HardDisk, hardDisk); #else /* VBOX_API_VERSION >= 4002000 */ @@ -3022,13 +1995,8 @@ _machineAttachDevice(IMachine *machine ATTRIBUTE_UNUSED, PRUint32 type ATTRIBUTE_UNUSED, IMedium * medium ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION >= 4000000 return machine->vtbl->AttachDevice(machine, name, controllerPort, device, type, medium); -#else /* VBOX_API_VERSION < 4000000 */ - vboxUnsupported(); - return 0; -#endif /* VBOX_API_VERSION < 4000000 */ } static nsresult @@ -3036,13 +2004,8 @@ _machineCreateSharedFolder(IMachine *machine, PRUnichar *name, PRUnichar *hostPath, PRBool writable, PRBool automount ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION < 4000000 - return machine->vtbl->CreateSharedFolder(machine, name, hostPath, - writable); -#else /* VBOX_API_VERSION >= 4000000 */ return machine->vtbl->CreateSharedFolder(machine, name, hostPath, writable, automount); -#endif /* VBOX_API_VERSION >= 4000000 */ } static nsresult @@ -3058,17 +2021,8 @@ _machineLaunchVMProcess(vboxDriverPtr data, PRUnichar *sessionType, PRUnichar *env, IProgress **progress) { -#if VBOX_API_VERSION < 4000000 - return data->vboxObj->vtbl->OpenRemoteSession(data->vboxObj, - data->vboxSession, - IID_MEMBER(value), - sessionType, - env, - progress); -#else /* VBOX_API_VERSION >= 4000000 */ return machine->vtbl->LaunchVMProcess(machine, data->vboxSession, sessionType, env, progress); -#endif /* VBOX_API_VERSION >= 4000000 */ } static nsresult @@ -3077,33 +2031,20 @@ _machineUnregister(IMachine *machine ATTRIBUTE_UNUSED, PRUint32 *aMediaSize ATTRIBUTE_UNUSED, IMedium ***aMedia ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION < 4000000 - vboxUnsupported(); - return 0; -#else /* VBOX_API_VERSION >= 4000000 */ return machine->vtbl->Unregister(machine, cleanupMode, aMediaSize, aMedia); -#endif /* VBOX_API_VERSION >= 4000000 */ } static nsresult _machineFindSnapshot(IMachine *machine, vboxIIDUnion *iidu, ISnapshot **snapshot) { -#if VBOX_API_VERSION < 4000000 - return machine->vtbl->GetSnapshot(machine, IID_MEMBER(value), snapshot); -#else /* VBOX_API_VERSION >= 4000000 */ return machine->vtbl->FindSnapshot(machine, IID_MEMBER(value), snapshot); -#endif /* VBOX_API_VERSION >= 4000000 */ } static nsresult _machineDetachDevice(IMachine *machine, PRUnichar *name, PRInt32 controllerPort, PRInt32 device) { -#if VBOX_API_VERSION < 3001000 - return machine->vtbl->DetachHardDisk(machine, name, controllerPort, device); -#else /* VBOX_API_VERSION >= 3001000 */ return machine->vtbl->DetachDevice(machine, name, controllerPort, device); -#endif /* VBOX_API_VERSION >= 3001000 */ } static nsresult @@ -3151,12 +2092,7 @@ _machineGetNetworkAdapter(IMachine *machine, PRUint32 slot, INetworkAdapter **ad static nsresult _machineGetChipsetType(IMachine *machine ATTRIBUTE_UNUSED, PRUint32 *chipsetType ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION >= 4001000 return machine->vtbl->GetChipsetType(machine, chipsetType); -#else /* VBOX_API_VERSION < 4001000 */ - vboxUnsupported(); - return 0; -#endif /* VBOX_API_VERSION < 4001000 */ } static nsresult @@ -3174,11 +2110,7 @@ _machineGetParallelPort(IMachine *machine, PRUint32 slot, IParallelPort **port) static nsresult _machineGetVRDxServer(IMachine *machine, IVRDxServer **VRDxServer) { -#if VBOX_API_VERSION < 4000000 - return machine->vtbl->GetVRDPServer(machine, VRDxServer); -#else /* VBOX_API_VERSION >= 4000000 */ return machine->vtbl->GetVRDEServer(machine, VRDxServer); -#endif /* VBOX_API_VERSION >= 4000000 */ } static nsresult @@ -3230,25 +2162,13 @@ _machineSetMemorySize(IMachine *machine, PRUint32 memorySize) static nsresult _machineGetCPUProperty(IMachine *machine, PRUint32 property ATTRIBUTE_UNUSED, PRBool *value) { -#if VBOX_API_VERSION < 3001000 - return machine->vtbl->GetPAEEnabled(machine, value); -#elif VBOX_API_VERSION == 3001000 - return machine->vtbl->GetCpuProperty(machine, property, value); -#elif VBOX_API_VERSION >= 3002000 return machine->vtbl->GetCPUProperty(machine, property, value); -#endif } static nsresult _machineSetCPUProperty(IMachine *machine, PRUint32 property ATTRIBUTE_UNUSED, PRBool value) { -#if VBOX_API_VERSION < 3001000 - return machine->vtbl->SetPAEEnabled(machine, value); -#elif VBOX_API_VERSION == 3001000 - return machine->vtbl->SetCpuProperty(machine, property, value); -#elif VBOX_API_VERSION >= 3002000 return machine->vtbl->SetCPUProperty(machine, property, value); -#endif } static nsresult @@ -3303,24 +2223,14 @@ static nsresult _machineGetAccelerate2DVideoEnabled(IMachine *machine ATTRIBUTE_UNUSED, PRBool *accelerate2DVideoEnabled ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION >= 3001000 return machine->vtbl->GetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled); -#else /* VBOX_API_VERSION < 3001000 */ - vboxUnsupported(); - return 0; -#endif /* VBOX_API_VERSION < 3001000 */ } static nsresult _machineSetAccelerate2DVideoEnabled(IMachine *machine ATTRIBUTE_UNUSED, PRBool accelerate2DVideoEnabled ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION >= 3001000 return machine->vtbl->SetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled); -#else /* VBOX_API_VERSION < 3001000 */ - vboxUnsupported(); - return 0; -#endif /* VBOX_API_VERSION < 3001000 */ } static nsresult @@ -3347,28 +2257,6 @@ _machineSaveSettings(IMachine *machine) return machine->vtbl->SaveSettings(machine); } -#if VBOX_API_VERSION < 4000000 - -static nsresult -_sessionOpen(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine *machine ATTRIBUTE_UNUSED) -{ - return data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, IID_MEMBER(value)); -} - -static nsresult -_sessionOpenExisting(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine *machine ATTRIBUTE_UNUSED) -{ - return data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, IID_MEMBER(value)); -} - -static nsresult -_sessionClose(ISession *session) -{ - return session->vtbl->Close(session); -} - -#else /* VBOX_API_VERSION >= 4000000 */ - static nsresult _sessionOpen(vboxDriverPtr data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine) { @@ -3387,8 +2275,6 @@ _sessionClose(ISession *session) return session->vtbl->UnlockMachine(session); } -#endif /* VBOX_API_VERSION >= 4000000 */ - static nsresult _sessionGetConsole(ISession *session, IConsole **console) { @@ -3445,16 +2331,13 @@ static nsresult _consolePowerDown(IConsole *console) { nsresult rc; -#if VBOX_API_VERSION == 2002000 - rc = console->vtbl->PowerDown(console); -#else IProgress *progress = NULL; rc = console->vtbl->PowerDown(console, &progress); if (progress) { rc = progress->vtbl->WaitForCompletion(progress, -1); VBOX_RELEASE(progress); } -#endif + return rc; } @@ -3492,9 +2375,7 @@ _consoleTakeSnapshot(IConsole *console, PRUnichar *name, static nsresult _consoleDeleteSnapshot(IConsole *console, vboxIIDUnion *iidu, IProgress **progress) { -#if VBOX_API_VERSION < 3001000 - return console->vtbl->DiscardSnapshot(console, IID_MEMBER(value), progress); -#elif VBOX_API_VERSION >= 3001000 && VBOX_API_VERSION < 5000000 /* VBOX_API_VERSION >= 3001000 */ +#if VBOX_API_VERSION < 5000000 /* VBOX_API_VERSION < 5000000 */ return console->vtbl->DeleteSnapshot(console, IID_MEMBER(value), progress); #else /* VBOX_API_VERSION >= 5000000 */ IMachine *machine; @@ -3535,11 +2416,7 @@ _progressWaitForCompletion(IProgress *progress, PRInt32 timeout) static nsresult _progressGetResultCode(IProgress *progress, resultCodeUnion *resultCode) { -#if VBOX_API_VERSION == 2002000 - return progress->vtbl->GetResultCode(progress, &resultCode->uResultCode); -#else /* VBOX_API_VERSION != 2002000 */ return progress->vtbl->GetResultCode(progress, &resultCode->resultCode); -#endif /* VBOX_API_VERSION != 2002000 */ } static nsresult @@ -3585,7 +2462,6 @@ _systemPropertiesGetParallelPortCount(ISystemProperties *systemProperties, PRUin return systemProperties->vtbl->GetParallelPortCount(systemProperties, ParallelPortCount); } -#if VBOX_API_VERSION >= 3001000 static nsresult _systemPropertiesGetMaxPortCountForStorageBus(ISystemProperties *systemProperties, PRUint32 bus, PRUint32 *maxPortCount) @@ -3600,25 +2476,6 @@ _systemPropertiesGetMaxDevicesPerPortForStorageBus(ISystemProperties *systemProp return systemProperties->vtbl->GetMaxDevicesPerPortForStorageBus(systemProperties, bus, maxDevicesPerPort); } -#else /* VBOX_API_VERSION < 3001000 */ -static nsresult -_systemPropertiesGetMaxPortCountForStorageBus(ISystemProperties *systemProperties ATTRIBUTE_UNUSED, - PRUint32 bus ATTRIBUTE_UNUSED, - PRUint32 *maxPortCount ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} - -static nsresult -_systemPropertiesGetMaxDevicesPerPortForStorageBus(ISystemProperties *systemProperties ATTRIBUTE_UNUSED, - PRUint32 bus ATTRIBUTE_UNUSED, - PRUint32 *maxDevicesPerPort ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} -#endif static nsresult _systemPropertiesGetMaxGuestRAM(ISystemProperties *systemProperties, PRUint32 *maxGuestRAM) @@ -3955,27 +2812,9 @@ _vrdxServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) { nsresult rc; -#if VBOX_API_VERSION < 3001000 - PRUint32 VRDPport = 0; - rc = VRDxServer->vtbl->GetPort(VRDxServer, &VRDPport); - if (VRDPport) { - graphics->data.rdp.port = VRDPport; - } else { - graphics->data.rdp.autoport = true; - } -#elif VBOX_API_VERSION < 4000000 /* 3001000 <= VBOX_API_VERSION < 4000000 */ - PRUnichar *VRDPport = NULL; - rc = VRDxServer->vtbl->GetPorts(VRDxServer, &VRDPport); - if (VRDPport) { - /* even if vbox supports mutilpe ports, single port for now here */ - graphics->data.rdp.port = PRUnicharToInt(data->pFuncs, VRDPport); - VBOX_UTF16_FREE(VRDPport); - } else { - graphics->data.rdp.autoport = true; - } -#else /* VBOX_API_VERSION >= 4000000 */ PRUnichar *VRDEPortsKey = NULL; PRUnichar *VRDEPortsValue = NULL; + VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey); rc = VRDxServer->vtbl->GetVRDEProperty(VRDxServer, VRDEPortsKey, &VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsKey); @@ -3986,7 +2825,7 @@ _vrdxServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, } else { graphics->data.rdp.autoport = true; } -#endif /* VBOX_API_VERSION >= 4000000 */ + return rc; } @@ -3995,34 +2834,16 @@ _vrdxServerSetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) { nsresult rc = 0; -#if VBOX_API_VERSION < 3001000 - if (graphics->data.rdp.port) { - rc = VRDxServer->vtbl->SetPort(VRDxServer, - graphics->data.rdp.port); - VIR_DEBUG("VRDP Port changed to: %d", - graphics->data.rdp.port); - } else if (graphics->data.rdp.autoport) { - /* Setting the port to 0 will reset its value to - * the default one which is 3389 currently - */ - rc = VRDxServer->vtbl->SetPort(VRDxServer, 0); - VIR_DEBUG("VRDP Port changed to default, which is 3389 currently"); - } -#elif VBOX_API_VERSION < 4000000 /* 3001000 <= VBOX_API_VERSION < 4000000 */ - PRUnichar *portUtf16 = NULL; - 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(data->pFuncs, graphics->data.rdp.port); rc = VRDxServer->vtbl->SetVRDEProperty(VRDxServer, VRDEPortsKey, VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsKey); VBOX_UTF16_FREE(VRDEPortsValue); -#endif /* VBOX_API_VERSION >= 4000000 */ + return rc; } @@ -4054,34 +2875,29 @@ static nsresult _vrdxServerGetNetAddress(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, PRUnichar **netAddress) { -#if VBOX_API_VERSION >= 4000000 PRUnichar *VRDENetAddressKey = NULL; nsresult rc; + VBOX_UTF8_TO_UTF16("TCP/Address", &VRDENetAddressKey); rc = VRDxServer->vtbl->GetVRDEProperty(VRDxServer, VRDENetAddressKey, netAddress); VBOX_UTF16_FREE(VRDENetAddressKey); + return rc; -#else /* VBOX_API_VERSION < 4000000 */ - return VRDxServer->vtbl->GetNetAddress(VRDxServer, netAddress); -#endif /* VBOX_API_VERSION < 4000000 */ } static nsresult _vrdxServerSetNetAddress(vboxDriverPtr data ATTRIBUTE_UNUSED, IVRDxServer *VRDxServer, PRUnichar *netAddress) { -#if VBOX_API_VERSION < 4000000 - return VRDxServer->vtbl->SetNetAddress(VRDxServer, - netAddress); -#else /* VBOX_API_VERSION >= 4000000 */ PRUnichar *netAddressKey = NULL; nsresult rc; + VBOX_UTF8_TO_UTF16("TCP/Address", &netAddressKey); rc = VRDxServer->vtbl->SetVRDEProperty(VRDxServer, netAddressKey, netAddress); VBOX_UTF16_FREE(netAddressKey); + return rc; -#endif /* VBOX_API_VERSION >= 4000000 */ } static nsresult @@ -4183,61 +2999,21 @@ static nsresult _mediumGetName(IMedium *medium, PRUnichar **name) static nsresult _mediumGetSize(IMedium *medium, PRUint64 *uSize) { -#if VBOX_API_VERSION < 4000000 - return medium->vtbl->GetSize(medium, uSize); -#else /* VBOX_API_VERSION >= 4000000 */ nsresult rc; PRInt64 Size; + rc = medium->vtbl->GetSize(medium, &Size); *uSize = Size; + return rc; -#endif /* VBOX_API_VERSION >= 4000000 */ } static nsresult _mediumGetReadOnly(IMedium *medium ATTRIBUTE_UNUSED, PRBool *readOnly ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION < 3001000 - vboxUnsupported(); - return 0; -#else /* VBOX_API_VERSION >= 3001000 */ return medium->vtbl->GetReadOnly(medium, readOnly); -#endif /* VBOX_API_VERSION >= 3001000 */ -} - -#if VBOX_API_VERSION < 3001000 - -static nsresult _mediumGetParent(IMedium *medium ATTRIBUTE_UNUSED, - IMedium **parent ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} - -static nsresult _mediumGetChildren(IMedium *medium ATTRIBUTE_UNUSED, - PRUint32 *childrenSize ATTRIBUTE_UNUSED, - IMedium ***children ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} - -static nsresult _mediumGetFormat(IMedium *medium ATTRIBUTE_UNUSED, - PRUnichar **format ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} - -static nsresult _mediumDeleteStorage(IMedium *medium ATTRIBUTE_UNUSED, - IProgress **progress ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; } -#else /* VBOX_API_VERSION >= 3001000 */ - static nsresult _mediumGetParent(IMedium *medium, IMedium **parent) { @@ -4263,8 +3039,6 @@ static nsresult _mediumDeleteStorage(IMedium *medium, return medium->vtbl->DeleteStorage(medium, progress); } -#endif /* VBOX_API_VERSION >= 3001000 */ - static nsresult _mediumRelease(IMedium *medium) { return medium->vtbl->nsisupports.Release((nsISupports *)medium); @@ -4277,12 +3051,7 @@ static nsresult _mediumClose(IMedium *medium) static nsresult _mediumSetType(IMedium *medium ATTRIBUTE_UNUSED, PRUint32 type ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION > 3000000 return medium->vtbl->SetType(medium, type); -#else - vboxUnsupported(); - return 0; -#endif } static nsresult @@ -4292,10 +3061,7 @@ _mediumCreateDiffStorage(IMedium *medium ATTRIBUTE_UNUSED, PRUint32 *variant ATTRIBUTE_UNUSED, IProgress **progress ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION < 3001000 - vboxUnsupported(); - return 0; -#elif VBOX_API_VERSION < 4003000 +#if VBOX_API_VERSION < 4003000 if (variantSize == 0) return 0; if (variantSize > 1) @@ -4310,11 +3076,7 @@ static nsresult _mediumAttachmentGetMedium(IMediumAttachment *mediumAttachment, IHardDisk **hardDisk) { -#if VBOX_API_VERSION < 3001000 - return mediumAttachment->vtbl->GetHardDisk(mediumAttachment, hardDisk); -#else /* VBOX_API_VERSION >= 3001000 */ return mediumAttachment->vtbl->GetMedium(mediumAttachment, hardDisk); -#endif /* VBOX_API_VERSION >= 3001000 */ } static nsresult @@ -4328,12 +3090,7 @@ static nsresult _mediumAttachmentGetType(IMediumAttachment *mediumAttachment ATTRIBUTE_UNUSED, PRUint32 *type ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION < 3001000 - vboxUnsupported(); - return 0; -#else /* VBOX_API_VERSION >= 3001000 */ return mediumAttachment->vtbl->GetType(mediumAttachment, type); -#endif /* VBOX_API_VERSION >= 3001000 */ } static nsresult @@ -4423,10 +3180,7 @@ _displayGetScreenResolution(IDisplay *display ATTRIBUTE_UNUSED, PRInt32 *xOrigin ATTRIBUTE_UNUSED, PRInt32 *yOrigin ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION < 3002000 - vboxUnsupported(); - return 0; -#elif VBOX_API_VERSION < 4003000 +#if VBOX_API_VERSION < 4003000 return display->vtbl->GetScreenResolution(display, screenId, width, height, bitsPerPixel); #elif VBOX_API_VERSION < 5000000 /* VBOX_API_VERSION >= 4003000 */ @@ -4482,24 +3236,8 @@ _hostCreateHostOnlyNetworkInterface(vboxDriverPtr data ATTRIBUTE_UNUSED, IHostNetworkInterface **networkInterface) { nsresult rc = -1; -#if VBOX_API_VERSION == 2002000 - if (STREQ(name, "vboxnet0")) { - PRUint32 interfaceType = 0; - PRUnichar *networkInterfaceNameUtf16 = NULL; - - VBOX_UTF8_TO_UTF16(name, &networkInterfaceNameUtf16); - host->vtbl->FindHostNetworkInterfaceByName(host, networkInterfaceNameUtf16, networkInterface); - - (*networkInterface)->vtbl->GetInterfaceType(*networkInterface, &interfaceType); - if (interfaceType != HostNetworkInterfaceType_HostOnly) { - VBOX_RELEASE(*networkInterface); - *networkInterface = NULL; - } else { - rc = 0; - } - } -#else /* VBOX_API_VERSION != 2002000 */ IProgress *progress = NULL; + host->vtbl->CreateHostOnlyNetworkInterface(host, networkInterface, &progress); @@ -4507,7 +3245,7 @@ _hostCreateHostOnlyNetworkInterface(vboxDriverPtr data ATTRIBUTE_UNUSED, rc = progress->vtbl->WaitForCompletion(progress, -1); VBOX_RELEASE(progress); } -#endif /* VBOX_API_VERSION != 2002000 */ + return rc; } @@ -4516,18 +3254,7 @@ _hostRemoveHostOnlyNetworkInterface(IHost *host ATTRIBUTE_UNUSED, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IProgress **progress ATTRIBUTE_UNUSED) { -#if VBOX_API_VERSION == 2002000 - vboxUnsupported(); - return 0; -#elif VBOX_API_VERSION == 3000000 - nsresult rc; - IHostNetworkInterface *netInt = NULL; - rc = host->vtbl->RemoveHostOnlyNetworkInterface(host, IID_MEMBER(value), &netInt, progress); - VBOX_RELEASE(netInt); - return rc; -#else /* VBOX_API_VERSION > 3000000 */ return host->vtbl->RemoveHostOnlyNetworkInterface(host, IID_MEMBER(value), progress); -#endif /* VBOX_API_VERSION > 3000000 */ } static nsresult @@ -4678,14 +3405,11 @@ static nsresult _hardDiskGetLogicalSizeInByte(IHardDisk *hardDisk, PRUint64 *uLogicalSize) { nsresult rc; -#if VBOX_API_VERSION < 4000000 - rc = hardDisk->vtbl->GetLogicalSize(hardDisk, uLogicalSize); - *uLogicalSize *= 1024 * 1024; /* MB => Bytes */ -#else /* VBOX_API_VERSION >= 4000000 */ PRInt64 logicalSize; + rc = hardDisk->vtbl->GetLogicalSize(hardDisk, &logicalSize); *uLogicalSize = logicalSize; -#endif /* VBOX_API_VERSION >= 4000000 */ + return rc; } -- 2.9.3

and fold vboxAttachDrivesNew into vboxAttachDrives --- src/vbox/vbox_common.c | 45 +--- src/vbox/vbox_tmpl.c | 487 ------------------------------------------ src/vbox/vbox_uniformed_api.h | 1 - 3 files changed, 1 insertion(+), 532 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index af8a9f7..17a8024 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1039,9 +1039,8 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxDriverPtr data, } static void -vboxAttachDrivesNew(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) +vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { - /* AttachDrives for 3.0 and later */ size_t i; nsresult rc = 0; PRUint32 maxPortPerInst[StorageBus_Floppy + 1] = {}; @@ -1049,9 +1048,6 @@ vboxAttachDrivesNew(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) PRUnichar *storageCtlName = NULL; bool error = false; - if (gVBoxAPI.vboxAttachDrivesUseOld) - VIR_WARN("This function may not work in current vbox version"); - /* get the max port/slots/etc for the given storage bus */ error = !vboxGetMaxPortSlotValues(data->vboxObj, maxPortPerInst, maxSlotPerPort); @@ -1248,45 +1244,6 @@ vboxAttachDrivesNew(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) } static void -vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) -{ - /* Here, About the vboxAttachDrives. In fact,there is - * three different implementations. We name it as - * v1, v2 and v3. - * - * The first version(v1) is only used in vbox 2.2 and 3.0, - * v2 is used by 3.1 and 3.2, and v3 is used for later - * vbox versions. In sight of implementation, the v1 is - * totally different with v2 and v3. The v2 shares the same - * outline with v3, meanwhile the API they used has much - * difference. - * - * It seems we have no thing to do with old versions such as - * v1 and v2 when developing new vbox drivers. What's more, - * most of the vbox APIs used in v1 and v2 is incompatible with - * new vbox versions. It is a burden to put these APIs into - * vboxUniformedAPI, I prefer not to do that. - * - * After balancing the code size and the complied code size, - * I put my solution here. The v1 and v2 is a version specified - * code, which only be generated for first four version. The v3 - * will be put in vbox_common.c, it be complied only once, then - * be used by all next vbox drivers. - * - * Check the flag vboxAttachDrivesUseOld can tell you which - * implementation to use. When the flag is set, we need use - * the old version though gVBoxAPI.vboxAttachDrivesOld. It - * will automatically point to v1 or v2 deponds on you version. - * If the flag is clear, just call vboxAttachDrivesNew, which - * is the v3 implementation. - */ - if (gVBoxAPI.vboxAttachDrivesUseOld) - gVBoxAPI.vboxAttachDrivesOld(def, data, machine); - else - vboxAttachDrivesNew(def, data, machine); -} - -static void vboxAttachSound(virDomainDefPtr def, IMachine *machine) { nsresult rc; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 7fcf213..c9c946c 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -324,490 +324,6 @@ static virDomainState _vboxConvertState(PRUint32 state) } } -#if VBOX_API_VERSION < 3001000 - -static void -_vboxAttachDrivesOld(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) -{ - size_t i; - nsresult rc; - - if (def->ndisks == 0) - return; - - for (i = 0; i < def->ndisks; i++) { - const char *src = virDomainDiskGetSource(def->disks[i]); - int type = virDomainDiskGetType(def->disks[i]); - int format = virDomainDiskGetFormat(def->disks[i]); - - VIR_DEBUG("disk(%zu) type: %d", i, type); - VIR_DEBUG("disk(%zu) device: %d", i, def->disks[i]->device); - VIR_DEBUG("disk(%zu) bus: %d", i, def->disks[i]->bus); - VIR_DEBUG("disk(%zu) src: %s", i, src); - VIR_DEBUG("disk(%zu) dst: %s", i, def->disks[i]->dst); - VIR_DEBUG("disk(%zu) driverName: %s", i, - virDomainDiskGetDriver(def->disks[i])); - VIR_DEBUG("disk(%zu) driverType: %s", i, - virStorageFileFormatTypeToString(format)); - VIR_DEBUG("disk(%zu) cachemode: %d", i, def->disks[i]->cachemode); - VIR_DEBUG("disk(%zu) readonly: %s", i, (def->disks[i]->src->readonly - ? "True" : "False")); - VIR_DEBUG("disk(%zu) shared: %s", i, (def->disks[i]->src->shared - ? "True" : "False")); - - if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { - if (type == VIR_STORAGE_TYPE_FILE && src) { - IDVDDrive *dvdDrive = NULL; - /* Currently CDROM/DVD Drive is always IDE - * Secondary Master so neglecting the following - * parameters: - * def->disks[i]->bus - * def->disks[i]->dst - */ - - machine->vtbl->GetDVDDrive(machine, &dvdDrive); - if (dvdDrive) { - IDVDImage *dvdImage = NULL; - PRUnichar *dvdfileUtf16 = NULL; - vboxIID dvduuid = VBOX_IID_INITIALIZER; - vboxIID dvdemptyuuid = VBOX_IID_INITIALIZER; - - VBOX_UTF8_TO_UTF16(src, &dvdfileUtf16); - - data->vboxObj->vtbl->FindDVDImage(data->vboxObj, - dvdfileUtf16, &dvdImage); - if (!dvdImage) { - data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, - dvdfileUtf16, - dvdemptyuuid.value, - &dvdImage); - } - if (dvdImage) { - rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, - &dvduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("can't get the uuid of the file to " - "be attached to cdrom: %s, rc=%08x"), - src, (unsigned)rc); - } else { - rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach the file to cdrom: %s, rc=%08x"), - src, (unsigned)rc); - } else { - DEBUGIID("CD/DVDImage UUID:", dvduuid.value); - } - } - - VBOX_MEDIUM_RELEASE(dvdImage); - } - vboxIIDUnalloc(&dvduuid); - VBOX_UTF16_FREE(dvdfileUtf16); - VBOX_RELEASE(dvdDrive); - } - } else if (type == VIR_STORAGE_TYPE_BLOCK) { - } - } else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - if (type == VIR_STORAGE_TYPE_FILE && src) { - IHardDisk *hardDisk = NULL; - PRUnichar *hddfileUtf16 = NULL; - vboxIID hdduuid = VBOX_IID_INITIALIZER; - PRUnichar *hddEmpty = NULL; - /* Current Limitation: Harddisk can't be connected to - * Secondary Master as Secondary Master is always used - * for CD/DVD Drive, so don't connect the harddisk if it - * is requested to be connected to Secondary master - */ - - VBOX_UTF8_TO_UTF16(src, &hddfileUtf16); - VBOX_UTF8_TO_UTF16("", &hddEmpty); - - data->vboxObj->vtbl->FindHardDisk(data->vboxObj, hddfileUtf16, - &hardDisk); - - if (!hardDisk) { -# if VBOX_API_VERSION == 2002000 - data->vboxObj->vtbl->OpenHardDisk(data->vboxObj, - hddfileUtf16, - AccessMode_ReadWrite, - &hardDisk); -# else - data->vboxObj->vtbl->OpenHardDisk(data->vboxObj, - hddfileUtf16, - AccessMode_ReadWrite, - 0, - hddEmpty, - 0, - hddEmpty, - &hardDisk); -# endif - } - - if (hardDisk) { - rc = hardDisk->vtbl->imedium.GetId((IMedium *)hardDisk, - &hdduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("can't get the uuid of the file to be " - "attached as harddisk: %s, rc=%08x"), - src, (unsigned)rc); - } else { - if (def->disks[i]->src->readonly) { - hardDisk->vtbl->SetType(hardDisk, - HardDiskType_Immutable); - VIR_DEBUG("setting harddisk to readonly"); - } else if (!def->disks[i]->src->readonly) { - hardDisk->vtbl->SetType(hardDisk, - HardDiskType_Normal); - VIR_DEBUG("setting harddisk type to normal"); - } - if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_IDE) { - if (STREQ(def->disks[i]->dst, "hdc")) { - VIR_DEBUG("Not connecting harddisk to hdc as hdc" - " is taken by CD/DVD Drive"); - } else { - PRInt32 channel = 0; - PRInt32 device = 0; - PRUnichar *hddcnameUtf16 = NULL; - - char *hddcname; - ignore_value(VIR_STRDUP(hddcname, "IDE")); - VBOX_UTF8_TO_UTF16(hddcname, &hddcnameUtf16); - VIR_FREE(hddcname); - - if (STREQ(def->disks[i]->dst, "hda")) { - channel = 0; - device = 0; - } else if (STREQ(def->disks[i]->dst, "hdb")) { - channel = 0; - device = 1; - } else if (STREQ(def->disks[i]->dst, "hdd")) { - channel = 1; - device = 1; - } - - rc = machine->vtbl->AttachHardDisk(machine, - hdduuid.value, - hddcnameUtf16, - channel, - device); - VBOX_UTF16_FREE(hddcnameUtf16); - - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach the file as " - "harddisk: %s, rc=%08x"), - src, (unsigned)rc); - } else { - DEBUGIID("Attached HDD with UUID", hdduuid.value); - } - } - } - } - VBOX_MEDIUM_RELEASE(hardDisk); - } - vboxIIDUnalloc(&hdduuid); - VBOX_UTF16_FREE(hddEmpty); - VBOX_UTF16_FREE(hddfileUtf16); - } else if (type == VIR_STORAGE_TYPE_BLOCK) { - } - } else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - if (type == VIR_STORAGE_TYPE_FILE && src) { - IFloppyDrive *floppyDrive; - machine->vtbl->GetFloppyDrive(machine, &floppyDrive); - if (floppyDrive) { - rc = floppyDrive->vtbl->SetEnabled(floppyDrive, 1); - if (NS_SUCCEEDED(rc)) { - IFloppyImage *floppyImage = NULL; - PRUnichar *fdfileUtf16 = NULL; - vboxIID fduuid = VBOX_IID_INITIALIZER; - vboxIID fdemptyuuid = VBOX_IID_INITIALIZER; - - VBOX_UTF8_TO_UTF16(src, &fdfileUtf16); - rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj, - fdfileUtf16, - &floppyImage); - - if (!floppyImage) { - data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj, - fdfileUtf16, - fdemptyuuid.value, - &floppyImage); - } - - if (floppyImage) { - rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, - &fduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("can't get the uuid of the file to " - "be attached to floppy drive: %s, rc=%08x"), - src, (unsigned)rc); - } else { - rc = floppyDrive->vtbl->MountImage(floppyDrive, - fduuid.value); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach the file to " - "floppy drive: %s, rc=%08x"), - src, (unsigned)rc); - } else { - DEBUGIID("floppyImage UUID", fduuid.value); - } - } - VBOX_MEDIUM_RELEASE(floppyImage); - } - vboxIIDUnalloc(&fduuid); - VBOX_UTF16_FREE(fdfileUtf16); - } - VBOX_RELEASE(floppyDrive); - } - } else if (type == VIR_STORAGE_TYPE_BLOCK) { - } - } - } -} - -#elif VBOX_API_VERSION < 4000000 - -static void -_vboxAttachDrivesOld(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) -{ - size_t i; - nsresult rc = 0; - - PRUint32 maxPortPerInst[StorageBus_Floppy + 1] = {}; - PRUint32 maxSlotPerPort[StorageBus_Floppy + 1] = {}; - PRUnichar *storageCtlName = NULL; - bool error = false; - - /* get the max port/slots/etc for the given storage bus */ - error = !vboxGetMaxPortSlotValues(data->vboxObj, maxPortPerInst, - maxSlotPerPort); - - /* add a storage controller for the mediums to be attached */ - /* this needs to change when multiple controller are supported for - * ver > 3.1 */ - { - IStorageController *storageCtl = NULL; - PRUnichar *sName = NULL; - - VBOX_UTF8_TO_UTF16("IDE Controller", &sName); - machine->vtbl->AddStorageController(machine, - sName, - StorageBus_IDE, - &storageCtl); - VBOX_UTF16_FREE(sName); - VBOX_RELEASE(storageCtl); - - VBOX_UTF8_TO_UTF16("SATA Controller", &sName); - machine->vtbl->AddStorageController(machine, - sName, - StorageBus_SATA, - &storageCtl); - VBOX_UTF16_FREE(sName); - VBOX_RELEASE(storageCtl); - - VBOX_UTF8_TO_UTF16("SCSI Controller", &sName); - machine->vtbl->AddStorageController(machine, - sName, - StorageBus_SCSI, - &storageCtl); - VBOX_UTF16_FREE(sName); - VBOX_RELEASE(storageCtl); - - VBOX_UTF8_TO_UTF16("Floppy Controller", &sName); - machine->vtbl->AddStorageController(machine, - sName, - StorageBus_Floppy, - &storageCtl); - VBOX_UTF16_FREE(sName); - VBOX_RELEASE(storageCtl); - } - - for (i = 0; i < def->ndisks && !error; i++) { - const char *src = virDomainDiskGetSource(def->disks[i]); - int type = virDomainDiskGetType(def->disks[i]); - int format = virDomainDiskGetFormat(def->disks[i]); - - VIR_DEBUG("disk(%zu) type: %d", i, type); - VIR_DEBUG("disk(%zu) device: %d", i, def->disks[i]->device); - VIR_DEBUG("disk(%zu) bus: %d", i, def->disks[i]->bus); - VIR_DEBUG("disk(%zu) src: %s", i, src); - VIR_DEBUG("disk(%zu) dst: %s", i, def->disks[i]->dst); - VIR_DEBUG("disk(%zu) driverName: %s", i, - virDomainDiskGetDriver(def->disks[i])); - VIR_DEBUG("disk(%zu) driverType: %s", i, - virStorageFileFormatTypeToString(format)); - VIR_DEBUG("disk(%zu) cachemode: %d", i, def->disks[i]->cachemode); - VIR_DEBUG("disk(%zu) readonly: %s", i, (def->disks[i]->src->readonly - ? "True" : "False")); - VIR_DEBUG("disk(%zu) shared: %s", i, (def->disks[i]->src->shared - ? "True" : "False")); - - if (type == VIR_STORAGE_TYPE_FILE && src) { - IMedium *medium = NULL; - PRUnichar *mediumUUID = NULL; - PRUnichar *mediumFileUtf16 = NULL; - PRUint32 storageBus = StorageBus_Null; - PRUint32 deviceType = DeviceType_Null; - PRInt32 deviceInst = 0; - PRInt32 devicePort = 0; - PRInt32 deviceSlot = 0; - - VBOX_UTF8_TO_UTF16(src, &mediumFileUtf16); - - if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - deviceType = DeviceType_HardDisk; - data->vboxObj->vtbl->FindHardDisk(data->vboxObj, - mediumFileUtf16, &medium); - } else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { - deviceType = DeviceType_DVD; - data->vboxObj->vtbl->FindDVDImage(data->vboxObj, - mediumFileUtf16, &medium); - } else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - deviceType = DeviceType_Floppy; - data->vboxObj->vtbl->FindFloppyImage(data->vboxObj, - mediumFileUtf16, &medium); - } else { - VBOX_UTF16_FREE(mediumFileUtf16); - continue; - } - - if (!medium) { - PRUnichar *mediumEmpty = NULL; - - VBOX_UTF8_TO_UTF16("", &mediumEmpty); - - if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - rc = data->vboxObj->vtbl->OpenHardDisk(data->vboxObj, - mediumFileUtf16, - AccessMode_ReadWrite, - false, - mediumEmpty, - false, - mediumEmpty, - &medium); - } else if (def->disks[i]->device == - VIR_DOMAIN_DISK_DEVICE_CDROM) { - rc = data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, - mediumFileUtf16, - mediumEmpty, - &medium); - } else if (def->disks[i]->device == - VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - rc = data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj, - mediumFileUtf16, - mediumEmpty, - &medium); - } else { - rc = 0; - } - VBOX_UTF16_FREE(mediumEmpty); - } - - if (!medium) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to attach the following disk/dvd/floppy " - "to the machine: %s, rc=%08x"), - src, (unsigned)rc); - VBOX_UTF16_FREE(mediumFileUtf16); - continue; - } - - rc = medium->vtbl->GetId(medium, &mediumUUID); - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("can't get the uuid of the file to be attached " - "as harddisk/dvd/floppy: %s, rc=%08x"), - src, (unsigned)rc); - VBOX_RELEASE(medium); - VBOX_UTF16_FREE(mediumFileUtf16); - continue; - } - - if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - if (def->disks[i]->src->readonly) { - medium->vtbl->SetType(medium, MediumType_Immutable); - VIR_DEBUG("setting harddisk to immutable"); - } else if (!def->disks[i]->src->readonly) { - medium->vtbl->SetType(medium, MediumType_Normal); - VIR_DEBUG("setting harddisk type to normal"); - } - } - - if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_IDE) { - VBOX_UTF8_TO_UTF16("IDE Controller", &storageCtlName); - storageBus = StorageBus_IDE; - } else if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_SATA) { - VBOX_UTF8_TO_UTF16("SATA Controller", &storageCtlName); - storageBus = StorageBus_SATA; - } else if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_SCSI) { - VBOX_UTF8_TO_UTF16("SCSI Controller", &storageCtlName); - storageBus = StorageBus_SCSI; - } else if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_FDC) { - VBOX_UTF8_TO_UTF16("Floppy Controller", &storageCtlName); - storageBus = StorageBus_Floppy; - } - - /* get the device details i.e instance, port and slot */ - if (!vboxGetDeviceDetails(def->disks[i]->dst, - maxPortPerInst, - maxSlotPerPort, - storageBus, - &deviceInst, - &devicePort, - &deviceSlot)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("can't get the port/slot number of " - "harddisk/dvd/floppy to be attached: " - "%s, rc=%08x"), - src, (unsigned)rc); - VBOX_RELEASE(medium); - VBOX_UTF16_FREE(mediumUUID); - VBOX_UTF16_FREE(mediumFileUtf16); - continue; - } - - /* attach the harddisk/dvd/Floppy to the storage controller */ - rc = machine->vtbl->AttachDevice(machine, - storageCtlName, - devicePort, - deviceSlot, - deviceType, - mediumUUID); - - if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach the file as " - "harddisk/dvd/floppy: %s, rc=%08x"), - src, (unsigned)rc); - } else { - DEBUGIID("Attached HDD/DVD/Floppy with UUID", mediumUUID); - } - - VBOX_RELEASE(medium); - VBOX_UTF16_FREE(mediumUUID); - VBOX_UTF16_FREE(mediumFileUtf16); - VBOX_UTF16_FREE(storageCtlName); - } - } -} - -#else /* VBOX_API_VERSION >= 4000000 */ - -static void -_vboxAttachDrivesOld(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxDriverPtr data ATTRIBUTE_UNUSED, - IMachine *machine ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); -} - -#endif /* VBOX_API_VERSION >= 4000000 */ - static int _vboxDomainSnapshotRestore(virDomainPtr dom, IMachine *machine, @@ -3808,7 +3324,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->detachDevices = _detachDevices; pVBoxAPI->unregisterMachine = _unregisterMachine; pVBoxAPI->deleteConfig = _deleteConfig; - pVBoxAPI->vboxAttachDrivesOld = _vboxAttachDrivesOld; pVBoxAPI->vboxConvertState = _vboxConvertState; pVBoxAPI->dumpIDEHDDsOld = _dumpIDEHDDsOld; pVBoxAPI->dumpDVD = _dumpDVD; @@ -3860,12 +3375,10 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */ pVBoxAPI->getMachineForSession = 1; pVBoxAPI->detachDevicesExplicitly = 0; - pVBoxAPI->vboxAttachDrivesUseOld = 0; pVBoxAPI->supportScreenshot = 1; #else /* VBOX_API_VERSION < 4000000 */ pVBoxAPI->getMachineForSession = 0; pVBoxAPI->detachDevicesExplicitly = 1; - pVBoxAPI->vboxAttachDrivesUseOld = 1; pVBoxAPI->supportScreenshot = 0; #endif /* VBOX_API_VERSION < 4000000 */ diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 3b2b7a8..6c4cf3d 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -605,7 +605,6 @@ typedef struct { bool detachDevicesExplicitly; bool chipsetType; bool accelerate2DVideo; - bool vboxAttachDrivesUseOld; bool oldMediumInterface; bool vboxSnapshotRedefine; bool supportScreenshot; -- 2.9.3

VirtualBox 4.0+ uses IMedium and IHardDisk is no longer used, so * remove typef IMedium IHardDisk * merge UIHardDisk into UIMedium * update all references accordingly --- src/vbox/vbox_common.h | 1 - src/vbox/vbox_storage.c | 32 +++++++-------- src/vbox/vbox_tmpl.c | 91 +++++++++++++++++-------------------------- src/vbox/vbox_uniformed_api.h | 31 ++++++--------- 4 files changed, 64 insertions(+), 91 deletions(-) diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index 7bbab8d..76f7a8e 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -340,7 +340,6 @@ typedef nsISupports IDisplay; typedef nsISupports IHost; typedef nsISupports IHostNetworkInterface; typedef nsISupports IDHCPServer; -typedef IMedium IHardDisk; typedef nsISupports IKeyboard; /* Macros for all vbox drivers. */ diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index c286753..6c92a3c 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -106,7 +106,7 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool) } for (i = 0; i < hardDisks.count; ++i) { - IHardDisk *hardDisk = hardDisks.items[i]; + IMedium *hardDisk = hardDisks.items[i]; PRUint32 hddstate; if (!hardDisk) @@ -147,7 +147,7 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nname } for (i = 0; i < hardDisks.count && numActive < nnames; ++i) { - IHardDisk *hardDisk = hardDisks.items[i]; + IMedium *hardDisk = hardDisks.items[i]; PRUint32 hddstate; char *nameUtf8 = NULL; PRUnichar *nameUtf16 = NULL; @@ -201,7 +201,7 @@ vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) return ret; for (i = 0; i < hardDisks.count; ++i) { - IHardDisk *hardDisk = hardDisks.items[i]; + IMedium *hardDisk = hardDisks.items[i]; PRUint32 hddstate; char *nameUtf8 = NULL; PRUnichar *nameUtf16 = NULL; @@ -259,7 +259,7 @@ vboxStorageVolLookupByKey(virConnectPtr conn, const char *key) vboxDriverPtr data = conn->privateData; vboxIIDUnion hddIID; unsigned char uuid[VIR_UUID_BUFLEN]; - IHardDisk *hardDisk = NULL; + IMedium *hardDisk = NULL; PRUnichar *hddNameUtf16 = NULL; char *hddNameUtf8 = NULL; PRUint32 hddstate; @@ -325,7 +325,7 @@ vboxStorageVolLookupByPath(virConnectPtr conn, const char *path) { vboxDriverPtr data = conn->privateData; PRUnichar *hddPathUtf16 = NULL; - IHardDisk *hardDisk = NULL; + IMedium *hardDisk = NULL; PRUnichar *hddNameUtf16 = NULL; char *hddNameUtf8 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; @@ -410,7 +410,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, vboxIIDUnion hddIID; unsigned char uuid[VIR_UUID_BUFLEN]; char key[VIR_UUID_STRING_BUFLEN] = ""; - IHardDisk *hardDisk = NULL; + IMedium *hardDisk = NULL; IProgress *progress = NULL; PRUint64 logicalSize = 0; PRUint32 variant = HardDiskVariant_Standard; @@ -469,7 +469,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, if (def->target.capacity == def->target.allocation) variant = HardDiskVariant_Fixed; - rc = gVBoxAPI.UIHardDisk.CreateBaseStorage(hardDisk, logicalSize, variant, &progress); + rc = gVBoxAPI.UIMedium.CreateBaseStorage(hardDisk, logicalSize, variant, &progress); if (NS_FAILED(rc) || !progress) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not create base storage, rc=%08x"), @@ -510,7 +510,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) { vboxDriverPtr data = vol->conn->privateData; unsigned char uuid[VIR_UUID_BUFLEN]; - IHardDisk *hardDisk = NULL; + IMedium *hardDisk = NULL; int deregister = 0; PRUint32 hddstate = 0; size_t i = 0; @@ -592,7 +592,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) for (j = 0; j < hddAttachments.count; j++) { IMediumAttachment *hddAttachment = hddAttachments.items[j]; - IHardDisk *hdd = NULL; + IMedium *hdd = NULL; vboxIIDUnion iid; if (!hddAttachment) @@ -646,7 +646,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) if (machineIdsSize == 0 || machineIdsSize == deregister) { IProgress *progress = NULL; - if (NS_SUCCEEDED(gVBoxAPI.UIHardDisk.DeleteStorage(hardDisk, &progress)) && + if (NS_SUCCEEDED(gVBoxAPI.UIMedium.DeleteStorage(hardDisk, &progress)) && progress) { gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); VBOX_RELEASE(progress); @@ -664,7 +664,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info) { vboxDriverPtr data = vol->conn->privateData; - IHardDisk *hardDisk = NULL; + IMedium *hardDisk = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; PRUint32 hddstate; PRUint64 hddLogicalSize = 0; @@ -697,7 +697,7 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info info->type = VIR_STORAGE_VOL_FILE; - gVBoxAPI.UIHardDisk.GetLogicalSizeInByte(hardDisk, &hddLogicalSize); + gVBoxAPI.UIMedium.GetLogicalSize(hardDisk, &hddLogicalSize); info->capacity = hddLogicalSize; gVBoxAPI.UIMedium.GetSize(hardDisk, &hddActualSize); @@ -719,7 +719,7 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) { vboxDriverPtr data = vol->conn->privateData; - IHardDisk *hardDisk = NULL; + IMedium *hardDisk = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; PRUnichar *hddFormatUtf16 = NULL; char *hddFormatUtf8 = NULL; @@ -764,7 +764,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) pool.type = VIR_STORAGE_POOL_DIR; def.type = VIR_STORAGE_VOL_FILE; - rc = gVBoxAPI.UIHardDisk.GetLogicalSizeInByte(hardDisk, &hddLogicalSize); + rc = gVBoxAPI.UIMedium.GetLogicalSize(hardDisk, &hddLogicalSize); if (NS_FAILED(rc)) goto cleanup; @@ -780,7 +780,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) if (VIR_STRDUP(def.key, vol->key) < 0) goto cleanup; - rc = gVBoxAPI.UIHardDisk.GetFormat(hardDisk, &hddFormatUtf16); + rc = gVBoxAPI.UIMedium.GetFormat(hardDisk, &hddFormatUtf16); if (NS_FAILED(rc)) goto cleanup; @@ -811,7 +811,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) static char *vboxStorageVolGetPath(virStorageVolPtr vol) { vboxDriverPtr data = vol->conn->privateData; - IHardDisk *hardDisk = NULL; + IMedium *hardDisk = NULL; PRUnichar *hddLocationUtf16 = NULL; char *hddLocationUtf8 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index c9c946c..55adf6d 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -73,7 +73,6 @@ #include "vbox_glue.h" typedef IVRDEServer IVRDxServer; -typedef IMedium IHardDisk; #if VBOX_API_VERSION < 4003000 typedef IUSBController IUSBCommon; @@ -1402,15 +1401,15 @@ _virtualboxCreateMachine(vboxDriverPtr data, virDomainDefPtr def, IMachine **mac static nsresult _virtualboxCreateHardDisk(IVirtualBox *vboxObj, PRUnichar *format, - PRUnichar *location, IHardDisk **hardDisk) + PRUnichar *location, IMedium **medium) { /* In vbox 2.2 and 3.0, this function will create a IHardDisk object. * In vbox 3.1 and later, this function will create a IMedium object. */ #if VBOX_API_VERSION < 5000000 - return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, hardDisk); + return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, medium); #elif VBOX_API_VERSION >= 5000000 /*VBOX_API_VERSION >= 5000000*/ - return vboxObj->vtbl->CreateMedium(vboxObj, format, location, AccessMode_ReadWrite, DeviceType_HardDisk, hardDisk); + return vboxObj->vtbl->CreateMedium(vboxObj, format, location, AccessMode_ReadWrite, DeviceType_HardDisk, medium); #endif /*VBOX_API_VERSION >= 5000000*/ } @@ -1424,14 +1423,14 @@ static nsresult _virtualboxFindHardDisk(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType ATTRIBUTE_UNUSED, PRUint32 accessMode ATTRIBUTE_UNUSED, - IHardDisk **hardDisk) + IMedium **medium) { #if VBOX_API_VERSION < 4002000 return vboxObj->vtbl->FindMedium(vboxObj, location, - deviceType, hardDisk); + deviceType, medium); #else /* VBOX_API_VERSION >= 4002000 */ return vboxObj->vtbl->OpenMedium(vboxObj, location, - deviceType, accessMode, PR_FALSE, hardDisk); + deviceType, accessMode, PR_FALSE, medium); #endif /* VBOX_API_VERSION >= 4002000 */ } @@ -1457,14 +1456,14 @@ _virtualboxOpenMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED, } static nsresult -_virtualboxGetHardDiskByIID(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IHardDisk **hardDisk) +_virtualboxGetHardDiskByIID(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMedium **medium) { #if VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000 return vboxObj->vtbl->FindMedium(vboxObj, IID_MEMBER(value), DeviceType_HardDisk, - hardDisk); + medium); #else /* VBOX_API_VERSION >= 4002000 */ return vboxObj->vtbl->OpenMedium(vboxObj, IID_MEMBER(value), DeviceType_HardDisk, - AccessMode_ReadWrite, PR_FALSE, hardDisk); + AccessMode_ReadWrite, PR_FALSE, medium); #endif /* VBOX_API_VERSION >= 4002000 */ } @@ -2589,10 +2588,33 @@ _mediumCreateDiffStorage(IMedium *medium ATTRIBUTE_UNUSED, } static nsresult +_mediumCreateBaseStorage(IMedium *medium, PRUint64 logicalSize, + PRUint32 variant, IProgress **progress) +{ +#if VBOX_API_VERSION < 4003000 + return medium->vtbl->CreateBaseStorage(medium, logicalSize, variant, progress); +#else + return medium->vtbl->CreateBaseStorage(medium, logicalSize, 1, &variant, progress); +#endif +} + +static nsresult +_mediumGetLogicalSize(IMedium *medium, PRUint64 *uLogicalSize) +{ + nsresult rc; + PRInt64 logicalSize; + + rc = medium->vtbl->GetLogicalSize(medium, &logicalSize); + *uLogicalSize = logicalSize; + + return rc; +} + +static nsresult _mediumAttachmentGetMedium(IMediumAttachment *mediumAttachment, - IHardDisk **hardDisk) + IMedium **medium) { - return mediumAttachment->vtbl->GetMedium(mediumAttachment, hardDisk); + return mediumAttachment->vtbl->GetMedium(mediumAttachment, medium); } static nsresult @@ -2901,41 +2923,6 @@ _dhcpServerStop(IDHCPServer *dhcpServer) } static nsresult -_hardDiskCreateBaseStorage(IHardDisk *hardDisk, PRUint64 logicalSize, - PRUint32 variant, IProgress **progress) -{ -#if VBOX_API_VERSION < 4003000 - return hardDisk->vtbl->CreateBaseStorage(hardDisk, logicalSize, variant, progress); -#else - return hardDisk->vtbl->CreateBaseStorage(hardDisk, logicalSize, 1, &variant, progress); -#endif -} - -static nsresult -_hardDiskDeleteStorage(IHardDisk *hardDisk, IProgress **progress) -{ - return hardDisk->vtbl->DeleteStorage(hardDisk, progress); -} - -static nsresult -_hardDiskGetLogicalSizeInByte(IHardDisk *hardDisk, PRUint64 *uLogicalSize) -{ - nsresult rc; - PRInt64 logicalSize; - - rc = hardDisk->vtbl->GetLogicalSize(hardDisk, &logicalSize); - *uLogicalSize = logicalSize; - - return rc; -} - -static nsresult -_hardDiskGetFormat(IHardDisk *hardDisk, PRUnichar **format) -{ - return hardDisk->vtbl->GetFormat(hardDisk, format); -} - -static nsresult _keyboardPutScancode(IKeyboard *keyboard, PRInt32 scancode) { return keyboard->vtbl->PutScancode(keyboard, scancode); @@ -3229,6 +3216,8 @@ static vboxUniformedIMedium _UIMedium = { .Close = _mediumClose, .SetType = _mediumSetType, .CreateDiffStorage = _mediumCreateDiffStorage, + .CreateBaseStorage = _mediumCreateBaseStorage, + .GetLogicalSize = _mediumGetLogicalSize, }; static vboxUniformedIMediumAttachment _UIMediumAttachment = { @@ -3295,13 +3284,6 @@ static vboxUniformedIDHCPServer _UIDHCPServer = { .Stop = _dhcpServerStop, }; -static vboxUniformedIHardDisk _UIHardDisk = { - .CreateBaseStorage = _hardDiskCreateBaseStorage, - .DeleteStorage = _hardDiskDeleteStorage, - .GetLogicalSizeInByte = _hardDiskGetLogicalSizeInByte, - .GetFormat = _hardDiskGetFormat, -}; - static vboxUniformedIKeyboard _UIKeyboard = { .PutScancode = _keyboardPutScancode, .PutScancodes = _keyboardPutScancodes, @@ -3361,7 +3343,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->UIHost = _UIHost; pVBoxAPI->UIHNInterface = _UIHNInterface; pVBoxAPI->UIDHCPServer = _UIDHCPServer; - pVBoxAPI->UIHardDisk = _UIHardDisk; pVBoxAPI->UIKeyboard = _UIKeyboard; pVBoxAPI->machineStateChecker = _machineStateChecker; diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 6c4cf3d..3892aae 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -196,12 +196,12 @@ typedef struct { nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties); nsresult (*GetHost)(IVirtualBox *vboxObj, IHost **host); nsresult (*CreateMachine)(vboxDriverPtr driver, virDomainDefPtr def, IMachine **machine, char *uuidstr); - nsresult (*CreateHardDisk)(IVirtualBox *vboxObj, PRUnichar *format, PRUnichar *location, IHardDisk **hardDisk); + nsresult (*CreateHardDisk)(IVirtualBox *vboxObj, PRUnichar *format, PRUnichar *location, IMedium **medium); nsresult (*RegisterMachine)(IVirtualBox *vboxObj, IMachine *machine); nsresult (*FindHardDisk)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, - PRUint32 accessMode, IHardDisk **hardDisk); + PRUint32 accessMode, IMedium **medium); nsresult (*OpenMedium)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, PRUint32 accessMode, IMedium **medium); - nsresult (*GetHardDiskByIID)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IHardDisk **hardDisk); + nsresult (*GetHardDiskByIID)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMedium **medium); nsresult (*FindDHCPServerByNetworkName)(IVirtualBox *vboxObj, PRUnichar *name, IDHCPServer **server); nsresult (*CreateDHCPServer)(IVirtualBox *vboxObj, PRUnichar *name, IDHCPServer **server); nsresult (*RemoveDHCPServer)(IVirtualBox *vboxObj, IDHCPServer *server); @@ -420,19 +420,24 @@ typedef struct { nsresult (*GetSize)(IMedium *medium, PRUint64 *uSize); nsresult (*GetReadOnly)(IMedium *medium, PRBool *readOnly); nsresult (*GetParent)(IMedium *medium, IMedium **parent); - nsresult (*GetChildren)(IMedium *medium, PRUint32 *childrenSize, IMedium ***children); + nsresult (*GetChildren)(IMedium *medium, PRUint32 *childrenSize, + IMedium ***children); nsresult (*GetFormat)(IMedium *medium, PRUnichar **format); nsresult (*DeleteStorage)(IMedium *medium, IProgress **progress); nsresult (*Release)(IMedium *medium); nsresult (*Close)(IMedium *medium); nsresult (*SetType)(IMedium *medium, PRUint32 type); - nsresult (*CreateDiffStorage)(IMedium *medium, IMedium *target, PRUint32 variantSize, - PRUint32 *variant, IProgress **progress); + nsresult (*CreateDiffStorage)(IMedium *medium, IMedium *target, + PRUint32 variantSize, PRUint32 *variant, + IProgress **progress); + nsresult (*CreateBaseStorage)(IMedium *medium, PRUint64 logicalSize, + PRUint32 variant, IProgress **progress); + nsresult (*GetLogicalSize)(IMedium *medium, PRUint64 *uLogicalSize); } vboxUniformedIMedium; /* Functions for IMediumAttachment */ typedef struct { - nsresult (*GetMedium)(IMediumAttachment *mediumAttachment, IHardDisk **hardDisk); + nsresult (*GetMedium)(IMediumAttachment *mediumAttachment, IMedium **medium); nsresult (*GetController)(IMediumAttachment *mediumAttachment, PRUnichar **controller); nsresult (*GetType)(IMediumAttachment *mediumAttachment, PRUint32 *type); nsresult (*GetPort)(IMediumAttachment *mediumAttachment, PRInt32 *port); @@ -523,17 +528,6 @@ typedef struct { nsresult (*Stop)(IDHCPServer *dhcpServer); } vboxUniformedIDHCPServer; -/* Functions for IHardDisk, in vbox3.1 and later, it will call the - * corresponding functions in IMedium as IHardDisk does't exist in - * these versions. */ -typedef struct { - nsresult (*CreateBaseStorage)(IHardDisk *hardDisk, PRUint64 logicalSize, - PRUint32 variant, IProgress **progress); - nsresult (*DeleteStorage)(IHardDisk *hardDisk, IProgress **progress); - nsresult (*GetLogicalSizeInByte)(IHardDisk *hardDisk, PRUint64 *uLogicalSize); - nsresult (*GetFormat)(IHardDisk *hardDisk, PRUnichar **format); -} vboxUniformedIHardDisk; - typedef struct { nsresult (*PutScancode)(IKeyboard *keyboard, PRInt32 scancode); nsresult (*PutScancodes)(IKeyboard *keyboard, PRUint32 scancodesSize, @@ -596,7 +590,6 @@ typedef struct { vboxUniformedIHost UIHost; vboxUniformedIHNInterface UIHNInterface; vboxUniformedIDHCPServer UIDHCPServer; - vboxUniformedIHardDisk UIHardDisk; vboxUniformedIKeyboard UIKeyboard; uniformedMachineStateChecker machineStateChecker; /* vbox API features */ -- 2.9.3

* the getMachineForSession is always true for 4.0+. This also means that checkflag argument in openSessionForMachine no longer has any meaning because it was or'ed with getMachineForSession (always true) * remove supportScreenshot flag - vbox 4.0+ supports it * remove detachDevicesExplicitly flag only relevant for < 4.0 --- src/vbox/vbox_common.c | 131 ++++++++++++++---------------------------- src/vbox/vbox_storage.c | 14 ++--- src/vbox/vbox_tmpl.c | 11 ---- src/vbox/vbox_uniformed_api.h | 3 - 4 files changed, 48 insertions(+), 111 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 17a8024..f2ac7f9 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -282,19 +282,19 @@ vboxDestroyDriverConnection(void) virMutexUnlock(&vbox_driver_lock); } -static int openSessionForMachine(vboxDriverPtr data, const unsigned char *dom_uuid, vboxIIDUnion *iid, - IMachine **machine, bool checkflag) +static int openSessionForMachine(vboxDriverPtr data, const unsigned char *dom_uuid, + vboxIIDUnion *iid, IMachine **machine) { VBOX_IID_INITIALIZE(iid); vboxIIDFromUUID(iid, dom_uuid); - if (!checkflag || gVBoxAPI.getMachineForSession) { - /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */ - if (NS_FAILED(gVBoxAPI.UIVirtualBox.GetMachine(data->vboxObj, iid, machine))) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); - return -1; - } + + /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */ + if (NS_FAILED(gVBoxAPI.UIVirtualBox.GetMachine(data->vboxObj, iid, machine))) { + virReportError(VIR_ERR_NO_DOMAIN, "%s", + _("no domain with matching uuid")); + return -1; } + return 0; } @@ -563,7 +563,7 @@ vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) */ /* Open a Session for the machine */ - if (openSessionForMachine(data, dom->uuid, &iid, &machine, true) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; rc = gVBoxAPI.UISession.OpenExisting(data, &iid, machine); @@ -2014,42 +2014,6 @@ vboxDomainDefineXML(virConnectPtr conn, const char *xml) return vboxDomainDefineXMLFlags(conn, xml, 0); } -static void -detachDevices_common(vboxDriverPtr data, vboxIIDUnion *iidu) -{ - /* Block for checking if HDD's are attched to VM. - * considering just IDE bus for now. Also skipped - * chanel=1 and device=0 (Secondary Master) as currenlty - * it is allocated to CD/DVD Drive by default. - * - * Only do this for VirtualBox 3.x and before. Since - * VirtualBox 4.0 the Unregister method can do this for use. - */ - IMachine *machine = NULL; - PRUnichar *hddcnameUtf16 = NULL; - nsresult rc; - char *hddcname; - - if (!gVBoxAPI.detachDevicesExplicitly) - VIR_WARN("This function may not work in current vbox version"); - - ignore_value(VIR_STRDUP(hddcname, "IDE")); - VBOX_UTF8_TO_UTF16(hddcname, &hddcnameUtf16); - VIR_FREE(hddcname); - - /* Open a Session for the machine */ - rc = gVBoxAPI.UISession.Open(data, iidu, machine); - if (NS_SUCCEEDED(rc)) { - rc = gVBoxAPI.UISession.GetMachine(data->vboxSession, &machine); - if (NS_SUCCEEDED(rc) && machine) { - gVBoxAPI.detachDevices(data, machine, hddcnameUtf16); - gVBoxAPI.UIMachine.SaveSettings(machine); - } - gVBoxAPI.UISession.Close(data->vboxSession); - } - VBOX_UTF16_FREE(hddcnameUtf16); -} - static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; @@ -2067,8 +2031,6 @@ static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags) * VBox, so we can trivially ignore that flag. */ virCheckFlags(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, -1); vboxIIDFromUUID(&iid, dom->uuid); - if (gVBoxAPI.detachDevicesExplicitly) - detachDevices_common(data, &iid); rc = gVBoxAPI.unregisterMachine(data, &iid, &machine); DEBUGIID("UUID of machine being undefined", &iid); @@ -2432,7 +2394,7 @@ static int vboxDomainIsPersistent(virDomainPtr dom) if (!data->vboxObj) return ret; - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; ret = 1; @@ -2455,7 +2417,7 @@ static int vboxDomainIsUpdated(virDomainPtr dom) if (!data->vboxObj) return ret; - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; ret = 0; @@ -2479,7 +2441,7 @@ static int vboxDomainSuspend(virDomainPtr dom) if (!data->vboxObj) return ret; - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!machine) @@ -2530,7 +2492,7 @@ static int vboxDomainResume(virDomainPtr dom) if (!data->vboxObj) return ret; - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!machine) @@ -2583,7 +2545,7 @@ static int vboxDomainShutdownFlags(virDomainPtr dom, unsigned int flags) virCheckFlags(0, -1); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!machine) @@ -2640,7 +2602,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags) virCheckFlags(0, -1); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!machine) @@ -2688,7 +2650,7 @@ static int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags) virCheckFlags(0, -1); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!machine) @@ -2752,7 +2714,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) if (!data->vboxObj) return ret; - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!machine) @@ -2894,7 +2856,7 @@ static int vboxDomainGetState(virDomainPtr dom, int *state, virCheckFlags(0, -1); - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; gVBoxAPI.UIMachine.GetState(machine, &mstate); @@ -2929,7 +2891,7 @@ static int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, return -1; } - if (openSessionForMachine(data, dom->uuid, &iid, &machine, true) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) return -1; rc = gVBoxAPI.UISession.Open(data, &iid, machine); @@ -3859,7 +3821,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) /* Flags checked by virDomainDefFormat */ - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!(def = virDomainDefNew())) @@ -4131,7 +4093,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, if (dev == NULL) goto cleanup; - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!machine) @@ -4263,7 +4225,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) if (dev == NULL) goto cleanup; - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!machine) @@ -4487,7 +4449,7 @@ vboxSnapshotRedefine(virDomainPtr dom, if (!gVBoxAPI.vboxSnapshotRedefine) VIR_WARN("This function may not work in current version"); - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; rc = gVBoxAPI.UIMachine.SaveSettings(machine); @@ -5342,7 +5304,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, goto cleanup; - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; if (gVBoxAPI.vboxSnapshotRedefine) { @@ -5588,7 +5550,7 @@ static int vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def, VIR_WARN("This function may not work in current version"); VBOX_IID_INITIALIZE(&snapIid); - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name))) @@ -5808,7 +5770,7 @@ int vboxSnapshotGetReadOnlyDisks(virDomainSnapshotPtr snapshot, if (!gVBoxAPI.vboxSnapshotRedefine) VIR_WARN("This function may not work in current version"); - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name))) @@ -6025,7 +5987,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, virCheckFlags(0, NULL); - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name))) @@ -6164,7 +6126,7 @@ static int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags) virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS | VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; /* VBox snapshots do not require libvirt to maintain any metadata. */ @@ -6210,7 +6172,7 @@ static int vboxDomainSnapshotListNames(virDomainPtr dom, char **names, virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS | VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) { @@ -6288,7 +6250,7 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom, const char *name, virCheckFlags(0, NULL); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!(snapshot = vboxDomainSnapshotGet(data, dom, machine, name))) @@ -6318,7 +6280,7 @@ static int vboxDomainHasCurrentSnapshot(virDomainPtr dom, virCheckFlags(0, -1); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot); @@ -6359,7 +6321,7 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, virCheckFlags(0, NULL); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name))) @@ -6421,7 +6383,7 @@ vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags) virCheckFlags(0, NULL); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot); @@ -6480,7 +6442,7 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, virCheckFlags(0, -1); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name))) @@ -6537,7 +6499,7 @@ static int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, virCheckFlags(0, -1); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; /* Check that snapshot exists. If so, there is no metadata. */ @@ -6572,7 +6534,7 @@ static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, virCheckFlags(0, -1); - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; newSnapshot = vboxDomainSnapshotGet(data, dom, machine, snapshot->name); @@ -6766,7 +6728,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) goto cleanup; } - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; rc = gVBoxAPI.UIMachine.GetSettingsFilePath(machine, &settingsFilePathUtf16); if (NS_FAILED(rc)) { @@ -7174,7 +7136,7 @@ static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1); - if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0) goto cleanup; snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name); @@ -7259,15 +7221,9 @@ vboxDomainScreenshot(virDomainPtr dom, if (!data->vboxObj) return ret; - if (!gVBoxAPI.supportScreenshot) { - virReportError(VIR_ERR_NO_SUPPORT, "%s", - _("virDomainScreenshot don't support for current vbox version")); - return NULL; - } - virCheckFlags(0, NULL); - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) return NULL; rc = gVBoxAPI.UIMachine.GetMonitorCount(machine, &max_screen); @@ -7714,7 +7670,7 @@ vboxDomainSendKey(virDomainPtr dom, keyUpCodes[i] = keyDownCodes[i] + 0x80; } - if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0) + if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0) goto cleanup; rc = gVBoxAPI.UISession.OpenExisting(data, &iid, machine); @@ -7857,6 +7813,7 @@ virHypervisorDriver vboxCommonDriver = { .nodeAllocPages = vboxNodeAllocPages, /* 1.2.9 */ .domainHasManagedSaveImage = vboxDomainHasManagedSaveImage, /* 1.2.13 */ .domainSendKey = vboxDomainSendKey, /* 1.2.15 */ + .domainScreenshot = vboxDomainScreenshot, /* 0.9.2 */ }; static void updateDriver(void) @@ -7865,10 +7822,6 @@ static void updateDriver(void) * We need to make sure the vboxUniformedAPI is initialized * before calling this function. */ gVBoxAPI.registerDomainEvent(&vboxCommonDriver); - if (gVBoxAPI.supportScreenshot) - vboxCommonDriver.domainScreenshot = vboxDomainScreenshot; - else - vboxCommonDriver.domainScreenshot = NULL; } virHypervisorDriverPtr vboxGetHypervisorDriver(uint32_t uVersion) diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 6c92a3c..8ac7e1d 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -568,14 +568,12 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) VBOX_IID_INITIALIZE(&machineId); vboxIIDFromArrayItem(&machineId, &machineIds, i); - if (gVBoxAPI.getMachineForSession) { - if (NS_FAILED(gVBoxAPI.UIVirtualBox.GetMachine(data->vboxObj, - &machineId, - &machine))) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); - break; - } + if (NS_FAILED(gVBoxAPI.UIVirtualBox.GetMachine(data->vboxObj, + &machineId, + &machine))) { + virReportError(VIR_ERR_NO_DOMAIN, "%s", + _("no domain with matching uuid")); + break; } if (NS_FAILED(gVBoxAPI.UISession.Open(data, &machineId, machine))) { diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 55adf6d..0eacfe3 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -3352,17 +3352,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->domainEventCallbacks = 1; #endif /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */ -#if VBOX_API_VERSION >= 4000000 - /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */ - pVBoxAPI->getMachineForSession = 1; - pVBoxAPI->detachDevicesExplicitly = 0; - pVBoxAPI->supportScreenshot = 1; -#else /* VBOX_API_VERSION < 4000000 */ - pVBoxAPI->getMachineForSession = 0; - pVBoxAPI->detachDevicesExplicitly = 1; - pVBoxAPI->supportScreenshot = 0; -#endif /* VBOX_API_VERSION < 4000000 */ - #if VBOX_API_VERSION >= 4001000 pVBoxAPI->chipsetType = 1; #else /* VBOX_API_VERSION < 4001000 */ diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 3892aae..abb8486 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -594,13 +594,10 @@ typedef struct { uniformedMachineStateChecker machineStateChecker; /* vbox API features */ bool domainEventCallbacks; - bool getMachineForSession; - bool detachDevicesExplicitly; bool chipsetType; bool accelerate2DVideo; bool oldMediumInterface; bool vboxSnapshotRedefine; - bool supportScreenshot; bool networkRemoveInterface; } vboxUniformedAPI; -- 2.9.3

this was implemented only for vbox 3 series and was mostly stubs anyway. --- src/vbox/vbox_common.c | 20 -- src/vbox/vbox_tmpl.c | 648 ------------------------------------------ src/vbox/vbox_uniformed_api.h | 22 +- 3 files changed, 2 insertions(+), 688 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index f2ac7f9..c1c7997 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -111,8 +111,6 @@ vboxDriverDispose(void *obj) virObjectUnref(driver->caps); virObjectUnref(driver->xmlopt); - if (gVBoxAPI.domainEventCallbacks) - virObjectUnref(driver->domainEventState); } static int @@ -145,10 +143,6 @@ vboxDriverObjNew(void) NULL, NULL))) goto cleanup; - if (gVBoxAPI.domainEventCallbacks && - !(driver->domainEventState = virObjectEventStateNew())) - goto cleanup; - return driver; cleanup: @@ -199,10 +193,6 @@ vboxSdkInitialize(void) if (gVBoxAPI.UPFN.Initialize(vbox_driver) != 0) return -1; - if (gVBoxAPI.domainEventCallbacks && - gVBoxAPI.initializeDomainEvent(vbox_driver) != 0) - return -1; - if (vbox_driver->vboxObj == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("IVirtualBox object is null")); @@ -7816,14 +7806,6 @@ virHypervisorDriver vboxCommonDriver = { .domainScreenshot = vboxDomainScreenshot, /* 0.9.2 */ }; -static void updateDriver(void) -{ - /* Update the vboxDriver according to the vboxUniformedAPI. - * We need to make sure the vboxUniformedAPI is initialized - * before calling this function. */ - gVBoxAPI.registerDomainEvent(&vboxCommonDriver); -} - virHypervisorDriverPtr vboxGetHypervisorDriver(uint32_t uVersion) { /* Install gVBoxAPI according to the vbox API version. */ @@ -7835,7 +7817,5 @@ virHypervisorDriverPtr vboxGetHypervisorDriver(uint32_t uVersion) return NULL; } - updateDriver(); - return &vboxCommonDriver; } diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 0eacfe3..fecd54f 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -413,646 +413,6 @@ _vboxDomainSnapshotRestore(virDomainPtr dom, return ret; } -#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 - /* No Callback support for VirtualBox 2.2.* series */ - /* No Callback support for VirtualBox 4.* series */ - -static void -_registerDomainEvent(virHypervisorDriverPtr driver) -{ - driver->connectDomainEventRegister = NULL; - driver->connectDomainEventDeregister = NULL; - driver->connectDomainEventRegisterAny = NULL; - driver->connectDomainEventDeregisterAny = NULL; -} - -#else /* !(VBOX_API_VERSION == 2002000 || VBOX_API_VERSION >= 4000000) */ - -/* Functions needed for Callbacks */ -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; - - virObjectLock(data); - - VIR_DEBUG("IVirtualBoxCallback: %p, State: %d", callback, state); - DEBUGPRUnichar("machineId", machineId); - - if (machineId) { - char *machineIdUtf8 = NULL; - unsigned char uuid[VIR_UUID_BUFLEN]; - - data->pFuncs->pfnUtf16ToUtf8(machineId, &machineIdUtf8); - ignore_value(virUUIDParse(machineIdUtf8, uuid)); - - dom = vboxDomainLookupByUUID(callback->conn, uuid); - if (dom) { - virObjectEventPtr ev; - - if (state == MachineState_Starting) { - event = VIR_DOMAIN_EVENT_STARTED; - detail = VIR_DOMAIN_EVENT_STARTED_BOOTED; - } else if (state == MachineState_Restoring) { - event = VIR_DOMAIN_EVENT_STARTED; - detail = VIR_DOMAIN_EVENT_STARTED_RESTORED; - } else if (state == MachineState_Paused) { - event = VIR_DOMAIN_EVENT_SUSPENDED; - detail = VIR_DOMAIN_EVENT_SUSPENDED_PAUSED; - } else if (state == MachineState_Running) { - event = VIR_DOMAIN_EVENT_RESUMED; - detail = VIR_DOMAIN_EVENT_RESUMED_UNPAUSED; - } else if (state == MachineState_PoweredOff) { - event = VIR_DOMAIN_EVENT_STOPPED; - detail = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN; - } else if (state == MachineState_Stopping) { - event = VIR_DOMAIN_EVENT_STOPPED; - detail = VIR_DOMAIN_EVENT_STOPPED_DESTROYED; - } else if (state == MachineState_Aborted) { - event = VIR_DOMAIN_EVENT_STOPPED; - detail = VIR_DOMAIN_EVENT_STOPPED_CRASHED; - } else if (state == MachineState_Saving) { - event = VIR_DOMAIN_EVENT_STOPPED; - detail = VIR_DOMAIN_EVENT_STOPPED_SAVED; - } else { - event = VIR_DOMAIN_EVENT_STOPPED; - detail = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN; - } - - ev = virDomainEventLifecycleNewFromDom(dom, event, detail); - - if (ev) - virObjectEventStateQueue(data->domainEventState, ev); - } - } - - virObjectUnlock(data); - - return NS_OK; -} - -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); - - return NS_OK; -} - -static nsresult PR_COM_METHOD -vboxCallbackOnExtraDataCanChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, - PRUnichar *machineId, PRUnichar *key, - PRUnichar *value, - 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); - DEBUGPRUnichar("value", value); - - return NS_OK; -} - -static nsresult PR_COM_METHOD -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); - DEBUGPRUnichar("value", value); - - return NS_OK; -} - -# if VBOX_API_VERSION < 3001000 -static nsresult PR_COM_METHOD -vboxCallbackOnMediaRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED, - PRUnichar *mediaId, - 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; -} -# 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; - - virObjectLock(data); - - VIR_DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false"); - DEBUGPRUnichar("machineId", machineId); - - if (machineId) { - char *machineIdUtf8 = NULL; - unsigned char uuid[VIR_UUID_BUFLEN]; - - data->pFuncs->pfnUtf16ToUtf8(machineId, &machineIdUtf8); - ignore_value(virUUIDParse(machineIdUtf8, uuid)); - - dom = vboxDomainLookupByUUID(callback->conn, uuid); - if (dom) { - virObjectEventPtr ev; - - /* CURRENT LIMITATION: we never get the VIR_DOMAIN_EVENT_UNDEFINED - * event because the when the machine is de-registered the call - * to vboxDomainLookupByUUID fails and thus we don't get any - * dom pointer which is necessary (null dom pointer doesn't work) - * to show the VIR_DOMAIN_EVENT_UNDEFINED event - */ - if (registered) { - event = VIR_DOMAIN_EVENT_DEFINED; - detail = VIR_DOMAIN_EVENT_DEFINED_ADDED; - } else { - event = VIR_DOMAIN_EVENT_UNDEFINED; - detail = VIR_DOMAIN_EVENT_UNDEFINED_REMOVED; - } - - ev = virDomainEventLifecycleNewFromDom(dom, event, detail); - - if (ev) - virObjectEventStateQueue(data->domainEventState, ev); - } - } - - virObjectUnlock(data); - - return NS_OK; -} - -static nsresult PR_COM_METHOD -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); - - return NS_OK; -} - -static nsresult PR_COM_METHOD -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); - - return NS_OK; -} - -static nsresult PR_COM_METHOD -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); - - return NS_OK; -} - -static nsresult PR_COM_METHOD -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); - - return NS_OK; -} - -static nsresult PR_COM_METHOD -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); - DEBUGPRUnichar("value", value); - DEBUGPRUnichar("flags", flags); - - return NS_OK; -} - -static nsresult PR_COM_METHOD -vboxCallbackAddRef(nsISupports *pThis ATTRIBUTE_UNUSED) -{ - vboxCallbackPtr callback = (vboxCallbackPtr) pThis; - nsresult c; - - c = ++callback->vboxCallBackRefCount; - - VIR_DEBUG("pThis: %p, vboxCallback AddRef: %d", pThis, c); - - return c; -} - -static nsresult PR_COM_METHOD -vboxCallbackRelease(nsISupports *pThis) -{ - vboxCallbackPtr callback = (vboxCallbackPtr) pThis; - nsresult c; - - c = --callback->vboxCallBackRefCount; - if (c == 0) { - /* delete object */ - VIR_FREE(pThis->vtbl); - VIR_FREE(pThis); - } - - VIR_DEBUG("pThis: %p, vboxCallback Release: %d", pThis, c); - - return c; -} - -static nsresult PR_COM_METHOD -vboxCallbackQueryInterface(nsISupports *pThis, const nsID *iid, void **resultp) -{ - 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) { - callback->vboxCallBackRefCount++; - *resultp = callback; - - VIR_DEBUG("pThis: %p, vboxCallback QueryInterface: %d", pThis, callback->vboxCallBackRefCount); - - return NS_OK; - } - - - VIR_DEBUG("pThis: %p, vboxCallback QueryInterface didn't find a matching interface", pThis); - DEBUGUUID("The UUID Callback Interface expects", iid); - DEBUGUUID("The UUID Callback Interface got", &ivirtualboxCallbackUUID); - return NS_NOINTERFACE; -} - - -static vboxCallbackPtr -vboxAllocCallbackObj(virConnectPtr conn) -{ - vboxCallbackPtr callback = NULL; - - /* Allocate, Initialize and return a valid - * IVirtualBoxCallback object here - */ - if ((VIR_ALLOC(callback) < 0) || (VIR_ALLOC(callback->vtbl) < 0)) { - VIR_FREE(callback); - return NULL; - } - - { - 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 - callback->vtbl->OnMediaRegistered = &vboxCallbackOnMediaRegistered; -# else /* VBOX_API_VERSION >= 3001000 */ -# endif /* VBOX_API_VERSION >= 3001000 */ - callback->vtbl->OnMachineRegistered = &vboxCallbackOnMachineRegistered; - callback->vtbl->OnSessionStateChange = &vboxCallbackOnSessionStateChange; - callback->vtbl->OnSnapshotTaken = &vboxCallbackOnSnapshotTaken; -# if VBOX_API_VERSION < 3002000 - callback->vtbl->OnSnapshotDiscarded = &vboxCallbackOnSnapshotDiscarded; -# else /* VBOX_API_VERSION >= 3002000 */ - callback->vtbl->OnSnapshotDeleted = &vboxCallbackOnSnapshotDiscarded; -# endif /* VBOX_API_VERSION >= 3002000 */ - callback->vtbl->OnSnapshotChange = &vboxCallbackOnSnapshotChange; - callback->vtbl->OnGuestPropertyChange = &vboxCallbackOnGuestPropertyChange; - callback->vboxCallBackRefCount = 1; - } - - callback->conn = conn; - - return callback; -} - -static void vboxReadCallback(int watch ATTRIBUTE_UNUSED, - int fd, - int events ATTRIBUTE_UNUSED, - void *opaque) -{ - vboxDriverPtr data = (vboxDriverPtr) opaque; - if (fd >= 0) { - data->vboxQueue->vtbl->ProcessPendingEvents(data->vboxQueue); - } else { - nsresult rc; - PLEvent *pEvent = NULL; - - rc = data->vboxQueue->vtbl->WaitForEvent(data->vboxQueue, &pEvent); - if (NS_SUCCEEDED(rc)) - data->vboxQueue->vtbl->HandleEvent(data->vboxQueue, pEvent); - } -} - -static int -vboxConnectDomainEventRegister(virConnectPtr conn, - virConnectDomainEventCallback callback, - void *opaque, - virFreeCallback freecb) -{ - vboxDriverPtr data = conn->privateData; - int vboxRet = -1; - nsresult rc; - int ret = -1; - - if (!data->vboxObj) - return ret; - - /* Locking has to be there as callbacks are not - * really fully thread safe - */ - virObjectLock(data); - - if (data->vboxCallback == NULL) { - data->vboxCallback = vboxAllocCallbackObj(conn); - if (data->vboxCallback != NULL) { - rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, - (IVirtualBoxCallback *) data->vboxCallback); - if (NS_SUCCEEDED(rc)) - vboxRet = 0; - } - } else { - vboxRet = 0; - } - - /* Get the vbox file handle and add an event handle to it - * so that the events can be passed down to the user - */ - if (vboxRet == 0) { - if (data->fdWatch < 0) { - PRInt32 vboxFileHandle; - vboxFileHandle = data->vboxQueue->vtbl->GetEventQueueSelectFD(data->vboxQueue); - - data->fdWatch = virEventAddHandle(vboxFileHandle, VIR_EVENT_HANDLE_READABLE, vboxReadCallback, data, NULL); - } - - if (data->fdWatch >= 0) { - /* Once a callback is registered with virtualbox, use a list - * to store the callbacks registered with libvirt so that - * later you can iterate over them - */ - - ret = virDomainEventStateRegister(conn, data->domainEventState, - callback, opaque, freecb); - VIR_DEBUG("virObjectEventStateRegister (ret = %d) (conn: %p, " - "callback: %p, opaque: %p, " - "freecb: %p)", ret, conn, callback, - opaque, freecb); - } - } - - virObjectUnlock(data); - - if (ret >= 0) { - return 0; - } else { - if (data->vboxObj && data->vboxCallback) - data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, - (IVirtualBoxCallback *) data->vboxCallback); - return -1; - } -} - -static int -vboxConnectDomainEventDeregister(virConnectPtr conn, - virConnectDomainEventCallback callback) -{ - vboxDriverPtr data = conn->privateData; - int cnt; - int ret = -1; - - if (!data->vboxObj) - return ret; - - /* Locking has to be there as callbacks are not - * really fully thread safe - */ - virObjectLock(data); - - cnt = virDomainEventStateDeregister(conn, data->domainEventState, - callback); - - if (data->vboxCallback && cnt == 0) { - 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 */ - virEventRemoveHandle(data->fdWatch); - data->fdWatch = -1; - } - - virObjectUnlock(data); - - if (cnt >= 0) - ret = 0; - - return ret; -} - -static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, - virDomainPtr dom, - int eventID, - virConnectDomainEventGenericCallback callback, - void *opaque, - virFreeCallback freecb) -{ - vboxDriverPtr data = conn->privateData; - int vboxRet = -1; - nsresult rc; - int ret = -1; - - if (!data->vboxObj) - return ret; - - /* Locking has to be there as callbacks are not - * really fully thread safe - */ - virObjectLock(data); - - if (data->vboxCallback == NULL) { - data->vboxCallback = vboxAllocCallbackObj(conn); - if (data->vboxCallback != NULL) { - rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, - (IVirtualBoxCallback *) data->vboxCallback); - if (NS_SUCCEEDED(rc)) - vboxRet = 0; - } - } else { - vboxRet = 0; - } - - /* Get the vbox file handle and add an event handle to it - * so that the events can be passed down to the user - */ - if (vboxRet == 0) { - if (data->fdWatch < 0) { - PRInt32 vboxFileHandle; - vboxFileHandle = data->vboxQueue->vtbl->GetEventQueueSelectFD(data->vboxQueue); - - data->fdWatch = virEventAddHandle(vboxFileHandle, VIR_EVENT_HANDLE_READABLE, vboxReadCallback, data, NULL); - } - - if (data->fdWatch >= 0) { - /* Once a callback is registered with virtualbox, use a list - * to store the callbacks registered with libvirt so that - * later you can iterate over them - */ - - if (virDomainEventStateRegisterID(conn, data->domainEventState, - dom, eventID, - callback, opaque, freecb, &ret) < 0) - ret = -1; - VIR_DEBUG("virDomainEventStateRegisterID (ret = %d) (conn: %p, " - "callback: %p, opaque: %p, " - "freecb: %p)", ret, conn, callback, - opaque, freecb); - } - } - - virObjectUnlock(data); - - if (ret >= 0) { - return ret; - } else { - if (data->vboxObj && data->vboxCallback) - data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, - (IVirtualBoxCallback *) data->vboxCallback); - return -1; - } -} - -static int -vboxConnectDomainEventDeregisterAny(virConnectPtr conn, - int callbackID) -{ - vboxDriverPtr data = conn->privateData; - int cnt; - int ret = -1; - - if (!data->vboxObj) - return ret; - - /* Locking has to be there as callbacks are not - * really fully thread safe - */ - virObjectLock(data); - - cnt = virObjectEventStateDeregisterID(conn, data->domainEventState, - callbackID); - - if (data->vboxCallback && cnt == 0) { - 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 */ - virEventRemoveHandle(data->fdWatch); - data->fdWatch = -1; - } - - virObjectUnlock(data); - - if (cnt >= 0) - ret = 0; - - return ret; -} - -static void -_registerDomainEvent(virHypervisorDriverPtr driver) -{ - driver->connectDomainEventRegister = vboxConnectDomainEventRegister; /* 0.7.0 */ - driver->connectDomainEventDeregister = vboxConnectDomainEventDeregister; /* 0.7.0 */ - driver->connectDomainEventRegisterAny = vboxConnectDomainEventRegisterAny; /* 0.8.0 */ - driver->connectDomainEventDeregisterAny = vboxConnectDomainEventDeregisterAny; /* 0.8.0 */ -} - -#endif /* !(VBOX_API_VERSION == 2002000 || VBOX_API_VERSION >= 4000000) */ - -static int -_initializeDomainEvent(vboxDriverPtr data ATTRIBUTE_UNUSED) -{ -#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 - /* No event queue functionality in 2.2.* and 4.* as of now */ - vboxUnsupported(); -#else /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */ - /* Initialize the fWatch needed for Event Callbacks */ - data->fdWatch = -1; - data->pFuncs->pfnGetEventQueue(&data->vboxQueue); - if (data->vboxQueue == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("nsIEventQueue object is null")); - return -1; - } -#endif /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */ - return 0; -} - static void _detachDevices(vboxDriverPtr data ATTRIBUTE_UNUSED, IMachine *machine ATTRIBUTE_UNUSED, @@ -3302,7 +2662,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) { pVBoxAPI->APIVersion = VBOX_API_VERSION; pVBoxAPI->XPCOMCVersion = VBOX_XPCOMC_VERSION; - pVBoxAPI->initializeDomainEvent = _initializeDomainEvent; pVBoxAPI->detachDevices = _detachDevices; pVBoxAPI->unregisterMachine = _unregisterMachine; pVBoxAPI->deleteConfig = _deleteConfig; @@ -3315,7 +2674,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->attachFloppy = _attachFloppy; pVBoxAPI->detachFloppy = _detachFloppy; pVBoxAPI->snapshotRestore = _vboxDomainSnapshotRestore; - pVBoxAPI->registerDomainEvent = _registerDomainEvent; pVBoxAPI->UPFN = _UPFN; pVBoxAPI->UIID = _UIID; pVBoxAPI->UArray = _UArray; @@ -3346,12 +2704,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->UIKeyboard = _UIKeyboard; pVBoxAPI->machineStateChecker = _machineStateChecker; -#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 - pVBoxAPI->domainEventCallbacks = 0; -#else /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */ - pVBoxAPI->domainEventCallbacks = 1; -#endif /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */ - #if VBOX_API_VERSION >= 4001000 pVBoxAPI->chipsetType = 1; #else /* VBOX_API_VERSION < 4001000 */ diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index abb8486..9c9aff9 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -27,7 +27,7 @@ * * The vbox_tmpl.c is the only place where the driver knows the inside * architecture of those vbox structs(vboxObj, vboxSession, - * pFuncs, vboxCallback and vboxQueue). The file should be included + * pFuncs, and vboxCallback). The file should be included * after the currect vbox_CAPI_v*.h, then we can use the vbox structs * in vboxGlobalData. The vbox_tmpl.c should implement functions * defined in vboxUniformedAPI. @@ -36,7 +36,7 @@ * The vbox_driver.c collects vboxUniformedAPI for all versions. * Then vboxRegister calls the vboxRegisterUniformedAPI to register. * Note: In vbox_driver.c, the vbox structs in vboxGlobalData is - * defined by vbox_CAPI_v2.2.h. + * defined by vbox_CAPI_v4_0.h. * * The vbox_common.c, it is used to generate common codes for all vbox * versions. Bacause the same member varible's offset in a vbox struct @@ -96,14 +96,6 @@ typedef union { PRInt32 resultCode; } resultCodeUnion; -struct _vboxCallback { - struct IVirtualBoxCallback_vtbl *vtbl; - virConnectPtr conn; - int vboxCallBackRefCount; -}; - -typedef struct _vboxCallback vboxCallback; -typedef struct _vboxCallback *vboxCallbackPtr; struct _vboxDriver { virObjectLockable parent; @@ -120,13 +112,6 @@ struct _vboxDriver { IVirtualBoxClient *vboxClient; # endif - int fdWatch; - vboxCallbackPtr vboxCallback; -# if VBOX_API_VERSION > 2002000 && VBOX_API_VERSION < 4000000 - nsIEventQueue *vboxQueue; -# else - void *vboxQueue; -# endif unsigned long version; /* reference counting of vbox connections */ @@ -548,7 +533,6 @@ typedef struct { uint32_t APIVersion; uint32_t XPCOMCVersion; /* vbox APIs */ - int (*initializeDomainEvent)(vboxDriverPtr driver); void (*detachDevices)(vboxDriverPtr driver, IMachine *machine, PRUnichar *hddcnameUtf16); nsresult (*unregisterMachine)(vboxDriverPtr driver, vboxIIDUnion *iidu, IMachine **machine); void (*deleteConfig)(IMachine *machine); @@ -562,7 +546,6 @@ typedef struct { 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); vboxUniformedPFN UPFN; vboxUniformedIID UIID; vboxUniformedArray UArray; @@ -593,7 +576,6 @@ typedef struct { vboxUniformedIKeyboard UIKeyboard; uniformedMachineStateChecker machineStateChecker; /* vbox API features */ - bool domainEventCallbacks; bool chipsetType; bool accelerate2DVideo; bool oldMediumInterface; -- 2.9.3

* removed oldMediumInterface flag and related code that was used for vbox 2.x * remove accelerate2DVideo and networkRemoveInterface flags which were also conditionals for handling legacy vbox versions. --- src/vbox/vbox_common.c | 66 ++++-------------------------- src/vbox/vbox_network.c | 2 +- src/vbox/vbox_tmpl.c | 94 ++----------------------------------------- src/vbox/vbox_uniformed_api.h | 11 ----- 4 files changed, 13 insertions(+), 160 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index c1c7997..6309a17 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1563,15 +1563,13 @@ vboxAttachVideo(virDomainDefPtr def, IMachine *machine) gVBoxAPI.UIMachine.SetAccelerate3DEnabled(machine, def->videos[0]->accel->accel3d == VIR_TRISTATE_BOOL_YES); } - if (def->videos[0]->accel->accel2d && - gVBoxAPI.accelerate2DVideo) { + if (def->videos[0]->accel->accel2d) { gVBoxAPI.UIMachine.SetAccelerate2DVideoEnabled(machine, def->videos[0]->accel->accel2d == VIR_TRISTATE_BOOL_YES); } } else { gVBoxAPI.UIMachine.SetAccelerate3DEnabled(machine, 0); - if (gVBoxAPI.accelerate2DVideo) - gVBoxAPI.UIMachine.SetAccelerate2DVideoEnabled(machine, 0); + gVBoxAPI.UIMachine.SetAccelerate2DVideoEnabled(machine, 0); } } } @@ -3063,7 +3061,7 @@ vboxHostDeviceGetXMLDesc(vboxDriverPtr data, virDomainDefPtr def, IMachine *mach } static void -vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) +vboxDumpIDEHDDs(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { /* dump IDE hdds if present */ vboxArray mediumAttachments = VBOX_ARRAY_INITIALIZER; @@ -3073,9 +3071,6 @@ vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) PRUint32 maxPortPerInst[StorageBus_Floppy + 1] = {}; PRUint32 maxSlotPerPort[StorageBus_Floppy + 1] = {}; - if (gVBoxAPI.oldMediumInterface) - VIR_WARN("This function may not work in current vbox version"); - def->ndisks = 0; gVBoxAPI.UArray.vboxArrayGet(&mediumAttachments, machine, gVBoxAPI.UArray.handleMachineGetMediumAttachments(machine)); @@ -3245,8 +3240,7 @@ vboxDumpVideo(virDomainDefPtr def, vboxDriverPtr data ATTRIBUTE_UNUSED, gVBoxAPI.UIMachine.GetVRAMSize(machine, &VRAMSize); gVBoxAPI.UIMachine.GetMonitorCount(machine, &monitorCount); gVBoxAPI.UIMachine.GetAccelerate3DEnabled(machine, &accelerate3DEnabled); - if (gVBoxAPI.accelerate2DVideo) - gVBoxAPI.UIMachine.GetAccelerate2DVideoEnabled(machine, &accelerate2DEnabled); + gVBoxAPI.UIMachine.GetAccelerate2DVideoEnabled(machine, &accelerate2DEnabled); def->videos[0]->type = VIR_DOMAIN_VIDEO_TYPE_VBOX; def->videos[0]->vram = VRAMSize * 1024; @@ -3914,26 +3908,11 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) if (vboxDumpDisplay(def, data, machine) < 0) goto cleanup; - /* As the medium interface changed from 3.0 to 3.1. - * There are two totally different implementations. - * The old one would be version specified, while the - * new one is using the vboxUniformedAPI and be put - * into the common code. - */ - if (gVBoxAPI.oldMediumInterface) - gVBoxAPI.dumpIDEHDDsOld(def, data, machine); - else - vboxDumpIDEHDDsNew(def, data, machine); + vboxDumpIDEHDDs(def, data, machine); vboxDumpSharedFolders(def, data, machine); vboxDumpNetwork(def, data, machine, networkAdapterCount); vboxDumpAudio(def, data, machine); - - if (gVBoxAPI.oldMediumInterface) { - gVBoxAPI.dumpDVD(def, data, machine); - gVBoxAPI.dumpFloppy(def, data, machine); - } - vboxDumpSerial(def, data, machine, serialPortCount); vboxDumpParallel(def, data, machine, parallelPortCount); @@ -4106,20 +4085,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, if (NS_SUCCEEDED(rc) && machine) { /* ret = -VIR_ERR_ARGUMENT_UNSUPPORTED means the current device don't support hotplug. */ ret = -VIR_ERR_ARGUMENT_UNSUPPORTED; - if (dev->type == VIR_DOMAIN_DEVICE_DISK) { - if (gVBoxAPI.oldMediumInterface) { - const char *src = virDomainDiskGetSource(dev->data.disk); - int type = virDomainDiskGetType(dev->data.disk); - - if (dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM && - type == VIR_STORAGE_TYPE_FILE && src) - ret = gVBoxAPI.attachDVD(data, machine, src); - else if (dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && - type == VIR_STORAGE_TYPE_FILE && src) - ret = gVBoxAPI.attachFloppy(data, machine, src); - } - } else if (dev->type == VIR_DOMAIN_DEVICE_FS && - dev->data.fs->type == VIR_DOMAIN_FS_TYPE_MOUNT) { + if (dev->type == VIR_DOMAIN_DEVICE_FS && + dev->data.fs->type == VIR_DOMAIN_FS_TYPE_MOUNT) { PRUnichar *nameUtf16; PRUnichar *hostPathUtf16; PRBool writable; @@ -4237,24 +4204,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) if (NS_SUCCEEDED(rc) && machine) { /* ret = -VIR_ERR_ARGUMENT_UNSUPPORTED means the current device don't support hotplug. */ ret = -VIR_ERR_ARGUMENT_UNSUPPORTED; - if (dev->type == VIR_DOMAIN_DEVICE_DISK) { - if (gVBoxAPI.oldMediumInterface) { - int type = virDomainDiskGetType(dev->data.disk); - - if (dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { - if (type == VIR_STORAGE_TYPE_FILE) { - ret = gVBoxAPI.detachDVD(machine); - } else if (type == VIR_STORAGE_TYPE_BLOCK) { - } - } else if (dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - if (type == VIR_STORAGE_TYPE_FILE) { - ret = gVBoxAPI.detachFloppy(machine); - } else if (type == VIR_STORAGE_TYPE_BLOCK) { - } - } - } - } else if (dev->type == VIR_DOMAIN_DEVICE_NET) { - } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { + if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { if (dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { if (dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { } diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 0884b74..f004ec1 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -603,7 +603,7 @@ vboxNetworkUndefineDestroy(virNetworkPtr network, bool removeinterface) if (interfaceType != HostNetworkInterfaceType_HostOnly) goto cleanup; - if (gVBoxAPI.networkRemoveInterface && removeinterface) { + if (removeinterface) { vboxIIDUnion iid; IProgress *progress = NULL; nsresult rc; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index fecd54f..aa30f91 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -413,14 +413,6 @@ _vboxDomainSnapshotRestore(virDomainPtr dom, return ret; } -static void -_detachDevices(vboxDriverPtr data ATTRIBUTE_UNUSED, - IMachine *machine ATTRIBUTE_UNUSED, - PRUnichar *hddcnameUtf16 ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); -} - static nsresult _unregisterMachine(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine **machine) { @@ -480,62 +472,6 @@ _deleteConfig(IMachine *machine) } } -static void -_dumpIDEHDDsOld(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxDriverPtr data ATTRIBUTE_UNUSED, - IMachine *machine ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); -} - -static void -_dumpDVD(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxDriverPtr data ATTRIBUTE_UNUSED, - IMachine *machine ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); -} - -static int -_attachDVD(vboxDriverPtr data ATTRIBUTE_UNUSED, - IMachine *machine ATTRIBUTE_UNUSED, - const char *src ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} - -static int -_detachDVD(IMachine *machine ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} - -static void -_dumpFloppy(virDomainDefPtr def ATTRIBUTE_UNUSED, - vboxDriverPtr data ATTRIBUTE_UNUSED, - IMachine *machine ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); -} - -static int -_attachFloppy(vboxDriverPtr data ATTRIBUTE_UNUSED, - IMachine *machine ATTRIBUTE_UNUSED, - const char *src ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} - -static int -_detachFloppy(IMachine *machine ATTRIBUTE_UNUSED) -{ - vboxUnsupported(); - return 0; -} - static int _pfnInitialize(vboxDriverPtr driver) { if (!(driver->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION))) @@ -1095,15 +1031,15 @@ _machineSetAccelerate3DEnabled(IMachine *machine, PRBool accelerate3DEnabled) } static nsresult -_machineGetAccelerate2DVideoEnabled(IMachine *machine ATTRIBUTE_UNUSED, - PRBool *accelerate2DVideoEnabled ATTRIBUTE_UNUSED) +_machineGetAccelerate2DVideoEnabled(IMachine *machine, + PRBool *accelerate2DVideoEnabled) { return machine->vtbl->GetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled); } static nsresult -_machineSetAccelerate2DVideoEnabled(IMachine *machine ATTRIBUTE_UNUSED, - PRBool accelerate2DVideoEnabled ATTRIBUTE_UNUSED) +_machineSetAccelerate2DVideoEnabled(IMachine *machine, + PRBool accelerate2DVideoEnabled) { return machine->vtbl->SetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled); } @@ -2662,17 +2598,9 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) { pVBoxAPI->APIVersion = VBOX_API_VERSION; pVBoxAPI->XPCOMCVersion = VBOX_XPCOMC_VERSION; - pVBoxAPI->detachDevices = _detachDevices; pVBoxAPI->unregisterMachine = _unregisterMachine; pVBoxAPI->deleteConfig = _deleteConfig; pVBoxAPI->vboxConvertState = _vboxConvertState; - pVBoxAPI->dumpIDEHDDsOld = _dumpIDEHDDsOld; - pVBoxAPI->dumpDVD = _dumpDVD; - pVBoxAPI->attachDVD = _attachDVD; - pVBoxAPI->detachDVD = _detachDVD; - pVBoxAPI->dumpFloppy = _dumpFloppy; - pVBoxAPI->attachFloppy = _attachFloppy; - pVBoxAPI->detachFloppy = _detachFloppy; pVBoxAPI->snapshotRestore = _vboxDomainSnapshotRestore; pVBoxAPI->UPFN = _UPFN; pVBoxAPI->UIID = _UIID; @@ -2710,23 +2638,9 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->chipsetType = 0; #endif /* VBOX_API_VERSION < 4001000 */ -#if VBOX_API_VERSION >= 3001000 - pVBoxAPI->accelerate2DVideo = 1; - pVBoxAPI->oldMediumInterface = 0; -#else /* VBOX_API_VERSION < 3001000 */ - pVBoxAPI->accelerate2DVideo = 0; - pVBoxAPI->oldMediumInterface = 1; -#endif /* VBOX_API_VERSION < 3001000 */ - #if VBOX_API_VERSION >= 4002000 pVBoxAPI->vboxSnapshotRedefine = 1; #else /* VBOX_API_VERSION < 4002000 */ pVBoxAPI->vboxSnapshotRedefine = 0; #endif /* VBOX_API_VERSION < 4002000 */ - -#if VBOX_API_VERSION == 2002000 - pVBoxAPI->networkRemoveInterface = 0; -#else /* VBOX_API_VERSION > 2002000 */ - pVBoxAPI->networkRemoveInterface = 1; -#endif /* VBOX_API_VERSION > 2002000 */ } diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 9c9aff9..f26de27 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -533,18 +533,10 @@ typedef struct { uint32_t APIVersion; uint32_t XPCOMCVersion; /* vbox APIs */ - void (*detachDevices)(vboxDriverPtr driver, IMachine *machine, PRUnichar *hddcnameUtf16); nsresult (*unregisterMachine)(vboxDriverPtr driver, vboxIIDUnion *iidu, IMachine **machine); void (*deleteConfig)(IMachine *machine); void (*vboxAttachDrivesOld)(virDomainDefPtr def, vboxDriverPtr driver, IMachine *machine); virDomainState (*vboxConvertState)(PRUint32 state); - 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, 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); vboxUniformedPFN UPFN; vboxUniformedIID UIID; @@ -577,10 +569,7 @@ typedef struct { uniformedMachineStateChecker machineStateChecker; /* vbox API features */ bool chipsetType; - bool accelerate2DVideo; - bool oldMediumInterface; bool vboxSnapshotRedefine; - bool networkRemoveInterface; } vboxUniformedAPI; virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, -- 2.9.3

The IVRDxServer was used because vbox < 4 used to have IVRDPServer whereas vbox >= 4 has IVRDEServer. Now that support for legacy versions is being removed, we can use IVRDEServer. --- src/vbox/vbox_common.c | 36 +++++++++---------- src/vbox/vbox_common.h | 2 +- src/vbox/vbox_tmpl.c | 80 +++++++++++++++++++++---------------------- src/vbox/vbox_uniformed_api.h | 28 +++++++-------- 4 files changed, 72 insertions(+), 74 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 6309a17..8bdf3bb 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1586,27 +1586,27 @@ vboxAttachDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) virDomainGraphicsListenDefPtr glisten; for (i = 0; i < def->ngraphics; i++) { - IVRDxServer *VRDxServer = NULL; + IVRDEServer *VRDEServer = NULL; if ((def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) && (vrdpPresent == 0)) { vrdpPresent = 1; - gVBoxAPI.UIMachine.GetVRDxServer(machine, &VRDxServer); - if (VRDxServer) { - gVBoxAPI.UIVRDxServer.SetEnabled(VRDxServer, PR_TRUE); + gVBoxAPI.UIMachine.GetVRDEServer(machine, &VRDEServer); + if (VRDEServer) { + gVBoxAPI.UIVRDEServer.SetEnabled(VRDEServer, PR_TRUE); VIR_DEBUG("VRDP Support turned ON."); - gVBoxAPI.UIVRDxServer.SetPorts(data, VRDxServer, def->graphics[i]); + gVBoxAPI.UIVRDEServer.SetPorts(data, VRDEServer, def->graphics[i]); if (def->graphics[i]->data.rdp.replaceUser) { - gVBoxAPI.UIVRDxServer.SetReuseSingleConnection(VRDxServer, + gVBoxAPI.UIVRDEServer.SetReuseSingleConnection(VRDEServer, PR_TRUE); VIR_DEBUG("VRDP set to reuse single connection"); } if (def->graphics[i]->data.rdp.multiUser) { - gVBoxAPI.UIVRDxServer.SetAllowMultiConnection(VRDxServer, + gVBoxAPI.UIVRDEServer.SetAllowMultiConnection(VRDEServer, PR_TRUE); VIR_DEBUG("VRDP set to allow multiple connection"); } @@ -1616,7 +1616,7 @@ vboxAttachDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) PRUnichar *netAddressUtf16 = NULL; VBOX_UTF8_TO_UTF16(glisten->address, &netAddressUtf16); - gVBoxAPI.UIVRDxServer.SetNetAddress(data, VRDxServer, + gVBoxAPI.UIVRDEServer.SetNetAddress(data, VRDEServer, netAddressUtf16); VIR_DEBUG("VRDP listen address is set to: %s", glisten->address); @@ -1624,7 +1624,7 @@ vboxAttachDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) VBOX_UTF16_FREE(netAddressUtf16); } - VBOX_RELEASE(VRDxServer); + VBOX_RELEASE(VRDEServer); } } @@ -3263,7 +3263,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) PRUnichar *valueTypeUtf16 = NULL; char *valueTypeUtf8 = NULL; char *netAddressUtf8 = NULL; - IVRDxServer *VRDxServer = NULL; + IVRDEServer *VRDEServer = NULL; PRBool VRDxEnabled = PR_FALSE; virDomainGraphicsDefPtr graphics = NULL; int ret = -1; @@ -3325,9 +3325,9 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < 0) goto cleanup; - gVBoxAPI.UIMachine.GetVRDxServer(machine, &VRDxServer); - if (VRDxServer) - gVBoxAPI.UIVRDxServer.GetEnabled(VRDxServer, &VRDxEnabled); + gVBoxAPI.UIMachine.GetVRDEServer(machine, &VRDEServer); + if (VRDEServer) + gVBoxAPI.UIVRDEServer.GetEnabled(VRDEServer, &VRDxEnabled); if (VRDxEnabled) { PRUnichar *netAddressUtf16 = NULL; @@ -3337,11 +3337,11 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) if (VIR_ALLOC(graphics) < 0) goto cleanup; - gVBoxAPI.UIVRDxServer.GetPorts(data, VRDxServer, graphics); + gVBoxAPI.UIVRDEServer.GetPorts(data, VRDEServer, graphics); graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_RDP; - gVBoxAPI.UIVRDxServer.GetNetAddress(data, VRDxServer, &netAddressUtf16); + gVBoxAPI.UIVRDEServer.GetNetAddress(data, VRDEServer, &netAddressUtf16); if (netAddressUtf16) { VBOX_UTF16_TO_UTF8(netAddressUtf16, &netAddressUtf8); VBOX_UTF16_FREE(netAddressUtf16); @@ -3353,11 +3353,11 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) if (virDomainGraphicsListenAppendAddress(graphics, netAddressUtf8) < 0) goto cleanup; - gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection); + gVBoxAPI.UIVRDEServer.GetAllowMultiConnection(VRDEServer, &allowMultiConnection); if (allowMultiConnection) graphics->data.rdp.multiUser = true; - gVBoxAPI.UIVRDxServer.GetReuseSingleConnection(VRDxServer, &reuseSingleConnection); + gVBoxAPI.UIVRDEServer.GetReuseSingleConnection(VRDEServer, &reuseSingleConnection); if (reuseSingleConnection) graphics->data.rdp.replaceUser = true; @@ -3368,7 +3368,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) ret = 0; cleanup: - VBOX_RELEASE(VRDxServer); + VBOX_RELEASE(VRDEServer); VBOX_UTF8_FREE(valueTypeUtf8); VBOX_UTF8_FREE(netAddressUtf8); virDomainGraphicsDefFree(graphics); diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index 76f7a8e..c6da892 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -328,7 +328,7 @@ typedef nsISupports IAudioAdapter; typedef nsISupports INetworkAdapter; typedef nsISupports ISerialPort; typedef nsISupports IParallelPort; -typedef nsISupports IVRDxServer; +typedef nsISupports IVRDEServer; typedef nsISupports IUSBCommon; typedef nsISupports IUSBDeviceFilter; typedef nsISupports IMedium; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index aa30f91..5e6a919 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -72,8 +72,6 @@ /* Include this *last* or we'll get the wrong vbox_CAPI_*.h. */ #include "vbox_glue.h" -typedef IVRDEServer IVRDxServer; - #if VBOX_API_VERSION < 4003000 typedef IUSBController IUSBCommon; #else /* VBOX_API_VERSION >= 4003000 */ @@ -919,9 +917,9 @@ _machineGetParallelPort(IMachine *machine, PRUint32 slot, IParallelPort **port) } static nsresult -_machineGetVRDxServer(IMachine *machine, IVRDxServer **VRDxServer) +_machineGetVRDEServer(IMachine *machine, IVRDEServer **VRDEServer) { - return machine->vtbl->GetVRDEServer(machine, VRDxServer); + return machine->vtbl->GetVRDEServer(machine, VRDEServer); } static nsresult @@ -1607,27 +1605,27 @@ _parallelPortSetIOBase(IParallelPort *port, PRUint32 IOBase) } static nsresult -_vrdxServerGetEnabled(IVRDxServer *VRDxServer, PRBool *enabled) +_vrdeServerGetEnabled(IVRDEServer *VRDEServer, PRBool *enabled) { - return VRDxServer->vtbl->GetEnabled(VRDxServer, enabled); + return VRDEServer->vtbl->GetEnabled(VRDEServer, enabled); } static nsresult -_vrdxServerSetEnabled(IVRDxServer *VRDxServer, PRBool enabled) +_vrdeServerSetEnabled(IVRDEServer *VRDEServer, PRBool enabled) { - return VRDxServer->vtbl->SetEnabled(VRDxServer, enabled); + return VRDEServer->vtbl->SetEnabled(VRDEServer, enabled); } static nsresult -_vrdxServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, - IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) +_vrdeServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, + IVRDEServer *VRDEServer, virDomainGraphicsDefPtr graphics) { nsresult rc; PRUnichar *VRDEPortsKey = NULL; PRUnichar *VRDEPortsValue = NULL; VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey); - rc = VRDxServer->vtbl->GetVRDEProperty(VRDxServer, VRDEPortsKey, &VRDEPortsValue); + rc = VRDEServer->vtbl->GetVRDEProperty(VRDEServer, VRDEPortsKey, &VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsKey); if (VRDEPortsValue) { /* even if vbox supports mutilpe ports, single port for now here */ @@ -1641,8 +1639,8 @@ _vrdxServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, } static nsresult -_vrdxServerSetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, - IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) +_vrdeServerSetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, + IVRDEServer *VRDEServer, virDomainGraphicsDefPtr graphics) { nsresult rc = 0; PRUnichar *VRDEPortsKey = NULL; @@ -1650,7 +1648,7 @@ _vrdxServerSetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey); VRDEPortsValue = PRUnicharFromInt(data->pFuncs, graphics->data.rdp.port); - rc = VRDxServer->vtbl->SetVRDEProperty(VRDxServer, VRDEPortsKey, + rc = VRDEServer->vtbl->SetVRDEProperty(VRDEServer, VRDEPortsKey, VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsKey); VBOX_UTF16_FREE(VRDEPortsValue); @@ -1659,52 +1657,52 @@ _vrdxServerSetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, } static nsresult -_vrdxServerGetReuseSingleConnection(IVRDxServer *VRDxServer, PRBool *enabled) +_vrdeServerGetReuseSingleConnection(IVRDEServer *VRDEServer, PRBool *enabled) { - return VRDxServer->vtbl->GetReuseSingleConnection(VRDxServer, enabled); + return VRDEServer->vtbl->GetReuseSingleConnection(VRDEServer, enabled); } static nsresult -_vrdxServerSetReuseSingleConnection(IVRDxServer *VRDxServer, PRBool enabled) +_vrdeServerSetReuseSingleConnection(IVRDEServer *VRDEServer, PRBool enabled) { - return VRDxServer->vtbl->SetReuseSingleConnection(VRDxServer, enabled); + return VRDEServer->vtbl->SetReuseSingleConnection(VRDEServer, enabled); } static nsresult -_vrdxServerGetAllowMultiConnection(IVRDxServer *VRDxServer, PRBool *enabled) +_vrdeServerGetAllowMultiConnection(IVRDEServer *VRDEServer, PRBool *enabled) { - return VRDxServer->vtbl->GetAllowMultiConnection(VRDxServer, enabled); + return VRDEServer->vtbl->GetAllowMultiConnection(VRDEServer, enabled); } static nsresult -_vrdxServerSetAllowMultiConnection(IVRDxServer *VRDxServer, PRBool enabled) +_vrdeServerSetAllowMultiConnection(IVRDEServer *VRDEServer, PRBool enabled) { - return VRDxServer->vtbl->SetAllowMultiConnection(VRDxServer, enabled); + return VRDEServer->vtbl->SetAllowMultiConnection(VRDEServer, enabled); } static nsresult -_vrdxServerGetNetAddress(vboxDriverPtr data ATTRIBUTE_UNUSED, - IVRDxServer *VRDxServer, PRUnichar **netAddress) +_vrdeServerGetNetAddress(vboxDriverPtr data ATTRIBUTE_UNUSED, + IVRDEServer *VRDEServer, PRUnichar **netAddress) { PRUnichar *VRDENetAddressKey = NULL; nsresult rc; VBOX_UTF8_TO_UTF16("TCP/Address", &VRDENetAddressKey); - rc = VRDxServer->vtbl->GetVRDEProperty(VRDxServer, VRDENetAddressKey, netAddress); + rc = VRDEServer->vtbl->GetVRDEProperty(VRDEServer, VRDENetAddressKey, netAddress); VBOX_UTF16_FREE(VRDENetAddressKey); return rc; } static nsresult -_vrdxServerSetNetAddress(vboxDriverPtr data ATTRIBUTE_UNUSED, - IVRDxServer *VRDxServer, PRUnichar *netAddress) +_vrdeServerSetNetAddress(vboxDriverPtr data ATTRIBUTE_UNUSED, + IVRDEServer *VRDEServer, PRUnichar *netAddress) { PRUnichar *netAddressKey = NULL; nsresult rc; VBOX_UTF8_TO_UTF16("TCP/Address", &netAddressKey); - rc = VRDxServer->vtbl->SetVRDEProperty(VRDxServer, netAddressKey, + rc = VRDEServer->vtbl->SetVRDEProperty(VRDEServer, netAddressKey, netAddress); VBOX_UTF16_FREE(netAddressKey); @@ -2346,7 +2344,7 @@ static vboxUniformedIMachine _UIMachine = { .GetChipsetType = _machineGetChipsetType, .GetSerialPort = _machineGetSerialPort, .GetParallelPort = _machineGetParallelPort, - .GetVRDxServer = _machineGetVRDxServer, + .GetVRDEServer = _machineGetVRDEServer, .GetUSBCommon = _machineGetUSBCommon, .GetCurrentSnapshot = _machineGetCurrentSnapshot, .GetSettingsFilePath = _machineGetSettingsFilePath, @@ -2468,17 +2466,17 @@ static vboxUniformedIParallelPort _UIParallelPort = { .SetIOBase = _parallelPortSetIOBase, }; -static vboxUniformedIVRDxServer _UIVRDxServer = { - .GetEnabled = _vrdxServerGetEnabled, - .SetEnabled = _vrdxServerSetEnabled, - .GetPorts = _vrdxServerGetPorts, - .SetPorts = _vrdxServerSetPorts, - .GetReuseSingleConnection = _vrdxServerGetReuseSingleConnection, - .SetReuseSingleConnection = _vrdxServerSetReuseSingleConnection, - .GetAllowMultiConnection = _vrdxServerGetAllowMultiConnection, - .SetAllowMultiConnection = _vrdxServerSetAllowMultiConnection, - .GetNetAddress = _vrdxServerGetNetAddress, - .SetNetAddress = _vrdxServerSetNetAddress, +static vboxUniformedIVRDEServer _UIVRDEServer = { + .GetEnabled = _vrdeServerGetEnabled, + .SetEnabled = _vrdeServerSetEnabled, + .GetPorts = _vrdeServerGetPorts, + .SetPorts = _vrdeServerSetPorts, + .GetReuseSingleConnection = _vrdeServerGetReuseSingleConnection, + .SetReuseSingleConnection = _vrdeServerSetReuseSingleConnection, + .GetAllowMultiConnection = _vrdeServerGetAllowMultiConnection, + .SetAllowMultiConnection = _vrdeServerSetAllowMultiConnection, + .GetNetAddress = _vrdeServerGetNetAddress, + .SetNetAddress = _vrdeServerSetNetAddress, }; static vboxUniformedIUSBCommon _UIUSBCommon = { @@ -2617,7 +2615,7 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->UINetworkAdapter = _UINetworkAdapter; pVBoxAPI->UISerialPort = _UISerialPort; pVBoxAPI->UIParallelPort = _UIParallelPort; - pVBoxAPI->UIVRDxServer = _UIVRDxServer; + pVBoxAPI->UIVRDEServer = _UIVRDEServer; pVBoxAPI->UIUSBCommon = _UIUSBCommon; pVBoxAPI->UIUSBDeviceFilter = _UIUSBDeviceFilter; pVBoxAPI->UIMedium = _UIMedium; diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index f26de27..d1ce934 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -224,7 +224,7 @@ typedef struct { nsresult (*GetChipsetType)(IMachine *machine, PRUint32 *chipsetType); nsresult (*GetSerialPort)(IMachine *machine, PRUint32 slot, ISerialPort **port); nsresult (*GetParallelPort)(IMachine *machine, PRUint32 slot, IParallelPort **port); - nsresult (*GetVRDxServer)(IMachine *machine, IVRDxServer **VRDxServer); + nsresult (*GetVRDEServer)(IMachine *machine, IVRDEServer **VRDEServer); nsresult (*GetUSBCommon)(IMachine *machine, IUSBCommon **USBCommon); nsresult (*GetCurrentSnapshot)(IMachine *machine, ISnapshot **currentSnapshot); nsresult (*GetSettingsFilePath)(IMachine *machine, PRUnichar **settingsFilePath); @@ -359,23 +359,23 @@ typedef struct { nsresult (*SetIOBase)(IParallelPort *port, PRUint32 IOBase); } vboxUniformedIParallelPort; -/* Functions for IVRDPServer and IVRDEServer */ +/* Functions for IVRDEServer */ typedef struct { - nsresult (*GetEnabled)(IVRDxServer *VRDxServer, PRBool *enabled); - nsresult (*SetEnabled)(IVRDxServer *VRDxServer, PRBool enabled); - nsresult (*GetPorts)(vboxDriverPtr driver, IVRDxServer *VRDxServer, + nsresult (*GetEnabled)(IVRDEServer *VRDEServer, PRBool *enabled); + nsresult (*SetEnabled)(IVRDEServer *VRDEServer, PRBool enabled); + nsresult (*GetPorts)(vboxDriverPtr driver, IVRDEServer *VRDEServer, virDomainGraphicsDefPtr graphics); - nsresult (*SetPorts)(vboxDriverPtr driver, IVRDxServer *VRDxServer, + nsresult (*SetPorts)(vboxDriverPtr driver, IVRDEServer *VRDEServer, 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)(vboxDriverPtr driver, IVRDxServer *VRDxServer, + nsresult (*GetReuseSingleConnection)(IVRDEServer *VRDEServer, PRBool *enabled); + nsresult (*SetReuseSingleConnection)(IVRDEServer *VRDEServer, PRBool enabled); + nsresult (*GetAllowMultiConnection)(IVRDEServer *VRDEServer, PRBool *enabled); + nsresult (*SetAllowMultiConnection)(IVRDEServer *VRDEServer, PRBool enabled); + nsresult (*GetNetAddress)(vboxDriverPtr driver, IVRDEServer *VRDEServer, PRUnichar **netAddress); - nsresult (*SetNetAddress)(vboxDriverPtr driver, IVRDxServer *VRDxServer, + nsresult (*SetNetAddress)(vboxDriverPtr driver, IVRDEServer *VRDEServer, PRUnichar *netAddress); -} vboxUniformedIVRDxServer; +} vboxUniformedIVRDEServer; /* Common Functions for IUSBController and IUSBDeviceFilters */ typedef struct { @@ -553,7 +553,7 @@ typedef struct { vboxUniformedINetworkAdapter UINetworkAdapter; vboxUniformedISerialPort UISerialPort; vboxUniformedIParallelPort UIParallelPort; - vboxUniformedIVRDxServer UIVRDxServer; + vboxUniformedIVRDEServer UIVRDEServer; vboxUniformedIUSBCommon UIUSBCommon; vboxUniformedIUSBDeviceFilter UIUSBDeviceFilter; vboxUniformedIMedium UIMedium; -- 2.9.3

This function was not implemented for vbox 5+ which removed TakeScreenShotPNGToArray but provides TakeScreenShotToArray with BitmapFormat_PNG argument which is the same thing. --- src/vbox/vbox_tmpl.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 5e6a919..d022742 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2029,21 +2029,20 @@ _displayGetScreenResolution(IDisplay *display ATTRIBUTE_UNUSED, } static nsresult -_displayTakeScreenShotPNGToArray(IDisplay *display ATTRIBUTE_UNUSED, - PRUint32 screenId ATTRIBUTE_UNUSED, - PRUint32 width ATTRIBUTE_UNUSED, - PRUint32 height ATTRIBUTE_UNUSED, - PRUint32 *screenDataSize ATTRIBUTE_UNUSED, - PRUint8** screenData ATTRIBUTE_UNUSED) -{ -#if VBOX_API_VERSION < 4000000 || VBOX_API_VERSION >= 5000000 - vboxUnsupported(); - return 0; -#else /* VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 5000000 */ +_displayTakeScreenShotPNGToArray(IDisplay *display, PRUint32 screenId, + PRUint32 width, PRUint32 height, + PRUint32 *screenDataSize, + PRUint8** screenData) +{ +#if VBOX_API_VERSION >= 5000000 + return display->vtbl->TakeScreenShotToArray(display, screenId, width, + height, BitmapFormat_PNG, + screenDataSize, screenData); +#else /* VBOX_API_VERSION < 5000000 */ return display->vtbl->TakeScreenShotPNGToArray(display, screenId, width, height, screenDataSize, screenData); -#endif /* VBOX_API_VERSION >= 4000000 */ +#endif /* VBOX_API_VERSION >= 5000000 */ } static nsresult -- 2.9.3

* remove _vboxIID_v2_x and _vboxIID_v3_x structs and repalce with one _vboxIID as all supprted vbox versions have the same IID structure. * remove vboxIIDUnion that was used to abstract version depended IID differences. * remove IID_MEMBER macro and use the new vboxIID directly. --- src/vbox/vbox_common.c | 106 +++++++++++++++--------------- src/vbox/vbox_network.c | 10 +-- src/vbox/vbox_storage.c | 20 +++--- src/vbox/vbox_tmpl.c | 146 ++++++++++++++++-------------------------- src/vbox/vbox_uniformed_api.h | 73 ++++++++------------- 5 files changed, 147 insertions(+), 208 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 8bdf3bb..96e1ffd 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -273,7 +273,7 @@ vboxDestroyDriverConnection(void) } static int openSessionForMachine(vboxDriverPtr data, const unsigned char *dom_uuid, - vboxIIDUnion *iid, IMachine **machine) + vboxIID *iid, IMachine **machine) { VBOX_IID_INITIALIZE(iid); vboxIIDFromUUID(iid, dom_uuid); @@ -535,7 +535,7 @@ vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) { vboxDriverPtr data = dom->conn->privateData; IConsole *console = NULL; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; IProgress *progress = NULL; resultCodeUnion resultCode; @@ -751,7 +751,7 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) PRBool isAccessible = PR_FALSE; PRUnichar *machineNameUtf16 = NULL; char *machineNameUtf8 = NULL; - vboxIIDUnion iid; + vboxIID iid; unsigned char uuid[VIR_UUID_BUFLEN]; PRUint32 state; nsresult rc; @@ -825,7 +825,7 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, { vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; - vboxIIDUnion iid; + vboxIID iid; char *machineNameUtf8 = NULL; PRUnichar *machineNameUtf16 = NULL; unsigned char iid_as_uuid[VIR_UUID_BUFLEN]; @@ -902,7 +902,7 @@ vboxDomainLookupByName(virConnectPtr conn, const char *name) { vboxDriverPtr data = conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; - vboxIIDUnion iid; + vboxIID iid; char *machineNameUtf8 = NULL; PRUnichar *machineNameUtf16 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; @@ -1104,7 +1104,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) if (type == VIR_STORAGE_TYPE_FILE && src) { IMedium *medium = NULL; - vboxIIDUnion mediumUUID; + vboxIID mediumUUID; PRUnichar *mediumFileUtf16 = NULL; PRUint32 storageBus = StorageBus_Null; PRUint32 deviceType = DeviceType_Null; @@ -1858,7 +1858,7 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags vboxDriverPtr data = conn->privateData; IMachine *machine = NULL; IBIOSSettings *bios = NULL; - vboxIIDUnion mchiid; + vboxIID mchiid; virDomainDefPtr def = NULL; nsresult rc; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -2006,7 +2006,7 @@ static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; nsresult rc; int ret = -1; @@ -2043,7 +2043,7 @@ static int vboxDomainUndefine(virDomainPtr dom) } static int -vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion *iid) +vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIID *iid) { vboxDriverPtr data = dom->conn->privateData; int vrdpPresent = 0; @@ -2231,7 +2231,7 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) gVBoxAPI.UIMachine.GetAccessible(machine, &isAccessible); if (isAccessible) { - vboxIIDUnion iid; + vboxIID iid; VBOX_IID_INITIALIZE(&iid); @@ -2304,7 +2304,7 @@ static int vboxDomainIsActive(virDomainPtr dom) { vboxDriverPtr data = dom->conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; - vboxIIDUnion iid; + vboxIID iid; char *machineNameUtf8 = NULL; PRUnichar *machineNameUtf16 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; @@ -2375,7 +2375,7 @@ static int vboxDomainIsPersistent(virDomainPtr dom) /* All domains are persistent. However, we do want to check for * existence. */ vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; int ret = -1; @@ -2398,7 +2398,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. */ vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; int ret = -1; @@ -2420,7 +2420,7 @@ static int vboxDomainSuspend(virDomainPtr dom) { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; IConsole *console = NULL; PRBool isAccessible = PR_FALSE; PRUint32 state; @@ -2471,7 +2471,7 @@ static int vboxDomainResume(virDomainPtr dom) { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; IConsole *console = NULL; PRUint32 state; PRBool isAccessible = PR_FALSE; @@ -2522,7 +2522,7 @@ static int vboxDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; IConsole *console = NULL; PRUint32 state; PRBool isAccessible = PR_FALSE; @@ -2579,7 +2579,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; IConsole *console = NULL; PRUint32 state; PRBool isAccessible = PR_FALSE; @@ -2627,7 +2627,7 @@ static int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; IConsole *console = NULL; PRUint32 state; PRBool isAccessible = PR_FALSE; @@ -2693,7 +2693,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; PRUint32 state; PRBool isAccessible = PR_FALSE; nsresult rc; @@ -2834,7 +2834,7 @@ static int vboxDomainGetState(virDomainPtr dom, int *state, int *reason, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion domiid; + vboxIID domiid; IMachine *machine = NULL; PRUint32 mstate; int ret = -1; @@ -2866,7 +2866,7 @@ static int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; PRUint32 CPUCount = nvcpus; nsresult rc; int ret = -1; @@ -3782,7 +3782,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) vboxDriverPtr data = dom->conn->privateData; virDomainDefPtr def = NULL; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; PRBool accessible = PR_FALSE; size_t i = 0; PRBool PAEEnabled = PR_FALSE; @@ -4041,7 +4041,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; PRUint32 state; virDomainDefPtr def = NULL; virDomainDeviceDefPtr dev = NULL; @@ -4160,7 +4160,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) { vboxDriverPtr data = dom->conn->privateData; IMachine *machine = NULL; - vboxIIDUnion iid; + vboxIID iid; PRUint32 state; virDomainDefPtr def = NULL; virDomainDeviceDefPtr dev = NULL; @@ -4356,7 +4356,7 @@ vboxSnapshotRedefine(virDomainPtr dom, * Finally, we register the machine with the new virtualbox description file. */ vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion domiid; + vboxIID domiid; IMachine *machine = NULL; nsresult rc; PRUnichar *settingsFilePath = NULL; @@ -4465,7 +4465,7 @@ vboxSnapshotRedefine(virDomainPtr dom, PRUnichar *formatUtf = NULL; char *format = NULL; const char *parentUuid = NULL; - vboxIIDUnion iid; + vboxIID iid; VBOX_IID_INITIALIZE(&iid); VBOX_UTF8_TO_UTF16(realReadWriteDisksPath[it], &locationUtf); @@ -4561,7 +4561,7 @@ vboxSnapshotRedefine(virDomainPtr dom, char *format = NULL; char *parentUuid = NULL; virVBoxSnapshotConfHardDiskPtr readOnlyDisk = NULL; - vboxIIDUnion iid, parentiid; + vboxIID iid, parentiid; VBOX_IID_INITIALIZE(&iid); VBOX_IID_INITIALIZE(&parentiid); @@ -4867,7 +4867,7 @@ vboxSnapshotRedefine(virDomainPtr dom, char *uuid = NULL; IMedium *parentDisk = NULL; char *parentUuid = NULL; - vboxIIDUnion iid, parentiid; + vboxIID iid, parentiid; VBOX_IID_INITIALIZE(&iid); VBOX_IID_INITIALIZE(&parentiid); @@ -4984,7 +4984,7 @@ vboxSnapshotRedefine(virDomainPtr dom, char *uuid = NULL; char *format = NULL; char *tmp = NULL; - vboxIIDUnion iid, parentiid; + vboxIID iid, parentiid; VBOX_IID_INITIALIZE(&iid); VBOX_IID_INITIALIZE(&parentiid); @@ -5216,7 +5216,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, { vboxDriverPtr data = dom->conn->privateData; virDomainSnapshotDefPtr def = NULL; - vboxIIDUnion domiid; + vboxIID domiid; IMachine *machine = NULL; IConsole *console = NULL; IProgress *progress = NULL; @@ -5335,7 +5335,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, IMachine *machine, ISnapshot ***snapshots) { - vboxIIDUnion empty; + vboxIID empty; ISnapshot **list = NULL; PRUint32 count; nsresult rc; @@ -5469,7 +5469,7 @@ static int vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def, { virDomainPtr dom = snapshot->domain; vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion domiid; + vboxIID domiid; IMachine *machine = NULL; ISnapshot *snap = NULL; IMachine *snapMachine = NULL; @@ -5478,7 +5478,7 @@ static int vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def, PRUint32 maxSlotPerPort[StorageBus_Floppy + 1] = {}; int diskCount = 0; nsresult rc; - vboxIIDUnion snapIid; + vboxIID snapIid; char *snapshotUuidStr = NULL; size_t i = 0; int ret = -1; @@ -5690,7 +5690,7 @@ int vboxSnapshotGetReadOnlyDisks(virDomainSnapshotPtr snapshot, { virDomainPtr dom = snapshot->domain; vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion domiid; + vboxIID domiid; ISnapshot *snap = NULL; IMachine *machine = NULL; IMachine *snapMachine = NULL; @@ -5909,7 +5909,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, { virDomainPtr dom = snapshot->domain; vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion domiid; + vboxIID domiid; IMachine *machine = NULL; ISnapshot *snap = NULL; ISnapshot *parent = NULL; @@ -6054,7 +6054,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, static int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; nsresult rc; PRUint32 snapshotCount; @@ -6099,7 +6099,7 @@ static int vboxDomainSnapshotListNames(virDomainPtr dom, char **names, int nameslen, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; nsresult rc; ISnapshot **snapshots = NULL; @@ -6121,7 +6121,7 @@ static int vboxDomainSnapshotListNames(virDomainPtr dom, char **names, } if (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) { - vboxIIDUnion empty; + vboxIID empty; VBOX_IID_INITIALIZE(&empty); if (VIR_ALLOC_N(snapshots, 1) < 0) @@ -6180,7 +6180,7 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom, const char *name, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; ISnapshot *snapshot = NULL; virDomainSnapshotPtr ret = NULL; @@ -6209,7 +6209,7 @@ static int vboxDomainHasCurrentSnapshot(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; ISnapshot *snapshot = NULL; nsresult rc; @@ -6247,7 +6247,7 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, { virDomainPtr dom = snapshot->domain; vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; ISnapshot *snap = NULL; ISnapshot *parent = NULL; @@ -6310,7 +6310,7 @@ static virDomainSnapshotPtr vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; ISnapshot *snapshot = NULL; PRUnichar *nameUtf16 = NULL; @@ -6368,7 +6368,7 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, { virDomainPtr dom = snapshot->domain; vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; ISnapshot *snap = NULL; ISnapshot *current = NULL; @@ -6429,7 +6429,7 @@ static int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, { virDomainPtr dom = snapshot->domain; vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; ISnapshot *snap = NULL; int ret = -1; @@ -6460,7 +6460,7 @@ static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, { virDomainPtr dom = snapshot->domain; vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion domiid; + vboxIID domiid; IMachine *machine = NULL; ISnapshot *newSnapshot = NULL; ISnapshot *prevSnapshot = NULL; @@ -6534,7 +6534,7 @@ vboxDomainSnapshotDeleteSingle(vboxDriverPtr data, ISnapshot *snapshot) { IProgress *progress = NULL; - vboxIIDUnion iid; + vboxIID iid; int ret = -1; nsresult rc; resultCodeUnion result; @@ -6626,7 +6626,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) vboxDriverPtr data = dom->conn->privateData; virDomainSnapshotDefPtr def = NULL; char *defXml = NULL; - vboxIIDUnion domiid; + vboxIID domiid; nsresult rc; IMachine *machine = NULL; PRUnichar *settingsFilePathUtf16 = NULL; @@ -6728,7 +6728,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) char *uuid = NULL; char *format = NULL; char *tmp = NULL; - vboxIIDUnion iid, parentiid; + vboxIID iid, parentiid; resultCodeUnion resultCode; VBOX_IID_INITIALIZE(&iid); @@ -7061,7 +7061,7 @@ static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, { virDomainPtr dom = snapshot->domain; vboxDriverPtr data = dom->conn->privateData; - vboxIIDUnion domiid; + vboxIID domiid; IMachine *machine = NULL; ISnapshot *snap = NULL; IConsole *console = NULL; @@ -7148,7 +7148,7 @@ vboxDomainScreenshot(virDomainPtr dom, { vboxDriverPtr data = dom->conn->privateData; IConsole *console = NULL; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; nsresult rc; char *tmp; @@ -7286,7 +7286,7 @@ vboxConnectListAllDomains(virConnectPtr conn, char *machineNameUtf8 = NULL; PRUnichar *machineNameUtf16 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; - vboxIIDUnion iid; + vboxIID iid; PRUint32 state; nsresult rc; size_t i; @@ -7495,7 +7495,7 @@ vboxDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data = dom->conn->privateData; vboxArray machines = VBOX_ARRAY_INITIALIZER; - vboxIIDUnion iid; + vboxIID iid; char *machineNameUtf8 = NULL; PRUnichar *machineNameUtf16 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; @@ -7571,7 +7571,7 @@ vboxDomainSendKey(virDomainPtr dom, int ret = -1; vboxDriverPtr data = dom->conn->privateData; IConsole *console = NULL; - vboxIIDUnion iid; + vboxIID iid; IMachine *machine = NULL; IKeyboard *keyboard = NULL; PRInt32 *keyDownCodes = NULL; diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index f004ec1..50a7a56 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -255,7 +255,7 @@ static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *nameUtf8 = NULL; PRUnichar *nameUtf16 = NULL; IHostNetworkInterface *networkInterface = NULL; - vboxIIDUnion iid; + vboxIID iid; IHost *host = NULL; virNetworkPtr ret = NULL; @@ -307,7 +307,7 @@ static virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *nam IHostNetworkInterface *networkInterface = NULL; PRUint32 interfaceType = 0; unsigned char uuid[VIR_UUID_BUFLEN]; - vboxIIDUnion iid; + vboxIID iid; IHost *host = NULL; virNetworkPtr ret = NULL; nsresult rc; @@ -378,7 +378,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start) virNetworkDefPtr def = virNetworkDefParseString(xml); virNetworkIPDefPtr ipdef = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; - vboxIIDUnion vboxnetiid; + vboxIID vboxnetiid; virSocketAddr netmask; IHost *host = NULL; virNetworkPtr ret = NULL; @@ -604,7 +604,7 @@ vboxNetworkUndefineDestroy(virNetworkPtr network, bool removeinterface) goto cleanup; if (removeinterface) { - vboxIIDUnion iid; + vboxIID iid; IProgress *progress = NULL; nsresult rc; resultCodeUnion resultCode; @@ -769,7 +769,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) PRUint32 interfaceType = 0; PRUnichar *networkNameUtf16 = NULL; IDHCPServer *dhcpServer = NULL; - vboxIIDUnion vboxnet0IID; + vboxIID vboxnet0IID; IHost *host = NULL; char *ret = NULL; nsresult rc; diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 8ac7e1d..c2de1ce 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -221,7 +221,7 @@ vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) } if (nameUtf8 && STREQ(nameUtf8, name)) { - vboxIIDUnion hddIID; + vboxIID hddIID; unsigned char uuid[VIR_UUID_BUFLEN]; char key[VIR_UUID_STRING_BUFLEN] = ""; @@ -257,7 +257,7 @@ static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char *key) { vboxDriverPtr data = conn->privateData; - vboxIIDUnion hddIID; + vboxIID hddIID; unsigned char uuid[VIR_UUID_BUFLEN]; IMedium *hardDisk = NULL; PRUnichar *hddNameUtf16 = NULL; @@ -330,7 +330,7 @@ vboxStorageVolLookupByPath(virConnectPtr conn, const char *path) char *hddNameUtf8 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; char key[VIR_UUID_STRING_BUFLEN] = ""; - vboxIIDUnion hddIID; + vboxIID hddIID; PRUint32 hddstate; nsresult rc; virStorageVolPtr ret = NULL; @@ -407,7 +407,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, PRUnichar *hddNameUtf16 = NULL; virStoragePoolDef poolDef; nsresult rc; - vboxIIDUnion hddIID; + vboxIID hddIID; unsigned char uuid[VIR_UUID_BUFLEN]; char key[VIR_UUID_STRING_BUFLEN] = ""; IMedium *hardDisk = NULL; @@ -517,7 +517,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) size_t j = 0; PRUint32 machineIdsSize = 0; vboxArray machineIds = VBOX_ARRAY_INITIALIZER; - vboxIIDUnion hddIID; + vboxIID hddIID; int ret = -1; if (!data->vboxObj) @@ -562,7 +562,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) for (i = 0; i < machineIds.count; i++) { IMachine *machine = NULL; - vboxIIDUnion machineId; + vboxIID machineId; vboxArray hddAttachments = VBOX_ARRAY_INITIALIZER; VBOX_IID_INITIALIZE(&machineId); @@ -591,7 +591,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) for (j = 0; j < hddAttachments.count; j++) { IMediumAttachment *hddAttachment = hddAttachments.items[j]; IMedium *hdd = NULL; - vboxIIDUnion iid; + vboxIID iid; if (!hddAttachment) continue; @@ -667,7 +667,7 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info PRUint32 hddstate; PRUint64 hddLogicalSize = 0; PRUint64 hddActualSize = 0; - vboxIIDUnion hddIID; + vboxIID hddIID; nsresult rc; int ret = -1; @@ -725,7 +725,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) PRUint64 hddActualSize = 0; virStoragePoolDef pool; virStorageVolDef def; - vboxIIDUnion hddIID; + vboxIID hddIID; PRUint32 hddstate; nsresult rc; char *ret = NULL; @@ -813,7 +813,7 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) PRUnichar *hddLocationUtf16 = NULL; char *hddLocationUtf8 = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; - vboxIIDUnion hddIID; + vboxIID hddIID; PRUint32 hddstate; nsresult rc; char *ret = NULL; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index d022742..333e28a 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -150,14 +150,10 @@ if (strUtf16) {\ #define VBOX_SESSION_CLOSE() \ data->vboxSession->vtbl->UnlockMachine(data->vboxSession) -typedef struct _vboxIID_v3_x vboxIID; -typedef struct _vboxIID_v3_x vboxIID_v3_x; - # define VBOX_IID_INITIALIZER { NULL, true } -# define IID_MEMBER(name) (iidu->vboxIID_v3_x.name) static void -vboxIIDUnalloc_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid) +_vboxIIDUnalloc(vboxDriverPtr data, vboxIID *iid) { if (iid->value != NULL && iid->owner) data->pFuncs->pfnUtf16Free(iid->value); @@ -167,14 +163,8 @@ vboxIIDUnalloc_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid) } static void -_vboxIIDUnalloc(vboxDriverPtr data, vboxIIDUnion *iidu) -{ - vboxIIDUnalloc_v3_x(data, &iidu->vboxIID_v3_x); -} - -static void -vboxIIDToUUID_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid, - unsigned char *uuid) +_vboxIIDToUUID(vboxDriverPtr data, vboxIID *iid, + unsigned char *uuid) { char *utf8 = NULL; @@ -186,35 +176,21 @@ vboxIIDToUUID_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid, } static void -_vboxIIDToUUID(vboxDriverPtr data, vboxIIDUnion *iidu, - unsigned char *uuid) -{ - vboxIIDToUUID_v3_x(data, &iidu->vboxIID_v3_x, uuid); -} - -static void -vboxIIDFromUUID_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid, - const unsigned char *uuid) +_vboxIIDFromUUID(vboxDriverPtr data, vboxIID *iid, + const unsigned char *uuid) { char utf8[VIR_UUID_STRING_BUFLEN]; - vboxIIDUnalloc_v3_x(data, iid); + _vboxIIDUnalloc(data, iid); virUUIDFormat(uuid, utf8); data->pFuncs->pfnUtf8ToUtf16(utf8, &iid->value); } -static void -_vboxIIDFromUUID(vboxDriverPtr data, vboxIIDUnion *iidu, - const unsigned char *uuid) -{ - vboxIIDFromUUID_v3_x(data, &iidu->vboxIID_v3_x, uuid); -} - static bool -vboxIIDIsEqual_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid1, - vboxIID_v3_x *iid2) +_vboxIIDIsEqual(vboxDriverPtr data, vboxIID *iid1, + vboxIID *iid2) { unsigned char uuid1[VIR_UUID_BUFLEN]; unsigned char uuid2[VIR_UUID_BUFLEN]; @@ -224,42 +200,28 @@ vboxIIDIsEqual_v3_x(vboxDriverPtr data, vboxIID_v3_x *iid1, * or mixture of both and we don't want to fail here by * using direct string comparison. Here virUUIDParse() takes * care of these cases. */ - vboxIIDToUUID_v3_x(data, iid1, uuid1); - vboxIIDToUUID_v3_x(data, iid2, uuid2); + _vboxIIDToUUID(data, iid1, uuid1); + _vboxIIDToUUID(data, iid2, uuid2); return memcmp(uuid1, uuid2, VIR_UUID_BUFLEN) == 0; } -static bool -_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(vboxDriverPtr data, vboxIID_v3_x *iid, - vboxArray *array, int idx) +_vboxIIDFromArrayItem(vboxDriverPtr data, vboxIID *iid, + vboxArray *array, int idx) { - vboxIIDUnalloc_v3_x(data, iid); + _vboxIIDUnalloc(data, iid); iid->value = array->items[idx]; iid->owner = false; } -static void -_vboxIIDFromArrayItem(vboxDriverPtr data, vboxIIDUnion *iidu, - vboxArray *array, int idx) -{ - vboxIIDFromArrayItem_v3_x(data, &iidu->vboxIID_v3_x, array, idx); -} - -# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v3_x(data, iid) -# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v3_x(data, iid, uuid) -# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v3_x(data, iid, uuid) -# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v3_x(data, iid1, iid2) +# define vboxIIDUnalloc(iid) _vboxIIDUnalloc(data, iid) +# define vboxIIDToUUID(iid, uuid) _vboxIIDToUUID(data, iid, uuid) +# define vboxIIDFromUUID(iid, uuid) _vboxIIDFromUUID(data, iid, uuid) +# define vboxIIDIsEqual(iid1, iid2) _vboxIIDIsEqual(data, iid1, iid2) # define vboxIIDFromArrayItem(iid, array, idx) \ - vboxIIDFromArrayItem_v3_x(data, iid, array, idx) + _vboxIIDFromArrayItem(data, iid, array, idx) # define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16) /** @@ -412,11 +374,11 @@ _vboxDomainSnapshotRestore(virDomainPtr dom, } static nsresult -_unregisterMachine(vboxDriverPtr data, vboxIIDUnion *iidu, IMachine **machine) +_unregisterMachine(vboxDriverPtr data, vboxIID *iid, IMachine **machine) { nsresult rc; vboxArray media = VBOX_ARRAY_INITIALIZER; - rc = data->vboxObj->vtbl->FindMachine(data->vboxObj, IID_MEMBER(value), machine); + rc = data->vboxObj->vtbl->FindMachine(data->vboxObj, iid->value, machine); if (NS_FAILED(rc)) { virReportError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid")); @@ -534,29 +496,29 @@ static int _pfnUtf8ToUtf16(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar return pFuncs->pfnUtf8ToUtf16(pszString, ppwszString); } -static void _vboxIIDInitialize(vboxIIDUnion *iidu) +static void _vboxIIDInitialize(vboxIID *iid) { - memset(iidu, 0, sizeof(vboxIIDUnion)); - IID_MEMBER(owner) = true; + memset(iid, 0, sizeof(vboxIID)); + iid->owner = true; } -static void _DEBUGIID(vboxDriverPtr data, const char *msg, vboxIIDUnion *iidu) +static void _DEBUGIID(vboxDriverPtr data, const char *msg, vboxIID *iid) { - DEBUGPRUnichar(msg, IID_MEMBER(value)); + DEBUGPRUnichar(msg, iid->value); } static void _vboxIIDToUtf8(vboxDriverPtr data ATTRIBUTE_UNUSED, - vboxIIDUnion *iidu ATTRIBUTE_UNUSED, + vboxIID *iid ATTRIBUTE_UNUSED, char **utf8 ATTRIBUTE_UNUSED) { - data->pFuncs->pfnUtf16ToUtf8(IID_MEMBER(value), utf8); + data->pFuncs->pfnUtf16ToUtf8(iid->value, utf8); } static nsresult -_vboxArrayGetWithIIDArg(vboxArray *array, void *self, void *getter, vboxIIDUnion *iidu) +_vboxArrayGetWithIIDArg(vboxArray *array, void *self, void *getter, vboxIID *iid) { - return vboxArrayGetWithPtrArg(array, self, getter, IID_MEMBER(value)); + return vboxArrayGetWithPtrArg(array, self, getter, iid->value); } static void* _handleGetMachines(IVirtualBox *vboxObj) @@ -626,9 +588,9 @@ _virtualboxGetVersion(IVirtualBox *vboxObj, PRUnichar **versionUtf16) } static nsresult -_virtualboxGetMachine(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine) +_virtualboxGetMachine(IVirtualBox *vboxObj, vboxIID *iid, IMachine **machine) { - return vboxObj->vtbl->FindMachine(vboxObj, IID_MEMBER(value), machine); + return vboxObj->vtbl->FindMachine(vboxObj, iid->value, machine); } static nsresult @@ -750,13 +712,13 @@ _virtualboxOpenMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED, } static nsresult -_virtualboxGetHardDiskByIID(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMedium **medium) +_virtualboxGetHardDiskByIID(IVirtualBox *vboxObj, vboxIID *iid, IMedium **medium) { #if VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000 - return vboxObj->vtbl->FindMedium(vboxObj, IID_MEMBER(value), DeviceType_HardDisk, + return vboxObj->vtbl->FindMedium(vboxObj, iid->value, DeviceType_HardDisk, medium); #else /* VBOX_API_VERSION >= 4002000 */ - return vboxObj->vtbl->OpenMedium(vboxObj, IID_MEMBER(value), DeviceType_HardDisk, + return vboxObj->vtbl->OpenMedium(vboxObj, iid->value, DeviceType_HardDisk, AccessMode_ReadWrite, PR_FALSE, medium); #endif /* VBOX_API_VERSION >= 4002000 */ } @@ -826,7 +788,7 @@ _machineRemoveSharedFolder(IMachine *machine, PRUnichar *name) static nsresult _machineLaunchVMProcess(vboxDriverPtr data, IMachine *machine ATTRIBUTE_UNUSED, - vboxIIDUnion *iidu ATTRIBUTE_UNUSED, + vboxIID *iid ATTRIBUTE_UNUSED, PRUnichar *sessionType, PRUnichar *env, IProgress **progress) { @@ -844,9 +806,9 @@ _machineUnregister(IMachine *machine ATTRIBUTE_UNUSED, } static nsresult -_machineFindSnapshot(IMachine *machine, vboxIIDUnion *iidu, ISnapshot **snapshot) +_machineFindSnapshot(IMachine *machine, vboxIID *iid, ISnapshot **snapshot) { - return machine->vtbl->FindSnapshot(machine, IID_MEMBER(value), snapshot); + return machine->vtbl->FindSnapshot(machine, iid->value, snapshot); } static nsresult @@ -875,9 +837,9 @@ _machineGetName(IMachine *machine, PRUnichar **name) } static nsresult -_machineGetId(IMachine *machine, vboxIIDUnion *iidu) +_machineGetId(IMachine *machine, vboxIID *iid) { - return machine->vtbl->GetId(machine, &IID_MEMBER(value)); + return machine->vtbl->GetId(machine, &iid->value); } static nsresult @@ -1067,13 +1029,13 @@ _machineSaveSettings(IMachine *machine) } static nsresult -_sessionOpen(vboxDriverPtr data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine) +_sessionOpen(vboxDriverPtr data, vboxIID *iid ATTRIBUTE_UNUSED, IMachine *machine) { return machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write); } static nsresult -_sessionOpenExisting(vboxDriverPtr data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine) +_sessionOpenExisting(vboxDriverPtr data, vboxIID *iid ATTRIBUTE_UNUSED, IMachine *machine) { return machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Shared); } @@ -1182,10 +1144,10 @@ _consoleTakeSnapshot(IConsole *console, PRUnichar *name, } static nsresult -_consoleDeleteSnapshot(IConsole *console, vboxIIDUnion *iidu, IProgress **progress) +_consoleDeleteSnapshot(IConsole *console, vboxIID *iid, IProgress **progress) { #if VBOX_API_VERSION < 5000000 /* VBOX_API_VERSION < 5000000 */ - return console->vtbl->DeleteSnapshot(console, IID_MEMBER(value), progress); + return console->vtbl->DeleteSnapshot(console, iid->value, progress); #else /* VBOX_API_VERSION >= 5000000 */ IMachine *machine; nsresult rc; @@ -1193,7 +1155,7 @@ _consoleDeleteSnapshot(IConsole *console, vboxIIDUnion *iidu, IProgress **progre rc = console->vtbl->GetMachine(console, &machine); if (NS_SUCCEEDED(rc)) - rc = machine->vtbl->DeleteSnapshot(machine, IID_MEMBER(value), progress); + rc = machine->vtbl->DeleteSnapshot(machine, iid->value, progress); else virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to get machine from console. (error %d)"), rc); @@ -1786,9 +1748,9 @@ _usbDeviceFilterSetVendorId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar *vendor return USBDeviceFilter->vtbl->SetVendorId(USBDeviceFilter, vendorId); } -static nsresult _mediumGetId(IMedium *medium, vboxIIDUnion *iidu) +static nsresult _mediumGetId(IMedium *medium, vboxIID *iid) { - return medium->vtbl->GetId(medium, &IID_MEMBER(value)); + return medium->vtbl->GetId(medium, &iid->value); } static nsresult _mediumGetLocation(IMedium *medium, PRUnichar **location) @@ -1968,9 +1930,9 @@ _snapshotGetName(ISnapshot *snapshot, PRUnichar **name) } static nsresult -_snapshotGetId(ISnapshot *snapshot, vboxIIDUnion *iidu) +_snapshotGetId(ISnapshot *snapshot, vboxIID *iid) { - return snapshot->vtbl->GetId(snapshot, &IID_MEMBER(value)); + return snapshot->vtbl->GetId(snapshot, &iid->value); } static nsresult @@ -2046,10 +2008,10 @@ _displayTakeScreenShotPNGToArray(IDisplay *display, PRUint32 screenId, } static nsresult -_hostFindHostNetworkInterfaceById(IHost *host, vboxIIDUnion *iidu, +_hostFindHostNetworkInterfaceById(IHost *host, vboxIID *iid, IHostNetworkInterface **networkInterface) { - return host->vtbl->FindHostNetworkInterfaceById(host, IID_MEMBER(value), + return host->vtbl->FindHostNetworkInterfaceById(host, iid->value, networkInterface); } @@ -2082,10 +2044,10 @@ _hostCreateHostOnlyNetworkInterface(vboxDriverPtr data ATTRIBUTE_UNUSED, static nsresult _hostRemoveHostOnlyNetworkInterface(IHost *host ATTRIBUTE_UNUSED, - vboxIIDUnion *iidu ATTRIBUTE_UNUSED, + vboxIID *iid ATTRIBUTE_UNUSED, IProgress **progress ATTRIBUTE_UNUSED) { - return host->vtbl->RemoveHostOnlyNetworkInterface(host, IID_MEMBER(value), progress); + return host->vtbl->RemoveHostOnlyNetworkInterface(host, iid->value, progress); } static nsresult @@ -2107,9 +2069,9 @@ _hnInterfaceGetName(IHostNetworkInterface *hni, PRUnichar **name) } static nsresult -_hnInterfaceGetId(IHostNetworkInterface *hni, vboxIIDUnion *iidu) +_hnInterfaceGetId(IHostNetworkInterface *hni, vboxIID *iid) { - return hni->vtbl->GetId(hni, &IID_MEMBER(value)); + return hni->vtbl->GetId(hni, &iid->value); } static nsresult diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index d1ce934..2ccaf43 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -58,24 +58,7 @@ /* Extracted define from vbox_tmpl.c */ -# ifdef WIN32 -struct _vboxIID_v2_x_WIN32 { - /* IID is represented by a GUID value. */ - GUID value; -}; -# endif /* !WIN32 */ - -struct _vboxIID_v2_x { - /* IID is represented by a pointer to a nsID. */ - nsID *value; - - /* backing is used in cases where we need to create or copy an IID. - * We cannot allocate memory that can be freed by ComUnallocMem. - * Therefore, we use this stack allocated nsID instead. */ - nsID backing; -}; - -struct _vboxIID_v3_x { +struct _vboxIID { /* IID is represented by a UTF-16 encoded UUID in string form. */ PRUnichar *value; @@ -83,13 +66,7 @@ struct _vboxIID_v3_x { bool owner; }; -typedef union { -# ifdef WIN32 - struct _vboxIID_v2_x_WIN32 vboxIID_v2_x_WIN32; -# endif /* !WIN32 */ - struct _vboxIID_v2_x vboxIID_v2_x; - struct _vboxIID_v3_x vboxIID_v3_x; -} vboxIIDUnion; +typedef struct _vboxIID vboxIID; typedef union { nsresult uResultCode; @@ -138,20 +115,20 @@ typedef struct { /* Functions for vboxIID */ typedef struct { - void (*vboxIIDInitialize)(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); + void (*vboxIIDInitialize)(vboxIID *iid); + void (*vboxIIDUnalloc)(vboxDriverPtr driver, vboxIID *iid); + void (*vboxIIDToUUID)(vboxDriverPtr driver, vboxIID *iid, unsigned char *uuid); + void (*vboxIIDFromUUID)(vboxDriverPtr driver, vboxIID *iid, const unsigned char *uuid); + bool (*vboxIIDIsEqual)(vboxDriverPtr driver, vboxIID *iid1, vboxIID *iid2); + void (*vboxIIDFromArrayItem)(vboxDriverPtr driver, vboxIID *iid, vboxArray *array, int idx); + void (*vboxIIDToUtf8)(vboxDriverPtr driver, vboxIID *iid, char **utf8); + void (*DEBUGIID)(vboxDriverPtr driver, const char *msg, vboxIID *iid); } vboxUniformedIID; /* Functions for vboxArray */ typedef struct { nsresult (*vboxArrayGet)(vboxArray *array, void *self, void *getter); - nsresult (*vboxArrayGetWithIIDArg)(vboxArray *array, void *self, void *getter, vboxIIDUnion *iidu); + nsresult (*vboxArrayGetWithIIDArg)(vboxArray *array, void *self, void *getter, vboxIID *iid); void (*vboxArrayRelease)(vboxArray *array); void (*vboxArrayUnalloc)(vboxArray *array); /* Generate function pointers for vboxArrayGet */ @@ -176,7 +153,7 @@ typedef struct { /* Functions for IVirtualBox */ typedef struct { nsresult (*GetVersion)(IVirtualBox *vboxObj, PRUnichar **versionUtf16); - nsresult (*GetMachine)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine); + nsresult (*GetMachine)(IVirtualBox *vboxObj, vboxIID *iid, IMachine **machine); nsresult (*OpenMachine)(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine); nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties); nsresult (*GetHost)(IVirtualBox *vboxObj, IHost **host); @@ -186,7 +163,7 @@ typedef struct { nsresult (*FindHardDisk)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, PRUint32 accessMode, IMedium **medium); nsresult (*OpenMedium)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, PRUint32 accessMode, IMedium **medium); - nsresult (*GetHardDiskByIID)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMedium **medium); + nsresult (*GetHardDiskByIID)(IVirtualBox *vboxObj, vboxIID *iid, IMedium **medium); nsresult (*FindDHCPServerByNetworkName)(IVirtualBox *vboxObj, PRUnichar *name, IDHCPServer **server); nsresult (*CreateDHCPServer)(IVirtualBox *vboxObj, PRUnichar *name, IDHCPServer **server); nsresult (*RemoveDHCPServer)(IVirtualBox *vboxObj, IDHCPServer *server); @@ -206,18 +183,18 @@ typedef struct { PRBool automount); nsresult (*RemoveSharedFolder)(IMachine *machine, PRUnichar *name); nsresult (*LaunchVMProcess)(vboxDriverPtr driver, IMachine *machine, - vboxIIDUnion *iidu, + vboxIID *iid, PRUnichar *sessionType, PRUnichar *env, IProgress **progress); nsresult (*Unregister)(IMachine *machine, PRUint32 cleanupMode, PRUint32 *aMediaSize, IMedium ***aMedia); - nsresult (*FindSnapshot)(IMachine *machine, vboxIIDUnion *iidu, ISnapshot **snapshot); + nsresult (*FindSnapshot)(IMachine *machine, vboxIID *iid, ISnapshot **snapshot); nsresult (*DetachDevice)(IMachine *machine, PRUnichar *name, PRInt32 controllerPort, PRInt32 device); nsresult (*GetAccessible)(IMachine *machine, PRBool *isAccessible); nsresult (*GetState)(IMachine *machine, PRUint32 *state); nsresult (*GetName)(IMachine *machine, PRUnichar **name); - nsresult (*GetId)(IMachine *machine, vboxIIDUnion *iidu); + nsresult (*GetId)(IMachine *machine, vboxIID *iid); nsresult (*GetBIOSSettings)(IMachine *machine, IBIOSSettings **bios); nsresult (*GetAudioAdapter)(IMachine *machine, IAudioAdapter **audioAdapter); nsresult (*GetNetworkAdapter)(IMachine *machine, PRUint32 slot, INetworkAdapter **adapter); @@ -252,8 +229,8 @@ typedef struct { /* Functions for ISession */ typedef struct { - nsresult (*Open)(vboxDriverPtr driver, vboxIIDUnion *iidu, IMachine *machine); - nsresult (*OpenExisting)(vboxDriverPtr driver, vboxIIDUnion *iidu, IMachine *machine); + nsresult (*Open)(vboxDriverPtr driver, vboxIID *iid, IMachine *machine); + nsresult (*OpenExisting)(vboxDriverPtr driver, vboxIID *iid, IMachine *machine); nsresult (*GetConsole)(ISession *session, IConsole **console); nsresult (*GetMachine)(ISession *session, IMachine **machine); nsresult (*Close)(ISession *session); @@ -269,7 +246,7 @@ typedef struct { nsresult (*Reset)(IConsole *console); nsresult (*TakeSnapshot)(IConsole *console, PRUnichar *name, PRUnichar *description, IProgress **progress); - nsresult (*DeleteSnapshot)(IConsole *console, vboxIIDUnion *iidu, IProgress **progress); + nsresult (*DeleteSnapshot)(IConsole *console, vboxIID *iid, IProgress **progress); nsresult (*GetDisplay)(IConsole *console, IDisplay **display); nsresult (*GetKeyboard)(IConsole *console, IKeyboard **keyboard); } vboxUniformedIConsole; @@ -398,7 +375,7 @@ typedef struct { /* Functions for IMedium */ typedef struct { - nsresult (*GetId)(IMedium *medium, vboxIIDUnion *iidu); + nsresult (*GetId)(IMedium *medium, vboxIID *iid); nsresult (*GetLocation)(IMedium *medium, PRUnichar **location); nsresult (*GetState)(IMedium *medium, PRUint32 *state); nsresult (*GetName)(IMedium *medium, PRUnichar **name); @@ -445,7 +422,7 @@ typedef struct { /* Functions for ISnapshot */ typedef struct { nsresult (*GetName)(ISnapshot *snapshot, PRUnichar **name); - nsresult (*GetId)(ISnapshot *snapshot, vboxIIDUnion *iidu); + nsresult (*GetId)(ISnapshot *snapshot, vboxIID *iid); nsresult (*GetMachine)(ISnapshot *snapshot, IMachine **machine); nsresult (*GetDescription)(ISnapshot *snapshot, PRUnichar **description); nsresult (*GetTimeStamp)(ISnapshot *snapshot, PRInt64 *timeStamp); @@ -472,14 +449,14 @@ typedef struct { /* Functions for IHost */ typedef struct { - nsresult (*FindHostNetworkInterfaceById)(IHost *host, vboxIIDUnion *iidu, + nsresult (*FindHostNetworkInterfaceById)(IHost *host, vboxIID *iid, IHostNetworkInterface **networkInterface); nsresult (*FindHostNetworkInterfaceByName)(IHost *host, PRUnichar *name, IHostNetworkInterface **networkInterface); nsresult (*CreateHostOnlyNetworkInterface)(vboxDriverPtr driver, IHost *host, char *name, IHostNetworkInterface **networkInterface); - nsresult (*RemoveHostOnlyNetworkInterface)(IHost *host, vboxIIDUnion *iidu, + nsresult (*RemoveHostOnlyNetworkInterface)(IHost *host, vboxIID *iid, IProgress **progress); } vboxUniformedIHost; @@ -488,7 +465,7 @@ typedef struct { nsresult (*GetInterfaceType)(IHostNetworkInterface *hni, PRUint32 *interfaceType); nsresult (*GetStatus)(IHostNetworkInterface *hni, PRUint32 *status); nsresult (*GetName)(IHostNetworkInterface *hni, PRUnichar **name); - nsresult (*GetId)(IHostNetworkInterface *hni, vboxIIDUnion *iidu); + nsresult (*GetId)(IHostNetworkInterface *hni, vboxIID *iid); nsresult (*GetHardwareAddress)(IHostNetworkInterface *hni, PRUnichar **hardwareAddress); nsresult (*GetIPAddress)(IHostNetworkInterface *hni, PRUnichar **IPAddress); nsresult (*GetNetworkMask)(IHostNetworkInterface *hni, PRUnichar **networkMask); @@ -533,7 +510,7 @@ typedef struct { uint32_t APIVersion; uint32_t XPCOMCVersion; /* vbox APIs */ - nsresult (*unregisterMachine)(vboxDriverPtr driver, vboxIIDUnion *iidu, IMachine **machine); + nsresult (*unregisterMachine)(vboxDriverPtr driver, vboxIID *iid, IMachine **machine); void (*deleteConfig)(IMachine *machine); void (*vboxAttachDrivesOld)(virDomainDefPtr def, vboxDriverPtr driver, IMachine *machine); virDomainState (*vboxConvertState)(PRUint32 state); -- 2.9.3

--- docs/news.html.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/news.html.in b/docs/news.html.in index e544cfa..2c01f00 100644 --- a/docs/news.html.in +++ b/docs/news.html.in @@ -53,6 +53,14 @@ Add a display of the <physical> size of a disk volume in the output of the volume XML </li> + <li>vbox: remove support for VirtualBox 3.x and older<br/> + Those old VirtualBox versions have been unsupported by + upstream for a long time and the API of 4.0 and newer has + diverged enough to require code abstractions to handle differences. + Removing support for those old versions drops lots of code from the + driver and simplifies the logic to ease implementation of new features + going forward. + </li> </ul> </li> <li><strong>Bug fixes</strong> -- 2.9.3

The patch itself is attached as compressed archive due to its size. * delete SDK header files for vbox older than 4.0 * delete .c files for vbox older than 4.0 * update vbox_XPCOMCGlue to use oldest supported header file, that is 4.0 going forward. * remove deleted files from Makefile.am --- src/Makefile.am | 4 - src/vbox/vbox_CAPI_v2_2.h | 4869 -------------------------------------- src/vbox/vbox_CAPI_v3_0.h | 5396 ------------------------------------------ src/vbox/vbox_CAPI_v3_1.h | 5297 ----------------------------------------- src/vbox/vbox_CAPI_v3_2.h | 5625 -------------------------------------------- src/vbox/vbox_V2_2.c | 37 - src/vbox/vbox_V3_0.c | 37 - src/vbox/vbox_V3_1.c | 37 - src/vbox/vbox_V3_2.c | 37 - src/vbox/vbox_XPCOMCGlue.h | 2 +- src/vbox/vbox_tmpl.c | 10 +- 11 files changed, 2 insertions(+), 21349 deletions(-) delete mode 100644 src/vbox/vbox_CAPI_v2_2.h delete mode 100644 src/vbox/vbox_CAPI_v3_0.h delete mode 100644 src/vbox/vbox_CAPI_v3_1.h delete mode 100644 src/vbox/vbox_CAPI_v3_2.h delete mode 100644 src/vbox/vbox_V2_2.c delete mode 100644 src/vbox/vbox_V3_0.c delete mode 100644 src/vbox/vbox_V3_1.c delete mode 100644 src/vbox/vbox_V3_2.c

On 12/29/2016 03:34 PM, Dawid Zamirski wrote:
Hello,
This series removes support for legacy VirtualBox versions (3.x and older) that did not have upstream support for a while and won't even work on any relatively recent distro. The idea for doing this was first mentioned here [1] and this makes the driver code cleaner as the APIs for those old versions were quite different from v4.0+ and required abstractions to handle the differences.
Please note that the first patch in the series is sent to ML as a compressed attachment because it deletes VirtualBox SDK header files for those old verions which are large and the patch would not pass ML message size limit.
[1] https://www.redhat.com/archives/libvir-list/2016-November/msg01133.html
Regards, Dawid
Dawid Zamirski (12): vbox: remove SDK header files for vbox 3 and older. vbox: remove calls to *InstallUniformedAPI macros. vbox: remove code for old API versions. vbox: remove _vboxAttachDrivesOld vbox: do not use IHardDisk anymore. vbox: remove getMachineForSession flag. vbox: remove domain events support. vbox: remove code dealing with oldMediumInterface vbox: IVRDxServer to IVRDEServer. vbox: fix _displayTakeScreenShotPNGToArray vbox: consolidate vbox IID structures. docs: add news entry in improvements section.
docs/news.html.in | 8 + src/Makefile.am | 4 - src/vbox/vbox_CAPI_v2_2.h | 4869 ----------------------------------- src/vbox/vbox_CAPI_v3_0.h | 5396 --------------------------------------- src/vbox/vbox_CAPI_v3_1.h | 5297 -------------------------------------- src/vbox/vbox_CAPI_v3_2.h | 5625 ----------------------------------------- src/vbox/vbox_V2_2.c | 37 - src/vbox/vbox_V3_0.c | 37 - src/vbox/vbox_V3_1.c | 37 - src/vbox/vbox_V3_2.c | 37 - src/vbox/vbox_XPCOMCGlue.h | 2 +- src/vbox/vbox_common.c | 402 +-- src/vbox/vbox_common.h | 13 +- src/vbox/vbox_network.c | 12 +- src/vbox/vbox_storage.c | 76 +- src/vbox/vbox_tmpl.c | 3006 ++-------------------- src/vbox/vbox_uniformed_api.h | 171 +- 17 files changed, 438 insertions(+), 24591 deletions(-) delete mode 100644 src/vbox/vbox_CAPI_v2_2.h delete mode 100644 src/vbox/vbox_CAPI_v3_0.h delete mode 100644 src/vbox/vbox_CAPI_v3_1.h delete mode 100644 src/vbox/vbox_CAPI_v3_2.h delete mode 100644 src/vbox/vbox_V2_2.c delete mode 100644 src/vbox/vbox_V3_0.c delete mode 100644 src/vbox/vbox_V3_1.c delete mode 100644 src/vbox/vbox_V3_2.c
Seems reasonable - it builds for me ;-). I did take a cursory scan through the changes - they all seem valid. ACK series and can push everything before the release once/if the news patches series on list can come to a resolution (otherwise, I'll use news.html.in as this one does). Doubtful anyone has reservations about removing all the cruft, but I will let the ACK sit for the rest of today to see if anyone gripes ;-). John FWIW: I had to cleanup a few make syntax-check warnings in vbox_impl.c due to not needing extra spaces on preprocessor indents (#define instead of # define): cppi: src/vbox/vbox_tmpl.c: line 159: not properly indented cppi: src/vbox/vbox_tmpl.c: line 160: not properly indented cppi: src/vbox/vbox_tmpl.c: line 260: not properly indented cppi: src/vbox/vbox_tmpl.c: line 261: not properly indented cppi: src/vbox/vbox_tmpl.c: line 262: not properly indented cppi: src/vbox/vbox_tmpl.c: line 263: not properly indented cppi: src/vbox/vbox_tmpl.c: line 264: not properly indented cppi: src/vbox/vbox_tmpl.c: line 266: not properly indented cppi: src/vbox/vbox_tmpl.c: line 817: not properly indented cppi: src/vbox/vbox_tmpl.c: line 819: not properly indented cppi: src/vbox/vbox_tmpl.c: line 852: not properly indented cppi: src/vbox/vbox_tmpl.c: line 855: not properly indented cppi: src/vbox/vbox_tmpl.c: line 863: not properly indented cppi: src/vbox/vbox_tmpl.c: line 865: not properly indented cppi: src/vbox/vbox_tmpl.c: line 867: not properly indented cppi: src/vbox/vbox_tmpl.c: line 893: not properly indented cppi: src/vbox/vbox_tmpl.c: line 895: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1581: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1587: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1589: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1591: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1592: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1596: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1598: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1600: not properly indented cppi: src/vbox/vbox_tmpl.c: line 1601: not properly indented

On Tue, 2017-01-10 at 11:50 -0500, John Ferlan wrote:
Seems reasonable - it builds for me ;-). I did take a cursory scan through the changes - they all seem valid.
ACK series and can push everything before the release once/if the news patches series on list can come to a resolution (otherwise, I'll use news.html.in as this one does). Doubtful anyone has reservations about removing all the cruft, but I will let the ACK sit for the rest of today to see if anyone gripes ;-).
John
FWIW: I had to cleanup a few make syntax-check warnings in vbox_impl.c due to not needing extra spaces on preprocessor indents (#define instead of # define):
Whoops indeed - I've forgot to run make syntax-check before final submission. Those were the result of removing wrapping #if..#endif preprocessor directives that were used for old vbox versions which reduced nesting level. Regards, Dawid
participants (2)
-
Dawid Zamirski
-
John Ferlan