---
src/vbox/vbox_common.c | 45 +++++++++++++++++++++++
src/vbox/vbox_tmpl.c | 80 ++++++++++-------------------------------
src/vbox/vbox_uniformed_api.h | 2 ++
3 files changed, 65 insertions(+), 62 deletions(-)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 0527fea..aaebc44 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -2553,3 +2553,48 @@ int vboxDomainReboot(virDomainPtr dom, unsigned int flags)
vboxIIDUnalloc(&iid);
return ret;
}
+
+int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags)
+{
+ VBOX_OBJECT_CHECK(dom->conn, int, -1);
+ IMachine *machine = NULL;
+ vboxIIDUnion iid;
+ IConsole *console = NULL;
+ PRUint32 state;
+ PRBool isAccessible = PR_FALSE;
+
+ virCheckFlags(0, -1);
+
+ if (openSessionForMachine(data, dom->uuid, &iid, &machine, false) < 0)
+ goto cleanup;
+
+ if (!machine)
+ goto cleanup;
+
+ gVBoxAPI.UIMachine.GetAccessible(machine, &isAccessible);
+ if (!isAccessible)
+ goto cleanup;
+
+ gVBoxAPI.UIMachine.GetState(machine, &state);
+
+ if (gVBoxAPI.machineStateChecker.PoweredOff(state)) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("machine already powered down"));
+ goto cleanup;
+ }
+
+ gVBoxAPI.UISession.OpenExisting(data, &iid, machine);
+ gVBoxAPI.UISession.GetConsole(data->vboxSession, &console);
+ if (console) {
+ gVBoxAPI.UIConsole.PowerDown(console);
+ VBOX_RELEASE(console);
+ dom->id = -1;
+ ret = 0;
+ }
+ gVBoxAPI.UISession.Close(data->vboxSession);
+
+ cleanup:
+ VBOX_RELEASE(machine);
+ vboxIIDUnalloc(&iid);
+ return ret;
+}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index ef734c9..c3f14be 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -933,68 +933,6 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar
*utf16,
}
static int
-vboxDomainDestroyFlags(virDomainPtr dom,
- unsigned int flags)
-{
- VBOX_OBJECT_CHECK(dom->conn, int, -1);
- IMachine *machine = NULL;
- vboxIID iid = VBOX_IID_INITIALIZER;
- IConsole *console = NULL;
- PRUint32 state = MachineState_Null;
- PRBool isAccessible = PR_FALSE;
- nsresult rc;
-
- virCheckFlags(0, -1);
-
- vboxIIDFromUUID(&iid, dom->uuid);
- rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
- if (NS_FAILED(rc)) {
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching id %d"), dom->id);
- goto cleanup;
- }
-
- if (!machine)
- goto cleanup;
-
- machine->vtbl->GetAccessible(machine, &isAccessible);
- if (isAccessible) {
- machine->vtbl->GetState(machine, &state);
-
- if (state == MachineState_PoweredOff) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("machine already powered down"));
- goto cleanup;
- }
-
- VBOX_SESSION_OPEN_EXISTING(iid.value, machine);
- data->vboxSession->vtbl->GetConsole(data->vboxSession,
&console);
- if (console) {
-
-#if VBOX_API_VERSION == 2002000
- console->vtbl->PowerDown(console);
-#else
- IProgress *progress = NULL;
- console->vtbl->PowerDown(console, &progress);
- if (progress) {
- progress->vtbl->WaitForCompletion(progress, -1);
- VBOX_RELEASE(progress);
- }
-#endif
- VBOX_RELEASE(console);
- dom->id = -1;
- ret = 0;
- }
- VBOX_SESSION_CLOSE();
- }
-
- cleanup:
- VBOX_RELEASE(machine);
- vboxIIDUnalloc(&iid);
- return ret;
-}
-
-static int
vboxDomainDestroy(virDomainPtr dom)
{
return vboxDomainDestroyFlags(dom, 0);
@@ -9849,6 +9787,23 @@ _consolePowerButton(IConsole *console)
}
static nsresult
+_consolePowerDown(IConsole *console)
+{
+ nsresult rc;
+#if VBOX_API_VERSION == 2002000
+ rc = console->vtbl->PowerDown(console);
+#else
+ IProgress *progress = NULL;
+ rc = console->vtbl->PowerDown(console, &progress);
+ if (progress) {
+ rc = progress->vtbl->WaitForCompletion(progress, -1);
+ VBOX_RELEASE(progress);
+ }
+#endif
+ return rc;
+}
+
+static nsresult
_consoleReset(IConsole *console)
{
return console->vtbl->Reset(console);
@@ -10380,6 +10335,7 @@ static vboxUniformedIConsole _UIConsole = {
.Pause = _consolePause,
.Resume = _consoleResume,
.PowerButton = _consolePowerButton,
+ .PowerDown = _consolePowerDown,
.Reset = _consoleReset,
};
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index d5c6fb4..b9c2068 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -240,6 +240,7 @@ typedef struct {
nsresult (*Pause)(IConsole *console);
nsresult (*Resume)(IConsole *console);
nsresult (*PowerButton)(IConsole *console);
+ nsresult (*PowerDown)(IConsole *console);
nsresult (*Reset)(IConsole *console);
} vboxUniformedIConsole;
@@ -426,6 +427,7 @@ int vboxDomainResume(virDomainPtr dom);
int vboxDomainShutdownFlags(virDomainPtr dom, unsigned int flags);
int vboxDomainShutdown(virDomainPtr dom);
int vboxDomainReboot(virDomainPtr dom, unsigned int flags);
+int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags);
/* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
--
1.7.9.5