virMutexUnlock(&vbox_driver_lock);
}
-static int openSessionForMachine(vboxDriverPtr data, const unsigned char *dom_uuid, vboxIIDUnion *iid,
- IMachine **machine, bool checkflag)
+static int openSessionForMachine(vboxDriverPtr data, const unsigned char *dom_uuid,
+ vboxIIDUnion *iid, IMachine **machine)
{
VBOX_IID_INITIALIZE(iid);
vboxIIDFromUUID(iid, dom_uuid);
- if (!checkflag || gVBoxAPI.getMachineForSession) {
- /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */
- if (NS_FAILED(gVBoxAPI.UIVirtualBox.GetMachine(data->vboxObj, iid, machine))) {
- virReportError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
- return -1;
- }
+
+ /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */
+ if (NS_FAILED(gVBoxAPI.UIVirtualBox.GetMachine(data->vboxObj, iid, machine))) {
+ virReportError(VIR_ERR_NO_DOMAIN, "%s",
+ _("no domain with matching uuid"));
+ return -1;
}
+
return 0;
}
*/
/* Open a Session for the machine */
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, true) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
rc = gVBoxAPI.UISession.OpenExisting(data, &iid, machine);
return vboxDomainDefineXMLFlags(conn, xml, 0);
}
-static void
-detachDevices_common(vboxDriverPtr data, vboxIIDUnion *iidu)
-{
- /* Block for checking if HDD's are attched to VM.
- * considering just IDE bus for now. Also skipped
- * chanel=1 and device=0 (Secondary Master) as currenlty
- * it is allocated to CD/DVD Drive by default.
- *
- * Only do this for VirtualBox 3.x and before. Since
- * VirtualBox 4.0 the Unregister method can do this for use.
- */
- IMachine *machine = NULL;
- PRUnichar *hddcnameUtf16 = NULL;
- nsresult rc;
- char *hddcname;
-
- if (!gVBoxAPI.detachDevicesExplicitly)
- VIR_WARN("This function may not work in current vbox version");
-
- ignore_value(VIR_STRDUP(hddcname, "IDE"));
- VBOX_UTF8_TO_UTF16(hddcname, &hddcnameUtf16);
- VIR_FREE(hddcname);
-
- /* Open a Session for the machine */
- rc = gVBoxAPI.UISession.Open(data, iidu, machine);
- if (NS_SUCCEEDED(rc)) {
- rc = gVBoxAPI.UISession.GetMachine(data->vboxSession, &machine);
- if (NS_SUCCEEDED(rc) && machine) {
- gVBoxAPI.detachDevices(data, machine, hddcnameUtf16);
- gVBoxAPI.UIMachine.SaveSettings(machine);
- }
- gVBoxAPI.UISession.Close(data->vboxSession);
- }
- VBOX_UTF16_FREE(hddcnameUtf16);
-}
-
static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
{
vboxDriverPtr data = dom->conn->privateData;
* VBox, so we can trivially ignore that flag. */
virCheckFlags(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, -1);
vboxIIDFromUUID(&iid, dom->uuid);
- if (gVBoxAPI.detachDevicesExplicitly)
- detachDevices_common(data, &iid);
rc = gVBoxAPI.unregisterMachine(data, &iid, &machine);
DEBUGIID("UUID of machine being undefined", &iid);
if (!data->vboxObj)
return ret;
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
ret = 1;
if (!data->vboxObj)
return ret;
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
ret = 0;
if (!data->vboxObj)
return ret;
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!machine)
if (!data->vboxObj)
return ret;
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!machine)
virCheckFlags(0, -1);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!machine)
virCheckFlags(0, -1);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!machine)
virCheckFlags(0, -1);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!machine)
if (!data->vboxObj)
return ret;
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!machine)
virCheckFlags(0, -1);
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
gVBoxAPI.UIMachine.GetState(machine, &mstate);
return -1;
}
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, true) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
return -1;
rc = gVBoxAPI.UISession.Open(data, &iid, machine);
/* Flags checked by virDomainDefFormat */
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!(def = virDomainDefNew()))
if (dev == NULL)
goto cleanup;
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!machine)
if (dev == NULL)
goto cleanup;
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!machine)
if (!gVBoxAPI.vboxSnapshotRedefine)
VIR_WARN("This function may not work in current version");
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
rc = gVBoxAPI.UIMachine.SaveSettings(machine);
goto cleanup;
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
if (gVBoxAPI.vboxSnapshotRedefine) {
VIR_WARN("This function may not work in current version");
VBOX_IID_INITIALIZE(&snapIid);
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
if (!gVBoxAPI.vboxSnapshotRedefine)
VIR_WARN("This function may not work in current version");
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
virCheckFlags(0, NULL);
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
/* VBox snapshots do not require libvirt to maintain any metadata. */
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS |
VIR_DOMAIN_SNAPSHOT_LIST_METADATA, -1);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) {
virCheckFlags(0, NULL);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!(snapshot = vboxDomainSnapshotGet(data, dom, machine, name)))
virCheckFlags(0, -1);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot);
virCheckFlags(0, NULL);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
virCheckFlags(0, NULL);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot);
virCheckFlags(0, -1);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
virCheckFlags(0, -1);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
/* Check that snapshot exists. If so, there is no metadata. */
virCheckFlags(0, -1);
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
newSnapshot = vboxDomainSnapshotGet(data, dom, machine, snapshot->name);
goto cleanup;
}
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
rc = gVBoxAPI.UIMachine.GetSettingsFilePath(machine, &settingsFilePathUtf16);
if (NS_FAILED(rc)) {
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1);
- if (openSessionForMachine(data, dom->uuid, &domiid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name);
if (!data->vboxObj)
return ret;
- if (!gVBoxAPI.supportScreenshot) {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
- _("virDomainScreenshot don't support for current vbox version"));
- return NULL;
- }
-
virCheckFlags(0, NULL);
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
return NULL;
rc = gVBoxAPI.UIMachine.GetMonitorCount(machine, &max_screen);
keyUpCodes[i] = keyDownCodes[i] + 0x80;
}
- if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
rc = gVBoxAPI.UISession.OpenExisting(data, &iid, machine);
.nodeAllocPages = vboxNodeAllocPages, /* 1.2.9 */
.domainHasManagedSaveImage = vboxDomainHasManagedSaveImage, /* 1.2.13 */
.domainSendKey = vboxDomainSendKey, /* 1.2.15 */
+ .domainScreenshot = vboxDomainScreenshot, /* 0.9.2 */
};
static void updateDriver(void)
* We need to make sure the vboxUniformedAPI is initialized
* before calling this function. */
gVBoxAPI.registerDomainEvent(&vboxCommonDriver);
- if (gVBoxAPI.supportScreenshot)
- vboxCommonDriver.domainScreenshot = vboxDomainScreenshot;
- else
- vboxCommonDriver.domainScreenshot = NULL;
}
virHypervisorDriverPtr vboxGetHypervisorDriver(uint32_t uVersion)