From 4810269ef648348bbc7ef9113d4e7faf47b15c55 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 25 Jul 2012 10:33:16 -0700 Subject: Fix exception handling in libvirt attach_volume() Currently, the real reason for a failure is dropped when attempting to unroll the volume connection (with the exception of when it is VIR_ERR_OPERATION_FAILED). This change uses save_and_reraise_exception() to correct that so that the actual reason for failure gets logged. Fixes bug 1029463 Change-Id: Id47db565c4fb5a88d1a263600b41706dd3419726 --- nova/virt/libvirt/driver.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index f0ffa895c..7c8dfae47 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -631,15 +631,18 @@ class LibvirtDriver(driver.ComputeDriver): try: virt_dom.attachDevice(conf.to_xml()) except Exception, ex: - self.volume_driver_method('disconnect_volume', - connection_info, - mount_device) - if isinstance(ex, libvirt.libvirtError): errcode = ex.get_error_code() if errcode == libvirt.VIR_ERR_OPERATION_FAILED: + self.volume_driver_method('disconnect_volume', + connection_info, + mount_device) raise exception.DeviceIsBusy(device=mount_device) - raise + + with excutils.save_and_reraise_exception(): + self.volume_driver_method('disconnect_volume', + connection_info, + mount_device) # TODO(danms) once libvirt has support for LXC hotplug, # replace this re-define with use of the -- cgit