In guest lookup, libvirt domain is instanciated and then a info()
function is called, but it is possible that the guest be removed between
these two operations, raising an exception that is not treated.
This patch fix this issue, catching the exception, logging and returning
the correct error to the request.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
model/vms.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/model/vms.py b/model/vms.py
index 4f5d442..780e578 100644
--- a/model/vms.py
+++ b/model/vms.py
@@ -1272,7 +1272,15 @@ class VMModel(object):
def lookup(self, name):
dom = self.get_vm(name, self.conn)
- info = dom.info()
+ try:
+ # Avoid race condition, where guests may be deleted before below
+ # command.
+ info = dom.info()
+ except libvirt.libvirtError as e:
+ wok_log.error('Operation error while retrieving virtual machine '
+ '"%s" information: %s', name, e.message)
+ raise OperationFailed('KCHVM0009E', {'name': name,
+ 'err': e.message})
state = DOM_STATE_MAP[info[0]]
screenshot = None
# (type, listen, port, passwd, passwdValidTo)
--
2.1.0