Skip to content

Commit 24b9545

Browse files
author
gitlab
committed
Merge branch 'fix-9604@@2' into 'master'
Double check the existence of the KVM process See merge request !850
2 parents 5210ef2 + d2a4257 commit 24b9545

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

kvmagent/kvmagent/plugins/vm_plugin.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,13 @@ def start_vm(self, req):
30043004
rsp.success = False
30053005
return jsonobject.dumps(rsp)
30063006

3007+
def get_vm_stat_with_ps(uuid):
3008+
"""In case libvirtd is stopped or misbehaved"""
3009+
ret = shell.run("ps x | grep -w qemu | grep -v grep | grep -w -q %s" % uuid)
3010+
if ret != 0:
3011+
return Vm.VM_STATE_SHUTDOWN
3012+
return Vm.VM_STATE_RUNNING
3013+
30073014
@kvmagent.replyerror
30083015
def check_vm_state(self, req):
30093016
cmd = jsonobject.loads(req[http.REQUEST_BODY])
@@ -3012,7 +3019,7 @@ def check_vm_state(self, req):
30123019
for uuid in cmd.vmUuids:
30133020
s = states.get(uuid)
30143021
if not s:
3015-
s = Vm.VM_STATE_SHUTDOWN
3022+
s = get_vm_stat_with_ps(uuid)
30163023
rsp.states[uuid] = s
30173024
return jsonobject.dumps(rsp)
30183025

0 commit comments

Comments
 (0)