Initial commit of multifunction support

Need to remove option for virtual gpus.
This commit is contained in:
SimonFair
2023-10-14 23:46:31 +01:00
parent 5a69f4b8e3
commit 83d02ea7ff
3 changed files with 65 additions and 6 deletions
@@ -732,6 +732,7 @@
$pcidevs='';
$gpudevs_used=[];
$multidevices = $multi = [] ; #Load?
$vmrc='';
$channelscopypaste = '';
if (!empty($gpus)) {
@@ -834,6 +835,27 @@
$strRomFile = "<rom file='".$gpu['rom']."'/>";
}
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 = "<address type='pci' domain='0x0000' bus='".$multi_bus."' slot='0x".$gpu_slot."' function='0x".$gpu_function."' multifunction='on' />" ;
} else {
$multi_bus = $gpu['guestbus'] ;
$strSpecialAddress = "<address type='pci' domain='0x0000' bus='".$multi_bus."' slot='0x".$gpu_slot."' function='0x".$gpu_function."' multifunction='on' />" ;
}
$multidevices[$gpu_bus] = $multi_bus ;
}
$pcidevs .= "<hostdev mode='subsystem' type='pci' managed='yes'".$strXVGA.">
<driver name='vfio'/>
<source>
@@ -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 = "<address type='pci' domain='0x0000' bus='".$multidevices[$audio_bus]."' slot='0x".$audio_slot."' 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'];
@@ -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
];
}
}
@@ -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,19 @@
}
?>
</select>
<?
#$multifunction = "hidden" ;
if ($arrGPU['id'] != 'virtual') $multifunction = "" ;
?>
<span id="GPUMulti" name="gpu[<?=$i?>][multi]" <?=$multifunction?>>_(Multifunction)_:</span>
<select name="gpu[<?=$i?>][multi]" class="narrow" title="_(define Multifunctiion Support)_" <?=$multifunction?> >
<?
echo mk_option($arrGPU['guest']['multi'], 'off', 'Off');
echo mk_option($arrGPU['guest']['multi'], 'on', 'On');
?>
</select>
<input type="hidden" name="gpu[<?=$i?>][guestbus]" id="gpuguest" value="<?=htmlspecialchars($arrGPU['guest']["bus"])?>">
</td>
</tr>
@@ -1122,6 +1135,19 @@
}
?>
</select>
<?
#$multifunction = "hidden" ;
if ($arrGPU['id'] != 'virtual') $multifunction = "" ;
?>
<span id="GPUMulti" name="gpu[{{INDEX}}][multi]" <?=$multifunction?>>_(Multifunction)_:</span>
<select name="gpu[{{INDEX}}][multi]" class="narrow" title="_(define Multifunctiion Support)_" <?=$multifunction?> >
<?
echo mk_option($arrGPU['guest']['multi'], 'off', 'Off');
echo mk_option($arrGPU['guest']['multi'], 'on', 'On');
?>
</select>
<input type="hidden" name="gpu[{{INDEX}}][guestbus]" id="gpuguest" value="">
</td>
</tr>
<tr class="advanced romfile">