Merge pull request #1464 from SimonFair/Vm-Multifunction-support

VM multifunction support
This commit is contained in:
tom mortensen
2023-10-17 10:14:00 -07:00
committed by GitHub
5 changed files with 62 additions and 9 deletions
@@ -732,6 +732,7 @@
$pcidevs='';
$gpudevs_used=[];
$multidevices = [] ; #Load?
$vmrc='';
$channelscopypaste = '';
if (!empty($gpus)) {
@@ -834,6 +835,13 @@
$strRomFile = "<rom file='".$gpu['rom']."'/>";
}
if ($gpu['multi'] == "on"){
$strSpecialAddress = "<address type='pci' domain='0x0000' bus='0x20' slot='0x$gpu_bus' function='0x".$gpu_function."' multifunction='on' />" ;
$multidevices[$gpu_bus] = "0x$gpu_bus" ;
}
$pcidevs .= "<hostdev mode='subsystem' type='pci' managed='yes'".$strXVGA.">
<driver name='vfio'/>
<source>
@@ -846,8 +854,8 @@
$gpudevs_used[] = $gpu['id'];
}
}
$audiodevs_used=[];
$strSpecialAddressAudio = "" ;
if (!empty($audios)) {
foreach ($audios as $i => $audio) {
// Skip duplicate audio devices
@@ -856,12 +864,16 @@
}
[$audio_bus, $audio_slot, $audio_function] = my_explode(":", str_replace('.', ':', $audio['id']), 3);
if ($audio_function != 0) {
if (isset($multidevices[$audio_bus])) $strSpecialAddressAudio = "<address type='pci' domain='0x0000' bus='0x20' slot='0x$audio_bus' function='0x".$audio_function."' />" ;
}
$pcidevs .= "<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio'/>
<source>
<address domain='0x0000' bus='0x".$audio_bus."' slot='0x".$audio_slot."' function='0x".$audio_function."'/>
</source>
$strSpecialAddressAudio
</hostdev>";
$audiodevs_used[] = $audio['id'];
@@ -869,6 +881,7 @@
}
$pcidevs_used=[];
$strSpecialAddressOther = "" ;
if (!empty($pcis)) {
foreach ($pcis as $i => $pci_id) {
// Skip duplicate other pci devices
@@ -877,12 +890,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 = "<address type='pci' domain='0x0000' bus='0x20' slot='0x$pci_bus' function='0x".$pci_function."' />" ;
}
$pcidevs .= "<hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio'/>
<source>
<address domain='0x0000' bus='0x" . $pci_bus . "' slot='0x" . $pci_slot . "' function='0x" . $pci_function . "'/>
</source>" ;
</source>
$strSpecialAddressOther " ;
if (!empty($pciboot[$pci_id]) && !$vmclone) {
$pcidevs .= "<boot order='".$pciboot[$pci_id]."'/>" ;
}
@@ -2235,7 +2254,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 +2270,8 @@
'product' => $tmp2['product_name'],
'product_id' => $tmp2['product_id'],
'boot' => $boot,
'rom' => $rom
'rom' => $rom,
'guest' => $guest
];
}
}
@@ -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;
}
}
@@ -985,6 +985,17 @@
}
?>
</select>
<?
if ($arrGPU['id'] != 'virtual') $multifunction = "" ; else $multifunction = " disabled " ;
?>
<span id="GPUMulti<?=$i?>" name="gpu[<?=$i?>][multi]" class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced gpumultiline<?=$i?>" >_(Multifunction)_:</span>
<select id="GPUMultiSel<?=$i?>" name="gpu[<?=$i?>][multi]" class="<?if ($arrGPU['id'] != 'virtual') echo 'was';?>advanced narrow gpumultiselect<?=$i?>" title="_(define Multifunctiion Support)_" <?=$multifunction?> >
<?
echo mk_option($arrGPU['guest']['multi'], 'off', 'Off');
echo mk_option($arrGPU['guest']['multi'], 'on', 'On');
?>
</select>
</td>
</tr>
@@ -1122,6 +1133,13 @@
}
?>
</select>
<span id="GPUMulti" name="gpu[{{INDEX}}][multi]" >_(Multifunction)_:</span>
<select name="gpu[{{INDEX}}][multi]" class="narrow" title="_(define Multifunctiion Support)_" >
<?
echo mk_option("off", 'off', 'Off');
echo mk_option("off", 'on', 'On');
?>
</select>
</td>
</tr>
<tr class="advanced romfile">
@@ -1825,9 +1843,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 ;
}
}
@@ -79,7 +79,9 @@ switch ($_POST['table']) {
$supporthtml = "<span id='link$modname'><a href='$supporturl' target='_blank'><i title='"._("Support page $pluginname")."' class='fa fa-phone-square'></i></a></span>" ;
}
}
$html .= "<td>$modname$supporthtml</td>" ;
if (isset($module["version"])) $version = "(".$module["version"].")" ; else $version = "" ;
$html .= "<td>$modname $version$supporthtml</td>" ;
$html .= "<td>{$module['description']}</td><td id=\"status$modname\">{$module['state']}</td><td>{$module['type']}</td>";
$text = "" ;
@@ -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,