rbd: While converting from RAW to RBD, do not write when there is nothing to 
write


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/aee68f7c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/aee68f7c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/aee68f7c

Branch: refs/heads/rbd-snap-clone
Commit: aee68f7c6fe1e8e34b8a03ba1eca5aee51688d7d
Parents: 32c5779
Author: Wido den Hollander <[email protected]>
Authored: Thu May 16 16:54:55 2013 +0200
Committer: Wido den Hollander <[email protected]>
Committed: Thu May 16 16:54:55 2013 +0200

----------------------------------------------------------------------
 .../kvm/storage/LibvirtStorageAdaptor.java         |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aee68f7c/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 129b45f..4525ac2 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
@@ -959,11 +959,12 @@ public class LibvirtStorageAdaptor implements 
StorageAdaptor {
 
                 int chunkSize = 4194304;
                 int offset = 0;
-                byte[] buf = new byte[chunkSize];
                 s_logger.debug("Reading temporary file " + tmpFile + " into 
RBD image " + name + " in chunks of " + chunkSize + " bytes");
                 while(true) {
+                    byte[] buf = new byte[chunkSize];
+
                     int bytes = bis.read(buf);
-                    if (bytes < 0 ) {
+                    if (bytes <= 0) {
                         break;
                     }
                     image.write(buf, offset, bytes);

Reply via email to