rbd: Return null when the copy of the disk failed This makes sure we stop if the copy fails
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/32c57790 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/32c57790 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/32c57790 Branch: refs/heads/rbd-snap-clone Commit: 32c577902aa9a7a086946f162f12684ed1f8191d Parents: 6261de0 Author: Wido den Hollander <[email protected]> Authored: Thu May 16 13:31:12 2013 +0200 Committer: Wido den Hollander <[email protected]> Committed: Thu May 16 13:37:24 2013 +0200 ---------------------------------------------------------------------- .../kvm/storage/LibvirtStorageAdaptor.java | 16 +++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/32c57790/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java index c147fab..129b45f 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java @@ -802,8 +802,10 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } } catch (RadosException e) { s_logger.error("Failed to perform a RADOS action on the Ceph cluster, the error was: " + e.getMessage()); + disk = null; } catch (RbdException e) { s_logger.error("Failed to perform a RBD action on the Ceph cluster, the error was: " + e.getMessage()); + disk = null; } } } @@ -811,6 +813,11 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { s_logger.error("Failed to create " + disk.getPath() + " due to a failed executing of qemu-img: " + e.getMessage()); } + + if (disk == null) { + throw new CloudRuntimeException("Failed to create " + disk.getPath() + " from template " + template.getName()); + } + return disk; } @@ -977,12 +984,16 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } catch (QemuImgException e) { s_logger.error("Failed to do a temp convert from " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + e.getMessage()); + newDisk = null; } catch (RadosException e) { s_logger.error("A Ceph RADOS operation failed (" + e.getReturnValue() + "). The error was: " + e.getMessage()); + newDisk = null; } catch (RbdException e) { s_logger.error("A Ceph RBD operation failed (" + e.getReturnValue() + "). The error was: " + e.getMessage()); + newDisk = null; } catch (IOException e) { s_logger.error("Failed reading the temporary file during the conversion to RBD: " + e.getMessage()); + newDisk = null; } } else { @@ -1008,9 +1019,14 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } catch (QemuImgException e) { s_logger.error("Failed to convert " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + e.getMessage()); + newDisk = null; } } + if (newDisk == null) { + throw new CloudRuntimeException("Failed to copy " + disk.getPath() + " to " + name); + } + return newDisk; }
