Skip to content

Commit 09a97e1

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-6919: don't attempt to restart user vms having no Root volume attached
1 parent 04b1e31 commit 09a97e1

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

server/src/com/cloud/storage/StoragePoolAutomationImpl.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@
2323

2424
import javax.inject.Inject;
2525

26-
import org.apache.log4j.Logger;
27-
import org.springframework.stereotype.Component;
28-
2926
import org.apache.cloudstack.context.CallContext;
3027
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
3128
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
3229
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
3330
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
3431
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
32+
import org.apache.log4j.Logger;
33+
import org.springframework.stereotype.Component;
3534

3635
import com.cloud.agent.AgentManager;
3736
import com.cloud.agent.api.Answer;
@@ -362,10 +361,16 @@ public boolean cancelMaintain(DataStore store) {
362361
// if the instance is of type user vm, call the user vm manager
363362
if (vmInstance.getType().equals(VirtualMachine.Type.User)) {
364363
UserVmVO userVm = userVmDao.findById(vmInstance.getId());
365-
366-
vmMgr.advanceStart(userVm.getUuid(), null, null); // update work queue
367-
work.setStartedAfterMaintenance(true);
368-
_storagePoolWorkDao.update(work.getId(), work);
364+
// check if the vm has a root volume. If not, remove the item from the queue, the vm should be
365+
// started only when it has at least one root volume attached to it
366+
// don't allow to start vm that doesn't have a root volume
367+
if (volumeDao.findByInstanceAndType(work.getId(), Volume.Type.ROOT).isEmpty()) {
368+
_storagePoolWorkDao.remove(work.getId());
369+
} else {
370+
vmMgr.advanceStart(userVm.getUuid(), null, null);
371+
work.setStartedAfterMaintenance(true);
372+
_storagePoolWorkDao.update(work.getId(), work);
373+
}
369374
}
370375
return true;
371376
} catch (Exception e) {

0 commit comments

Comments
 (0)