I'm implementing a php interface to libvirt which uses libvirt-php as an api but i found that there's missing command in the libvirt-php module that use to hard reset the vm (from command 'virsh reset') so I have to add it using the same process as the 'libvirt_domain_reboot' function. Here is the patch for it:
diff -ur libvirt-php-0.4.6.orig/src/libvirt-php.c libvirt-php-0.4.6/src/libvirt-php.c
--- libvirt-php-0.4.6.orig/src/libvirt-php.c 2012-08-20 11:22:39.000000000 +0700
+++ libvirt-php-0.4.6/src/libvirt-php.c 2012-09-24 13:50:34.751140249 +0700
@@ -102,6 +102,7 @@
PHP_FE(libvirt_domain_managedsave, NULL)
PHP_FE(libvirt_domain_undefine, NULL)
PHP_FE(libvirt_domain_reboot, NULL)
+ PHP_FE(libvirt_domain_reset, NULL)
PHP_FE(libvirt_domain_define_xml, NULL)
PHP_FE(libvirt_domain_create_xml, NULL)
PHP_FE(libvirt_domain_memory_peek,NULL)
@@ -4910,6 +4911,28 @@
}
/*
+ Function name: libvirt_domain_reset
+ Since version: 0.4.6-iz
+ Description: Function is used to reset the domain identified by it's resource
+ Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()
+ Returns: TRUE for success, FALSE on error
+*/
+PHP_FUNCTION(libvirt_domain_reset)
+{
+ php_libvirt_domain *domain=NULL;
+ zval *zdomain;
+ int retval;
+ long flags=0;
+
+ GET_DOMAIN_FROM_ARGS("r|l",&zdomain,&flags);
+
+ retval=virDomainReset(domain->domain,flags);
+ DPRINTF("%s: virDomainReset(%p) returned %d\n", PHPFUNC, domain->domain, retval);
+ if (retval != 0) RETURN_FALSE;
+ RETURN_TRUE;
+}
+
+/*
Function name: libvirt_domain_define_xml
Since version: 0.4.1(-1)
Description: Function is used to define the domain from XML string
diff -ur libvirt-php-0.4.6.orig/src/libvirt-php.h libvirt-php-0.4.6/src/libvirt-php.h
--- libvirt-php-0.4.6.orig/src/libvirt-php.h 2012-08-07 22:11:25.000000000 +0700
+++ libvirt-php-0.4.6/src/libvirt-php.h 2012-09-24 13:49:05.428130682 +0700
@@ -314,6 +314,7 @@
PHP_FUNCTION(libvirt_domain_managedsave);
PHP_FUNCTION(libvirt_domain_undefine);
PHP_FUNCTION(libvirt_domain_reboot);
+PHP_FUNCTION(libvirt_domain_reset);
PHP_FUNCTION(libvirt_domain_define_xml);
PHP_FUNCTION(libvirt_domain_create_xml);
PHP_FUNCTION(libvirt_domain_memory_peek);
--
Personal hosting by icez network
http://www.thzhost.com