From 139c240c1372208a9a01fe6486f3de4cac804a8c Mon Sep 17 00:00:00 2001 From: Dimitris Aragiorgis Date: Thu, 10 Oct 2013 17:03:47 +0300 Subject: [PATCH] Add finally: mosock.close() in _PassFds Signed-off-by: Dimitris Aragiorgis --- lib/hypervisor/hv_kvm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index d19aa9f..6328534 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -2056,14 +2056,16 @@ class KVMHypervisor(hv_base.BaseHypervisor): """ # TODO: factor out code related to unix sockets. # squash common parts between monitor and qmp - monsock = MonitorSocket(self._InstanceMonitor(instance.name)) - monsock.connect() kvm_devid = _GenerateDeviceKVMId(constants.HOTPLUG_TARGET_NIC, nic) command = "getfd %s\n" % kvm_devid fds = [fd] logging.info("%s", fds) - fdsend.sendfds(monsock.sock, command, fds=fds) - monsock.close() + try: + monsock = MonitorSocket(self._InstanceMonitor(instance.name)) + monsock.connect() + fdsend.sendfds(monsock.sock, command, fds=fds) + finally: + monsock.close() @classmethod def _ParseKVMVersion(cls, text): -- 1.7.10.4