mirror of
https://github.com/unraid/webgui.git
synced 2026-04-22 10:08:25 -05:00
CPU pinning page: disallow NONE cores selection for VM
This commit is contained in:
@@ -72,9 +72,14 @@ function apply(form) {
|
||||
// show the instant wait message
|
||||
$('#wait-'+id).show();
|
||||
// step 1: prepare the update and report back the changes
|
||||
$.post('/webGui/include/UpdateOne.php',args,function(d){
|
||||
if (d.success) {
|
||||
var data = d.success.split(';');
|
||||
$.post('/webGui/include/UpdateOne.php',args,function(reply){
|
||||
if (reply.error) {
|
||||
swal({type:'error', title:'Assignment error', text:reply.error},function(){
|
||||
$('#wait-'+id).hide();
|
||||
$(form).find('input[value="Done"]').val('Reset').prop('disabled',false).prop('onclick',null).off('click').click(function(){reset($('form[name="'+id+'"]'));});
|
||||
});
|
||||
} else if (reply.success) {
|
||||
var data = reply.success.split(';');
|
||||
wait = data.length;
|
||||
for (var i=0; i < data.length; i++) {
|
||||
var name = data[i];
|
||||
|
||||
@@ -22,12 +22,16 @@ foreach($_POST as $key => $val) {
|
||||
}
|
||||
// map holds the list of each vm or container and its newly proposed cpu assignments
|
||||
$map = array_map(function($d){return substr($d,0,-1);},$map);
|
||||
|
||||
file_put_contents('/tmp/map',print_r($map,true));
|
||||
switch ($_POST['id']) {
|
||||
case 'vm':
|
||||
// report changed vms in temporary file
|
||||
require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
|
||||
foreach ($map as $name => $cpuset) {
|
||||
if (!strlen($cpuset)) {
|
||||
$reply = ['error' => "Not allowed to assign ZERO cores"];
|
||||
break 2;
|
||||
}
|
||||
$uuid = $lv->domain_get_uuid($lv->get_domain_by_name($name));
|
||||
$cfg = domain_to_config($uuid);
|
||||
$cpus = implode(',',$cfg['domain']['vcpu']);
|
||||
@@ -38,6 +42,7 @@ case 'vm':
|
||||
file_put_contents("/var/tmp/$name.tmp",$cpuset);
|
||||
}
|
||||
}
|
||||
$reply = ['success' => (count($changes) ? implode(';',$changes) : '')];
|
||||
break;
|
||||
case 'ct':
|
||||
// update the XML file of the container
|
||||
@@ -65,10 +70,10 @@ case 'ct':
|
||||
exec("sed -ri 's/^(<CPUset)/ \\1/;s/><(\\/Container)/>\\n <\\1/' \"$file\""); // aftercare
|
||||
}
|
||||
}
|
||||
$reply = ['success' => (count($changes) ? implode(';',$changes) : '')];
|
||||
break;
|
||||
}
|
||||
// signal changes
|
||||
$reply = ['success' => (count($changes) ? implode(';',$changes) : '')];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($reply));
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user