diff options
author | Brian Waldon <bcwaldon@gmail.com> | 2012-02-27 17:37:57 -0800 |
---|---|---|
committer | Brian Waldon <bcwaldon@gmail.com> | 2012-02-27 19:34:36 -0800 |
commit | 44067ba758b378c4c2c2ff88b0d1b7a3c27ac812 (patch) | |
tree | 3981cf82ea5fae17b53a86fda2b2a78e7d4c7b6c /nova | |
parent | f01b9b8dd25d763e652259a0f99264d93661b29f (diff) | |
download | nova-44067ba758b378c4c2c2ff88b0d1b7a3c27ac812.tar.gz |
Call detach_volume when attach fails
* Fixes bug 914974
* Raise exception.DeviceBusy when volume cannot attach
Change-Id: Ie18377ba6acd6226612c70fa209185cc579c2d85
Diffstat (limited to 'nova')
-rw-r--r-- | nova/exception.py | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/connection.py | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/nova/exception.py b/nova/exception.py index 6686175007..e1caf28fe9 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -362,6 +362,10 @@ class InvalidDevicePath(Invalid): message = _("The supplied device path (%(path)s) is invalid.") +class DeviceIsBusy(Invalid): + message = _("The supplied device (%(device)s) is busy.") + + class InvalidCPUInfo(Invalid): message = _("Unacceptable CPU info") + ": %(reason)s" diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index c531c2cc81..83277ea44b 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -472,7 +472,18 @@ class LibvirtConnection(driver.ComputeDriver): if FLAGS.libvirt_type == 'lxc': self._attach_lxc_volume(xml, virt_dom, instance_name) else: - virt_dom.attachDevice(xml) + 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: + raise exception.DeviceIsBusy(device=mount_device) + raise @staticmethod def _get_disk_xml(xml, device): |