Add -r flag to virsh to connect in readonly mode. The script should only read information, not change anything.

This commit is contained in:
Alexander Kratzsch
2016-09-29 11:40:51 +02:00
parent 499b05f0f5
commit 6a876295f0

View File

@@ -31,7 +31,7 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') {
if ($ssh_ok || !strstr($method, 'ssh')) { if ($ssh_ok || !strstr($method, 'ssh')) {
// Fetch virtual machine list // Fetch virtual machine list
unset($domlist); unset($domlist);
exec($config['virsh'].' -c '.$uri.' list', $domlist); exec($config['virsh'].' -rc '.$uri.' list', $domlist);
foreach ($domlist as $dom) { foreach ($domlist as $dom) {
list($dom_id,) = explode(' ', trim($dom), 2); list($dom_id,) = explode(' ', trim($dom), 2);
@@ -39,7 +39,7 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') {
if (is_numeric($dom_id)) { if (is_numeric($dom_id)) {
// Fetch the Virtual Machine information. // Fetch the Virtual Machine information.
unset($vm_info_array); unset($vm_info_array);
exec($config['virsh'].' -c '.$uri.' dumpxml '.$dom_id, $vm_info_array); exec($config['virsh'].' -rc '.$uri.' dumpxml '.$dom_id, $vm_info_array);
// <domain type='kvm' id='3'> // <domain type='kvm' id='3'>
// <name>moo.example.com</name> // <name>moo.example.com</name>
@@ -67,7 +67,7 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') {
$vmwVmGuestOS = ''; $vmwVmGuestOS = '';
// libvirt does not supply this // libvirt does not supply this
$vmwVmMemSize = ($xml->currentMemory / 1024); $vmwVmMemSize = ($xml->currentMemory / 1024);
exec($config['virsh'].' -c '.$uri.' domstate '.$dom_id, $vm_state); exec($config['virsh'].' -rc '.$uri.' domstate '.$dom_id, $vm_state);
$vmwVmState = ucfirst($vm_state[0]); $vmwVmState = ucfirst($vm_state[0]);
$vmwVmCpus = $xml->vcpu; $vmwVmCpus = $xml->vcpu;