Several VM Manager and general webui fixes/tuning for 6.2

- move qemu script out of the docroot

- added latest virtio-win-iso (0.1.112-1)

- mark all drive/usb controllers blacklisted that contain disks in the array from pci passthough

- fix regex to include nameless usb devices

- default to usb2 for new VMs

- show pci and usb device IDs next to device labels

- dont show help on/off splash image

- VM Manager help section updates
This commit is contained in:
Eric Schultz
2016-01-14 22:33:18 -08:00
parent e29c77b6b4
commit 20977c5210
8 changed files with 64 additions and 44 deletions
@@ -274,7 +274,7 @@
$machine_type = (stripos($machine, 'q35') !== false ? 'q35' : 'pc');
$os_type = ((empty($template['os']) || stripos($template['os'], 'windows') === false) ? 'other' : 'windows');
//$emulator = $this->get_default_emulator();
$emulator = '/usr/local/emhttp/plugins/dynamix.vm.manager/scripts/qemu.sh';
$emulator = '/usr/local/sbin/qemu';
$arch = $domain['arch'];
$pae = ($arch == 'i686') ? '<pae/>' : '';
@@ -262,6 +262,12 @@
$virtio_isos = [
'virtio-win-0.1.112-1' => [
'name' => 'virtio-win-0.1.112-1.iso',
'url' => 'https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.112-1/virtio-win-0.1.112.iso',
'size' => 56926208,
'md5' => '7db0211d7aec3e08fadd21c8eaaf35db'
],
'virtio-win-0.1.110-2' => [
'name' => 'virtio-win-0.1.110-2.iso',
'url' => 'https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.110-2/virtio-win-0.1.110.iso',
@@ -437,32 +443,46 @@
$cacheValidPCIDevices = null;
function getValidPCIDevices() {
global $cacheValidPCIDevices;
global $disks;
if (!is_null($cacheValidPCIDevices)) {
return $cacheValidPCIDevices;
}
$strOSUSBController = trim(shell_exec("udevadm info -q path -n /dev/disk/by-label/UNRAID 2>/dev/null | grep -Po '0000:\K\w{2}:\w{2}\.\w{1}'"));
$strOSNetworkDevice = trim(shell_exec("udevadm info -q path -p /sys/class/net/eth0 2>/dev/null | grep -Po '0000:\K\w{2}:\w{2}\.\w{1}'"));
$strOSNetworkDevice = trim(exec("udevadm info -q path -p /sys/class/net/eth0 2>/dev/null | grep -Po '0000:\K\w{2}:\w{2}\.\w{1}'"));
//TODO: add any drive controllers currently being used by unraid to the blacklist
$arrOSDiskControllers = [];
foreach ($disks as $strDisk => $arrDisk) {
if (!empty($arrDisk['device']) && file_exists('/dev/'.$arrDisk['device'])) {
$strOSDiskController = trim(exec("udevadm info -q path -n /dev/".$arrDisk['device']." | grep -Po '0000:\K\w{2}:\w{2}\.\w{1}'"));
if (!empty($strOSDiskController)) {
$arrOSDiskControllers[] = $strOSDiskController;
}
}
}
$arrOSDiskControllers = array_values(array_unique($arrOSDiskControllers));
$arrBlacklistIDs = array($strOSUSBController, $strOSNetworkDevice);
$arrBlacklistIDs = $arrOSDiskControllers;
if (!empty($strOSNetworkDevice)) {
$arrBlacklistIDs[] = $strOSNetworkDevice;
}
$arrBlacklistClassIDregex = '/^(05|06|08|0a|0b|0c05)/';
// Got Class IDs at the bottom of /usr/share/hwdata/pci.ids
$arrWhitelistGPUClassIDregex = '/^(0001|03)/';
$arrWhitelistAudioClassIDregex = '/^(0403)/';
$arrValidPCIDevices = array();
$arrValidPCIDevices = [];
exec("lspci -m -nn 2>/dev/null", $arrAllPCIDevices);
foreach ($arrAllPCIDevices as $strPCIDevice) {
// Example: 00:1f.0 "ISA bridge [0601]" "Intel Corporation [8086]" "Z77 Express Chipset LPC Controller [1e44]" -r04 "Micro-Star International Co., Ltd. [MSI] [1462]" "Device [7759]"
if (preg_match('/^(?P<id>\S+) \"(?P<type>[^"]+) \[(?P<typeid>[a-f0-9]{4})\]\" \"(?P<vendorname>[^"]+) \[(?P<vendorid>[a-f0-9]{4})\]\" \"(?P<productname>[^"]+) \[(?P<productid>[a-f0-9]{4})\]\"/', $strPCIDevice, $arrMatch)) {
$boolBlacklisted = false;
if (in_array($arrMatch['id'], $arrBlacklistIDs) || preg_match($arrBlacklistClassIDregex, $arrMatch['typeid'])) {
// Device blacklisted, skip device
continue;
$boolBlacklisted = true;
}
$strClass = 'other';
@@ -520,7 +540,8 @@
'productname' => $arrMatch['productname'],
'class' => $strClass,
'driver' => $strDriver,
'name' => $arrMatch['vendorname'] . ' ' . $arrMatch['productname']
'name' => $arrMatch['vendorname'] . ' ' . $arrMatch['productname'],
'blacklisted' => $boolBlacklisted
);
}
}
@@ -535,7 +556,7 @@
$arrValidPCIDevices = getValidPCIDevices();
$arrValidGPUDevices = array_filter($arrValidPCIDevices, function($arrDev) {
return ($arrDev['class'] == 'vga');
return ($arrDev['class'] == 'vga' && !$arrDev['blacklisted']);
});
return $arrValidGPUDevices;
@@ -546,7 +567,7 @@
$arrValidPCIDevices = getValidPCIDevices();
$arrValidAudioDevices = array_filter($arrValidPCIDevices, function($arrDev) {
return ($arrDev['class'] == 'audio');
return ($arrDev['class'] == 'audio' && !$arrDev['blacklisted']);
});
return $arrValidAudioDevices;
@@ -557,7 +578,7 @@
$arrValidPCIDevices = getValidPCIDevices();
$arrValidOtherDevices = array_filter($arrValidPCIDevices, function($arrDev) {
return ($arrDev['class'] == 'other');
return ($arrDev['class'] == 'other' && !$arrDev['blacklisted']);
});
return $arrValidOtherDevices;
@@ -568,7 +589,7 @@
$arrValidPCIDevices = getValidPCIDevices();
$arrValidOtherStubbedDevices = array_filter($arrValidPCIDevices, function($arrDev) {
return ($arrDev['class'] == 'other' && in_array($arrDev['driver'], ['pci-stub', 'vfio-pci']));
return ($arrDev['class'] == 'other' && !$arrDev['blacklisted'] && in_array($arrDev['driver'], ['pci-stub', 'vfio-pci']));
});
return $arrValidOtherStubbedDevices;
@@ -591,12 +612,12 @@
exec("lsusb 2>/dev/null", $arrAllUSBDevices);
foreach ($arrAllUSBDevices as $strUSBDevice) {
if (preg_match('/^.+ID (?P<id>\S+) (?P<name>.+)$/', $strUSBDevice, $arrMatch)) {
if (preg_match('/^.+ID (?P<id>\S+)(?P<name>.+)$/', $strUSBDevice, $arrMatch)) {
$arrMatch['name'] = trim($arrMatch['name']);
if (empty($arrMatch['name'])) {
// Device name is blank, replace using fallback default
$arrMatch['name'] = 'unnamed device ('.$arrMatch['id'].')';
$arrMatch['name'] = '<unnamed device>';
}
if (stripos($GLOBALS['var']['flashGUID'], str_replace(':', '-', $arrMatch['id'])) === 0) {
@@ -1,3 +0,0 @@
#!/bin/bash
eval exec /usr/bin/qemu-system-x86_64 $(/usr/local/emhttp/plugins/dynamix.vm.manager/scripts/qemu.php "$@")
@@ -48,7 +48,7 @@
'vcpu' => [0],
'hyperv' => 1,
'ovmf' => 1,
'usbmode' => 'usb3'
'usbmode' => 'usb2'
],
'media' => [
'cdrom' => '',
@@ -259,7 +259,7 @@
<table>
<tr>
<td>CPUs:</td>
<td>Logical CPUs:</td>
<td>
<div class="textarea four">
<?php
@@ -272,14 +272,15 @@
}
}
?>
<label for="vcpu<?=$i?>"><input type="checkbox" name="domain[vcpu][]" class="domain_vcpu" id="vcpu<?=$i?>" value="<?=$i?>" <?=$extra;?>/> Core <?=$i?></label>
<label for="vcpu<?=$i?>"><input type="checkbox" name="domain[vcpu][]" class="domain_vcpu" id="vcpu<?=$i?>" value="<?=$i?>" <?=$extra;?>/> CPU <?=$i?></label>
<?php } ?>
</div>
</td>
</tr>
</table>
<blockquote class="inline_help">
<p>By default, VMs created will be pinned to physical CPU cores to improve performance. From this view, you can adjust which actual CPU cores a VM will be pinned (minimum 1).</p>
<p>The number of logical CPUs in your system is determined by multiplying the number of CPU cores on your processor(s) by the number of threads.</p>
<p>Select which logical CPUs you wish to allow your VM to use. (minimum 1).</p>
</blockquote>
<table>
@@ -323,7 +324,7 @@
</div>
<div class="advanced">
<blockquote class="inline_help">
<p>Select how much memory to allocate to the VM at boot (cannot be more than Max. Mem).</p>
<p>For VMs where no PCI devices are being passed through (GPUs, sound, etc.), you can set different values to initial and max memory to allow for memory ballooning. If you are passing through a PCI device, only the initial memory value is used and the max memory value is ignored. For more information on KVM memory ballooning, see <a href="http://www.linux-kvm.org/page/FAQ#Is_dynamic_memory_management_for_guests_supported.3F" target="_new">here</a>.</p>
</blockquote>
</div>
@@ -758,7 +759,7 @@
}
foreach($arrValidGPUDevices as $arrDev) {
echo mk_option($arrGPU['id'], $arrDev['id'], $arrDev['name']);
echo mk_option($arrGPU['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
@@ -824,7 +825,7 @@
echo mk_option('', '', 'None');
foreach($arrValidGPUDevices as $arrDev) {
echo mk_option('', $arrDev['id'], $arrDev['name']);
echo mk_option('', $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
@@ -846,7 +847,7 @@
echo mk_option($arrAudio['id'], '', 'None');
foreach($arrValidAudioDevices as $arrDev) {
echo mk_option($arrAudio['id'], $arrDev['id'], $arrDev['name']);
echo mk_option($arrAudio['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
@@ -868,7 +869,7 @@
<select name="audio[{{INDEX}}][id]" class="audio narrow">
<?php
foreach($arrValidAudioDevices as $arrDev) {
echo mk_option('', $arrDev['id'], $arrDev['name']);
echo mk_option('', $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
@@ -948,12 +949,12 @@
<tr>
<td>USB Devices:</td>
<td>
<div class="textarea">
<div class="textarea" style="width: 540px">
<?php
if (!empty($arrValidUSBDevices)) {
foreach($arrValidUSBDevices as $i => $arrDev) {
?>
<label for="usb<?=$i?>"><input type="checkbox" name="usb[]" id="usb<?=$i?>" value="<?=$arrDev['id']?>" <?php if (count(array_filter($arrConfig['usb'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) echo 'checked="checked"'; ?>/> <?=$arrDev['name']?></label><br/>
<label for="usb<?=$i?>"><input type="checkbox" name="usb[]" id="usb<?=$i?>" value="<?=$arrDev['id']?>" <?php if (count(array_filter($arrConfig['usb'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) echo 'checked="checked"'; ?>/> <?=$arrDev['name']?> (<?=$arrDev['id']?>)</label><br/>
<?php
}
} else {
@@ -1010,7 +1011,7 @@
}
$intAvailableOtherPCIDevices++;
?>
<label for="pci<?=$i?>"><input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=$arrDev['id']?>" <?=$extra?>/> <?=$arrDev['name']?> | <?=$arrDev['type']?><span class="advanced"> | <?=$arrDev['id']?></span></label><br/>
<label for="pci<?=$i?>"><input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=$arrDev['id']?>" <?=$extra?>/> <?=$arrDev['name']?> | <?=$arrDev['type']?> (<?=$arrDev['id']?>)</label><br/>
<?
}
}
@@ -562,7 +562,7 @@
<table>
<tr>
<td>CPUs:</td>
<td>Logical CPUs:</td>
<td>
<div class="textarea four">
<?php
@@ -575,14 +575,15 @@
}
}
?>
<label for="vcpu<?=$i?>"><input type="checkbox" name="domain[vcpu][]" class="domain_vcpu" id="vcpu<?=$i?>" value="<?=$i?>" <?=$extra;?>/> Core <?=$i?></label>
<label for="vcpu<?=$i?>"><input type="checkbox" name="domain[vcpu][]" class="domain_vcpu" id="vcpu<?=$i?>" value="<?=$i?>" <?=$extra;?>/> CPU <?=$i?></label>
<?php } ?>
</div>
</td>
</tr>
</table>
<blockquote class="inline_help">
<p>By default, VMs created will be pinned to physical CPU cores to improve performance. From this view, you can adjust which actual CPU cores a VM will be pinned (minimum 1).</p>
<p>The number of logical CPUs in your system is determined by multiplying the number of CPU cores on your processor(s) by the number of threads.</p>
<p>Select which logical CPUs you wish to allow your VM to use. (minimum 1).</p>
</blockquote>
<table>
@@ -622,7 +623,7 @@
</div>
<div class="advanced">
<blockquote class="inline_help">
<p>Select how much memory to allocate to the VM at boot (cannot be more than Max. Mem).</p>
<p>For VMs where no PCI devices are being passed through (GPUs, sound, etc.), you can set different values to initial and max memory to allow for memory ballooning. If you are passing through a PCI device, only the initial memory value is used and the max memory value is ignored. For more information on KVM memory ballooning, see <a href="http://www.linux-kvm.org/page/FAQ#Is_dynamic_memory_management_for_guests_supported.3F" target="_new">here</a>.</p>
</blockquote>
</div>
@@ -697,7 +698,7 @@
}
foreach($arrValidGPUDevices as $arrDev) {
echo mk_option($arrGPU['id'], $arrDev['id'], $arrDev['name']);
echo mk_option($arrGPU['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
@@ -726,7 +727,7 @@
echo mk_option('', '', 'None');
foreach($arrValidGPUDevices as $arrDev) {
echo mk_option('', $arrDev['id'], $arrDev['name']);
echo mk_option('', $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
@@ -748,7 +749,7 @@
echo mk_option($arrAudio['id'], '', 'None');
foreach($arrValidAudioDevices as $arrDev) {
echo mk_option($arrAudio['id'], $arrDev['id'], $arrDev['name']);
echo mk_option($arrAudio['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
@@ -772,7 +773,7 @@
<select name="audio[{{INDEX}}][id]" class="audio narrow">
<?php
foreach($arrValidAudioDevices as $arrDev) {
echo mk_option('', $arrDev['id'], $arrDev['name']);
echo mk_option('', $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
}
?>
</select>
@@ -852,12 +853,12 @@
<tr>
<td>USB Devices:</td>
<td>
<div class="textarea">
<div class="textarea" style="width: 540px">
<?php
if (!empty($arrValidUSBDevices)) {
foreach($arrValidUSBDevices as $i => $arrDev) {
?>
<label for="usb<?=$i?>"><input type="checkbox" name="usb[]" id="usb<?=$i?>" value="<?=$arrDev['id']?>" <?php if (count(array_filter($arrConfig['usb'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) echo 'checked="checked"'; ?>/> <?=$arrDev['name']?></label><br/>
<label for="usb<?=$i?>"><input type="checkbox" name="usb[]" id="usb<?=$i?>" value="<?=$arrDev['id']?>" <?php if (count(array_filter($arrConfig['usb'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) echo 'checked="checked"'; ?>/> <?=$arrDev['name']?> (<?=$arrDev['id']?>)</label><br/>
<?php
}
} else {
@@ -914,7 +915,7 @@
}
$intAvailableOtherPCIDevices++;
?>
<label for="pci<?=$i?>"><input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=$arrDev['id']?>" <?=$extra?>/> <?=$arrDev['name']?> | <?=$arrDev['type']?><span class="advanced"> | <?=$arrDev['id']?></span></label><br/>
<label for="pci<?=$i?>"><input type="checkbox" name="pci[]" id="pci<?=$i?>" value="<?=$arrDev['id']?>" <?=$extra?>/> <?=$arrDev['name']?> | <?=$arrDev['type']?> (<?=$arrDev['id']?>)</label><br/>
<?
}
}
+2 -2
View File
@@ -17,12 +17,12 @@ Icon="help.png"
<script>
function HelpButton() {
$('.inline_help').toggle('slow');
$('#nav-item.HelpButton').toggleClass('nav-button-active');
$('#nav-item.HelpButton').toggleClass('active');
if ($.cookie('help')==null) {
$.cookie('help','help',{path:'/'}); var help = 'on';
} else {
$.removeCookie('help',{path:'/'}); var help = 'off';
}
swal({title:'Help is '+help.toUpperCase(),imageUrl:'/webGui/images/help-'+help+'.png',timer:1500,animation:'slide-from-top',showConfirmButton:false});
//swal({title:'Help is '+help.toUpperCase(),imageUrl:'/webGui/images/help-'+help+'.png',timer:1500,animation:'slide-from-top',showConfirmButton:false});
}
</script>
@@ -181,7 +181,7 @@ function countDown() {
$(function() {
var tab = $.cookie('one')||$.cookie('tab')||'tab1';
if (tab=='tab0') tab = 'tab'+$('input[name$="tabs"]').length; else if ($('#'+tab).length==0) {initab(); tab = 'tab1';}
if ($.cookie('help')=='help') {$('.inline_help').show(); $('#nav-item.HelpButton').addClass('nav-button-active');}
if ($.cookie('help')=='help') {$('.inline_help').show(); $('#nav-item.HelpButton').addClass('active');}
$('#'+tab).attr('checked', true);
<?if ($display['refresh']>0 || ($display['refresh']<0 && $var['mdResync']==0)):?>
if (update>1) setTimeout(countDown,1000);
+1 -1
View File
@@ -39,7 +39,7 @@ if (file_exists($log)) {
while (($line = fgets($handle)) !== false) {
list($date,$duration,$speed,$status) = explode('|',$line);
if ($speed==0) $speed = 'Unavailable';
if ($duration>0||$status<>0) {echo "<tr><td>$date</td><td>".my_duration($duration)."</td><td>$speed</td><td>".($status==0?'OK':$status)."</td></tr>"; $row++;}
if ($duration>0||$status<>0) {echo "<tr><td>$date</td><td>".my_duration($duration)."</td><td>$speed</td><td>".($status==0?'OK':($status==-4?'Canceled':$status))."</td></tr>"; $row++;}
}
fclose($handle);
}