screenshot of remote host is available.
get_domain_object make so many error to message log, so you had better not
use .
diff --git a/examples/libvirt.php b/examples/libvirt.php
index 1ca71b6..bf903f6 100644
--- a/examples/libvirt.php
+++ b/examples/libvirt.php
@@ -29,9 +29,9 @@
}
function domain_get_screenshot($domain) {
- $dom = $this->get_domain_object($domain);
-
- $tmp = libvirt_domain_get_screenshot($dom);
+ $dom = libvirt_domain_lookup_by_uuid_string($this->conn, $domain);
+ $hostname = $this->get_hostname();
+ $tmp = libvirt_domain_get_screenshot($dom, $hostname);
return ($tmp) ? $tmp : $this->_set_last_error();
}
diff --git a/src/libvirt-php.cb/src/libvirt-php.c
index 87e0467..4a53e33 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -1880,6 +1880,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot)
int port = -1;
int scancode = 10;
char *path;
+ char *hostname;
path = get_feature_binary("screenshot");
if (access(path, X_OK) != 0) {
@@ -1887,7 +1888,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot)
RETURN_FALSE;
}
- GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &scancode);
+ GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &hostname, &scancode);
xml=virDomainGetXMLDesc(domain->domain, 0);
if (xml==NULL) {
@@ -1912,10 +1913,16 @@ PHP_FUNCTION(libvirt_domain_get_screenshot)
RETURN_FALSE;
if (childpid == 0) {
+ char *prm = NULL;
char tmpp[8] = { 0 };
-
+
snprintf(tmpp, sizeof(tmpp), ":%d", port);
- retval = execlp(path, basename(path), tmpp, file, NULL);
+ prm = emalloc((sizeof(tmpp) + sizeof(hostname)) * sizeof(char));
+ sprintf(prm, "%s%s", hostname, tmpp);
+
+ retval = execlp(path, basename(path), prm, file, NULL);
+
+ free(prm);
_exit( retval );
}
else {