You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2013/05/14 15:58:02 UTC

[43/47] git commit: updated refs/heads/rbd-snap-clone to 30acdb7

Add some comments to the KVM storage code to clarify what it does

Since I also forget this some times


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

Branch: refs/heads/rbd-snap-clone
Commit: efc98977df04179199629d14043ea83af620854c
Parents: 63ee383
Author: Wido den Hollander <wi...@widodh.nl>
Authored: Tue May 14 11:48:23 2013 +0200
Committer: Wido den Hollander <wi...@widodh.nl>
Committed: Tue May 14 15:56:57 2013 +0200

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java     |    7 ++++
 .../kvm/storage/LibvirtStorageAdaptor.java         |   29 ++++++++++++++-
 2 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/efc98977/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index b8c6f09..a80ae37 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1236,6 +1236,13 @@ ServerResource {
     }
 
     private CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
+       /**
+            This method is only used for copying files from Primary Storage TO Secondary Storage
+
+            It COULD also do it the other way around, but the code in the ManagementServerImpl shows
+            that it always sets copyToSecondary to true
+
+         */
         boolean copyToSecondary = cmd.toSecondaryStorage();
         String volumePath = cmd.getVolumePath();
         StorageFilerTO pool = cmd.getPool();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/efc98977/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 41b6401..8f1cd73 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
@@ -643,6 +643,15 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         }
     }
 
+    /**
+     * This function copies a physical disk from Secondary Storage to Primary Storage
+     * or from Primary to Primary Storage
+     *
+     * The first time a template is deployed in Primary Storage it will be copied from
+     * Secondary to Primary.
+     *
+     * If it has been created on Primary Storage, it will be copied on the Primary Storage
+     */
     @Override
     public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
             String name, PhysicalDiskFormat format, long size, KVMStoragePool destPool) {
@@ -701,6 +710,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
                     /**
                      * We have to find out if the source file is in the same RBD pool and has
                      * RBD format 2 before we can do a layering/clone operation on the RBD image
+                     *
+                     * This will be the case when the template is already on Primary Storage and
+                     * we want to copy it
                      */
 
                     if ((srcPool.getSourceHost().equals(destPool.getSourceHost())) && (srcPool.getSourceDir().equals(destPool.getSourceDir()))) {
@@ -790,17 +802,26 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         }
     }
 
+    /**
+     * This copies a volume from Primary Storage to Secondary Storage
+     *
+     * In theory it could also do it the other way around, but the current implementation
+     * in ManagementServerImpl shows that the destPool is always a Secondary Storage Pool
+     */
     @Override
     public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
             KVMStoragePool destPool) {
 
-        /*
+        /**
             With RBD you can't run qemu-img convert with an existing RBD image as destination
             qemu-img will exit with the error that the destination already exists.
             So for RBD we don't create the image, but let qemu-img do that for us.
 
             We then create a KVMPhysicalDisk object that we can return
-        */
+
+            It is however very unlikely that the destPool will be RBD, since it isn't supported
+            for Secondary Storage
+         */
 
         KVMPhysicalDisk newDisk;
         if (destPool.getType() != StoragePoolType.RBD) {
@@ -857,6 +878,10 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
                     destPath));
             destFile.setFormat(destFormat);
         } else {
+            /**
+                We let Qemu-Img do the work here. Although we could work with librbd and have that do the cloning
+                it doesn't benefit us. It's better to keep the current code in place which works
+             */
             srcFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(srcPool.getSourceHost(),
                     srcPool.getSourcePort(),
                     srcPool.getAuthUserName(),