From efd598c8f8dfc97c0656b2c6d773e212be820176 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 25 May 2024 19:56:43 +0100 Subject: [PATCH 1/4] Fix templates broken by evdevs. --- .../include/libvirt_helpers.php | 12 ++++++++- .../templates/Custom.form.php | 26 +++++++------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php index 8d78bcd93..75935cdfa 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php @@ -941,7 +941,17 @@ private static $encoding = 'UTF-8'; $xml = $lv->domain_get_xml($res) ; $xmldoc = new SimpleXMLElement($xml); $xmlpath = $xmldoc->xpath('//devices/input[@type="evdev"] '); - return $xmlpath; + $evdevs = []; + foreach ($xmlpath as $i => $evDev) { + $evdevs[$i] = [ + 'dev' => $evDev->source->attributes()->dev, + 'grab' => $evDev->source->attributes()->grab, + 'repeat' => $evDev->source->attributes()->repeat, + 'grabToggle' => $evDev->source->attributes()->grabToggle + ]; + } + if (empty($evdevs)) $evdevs[0] = ['dev'=>"",'grab'=>"",'repeat'=>"",'grabToggle'=>""]; + return $evdevs; } $cacheValidUSBDevices = null; diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 12abb670b..c8086651b 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1627,15 +1627,7 @@

- - "; - $evdevdoc = new SimpleXMLElement($evdevxml); - $arrConfig['evdev']= $evdevdoc->xpath('//input[@type="evdev"] '); - } - + if (!isset($arrConfig['evdev'])) $arrConfig['evdev'][0] = ['dev'=>"",'grab'=>"",'repeat'=>"",'grabToggle'=>""]; foreach ($arrConfig['evdev'] as $i => $arrEvdev) { $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : ''; ?> @@ -1645,8 +1637,8 @@ @@ -1655,8 +1647,8 @@ _(Grab)_: @@ -1665,8 +1657,8 @@ _(Repeat)_: @@ -1675,8 +1667,8 @@ _(Grab Toggle)_: From 290d4da90a2a8bb63fc699b5b1976fc920ac0050 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 25 May 2024 20:24:20 +0100 Subject: [PATCH 2/4] Updates to my_mkdir. --- emhttp/plugins/dynamix/include/Helpers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/Helpers.php b/emhttp/plugins/dynamix/include/Helpers.php index c8304ed6a..15c536538 100644 --- a/emhttp/plugins/dynamix/include/Helpers.php +++ b/emhttp/plugins/dynamix/include/Helpers.php @@ -291,11 +291,11 @@ function my_mkdir($dirname,$permissions = 0777,$recursive = false,$own = "nobody case "zfs": $zfsdataset = trim(shell_exec("zfs list -H -o name $parent")) ; $zfsdataset .= str_replace($parent,"",$dirname); - if ($recursive) $rtncode=exec("zfs create -p $zfsdataset");else $rtncode=exec("zfs create $zfsdataset"); + if ($recursive) $rtncode=exec("zfs create -p \"$zfsdataset\"");else $rtncode=exec("zfs create \"$zfsdataset\""); if (!$rtncode) mkdir($dirname, $permissions, $recursive); else chmod($zfsdataset,$permissions); break; case "btrfs": - if ($recursive) $rtncode=exec("btrfs subvolume create --parents $dirname"); else $rtncode=exec("btrfs subvolume create $dirname"); + if ($recursive) $rtncode=exec("btrfs subvolume create --parents \"$dirname\""); else $rtncode=exec("btrfs subvolume create \"$dirname\""); if (!$rtncode) mkdir($dirname, $permissions, $recursive); else chmod($dirname,$permissions); break; default: From 74ee77521e36fda0189ecda4034582036542850a Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 26 May 2024 09:21:20 +0100 Subject: [PATCH 3/4] Fix to use template machine type rather than default to windows default i440 --- emhttp/plugins/dynamix.vm.manager/include/VMedit.php | 6 +++++- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMedit.php b/emhttp/plugins/dynamix.vm.manager/include/VMedit.php index 67b2dd6ef..a03863995 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/VMedit.php +++ b/emhttp/plugins/dynamix.vm.manager/include/VMedit.php @@ -93,8 +93,12 @@ if (isset($_GET['uuid'])) { } $arrLoad['form'] = $arrAllTemplates[$strSelectedTemplate]['form']; } +$usertemplate = false; $strSelectedTemplateUT = $strSelectedTemplate; -if (strpos($strSelectedTemplate,"User-") !== false) $strSelectedTemplateUT = str_replace("User-","",$strSelectedTemplateUT); +if (strpos($strSelectedTemplate,"User-") !== false) { + $strSelectedTemplateUT = str_replace("User-","",$strSelectedTemplateUT); + $usertemplate = true; +} ?> diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index c8086651b..98aad9abf 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -2550,7 +2550,7 @@ $(function() { $('#vmform #domain_clock').val('localtime'); $("#vmform #domain_machine option").each(function(){ if ($(this).val().indexOf('i440fx') != -1) { - $('#vmform #domain_machine').val($(this).val()).change(); + if (!) $('#vmform #domain_machine').val($(this).val()).change(); return false; } }); From a6c03694449e91a0c341fe7a5af6db5e5cfb9c43 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 26 May 2024 14:32:35 +0100 Subject: [PATCH 4/4] Fix overwrite of xml if user template name is not changed. --- emhttp/plugins/dynamix.vm.manager/include/VMedit.php | 4 ++-- .../dynamix.vm.manager/templates/Custom.form.php | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMedit.php b/emhttp/plugins/dynamix.vm.manager/include/VMedit.php index a03863995..059ba47d7 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/VMedit.php +++ b/emhttp/plugins/dynamix.vm.manager/include/VMedit.php @@ -93,11 +93,11 @@ if (isset($_GET['uuid'])) { } $arrLoad['form'] = $arrAllTemplates[$strSelectedTemplate]['form']; } -$usertemplate = false; +$usertemplate = 0; $strSelectedTemplateUT = $strSelectedTemplate; if (strpos($strSelectedTemplate,"User-") !== false) { $strSelectedTemplateUT = str_replace("User-","",$strSelectedTemplateUT); - $usertemplate = true; + $usertemplate = 1; } ?> diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 98aad9abf..663d145cd 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -302,7 +302,11 @@ } else $arrClocks = $arrDefaultClocks['other'] ; } - if (strpos($arrConfig['template']['name'],"User-") !== false) $arrConfig['template']['name'] = str_replace("User-","",$arrConfig['template']['name']); + if (strpos($arrConfig['template']['name'],"User-") !== false) { + $arrConfig['template']['name'] = str_replace("User-","",$arrConfig['template']['name']); + unset($arrConfig['domain']['uuid']); + } + if ($usertemplate == 1) unset($arrConfig['domain']['uuid']); ?> @@ -2550,7 +2554,8 @@ $(function() { $('#vmform #domain_clock').val('localtime'); $("#vmform #domain_machine option").each(function(){ if ($(this).val().indexOf('i440fx') != -1) { - if (!) $('#vmform #domain_machine').val($(this).val()).change(); + var usertemplate = ; + if (usertemplate = 0) $('#vmform #domain_machine').val($(this).val()).change(); return false; } }); @@ -2559,7 +2564,8 @@ $(function() { $('#vmform #clockoffset').val('utc'); $("#vmform #domain_machine option").each(function(){ if ($(this).val().indexOf('q35') != -1) { - $('#vmform #domain_machine').val($(this).val()).change(); + var usertemplate = ; + if (usertemplate = 0) $('#vmform #domain_machine').val($(this).val()).change(); return false; } });