From 20977c5210746b2be108b660cc39596c4fb01b67 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Thu, 14 Jan 2016 22:33:18 -0800 Subject: [PATCH] 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 --- .../dynamix.vm.manager/classes/libvirt.php | 2 +- .../classes/libvirt_helpers.php | 47 ++++++++++++++----- plugins/dynamix.vm.manager/scripts/qemu.sh | 3 -- .../templates/Custom.form.php | 25 +++++----- .../templates/OpenELEC.form.php | 23 ++++----- plugins/dynamix/HelpButton.page | 4 +- plugins/dynamix/include/DefaultPageLayout.php | 2 +- plugins/dynamix/include/ParityHistory.php | 2 +- 8 files changed, 64 insertions(+), 44 deletions(-) delete mode 100755 plugins/dynamix.vm.manager/scripts/qemu.sh diff --git a/plugins/dynamix.vm.manager/classes/libvirt.php b/plugins/dynamix.vm.manager/classes/libvirt.php index 6d1fc2e6e..bc1c06341 100644 --- a/plugins/dynamix.vm.manager/classes/libvirt.php +++ b/plugins/dynamix.vm.manager/classes/libvirt.php @@ -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') ? '' : ''; diff --git a/plugins/dynamix.vm.manager/classes/libvirt_helpers.php b/plugins/dynamix.vm.manager/classes/libvirt_helpers.php index 98b743531..8a1dd3fca 100644 --- a/plugins/dynamix.vm.manager/classes/libvirt_helpers.php +++ b/plugins/dynamix.vm.manager/classes/libvirt_helpers.php @@ -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\S+) \"(?P[^"]+) \[(?P[a-f0-9]{4})\]\" \"(?P[^"]+) \[(?P[a-f0-9]{4})\]\" \"(?P[^"]+) \[(?P[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\S+) (?P.+)$/', $strUSBDevice, $arrMatch)) { + if (preg_match('/^.+ID (?P\S+)(?P.+)$/', $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'] = ''; } if (stripos($GLOBALS['var']['flashGUID'], str_replace(':', '-', $arrMatch['id'])) === 0) { diff --git a/plugins/dynamix.vm.manager/scripts/qemu.sh b/plugins/dynamix.vm.manager/scripts/qemu.sh deleted file mode 100755 index 16d959464..000000000 --- a/plugins/dynamix.vm.manager/scripts/qemu.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -eval exec /usr/bin/qemu-system-x86_64 $(/usr/local/emhttp/plugins/dynamix.vm.manager/scripts/qemu.php "$@") \ No newline at end of file diff --git a/plugins/dynamix.vm.manager/templates/Custom.form.php b/plugins/dynamix.vm.manager/templates/Custom.form.php index db3ddec49..61bc5e7c7 100644 --- a/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -48,7 +48,7 @@ 'vcpu' => [0], 'hyperv' => 1, 'ovmf' => 1, - 'usbmode' => 'usb3' + 'usbmode' => 'usb2' ], 'media' => [ 'cdrom' => '', @@ -259,7 +259,7 @@ - +
CPUs:Logical CPUs:
- +
-

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).

+

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.

+

Select which logical CPUs you wish to allow your VM to use. (minimum 1).

@@ -323,7 +324,7 @@
-

Select how much memory to allocate to the VM at boot (cannot be more than Max. Mem).

+

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 here.

@@ -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'].')'); } ?> @@ -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'].')'); } ?> @@ -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'].')'); } ?> @@ -868,7 +869,7 @@ @@ -948,12 +949,12 @@ - +
USB Devices: -
+
$arrDev) { ?> -
+
-
+
CPUs:Logical CPUs:
- +
-

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).

+

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.

+

Select which logical CPUs you wish to allow your VM to use. (minimum 1).

@@ -622,7 +623,7 @@
-

Select how much memory to allocate to the VM at boot (cannot be more than Max. Mem).

+

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 here.

@@ -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'].')'); } ?> @@ -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'].')'); } ?> @@ -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'].')'); } ?> @@ -772,7 +773,7 @@ @@ -852,12 +853,12 @@ "; $row++;} + if ($duration>0||$status<>0) {echo ""; $row++;} } fclose($handle); }
USB Devices: -
+
$arrDev) { ?> -
+
-
+
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}); } \ No newline at end of file diff --git a/plugins/dynamix/include/DefaultPageLayout.php b/plugins/dynamix/include/DefaultPageLayout.php index 21db3c9b3..94faadcf8 100644 --- a/plugins/dynamix/include/DefaultPageLayout.php +++ b/plugins/dynamix/include/DefaultPageLayout.php @@ -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); 0 || ($display['refresh']<0 && $var['mdResync']==0)):?> if (update>1) setTimeout(countDown,1000); diff --git a/plugins/dynamix/include/ParityHistory.php b/plugins/dynamix/include/ParityHistory.php index 60a7ed0d5..9c7bc358e 100644 --- a/plugins/dynamix/include/ParityHistory.php +++ b/plugins/dynamix/include/ParityHistory.php @@ -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 "
$date".my_duration($duration)."$speed".($status==0?'OK':$status)."
$date".my_duration($duration)."$speed".($status==0?'OK':($status==-4?'Canceled':$status))."