[libvirt-php][PATCH v1] add libvirt_domain_qemu_agent_command

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

 



add another missing libvirt command

Signed-off-by: Vasiliy Tolstov <v.tolstov@xxxxxxxxx>
---
 configure.ac      |  3 +++
 src/Makefile.am   |  5 +++--
 src/libvirt-php.c | 28 ++++++++++++++++++++++++++++
 src/libvirt-php.h |  2 ++
 4 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9e9fee0..0afa2e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,9 @@ PKG_PROG_PKG_CONFIG

 LIBVIRT_REQUIRED=0.6.2
 PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
+PKG_CHECK_MODULES(QEMU, libvirt-qemu)
+AC_SUBST([QEMU_CFLAGS])
+AC_SUBST([QEMU_LIBS])

 dnl ==========================================================================
 dnl required minimum version of libxml2
diff --git a/src/Makefile.am b/src/Makefile.am
index 8e6a800..f270ec2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,13 +27,14 @@ uninstall-local:

 AM_CFLAGS = \
 	$(PHPINC) $(LIBXML_CFLAGS) \
-	$(LIBVIRT_CFLAGS) $(DEFINES) \
+	$(LIBVIRT_CFLAGS) $(QEMU_CFLAGS) $(DEFINES) \
 	-I$(top_srcdir)/winsrc

 AM_LDFLAGS = \
 	$(SHLIB_LDFLAGS) \
 	$(LIBXML_LIBS) \
-	$(LIBVIRT_LIBS)
+	$(LIBVIRT_LIBS) \
+	$(QEMU_LIBS)

 lib_LTLIBRARIES = libvirt-php.la

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index d46fbb9..f9d5557 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -161,6 +161,7 @@ static zend_function_entry libvirt_functions[] = {
 	PHP_FE(libvirt_domain_send_keys, NULL)
 	PHP_FE(libvirt_domain_send_pointer_event, NULL)
 	PHP_FE(libvirt_domain_update_device, NULL)
+	PHP_FE(libvirt_domain_qemu_agent_command, NULL)
 	/* Domain snapshot functions */
 	PHP_FE(libvirt_domain_has_current_snapshot, NULL)
 	PHP_FE(libvirt_domain_snapshot_create, NULL)
@@ -3943,6 +3944,33 @@ PHP_FUNCTION(libvirt_domain_get_name)
 }

 /*
+	Function name:	libvirt_domain_qemu_agent_command
+	Since version:	0.5.2(-1)
+	Description:	Function is used to send qemu-ga command
+	Arguments:	@res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()
+			@timeout [int]: timeout for waiting (-2 block, -1 default, 0 no wait, >0 wait specific time
+			@flags [int]: ??
+	Returns:	String on success and FALSE on error
+*/
+PHP_FUNCTION(libvirt_domain_qemu_agent_command)
+{
+	php_libvirt_domain *domain=NULL;
+	zval *zdomain;
+	const char *cmd;
+	int cmd_len;
+	char *ret;
+	long timeout = -1;
+	long flags = 0;
+
+	GET_DOMAIN_FROM_ARGS("rs|l|l", &zdomain, &cmd, &cmd_len, &timeout, &flags);
+
+	ret = virDomainQemuAgentCommand(domain->domain, cmd, timeout, flags);
+	if (ret == NULL) RETURN_FALSE;
+
+	RETURN_STRING(ret,1);
+}
+
+/*
 	Function name:	libvirt_domain_get_uuid_string
 	Since version:	0.4.1(-1)
 	Description:	Function is used to get the domain's UUID in string format
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 7c9a229..1d9c6ab 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -80,6 +80,7 @@

 #include <libvirt/libvirt.h>
 #include <libvirt/virterror.h>
+#include <libvirt/libvirt-qemu.h>
 #include <libxml/parser.h>
 #include <libxml/xpath.h>
 #include <fcntl.h>
@@ -427,6 +428,7 @@ PHP_FUNCTION(libvirt_domain_send_keys);
 PHP_FUNCTION(libvirt_domain_send_pointer_event);
 PHP_FUNCTION(libvirt_domain_get_metadata);
 PHP_FUNCTION(libvirt_domain_set_metadata);
+PHP_FUNCTION(libvirt_domain_qemu_agent_command);
 /* Domain snapshot functions */
 PHP_FUNCTION(libvirt_domain_has_current_snapshot);
 PHP_FUNCTION(libvirt_domain_snapshot_create);
--
2.3.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]