From e6ff7a5d7f332b9de451c60a9be52e9407d90482 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Mon, 27 May 2024 10:43:27 +0100 Subject: [PATCH] Updates --- .../dynamix.vm.manager/include/VMedit.php | 14 +- .../include/libvirt_helpers.php | 7 +- .../templates/Custom.form.php | 57 ++++- ...{Custom.formXML.php => Custom.formold.php} | 199 +++++++++++++----- 4 files changed, 205 insertions(+), 72 deletions(-) rename emhttp/plugins/dynamix.vm.manager/templates/{Custom.formXML.php => Custom.formold.php} (94%) diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMedit.php b/emhttp/plugins/dynamix.vm.manager/include/VMedit.php index 31dcdb116..5a52037fd 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/VMedit.php +++ b/emhttp/plugins/dynamix.vm.manager/include/VMedit.php @@ -100,14 +100,12 @@ if (strpos($strSelectedTemplate,"User-") !== false) { $strSelectedTemplateUT = str_replace("User-","",$strSelectedTemplateUT); $usertemplate = 1; } -$newmodel = is_file("/etc/libvirt/qemu/newmodel"); -if ($newmodel && $arrLoad['form'] == "Custom.form.php") { $arrLoad['form'] = "Custom.formXML.php"; $inlineswt = ''; } else $inlineswt = ""; ?> - +
@@ -167,14 +165,14 @@ function isVMXMLMode() { } function isinlineXMLMode() { - return ($.cookie('vmmanager_inline_mode') == 'hide'); + return ($.cookie('vmmanager_inline_mode') == 'show'); } function hidexml(checked) { var form = document.getElementById("vmform"); // Replace "yourFormId" with the actual ID of your form var xmlElements = form.getElementsByClassName("xml"); - if (checked == 1) xmldisplay = "none"; else xmldisplay = ""; + if (checked == 0) xmldisplay = "none"; else xmldisplay = ""; // Unhide each element for (var i = 0; i < xmlElements.length; i++) { xmlElements[i].style.display = xmldisplay; // Setting to empty string will revert to default style @@ -199,8 +197,8 @@ $(function() { }); $('.inlineview').switchButton({ labels_placement: "left", - on_label: "_(Hide inline xml)_", - off_label: "_(Show Inline XML)_", + off_label: "_(Hide inline xml)_", + on_label: "_(Show Inline XML)_", checked: isinlineXMLMode() }); $('.advancedview').change(function () { @@ -209,7 +207,7 @@ $(function() { }); $('.inlineview').change(function () { hidexml($(this).is(':checked')); - $.cookie('vmmanager_inline_mode', $(this).is(':checked') ? 'hide' : 'show', { expires: 3650 }); + $.cookie('vmmanager_inline_mode', $(this).is(':checked') ? 'show' : 'hide', { expires: 3650 }); }); $('#template_img').click(function (){ diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php index 821baa60e..a9901f231 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php @@ -2748,10 +2748,9 @@ function build_xml_templates($strXML) { $xml2["devices"]["usb"][$usbaddr] = $xmlhostdev; $xml2["devices"]["allusb"] .= $xmlhostdev; break; - } - - - } + } + } + foreach($xml2["devices"]["input"] as $input) $xml2["devices"]["allinput"] .= "$input\n"; return $xml2; } diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 663d145cd..c3bcd7a4f 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -24,6 +24,7 @@ } $arrValidMachineTypes = getValidMachineTypes(); + $arrValidPCIDevices = getValidPCIDevices(); $arrValidGPUDevices = getValidGPUDevices(); $arrValidAudioDevices = getValidAudioDevices(); $arrValidOtherDevices = getValidOtherDevices(); @@ -290,6 +291,12 @@ $boolNew = true; $arrConfig = $arrConfigDefaults; $arrVMUSBs = getVMUSBs($strXML) ; + $strXML = $lv->config_to_xml($arrConfig); + $domXML = new DOMDocument(); + $domXML->preserveWhiteSpace = false; + $domXML->formatOutput = true; + $domXML->loadXML($strXML); + $strXML= $domXML->saveXML(); } // Add any custom metadata field defaults (e.g. os) if (!$arrConfig['template']['os']) { @@ -307,6 +314,7 @@ unset($arrConfig['domain']['uuid']); } if ($usertemplate == 1) unset($arrConfig['domain']['uuid']); + $xml2 = build_xml_templates($strXML); ?> @@ -329,6 +337,7 @@ _(Name)_: +
@@ -339,6 +348,7 @@ _(Description)_: +
@@ -428,6 +438,7 @@ ?> +
@@ -470,6 +481,7 @@ ?>
+
@@ -506,6 +518,7 @@ ?> +
@@ -533,6 +546,7 @@ +
@@ -651,6 +665,7 @@ + _(OS Install CDRom Bus)_: @@ -686,6 +701,7 @@ +
@@ -725,6 +741,7 @@ if (strpos($domain_cfg['DOMAINDIR'], dirname(dirname($arrDisk['new']))) === false || basename(dirname($arrDisk['new'])) != $arrConfig['domain']['name'] || ( basename($arrDisk['new']) != 'vdisk'.($i+1).'.img') && basename($arrDisk['new']) != 'vdisk'.($i+1).'.qcow2') { + if ($arrDisk['driver'] == "qcow2" && (basename($arrDisk['new']) == 'vdisk'.($i+1).'.qcow2')) $default_option = "auto"; else $default_option = 'manual'; } if (file_exists(dirname(dirname($arrDisk['new'])).'/'.$arrConfig['domain']['name'].'/vdisk'.($i+1).'.img') || file_exists(dirname(dirname($arrDisk['new'])).'/'.$arrConfig['domain']['name'].'/vdisk'.($i+1).'.qcow2')) { @@ -784,6 +801,7 @@ ?>
+ @@ -1003,6 +1021,7 @@ mk_dropdown_options($arrUnraidShares, $arrUnraidIndex);?> + @@ -1124,6 +1143,13 @@ ?> + + + + + + @@ -1340,6 +1367,7 @@ + _(Network Source)_: @@ -1457,7 +1485,7 @@ _(USB Devices)_: -
+
$arrDev) { @@ -1465,7 +1493,8 @@
+ ()
+
- +
@@ -1489,7 +1518,7 @@ _(Other PCI Devices)_: -
+
">    />   style="width: 50px;" name="pciboot[]" title="_(Boot order)_" value="" > | ()
+
+
@@ -1561,7 +1592,7 @@ if ($arrConfig['qemucmdline'] == "") $qemurows = 2 ; else $qemurows = 15 ; ?> - + @@ -1583,6 +1614,7 @@ ?> + + + _(Grab)_: @@ -1779,6 +1813,19 @@

Click Create to generate the vDisks and return to the Virtual Machines page where your new VM will be created.

+ + + + + + + + + +
_(Other XML)_: +
diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.formXML.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.formold.php similarity index 94% rename from emhttp/plugins/dynamix.vm.manager/templates/Custom.formXML.php rename to emhttp/plugins/dynamix.vm.manager/templates/Custom.formold.php index 03960f640..7fec53f24 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.formXML.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.formold.php @@ -97,7 +97,7 @@ 'protocol' => 'vnc', 'autoport' => 'yes', 'model' => 'qxl', - 'keymap' => 'en-us', + 'keymap' => 'none', 'port' => -1 , 'wsport' => -1, 'copypaste' => 'no' @@ -291,12 +291,6 @@ $boolNew = true; $arrConfig = $arrConfigDefaults; $arrVMUSBs = getVMUSBs($strXML) ; - $strXML = $lv->config_to_xml($arrConfig); - $domXML = new DOMDocument(); - $domXML->preserveWhiteSpace = false; - $domXML->formatOutput = true; - $domXML->loadXML($strXML); - $strXML= $domXML->saveXML(); } // Add any custom metadata field defaults (e.g. os) if (!$arrConfig['template']['os']) { @@ -309,8 +303,11 @@ } else $arrClocks = $arrDefaultClocks['other'] ; } - if (strpos($arrConfig['template']['name'],"User-") !== false) $arrConfig['template']['name'] = str_replace("User-","",$arrConfig['template']['name']); - $xml2 = build_xml_templates($strXML); + 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']); ?> @@ -333,7 +330,6 @@ _(Name)_: -
@@ -344,7 +340,6 @@ _(Description)_: -
@@ -434,7 +429,6 @@ ?> -
@@ -477,7 +471,6 @@ ?>
-
@@ -514,7 +507,6 @@ ?> -
@@ -542,7 +534,6 @@ -
@@ -661,7 +652,6 @@ - _(OS Install CDRom Bus)_: @@ -697,7 +687,6 @@ -
@@ -737,7 +726,6 @@ if (strpos($domain_cfg['DOMAINDIR'], dirname(dirname($arrDisk['new']))) === false || basename(dirname($arrDisk['new'])) != $arrConfig['domain']['name'] || ( basename($arrDisk['new']) != 'vdisk'.($i+1).'.img') && basename($arrDisk['new']) != 'vdisk'.($i+1).'.qcow2') { - if ($arrDisk['driver'] == "qcow2" && (basename($arrDisk['new']) == 'vdisk'.($i+1).'.qcow2')) $default_option = "auto"; else $default_option = 'manual'; } if (file_exists(dirname(dirname($arrDisk['new'])).'/'.$arrConfig['domain']['name'].'/vdisk'.($i+1).'.img') || file_exists(dirname(dirname($arrDisk['new'])).'/'.$arrConfig['domain']['name'].'/vdisk'.($i+1).'.qcow2')) { @@ -797,7 +785,6 @@ ?>
- @@ -1017,7 +1004,6 @@ mk_dropdown_options($arrUnraidShares, $arrUnraidIndex);?> - @@ -1139,13 +1125,6 @@ ?> - - - - - - @@ -1363,7 +1341,6 @@ - _(Network Source)_: @@ -1481,7 +1458,7 @@ _(USB Devices)_: -
+
$arrDev) { @@ -1489,8 +1466,7 @@
- + ()
- +
@@ -1514,7 +1490,7 @@ _(Other PCI Devices)_: -
+
">    />   style="width: 50px;" name="pciboot[]" title="_(Boot order)_" value="" > | ()
-
-
@@ -1588,7 +1562,7 @@ if ($arrConfig['qemucmdline'] == "") $qemurows = 2 ; else $qemurows = 15 ; ?> - + @@ -1610,7 +1584,6 @@ ?> - Windows and Hyperv Hpet:no Hypervclock: yes Pit no rtc no.

+ "",'grab'=>"",'repeat'=>"",'grabToggle'=>""]; + foreach ($arrConfig['evdev'] as $i => $arrEvdev) { + $strLabel = ($i > 0) ? appendOrdinalSuffix($i + 1) : ''; + ?> + + + + + + + + + + + + + + + + + + + + + + +
_(Evdev Device)_: + +
_(Grab)_: + +
_(Repeat)_: + +
_(Grab Toggle)_: + +
+ +
+
+

+ Event Devices
+ Evdev is an input interface built into the Linux kernel. QEMU’s evdev passthrough support allows a user to redirect evdev events to a guest. These events can include mouse movements and key presses. By hitting both Ctrl keys at the same time, QEMU can toggle the input recipient. QEMU’s evdev passthrough also features almost no latency, making it perfect for gaming. The main downside to evdev passthrough is the lack of button rebinding – and in some cases, macro keys won’t even work at all. + Optional items are normally only used for keyboards. +

+

+ Device
+ Host device to passthrough to guest. +

+ +

+ Grab
+ All grabs all input devices instead of just one +

+ +

+ Repeat
+ Repeat with value 'on'/'off' to enable/disable auto-repeat events +

+ +

+ GrabToggle
+ GrabToggle with values ctrl-ctrl, alt-alt, shift-shift, meta-meta, scrolllock or ctrl-scrolllock to change the grab key combination

+ +

Additional devices can be added/removed by clicking the symbols to the left.

+
+
+ + + + @@ -1680,19 +1780,6 @@

Click Create to generate the vDisks and return to the Virtual Machines page where your new VM will be created.

- -
- - - - - - - -
_(Other XML)_: -
@@ -1957,8 +2044,8 @@ $(function() { $('.advancedview').change(function () { if ($(this).is(':checked')) { setTimeout(function() { - var xmlPanelHeight = window.outerHeight - 550; - if (xmlPanelHeight < 0) xmlPanelHeight = null; + var xmlPanelHeight = window.outerHeight; + if (xmlPanelHeight > 1024) xmlPanelHeight = xmlPanelHeight-550; editor.setSize(null,xmlPanelHeight); editor.refresh(); }, 100); @@ -2468,7 +2555,8 @@ $(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(); + var usertemplate = ; + if (usertemplate = 0) $('#vmform #domain_machine').val($(this).val()).change(); return false; } }); @@ -2477,7 +2565,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; } });