[libvirt] [libvirt-php] Add libvirt_storagepool_build() function

Lyre liyong at skybility.com
Wed Apr 20 02:33:02 UTC 2011


also add flags for this function, currently not used.
---
 src/libvirt-php.c |   31 +++++++++++++++++++++++++++++++
 src/libvirt-php.h |    1 +
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index d436e1c..54331bb 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -129,6 +129,7 @@ static function_entry libvirt_functions[] = {
 	PHP_FE(libvirt_storagepool_refresh, NULL)
 	PHP_FE(libvirt_storagepool_set_autostart, NULL)
 	PHP_FE(libvirt_storagepool_get_autostart, NULL)
+	PHP_FE(libvirt_storagepool_build, NULL)
 	/* Network functions */
 	PHP_FE(libvirt_network_define_xml, NULL)
 	PHP_FE(libvirt_network_undefine, NULL)
@@ -542,6 +543,13 @@ PHP_MINIT_FUNCTION(libvirt)
 	/* Forcibly modify device (ex. force eject a cdrom) */
 	REGISTER_LONG_CONSTANT("VIR_DOMAIN_DEVICE_MODIFY_FORCE",	4, CONST_CS | CONST_PERSISTENT);
 
+	/* REGISTER_LONG_CONSTANT */
+	REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_NEW",	 	0, CONST_CS | CONST_PERSISTENT);
+	/* Repair / reinitialize */
+	REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_REPAIR",	 	1, CONST_CS | CONST_PERSISTENT); 
+	/* Extend existing pool */
+	REGISTER_LONG_CONSTANT("VIR_STORAGE_POOL_BUILD_RESIZE",		2, CONST_CS | CONST_PERSISTENT);
+
 	REGISTER_INI_ENTRIES();
 
 	/* Initialize libvirt and set up error callback */
@@ -3582,6 +3590,29 @@ PHP_FUNCTION(libvirt_storagepool_get_autostart)
 	}
 }
 
+/*
+	Function name:	libvirt_storagepool_build
+	Since version:	0.4.2
+	Description:	Function is used to Build the underlying storage pool, e.g. create the destination directory for NFS
+	Arguments:	@res [resource]: libvirt storagepool resource
+	Returns:	TRUE if success, FALSE on error
+*/
+PHP_FUNCTION(libvirt_storagepool_build)
+{
+	php_libvirt_storagepool *pool = NULL;
+	zval *zpool;
+	int flags = 0;
+
+	GET_STORAGEPOOL_FROM_ARGS ("r", &zpool);
+
+	if (virStoragePoolBuild (pool->pool, flags) == 0)
+	{
+		RETURN_TRUE;
+	}
+	
+	RETURN_FALSE;
+}
+
 /* Listing functions */
 /*
 	Function name:	libvirt_list_storagepools
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 4e8dec6..2d79f60 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -193,6 +193,7 @@ PHP_FUNCTION(libvirt_storagepool_get_volume_count);
 PHP_FUNCTION(libvirt_storagepool_refresh);
 PHP_FUNCTION(libvirt_storagepool_set_autostart);
 PHP_FUNCTION(libvirt_storagepool_get_autostart);
+PHP_FUNCTION(libvirt_storagepool_build);
 /* Network functions */
 PHP_FUNCTION(libvirt_network_define_xml);
 PHP_FUNCTION(libvirt_network_undefine);
-- 
1.7.3.4




More information about the libvir-list mailing list