[libvirt-php PATCH] add API bindings for get/set network autostart

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

 



Aside from that:
* fix arginfo_libvirt_conn_flags - it has 2 args not 1
* get rid arginfo_libvirt_domain_set_autostart and use
  arginfo_libvirt_conn_flags instead as it's the same.
---
 src/libvirt-php.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-------
 src/libvirt-php.h |  2 ++
 2 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 99d6397..c2ab0da 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -284,7 +284,7 @@ ZEND_ARG_INFO(0, conn)
 ZEND_ARG_INFO(0, to)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_flags, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_flags, 0, 0, 2)
 ZEND_ARG_INFO(0, conn)
 ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO()
@@ -399,11 +399,6 @@ ZEND_ARG_INFO(0, res)
 ZEND_ARG_INFO(0, mac)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_set_autostart, 0, 0, 2)
-ZEND_ARG_INFO(0, conn)
-ZEND_ARG_INFO(0, flags)
-ZEND_END_ARG_INFO()
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_get_metadata, 0, 0, 4)
 ZEND_ARG_INFO(0, conn)
 ZEND_ARG_INFO(0, type)
@@ -662,7 +657,7 @@ static zend_function_entry libvirt_functions[] = {
     PHP_FE(libvirt_domain_get_block_info,        arginfo_libvirt_domain_get_block_info)
     PHP_FE(libvirt_domain_get_network_info,      arginfo_libvirt_domain_get_network_info)
     PHP_FE(libvirt_domain_get_autostart,         arginfo_libvirt_conn)
-    PHP_FE(libvirt_domain_set_autostart,         arginfo_libvirt_domain_set_autostart)
+    PHP_FE(libvirt_domain_set_autostart,         arginfo_libvirt_conn_flags)
     PHP_FE(libvirt_domain_get_metadata,          arginfo_libvirt_domain_get_metadata)
     PHP_FE(libvirt_domain_set_metadata,          arginfo_libvirt_domain_set_metadata)
     PHP_FE(libvirt_domain_is_active,             arginfo_libvirt_conn)
@@ -724,6 +719,8 @@ static zend_function_entry libvirt_functions[] = {
     PHP_FE(libvirt_network_get_uuid_string,      arginfo_libvirt_conn)
     PHP_FE(libvirt_network_get_uuid,             arginfo_libvirt_conn)
     PHP_FE(libvirt_network_get_name,             arginfo_libvirt_conn)
+    PHP_FE(libvirt_network_get_autostart,        arginfo_libvirt_conn)
+    PHP_FE(libvirt_network_set_autostart,        arginfo_libvirt_conn_flags)
     /* Node functions */
     PHP_FE(libvirt_node_get_info,                arginfo_libvirt_conn)
     PHP_FE(libvirt_node_get_cpu_stats,           arginfo_libvirt_conn_optcpunr)
@@ -10002,6 +9999,49 @@ PHP_FUNCTION(libvirt_network_get_name)
 }
 
 /*
+ * Function name:   libvirt_network_get_autostart
+ * Since version:   0.5.4
+ * Description:     Function is getting the autostart value for the network
+ * Arguments:       @res [resource]: libvirt network resource
+ * Returns:         autostart value or -1 on error
+ */
+PHP_FUNCTION(libvirt_network_get_autostart)
+{
+    php_libvirt_network *network = NULL;
+    zval *znetwork;
+    int autostart;
+
+    GET_NETWORK_FROM_ARGS("r", &znetwork);
+
+    if (virNetworkGetAutostart(network->network, &autostart) != 0)
+        RETURN_LONG(-1);
+
+    RETURN_LONG((long) autostart);
+}
+
+/*
+ * Function name:   libvirt_network_set_autostart
+ * Since version:   0.5.4
+ * Description:     Function is setting the autostart value for the network
+ * Arguments:       @res [resource]: libvirt network resource
+ *                  @flags [int]: flag to enable/disable autostart
+ * Returns:         TRUE on success, FALSE on error
+ */
+PHP_FUNCTION(libvirt_network_set_autostart)
+{
+    php_libvirt_network *network = NULL;
+    zval *znetwork;
+    zend_long autostart = 0;
+
+    GET_NETWORK_FROM_ARGS("rl", &znetwork, &autostart);
+
+    if (virNetworkSetAutostart(network->network, autostart) < 0)
+        RETURN_FALSE;
+
+    RETURN_TRUE;
+}
+
+/*
  * Function name:   libvirt_version
  * Since version:   0.4.1(-1)
  * Description:     Function is used to get libvirt, driver and libvirt-php version numbers. Can be used for information purposes, for version checking please use libvirt_check_version() defined below
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index f87d180..f9dec09 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -423,6 +423,8 @@ PHP_FUNCTION(libvirt_network_set_active);
 PHP_FUNCTION(libvirt_network_get_uuid_string);
 PHP_FUNCTION(libvirt_network_get_uuid);
 PHP_FUNCTION(libvirt_network_get_name);
+PHP_FUNCTION(libvirt_network_get_autostart);
+PHP_FUNCTION(libvirt_network_set_autostart);
 /* Nodedev functions */
 PHP_FUNCTION(libvirt_nodedev_get);
 PHP_FUNCTION(libvirt_nodedev_capabilities);
-- 
2.13.0

--
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]
  Powered by Linux