From 00ad536269ef1bbb3c0f09b9b5ef3b4ee9b79c7d Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Tue, 3 Feb 2009 16:05:10 +0000 Subject: [PATCH] KVM: Make GetAllInstancesInfo concurrency-safe Or actually more so. If this function gets called while instances get shut down, it might try to report information on instances which don't exits. Try to fail gracefully if that happens, by just skipping an instance which has disappeared in the meantime. Reviewed-by: iustinp --- lib/hypervisor/hv_kvm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index d14418588..0df7e422d 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -202,7 +202,12 @@ class KVMHypervisor(hv_base.BaseHypervisor): for name in os.listdir(self._PIDS_DIR): filename = "%s/%s" % (self._PIDS_DIR, name) if utils.IsProcessAlive(utils.ReadPidFile(filename)): - data.append(self.GetInstanceInfo(name)) + try: + info = self.GetInstanceInfo(name) + except errors.HypervisorError, err: + continue + if info: + data.append(info) return data -- GitLab