Merge pull request #2288 from SimonFair/Fix-PCI-changes

Remove OpenElec and LibreElec
This commit is contained in:
tom mortensen
2025-07-09 11:57:28 -07:00
committed by GitHub
8 changed files with 82 additions and 5783 deletions

View File

@@ -72,11 +72,7 @@ if (isset($_GET['uuid'])) {
if (empty($_GET['template'])) {
// read vm-template attribute
$strTemplateOS = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@os');
$strLibreELEC = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@libreelec');
$strOpenELEC = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@openelec');
if ($strLibreELEC) $strSelectedTemplate = 'LibreELEC';
elseif ($strOpenELEC) $strSelectedTemplate = 'OpenELEC';
elseif ($strTemplateOS) {
if ($strTemplateOS) {
$strSelectedTemplate = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@name');
} else {
// legacy VM support for <6.2 but need it going forward too

View File

@@ -353,11 +353,18 @@ class Libvirt {
}
if (!empty($domain['cpumigrate'])) $cpumigrate = " migratable='".$domain['cpumigrate']."'";
}
$cpupmemlmt ='';
if ($domain['cpupmemlmt'] != "None") {
$escaped_limit = htmlspecialchars($domain['cpupmemlmt'], ENT_QUOTES | ENT_XML1);
if ($domain['cpumode'] == 'host-passthrough') $cpupmemlmt = "<maxphysaddr mode='passthrough' limit='{$escaped_limit}'/>";
else $cpupmemlmt = "<maxphysaddr mode='emulate' bits='{$escaped_limit}'/>";
}
#<cpu mode='custom' match='exact' check='partial'>
#<model fallback='allow'>Skylake-Client-noTSX-IBRS</model>
$cpustr = "<cpu $cpumode $cpumigrate>
<topology sockets='1' cores='{$intCores}' threads='{$intThreads}'/>
$cpucache
$cpupmemlmt
$cpufeatures
</cpu>
<vcpu placement='static'>{$vcpus}</vcpu>
@@ -2033,6 +2040,23 @@ class Libvirt {
return $var;
}
function domain_get_cpu_pmem_limit($domain) {
$cpu_mode = $this->get_xpath($domain, '//domain/cpu/@mode', false);
if (!$cpu_mode) return "None";
$cpu_mode = $cpu_mode[0];
if ($cpu_mode === 'host-passthrough') {
$limit = $this->get_xpath($domain, '//domain/cpu/maxphysaddr/@limit', false);
return $limit ? intval($limit[0]) : "None";
} elseif (in_array($cpu_mode, ['custom', 'host-model'])) {
$bits = $this->get_xpath($domain, '//domain/cpu/maxphysaddr/@bits', false);
return $bits ? intval($bits[0]) : "None";
}
return "None"; // no limit found or not enforced
}
# <cpu mode='custom' match='exact' check='partial'>
# <model fallback='allow'>Skylake-Client-noTSX-IBRS</model>

View File

@@ -343,17 +343,6 @@ class Array2XML {
]
],
' Pre-packaged ' => '', /* Pre-built Header */
'LibreELEC' => [
'form' => 'LibreELEC.form.php',
'icon' => 'libreelec.png'
],
'OpenELEC' => [
'form' => 'OpenELEC.form.php',
'icon' => 'openelec.png'
],
' Linux ' => '', /* Linux Header */
@@ -441,51 +430,6 @@ class Array2XML {
]
];
$arrOpenELECVersions = [
'6.0.3_1' => [
'name' => '6.0.3',
'url' => 'https://s3.amazonaws.com/dnld.lime-technology.com/images/OpenELEC/OpenELEC-unRAID.x86_64-6.0.3_1.tar.xz',
'size' => 178909136,
'md5' => 'c584312831d7cd93a40e61ac9f186d32',
'localpath' => '',
'valid' => '0'
],
'6.0.0_1' => [
'name' => '6.0.0',
'url' => 'https://s3.amazonaws.com/dnld.lime-technology.com/images/OpenELEC/OpenELEC-unRAID.x86_64-6.0.0_1.tar.xz',
'size' => 165658636,
'md5' => '66fb6c3f1b6db49c291753fb3ec7c15c',
'localpath' => '',
'valid' => '0'
],
'5.95.3_1' => [
'name' => '5.95.3 (6.0.0 Beta3)',
'url' => 'https://s3.amazonaws.com/dnld.lime-technology.com/images/OpenELEC/OpenELEC-unRAID.x86_64-5.95.3_1.tar.xz',
'size' => 153990180,
'md5' => '8936cda74c28ddcaa165cc49ff2a477a',
'localpath' => '',
'valid' => '0'
],
'5.95.2_1' => [
'name' => '5.95.2 (6.0.0 Beta2)',
'url' => 'https://s3.amazonaws.com/dnld.lime-technology.com/images/OpenELEC/OpenELEC-unRAID.x86_64-5.95.2_1.tar.xz',
'size' => 156250392,
'md5' => 'ac70048eecbda4772e386c6f271cb5e9',
'localpath' => '',
'valid' => '0'
]
];
$arrLibreELECVersions = [
'7.0.1_1' => [
'name' => '7.0.1',
'url' => 'https://s3.amazonaws.com/dnld.lime-technology.com/images/LibreELEC/LibreELEC-unRAID.x86_64-7.0.1_1.tar.xz',
'size' => 209748564,
'md5' => 'c1e8def2ffb26a355e7cc598311697f6',
'localpath' => '',
'valid' => '0'
]
];
$fedora = '/var/tmp/fedora-virtio-isos';
// set variable to obtained information
@@ -1058,7 +1002,7 @@ class Array2XML {
if (empty($arrMatch['name'])) {
// Device name is blank, attempt to lookup usb details
exec("lsusb -d ".$arrMatch['id']." -v 2>/dev/null | grep -Po '^\s+(iManufacturer|iProduct)\s+[1-9]+ \K[^\\n]+'", $arrAltName);
exec("lsusb -d ".$arrMatch['id']." -v 2>/dev/null | grep -Po '^\s+(iManufacturer|iProduct)\s+[1-9]+ \K[^\\n]+'", $arrAltName); #PHPS
$arrMatch['name'] = trim(implode(' ', (array)$arrAltName));
if (empty($arrMatch['name'])) {
@@ -1461,6 +1405,7 @@ class Array2XML {
'maxmem' => $lv->domain_get_memory($res),
'password' => '', //TODO?
'cpumode' => $lv->domain_get_cpu_type($res),
'cpupmemlmt' => $lv->domain_get_cpu_pmem_limit($res),
'cpumigrate' => $lv->domain_get_cpu_migrate($res),
'vcpus' => $dom['nrVirtCpu'],
'vcpu' => $lv->domain_get_vcpu_pins($res),
@@ -1562,7 +1507,7 @@ class Array2XML {
// remove existing auto-generated settings
unset($old['cputune']['vcpupin'],$old['devices']['video'],$old['devices']['disk'],$old['devices']['interface'],$old['devices']['filesystem'],$old['cpu']['@attributes'],$old['os']['boot'],$old['os']['loader'],$old['os']['nvram']);
// Remove old CPU cache and features
unset($old['cpu']['cache'], $old['cpu']['feature']);
unset($old['cpu']['cache'], $old['cpu']['feature'], $old['cpu']['maxphysaddr']);
unset($old['features']['hyperv'],$old['devices']['channel']);
// set namespace
$new['metadata']['vmtemplate']['@attributes']['xmlns'] = 'unraid';
@@ -1859,7 +1804,7 @@ class Array2XML {
}
$cmdstr = "rsync -ahPIXS --out-format=%f --info=flist0,misc0,stats0,name1,progress2 '$repsrc' '$reptgt'";
$error = execCommand_nchan_clone($cmdstr,$target,$refcmd);
$error = execCommand_nchan_clone($cmdstr,$target,$refcmd); #PHPS
if (!$error) { write("addLog\0".htmlspecialchars("Image copied failed.")); return( false); }
}
}
@@ -1951,7 +1896,7 @@ class Array2XML {
$file = $disk["file"];
if ($disk['device'] == "hdc" ) $primarypath = dirname(transpose_user_path($file));
$output = array();
exec("qemu-img info --backing-chain -U '$file' | grep image:",$output);
exec("qemu-img info --backing-chain -U '$file' | grep image:",$output); #PHPS
foreach($output as $key => $line) {
$line=str_replace("image: ","",$line);
$output[$key] = $line;

View File

@@ -228,22 +228,20 @@ function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, f
ajaxVMDispatch({action:"domain-undefine",uuid:uuid}, "loadlist");
});
}});
if (template != 'OpenELEC') {
opts.push({text:_("Remove VM")+" & "+_("Disks"), icon:"fa-trash", action:function(e) {
e.preventDefault();
swal({
title:_("Are you sure?"),
text:_("Completely REMOVE")+" "+name+" "+_("disk image and definition"),
type:"warning",
showCancelButton:true,
confirmButtonText:_('Proceed'),
cancelButtonText:_('Cancel')
},function(){
$('#vm-'+uuid).find('i').removeClass('fa-play fa-square fa-pause').addClass('fa-refresh fa-spin');
ajaxVMDispatch({action:"domain-delete",uuid:uuid}, "loadlist");
});
}});
}
opts.push({text:_("Remove VM")+" & "+_("Disks"), icon:"fa-trash", action:function(e) {
e.preventDefault();
swal({
title:_("Are you sure?"),
text:_("Completely REMOVE")+" "+name+" "+_("disk image and definition"),
type:"warning",
showCancelButton:true,
confirmButtonText:_('Proceed'),
cancelButtonText:_('Cancel')
},function(){
$('#vm-'+uuid).find('i').removeClass('fa-play fa-square fa-pause').addClass('fa-refresh fa-spin');
ajaxVMDispatch({action:"domain-delete",uuid:uuid}, "loadlist");
});
}});
}
if (usage) { context.destroy('#vmusage-'+uuid); context.attach('#vmusage-'+uuid, opts); } else { context.destroy('#vm-'+uuid); context.attach('#vm-'+uuid, opts); }
}

View File

@@ -133,6 +133,7 @@ $arrConfigDefaults = [
]
];
$hdrXML = "<?xml version='1.0' encoding='UTF-8'?>\n"; // XML encoding declaration
$debug = false;
// Merge in any default values from the VM template
if ($arrAllTemplates[$strSelectedTemplate] && $arrAllTemplates[$strSelectedTemplate]['overrides']) {
@@ -256,6 +257,12 @@ if (isset($_POST['updatevm'])) {
if ($error = create_vdisk($_POST) === false) {
$arrExistingConfig = custom::createArray('domain',$strXML);
$arrUpdatedConfig = custom::createArray('domain',$lv->config_to_xml($_POST));
if ($debug) {
file_put_contents("/tmp/vmdebug_exist",$strXML);
file_put_contents("/tmp/vmdebug_new",$lv->config_to_xml($_POST));
file_put_contents("/tmp/vmdebug_arrayN",json_encode($arrUpdatedConfig,JSON_PRETTY_PRINT));
file_put_contents("/tmp/vmdebug_arrayE",json_encode($arrExistingConfig,JSON_PRETTY_PRINT));
}
array_update_recursive($arrExistingConfig, $arrUpdatedConfig);
$arrConfig = array_replace_recursive($arrExistingConfig, $arrUpdatedConfig);
$xml = custom::createXML('domain',$arrConfig)->saveXML();
@@ -1903,6 +1910,37 @@ foreach ($arrConfig['evdev'] as $i => $arrEvdev) {
</p>
</blockquote>
</div>
<table>
</tr>
<tr class="advanced">
<td><span class="advanced">_(Physical Address Bit Limit)_ </span></td>
<td>
<span class="width"><select id="cpupmemlmt" name="domain[cpupmemlmt]" class="cpupmem">
<?
echo mk_option($arrConfig['domain']['cpupmemlmt'], 'None', 'None');
echo mk_option($arrConfig['domain']['cpupmemlmt'], '32', '32-bit (4 GB)');
echo mk_option($arrConfig['domain']['cpupmemlmt'], '36', '36-bit (64 GB)');
echo mk_option($arrConfig['domain']['cpupmemlmt'], '39', '39-bit (512 GB)');
echo mk_option($arrConfig['domain']['cpupmemlmt'], '42', '42-bit (4 TB)');
echo mk_option($arrConfig['domain']['cpupmemlmt'], '48', '48-bit (256 TB)');
?>
</td>
</tr>
</table>
<div class="advanced">
<blockquote class="inline_help">
<p>
<b>Physical Address Bit Limit</b><br>
Sets limit on the physical address space.
<br>
Some guest systems or GPUs passed through might not work properly if mapped to high physical addresses (especially GPUs with 32-bit BARs). Using maxphysaddr=36 or maxphysaddr=39 limits the physical memory below 64 GB or 512 GB, avoiding such issues.
<br>
<br>bits=32 Addressable Memory 4 GB Use Case: Force 32-bit PCI compatibility
<br>bits=36 Addressable Memory 64 GB Use Case: Compatibility with older devices / 32-bit BARs
<br>bits=39 Addressable Memory 512 GB Use Case: Safe for most modern guests
<br>bits=48 Addressable Memory 256 TB Use Case: Full addressing, default on modern CPUs
</p>
</div>
<?}?>
<?}?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff