|
23 | 23 |
|
24 | 24 | import javax.inject.Inject; |
25 | 25 |
|
26 | | -import org.apache.log4j.Logger; |
27 | | -import org.springframework.stereotype.Component; |
28 | | - |
29 | 26 | import org.apache.cloudstack.context.CallContext; |
30 | 27 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; |
31 | 28 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; |
32 | 29 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; |
33 | 30 | import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
34 | 31 | import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
| 32 | +import org.apache.log4j.Logger; |
| 33 | +import org.springframework.stereotype.Component; |
35 | 34 |
|
36 | 35 | import com.cloud.agent.AgentManager; |
37 | 36 | import com.cloud.agent.api.Answer; |
@@ -362,10 +361,16 @@ public boolean cancelMaintain(DataStore store) { |
362 | 361 | // if the instance is of type user vm, call the user vm manager |
363 | 362 | if (vmInstance.getType().equals(VirtualMachine.Type.User)) { |
364 | 363 | 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 | + } |
369 | 374 | } |
370 | 375 | return true; |
371 | 376 | } catch (Exception e) { |
|
0 commit comments