improve ovmf-tpm xml support

This commit is contained in:
Eric Schultz
2021-10-14 13:23:28 -07:00
parent 74bad30c21
commit db2efa2dbb
3 changed files with 11 additions and 11 deletions
@@ -279,6 +279,7 @@
$pae = ($arch == 'i686') ? '<pae/>' : '';
$loader = '';
$swtpm = '';
if (!empty($domain['ovmf'])) {
if ($domain['ovmf'] == 1) {
if (!is_file('/etc/libvirt/qemu/nvram/'.$uuid.'_VARS-pure-efi.fd')) {
@@ -1049,14 +1049,14 @@
$strUSBMode = 'usb3-qemu';
}
$strOVMF = '0';
if (!empty($lv->domain_get_ovmf($res))) {
if (is_file('/etc/libvirt/qemu/nvram/'.$uuid.'_VARS-pure-efi.fd')) {
$ovmfloader = $lv->domain_get_ovmf($res);
if (strpos($ovmfloader, '_CODE-pure-efi.fd') !== false) {
$strOVMF = '1';
} else if (is_file('/etc/libvirt/qemu/nvram/'.$uuid.'_VARS-pure-efi-tpm.fd')) {
} else if (strpos($ovmfloader, '_CODE-pure-efi-tpm.fd') !== false) {
$strOVMF = '2';
} else {
$strOVMF = '0';
}
}
}
return [
@@ -1148,8 +1148,10 @@
// update parent arrays
if (!$old['devices']['hostdev']) unset($old['devices']['hostdev']);
if (!$new['devices']['hostdev']) unset($new['devices']['hostdev']);
// preserve tpm
if (!$new['devices']['tpm']) unset($old['devices']['tpm']);
// remove existing auto-generated settings
unset($old['cputune']['vcpupin'],$old['devices']['video'],$old['devices']['disk'],$old['devices']['interface'],$old['cpu']['@attributes'],$old['os']['boot']);
unset($old['cputune']['vcpupin'],$old['devices']['video'],$old['devices']['disk'],$old['devices']['interface'],$old['cpu']['@attributes'],$old['os']['boot'],$old['os']['loader'],$old['os']['nvram']);
// set namespace
$new['metadata']['vmtemplate']['@attributes']['xmlns'] = 'unraid';
}
@@ -429,9 +429,6 @@
}
?>
</select>
<?if (!empty($arrConfig['domain']['state'])) {?>
<input type="hidden" name="domain[ovmf]" value="<?=htmlspecialchars($arrConfig['domain']['ovmf'])?>">
<?}?>
</td>
</tr>
</table>
@@ -1389,10 +1386,10 @@ $(function() {
$("#vmform #domain_ovmf").change(function changeBIOSEvent() {
// using OVMF - disable vmvga vnc option
if ($(this).val() == '1' && $("#vmform #vncmodel").val() == 'vmvga') {
if ($(this).val() != '0' && $("#vmform #vncmodel").val() == 'vmvga') {
$("#vmform #vncmodel").val('qxl');
}
$("#vmform #vncmodel option[value='vmvga']").prop('disabled', ($(this).val() == '1'));
$("#vmform #vncmodel option[value='vmvga']").prop('disabled', ($(this).val() != '0'));
}).change(); // fire event now
$("#vmform").on("spawn_section", function spawnSectionEvent(evt, section, sectiondata) {