You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/04/25 16:45:32 UTC

[06/51] [abbrv] git commit: updated refs/heads/marvin_refactor to dbcfc66

in case vm doesn't exist on kvm host, getconnectionbyname will throw exception, need to catch the exception, and return the default connection


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

Branch: refs/heads/marvin_refactor
Commit: 435f4bceb27f7b7bc96ad1ee46f4688b9a971355
Parents: cdd459b
Author: Edison Su <su...@gmail.com>
Authored: Wed Apr 24 10:38:14 2013 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Wed Apr 24 10:39:07 2013 -0700

----------------------------------------------------------------------
 .../hypervisor/kvm/resource/LibvirtConnection.java |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/435f4bce/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java
index 2ad1616..2fc5425 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java
@@ -61,13 +61,19 @@ public class LibvirtConnection {
     static public Connect getConnectionByVmName(String vmName) throws LibvirtException {
         HypervisorType[] hypervisors = new HypervisorType[] {HypervisorType.KVM, Hypervisor.HypervisorType.LXC};
 
+        
         for (HypervisorType hypervisor : hypervisors) {
-          Connect conn = LibvirtConnection.getConnectionByType(hypervisor.toString());
-          if (conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName.getBytes())) != null) {
-             return conn;
-          }
+            try {
+                Connect conn = LibvirtConnection.getConnectionByType(hypervisor.toString());
+                if (conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName.getBytes())) != null) {
+                    return conn;
+                }
+            } catch (Exception e) {
+               s_logger.debug("can't find connection: " + hypervisor.toString() + ", for vm: " + vmName + ", continue");
+            }
         }
 
+        s_logger.debug("can't find which hypervisor the vm used , then use the default hypervisor");
         // return the default connection
         return getConnection();
     }