use isHvm of template to decide to boot a HVM vm

This commit is contained in:
Frank 2011-06-10 14:35:46 -07:00
parent 379cbc1d55
commit 5f5509ac00
2 changed files with 20 additions and 8 deletions

View File

@ -46,7 +46,7 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
@Override
public <T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm) {
BootloaderType bt = BootloaderType.PyGrub;
if (vm.getBootLoaderType() != null) {
if (vm.getBootLoaderType() == BootloaderType.CD) {
bt = vm.getBootLoaderType();
}
VirtualMachineTO to = toVirtualMachineTO(vm);

View File

@ -2473,13 +2473,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
if (owner.getState() == Account.State.disabled) {
throw new PermissionDeniedException("The owner of " + vm + " is disabled: " + vm.getAccountId());
}
VirtualMachineTemplate template = profile.getTemplate();
if (vm.getIsoId() != null) {
template = _templateDao.findById(vm.getIsoId());
}
if (template != null && template.getFormat() == ImageFormat.ISO && vm.getIsoId() != null) {
String isoPath = null;
String isoPath = null;
VirtualMachineTemplate template = _templateDao.findById(vm.getIsoId());
if (template == null || template.getFormat() != ImageFormat.ISO) {
throw new CloudRuntimeException("Can not find ISO in vm_template table for id " + vm.getIsoId());
}
Pair<String, String> isoPathPair = _storageMgr.getAbsoluteIsoPath(template.getId(), vm.getDataCenterId());
if (isoPathPair == null) {
s_logger.warn("Couldn't get absolute iso path");
@ -2487,6 +2489,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
} else {
isoPath = isoPathPair.first();
}
if (template.isBootable()) {
profile.setBootLoaderType(BootloaderType.CD);
}
@ -2500,12 +2503,21 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
iso.setDeviceId(3);
profile.addDisk(iso);
} else {
VirtualMachineTemplate template = profile.getTemplate();
/* create a iso placeholder */
VolumeTO iso = new VolumeTO(profile.getId(), Volume.Type.ISO, StoragePoolType.ISO, null, template.getName(), null, null, 0, null);
iso.setDeviceId(3);
profile.addDisk(iso);
if (template != null) {
if (template.isRequiresHvm()) {
profile.setBootLoaderType(BootloaderType.HVM);
} else {
profile.setBootLoaderType(BootloaderType.PyGrub);
}
}
}
return true;
}