File tree Expand file tree Collapse file tree
kvmagent/kvmagent/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments