The CreateHardDiskMedium only support create HardDisk for medium
type, and it only works when vbox version >= 3.1. This patch make
the function workable with all vbox versions and rename it as
CreateHardDisk.
In vbox 2.2 and 3.0 this function will create a IHardDisk object.
In vbox later than 3.0, this function will create a IMedium object.
---
src/vbox/vbox_common.c | 16 ++++++++--------
src/vbox/vbox_tmpl.c | 18 +++++++-----------
src/vbox/vbox_uniformed_api.h | 2 +-
3 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index cfc73d8..f1ec7f4 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -5071,10 +5071,10 @@ vboxSnapshotRedefine(virDomainPtr dom,
if (virAsprintf(&newLocationUtf8, "%sfakedisk-%d.vdi",
machineLocationPath, it) < 0)
goto cleanup;
VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation);
- rc = gVBoxAPI.UIVirtualBox.CreateHardDiskMedium(data->vboxObj,
- formatUtf16,
- newLocation,
- &newMedium);
+ rc = gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj,
+ formatUtf16,
+ newLocation,
+ &newMedium);
VBOX_UTF16_FREE(newLocation);
VBOX_UTF16_FREE(formatUtf16);
if (NS_FAILED(rc)) {
@@ -6776,10 +6776,10 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr
snapshot)
machineLocationPath, def->parent, it) < 0)
goto cleanup;
VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation);
- rc = gVBoxAPI.UIVirtualBox.CreateHardDiskMedium(data->vboxObj,
- formatUtf16,
- newLocation,
- &newMedium);
+ rc = gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj,
+ formatUtf16,
+ newLocation,
+ &newMedium);
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to create HardDisk, rc=%08x"),
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 03d194b..5aa1677 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -3443,17 +3443,13 @@ _virtualboxCreateMachine(vboxGlobalData *data, virDomainDefPtr
def, IMachine **m
}
static nsresult
-_virtualboxCreateHardDiskMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED,
- PRUnichar *format ATTRIBUTE_UNUSED,
- PRUnichar *location ATTRIBUTE_UNUSED,
- IMedium **medium ATTRIBUTE_UNUSED)
+_virtualboxCreateHardDisk(IVirtualBox *vboxObj, PRUnichar *format,
+ PRUnichar *location, IHardDisk **hardDisk)
{
-#if VBOX_API_VERSION < 3001000
- vboxUnsupported();
- return 0;
-#else /* VBOX_API_VERSION >= 3001000 */
- return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, medium);
-#endif /* VBOX_API_VERSION >= 3001000 */
+ /* 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.
+ */
+ return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, hardDisk);
}
static nsresult
@@ -5195,7 +5191,7 @@ static vboxUniformedIVirtualBox _UIVirtualBox = {
.GetSystemProperties = _virtualboxGetSystemProperties,
.GetHost = _virtualboxGetHost,
.CreateMachine = _virtualboxCreateMachine,
- .CreateHardDiskMedium = _virtualboxCreateHardDiskMedium,
+ .CreateHardDisk = _virtualboxCreateHardDisk,
.RegisterMachine = _virtualboxRegisterMachine,
.FindHardDisk = _virtualboxFindHardDisk,
.OpenMedium = _virtualboxOpenMedium,
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 4843824..8a2a96b 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -194,7 +194,7 @@ typedef struct {
nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties
**systemProperties);
nsresult (*GetHost)(IVirtualBox *vboxObj, IHost **host);
nsresult (*CreateMachine)(vboxGlobalData *data, virDomainDefPtr def, IMachine
**machine, char *uuidstr);
- nsresult (*CreateHardDiskMedium)(IVirtualBox *vboxObj, PRUnichar *format, PRUnichar
*location, IMedium **medium);
+ nsresult (*CreateHardDisk)(IVirtualBox *vboxObj, PRUnichar *format, PRUnichar
*location, IHardDisk **hardDisk);
nsresult (*RegisterMachine)(IVirtualBox *vboxObj, IMachine *machine);
nsresult (*FindHardDisk)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32
deviceType,
PRUint32 accessMode, IHardDisk **hardDisk);
--
1.7.9.5