Skip to content

Commit 3ebcf4f

Browse files
committed
Fix an issue of referring the out-scoped 'vm_uuid'
Signed-off-by: Qun Li <qun.li@zstack.io>
1 parent 4890dbb commit 3ebcf4f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kvmagent/kvmagent/plugins/ha_plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def kill_vm(maxAttempts, mountPaths=None, isFileSystem=None):
4343
logger.debug('vm_in_process_uuid_list:\n' + vm_in_process_uuid_list)
4444

4545
# kill vm's qemu process
46-
vm_pids = []
46+
vm_pids_dict = {}
4747
for vm_uuid in vm_in_process_uuid_list.split('\n'):
4848
vm_uuid = vm_uuid.strip(' \t\n\r')
4949
if not vm_uuid:
@@ -55,9 +55,9 @@ def kill_vm(maxAttempts, mountPaths=None, isFileSystem=None):
5555

5656
vm_pid = shell.call("ps aux | grep qemu-kvm | grep -v grep | awk '/%s/{print $2}'" % vm_uuid)
5757
vm_pid = vm_pid.strip(' \t\n\r')
58-
vm_pids.append(vm_pid)
58+
vm_pids_dict[vm_uuid] = vm_pid
5959

60-
for vm_pid in vm_pids:
60+
for vm_uuid, vm_pid in vm_pids_dict.items():
6161
kill = shell.ShellCmd('kill -9 %s' % vm_pid)
6262
kill(False)
6363
if kill.return_code == 0:
@@ -66,7 +66,7 @@ def kill_vm(maxAttempts, mountPaths=None, isFileSystem=None):
6666
else:
6767
logger.warn('failed to kill the vm[uuid:%s, pid:%s] %s' % (vm_uuid, vm_pid, kill.stderr))
6868

69-
return vm_pids
69+
return vm_pids_dict.values()
7070

7171

7272
def mount_path_is_nfs(mount_path):

0 commit comments

Comments
 (0)