[libvirt-php][PATCH 1/3] examples: Check properly if connected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So far, we connect and issue an API immediately. And only after
it fails we assume we're not connected. This is just not right
as we should have checked before issuing the API whether we are
connected at all.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 examples/index.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/examples/index.php b/examples/index.php
index 381baef..b2f5b69 100644
--- a/examples/index.php
+++ b/examples/index.php
@@ -1,9 +1,11 @@
 <?php
 	require('libvirt.php');
 	$lv = new Libvirt('qemu:///system');
+	if ($lv == false)
+		die('<html><body>Cannot open connection to hypervisor</body></html>');
 	$hn = $lv->get_hostname();
 	if ($hn == false)
-		die('Cannot open connection to hypervisor</body></html>');
+		die('<html><body>Cannot get hostname</body></html>');
 
 	$action = array_key_exists('action', $_GET) ? $_GET['action'] : false;
 	$subaction = array_key_exists('subaction', $_GET) ? $_GET['subaction'] : false;
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]