* add more snapshot flag constants
* add flags support to snapshot functions
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
src/libvirt-php.c | 61 ++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 49 insertions(+), 12 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index d13e5b4..a2949f1 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -1240,6 +1240,31 @@ PHP_MINIT_FUNCTION(libvirt)
/* Domain snapshot constants */
REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_DELETE_CHILDREN",
VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_DELETE_METADATA_ONLY",
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_DELETE_CHILDREN_ONLY",
VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_REDEFINE",
VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_CURRENT",
VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_NO_METADATA",
VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_HALT",
VIR_DOMAIN_SNAPSHOT_CREATE_HALT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_DISK_ONLY",
VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_REUSE_EXT",
VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_QUIESCE",
VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_ATOMIC",
VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_CREATE_LIVE",
VIR_DOMAIN_SNAPSHOT_CREATE_LIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_DESCENDANTS",
VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_ROOTS",
VIR_DOMAIN_SNAPSHOT_LIST_ROOTS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_METADATA",
VIR_DOMAIN_SNAPSHOT_LIST_METADATA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_LEAVES",
VIR_DOMAIN_SNAPSHOT_LIST_LEAVES, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_NO_LEAVES",
VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_NO_METADATA",
VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_INACTIVE",
VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_ACTIVE",
VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_DISK_ONLY",
VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_INTERNAL",
VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_LIST_EXTERNAL",
VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_REVERT_RUNNING",
VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_REVERT_PAUSED",
VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_SNAPSHOT_REVERT_FORCE",
VIR_DOMAIN_SNAPSHOT_REVERT_FORCE, CONST_CS | CONST_PERSISTENT);
/* Memory constants */
REGISTER_LONG_CONSTANT("VIR_MEMORY_VIRTUAL", 1, CONST_CS |
CONST_PERSISTENT);
@@ -6568,6 +6593,7 @@ PHP_FUNCTION(libvirt_domain_get_job_info)
* Since version: 0.4.1(-2)
* Description: Function is used to get the information whether domain has the
current snapshot
* Arguments: @res [resource]: libvirt domain resource
+ * @flags [int]: libvirt snapshot flags
* Returns: TRUE is domain has the current snapshot, otherwise FALSE (you may
need to check for error using libvirt_get_last_error())
*/
PHP_FUNCTION(libvirt_domain_has_current_snapshot)
@@ -6575,10 +6601,11 @@ PHP_FUNCTION(libvirt_domain_has_current_snapshot)
php_libvirt_domain *domain=NULL;
zval *zdomain;
int retval;
+ long flags = 0;
- GET_DOMAIN_FROM_ARGS("r",&zdomain);
+ GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags);
- retval=virDomainHasCurrentSnapshot(domain->domain, 0);
+ retval=virDomainHasCurrentSnapshot(domain->domain, flags);
if (retval <= 0) RETURN_FALSE;
RETURN_TRUE;
}
@@ -6589,6 +6616,7 @@ PHP_FUNCTION(libvirt_domain_has_current_snapshot)
* Description: This functions is used to lookup for the snapshot by it's name
* Arguments: @res [resource]: libvirt domain resource
* @name [string]: name of the snapshot to get the resource
+ * @flags [int]: libvirt snapshot flags
* Returns: domain snapshot resource
*/
PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name)
@@ -6597,13 +6625,14 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name)
zval *zdomain;
int name_len;
char *name=NULL;
+ long flags = 0;
php_libvirt_snapshot *res_snapshot;
virDomainSnapshotPtr snapshot = NULL;
- GET_DOMAIN_FROM_ARGS("rs",&zdomain,&name,&name_len);
+
GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&name,&name_len,&flags);
if ( (name == NULL) || (name_len<1)) RETURN_FALSE;
- snapshot=virDomainSnapshotLookupByName(domain->domain, name, 0);
+ snapshot=virDomainSnapshotLookupByName(domain->domain, name, flags);
if (snapshot==NULL) RETURN_FALSE;
res_snapshot = (php_libvirt_snapshot *)emalloc(sizeof(php_libvirt_snapshot));
@@ -6620,6 +6649,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name)
* Since version: 0.4.1(-2)
* Description: This function creates the domain snapshot for the domain identified
by it's resource
* Arguments: @res [resource]: libvirt domain resource
+ * @flags [int]: libvirt snapshot flags
* Returns: domain snapshot resource
*/
PHP_FUNCTION(libvirt_domain_snapshot_create)
@@ -6628,10 +6658,11 @@ PHP_FUNCTION(libvirt_domain_snapshot_create)
php_libvirt_snapshot *res_snapshot;
zval *zdomain;
virDomainSnapshotPtr snapshot = NULL;
+ long flags = 0;
- GET_DOMAIN_FROM_ARGS("r",&zdomain);
+ GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags);
- snapshot=virDomainSnapshotCreateXML(domain->domain,
"<domainsnapshot/>", 0);
+ snapshot=virDomainSnapshotCreateXML(domain->domain,
"<domainsnapshot/>", flags);
DPRINTF("%s: virDomainSnapshotCreateXML(%p, <xml>) returned %p\n",
PHPFUNC, domain->domain, snapshot);
if (snapshot == NULL) RETURN_FALSE;
@@ -6649,6 +6680,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_create)
* Since version: 0.4.1(-2)
* Description: Function is used to get the XML description of the snapshot
identified by it's resource
* Arguments: @res [resource]: libvirt snapshot resource
+ * @flags [int]: libvirt snapshot flags
* Returns: XML description string for the snapshot
*/
PHP_FUNCTION(libvirt_domain_snapshot_get_xml)
@@ -6657,10 +6689,11 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml)
char *xml_out;
zval *zsnapshot;
php_libvirt_snapshot *snapshot;
+ long flags = 0;
- GET_SNAPSHOT_FROM_ARGS("r",&zsnapshot);
+ GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags);
- xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, 0);
+ xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags);
if (xml==NULL) RETURN_FALSE;
RECREATE_STRING_WITH_E(xml_out,xml);
@@ -6673,6 +6706,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml)
* Since version: 0.4.1(-2)
* Description: Function is used to revert the domain state to the state identified
by the snapshot
* Arguments: @res [resource]: libvirt snapshot resource
+ * @flags [int]: libvirt snapshot flags
* Returns: TRUE on success, FALSE on error
*/
PHP_FUNCTION(libvirt_domain_snapshot_revert)
@@ -6680,10 +6714,11 @@ PHP_FUNCTION(libvirt_domain_snapshot_revert)
zval *zsnapshot;
php_libvirt_snapshot *snapshot;
int ret;
+ long flags = 0;
- GET_SNAPSHOT_FROM_ARGS("r",&zsnapshot);
+ GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags);
- ret = virDomainRevertToSnapshot(snapshot->snapshot, 0);
+ ret = virDomainRevertToSnapshot(snapshot->snapshot, flags);
DPRINTF("%s: virDomainRevertToSnapshot(%p, 0) returned %d\n", PHPFUNC,
snapshot->snapshot, ret);
if (ret == -1) RETURN_FALSE;
RETURN_TRUE;
@@ -6717,6 +6752,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_delete)
* Since version: 0.4.1(-2)
* Description: Function is used to list domain snapshots for the domain specified by
it's resource
* Arguments: @res [resource]: libvirt domain resource
+ * @flags [int]: libvirt snapshot flags
* Returns: libvirt domain snapshot names array
*/
PHP_FUNCTION(libvirt_list_domain_snapshots)
@@ -6726,11 +6762,12 @@ PHP_FUNCTION(libvirt_list_domain_snapshots)
int count=-1;
int expectedcount=-1;
char **names;
+ long flags = 0;
int i;
- GET_DOMAIN_FROM_ARGS("r",&zdomain);
+ GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags);
- expectedcount=virDomainSnapshotNum(domain->domain, 0);
+ expectedcount=virDomainSnapshotNum(domain->domain, flags);
DPRINTF("%s: virDomainSnapshotNum(%p, 0) returned %d\n", PHPFUNC,
domain->domain, expectedcount);
if (expectedcount != -1 ) {
--
2.3.3