Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward de04881da -> 146867eb0


CLOUDSTACK-6919: don't attempt to restart user vms having no Root volume 
attached


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

Branch: refs/heads/4.4-forward
Commit: 146867eb071bae6334bb7b902a4c9319c33b5a1f
Parents: de04881
Author: Alena Prokharchyk <[email protected]>
Authored: Mon Jun 16 14:57:02 2014 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Mon Jun 16 14:59:12 2014 -0700

----------------------------------------------------------------------
 .../cloud/storage/StoragePoolAutomationImpl.java | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/146867eb/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StoragePoolAutomationImpl.java 
b/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
index 8becd75..8ff759d 100644
--- a/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
+++ b/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
@@ -23,15 +23,14 @@ import java.util.List;
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import 
org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
@@ -362,10 +361,16 @@ public class StoragePoolAutomationImpl implements 
StoragePoolAutomation {
                 // if the instance is of type user vm, call the user vm manager
                 if (vmInstance.getType().equals(VirtualMachine.Type.User)) {
                     UserVmVO userVm = userVmDao.findById(vmInstance.getId());
-
-                    vmMgr.advanceStart(userVm.getUuid(), null, null);          
              // update work queue
-                    work.setStartedAfterMaintenance(true);
-                    _storagePoolWorkDao.update(work.getId(), work);
+                    // check if the vm has a root volume. If not, remove the 
item from the queue, the vm should be
+                    // started only when it has at least one root volume 
attached to it
+                    // don't allow to start vm that doesn't have a root volume
+                    if (volumeDao.findByInstanceAndType(work.getId(), 
Volume.Type.ROOT).isEmpty()) {
+                        _storagePoolWorkDao.remove(work.getId());
+                    } else {
+                        vmMgr.advanceStart(userVm.getUuid(), null, null);
+                        work.setStartedAfterMaintenance(true);
+                        _storagePoolWorkDao.update(work.getId(), work);
+                    }
                 }
                 return true;
             } catch (Exception e) {

Reply via email to