[libvirt-php 2/3] add block_commit support and needed const

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

 



Signed-off-by: Vasiliy Tolstov <v.tolstov@xxxxxxxxx>
---
 src/libvirt-php.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/libvirt-php.h |  1 +
 2 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 4034458e0e4f..8e03d86a811a 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -138,6 +138,7 @@ static zend_function_entry libvirt_functions[] = {
     PHP_FE(libvirt_domain_set_memory,NULL)
     PHP_FE(libvirt_domain_set_max_memory,NULL)
     PHP_FE(libvirt_domain_set_memory_flags,NULL)
+    PHP_FE(libvirt_domain_block_commit, NULL)
     PHP_FE(libvirt_domain_block_stats,NULL)
     PHP_FE(libvirt_domain_block_resize,NULL)
     PHP_FE(libvirt_domain_block_job_abort,NULL)
@@ -1355,11 +1356,40 @@ PHP_MINIT_FUNCTION(libvirt)
     /* Job was aborted but it's not cleanup up yet */
     REGISTER_LONG_CONSTANT("VIR_DOMAIN_JOB_CANCELLED",  5, CONST_CS | CONST_PERSISTENT);
 
+
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_COMMIT_SHALLOW", VIR_DOMAIN_BLOCK_COMMIT_SHALLOW, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_COMMIT_DELETE", VIR_DOMAIN_BLOCK_COMMIT_DELETE, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_COMMIT_ACTIVE", VIR_DOMAIN_BLOCK_COMMIT_ACTIVE, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_COMMIT_RELATIVE", VIR_DOMAIN_BLOCK_COMMIT_RELATIVE, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES", VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES, CONST_CS | CONST_PERSISTENT);
+
+
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_COPY_SHALLOW", VIR_DOMAIN_BLOCK_COPY_SHALLOW, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_COPY_REUSE_EXT", VIR_DOMAIN_BLOCK_COPY_REUSE_EXT, CONST_CS | CONST_PERSISTENT);
+
     REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC",  VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC, CONST_CS | CONST_PERSISTENT);
     REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT",  VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT, CONST_CS | CONST_PERSISTENT);
-
     REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES",    VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES, CONST_CS | CONST_PERSISTENT);
 
+
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN", VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_TYPE_PULL", VIR_DOMAIN_BLOCK_JOB_TYPE_PULL, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_TYPE_COPY", VIR_DOMAIN_BLOCK_JOB_TYPE_COPY, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT", VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT", VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT, CONST_CS | CONST_PERSISTENT);
+
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_PULL_BANDWIDTH_BYTES", VIR_DOMAIN_BLOCK_PULL_BANDWIDTH_BYTES, CONST_CS | CONST_PERSISTENT);
+
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_REBASE_SHALLOW", VIR_DOMAIN_BLOCK_REBASE_SHALLOW, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT", VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_REBASE_COPY_RAW", VIR_DOMAIN_BLOCK_REBASE_COPY_RAW, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_REBASE_COPY", VIR_DOMAIN_BLOCK_REBASE_COPY, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_REBASE_RELATIVE", VIR_DOMAIN_BLOCK_REBASE_RELATIVE, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_REBASE_COPY_DEV", VIR_DOMAIN_BLOCK_REBASE_COPY_DEV, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_REBASE_BANDWIDTH_BYTES", VIR_DOMAIN_BLOCK_REBASE_BANDWIDTH_BYTES, CONST_CS | CONST_PERSISTENT);
+
+    REGISTER_LONG_CONSTANT("VIR_DOMAIN_BLOCK_RESIZE_BYTES", VIR_DOMAIN_BLOCK_RESIZE_BYTES, CONST_CS | CONST_PERSISTENT);
+
     /* Migration constants */
     REGISTER_LONG_CONSTANT("VIR_MIGRATE_LIVE",        1, CONST_CS | CONST_PERSISTENT);
     /* direct source -> dest host control channel Note the less-common spelling that we're stuck with: */
@@ -6082,6 +6112,40 @@ PHP_FUNCTION(libvirt_domain_block_resize)
 }
 
 /*
+ * Function name:   libvirt_domain_block_commit
+ * Since version:   0.5.2(-1)
+ * Description:     Function is used to commit block job
+ * Arguments:       @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()
+ *                  @disk [string]: path to the block device, or device shorthand
+ *                  @base [string]: path to backing file to merge into, or device shorthand, or NULL for default
+ *                  @top [string]: path to file within backing chain that contains data to be merged, or device shorthand, or NULL to merge all possible data
+ *                  @bandwidth [int]: (optional) specify bandwidth limit; flags determine the unit
+ *                  @flags [int]: bitwise-OR of VIR_DOMAIN_BLOCK_COMMIT_*
+ * Returns:         true on success fail on error
+ */
+PHP_FUNCTION(libvirt_domain_block_commit)
+{
+        php_libvirt_domain *domain=NULL;
+        zval *zdomain;
+        int retval;
+        char *disk;
+        int disk_len;
+        char *base = NULL;
+        int base_len;
+        char *top = NULL;
+        int top_len;
+        long bandwidth = 0;
+        long flags = 0;
+
+        GET_DOMAIN_FROM_ARGS("rsssll",&zdomain, &disk, &disk_len, &base, &base_len, &top, &top_len, &bandwidth, &flags);
+
+        retval=virDomainBlockCommit(domain->domain, disk, base, top, bandwidth, flags);
+        if (retval == -1) RETURN_FALSE;
+
+        RETURN_TRUE;
+}
+
+/*
  * Function name:   libvirt_domain_block_job_abort
  * Since version:   0.5.1(-1)
  * Description:     Function is used to abort block job
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index eb4b7f4d0656..cb06c2d0b8a7 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -403,6 +403,7 @@ PHP_FUNCTION(libvirt_domain_set_memory_flags);
 PHP_FUNCTION(libvirt_domain_memory_peek);
 PHP_FUNCTION(libvirt_domain_memory_stats);
 PHP_FUNCTION(libvirt_domain_update_device);
+PHP_FUNCTION(libvirt_domain_block_commit);
 PHP_FUNCTION(libvirt_domain_block_stats);
 PHP_FUNCTION(libvirt_domain_block_resize);
 PHP_FUNCTION(libvirt_domain_block_job_abort);
-- 
2.7.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]