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

Re: [libvirt] [libvirt-php][PATCH] Fix virConnectClose failed issue on list_domains



sorry.

fixed a little.

Regards,
Yukihiro Kawada



diff --git a/examples/libvirt.php b/examples/libvirt.php
index 10e7e38..8a54acd 100644
--- a/examples/libvirt.php
+++ b/examples/libvirt.php
@@ -22,7 +22,7 @@
 		}

 		function get_hostname() {
-			return libvirt_get_hostname($this->conn);
+			return libvirt_connect_get_hostname($this->conn);
 		}

 		function get_domain_object($nameRes) {
@@ -178,30 +178,23 @@
 		}

 		function get_uri() {
-			return libvirt_get_uri($this->conn);
+			return libvirt_connect_get_uri($this->conn);
 		}

 		function get_domain_count() {
-			$ac = libvirt_get_active_domain_count($this->conn);
-			$ic = libvirt_get_inactive_domain_count($this->conn);
-			$tc = libvirt_get_domain_count($this->conn);
-
-			return array(
-					'active'   => $ac,
-					'inactive' => $ic,
-					'total'    => $tc
-				    );
+                        return libvirt_domain_get_counts($this->conn);
 		}

 		function get_domains() {
 			$domNames = array();

 			$doms = libvirt_list_domains($this->conn);
-			foreach ($doms as $dom) {
-				$tmp = libvirt_domain_get_uuid_string($dom);
-				$domNames[$tmp] = libvirt_domain_get_name($dom);
+			foreach ($doms as $nam) {
+                            $dom =
libvirt_domain_lookup_by_name($this->conn, $nam);
+                            $tmp = libvirt_domain_get_uuid_string($dom);
+                            $domNames[$tmp] = $nam;
 			}
-
+                        unset($doms);
 			ksort($domNames);
 			return $domNames;
 		}
@@ -316,7 +309,7 @@
 			$ret = array();

 			if ($name != false) {
-				$dom=libvirt_domain_lookup_by_name($this->conn, $name);
+				$dom = libvirt_domain_lookup_by_name($this->conn, $name);
 				if (!$dom)
 					return false;

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 5e77994..fbd910b 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -3467,7 +3467,7 @@ PHP_FUNCTION(libvirt_list_domains)
 	int *ids;
 	char **names;
 	const char *name;
-	int i;
+	int i, rv;
 	virDomainPtr domain=NULL;

 	GET_CONNECTION_FROM_ARGS("r",&zconn);
@@ -3490,6 +3490,14 @@ PHP_FUNCTION(libvirt_list_domains)
 	}
   	efree(ids);

+        if (domain != NULL) {
+                rv = virDomainFree (domain);  // Y.Kawada
+                if (rv != 0) {
+                        php_error_docref(NULL TSRMLS_CC,
E_WARNING,"virDomainFree failed with %i on list_domain: %s", rv,
LIBVIRT_G (last_error));
+                }
+                domain = NULL;
+        }
+
 	expectedcount=virConnectNumOfDefinedDomains (conn->conn);
 	names=emalloc(expectedcount*sizeof(char *));
 	count=virConnectListDefinedDomains (conn->conn,names	,expectedcount);


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