mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
vbox: Make CreateHardDisk support all vbox versions
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.
This commit is contained in:
parent
fc41e00391
commit
382e655d16
@ -5115,10 +5115,10 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
|||||||
if (virAsprintf(&newLocationUtf8, "%sfakedisk-%d.vdi", machineLocationPath, it) < 0)
|
if (virAsprintf(&newLocationUtf8, "%sfakedisk-%d.vdi", machineLocationPath, it) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation);
|
VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation);
|
||||||
rc = gVBoxAPI.UIVirtualBox.CreateHardDiskMedium(data->vboxObj,
|
rc = gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj,
|
||||||
formatUtf16,
|
formatUtf16,
|
||||||
newLocation,
|
newLocation,
|
||||||
&newMedium);
|
&newMedium);
|
||||||
VBOX_UTF16_FREE(newLocation);
|
VBOX_UTF16_FREE(newLocation);
|
||||||
VBOX_UTF16_FREE(formatUtf16);
|
VBOX_UTF16_FREE(formatUtf16);
|
||||||
if (NS_FAILED(rc)) {
|
if (NS_FAILED(rc)) {
|
||||||
@ -6877,10 +6877,10 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
|||||||
machineLocationPath, def->parent, it) < 0)
|
machineLocationPath, def->parent, it) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation);
|
VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation);
|
||||||
rc = gVBoxAPI.UIVirtualBox.CreateHardDiskMedium(data->vboxObj,
|
rc = gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj,
|
||||||
formatUtf16,
|
formatUtf16,
|
||||||
newLocation,
|
newLocation,
|
||||||
&newMedium);
|
&newMedium);
|
||||||
if (NS_FAILED(rc)) {
|
if (NS_FAILED(rc)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unable to create HardDisk, rc=%08x"),
|
_("Unable to create HardDisk, rc=%08x"),
|
||||||
|
@ -3456,17 +3456,13 @@ _virtualboxCreateMachine(vboxGlobalData *data, virDomainDefPtr def, IMachine **m
|
|||||||
}
|
}
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
_virtualboxCreateHardDiskMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED,
|
_virtualboxCreateHardDisk(IVirtualBox *vboxObj, PRUnichar *format,
|
||||||
PRUnichar *format ATTRIBUTE_UNUSED,
|
PRUnichar *location, IHardDisk **hardDisk)
|
||||||
PRUnichar *location ATTRIBUTE_UNUSED,
|
|
||||||
IMedium **medium ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
#if VBOX_API_VERSION < 3001000
|
/* In vbox 2.2 and 3.0, this function will create a IHardDisk object.
|
||||||
vboxUnsupported();
|
* In vbox 3.1 and later, this function will create a IMedium object.
|
||||||
return 0;
|
*/
|
||||||
#else /* VBOX_API_VERSION >= 3001000 */
|
return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, hardDisk);
|
||||||
return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, medium);
|
|
||||||
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
@ -5209,7 +5205,7 @@ static vboxUniformedIVirtualBox _UIVirtualBox = {
|
|||||||
.GetSystemProperties = _virtualboxGetSystemProperties,
|
.GetSystemProperties = _virtualboxGetSystemProperties,
|
||||||
.GetHost = _virtualboxGetHost,
|
.GetHost = _virtualboxGetHost,
|
||||||
.CreateMachine = _virtualboxCreateMachine,
|
.CreateMachine = _virtualboxCreateMachine,
|
||||||
.CreateHardDiskMedium = _virtualboxCreateHardDiskMedium,
|
.CreateHardDisk = _virtualboxCreateHardDisk,
|
||||||
.RegisterMachine = _virtualboxRegisterMachine,
|
.RegisterMachine = _virtualboxRegisterMachine,
|
||||||
.FindHardDisk = _virtualboxFindHardDisk,
|
.FindHardDisk = _virtualboxFindHardDisk,
|
||||||
.OpenMedium = _virtualboxOpenMedium,
|
.OpenMedium = _virtualboxOpenMedium,
|
||||||
|
@ -194,7 +194,7 @@ typedef struct {
|
|||||||
nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties);
|
nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties);
|
||||||
nsresult (*GetHost)(IVirtualBox *vboxObj, IHost **host);
|
nsresult (*GetHost)(IVirtualBox *vboxObj, IHost **host);
|
||||||
nsresult (*CreateMachine)(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr);
|
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 (*RegisterMachine)(IVirtualBox *vboxObj, IMachine *machine);
|
||||||
nsresult (*FindHardDisk)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType,
|
nsresult (*FindHardDisk)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType,
|
||||||
PRUint32 accessMode, IHardDisk **hardDisk);
|
PRUint32 accessMode, IHardDisk **hardDisk);
|
||||||
|
Loading…
Reference in New Issue
Block a user