mirror of
https://github.com/unraid/webgui.git
synced 2026-01-08 02:29:51 -06:00
Custom CPUs
This commit is contained in:
@@ -55,6 +55,22 @@
|
||||
return ($tmp) ? $tmp : $this->_set_last_error();
|
||||
}
|
||||
|
||||
function get_domain_capabilities($emulatorbin, $arch, $machine, $virttype, $xpath) {
|
||||
|
||||
#@conn [resource]: resource for connection
|
||||
#@emulatorbin [string]: optional path to emulator
|
||||
#@arch [string]: optional domain architecture
|
||||
#@machine [string]: optional machine type
|
||||
#@virttype [string]: optional virtualization type
|
||||
#@flags [int] : extra flags; not used yet, so callers should always pass 0
|
||||
#@xpath [string]: optional xPath query to be applied on the result
|
||||
#Returns: : domain capabilities XML from the connection or FALSE for error
|
||||
|
||||
$tmp = libvirt_connect_get_domain_capabilities($this->conn, $emulatorbin, $arch, $machine, $virttype, 0, $xpath);
|
||||
return ($tmp) ? $tmp : $this->_set_last_error();
|
||||
}
|
||||
|
||||
|
||||
function get_machine_types($arch = 'x86_64' /* or 'i686' */) {
|
||||
$tmp = libvirt_connect_get_machine_types($this->conn);
|
||||
|
||||
@@ -383,6 +399,10 @@
|
||||
$cpucache = '';
|
||||
$cpufeatures = '';
|
||||
$cpumigrate = '';
|
||||
$cpucheck = '';
|
||||
$cpumatch = '' ;
|
||||
$cpucustom = '' ;
|
||||
$cpufallback = '' ;
|
||||
if (!empty($domain['cpumode']) && $domain['cpumode'] == 'host-passthrough') {
|
||||
$cpumode .= "mode='host-passthrough'";
|
||||
$cpucache = "<cache mode='passthrough'/>";
|
||||
@@ -406,8 +426,17 @@
|
||||
|
||||
if (!empty($domain['cpumigrate'])) $cpumigrate = " migratable='".$domain['cpumigrate']."'" ;
|
||||
}
|
||||
#<cpu mode='custom' match='exact' check='partial'>
|
||||
#<model fallback='allow'>Skylake-Client-noTSX-IBRS</model>
|
||||
if (!empty($domain['cpumode']) && $domain['cpumode'] == 'custom') {
|
||||
if (!empty($domain['cpucustom']['match'])) $cpumatch = " match='".$domain['cpucustom']['match'].'"';
|
||||
if (!empty($domain['cpucustom']['check'])) $cpucheck = " check='".$domain['cpucustom']['check'].'"';
|
||||
if (!empty($domain['cpucustom']['fallback'])) $cpufallback = " fallback='".$domain['cpucustom']['fallback'].'"';
|
||||
if (!empty($domain['cpucustom']['model'])) $cpucustom = "<model $cpufallback>".$domain['cpucustom']['model']."</model>";
|
||||
}
|
||||
|
||||
$cpustr = "<cpu $cpumode $cpumigrate>
|
||||
$cpustr = "<cpu $cpumode $cpumigrate $cpumatch $cpucheck>
|
||||
$cpucustom
|
||||
<topology sockets='1' cores='{$intCores}' threads='{$intThreads}'/>
|
||||
$cpucache
|
||||
$cpufeatures
|
||||
@@ -2327,6 +2356,40 @@
|
||||
|
||||
return $var;
|
||||
}
|
||||
# <cpu mode='custom' match='exact' check='partial'>
|
||||
# <model fallback='allow'>Skylake-Client-noTSX-IBRS</model>
|
||||
|
||||
function domain_get_cpu_custom($domain) {
|
||||
$tmp = $this->get_xpath($domain, '//domain/cpu/@match', false);
|
||||
if (!$tmp)
|
||||
$tmp[0] = '';
|
||||
|
||||
$var['match'] = trim($tmp[0]);
|
||||
unset($tmp);
|
||||
|
||||
$tmp = $this->get_xpath($domain, '//domain/cpu/@check', false);
|
||||
if (!$tmp)
|
||||
$tmp[0] = '';
|
||||
|
||||
$var['check'] = trim($tmp[0]);
|
||||
unset($tmp);
|
||||
|
||||
$tmp = $this->get_xpath($domain, '//domain/cpu/model/@fallback', false);
|
||||
if (!$tmp)
|
||||
$tmp[0] = '';
|
||||
|
||||
$var['fallback'] = trim($tmp[0]);
|
||||
unset($tmp);
|
||||
|
||||
$tmp = $this->get_xpath($domain, '//domain/cpu/model', false);
|
||||
if (!$tmp)
|
||||
$tmp[0] = '';
|
||||
|
||||
$var['model'] = trim($tmp[0]);
|
||||
unset($tmp);
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
function domain_get_cpu_migrate($domain) {
|
||||
$tmp = $this->get_xpath($domain, '//domain/cpu/@migratable', false);
|
||||
|
||||
@@ -712,47 +712,47 @@ private static $encoding = 'UTF-8';
|
||||
|
||||
$arrDisplayOptions = [
|
||||
"H1.16M" => [
|
||||
"text" => "1 Screen 16Mb Memory",
|
||||
"text" => "1 Display 16Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='16384' vgamem='16384' heads='1' primary='yes'",
|
||||
],
|
||||
"H1.32M" => [
|
||||
"text" => "1 Screen 32Mb Memory",
|
||||
"text" => "1 Display 32Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='32768' vgamem='32768' heads='1' primary='yes'",
|
||||
],
|
||||
"H1.64M" => [
|
||||
"text" => "1 Screen 64Mb Memory",
|
||||
"text" => "1 Display 64Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='65536' vram64='65535' vgamem='65536' heads='1' primary='yes'",
|
||||
],
|
||||
"H1.128M" => [
|
||||
"text" => "1 Screen 128Mb Memory",
|
||||
"text" => "1 Display 128Mb Memory",
|
||||
"qxlxml"=> "ram='65536' vram='131072' vram64='131072' vgamem='65536' heads='1' primary='yes'",
|
||||
],
|
||||
"H1.256M" => [
|
||||
"text" => "1 Screen 256Mb Memory",
|
||||
"text" => "1 Display 256Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='262144' vram64='262144' vgamem='65536' heads='1' primary='yes'",
|
||||
],
|
||||
"H2.64M" => [
|
||||
"text" => "2 Screens 64Mb Memory",
|
||||
"text" => "2 Displays 64Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='65536' vram64='65535' vgamem='65536' heads='2' primary='yes'",
|
||||
],
|
||||
"H2.128M" => [
|
||||
"text" => "2 Screens 128Mb Memory",
|
||||
"text" => "2 Displays 128Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='131072'vram64='131072' vgamem='65536' heads='2' primary='yes'",
|
||||
],
|
||||
"H2.256M" => [
|
||||
"text" => "2 Screens 256Mb Memory",
|
||||
"text" => "2 Displays 256Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='262144'vram64='262144' vgamem='65536' heads='2' primary='yes'",
|
||||
],
|
||||
"H4.64M" => [
|
||||
"text" => "4 Screens 64Mb Memory",
|
||||
"text" => "4 Displays 64Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='65536' vram64='65535' vgamem='65536' heads='4' primary='yes'",
|
||||
],
|
||||
"H4.128M" => [
|
||||
"text" => "4 Screens 128Mb Memory",
|
||||
"text" => "4 Displays 128Mb Memory",
|
||||
"qxlxml" => "ram='65536' vram='131072'vram64='131072' vgamem='65536' heads='4' primary='yes'",
|
||||
],
|
||||
"H4.256M" => [
|
||||
"text" => "4 Screens 256Mb Memory",
|
||||
"text" => "4 Displays 256Mb Memory",
|
||||
"qxlxml"=> "ram='65536' vram='262144' vram64='262144' vgamem='65536' heads='4' primary='yes'",
|
||||
],
|
||||
];
|
||||
@@ -1453,6 +1453,7 @@ private static $encoding = 'UTF-8';
|
||||
'maxmem' => $lv->domain_get_memory($res),
|
||||
'password' => '', //TODO?
|
||||
'cpumode' => $lv->domain_get_cpu_type($res),
|
||||
'cpucustom' => $lv->domain_get_cpu_custom($res),
|
||||
'cpumigrate' => $lv->domain_get_cpu_migrate($res),
|
||||
'vcpus' => $dom['nrVirtCpu'],
|
||||
'vcpu' => $lv->domain_get_vcpu_pins($res),
|
||||
|
||||
@@ -464,11 +464,11 @@
|
||||
<td><span class="advanced">_(CPU)_ </span>_(Mode)_:</td>
|
||||
<td>
|
||||
<select id="cpu" name="domain[cpumode]" class="cpu" title="_(define type of cpu presented to this vm)_">
|
||||
<?mk_dropdown_options(['host-passthrough' => _('Host Passthrough').' (' . $strCPUModel . ')', 'custom' => _('Emulated').' ('._('QEMU64').')'], $arrConfig['domain']['cpumode']);?>
|
||||
<?mk_dropdown_options(['host-passthrough' => _('Host Passthrough').' (' . $strCPUModel . ')', 'custom' => _('Custom')], $arrConfig['domain']['cpumode']);?>
|
||||
</select>
|
||||
<span class="advanced" id="domain_cpumigrate_text"<?=$migratehidden?>>_(Migratable)_:</span>
|
||||
<span class="advanced" id="domain_cpumigrate_text" <?=$migratehidden?>>_(Migratable)_:</span>
|
||||
|
||||
<select name="domain[cpumigrate]" id="domain_cpumigrate" <?=$migratehidden?> class="narrow" title="_(define if migratable)_">
|
||||
<select name="domain[cpumigrate]" id="domain_cpumigrate" <?=$migratehidden?> hidden class="narrow" title="_(define if migratable)_">
|
||||
<?
|
||||
echo mk_option($arrConfig['domain']['cpumigrate'], 'on', 'On');
|
||||
echo mk_option($arrConfig['domain']['cpumigrate'], 'off', 'Off') ;
|
||||
@@ -477,6 +477,50 @@
|
||||
</td>
|
||||
<td><textarea class="xml" id="xmlcpu" rows=1 disabled ><?=htmlspecialchars($xml2['cpu'])?></textarea></td>
|
||||
</tr>
|
||||
<?
|
||||
$customhidden = "disabled hidden" ;
|
||||
if ($arrConfig['domain']['cpumode'] == 'custom') $customhidden = "" ;
|
||||
?>
|
||||
</table>
|
||||
<table $customhidden id="domain_cpucustom" >
|
||||
<tr class="advanced">
|
||||
<td><span class="advanced" id="domain_cpucustom_model_text">_(CPU Custom)_ </span>_(Model)_:</td>
|
||||
<td>
|
||||
<?
|
||||
$new = simplexml_load_string($lv->get_domain_capabilities(null,"x86_64",null,null,null))->xpath("//domainCapabilities/cpu/mode[@name='custom']") ;
|
||||
$arrValidCustomTypes = json_decode(json_encode($new[0]), true)['model']; ?>
|
||||
<select id="domain_cpucustom_model" name="domain[cpucustom][model]" class="cpucustom" title="_(define type of cpu presented to this vm)_">
|
||||
<?
|
||||
foreach($arrValidCustomTypes as $customtype) {
|
||||
echo mk_option($arrConfig['domain']['cpucustom']["model"],$customtype,$customtype);
|
||||
}?>
|
||||
|
||||
</select>
|
||||
<span class="advanced" id="domain_cpucustom_match_text"<?=$customhidden?>>_(Match)_:</span>
|
||||
<select name="domain[cpucustom][match]" id="domain_cpucustom_match" <?=$customhidden?> class="narrow" title="_(define if migratable)_">
|
||||
<?
|
||||
echo mk_option($arrConfig['domain']['cpucustom']['match'], 'minimum', 'minimum');
|
||||
echo mk_option($arrConfig['domain']['cpucustom']['match'], 'exact', 'exact') ;
|
||||
echo mk_option($arrConfig['domain']['cpucustom']['match'], 'strict', 'strict') ;
|
||||
?>
|
||||
</select>
|
||||
<span class="advanced" id="domain_cpucustom_check_text"<?=$customhidden?>>_(Check)_:</span>
|
||||
<select name="domain[cpucustom][check]" id="domain_cpucustom_check" <?=$customhidden?> class="narrow" title="_(define if migratable)_">
|
||||
<?
|
||||
echo mk_option($arrConfig['domain']['cpucustom']['check'], 'full', 'full');
|
||||
echo mk_option($arrConfig['domain']['cpucustom']['check'], 'partial', 'partial') ;
|
||||
echo mk_option($arrConfig['domain']['cpucustom']['check'], 'none', 'none') ;
|
||||
?>
|
||||
</select>
|
||||
<span class="advanced" id="domain_cpucustom_fallbacktext"<?=$customhidden?>>_(Fallback)_:</span>
|
||||
<select name="domain[cpucustom][fallback]" id="domain_cpucustom_fallback" <?=$customhidden?> class="narrow" title="_(define if migratable)_">
|
||||
<?
|
||||
echo mk_option($arrConfig['domain']['cpucustom']['fallback'], 'allow', 'allow');
|
||||
echo mk_option($arrConfig['domain']['cpucustom']['fallback'], 'forbid', 'forbid') ;
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="advanced">
|
||||
<blockquote class="inline_help">
|
||||
@@ -2432,11 +2476,14 @@ $(function() {
|
||||
if (myvalue == "custom") {
|
||||
document.getElementById("domain_cpumigrate_text").style.visibility="hidden";
|
||||
document.getElementById("domain_cpumigrate").style.visibility="hidden";
|
||||
document.getElementById("domain_cpucustom").style.display="inline";
|
||||
document.getElementById("domain_cpucustom").style.visibility="visible";
|
||||
} else {
|
||||
document.getElementById("domain_cpumigrate_text").style.display="inline";
|
||||
document.getElementById("domain_cpumigrate_text").style.visibility="visible";
|
||||
document.getElementById("domain_cpumigrate").style.display="inline";
|
||||
document.getElementById("domain_cpumigrate").style.visibility="visible";
|
||||
document.getElementById("domain_cpucustom").style.visibility="hidden";
|
||||
}
|
||||
|
||||
}) ;
|
||||
|
||||
Reference in New Issue
Block a user