提交 f2f70c21 编写于 作者: D Dawid Zamirski 提交者: John Ferlan

vbox: remove code dealing with oldMediumInterface

* 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.
上级 1d963578
......@@ -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) {
}
......
......@@ -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;
......
......@@ -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 */
}
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册