From 83d02ea7ff9b9c2470225c82760d4b527a8bca3e Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 14 Oct 2023 23:46:31 +0100 Subject: [PATCH 1/6] Initial commit of multifunction support Need to remove option for virtual gpus. --- .../dynamix.vm.manager/include/libvirt.php | 38 +++++++++++++++++-- .../include/libvirt_helpers.php | 7 ++-- .../templates/Custom.form.php | 26 +++++++++++++ 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index 484f5e011..c3e63faad 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -732,6 +732,7 @@ $pcidevs=''; $gpudevs_used=[]; + $multidevices = $multi = [] ; #Load? $vmrc=''; $channelscopypaste = ''; if (!empty($gpus)) { @@ -834,6 +835,27 @@ $strRomFile = ""; } + if ($gpu['multi'] == "on"){ + # This is a new Multifunction device/VM allocate from range 0x90 + $multibus = array_key_last($multi) ; + file_put_contents("/tmp/mbus", $multibus) ; + if ($multibus == NULL) $multi_bus = "0x90" ; + else + { + $multi_bus = hexdec($multibus) + 1 ; + $multi_bus = "0x".dechex($multi_bus) ; + } + $multi[$multi_bus] = $multi_bus ; + $strSpecialAddress = "
" ; + } else { + $multi_bus = $gpu['guestbus'] ; + $strSpecialAddress = "
" ; + } + $multidevices[$gpu_bus] = $multi_bus ; + } + + + $pcidevs .= " @@ -846,8 +868,9 @@ $gpudevs_used[] = $gpu['id']; } } - + file_put_contents("/tmp/bus", $multi) ; $audiodevs_used=[]; + $strSpecialAddressAudio = "" ; if (!empty($audios)) { foreach ($audios as $i => $audio) { // Skip duplicate audio devices @@ -856,12 +879,16 @@ } [$audio_bus, $audio_slot, $audio_function] = my_explode(":", str_replace('.', ':', $audio['id']), 3); + if ($audio_function != 0) { + if (isset($multidevices[$audio_bus])) $strSpecialAddressAudio = "
" ; + } $pcidevs .= "
+ $strSpecialAddressAudio "; $audiodevs_used[] = $audio['id']; @@ -2235,7 +2262,11 @@ $boot =$xpath->query('boot/@order', $objNode)->Item(0)->value; $devid = str_replace('0x', '', 'pci_'.$dom.'_'.$bus.'_'.$slot.'_'.$func); $tmp2 = $this->get_node_device_information($devid); - + $guest["multi"] = $xpath->query('address/@multifunction', $objNode)->Item(0)->value ? "on" : "off" ; + $guest["dom"] = $xpath->query('address/@domain', $objNode)->Item(0)->value; + $guest["bus"] = $xpath->query('address/@bus', $objNode)->Item(0)->value; + $guest["slot"] = $xpath->query('address/@slot', $objNode)->Item(0)->value; + $guest["func"] = $xpath->query('address/@function', $objNode)->Item(0)->value; $devs[] = [ 'domain' => $dom, 'bus' => $bus, @@ -2247,7 +2278,8 @@ 'product' => $tmp2['product_name'], 'product_id' => $tmp2['product_id'], 'boot' => $boot, - 'rom' => $rom + 'rom' => $rom, + 'guest' => $guest ]; } } diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php index 9575152c6..4274958fc 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php @@ -1166,25 +1166,26 @@ private static $encoding = 'UTF-8'; 'wsport' => $lv->domain_get_ws_port($res), 'autoport' => $autoport, 'copypaste' => $getcopypaste, + 'guest' => ['multi' => 'off' ], ]; } foreach ($arrHostDevs as $arrHostDev) { $arrFoundGPUDevices = array_filter($arrValidGPUDevices, function($arrDev) use ($arrHostDev) {return ($arrDev['id'] == $arrHostDev['id']);}); if (!empty($arrFoundGPUDevices)) { - $arrGPUDevices[] = ['id' => $arrHostDev['id'], 'rom' => $arrHostDev['rom']]; + $arrGPUDevices[] = ['id' => $arrHostDev['id'], 'rom' => $arrHostDev['rom'], 'guest' => $arrHostDev['guest']]; continue; } $arrFoundAudioDevices = array_filter($arrValidAudioDevices, function($arrDev) use ($arrHostDev) {return ($arrDev['id'] == $arrHostDev['id']);}); if (!empty($arrFoundAudioDevices)) { - $arrAudioDevices[] = ['id' => $arrHostDev['id']]; + $arrAudioDevices[] = ['id' => $arrHostDev['id'], 'guest' => $arrHostDev['guest']]; continue; } $arrFoundOtherDevices = array_filter($arrValidOtherDevices, function($arrDev) use ($arrHostDev) {return ($arrDev['id'] == $arrHostDev['id']);}); if (!empty($arrFoundOtherDevices)) { - $arrOtherDevices[] = ['id' => $arrHostDev['id'],'boot' => $arrHostDev['boot']]; + $arrOtherDevices[] = ['id' => $arrHostDev['id'],'boot' => $arrHostDev['boot'], 'guest' => $arrHostDev['guest']]; continue; } } diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index d5fa2369a..12a072cb5 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -985,6 +985,19 @@ } ?> + + >_(Multifunction)_: + + + "> @@ -1122,6 +1135,19 @@ } ?> + + >_(Multifunction)_: + + + From b4bd84cd03ff1ba69aecd31229f3b825d1518d21 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 14 Oct 2023 23:48:43 +0100 Subject: [PATCH 2/6] Update libvirt.php --- emhttp/plugins/dynamix.vm.manager/include/libvirt.php | 1 + 1 file changed, 1 insertion(+) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index c3e63faad..a0b5007c8 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -836,6 +836,7 @@ } if ($gpu['multi'] == "on"){ + if ($gpu['guestbus'] == "") { # This is a new Multifunction device/VM allocate from range 0x90 $multibus = array_key_last($multi) ; file_put_contents("/tmp/mbus", $multibus) ; From 43465bfd35f50c6469d7984dc498f96e02d355f9 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sun, 15 Oct 2023 11:16:20 +0100 Subject: [PATCH 3/6] Disable input if Virtual. Add Support for OtherPCI Devices --- .../dynamix.vm.manager/include/libvirt.php | 17 ++++++++++++++--- .../templates/Custom.form.php | 17 ++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index a0b5007c8..ed8f1d77e 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -733,6 +733,11 @@ $pcidevs=''; $gpudevs_used=[]; $multidevices = $multi = [] ; #Load? + foreach ($gpus as $i => $gpu) { + if ($gpu['guestbus'] != "") $multi[$gpu['guestbus']] = $gpu['guestbus'] ; + #$multi[$gpu['guestbus']] = $gpu['guestbus'] ; + } + ksort($multi) ; $vmrc=''; $channelscopypaste = ''; if (!empty($gpus)) { @@ -838,8 +843,7 @@ if ($gpu['multi'] == "on"){ if ($gpu['guestbus'] == "") { # This is a new Multifunction device/VM allocate from range 0x90 - $multibus = array_key_last($multi) ; - file_put_contents("/tmp/mbus", $multibus) ; + $multibus = array_key_last($multi) ; if ($multibus == NULL) $multi_bus = "0x90" ; else { @@ -897,6 +901,7 @@ } $pcidevs_used=[]; + $strSpecialAddressOther = "" ; if (!empty($pcis)) { foreach ($pcis as $i => $pci_id) { // Skip duplicate other pci devices @@ -905,12 +910,18 @@ } if ($vmclone) [$pci_bus, $pci_slot, $pci_function] = my_explode(":", str_replace('.', ':', $pci_id['id']), 3); else [$pci_bus, $pci_slot, $pci_function] = my_explode(":", str_replace('.', ':', $pci_id), 3); + + if ($pci_function != 0) { + if (isset($multidevices[$pci_bus])) $strSpecialAddressOther = "
" ; + } $pcidevs .= "
- " ; + + $strSpecialAddressOther " ; + if (!empty($pciboot[$pci_id]) && !$vmclone) { $pcidevs .= "" ; } diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 12a072cb5..53881ce21 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -986,18 +986,17 @@ ?> - >_(Multifunction)_: + _(Multifunction)_: - > - "> + "> @@ -1143,8 +1142,8 @@ @@ -1851,9 +1850,13 @@ $(function() { if (myvalue == 'virtual') { $vnc_sections.filter('.wasadvanced').removeClass('wasadvanced').addClass('advanced'); slideDownRows($vnc_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced')); + var MultiSel = document.getElementById("GPUMultiSel0") ; + MultiSel.disabled = true ; } else { slideUpRows($vnc_sections); $vnc_sections.filter('.advanced').removeClass('advanced').addClass('wasadvanced'); + var MultiSel = document.getElementById("GPUMultiSel0") ; + MultiSel.disabled = false ; } } From bde58c02984610779a3fa49046663a6db7772452 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:24:54 +0100 Subject: [PATCH 4/6] Revise processing --- .../dynamix.vm.manager/include/libvirt.php | 35 +++++-------------- .../templates/Custom.form.php | 11 ++---- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index ed8f1d77e..0cb19f8f1 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -268,6 +268,7 @@ function config_to_xml($config,$vmclone = false) { + file_put_contents("/tmp/vmconfig", $config) ; $domain = $config['domain']; $media = $config['media']; $nics = $config['nic']; @@ -732,12 +733,7 @@ $pcidevs=''; $gpudevs_used=[]; - $multidevices = $multi = [] ; #Load? - foreach ($gpus as $i => $gpu) { - if ($gpu['guestbus'] != "") $multi[$gpu['guestbus']] = $gpu['guestbus'] ; - #$multi[$gpu['guestbus']] = $gpu['guestbus'] ; - } - ksort($multi) ; + $multidevices = [] ; #Load? $vmrc=''; $channelscopypaste = ''; if (!empty($gpus)) { @@ -841,22 +837,8 @@ } if ($gpu['multi'] == "on"){ - if ($gpu['guestbus'] == "") { - # This is a new Multifunction device/VM allocate from range 0x90 - $multibus = array_key_last($multi) ; - if ($multibus == NULL) $multi_bus = "0x90" ; - else - { - $multi_bus = hexdec($multibus) + 1 ; - $multi_bus = "0x".dechex($multi_bus) ; - } - $multi[$multi_bus] = $multi_bus ; - $strSpecialAddress = "
" ; - } else { - $multi_bus = $gpu['guestbus'] ; - $strSpecialAddress = "
" ; - } - $multidevices[$gpu_bus] = $multi_bus ; + $strSpecialAddress = "
" ; + $multidevices[$gpu_bus] = "0x$gpu_bus" ; } @@ -873,7 +855,8 @@ $gpudevs_used[] = $gpu['id']; } } - file_put_contents("/tmp/bus", $multi) ; + #file_put_contents("/tmp/pcidevs" , $pcidevs) ; + #file_put_contents("/tmp/bus", $multidevices) ; $audiodevs_used=[]; $strSpecialAddressAudio = "" ; if (!empty($audios)) { @@ -885,7 +868,7 @@ [$audio_bus, $audio_slot, $audio_function] = my_explode(":", str_replace('.', ':', $audio['id']), 3); if ($audio_function != 0) { - if (isset($multidevices[$audio_bus])) $strSpecialAddressAudio = "
" ; + if (isset($multidevices[$audio_bus])) $strSpecialAddressAudio = "
" ; } $pcidevs .= " @@ -919,8 +902,7 @@
- - $strSpecialAddressOther " ; + " ; if (!empty($pciboot[$pci_id]) && !$vmclone) { $pcidevs .= "" ; @@ -933,6 +915,7 @@ if ($vmclone) $pcidevs_used[] = $pci_id['d']; else $pcidevs_used[] = $pci_id ; } } + #file_put_contents("/tmp/vmdetail", $pcidevs) ; $memballoon = ""; if (empty( array_filter(array_merge($gpudevs_used, $audiodevs_used, $pcidevs_used), function($k){ return strpos($k,'#remove')===false && $k!='virtual' ; }) )) { diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 53881ce21..939d352ed 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -996,7 +996,6 @@ echo mk_option($arrGPU['guest']['multi'], 'on', 'On'); ?> - "> @@ -1134,19 +1133,13 @@ } ?> - - >_(Multifunction)_: - - - From 8fc34e3f4aadd0a5df123accad4808b82a34d92b Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:42:36 +0100 Subject: [PATCH 5/6] Add PCI Other multifunction support. --- emhttp/plugins/dynamix.vm.manager/include/libvirt.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index 0cb19f8f1..cebfe945f 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -268,7 +268,6 @@ function config_to_xml($config,$vmclone = false) { - file_put_contents("/tmp/vmconfig", $config) ; $domain = $config['domain']; $media = $config['media']; $nics = $config['nic']; @@ -855,8 +854,6 @@ $gpudevs_used[] = $gpu['id']; } } - #file_put_contents("/tmp/pcidevs" , $pcidevs) ; - #file_put_contents("/tmp/bus", $multidevices) ; $audiodevs_used=[]; $strSpecialAddressAudio = "" ; if (!empty($audios)) { @@ -868,7 +865,7 @@ [$audio_bus, $audio_slot, $audio_function] = my_explode(":", str_replace('.', ':', $audio['id']), 3); if ($audio_function != 0) { - if (isset($multidevices[$audio_bus])) $strSpecialAddressAudio = "
" ; + if (isset($multidevices[$audio_bus])) $strSpecialAddressAudio = "
" ; } $pcidevs .= " @@ -895,14 +892,15 @@ else [$pci_bus, $pci_slot, $pci_function] = my_explode(":", str_replace('.', ':', $pci_id), 3); if ($pci_function != 0) { - if (isset($multidevices[$pci_bus])) $strSpecialAddressOther = "
" ; + if (isset($multidevices[$pci_bus])) $strSpecialAddressOther = "
" ; } $pcidevs .= "
- " ; + + $strSpecialAddressOther " ; if (!empty($pciboot[$pci_id]) && !$vmclone) { $pcidevs .= "" ; @@ -915,7 +913,6 @@ if ($vmclone) $pcidevs_used[] = $pci_id['d']; else $pcidevs_used[] = $pci_id ; } } - #file_put_contents("/tmp/vmdetail", $pcidevs) ; $memballoon = ""; if (empty( array_filter(array_merge($gpudevs_used, $audiodevs_used, $pcidevs_used), function($k){ return strpos($k,'#remove')===false && $k!='virtual' ; }) )) { From e33ec1466ecd7b06f19d7d7d6e02a82dd6e0c5d6 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:16:20 +0100 Subject: [PATCH 6/6] SystemDrivers add version Add version to module Module (Version) --- emhttp/plugins/dynamix/include/SysDrivers.php | 4 +++- emhttp/plugins/dynamix/include/SysDriversHelpers.php | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/SysDrivers.php b/emhttp/plugins/dynamix/include/SysDrivers.php index 47ac13566..2b6ee2fa0 100644 --- a/emhttp/plugins/dynamix/include/SysDrivers.php +++ b/emhttp/plugins/dynamix/include/SysDrivers.php @@ -79,7 +79,9 @@ switch ($_POST['table']) { $supporthtml = "" ; } } - $html .= "$modname$supporthtml" ; + if (isset($module["version"])) $version = "(".$module["version"].")" ; else $version = "" ; + + $html .= "$modname $version$supporthtml" ; $html .= "{$module['description']}{$module['state']}{$module['type']}"; $text = "" ; diff --git a/emhttp/plugins/dynamix/include/SysDriversHelpers.php b/emhttp/plugins/dynamix/include/SysDriversHelpers.php index b85f01cf4..382e5791f 100644 --- a/emhttp/plugins/dynamix/include/SysDriversHelpers.php +++ b/emhttp/plugins/dynamix/include/SysDriversHelpers.php @@ -52,6 +52,9 @@ function getmodules($line) { case "file": $file = trim(str_replace("file:","",$outline)) ; break ; + case "version": + $version = trim(str_replace("version:","",$data[1])) ; + break ; case "alias": case "author": case "firmware": @@ -103,7 +106,8 @@ $dir = str_replace("/lib/modules/$kernel/kernel/", "" ,$dir) ; if ($desc != null) $description = substr($desc , 0 ,60) ; else $description = null ; $arrModules[$modname] = [ 'modname' => $modname, - 'dependacy' => $depends, + 'dependacy' => $depends, + 'version' => $version, 'parms' => $parms, 'file' => $file, 'modprobe' => $modprobe,