---
src/vbox/vbox_common.c | 54 ++++++++++++++++++++++++++++++++++++++
src/vbox/vbox_tmpl.c | 57 -----------------------------------------
src/vbox/vbox_uniformed_api.h | 1 +
3 files changed, 55 insertions(+), 57 deletions(-)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 102500a..b457c00 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -2615,3 +2615,57 @@ char *vboxDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) {
ignore_value(VIR_STRDUP(osType, "hvm"));
return osType;
}
+
+int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory)
+{
+ VBOX_OBJECT_CHECK(dom->conn, int, -1);
+ IMachine *machine = NULL;
+ vboxIIDUnion iid;
+ PRUint32 state;
+ PRBool isAccessible = PR_FALSE;
+ nsresult rc;
+
+ 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",
+ _("memory size can't be changed unless domain is powered
down"));
+ goto cleanup;
+ }
+
+ rc = gVBoxAPI.UISession.Open(data, &iid, machine);
+ if (NS_FAILED(rc))
+ goto cleanup;
+
+ rc = gVBoxAPI.UISession.GetMachine(data->vboxSession, &machine);
+ if (NS_SUCCEEDED(rc) && machine) {
+
+ rc = gVBoxAPI.UIMachine.SetMemorySize(machine,
+ VIR_DIV_UP(memory, 1024));
+ if (NS_SUCCEEDED(rc)) {
+ gVBoxAPI.UIMachine.SaveSettings(machine);
+ ret = 0;
+ } else {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("could not set the memory size of the "
+ "domain to: %lu Kb, rc=%08x"),
+ memory, (unsigned)rc);
+ }
+ }
+ 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 58f921a..2cb564e 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -932,63 +932,6 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar
*utf16,
return result;
}
-static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory)
-{
- VBOX_OBJECT_CHECK(dom->conn, int, -1);
- IMachine *machine = NULL;
- vboxIID iid = VBOX_IID_INITIALIZER;
- PRUint32 state = MachineState_Null;
- PRBool isAccessible = PR_FALSE;
- nsresult rc;
-
- 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",
- _("memory size can't be changed unless domain is
powered down"));
- goto cleanup;
- }
-
- rc = VBOX_SESSION_OPEN(iid.value, machine);
- if (NS_SUCCEEDED(rc)) {
- rc = data->vboxSession->vtbl->GetMachine(data->vboxSession,
&machine);
- if (NS_SUCCEEDED(rc) && machine) {
-
- rc = machine->vtbl->SetMemorySize(machine,
- VIR_DIV_UP(memory, 1024));
- if (NS_SUCCEEDED(rc)) {
- machine->vtbl->SaveSettings(machine);
- ret = 0;
- } else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("could not set the memory size of the "
- "domain to: %lu Kb, rc=%08x"),
- memory, (unsigned)rc);
- }
- }
- VBOX_SESSION_CLOSE();
- }
- }
-
- cleanup:
- VBOX_RELEASE(machine);
- vboxIIDUnalloc(&iid);
- return ret;
-}
-
static virDomainState vboxConvertState(enum MachineState state)
{
switch (state) {
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 31a0e45..bc76904 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -430,6 +430,7 @@ int vboxDomainReboot(virDomainPtr dom, unsigned int flags);
int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags);
int vboxDomainDestroy(virDomainPtr dom);
char *vboxDomainGetOSType(virDomainPtr dom);
+int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory);
/* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
--
1.7.9.5