From: ryan woodsmall <rwoodsmall@xxxxxxxxx> --- src/vbox/vbox_tmpl.c | 90 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 80 insertions(+), 10 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index d37888c..5bef956 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -72,6 +72,8 @@ # include "vbox_CAPI_v4_0.h" #elif VBOX_API_VERSION == 4001 # include "vbox_CAPI_v4_1.h" +#elif VBOX_API_VERSION == 4002 +# include "vbox_CAPI_v4_2.h" #else # error "Unsupport VBOX_API_VERSION" #endif @@ -4178,9 +4180,12 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) continue; } -# if VBOX_API_VERSION >= 4000 +# if VBOX_API_VERSION >= 4000 && VBOX_API_VERSION < 4002 data->vboxObj->vtbl->FindMedium(data->vboxObj, mediumFileUtf16, deviceType, &medium); +# elif VBOX_API_VERSION >= 4002 + data->vboxObj->vtbl->OpenMedium(data->vboxObj, mediumFileUtf16, + deviceType, accessMode, PR_FALSE, &medium); # endif if (!medium) { @@ -4920,7 +4925,11 @@ vboxAttachUSB(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) machine->vtbl->GetUSBController(machine, &USBController); if (USBController) { USBController->vtbl->SetEnabled(USBController, 1); +#if VBOX_API_VERSION < 4002 USBController->vtbl->SetEnabledEhci(USBController, 1); +#else + USBController->vtbl->SetEnabledEHCI(USBController, 1); +#endif for (i = 0; i < def->nhostdevs; i++) { if (def->hostdevs[i]->mode == @@ -5025,10 +5034,18 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { vboxIID mchiid = VBOX_IID_INITIALIZER; virDomainDefPtr def = NULL; PRUnichar *machineNameUtf16 = NULL; -#if VBOX_API_VERSION >= 3002 +#if VBOX_API_VERSION >= 3002 && VBOX_API_VERSION < 4002 PRBool override = PR_FALSE; #endif nsresult rc; + char uuidstr[VIR_UUID_STRING_BUFLEN]; +#if VBOX_API_VERSION >= 4002 + const char *flagsUUIDPrefix = "UUID="; + const char *flagsForceOverwrite = "forceOverwrite=0"; + const char *flagsSeparator = ","; + char createFlags[strlen(flagsUUIDPrefix) + VIR_UUID_STRING_BUFLEN + strlen(flagsSeparator) + strlen(flagsForceOverwrite) + 1]; + PRUnichar *createFlagsUtf16 = NULL; +#endif if (!(def = virDomainDefParseString(xml, data->caps, data->xmlopt, 1 << VIR_DOMAIN_VIRT_VBOX, @@ -5038,6 +5055,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { VBOX_UTF8_TO_UTF16(def->name, &machineNameUtf16); vboxIIDFromUUID(&iid, def->uuid); + virUUIDFormat(def->uuid, uuidstr); + #if VBOX_API_VERSION < 3002 rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj, machineNameUtf16, @@ -5053,7 +5072,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { iid.value, override, &machine); -#else /* VBOX_API_VERSION >= 4000 */ +#elif VBOX_API_VERSION >= 4000 && VBOX_API_VERSION < 4002 rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj, NULL, machineNameUtf16, @@ -5061,7 +5080,23 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { iid.value, override, &machine); -#endif /* VBOX_API_VERSION >= 4000 */ +#else /* VBOX_API_VERSION >= 4002 */ + snprintf(createFlags, sizeof(createFlags), "%s%s%s%s", + flagsUUIDPrefix, + uuidstr, + flagsSeparator, + flagsForceOverwrite + ); + VBOX_UTF8_TO_UTF16(createFlags, &createFlagsUtf16); + rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj, + NULL, + machineNameUtf16, + 0, + nsnull, + nsnull, + createFlagsUtf16, + &machine); +#endif /* VBOX_API_VERSION >= 4002 */ VBOX_UTF16_FREE(machineNameUtf16); if (NS_FAILED(rc)) { @@ -7845,15 +7880,26 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char * * IP and enables the interface so even if the dhcpserver is not * started the interface is still up and running */ +#if VBOX_API_VERSION < 4002 networkInterface->vtbl->EnableStaticIpConfig(networkInterface, ipAddressUtf16, networkMaskUtf16); +#else + networkInterface->vtbl->EnableStaticIPConfig(networkInterface, + ipAddressUtf16, + networkMaskUtf16); +#endif VBOX_UTF16_FREE(ipAddressUtf16); VBOX_UTF16_FREE(networkMaskUtf16); } else { +#if VBOX_API_VERSION < 4002 networkInterface->vtbl->EnableDynamicIpConfig(networkInterface); networkInterface->vtbl->DhcpRediscover(networkInterface); +#else + networkInterface->vtbl->EnableDynamicIPConfig(networkInterface); + networkInterface->vtbl->DHCPRediscover(networkInterface); +#endif } rc = networkInterface->vtbl->GetId(networkInterface, &vboxnetiid.value); @@ -8451,9 +8497,13 @@ static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char vboxIIDFromUUID(&hddIID, uuid); #if VBOX_API_VERSION < 4000 rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk); -#else /* VBOX_API_VERSION >= 4000 */ +#elif VBOX_API_VERSION >= 4000 && VBOX_API_VERSION < 4002 rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value, DeviceType_HardDisk, &hardDisk); +#else + rc = data->vboxObj->vtbl->OpenMedium(data->vboxObj, hddIID.value, + DeviceType_HardDisk, AccessMode_ReadWrite, + PR_FALSE, &hardDisk); #endif /* VBOX_API_VERSION >= 4000 */ if (NS_SUCCEEDED(rc)) { PRUint32 hddstate; @@ -8508,9 +8558,13 @@ static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const cha #if VBOX_API_VERSION < 4000 rc = data->vboxObj->vtbl->FindHardDisk(data->vboxObj, hddPathUtf16, &hardDisk); -#else /* VBOX_API_VERSION >= 4000 */ +#elif VBOX_API_VERSION >= 4000 && VBOX_API_VERSION < 4002 rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddPathUtf16, DeviceType_HardDisk, &hardDisk); +#else + rc = data->vboxObj->vtbl->OpenMedium(data->vboxObj, hddPathUtf16, + DeviceType_HardDisk, AccessMode_ReadWrite, + PR_FALSE, &hardDisk); #endif /* VBOX_API_VERSION >= 4000 */ if (NS_SUCCEEDED(rc)) { PRUint32 hddstate; @@ -8684,9 +8738,13 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, vboxIIDFromUUID(&hddIID, uuid); #if VBOX_API_VERSION < 4000 rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk); -#else /* VBOX_API_VERSION >= 4000 */ +#elif VBOX_API_VERSION >= 4000 && VBOX_API_VERSION < 4002 rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value, DeviceType_HardDisk, &hardDisk); +#else + rc = data->vboxObj->vtbl->OpenMedium(data->vboxObj, hddIID.value, + DeviceType_HardDisk, AccessMode_ReadWrite, + PR_FALSE, &hardDisk); #endif /* VBOX_API_VERSION >= 4000 */ if (NS_SUCCEEDED(rc)) { PRUint32 hddstate; @@ -8852,9 +8910,13 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info vboxIIDFromUUID(&hddIID, uuid); #if VBOX_API_VERSION < 4000 rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk); -#else /* VBOX_API_VERSION >= 4000 */ +#elif VBOX_API_VERSION >= 4000 && VBOX_API_VERSION < 4002 rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value, DeviceType_HardDisk, &hardDisk); +#else + rc = data->vboxObj->vtbl->OpenMedium(data->vboxObj, hddIID.value, + DeviceType_HardDisk, AccessMode_ReadWrite, + PR_FALSE, &hardDisk); #endif /* VBOX_API_VERSION >= 4000 */ if (NS_SUCCEEDED(rc)) { PRUint32 hddstate; @@ -8922,9 +8984,13 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) vboxIIDFromUUID(&hddIID, uuid); #if VBOX_API_VERSION < 4000 rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk); -#else /* VBOX_API_VERSION >= 4000 */ +#elif VBOX_API_VERSION >= 4000 && VBOX_API_VERSION < 4002 rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value, DeviceType_HardDisk, &hardDisk); +#else + rc = data->vboxObj->vtbl->OpenMedium(data->vboxObj, hddIID.value, + DeviceType_HardDisk, AccessMode_ReadWrite, + PR_FALSE, &hardDisk); #endif /* VBOX_API_VERSION >= 4000 */ if (NS_SUCCEEDED(rc)) { PRUint32 hddstate; @@ -9027,9 +9093,13 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) { vboxIIDFromUUID(&hddIID, uuid); #if VBOX_API_VERSION < 4000 rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk); -#else /* VBOX_API_VERSION >= 4000 */ +#elif VBOX_API_VERSION >= 4000 && VBOX_API_VERSION < 4002 rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value, DeviceType_HardDisk, &hardDisk); +#else + rc = data->vboxObj->vtbl->OpenMedium(data->vboxObj, hddIID.value, + DeviceType_HardDisk, AccessMode_ReadWrite, + PR_FALSE, &hardDisk); #endif /* VBOX_API_VERSION >= 4000 */ if (NS_SUCCEEDED(rc)) { PRUint32 hddstate; -- 1.7.10.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list