From ceb97ab39288f2d536128492f76349d3ba5516a6 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 1 Sep 2024 21:17:05 +0100 Subject: [PATCH 1/4] Disable dataset processing. --- emhttp/plugins/dynamix/include/Helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/Helpers.php b/emhttp/plugins/dynamix/include/Helpers.php index d91e48566..8c9033bb6 100644 --- a/emhttp/plugins/dynamix/include/Helpers.php +++ b/emhttp/plugins/dynamix/include/Helpers.php @@ -358,7 +358,7 @@ function my_rmdir($dirname) { case "zfs": $zfsoutput = array(); $zfsdataset = trim(shell_exec("zfs list -H -o name \"$dirname\"")) ; - exec("zfs destroy \"$zfsdataset\"",$zfsoutput,$rtncode); + #exec("zfs destroy \"$zfsdataset\"",$zfsoutput,$rtncode); break; case "btrfs": default: From 753d87c6903d6ef94a60038ce5760c5a06acf09f Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Mon, 2 Sep 2024 18:03:10 +0100 Subject: [PATCH 2/4] Additional VM ZFS delete fixes --- .../dynamix.vm.manager/include/libvirt.php | 13 ++++++-- emhttp/plugins/dynamix/include/Helpers.php | 31 +++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index 33e224e98..824d110b2 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -2004,8 +2004,17 @@ if (is_file($cfg)) unlink($cfg); if (is_file($xml)) unlink($xml); if (is_dir($dir) && $this->is_dir_empty($dir)) { - $error = my_rmdir($dir); - qemu_log("$domain","delete empty $dir $error"); + $result= my_rmdir($dir); + if ($result['type'] == "zfs") { + qemu_log("$domain","delete empty zfs $dir {$result['rtncode']}"); + if (isset($result['dataset'])) qemu_log("$domain","dataset {$result['dataset']} "); + if (isset($result['cmd'])) qemu_log("$domain","Command {$result['cmd']} "); + if (isset($result['output'])) { + $outputlogs = implode(" ",$result['output']); + qemu_log("$domain","Output $outputlogs end"); + } + } + else qemu_log("$domain","delete empty $dir {$result['rtncode']}"); } } diff --git a/emhttp/plugins/dynamix/include/Helpers.php b/emhttp/plugins/dynamix/include/Helpers.php index 8c9033bb6..f64ba2f2d 100644 --- a/emhttp/plugins/dynamix/include/Helpers.php +++ b/emhttp/plugins/dynamix/include/Helpers.php @@ -345,27 +345,46 @@ function my_mkdir($dirname,$permissions = 0777,$recursive = false,$own = "nobody return($rtncode); } function my_rmdir($dirname) { - if (!is_dir($dirname)) return(false); + if (!is_dir("$dirname")) { + $return = [ + 'rtncode' => "false", + 'type' => "NoDir", + ]; + return($return); + } if (strpos($dirname,'/mnt/user/')===0) { $realdisk = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($dirname)." 2>/dev/null")); if (!empty($realdisk)) { - $dirname = str_replace('/mnt/user/', "/mnt/$realdisk/", $dirname); + $dirname = str_replace('/mnt/user/', "/mnt/$realdisk/", "$dirname"); } } - $fstype = trim(shell_exec(" stat -f -c '%T' $dirname")); + $fstype = trim(shell_exec(" stat -f -c '%T' ".escapeshellarg($dirname))); $rtncode = false; switch ($fstype) { case "zfs": $zfsoutput = array(); - $zfsdataset = trim(shell_exec("zfs list -H -o name \"$dirname\"")) ; - #exec("zfs destroy \"$zfsdataset\"",$zfsoutput,$rtncode); + $zfsdataset = trim(shell_exec("zfs list -H -o name ".escapeshellarg($dirname))) ; + $cmdstr = "zfs destroy \"$zfsdataset\" 2>&1 "; + $error = exec($cmdstr,$zfsoutput,$rtncode); + $return = [ + 'rtncode' => $rtncode, + 'output' => $zfsoutput, + 'dataset' => $zfsdataset, + 'type' => $fstype, + 'cmd' => $cmdstr, + 'error' => $error, + ]; break; case "btrfs": default: $rtncode = rmdir($dirname); + $return = [ + 'rtncode' => $rtncode, + 'type' => $fstype, + ]; break; } - return($rtncode); + return($return); } function get_realvolume($path) { if (strpos($path,"/mnt/user/",0) === 0) From 4ea425411ad3212883ef7f42f27d605703b664d3 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Tue, 3 Sep 2024 21:45:50 +0100 Subject: [PATCH 3/4] Add disable rename if snapshots found. --- .../templates/Custom.form.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 58452f19e..54c0e3c15 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -317,6 +317,18 @@ } if ($usertemplate == 1) unset($arrConfig['domain']['uuid']); $xml2 = build_xml_templates($strXML); + #disable rename if snapshots exist + $snapshots = getvmsnapshots($arrConfig['domain']['name']) ; + if ($snapshots != null && count($snapshots) && !$boolNew) + { + $snaprenamehidden = ""; + $namedisable = "disabled"; + $snapcount = count($snapshots); + } else { + $snaprenamehidden = "hidden"; + $namedisable = ""; + $snapcount = "0"; + }; ?> @@ -336,10 +348,12 @@ - + - +
+ id="snap-rename" class="orange-text"> _(Rename disabled, snapshot(s) exists.)_ +
_(Name)_: type="text" name="domain[name]" id="domain_name" oninput="checkName(this.value)" class="textTemplate" title="_(Name of virtual machine)_" placeholder="_(e.g.)_ _(My Workstation)_" value="" required />
From c27e018fdbd5a32d5881adfdb4dcc620e7cbdf35 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:11:44 +0100 Subject: [PATCH 4/4] Reduce Multifunction starting bus. --- emhttp/plugins/dynamix.vm.manager/include/libvirt.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index 824d110b2..042a17ae0 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -910,9 +910,9 @@ } if ($gpu['multi'] == "on"){ - $newgpu_bus= 0x10; + $newgpu_bus= 0x07; if (!isset($multibus[$newgpu_bus])) { - $multibus[$newgpu_bus] = 0x10; + $multibus[$newgpu_bus] = 0x07; } else { #Get next bus $newgpu_bus = end($multibus) + 0x01;