From 19361f0b4da12745c317da9fe4be66ba47fd7de6 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 14 Dec 2024 10:29:43 +0000 Subject: [PATCH 01/13] Initial Commit Templates Export/Import Changes for virgl(Virtio3d) Bios flag. --- .../dynamix.vm.manager/VMMachines.page | 2 +- .../dynamix.vm.manager/VMTemplates.page | 201 +++++++++++++++++- .../dynamix.vm.manager/include/VMajax.php | 44 ++++ .../dynamix.vm.manager/include/libvirt.php | 39 +++- .../include/libvirt_helpers.php | 14 +- .../sheets/VMTemplates-azure.css | 1 + .../sheets/VMTemplates-black.css | 2 + .../sheets/VMTemplates-gray.css | 2 + .../sheets/VMTemplates-white.css | 2 + .../dynamix.vm.manager/sheets/VMTemplates.css | 4 + .../templates/Custom.form.php | 50 ++++- 11 files changed, 350 insertions(+), 11 deletions(-) create mode 100644 emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates-azure.css create mode 100644 emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates-black.css create mode 100644 emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates-gray.css create mode 100644 emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates-white.css diff --git a/emhttp/plugins/dynamix.vm.manager/VMMachines.page b/emhttp/plugins/dynamix.vm.manager/VMMachines.page index 1fbdbf65e..92addef7c 100644 --- a/emhttp/plugins/dynamix.vm.manager/VMMachines.page +++ b/emhttp/plugins/dynamix.vm.manager/VMMachines.page @@ -486,7 +486,7 @@ $(function() {
| _(Graphics Card)_: | @@ -1249,9 +1250,19 @@|
| _(VM Console Video Driver)_: | - |
| _(Graphics ROM Needed?)_: | _(GPU is primary adapater, vbios may be required.)_ |
@@ -1350,6 +1365,7 @@ +@@ -2084,6 +2100,19 @@ function AutoportChange(autoport) { } } +function VMConsoleDriverChange(driver) { + if (driver.value != "virtio3d") { + document.getElementById("vncrender").style.visibility="hidden"; + document.getElementById("vncrendertext").style.visibility="hidden"; + + } else { + document.getElementById("vncrender").style.display="inline"; + document.getElementById("vncrender").style.visibility="visible"; + document.getElementById("vncrendertext").style.display="inline"; + document.getElementById("vncrendertext").style.visibility="visible"; + } +} + function ProtocolChange(protocol) { var autoport = document.getElementById("autoport").value ; if (autoport == "yes") { @@ -2391,6 +2420,7 @@ $(function() { }) ; $("#vmform").on("change", ".gpu", function changeGPUEvent() { + const ValidGPUs = =json_encode($arrValidGPUDevices);?>; var myvalue = $(this).val(); var mylabel = $(this).children('option:selected').text(); var myindex = $(this).closest('table').data('index'); @@ -2402,6 +2432,13 @@ $(function() { slideDownRows($vnc_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced')); var MultiSel = document.getElementById("GPUMultiSel0") ; MultiSel.disabled = true ; + if (document.getElementById("vncmodel").value == "virtio3d") { + $("#vncrender").show(); + $("#vncrendertext").show(); + } else { + $("#vncrender").hide(); + $("#vncrendertext").hide(); + } } else { slideUpRows($vnc_sections); $vnc_sections.filter('.advanced').removeClass('advanced').addClass('wasadvanced'); @@ -2410,6 +2447,11 @@ $(function() { } } + if (mylabel == "None") $("#gpubootvga"+myindex).hide(); + if (myvalue != 'virtual' && myvalue != '' && myvalue !="nogpu") { + if (ValidGPUs[myvalue].bootvga == "1") $("#gpubootvga"+myindex).show(); else $("#gpubootvga"+myindex).hide(); + } + $romfile = $(this).closest('table').find('.romfile'); if (myvalue == 'virtual' || myvalue == '' || myvalue =="nogpu") { slideUpRows($romfile.not(isVMAdvancedMode() ? '.basic' : '.advanced')); From 08987bc2f1c6e6a2202405aa5852a260935282c0 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 14 Dec 2024 11:12:49 +0000 Subject: [PATCH 02/13] Add driver and rendernode to VMMachines view --- emhttp/plugins/dynamix.vm.manager/include/VMMachines.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php index 820a53f79..48c8b7290 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php +++ b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php @@ -78,18 +78,22 @@ foreach ($vms as $vm) { $vmrcurl = ''; $graphics = ''; $virtual = false ; + if (isset($arrConfig['gpu'][0]['model'])) {$vrtdriver=" "._("Driver").strtoupper(":{$arrConfig['gpu'][0]['model']} "); $vrtmodel =$arrConfig['gpu'][0]['model'];} else $vrtdriver = ""; + if (isset($arrConfig['gpu'][0]['render']) && $vrtmodel == "virtio3d") { + if (isset($arrConfig['gpu'][0]['render']) && $arrConfig['gpu'][0]['render'] == "auto") $vrtdriver .= " _(Graphics ROM Needed?)_: _(GPU is primary adapater, vbios may be required.)_
"._("RenderGPU").":"._("Auto"); else $vrtdriver .= "
"._("RenderGPU").":{$arrValidGPUDevices[$arrConfig['gpu'][0]['render']]['name']}"; + } if ($vmrcport > 0) { $wsport = $lv->domain_get_ws_port($res); $vmrcprotocol = $lv->domain_get_vmrc_protocol($res); if ($vmrcprotocol == "vnc") $vmrcscale = "&resize=scale"; else $vmrcscale = ""; $vmrcurl = autov('/plugins/dynamix.vm.manager/'.$vmrcprotocol.'.html',true).$vmrcscale.'&autoconnect=true&host='._var($_SERVER,'HTTP_HOST'); if ($vmrcprotocol == "spice") $vmrcurl .= '&vmname='. urlencode($vm) .'&port=/wsproxy/'.$vmrcport.'/'; else $vmrcurl .= '&port=&path=/wsproxy/'.$wsport.'/'; - $graphics = strtoupper($vmrcprotocol).":".$vmrcport."\n"; + $graphics = strtoupper($vmrcprotocol).':'._($auto)."$vrtdriver\n"; $virtual = true ; } elseif ($vmrcport == -1 || $autoport) { $vmrcprotocol = $lv->domain_get_vmrc_protocol($res); if ($autoport == "yes") $auto = "auto"; else $auto="manual"; - $graphics = strtoupper($vmrcprotocol).':'._($auto)."\n"; + $graphics = strtoupper($vmrcprotocol).':'._($auto)."$vrtdriver\n"; $virtual = true ; } if (!empty($arrConfig['gpu'])) { From 8616faad598a363be56d0f21586de33408c0a7a8 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:14:11 +0000 Subject: [PATCH 03/13] Add support to detect auto gpu in use. --- emhttp/plugins/dynamix.vm.manager/include/libvirt.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index 5a0a1784c..0c5f3a083 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -2221,6 +2221,8 @@ $var = $tmp[0]; unset($tmp); + + if (!str_contains($var,"pci")) $var = trim(shell_exec("udevadm info -q symlink -r $var")); $var = str_replace(['/dev/dri/by-path/pci-0000:','-render'],['',''],$var); return $var; } From 8591914a185bb476e931ddcd665014903b66744e Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Thu, 19 Dec 2024 08:03:39 +0000 Subject: [PATCH 04/13] Fix Templates CSS --- emhttp/plugins/dynamix.vm.manager/VMTemplates.page | 2 +- emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates-azure.css | 2 +- emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates-black.css | 2 +- emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates-gray.css | 2 +- emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates-white.css | 2 +- emhttp/plugins/dynamix.vm.manager/sheets/VMTemplates.css | 3 --- 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/VMTemplates.page b/emhttp/plugins/dynamix.vm.manager/VMTemplates.page index aa9987861..ce12319e6 100644 --- a/emhttp/plugins/dynamix.vm.manager/VMTemplates.page +++ b/emhttp/plugins/dynamix.vm.manager/VMTemplates.page @@ -46,7 +46,7 @@ Markdown="false" - +