diff --git a/ccnode/hypervisor/__init__.py b/ccnode/hypervisor/__init__.py index da794060ac8855561ea392389c6126f8ca44b875..52ad80c0c32ad9af88929d4fe9f8304a319d2be6 100644 --- a/ccnode/hypervisor/__init__.py +++ b/ccnode/hypervisor/__init__.py @@ -200,9 +200,13 @@ class Handler(HostHandler): logger.debug('VM destroy %s', name) try: self.hypervisor.domains[name].destroy() - except libvirt.libvirtError: - logger.exception('Error while destroying VM %s', name) - raise + except libvirt.libvirtError as exc: + # Libvirt raises exception 'domain is not running' event is domain + # is running, might be a bug in libvirt + if 'domain is not running' not in str(exc) or ( + self.hypervisor.domains[name].state != 'running'): + logger.exception('Error while destroying VM %s', name) + raise except KeyError: msg = 'Cannot destroy VM %s because it is not defined' % name logger.error(msg)