[libvirt-php] domains: added autostart and is active

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

 



This patch added following functions for domain:

* integer libvirt_domain_get_autostart(resource $domain)
  return 1, 0, and -1 indicates true, false, and error.

* bool libvirt_domain_set_autostart(resource $domain, bool $autosatrt)
  return ture on succeess and false on failure.

* integer libvirt_domain_is_active(resource $domain)
  return 1, 0, and -1 indicates true, false, and error.

	modified:   src/libvirt.c
	modified:   src/php_libvirt.h
---
 src/libvirt.c     |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 src/php_libvirt.h |    3 +++
 2 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 570511e..748d898 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -63,6 +63,9 @@ static function_entry libvirt_functions[] = {
 	PHP_FE(libvirt_domain_memory_stats,NULL)
 	PHP_FE(libvirt_domain_block_stats,NULL)
 	PHP_FE(libvirt_domain_interface_stats,NULL)
+	PHP_FE(libvirt_domain_get_autostart, NULL)
+	PHP_FE(libvirt_domain_set_autostart, NULL)
+	PHP_FE(libvirt_domain_is_active, NULL)
 	PHP_FE(libvirt_version,NULL)
 	PHP_FE(libvirt_domain_get_connect, NULL)
 	PHP_FE(libvirt_domain_migrate, NULL)
@@ -70,7 +73,7 @@ static function_entry libvirt_functions[] = {
 	PHP_FE(libvirt_domain_get_job_info, NULL)
 	PHP_FE(libvirt_domain_xml_xpath, NULL)
 	PHP_FE(libvirt_domain_get_block_info, NULL)
-        PHP_FE(libvirt_domain_get_network_info, NULL)
+    PHP_FE(libvirt_domain_get_network_info, NULL)
 	PHP_FE(libvirt_list_storagepools,NULL)
 	PHP_FE(libvirt_storagepool_lookup_by_name,NULL)
 	PHP_FE(libvirt_storagepool_list_volumes,NULL)
@@ -2200,6 +2203,46 @@ PHP_FUNCTION(libvirt_domain_interface_stats)
 	LONGLONG_ASSOC(return_value, "tx_drop", stats.tx_drop); 
 }
 
+PHP_FUNCTION(libvirt_domain_get_autostart)
+{
+	php_libvirt_domain *domain = NULL;
+	zval *zdomain;
+	int flags = 0;
+
+	GET_DOMAIN_FROM_ARGS ("r", &zdomain);
+
+	if (virDomainGetAutostart (domain->domain, &flags) != 0)
+	{
+		RETURN_LONG (-1);
+	}
+	RETURN_LONG ((long)flags);
+}
+
+PHP_FUNCTION(libvirt_domain_set_autostart)
+{
+	php_libvirt_domain *domain = NULL;
+	zval *zdomain;
+	zend_bool flags = 0;
+
+	GET_DOMAIN_FROM_ARGS ("rb", &zdomain, &flags);
+
+	if (virDomainSetAutostart (domain->domain, flags) != 0)
+	{
+		RETURN_FALSE;
+	}
+	RETURN_TRUE;
+}
+
+PHP_FUNCTION(libvirt_domain_is_active)
+{
+	php_libvirt_domain *domain = NULL;
+	zval *zdomain;
+
+	GET_DOMAIN_FROM_ARGS ("r", &zdomain);
+
+	RETURN_LONG (virDomainIsActive(domain->domain));
+}
+
 PHP_FUNCTION(libvirt_version)
 {
 	unsigned long libVer;
diff --git a/src/php_libvirt.h b/src/php_libvirt.h
index 054df46..213d27f 100644
--- a/src/php_libvirt.h
+++ b/src/php_libvirt.h
@@ -107,6 +107,9 @@ PHP_FUNCTION(libvirt_domain_memory_peek);
 PHP_FUNCTION(libvirt_domain_memory_stats);
 PHP_FUNCTION(libvirt_domain_block_stats);
 PHP_FUNCTION(libvirt_domain_interface_stats);
+PHP_FUNCTION(libvirt_domain_get_autostart);
+PHP_FUNCTION(libvirt_domain_set_autostart);
+PHP_FUNCTION(libvirt_domain_is_active);
 PHP_FUNCTION(libvirt_version);
 PHP_FUNCTION(libvirt_domain_get_connect);
 PHP_FUNCTION(libvirt_domain_migrate);
-- 
1.7.1


--
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]