[libvirt-php PATCH 31/35] add libvirt_domain_block_job_info

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

 



From: Vasiliy Tolstov <v.tolstov@xxxxxxxxx>

Signed-off-by: Vasiliy Tolstov <v.tolstov@xxxxxxxxx>
Signed-off-by: Yuriy Gromak <sewer@xxxxxxxx>
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libvirt-php.c | 36 ++++++++++++++++++++++++++++++++++++
 src/libvirt-php.h |  1 +
 2 files changed, 37 insertions(+)

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 7bea9e2..1af6077 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -143,6 +143,7 @@ static zend_function_entry libvirt_functions[] = {
     PHP_FE(libvirt_domain_block_resize,NULL)
     PHP_FE(libvirt_domain_block_job_abort,NULL)
     PHP_FE(libvirt_domain_block_job_set_speed,NULL)
+    PHP_FE(libvirt_domain_block_job_info,NULL)
     PHP_FE(libvirt_domain_interface_stats,NULL)
     PHP_FE(libvirt_domain_get_connect, NULL)
     PHP_FE(libvirt_domain_migrate, NULL)
@@ -1371,6 +1372,8 @@ PHP_MINIT_FUNCTION(libvirt)
     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_INFO_BANDWIDTH_BYTES",    VIR_DOMAIN_BLOCK_JOB_INFO_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);
@@ -6145,6 +6148,39 @@ PHP_FUNCTION(libvirt_domain_block_commit)
         RETURN_TRUE;
 }
 
+
+/*
+     * Function name:   libvirt_domain_block_job_info
+     * Since version:   0.5.2(-1)
+     * Description:     Function is used to request block job information for the given disk
+     * Arguments:       @dom [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*()
+     *                  @disk [string]: path to the block device, or device shorthand
+     *                  @flags [int]: bitwise-OR of VIR_DOMAIN_BLOCK_COMMIT_*
+     * Returns:         Array with status virDomainGetBlockJobInfo and blockjob information.
+*/
+PHP_FUNCTION(libvirt_domain_block_job_info)
+{
+    php_libvirt_domain *domain=NULL;
+    zval *zdomain;
+    int retval;
+    char *disk;
+    int disk_len;
+    long flags = 0;
+    virDomainBlockJobInfo info;
+
+    GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &disk, &disk_len, &flags);
+
+    retval=virDomainGetBlockJobInfo(domain->domain, disk, &info, flags);
+
+    array_init(return_value);
+    add_assoc_long(return_value, "status", (int)retval);
+    add_assoc_long(return_value, "type", (int)info.type);
+    add_assoc_long(return_value, "bandwidth", (unsigned long)info.bandwidth);
+    add_assoc_long(return_value, "cur", (unsigned long long)info.cur);
+    add_assoc_long(return_value, "end", (unsigned long long)info.end);
+}
+
+
 /*
  * Function name:   libvirt_domain_block_job_abort
  * Since version:   0.5.1(-1)
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index cb06c2d..a45b4bd 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -408,6 +408,7 @@ PHP_FUNCTION(libvirt_domain_block_stats);
 PHP_FUNCTION(libvirt_domain_block_resize);
 PHP_FUNCTION(libvirt_domain_block_job_abort);
 PHP_FUNCTION(libvirt_domain_block_job_set_speed);
+PHP_FUNCTION(libvirt_domain_block_job_info);
 PHP_FUNCTION(libvirt_domain_interface_stats);
 PHP_FUNCTION(libvirt_domain_get_connect);
 PHP_FUNCTION(libvirt_domain_migrate);
-- 
2.5.5

--
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]