Change in vdsm[master]: Memory Hotplug
vdelima at redhat.com
vdelima at redhat.com
Wed Nov 12 12:00:13 UTC 2014
Vitor de Lima has uploaded a new change for review.
Change subject: Memory Hotplug
......................................................................
Memory Hotplug
Introduces a new method to increase the amount of memory of a guest
and exposes it in the XML-RPC and JSON-RPC.
Change-Id: I82bb7d1f7eaaca67b0ceebb4e782ea36541c81c0
Signed-off-by: Vitor de Lima <vdelima at redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/rpc/Bridge.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/virt/vm.py
6 files changed, 61 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/35080/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index 9091644..2022391 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -306,6 +306,9 @@
params = {'vmId': args[0], 'drive': drive}
return self.ExecAndExit(self.s.hotunplugDisk(params))
+ def setAmountOfMemory(self, args):
+ return self.ExecAndExit(self.s.setAmountOfMemory(args[0], args[1]))
+
def setNumberOfCpus(self, args):
return self.ExecAndExit(self.s.setNumberOfCpus(args[0], args[1]))
@@ -2696,6 +2699,11 @@
'<vmId> <spUUID> <sdUUID> <imgUUID> <volUUID> <newSize>',
'Extends the virtual size of a disk'
)),
+ 'setAmountOfMemory': (
+ serv.setAmountOfMemory, (
+ '<vmId> <amountOfMemory>',
+ 'set the amount of memory for a running VM'
+ )),
'setNumberOfCpus': (
serv.setNumberOfCpus, (
'<vmId> <numberOfCpus>',
diff --git a/vdsm/API.py b/vdsm/API.py
index 1ef4b00..3fd81fa 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -467,6 +467,23 @@
return curVm.hotunplugDisk(params)
+ def setAmountOfMemory(self, amountOfMemory):
+
+ if self._UUID is None or amountOfMemory is None:
+ self.log.error('Missing one of required parameters: \
+ vmId: (%s), amountOfMemory: (%s)', self._UUID, amountOfMemory)
+ return {'status': {'code': errCode['MissParam']['status']['code'],
+ 'message': 'Missing one of required '
+ 'parameters: vmId, amountOfMemory'}}
+
+ try:
+ curVm = self._cif.vmContainer[self._UUID]
+ except KeyError:
+ self.log.warning("vm %s doesn't exist", self._UUID)
+ return errCode['noVM']
+
+ return curVm.setAmountOfMemory(int(amountOfMemory))
+
def setNumberOfCpus(self, numberOfCpus):
if self._UUID is None or numberOfCpus is None:
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 0164691..25f35e6 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -427,6 +427,10 @@
vm = API.VM(vmId)
return vm.updateDevice(params)
+ def vmSetAmountOfMemory(self, vmId, amountOfMemory):
+ vm = API.VM(vmId)
+ return vm.setAmountOfMemory(amountOfMemory)
+
def vmSetNumberOfCpus(self, vmId, numberOfCpus):
vm = API.VM(vmId)
return vm.setNumberOfCpus(numberOfCpus)
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index f894758..465a3ac 100644
--- a/vdsm/rpc/Bridge.py
+++ b/vdsm/rpc/Bridge.py
@@ -451,6 +451,7 @@
'VM_hotunplugNic': {'ret': 'vmList'},
'VM_mergeStatus': {'ret': 'mergeStatus'},
'VM_migrationCreate': {'ret': VM_migrationCreate_Ret},
+ 'VM_setAmountOfMemory': {'ret': 'vmList'},
'VM_setNumberOfCpus': {'ret': 'vmList'},
'VM_getIoTunePolicy': {'ret': 'ioTunePolicyList'},
'VM_updateDevice': {'ret': 'vmList'},
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 624b686..8169c76 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -7772,6 +7772,24 @@
'legality': 'VolumeLegality'}}
##
+# @VM.setAmountOfMemory:
+#
+# Set the amount of memory for a VM
+#
+# @vmID: The UUID of the VM
+#
+# @amountOfMemory: The new amount of memory
+#
+# Returns:
+# The VM definition, as updated
+#
+# Since: ?
+##
+{'command': {'class': 'VM', 'name': 'setAmountOfMemory'},
+ 'data': {'vmID': 'UUID', 'amountOfMemory': 'int'},
+ 'returns': 'VmDefinition'}
+
+##
# @VM.setNumberOfCpus:
#
# Set the number CPUs for a VM
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index eaa609c..5c3b3f1 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -3071,6 +3071,19 @@
params=nic.custom)
return {'status': doneCode, 'vmList': self.status()}
+ def setAmountOfMemory(self, amountOfMemory):
+
+ if self.isMigrating():
+ return errCode['migInProgress']
+
+ self.log.debug("Setting amount of memory to : %s", amountOfMemory)
+
+ # FIXME call libvirt to set the amount of memory
+
+ self.saveState()
+
+ return {'status': doneCode, 'vmList': self.status()}
+
def setNumberOfCpus(self, numberOfCpus):
if self.isMigrating():
--
To view, visit http://gerrit.ovirt.org/35080
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I82bb7d1f7eaaca67b0ceebb4e782ea36541c81c0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vitor de Lima <vdelima at redhat.com>
More information about the vdsm-patches
mailing list