Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef.WatchDogAction;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.WatchDogDef.WatchDogModel;
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestDef;

public class LibvirtDomainXMLParser {
protected Logger logger = LogManager.getLogger(getClass());
Expand All @@ -63,6 +64,8 @@ public class LibvirtDomainXMLParser {
private LibvirtVMDef.CpuTuneDef cpuTuneDef;
private LibvirtVMDef.CpuModeDef cpuModeDef;
private String name;
private GuestDef.BootType bootType;
private GuestDef.BootMode bootMode;

public boolean parseDomainXML(String domXML) {
DocumentBuilder builder;
Expand Down Expand Up @@ -516,6 +519,14 @@ public LibvirtVMDef.CpuModeDef getCpuModeDef() {
return cpuModeDef;
}

public GuestDef.BootType getBootType() {
return bootType;
}

public GuestDef.BootMode getBootMode() {
return bootMode;
}

private void extractCpuTuneDef(final Element rootElement) {
NodeList cpuTunesList = rootElement.getElementsByTagName("cputune");
if (cpuTunesList.getLength() > 0) {
Expand Down Expand Up @@ -569,4 +580,29 @@ private void extractCpuModeDef(final Element rootElement){
}
}
}

private void extractBootDef(final Element rootElement) {
Element osElement = (Element) rootElement.getElementsByTagName("os").item(0);
if (osElement != null) {
NodeList loaderList = osElement.getElementsByTagName("loader");
if (loaderList.getLength() > 0) {
Element loader = (Element) loaderList.item(0);
String type = loader.getAttribute("type");
String secure = loader.getAttribute("secure");
if ("pflash".equalsIgnoreCase(type) || loader.getTextContent().toLowerCase().contains("uefi")) {
bootType = GuestDef.BootType.UEFI;
} else {
bootType = GuestDef.BootType.BIOS;
}
if ("yes".equalsIgnoreCase(secure)) {
bootMode = GuestDef.BootMode.SECURE;
} else {
bootMode = GuestDef.BootMode.LEGACY;
}
} else {
bootType = GuestDef.BootType.BIOS;
bootMode = GuestDef.BootMode.LEGACY;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public String toString() {
}
}

enum BootType {
public enum BootType {
UEFI("UEFI"), BIOS("BIOS");

String _type;
Expand All @@ -80,7 +80,7 @@ public String toString() {
}
}

enum BootMode {
public enum BootMode {
LEGACY("LEGACY"), SECURE("SECURE");

String _mode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ private UnmanagedInstanceTO getUnmanagedInstance(LibvirtComputingResource libvir
instance.setNics(getUnmanagedInstanceNics(parser.getInterfaces()));
instance.setDisks(getUnmanagedInstanceDisks(parser.getDisks(),libvirtComputingResource, conn, domain.getName()));
instance.setVncPassword(getFormattedVncPassword(parser.getVncPasswd()));
if (parser.getBootType() != null) {
instance.setBootType(parser.getBootType().toString());
}
if (parser.getBootMode() != null) {
instance.setBootMode(parser.getBootMode().toString());
}

return instance;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,9 @@ private UserVm importVirtualMachineInternal(final UnmanagedInstanceTO unmanagedI
allDetails.put(VmDetailConstants.CPU_SPEED, String.valueOf(validatedServiceOffering.getSpeed()));
}
}
if (!template.isDeployAsIs() && unmanagedInstance.getBootType() != null) {
allDetails.put(unmanagedInstance.getBootType(), unmanagedInstance.getBootMode());
}

if (!migrateAllowed && host != null && !hostSupportsServiceOfferingAndTemplate(host, validatedServiceOffering, template)) {
throw new InvalidParameterValueException(String.format("Service offering: %s or template: %s is not compatible with host: %s of unmanaged VM: %s", serviceOffering.getUuid(), template.getUuid(), host.getUuid(), instanceName));
Expand Down
Loading