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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list