Commit 89da2ff3 authored by Guido Trotter's avatar Guido Trotter
Browse files

kvm: get more accurate info from qmp, if possible


Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent fc84cd5d
......@@ -202,6 +202,8 @@ class QmpConnection:
_FIRST_MESSAGE_KEY = "QMP"
_EVENT_KEY = "event"
_ERROR_KEY = "error"
_RETURN_KEY = RETURN_KEY = "return"
_ACTUAL_KEY = ACTUAL_KEY = "actual"
_ERROR_CLASS_KEY = "class"
_ERROR_DATA_KEY = "data"
_ERROR_DESC_KEY = "desc"
......@@ -916,6 +918,17 @@ class KVMHypervisor(hv_base.BaseHypervisor):
istat = "---b-"
times = "0"
try:
qmp = QmpConnection(self._InstanceQmpMonitor(instance_name))
qmp.connect()
vcpus = len(qmp.Execute("query-cpus")[qmp.RETURN_KEY])
# Will fail if ballooning is not enabled, but we can then just resort to
# the value above.
mem_bytes = qmp.Execute("query-balloon")[qmp.RETURN_KEY][qmp.ACTUAL_KEY]
memory = mem_bytes / 1048576
except errors.HypervisorError:
pass
return (instance_name, pid, memory, vcpus, istat, times)
def GetAllInstancesInfo(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment