mirror of
https://github.com/unraid/webgui.git
synced 2026-01-10 03:30:03 -06:00
Merge pull request #1307 from SimonFair/Remove-lock-posix='on'-flock='on'/-
VM Manager Updates
This commit is contained in:
@@ -1631,6 +1631,11 @@ When shutting down the server, this defines how long to wait in seconds for *gra
|
||||
NOTE: It's recommended to shut down guest VMs from within the VM.
|
||||
:end
|
||||
|
||||
:vms_console_help:
|
||||
For setting the console options to show on context menus. Web will show only inbuild web clients(VNC and SPICE),
|
||||
Virtual Manager Remote Viewer will only show the Remote Viewer option. Both will show both Web and Remote Viewer.
|
||||
:end
|
||||
|
||||
:vms_acs_override_help:
|
||||
*PCIe ACS override* allows various hardware components to expose themselves as isolated devices.
|
||||
Typically it is sufficient to isolate *Downstream* ports.
|
||||
|
||||
@@ -185,6 +185,15 @@ _(VM shutdown time-out)_:
|
||||
|
||||
:vms_shutdown_timeout_help:
|
||||
|
||||
_(Console Options)_:
|
||||
: <select id="vmsconsole" name="CONSOLE">
|
||||
<?=mk_option($domain_cfg['CONSOLE'], 'web', _('Web interface'))?>
|
||||
<?=mk_option($domain_cfg['CONSOLE'], 'remote', _('Virt-Manager Remote Viewer'))?>
|
||||
<?=mk_option($domain_cfg['CONSOLE'], 'both', _('Both Web & Virt-Manager Remote Viewer'))?>
|
||||
</select>
|
||||
|
||||
:vms_console_help:
|
||||
|
||||
_(PCIe ACS override)_:
|
||||
: <select id="pcie_acs_override"<?=$safemode?' disabled':''?>>
|
||||
<?= mk_option($pcie_acs_override, '', _('Disabled'))?>
|
||||
|
||||
@@ -100,7 +100,8 @@ foreach ($vms as $vm) {
|
||||
$graphics = str_replace("\n", "<br>", trim($graphics));
|
||||
}
|
||||
unset($dom);
|
||||
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,addslashes($vmrcurl),strtoupper($vmrcprotocol),addslashes($log));
|
||||
if (!isset($domain_cfg["CONSOLE"])) $vmrcconsole = "web" ; else $vmrcconsole = $domain_cfg["CONSOLE"] ;
|
||||
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm),addslashes($uuid),addslashes($template),$state,addslashes($vmrcurl),strtoupper($vmrcprotocol),addslashes($log), $vmrcconsole);
|
||||
$kvm[] = "kvm.push({id:'$uuid',state:'$state'});";
|
||||
switch ($state) {
|
||||
case 'running':
|
||||
|
||||
@@ -106,6 +106,45 @@ case 'domain-start-console':
|
||||
$arrResponse['vmrcurl'] = $vmrcurl;
|
||||
break;
|
||||
|
||||
case 'domain-start-consoleRV':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_start($domName)
|
||||
? ['success' => true, 'state' => $lv->domain_get_state($domName)]
|
||||
: ['error' => $lv->get_last_error()];
|
||||
$dom = $lv->get_domain_by_name($domName);
|
||||
$vmrcport = $lv->domain_get_vnc_port($dom);
|
||||
$wsport = $lv->domain_get_ws_port($dom);
|
||||
$protocol = $lv->domain_get_vmrc_protocol($dom);
|
||||
if ($protocol == "spice") $port= $vmrcport ; else $port=$vmrcport ;
|
||||
$vvarray = array() ;
|
||||
$vvarray[] = "[virt-viewer]\n";
|
||||
$vvarray[] = "type=$protocol\n";
|
||||
$vvarray[] = "host="._var($_SERVER,'HTTP_HOST')."\n" ;
|
||||
$vvarray[] = "port=$port\n" ;
|
||||
if (!is_dir("/mnt/user/system/remoteviewer")) mkdir("/mnt/user/system/remoteviewer") ;
|
||||
$vvfile = "/mnt/user/system/remoteviewer/rv"._var($_SERVER,'HTTP_HOST').".$port.vv" ;
|
||||
file_put_contents($vvfile,$vvarray) ;
|
||||
$arrResponse['vvfile'] = $vvfile;
|
||||
break;
|
||||
|
||||
case 'domain-consoleRV':
|
||||
requireLibvirt();
|
||||
$dom = $lv->get_domain_by_name($domName);
|
||||
$vmrcport = $lv->domain_get_vnc_port($dom);
|
||||
$wsport = $lv->domain_get_ws_port($dom);
|
||||
$protocol = $lv->domain_get_vmrc_protocol($dom);
|
||||
if ($protocol == "spice") $port= $vmrcport ; else $port=$vmrcport ;
|
||||
$vvarray = array() ;
|
||||
$vvarray[] = "[virt-viewer]\n";
|
||||
$vvarray[] = "type=$protocol\n";
|
||||
$vvarray[] = "host="._var($_SERVER,'HTTP_HOST')."\n" ;
|
||||
$vvarray[] = "port=$port\n" ;
|
||||
if (!is_dir("/mnt/user/system/remoteviewer")) mkdir("/mnt/user/system/remoteviewer") ;
|
||||
$vvfile = "/mnt/user/system/remoteviewer/rv"._var($_SERVER,'HTTP_HOST').".$port.vv" ;
|
||||
file_put_contents($vvfile,$vvarray) ;
|
||||
$arrResponse['vvfile'] = $vvfile;
|
||||
break;
|
||||
|
||||
case 'domain-pause':
|
||||
requireLibvirt();
|
||||
$arrResponse = $lv->domain_suspend($domName)
|
||||
|
||||
@@ -704,7 +704,6 @@
|
||||
<binary path='/usr/libexec/virtiofsd' xattr='on'>
|
||||
<sandbox mode='chroot'/>
|
||||
<cache mode='always'/>
|
||||
<lock posix='on' flock='on'/>
|
||||
</binary>
|
||||
</filesystem>" ;
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,16 @@ function displayconsole(url) {
|
||||
window.open(url, '_blank', 'scrollbars=yes,resizable=yes');
|
||||
}
|
||||
|
||||
function downloadFile(source) {
|
||||
var a = document.createElement('a');
|
||||
a.setAttribute('href',source);
|
||||
a.setAttribute('download',source.split('/').pop());
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
}
|
||||
|
||||
function ajaxVMDispatch(params, spin){
|
||||
if (spin) $('#vm-'+params['uuid']).parent().find('i').removeClass('fa-play fa-square fa-pause').addClass('fa-refresh fa-spin');
|
||||
$.post("/plugins/dynamix.vm.manager/include/VMajax.php", params, function(data) {
|
||||
@@ -35,17 +45,43 @@ function ajaxVMDispatchconsole(params, spin){
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
function addVMContext(name, uuid, template, state, vmrcurl,vmrcprotocol , log){
|
||||
function ajaxVMDispatchconsoleRV(params, spin){
|
||||
if (spin) $('#vm-'+params['uuid']).parent().find('i').removeClass('fa-play fa-square fa-pause').addClass('fa-refresh fa-spin');
|
||||
$.post("/plugins/dynamix.vm.manager/include/VMajax.php", params, function(data) {
|
||||
if (data.error) {
|
||||
swal({
|
||||
title:_("Execution error"), html:true,
|
||||
text:data.error, type:"error",
|
||||
confirmButtonText:_('Ok')
|
||||
},function(){
|
||||
if (spin) setTimeout(spin+'()',500); else location=window.location.href;
|
||||
});
|
||||
} else {
|
||||
if (spin) setTimeout(spin+'()',500); else location=window.location.href;
|
||||
downloadFile(data.vvfile) ;
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
function addVMContext(name, uuid, template, state, vmrcurl, vmrcprotocol, log, console="web"){
|
||||
var opts = [];
|
||||
var path = location.pathname;
|
||||
var x = path.indexOf("?");
|
||||
if (x!=-1) path = path.substring(0,x);
|
||||
if (vmrcurl !== "" && state == "running") {
|
||||
var vmrctext=_("VM Console") + "(" + vmrcprotocol + ")" ;
|
||||
opts.push({text:vmrctext, icon:"fa-desktop", action:function(e) {
|
||||
e.preventDefault();
|
||||
window.open(vmrcurl, '_blank', 'scrollbars=yes,resizable=yes');
|
||||
}});
|
||||
if (vmrcurl !== "" && state == "running") {
|
||||
if (console == "web" || console == "both") {
|
||||
var vmrctext=_("VM Console") + "(" + vmrcprotocol + ")" ;
|
||||
opts.push({text:vmrctext, icon:"fa-desktop", action:function(e) {
|
||||
e.preventDefault();
|
||||
window.open(vmrcurl, '_blank', 'scrollbars=yes,resizable=yes');
|
||||
}});
|
||||
}
|
||||
if (console == "remote" || console == "both") {
|
||||
opts.push({text:_("VM remote-viewer")+ "(" + vmrcprotocol + ")" , icon:"fa-desktop", action:function(e) {
|
||||
e.preventDefault();
|
||||
ajaxVMDispatchconsoleRV({action:"domain-consoleRV", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
|
||||
}});
|
||||
}
|
||||
|
||||
opts.push({divider:true});
|
||||
}
|
||||
context.settings({right:false,above:false});
|
||||
@@ -93,11 +129,18 @@ function addVMContext(name, uuid, template, state, vmrcurl,vmrcprotocol , log){
|
||||
e.preventDefault();
|
||||
ajaxVMDispatch({action:"domain-start", uuid:uuid}, "loadlist");
|
||||
}});
|
||||
if (vmrcprotocol == "VNC" || vmrcprotocol == "SPICE") {
|
||||
opts.push({text:_("Start with console")+ "(" + vmrcprotocol + ")" , icon:"fa-play", action:function(e) {
|
||||
e.preventDefault();
|
||||
ajaxVMDispatchconsole({action:"domain-start-console", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
|
||||
}});
|
||||
if (vmrcprotocol == "VNC" || vmrcprotocol == "SPICE") {
|
||||
if (console == "web" || console == "both") {
|
||||
opts.push({text:_("Start with console")+ "(" + vmrcprotocol + ")" , icon:"fa-play", action:function(e) {
|
||||
e.preventDefault();
|
||||
ajaxVMDispatchconsole({action:"domain-start-console", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
|
||||
}});}
|
||||
if (console == "remote" || console == "both") {
|
||||
opts.push({text:_("Start with remote-viewer")+ "(" + vmrcprotocol + ")" , icon:"fa-play", action:function(e) {
|
||||
e.preventDefault();
|
||||
ajaxVMDispatchconsoleRV({action:"domain-start-consoleRV", uuid:uuid, vmrcurl:vmrcurl}, "loadlist") ;
|
||||
}});
|
||||
}
|
||||
}}
|
||||
opts.push({divider:true});
|
||||
if (log !== "") {
|
||||
|
||||
@@ -110,7 +110,8 @@ if ($_POST['vms'] && ($display=='icons' || $display=='vms')) {
|
||||
$template = $lv->_get_single_xpath_result($res, '//domain/metadata/*[local-name()=\'vmtemplate\']/@name');
|
||||
if (empty($template)) $template = 'Custom';
|
||||
$log = (is_file("/var/log/libvirt/qemu/$vm.log") ? "libvirt/qemu/$vm.log" : '');
|
||||
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s', '%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), strtoupper($vmrcprotocol), addslashes($log));
|
||||
if (!isset($domain_cfg["CONSOLE"])) $vmrcconsole = "web" ; else $vmrcconsole = $domain_cfg["CONSOLE"] ;
|
||||
$menu = sprintf("onclick=\"addVMContext('%s','%s','%s','%s','%s','%s','%s','%s')\"", addslashes($vm), addslashes($uuid), addslashes($template), $state, addslashes($vmrcurl), strtoupper($vmrcprotocol), addslashes($log), $vmrcconsole);
|
||||
$icon = $lv->domain_get_icon_url($res);
|
||||
switch ($state) {
|
||||
case 'running':
|
||||
|
||||
Reference in New Issue
Block a user