Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
Signed-off-by: Aaron Rosen <arosen@nicira.com>
  • Loading branch information
kk7ds authored and aaronorosen committed Aug 23, 2012
1 parent 272b98d commit 86fb736
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions Authors
Expand Up @@ -39,6 +39,7 @@ Cole Robinson <crobinso@redhat.com>
Cor Cornelisse <cor@hyves.nl>
Cory Wright <corywright@gmail.com>
Dan Prince <dprince@redhat.com>
Dan Smith <danms@us.ibm.com>
Dan Wendlandt <dan@nicira.com>
Daniel P. Berrange <berrange@redhat.com>
Dave Lapsley <dlapsley@nicira.com>
Expand Down
12 changes: 7 additions & 5 deletions nova/virt/libvirt/connection.py
Expand Up @@ -537,15 +537,17 @@ def attach_volume(self, connection_info, instance_name, mountpoint):
try:
virt_dom.attachDevice(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 utils.save_and_reraise_exception():
self.volume_driver_method('disconnect_volume',
connection_info,
mount_device)

@staticmethod
def _get_disk_xml(xml, device):
Expand Down

0 comments on commit 86fb736

Please sign in to comment.