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(a)redhat.com>
---
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