Fix UUID change in xml view

This commit is contained in:
SimonFair
2023-11-24 14:23:18 +00:00
parent ec3b1e1f2b
commit 9c85e6132f
2 changed files with 20 additions and 1 deletions

View File

@@ -1966,6 +1966,20 @@
return false;
}
function nvram_rename($uuid,$newuuid) {
// rename backup OVMF VARS if this domain had them
if (is_file('/etc/libvirt/qemu/nvram/'.$uuid.'_VARS-pure-efi.fd')) {
rename('/etc/libvirt/qemu/nvram/'.$uuid.'_VARS-pure-efi.fd_backup', '/etc/libvirt/qemu/nvram/'.$newuuid.'_VARS-pure-efi.fd');
return true;
}
if (is_file('/etc/libvirt/qemu/nvram/'.$uuid.'_VARS-pure-efi-tpm.fd')) {
rename('/etc/libvirt/qemu/nvram/'.$uuid.'_VARS-pure-efi-tpm.fd_backup', '/etc/libvirt/qemu/nvram/'.$newuuid.'_VARS-pure-efi-tpm.fd');
return true;
}
return false;
}
function nvram_create_snapshot($uuid,$snapshotname) {
// snapshot backup OVMF VARS if this domain had them
if (is_file('/etc/libvirt/qemu/nvram/'.$uuid.'_VARS-pure-efi.fd')) {

View File

@@ -217,11 +217,15 @@
}
}
}
$newuuid = $uuid;
$olduuid = $uuid;
// construct updated config
if (isset($_POST['xmldesc'])) {
// XML view
$xml = $_POST['xmldesc'];
$arrExistingConfig = custom::createArray('domain',$xml);
$newuuid = $arrExistingConfig['uuid'] ;
$xml = str_replace($olduuid,$newuuid,$xml);
} else {
// form view
if ($error = create_vdisk($_POST) === false) {
@@ -240,6 +244,7 @@
$lv->nvram_backup($uuid);
$lv->domain_undefine($dom);
$lv->nvram_restore($uuid);
if ($newuuid != $olduuid) $lv->nvram_rename($olduuid,$newuuid);
$new = $lv->domain_define($xml);
if ($new) {
$lv->domain_set_autostart($new, $newAutoStart);