On 10.06.2015 10:18, Vasiliy Tolstov wrote: > * libvirt_connect_get_all_domain_stats > * libvirt_domain_block_resize > * libvirt_domain_block_job_abort > * libvirt_domain_block_job_set_speed > > Signed-off-by: Vasiliy Tolstov <v.tolstov@xxxxxxxxx> > --- > src/libvirt-php.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++- > src/libvirt-php.h | 4 ++ > 2 files changed, 180 insertions(+), 1 deletion(-) >From the e-mail header: Content-Type: text/plain; charset=yes I've not know there's such charset as yes :) > > diff --git a/src/libvirt-php.c b/src/libvirt-php.c > index e9b9657..f9096ef 100644 > --- a/src/libvirt-php.c > +++ b/src/libvirt-php.c > @@ -91,6 +91,7 @@ static zend_function_entry libvirt_functions[] = { > PHP_FE(libvirt_connect_get_maxvcpus, NULL) > PHP_FE(libvirt_connect_get_encrypted, NULL) > PHP_FE(libvirt_connect_get_secure, NULL) > + PHP_FE(libvirt_connect_get_all_domain_stats, NULL) > /* Stream functions */ > PHP_FE(libvirt_stream_create, NULL) > PHP_FE(libvirt_stream_close, NULL) > @@ -136,6 +137,10 @@ static zend_function_entry libvirt_functions[] = { > PHP_FE(libvirt_domain_memory_peek,NULL) > PHP_FE(libvirt_domain_memory_stats,NULL) > PHP_FE(libvirt_domain_block_stats,NULL) > + PHP_FE(libvirt_domain_block_resize,NULL) > + // PHP_FE(libvirt_domain_block_copy,NULL) Just drop this line. > + PHP_FE(libvirt_domain_block_job_abort,NULL) > + PHP_FE(libvirt_domain_block_job_set_speed,NULL) > PHP_FE(libvirt_domain_interface_stats,NULL) > PHP_FE(libvirt_domain_get_connect, NULL) > PHP_FE(libvirt_domain_migrate, NULL) > @@ -1332,6 +1337,11 @@ 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_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); > + > /* 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: */ > @@ -1374,7 +1384,7 @@ PHP_MINIT_FUNCTION(libvirt) > REGISTER_LONG_CONSTANT("VIR_DOMAIN_FLAG_TEST_LOCAL_VNC", DOMAIN_FLAG_TEST_LOCAL_VNC, CONST_CS | CONST_PERSISTENT); > REGISTER_LONG_CONSTANT("VIR_DOMAIN_FLAG_SOUND_AC97", DOMAIN_FLAG_SOUND_AC97, CONST_CS | CONST_PERSISTENT); > REGISTER_LONG_CONSTANT("VIR_DOMAIN_DISK_FILE", DOMAIN_DISK_FILE, CONST_CS | CONST_PERSISTENT); > - REGISTER_LONG_CONSTANT("VIR_DOMAIN_DISK_BLOCK", DOMAIN_DISK_BLOCK, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_DOMAIN_DISK_BLOCK", DOMAIN_DISK_BLOCK, CONST_CS | CONST_PERSISTENT); This looks like spurious change. > REGISTER_LONG_CONSTANT("VIR_DOMAIN_DISK_ACCESS_ALL", DOMAIN_DISK_ACCESS_ALL, CONST_CS | CONST_PERSISTENT); > > /* Domain metadata constants */ > @@ -1385,6 +1395,24 @@ PHP_MINIT_FUNCTION(libvirt) > REGISTER_LONG_CONSTANT("VIR_DOMAIN_AFFECT_LIVE", 1, CONST_CS | CONST_PERSISTENT); > REGISTER_LONG_CONSTANT("VIR_DOMAIN_AFFECT_CONFIG", 2, CONST_CS | CONST_PERSISTENT); > > + REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_STATE", VIR_DOMAIN_STATS_STATE, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_CPU_TOTAL", VIR_DOMAIN_STATS_CPU_TOTAL, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_BALLOON", VIR_DOMAIN_STATS_BALLOON, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_VCPU", VIR_DOMAIN_STATS_VCPU, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_INTERFACE", VIR_DOMAIN_STATS_INTERFACE, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_DOMAIN_STATS_BLOCK", VIR_DOMAIN_STATS_BLOCK, CONST_CS | CONST_PERSISTENT); > + > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE", VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE", VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER", VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED", VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT", VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING", VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF", VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF, CONST_CS | CONST_PERSISTENT); > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT", VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT, CONST_CS | CONST_PERSISTENT); > + // REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING", VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING, CONST_CS | CONST_PERSISTENT); This line should be dropped too. > + REGISTER_LONG_CONSTANT("VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS", VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, CONST_CS | CONST_PERSISTENT); > + > /* Connect flags */ > REGISTER_LONG_CONSTANT("VIR_CONNECT_FLAG_SOUNDHW_GET_NAMES", CONNECT_FLAG_SOUNDHW_GET_NAMES, CONST_CS | CONST_PERSISTENT); > > @@ -2425,6 +2453,69 @@ PHP_FUNCTION(libvirt_connect_get_secure) > RETURN_LONG( virConnectIsSecure(conn->conn) ); > } > > + > +/* > + Function name: libvirt_connect_get_all_domain_stats > + Since version: 0.5.1(-1) > + Description: Query statistics for all domains on a given connection > + Arguments:▶ @conn [resource]: resource for connection s/▶// > + @stats [int]: the statistic groups from VIR_DOMAIN_STATS_* > + @flags [int]: the filter flags from VIR_CONNECT_GET_ALL_DOMAINS_STATS_* > + Returns: assoc array with statistics or false on error > +*/ > +PHP_FUNCTION(libvirt_connect_get_all_domain_stats) > +{ > + php_libvirt_connection *conn = NULL; > + zval *zconn; > + int retval = -1; > + long flags = 0; > + long stats = 0; > + char *name = NULL; const char *name; > + int i; > + int j; > + virTypedParameter params; > + virDomainStatsRecordPtr *retstats = NULL; > + > + GET_CONNECTION_FROM_ARGS("r|l|l",&zconn, &stats, &flags); > + > + retval = virConnectGetAllDomainStats(conn->conn, stats, &retstats, flags); > + > + array_init(return_value); > + if (retval < 0) > + RETURN_FALSE; > + > + for (i=0; i < retval; i++) { > + zval *arr2; > + ALLOC_INIT_ZVAL(arr2); > + array_init(arr2); > + for (j = 0; j < retstats[i]->nparams; j++) { > + params = retstats[i]->params[j]; > + switch (params.type) { > + case VIR_TYPED_PARAM_INT: > + add_assoc_long(arr2, params.field, params.value.i); > + case VIR_TYPED_PARAM_UINT: > + add_assoc_long(arr2, params.field, params.value.ui); > + case VIR_TYPED_PARAM_LLONG: > + add_assoc_long(arr2, params.field, params.value.l); > + case VIR_TYPED_PARAM_ULLONG: > + add_assoc_long(arr2, params.field, params.value.ul); > + case VIR_TYPED_PARAM_DOUBLE: > + add_assoc_double(arr2, params.field, params.value.d); > + case VIR_TYPED_PARAM_BOOLEAN: > + add_assoc_bool(arr2, params.field, params.value.b); > + case VIR_TYPED_PARAM_STRING: > + add_assoc_string_ex(arr2, params.field, strlen(params.field)+1, params.value.s, strlen(params.value.s)+1); > + } > + } > + name = virDomainGetName(retstats[i]->dom); > + zend_hash_update(Z_ARRVAL_P(return_value), name, strlen(name)+1, &arr2, sizeof(arr2), NULL); > + } > + > + virDomainStatsRecordListFree(retstats); > +} > + > + > + Otherwise looking good. Fixed all the nits, ACKed and pushed. Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list