From 1374c56ade4678f8e1bcb46bc79f832d9b9cbb07 Mon Sep 17 00:00:00 2001 From: DerTFL Date: Sun, 1 Nov 2020 03:26:00 +0300 Subject: [PATCH] Fixed display "Power Status" for libvirt vm's (#12283) * Update print-vm.inc.php virsh (libvirtd (libvirt) 4.5.0) displaying status of VMs: ``` shut off running paused ``` * Update libvirt-vminfo.inc.php --- includes/discovery/libvirt-vminfo.inc.php | 3 ++- includes/html/print-vm.inc.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/discovery/libvirt-vminfo.inc.php b/includes/discovery/libvirt-vminfo.inc.php index 070542b58c..67de5ecd87 100644 --- a/includes/discovery/libvirt-vminfo.inc.php +++ b/includes/discovery/libvirt-vminfo.inc.php @@ -74,7 +74,8 @@ if (Config::get('enable_libvirt') && $device['os'] == 'linux') { // libvirt does not supply this exec(Config::get('virsh') . ' -rc ' . $uri . ' domstate ' . $dom_id, $vm_state); $vmwVmState = ucfirst($vm_state[0]); - + unset($vm_state); + $vmwVmCpus = $xml->vcpu['current']; if (! isset($vmwVmCpus)) { $vmwVmCpus = $xml->vcpu; diff --git a/includes/html/print-vm.inc.php b/includes/html/print-vm.inc.php index 449afbb65e..7fe0da6c15 100644 --- a/includes/html/print-vm.inc.php +++ b/includes/html/print-vm.inc.php @@ -11,11 +11,11 @@ if (getidbyname($vm['vmwVmDisplayName'])) { echo ''; -if ($vm['vmwVmState'] == 'powered off') { +if ($vm['vmwVmState'] == 'powered off' || $vm['vmwVmState'] == 'Shut off') { echo 'OFF'; -} elseif ($vm['vmwVmState'] == 'powered on') { +} elseif ($vm['vmwVmState'] == 'powered on' || $vm['vmwVmState'] == 'Running') { echo 'ON'; -} elseif ($vm['vmwVmState'] == 'suspended') { +} elseif ($vm['vmwVmState'] == 'suspended' || $vm['vmwVmState'] == 'Paused') { echo 'SUSPEND'; }