We currently have all other power-related functions implemented,
but are missing the ability to call virDomainReset from the PHP
bindings. This adds that functionality.
Signed-off-by: Marcus Recck <mrecck(a)datto.com>
---
doc/source/libvirt/entities.functions.xml | 1 +
.../functions/libvirt-domain-reboot.xml | 1 +
.../functions/libvirt-domain-reset.xml | 82 +++++++++++++++++++
.../functions/libvirt-domain-resume.xml | 1 +
.../functions/libvirt-domain-shutdown.xml | 1 +
.../functions/libvirt-domain-suspend.xml | 1 +
examples/libvirt.php | 9 ++
src/libvirt-domain.c | 24 ++++++
src/libvirt-domain.h | 2 +
9 files changed, 122 insertions(+)
create mode 100644 doc/source/libvirt/functions/libvirt-domain-reset.xml
diff --git a/doc/source/libvirt/entities.functions.xml
b/doc/source/libvirt/entities.functions.xml
index 58faefa..0c1c83c 100644
--- a/doc/source/libvirt/entities.functions.xml
+++ b/doc/source/libvirt/entities.functions.xml
@@ -22,6 +22,7 @@
&reference.libvirt.functions.libvirt-domain-migrate-to-uri;
&reference.libvirt.functions.libvirt-domain-migrate;
&reference.libvirt.functions.libvirt-domain-reboot;
+&reference.libvirt.functions.libvirt-domain-reset;
&reference.libvirt.functions.libvirt-domain-resume;
&reference.libvirt.functions.libvirt-domain-shutdown;
&reference.libvirt.functions.libvirt-domain-suspend;
diff --git a/doc/source/libvirt/functions/libvirt-domain-reboot.xml
b/doc/source/libvirt/functions/libvirt-domain-reboot.xml
index b2531f6..8e00ece 100644
--- a/doc/source/libvirt/functions/libvirt-domain-reboot.xml
+++ b/doc/source/libvirt/functions/libvirt-domain-reboot.xml
@@ -53,6 +53,7 @@
<member><function>libvirt_domain_shutdown</function></member>
<member><function>libvirt_domain_suspend</function></member>
<member><function>libvirt_domain_create</function></member>
+ <member><function>libvirt_domain_reset</function></member>
</simplelist>
</para>
</refsect1>
diff --git a/doc/source/libvirt/functions/libvirt-domain-reset.xml
b/doc/source/libvirt/functions/libvirt-domain-reset.xml
new file mode 100644
index 0000000..51af0c1
--- /dev/null
+++ b/doc/source/libvirt/functions/libvirt-domain-reset.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Revision: 1.28 $ -->
+
+<refentry xml:id="function.libvirt-domain-reset"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink">
+ <refnamediv>
+ <refname>libvirt_domain_reset</refname>
+ <refpurpose>Reset a domain</refpurpose>
+ </refnamediv>
+
+ <refsect1 role="description">
+ &reftitle.description;
+ <methodsynopsis>
+
<type>bool</type><methodname>libvirt_domain_reset</methodname>
+ <methodparam
><type>resource</type><parameter>domain</parameter></methodparam>
+ </methodsynopsis>
+ <para>
+ Reset a domain immediately without any guest shutdown.
+ </para>
+
+ </refsect1>
+
+ <refsect1 role="parameters">
+ &reftitle.parameters;
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><parameter>domain</parameter></term>
+ <listitem>
+ <para>
+ Domain resource of domain to reset. You can get domain resource using various
functions (i.e. <function>libvirt_domain_lookup_by_uuid</function> or
<function>libvirt_list_domains</function>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect1>
+
+ <refsect1 role="returnvalues">
+ &reftitle.returnvalues;
+ <!-- See also &return.success; -->
+ <para>
+ &true; on success and &false; on failure
+ </para>
+ </refsect1>
+
+
+
+ <refsect1 role="seealso">
+ &reftitle.seealso;
+ <para>
+ <simplelist>
+ <member><function>libvirt_domain_reboot</function></member>
+ <member><function>libvirt_domain_resume</function></member>
+ <member><function>libvirt_domain_suspend</function></member>
+ <member><function>libvirt_domain_create</function></member>
+
<member><function>libvirt_domain_shutdown</function></member>
+ </simplelist>
+ </para>
+ </refsect1>
+
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+indent-tabs-mode:nil
+sgml-parent-document:nil
+sgml-default-dtd-file:"../../../../manual.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+vim600: syn=xml fen fdm=syntax fdl=2 si
+vim: et tw=78 syn=sgml
+vi: ts=1 sw=1
+-->
diff --git a/doc/source/libvirt/functions/libvirt-domain-resume.xml
b/doc/source/libvirt/functions/libvirt-domain-resume.xml
index c7d1ba4..cf6378a 100644
--- a/doc/source/libvirt/functions/libvirt-domain-resume.xml
+++ b/doc/source/libvirt/functions/libvirt-domain-resume.xml
@@ -53,6 +53,7 @@
<member><function>libvirt_domain_shutdown</function></member>
<member><function>libvirt_domain_suspend</function></member>
<member><function>libvirt_domain_create</function></member>
+ <member><function>libvirt_domain_reset</function></member>
</simplelist>
</para>
</refsect1>
diff --git a/doc/source/libvirt/functions/libvirt-domain-shutdown.xml
b/doc/source/libvirt/functions/libvirt-domain-shutdown.xml
index 99d6dde..5ae430b 100644
--- a/doc/source/libvirt/functions/libvirt-domain-shutdown.xml
+++ b/doc/source/libvirt/functions/libvirt-domain-shutdown.xml
@@ -53,6 +53,7 @@
<member><function>libvirt_domain_resume</function></member>
<member><function>libvirt_domain_suspend</function></member>
<member><function>libvirt_domain_create</function></member>
+ <member><function>libvirt_domain_reset</function></member>
</simplelist>
</para>
</refsect1>
diff --git a/doc/source/libvirt/functions/libvirt-domain-suspend.xml
b/doc/source/libvirt/functions/libvirt-domain-suspend.xml
index 6787c7e..6627a5e 100644
--- a/doc/source/libvirt/functions/libvirt-domain-suspend.xml
+++ b/doc/source/libvirt/functions/libvirt-domain-suspend.xml
@@ -53,6 +53,7 @@
<member><function>libvirt_domain_resume</function></member>
<member><function>libvirt_domain_shutdown</function></member>
<member><function>libvirt_domain_create</function></member>
+ <member><function>libvirt_domain_reset</function></member>
</simplelist>
</para>
</refsect1>
diff --git a/examples/libvirt.php b/examples/libvirt.php
index 8e56327..1b1c9d0 100644
--- a/examples/libvirt.php
+++ b/examples/libvirt.php
@@ -873,6 +873,15 @@ class Libvirt {
return ($tmp) ? $tmp : $this->_set_last_error();
}
+ function domain_reset($domain) {
+ $dom = $this->get_domain_object($domain);
+ if (!$dom)
+ return false;
+
+ $tmp = libvirt_domain_reset($dom);
+ return ($tmp) ? $tmp: $this->_set_last_error();
+ }
+
function domain_suspend($domain) {
$dom = $this->get_domain_object($domain);
if (!$dom)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 701aab3..9a7f28c 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -1496,6 +1496,30 @@ PHP_FUNCTION(libvirt_domain_reboot)
RETURN_TRUE;
}
+/*
+ * Function name: libvirt_domain_reset
+ * Since version: 0.5.5
+ * Description: Function is used to reset the domain identified by its resource
+ * Arguments: @res [resource]: libvirt domain resource, e.g. from
libvirt_domain_lookup_by_*()
+ @flags [int]: optional flags
+ * Returns: TRUE for success, FALSE on error
+ */
+PHP_FUNCTION(libvirt_domain_reset)
+{
+ php_libvirt_domain *domain = NULL;
+ zval *zdomain;
+ int retval;
+ zend_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)
diff --git a/src/libvirt-domain.h b/src/libvirt-domain.h
index f15237f..8b80c9c 100644
--- a/src/libvirt-domain.h
+++ b/src/libvirt-domain.h
@@ -74,6 +74,7 @@
PHP_FE(libvirt_domain_managedsave, arginfo_libvirt_conn)
\
PHP_FE(libvirt_domain_undefine, arginfo_libvirt_conn)
\
PHP_FE(libvirt_domain_reboot, arginfo_libvirt_conn_flags)
\
+ PHP_FE(libvirt_domain_reset, arginfo_libvirt_conn_flags)
\
PHP_FE(libvirt_domain_define_xml, arginfo_libvirt_conn_xml)
\
PHP_FE(libvirt_domain_create_xml, arginfo_libvirt_conn_xml)
\
PHP_FE(libvirt_domain_xml_from_native, arginfo_libvirt_domain_xml_from_native)
\
@@ -165,6 +166,7 @@ PHP_FUNCTION(libvirt_domain_suspend);
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_xml_from_native);
--
2.24.0