You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2012/06/15 20:33:56 UTC

git commit: CS-15155 : after system VMs boot up, destroy CD virtual device for System VM when reconnect XenServer host, try to destroy CD virtual device for System VM, this is for upgrade

Updated Branches:
  refs/heads/master 2af678902 -> 5f3e0c578


   CS-15155 : after system VMs boot up, destroy CD virtual device for System VM
               when reconnect XenServer host, try to destroy CD virtual device for System VM, this is for upgrade


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

Branch: refs/heads/master
Commit: 5f3e0c57839d58ac7acca3f7749e885b2280eebd
Parents: 2af6789
Author: anthony <an...@cloud.com>
Authored: Fri Jun 15 11:27:53 2012 -0700
Committer: anthony <an...@cloud.com>
Committed: Fri Jun 15 11:27:53 2012 -0700

----------------------------------------------------------------------
 .../xen/resource/CitrixResourceBase.java           |   32 ++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5f3e0c57/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 121675e..3917242 100644
--- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -1104,6 +1104,27 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         return cdromVBD;
     }
 
+    protected void destroyPatchVbd(Connection conn, String vmName) throws XmlRpcException, XenAPIException {
+        try {
+            if( !vmName.startsWith("r-") && !vmName.startsWith("s-") && !vmName.startsWith("v-") ) {
+                return;
+            }
+            Set<VM> vms = VM.getByNameLabel(conn, vmName);
+            for ( VM vm : vms ) {
+                Set<VBD> vbds = vm.getVBDs(conn);
+                for( VBD vbd : vbds ) {
+                   if (vbd.getType(conn) == Types.VbdType.CD ) {
+                       vbd.eject(conn);
+                       vbd.destroy(conn);
+                       break;
+                   }
+                }
+            }
+        } catch (Exception e) {
+            s_logger.debug("Cannot destory CD-ROM device for VM " + vmName + " due to " + e.toString(), e);
+        }
+    }
+
     protected CheckSshAnswer execute(CheckSshCommand cmd) {
         Connection conn = getConnection();
         String vmName = cmd.getName();
@@ -1119,6 +1140,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             if (result != null) {
                 return new CheckSshAnswer(cmd, "Can not ping System vm " + vmName + "due to:" + result);
             }
+            destroyPatchVbd(conn, vmName);
         } catch (Exception e) {
             return new CheckSshAnswer(cmd, e);
         }
@@ -2683,7 +2705,15 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         callHostPlugin(conn, "vmopsSnapshot", "unmountSnapshotsDir", "dcId", dcId.toString());
 
         setupLinkLocalNetwork(conn);
-
+        // try to destroy CD-ROM device for all system VMs on this host
+        try {
+            Host host = Host.getByUuid(conn, _host.uuid);
+            Set<VM> vms = host.getResidentVMs(conn);
+            for ( VM vm : vms ) {
+                destroyPatchVbd(conn, vm.getNameLabel(conn));
+            }
+        } catch (Exception e) {
+        }
         try {
             boolean result = cleanupHaltedVms(conn);
             if (!result) {