cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [22/34] git commit: updated refs/heads/ui-restyle to 23093ed
Date Thu, 26 Sep 2013 18:03:23 GMT
kvm upgrade issue from 2.2.14: 1. the uuid passed by mgt server is malformat, libvirt can't
start vm. 2. the template path on primary storage is incorrect, which contains absolute path


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

Branch: refs/heads/ui-restyle
Commit: 0eb3944fc8108b3a8bf161bad692f6f58fb5835b
Parents: 3ddc6da
Author: Edison Su <sudison@gmail.com>
Authored: Fri Aug 30 18:06:08 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Sep 25 16:20:06 2013 -0700

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  | 20 +++++++++++++++++++-
 .../kvm/storage/KVMStorageProcessor.java        |  4 ++++
 .../resource/LibvirtComputingResourceTest.java  | 15 +++++++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb3944f/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 61fe71d..04499d5 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
@@ -3357,10 +3357,28 @@ ServerResource {
         }
     }
 
+    protected  String getUuid(String uuid) {
+        if (uuid == null) {
+            uuid = UUID.randomUUID().toString();
+        } else {
+            try {
+                UUID uuid2 = UUID.fromString(uuid);
+                String uuid3 = uuid2.toString();
+                if (!uuid3.equals(uuid)) {
+                    uuid = UUID.randomUUID().toString();
+                }
+            } catch (IllegalArgumentException e) {
+                uuid = UUID.randomUUID().toString();
+            }
+        }
+        return uuid;
+    }
     protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) {
         LibvirtVMDef vm = new LibvirtVMDef();
         vm.setDomainName(vmTO.getName());
-        vm.setDomUUID(vmTO.getUuid());
+        String uuid = vmTO.getUuid();
+        uuid = getUuid(uuid);
+        vm.setDomUUID(uuid);
         vm.setDomDescription(vmTO.getOs());
 
         GuestDef guest = new GuestDef();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb3944f/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
index 5ed93aa..383d211 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
@@ -289,6 +289,10 @@ public class KVMStorageProcessor implements StorageProcessor {
             if (primaryPool.getType() == StoragePoolType.CLVM) {
                 vol = templateToPrimaryDownload(templatePath, primaryPool);
             } else {
+                if (templatePath.contains("/mnt")) {
+                    //upgrade issue, if the path contains path, need to extract the volume
uuid from path
+                    templatePath = templatePath.substring(templatePath.lastIndexOf(File.separator)
+ 1);
+                }
                 BaseVol = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(),
templatePath);
                 vol = storagePoolMgr.createDiskFromTemplate(BaseVol, UUID.randomUUID().toString(),
BaseVol.getPool());
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0eb3944f/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
index 3640030..d6e8dc2 100644
--- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
+++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
@@ -24,11 +24,13 @@ import com.cloud.template.VirtualMachineTemplate.BootloaderType;
 import com.cloud.utils.Pair;
 import com.cloud.vm.VirtualMachine;
 
+import junit.framework.Assert;
 import org.apache.commons.lang.SystemUtils;
 import org.junit.Assume;
 import org.junit.Test;
 
 import java.util.Random;
+import java.util.UUID;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -195,4 +197,17 @@ public class LibvirtComputingResourceTest {
         Pair<Double, Double> stats = LibvirtComputingResource.getNicStats("lo");
         assertNotNull(stats);
     }
+
+    @Test
+    public void testUUID() {
+        String uuid = "1";
+        LibvirtComputingResource lcr = new LibvirtComputingResource();
+        uuid =lcr.getUuid(uuid);
+        Assert.assertTrue(!uuid.equals("1"));
+
+        String oldUuid = UUID.randomUUID().toString();
+        uuid = oldUuid;
+        uuid = lcr.getUuid(uuid);
+        Assert.assertTrue(uuid.equals(oldUuid));
+    }
 }


Mime
View raw message