This patch for libvirt-php Pre-4.2 version.<br />I checked with libvirt 0.8.8 version.<br /><br />I fixed irConnectClose failed issue on list_domains.<br />And web example codes updated for 0.8.8 API.<br /><br />This issue is:<br />$domains = libvirt_list_domains($conn);<br />PHP Warning:  main(): virConnectClose failed with 1 on destructor: (null) <br /><br />And if ssh connect to remote host then some netcat processes remain on remote host.<br /><br /># ps axu|grep libvirt|grep 'nc -U'<br />apache   27867  0.0  0.0   7332   368 ?        Ss   12:09   0:00 nc -U /var/run/libvirt/libvirt-sock<br />apache   27871  0.0  0.0   7332   372 ?        Ss   12:09   0:00 nc -U /var/run/libvirt/libvirt-sock<br />apache   27875  0.0  0.0   7332   368 ?        Ss   12:09   0:00 nc -U /var/run/libvirt/libvirt-sock<br /><br />Thanks for libvirt-php.<br />Regards,<br />==<br />Yukihiro Kawada<br /><br /><br />diff --git a/examples/libvirt.php b/examples/libvirt.php<br />index 10e7e38..8a54acd 100644<br />--- a/examples/libvirt.php<br />+++ b/examples/libvirt.php<br />@@ -22,7 +22,7 @@<br />              }<br /> <br />              function get_hostname() {<br />-                  return libvirt_get_hostname($this->conn);<br />+                       return libvirt_connect_get_hostname($this->conn);<br />                }<br /> <br />              function get_domain_object($nameRes) {<br />@@ -178,30 +178,23 @@<br />             }<br /> <br />              function get_uri() {<br />-                       return libvirt_get_uri($this->conn);<br />+                    return libvirt_connect_get_uri($this->conn);<br />             }<br /> <br />              function get_domain_count() {<br />-                      $ac = libvirt_get_active_domain_count($this->conn);<br />-                     $ic = libvirt_get_inactive_domain_count($this->conn);<br />-                   $tc = libvirt_get_domain_count($this->conn);<br />-<br />-                       return array(<br />-                                      'active'   => $ac,<br />-                                      'inactive' => $ic,<br />-                                      'total'    => $tc<br />-                                   );<br />+                        return libvirt_domain_get_counts($this->conn);<br />                }<br /> <br />              function get_domains() {<br />                    $domNames = array();<br /> <br />                   $doms = libvirt_list_domains($this->conn);<br />-                      foreach ($doms as $dom) {<br />-                          $tmp = libvirt_domain_get_uuid_string($dom);<br />-                               $domNames[$tmp] = libvirt_domain_get_name($dom);<br />+                   foreach ($doms as $nam) {<br />+                            $dom = libvirt_domain_lookup_by_name($this->conn, $nam);<br />+                            $tmp = libvirt_domain_get_uuid_string($dom);<br />+                            $domNames[$tmp] = $nam;<br />                  }<br />-<br />+                        unset($doms);<br />                    ksort($domNames);<br />                   return $domNames;<br />           }<br />@@ -316,7 +309,7 @@<br />                    $ret = array();<br /> <br />                        if ($name != false) {<br />-                              $dom=libvirt_domain_lookup_by_name($this->conn, $name);<br />+                         $dom = libvirt_domain_lookup_by_name($this->conn, $name);<br />                                if (!$dom)<br />                                  return false;<br /> <br />diff --git a/src/libvirt-php.c b/src/libvirt-php.c<br />index 5e77994..f5a927b 100644<br />--- a/src/libvirt-php.c<br />+++ b/src/libvirt-php.c<br />@@ -3467,7 +3467,7 @@ PHP_FUNCTION(libvirt_list_domains)<br />         int *ids;<br />   char **names;<br />       const char *name;<br />-  int i;<br />+     int i, rv;<br />  virDomainPtr domain=NULL;<br /> <br />      GET_CONNECTION_FROM_ARGS("r",&zconn);<br />@@ -3490,6 +3490,12 @@ PHP_FUNCTION(libvirt_list_domains)<br />    }<br />           efree(ids);<br /> <br />+   rv = virDomainFree (domain);  // Y.Kawada<br />+  if (rv != 0) {<br />+             php_error_docref(NULL TSRMLS_CC, E_WARNING,"virDomainFree failed with %i on list_domain: %s", rv, LIBVIRT_G (last_error));<br />+        }<br />+        domain = NULL;<br />+<br />  expectedcount=virConnectNumOfDefinedDomains (conn->conn);<br />        names=emalloc(expectedcount*sizeof(char *));<br />        count=virConnectListDefinedDomains (conn->conn,names ,expectedcount);