[libvirt] [libvirt-php PATCH 00/29] Add PHP7 support and unit tests V2

This patch set is a revision of the first version, taking into account some of the feedback from Michal Privoznik. I've done some patch surgery to rebase the patch set on the current git HEAD, so it should cleanly apply as-is. Additionally, I've squashed a few commits (mainly some of Remi's patches that were squashable that should be squashed). This means that Vasiliy's patches are no longer unnecessarily part of this patch set. I've updated my patches for the instructions on the php extension build system method to correct a typo on how to run the tests (`make test` instead of `make tests`) and removed the "-dev" suffix that Remi attached to the version string in libvirt-php.h, as I expect that there will likely be a libvirt-php release after this patch set is merged. I would greatly appreciate a quick review and merge of this patch set. Chuck Roydhouse (1): add arginfo for libvirt_domain_block_commit and libvirt_domain_block_job_info Frederic Mora (1): Add more tests Neal Gompa (2): Commit short instructions to using the php extension build method Bump version to 0.5.2 Remi Collet (25): add config.m4 to allow standard PHP extension build system include config.h earlier add missing arginfo adapt RETURN_STRING work on zpp register + fetch resources + hash adapt add_assoc_string_ex clean ALLOC_INIT_ZVAL zend_hash_update add_next_index_string buildable with PHP 7 bump version 0.5.2-dev fix missed (hidden) zpp calls fix PHP 5 compat fix libvirt_version + add test port test-connect.phpt to real phpt Switch all add_assoc_string_ex to add_assoc_string to avoid nul char management Fix max_connections management add test-conn-limit.phpt (as real phpt) add test-connect-get-emulator.phpt fix parse_array + build warnings convert test-install.phpt to real phpt convert test-domain-create-and-coredump.phpt to real phpt convert test-domain-create-and-get-xpath.phpt to real phpt fix PHP 5 compat again (nested macro issue) INSTALL.PHPEXT | 14 + configure.ac | 2 +- src/config.m4 | 52 + src/libvirt-php.c | 1796 ++++++++++++++++------- src/libvirt-php.h | 48 +- src/tests/example-no-disk-and-media.xml | 41 + src/tests/qemu-no-disk-and-media.xml | 41 + src/tests/skipif.inc | 3 + src/tests/test-conn-limit.phpt | 49 + src/tests/test-connect-get-capabilities.phpt | 27 + src/tests/test-connect-get-emulator.phpt | 15 + src/tests/test-connect-get-info.phpt | 110 ++ src/tests/test-connect-get-machine-types.phpt | 30 + src/tests/test-connect.phpt | 15 + src/tests/test-domain-create-and-coredump.phpt | 49 + src/tests/test-domain-create-and-get-xpath.phpt | 56 + src/tests/test-domain-create-and-shutdown.phpt | 38 + src/tests/test-domain-define.phpt | 38 + src/tests/test-domain-disk.phpt | 71 + src/tests/test-domain-get.phpt | 91 ++ src/tests/test-domain-lookup-by-name.phpt | 35 + src/tests/test-domain-nic.phpt | 52 + src/tests/test-install.phpt | 136 ++ src/tests/test-libvirt-php.img | 0 src/tests/test-logfile.phpt | 43 + src/tests/test-version-get.phpt | 27 + 26 files changed, 2330 insertions(+), 549 deletions(-) create mode 100644 INSTALL.PHPEXT create mode 100644 src/config.m4 create mode 100644 src/tests/example-no-disk-and-media.xml create mode 100644 src/tests/qemu-no-disk-and-media.xml create mode 100644 src/tests/skipif.inc create mode 100644 src/tests/test-conn-limit.phpt create mode 100644 src/tests/test-connect-get-capabilities.phpt create mode 100644 src/tests/test-connect-get-emulator.phpt create mode 100644 src/tests/test-connect-get-info.phpt create mode 100644 src/tests/test-connect-get-machine-types.phpt create mode 100644 src/tests/test-connect.phpt create mode 100644 src/tests/test-domain-create-and-coredump.phpt create mode 100644 src/tests/test-domain-create-and-get-xpath.phpt create mode 100644 src/tests/test-domain-create-and-shutdown.phpt create mode 100644 src/tests/test-domain-define.phpt create mode 100644 src/tests/test-domain-disk.phpt create mode 100644 src/tests/test-domain-get.phpt create mode 100644 src/tests/test-domain-lookup-by-name.phpt create mode 100644 src/tests/test-domain-nic.phpt create mode 100644 src/tests/test-install.phpt create mode 100644 src/tests/test-libvirt-php.img create mode 100644 src/tests/test-logfile.phpt create mode 100644 src/tests/test-version-get.phpt -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/config.m4 | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/config.m4 diff --git a/src/config.m4 b/src/config.m4 new file mode 100644 index 0000000..35bdd76 --- /dev/null +++ b/src/config.m4 @@ -0,0 +1,54 @@ +PHP_ARG_WITH(libvirt, for libvirt support, +[ --with-libvirt Include libvirt support]) + +if test "$PHP_LIBVIRT" != "no"; then + + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + + LIBVIRT_REQUIRED=1.2.8 + + if test -x "$PKG_CONFIG" && $PKG_CONFIG libvirt --exists ; then + AC_MSG_CHECKING(libvirt version) + if $PKG_CONFIG libvirt --atleast-version=$LIBVIRT_REQUIRED ; then + LIBVIRT_INCLUDE=`$PKG_CONFIG libvirt --cflags` + LIBVIRT_LIBRARY=`$PKG_CONFIG libvirt --libs` + LIBVIRT_VERSION=`$PKG_CONFIG libvirt --modversion` + AC_MSG_RESULT($LIBVIRT_VERSION) + else + AC_MSG_ERROR(version too old) + fi + PHP_EVAL_INCLINE($LIBVIRT_INCLUDE) + PHP_EVAL_LIBLINE($LIBVIRT_LIBRARY, LIBVIRT_SHARED_LIBADD) + + AC_MSG_CHECKING(libvirt-qemu version) + if $PKG_CONFIG libvirt-qemu --atleast-version=$LIBVIRT_REQUIRED ; then + QEMU_INCLUDE=`$PKG_CONFIG libvirt-qemu --cflags` + QEMU_LIBRARY=`$PKG_CONFIG libvirt-qemu --libs` + QEMU_VERSION=`$PKG_CONFIG libvirt-qemu --modversion` + AC_MSG_RESULT($QEMU_VERSION) + else + AC_MSG_ERROR(version too old) + fi + PHP_EVAL_INCLINE($QEMU_INCLUDE) + PHP_EVAL_LIBLINE($QEMU_LIBRARY, LIBVIRT_SHARED_LIBADD) + + AC_MSG_CHECKING(libxml version) + if $PKG_CONFIG libxml-2.0 --exists ; then + LIBXML_INCLUDE=`$PKG_CONFIG libxml-2.0 --cflags` + LIBXML_LIBRARY=`$PKG_CONFIG libxml-2.0 --libs` + LIBXML_VERSION=`$PKG_CONFIG libxml-2.0 --modversion` + AC_MSG_RESULT($LIBXML_VERSION) + else + AC_MSG_ERROR(version too old) + fi + PHP_EVAL_INCLINE($LIBXML_INCLUDE) + PHP_EVAL_LIBLINE($LIBXML_LIBRARY, LIBVIRT_SHARED_LIBADD) + + CFLAGS="$CFLAGS -DCOMPILE_DL_LIBVIRT=1" + + PHP_SUBST(LIBVIRT_SHARED_LIBADD) + PHP_NEW_EXTENSION(libvirt, libvirt-php.c sockets.c vncfunc.c, $ext_shared) + else + AC_MSG_ERROR(pkg-config not found) + fi +fi -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/config.m4 | 2 -- src/libvirt-php.h | 14 ++++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/config.m4 b/src/config.m4 index 35bdd76..239329f 100644 --- a/src/config.m4 +++ b/src/config.m4 @@ -44,8 +44,6 @@ if test "$PHP_LIBVIRT" != "no"; then PHP_EVAL_INCLINE($LIBXML_INCLUDE) PHP_EVAL_LIBLINE($LIBXML_LIBRARY, LIBVIRT_SHARED_LIBADD) - CFLAGS="$CFLAGS -DCOMPILE_DL_LIBVIRT=1" - PHP_SUBST(LIBVIRT_SHARED_LIBADD) PHP_NEW_EXTENSION(libvirt, libvirt-php.c sockets.c vncfunc.c, $ext_shared) else diff --git a/src/libvirt-php.h b/src/libvirt-php.h index a45b4bd..bf33a57 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -48,14 +48,18 @@ #define COMPILE_DL_LIBVIRT #endif +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifdef COMPILE_DL_LIBVIRT -#include "php.h" #undef PACKAGE_BUGREPORT #undef PACKAGE_NAME #undef PACKAGE_STRING #undef PACKAGE_TARNAME #undef PACKAGE_URL #undef PACKAGE_VERSION +#include "php.h" #ifdef ZTS #include "TSRM.h" @@ -69,13 +73,11 @@ #endif #endif -#ifdef HAVE_CONFIG_H -#include "../config.h" -#else -#define VERSION "0.5.0" +#ifndef VERSION +#define VERSION "0.5.1" #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_MICRO 0 +#define VERSION_MICRO 1 #endif #include <libvirt/libvirt.h> -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 715 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 553 insertions(+), 162 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 1af6077..3f06edc 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -70,184 +70,563 @@ ZEND_DECLARE_MODULE_GLOBALS(libvirt) ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_connect, 0, 0, 0) ZEND_ARG_INFO(0, url) ZEND_ARG_INFO(0, readonly) +ZEND_ARG_INFO(0, credentials) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_void, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_xpath, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, xpath) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_connect_get_emulator, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, arch) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_connect_get_soundhw_models, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, arch) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_connect_get_all_domain_stats, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, stats) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_stream_send, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, data) +ZEND_ARG_INFO(0, len) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_new, 0, 0, 9) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, name) +ZEND_ARG_INFO(0, arch) +ZEND_ARG_INFO(0, memMB) +ZEND_ARG_INFO(0, maxmemMB) +ZEND_ARG_INFO(0, vcpus) +ZEND_ARG_INFO(0, iso) +ZEND_ARG_INFO(0, disks) +ZEND_ARG_INFO(0, networks) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_change_vcpus, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, numCpus) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_change_memory, 0, 0, 3) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, allocMem) +ZEND_ARG_INFO(0, allocMax) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_change_boot_devices, 0, 0, 3) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, first) +ZEND_ARG_INFO(0, second) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_disk_add, 0, 0, 5) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, img) +ZEND_ARG_INFO(0, dev) +ZEND_ARG_INFO(0, type) +ZEND_ARG_INFO(0, driver) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_disk_remove, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, dev) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_nic_add, 0, 0, 4) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, mac) +ZEND_ARG_INFO(0, network) +ZEND_ARG_INFO(0, model) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_nic_remove, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, dev) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_lookup_by_id, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, id) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_uuid, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, uuid) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_xml, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, xml) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_core_dump, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, to) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_flags, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_memory_peek, 0, 0, 4) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, start) +ZEND_ARG_INFO(0, size) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_set_memory, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, memory) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_set_memory_flags, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, memory) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_path, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, path) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_block_resize, 0, 0, 3) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, path) +ZEND_ARG_INFO(0, size) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_block_job_abort, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, path) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_block_job_set_speed, 0, 0, 3) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, path) +ZEND_ARG_INFO(0, bandwidth) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_migrate, 0, 0, 3) +ZEND_ARG_INFO(0, res) +ZEND_ARG_INFO(0, dest_conn) +ZEND_ARG_INFO(0, flags) +ZEND_ARG_INFO(0, dname) +ZEND_ARG_INFO(0, bandwidth) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_migrate_to_uri, 0, 0, 3) +ZEND_ARG_INFO(0, res) +ZEND_ARG_INFO(0, dest_uri) +ZEND_ARG_INFO(0, flags) +ZEND_ARG_INFO(0, dname) +ZEND_ARG_INFO(0, bandwidth) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_migrate_to_uri2, 0, 0, 1) +ZEND_ARG_INFO(0, res) +ZEND_ARG_INFO(0, dconn_uri) +ZEND_ARG_INFO(0, mig_uri) +ZEND_ARG_INFO(0, dxml) +ZEND_ARG_INFO(0, flags) +ZEND_ARG_INFO(0, dname) +ZEND_ARG_INFO(0, bandwidth) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_xml_xpath, 0, 0, 2) +ZEND_ARG_INFO(0, res) +ZEND_ARG_INFO(0, xpath) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_get_block_info, 0, 0, 2) +ZEND_ARG_INFO(0, res) +ZEND_ARG_INFO(0, dev) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_get_network_info, 0, 0, 2) +ZEND_ARG_INFO(0, res) +ZEND_ARG_INFO(0, mac) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_set_autostart, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_get_metadata, 0, 0, 4) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, type) +ZEND_ARG_INFO(0, uri) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_set_metadata, 0, 0, 6) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, type) +ZEND_ARG_INFO(0, metadata) +ZEND_ARG_INFO(0, key) +ZEND_ARG_INFO(0, uri) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_get_screenshot, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, server) +ZEND_ARG_INFO(0, scancode) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_get_screenshot_api, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, screenID) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_get_screen_dimensions, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, server) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_send_keys, 0, 0, 3) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, server) +ZEND_ARG_INFO(0, scancode) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_send_pointer_event, 0, 0, 5) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, server) +ZEND_ARG_INFO(0, pos_x) +ZEND_ARG_INFO(0, pox_y) +ZEND_ARG_INFO(0, clicked) +ZEND_ARG_INFO(0, release) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_update_device, 0, 0, 3) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, xml) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_optflags, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_snapshot_lookup_by_name, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, name) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_name, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_storagevolume_lookup_by_path, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, path) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_storagevolume_get_xml_desc, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, xpath) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_storagevolume_create_xml_from, 0, 0, 3) +ZEND_ARG_INFO(0, pool) +ZEND_ARG_INFO(0, xml) +ZEND_ARG_INFO(0, original_volume) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_storagevolume_download, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, stream) +ZEND_ARG_INFO(0, offset) +ZEND_ARG_INFO(0, length) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_storagevolume_resize, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, capacity) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_storagepool_define_xml, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, xml) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_optcpunr, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, cpunr) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_opttime, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, time) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_optcap, 0, 0, 1) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, cap) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_opttype, 0, 0, 0) +ZEND_ARG_INFO(0, type) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_check_version, 0, 0, 3) +ZEND_ARG_INFO(0, major) +ZEND_ARG_INFO(0, minor) +ZEND_ARG_INFO(0, micro) +ZEND_ARG_INFO(0, type) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_name, 0, 0, 1) +ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_optpath, 0, 0, 0) +ZEND_ARG_INFO(0, path) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_image_create, 0, 0, 4) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, name) +ZEND_ARG_INFO(0, size) +ZEND_ARG_INFO(0, format) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_image, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, image) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_logfile_set, 0, 0, 1) +ZEND_ARG_INFO(0, filename) +ZEND_ARG_INFO(0, maxsize) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_qemu_agent_command, 0, 0, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(0, cmd) +ZEND_ARG_INFO(0, timeout) +ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO() static zend_function_entry libvirt_functions[] = { /* Common functions */ - PHP_FE(libvirt_get_last_error,NULL) + PHP_FE(libvirt_get_last_error, arginfo_libvirt_void) /* Connect functions */ - PHP_FE(libvirt_connect, arginfo_libvirt_connect) - PHP_FE(libvirt_connect_get_uri, NULL) - PHP_FE(libvirt_connect_get_hostname, NULL) - PHP_FE(libvirt_connect_get_capabilities, NULL) - PHP_FE(libvirt_connect_get_emulator, NULL) - PHP_FE(libvirt_connect_get_nic_models, NULL) - PHP_FE(libvirt_connect_get_soundhw_models, NULL) - PHP_FE(libvirt_connect_get_information, NULL) - PHP_FE(libvirt_connect_get_machine_types, NULL) - PHP_FE(libvirt_connect_get_hypervisor, NULL) - PHP_FE(libvirt_connect_get_sysinfo, NULL) - 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) + PHP_FE(libvirt_connect, arginfo_libvirt_connect) + PHP_FE(libvirt_connect_get_uri, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_hostname, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_capabilities, arginfo_libvirt_conn_xpath) + PHP_FE(libvirt_connect_get_emulator, arginfo_libvirt_connect_get_emulator) + PHP_FE(libvirt_connect_get_nic_models, arginfo_libvirt_connect_get_emulator) + PHP_FE(libvirt_connect_get_soundhw_models, arginfo_libvirt_connect_get_soundhw_models) + PHP_FE(libvirt_connect_get_information, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_machine_types, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_hypervisor, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_sysinfo, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_maxvcpus, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_encrypted, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_secure, arginfo_libvirt_conn) + PHP_FE(libvirt_connect_get_all_domain_stats, arginfo_libvirt_connect_get_all_domain_stats) /* Stream functions */ - PHP_FE(libvirt_stream_create, NULL) - PHP_FE(libvirt_stream_close, NULL) - PHP_FE(libvirt_stream_abort, NULL) - PHP_FE(libvirt_stream_finish, NULL) - PHP_FE(libvirt_stream_send, NULL) - PHP_FE(libvirt_stream_recv, NULL) + PHP_FE(libvirt_stream_create, arginfo_libvirt_conn) + PHP_FE(libvirt_stream_close, arginfo_libvirt_conn) + PHP_FE(libvirt_stream_abort, arginfo_libvirt_conn) + PHP_FE(libvirt_stream_finish, arginfo_libvirt_conn) + PHP_FE(libvirt_stream_send, arginfo_libvirt_stream_send) + PHP_FE(libvirt_stream_recv, arginfo_libvirt_stream_send) /* Domain functions */ - PHP_FE(libvirt_domain_new, NULL) - PHP_FE(libvirt_domain_new_get_vnc, NULL) - PHP_FE(libvirt_domain_get_counts, NULL) - PHP_FE(libvirt_domain_is_persistent, NULL) - PHP_FE(libvirt_domain_lookup_by_name, NULL) - PHP_FE(libvirt_domain_get_xml_desc, NULL) - PHP_FE(libvirt_domain_get_disk_devices, NULL) - PHP_FE(libvirt_domain_get_interface_devices, NULL) - PHP_FE(libvirt_domain_change_vcpus, NULL) - PHP_FE(libvirt_domain_change_memory, NULL) - PHP_FE(libvirt_domain_change_boot_devices, NULL) - PHP_FE(libvirt_domain_disk_add, NULL) - PHP_FE(libvirt_domain_disk_remove, NULL) - PHP_FE(libvirt_domain_nic_add, NULL) - PHP_FE(libvirt_domain_nic_remove, NULL) - PHP_FE(libvirt_domain_get_info, NULL) - PHP_FE(libvirt_domain_get_name, NULL) - PHP_FE(libvirt_domain_get_uuid, NULL) - PHP_FE(libvirt_domain_get_uuid_string, NULL) - PHP_FE(libvirt_domain_get_id, NULL) - PHP_FE(libvirt_domain_lookup_by_id, NULL) - PHP_FE(libvirt_domain_lookup_by_uuid, NULL) - PHP_FE(libvirt_domain_lookup_by_uuid_string, NULL) - PHP_FE(libvirt_domain_destroy, NULL) - PHP_FE(libvirt_domain_create, NULL) - PHP_FE(libvirt_domain_resume, NULL) - PHP_FE(libvirt_domain_core_dump, NULL) - PHP_FE(libvirt_domain_shutdown, NULL) - PHP_FE(libvirt_domain_suspend, NULL) - PHP_FE(libvirt_domain_managedsave, NULL) - PHP_FE(libvirt_domain_undefine, NULL) - PHP_FE(libvirt_domain_reboot, NULL) - PHP_FE(libvirt_domain_define_xml, NULL) - PHP_FE(libvirt_domain_create_xml, NULL) - PHP_FE(libvirt_domain_memory_peek,NULL) - PHP_FE(libvirt_domain_memory_stats,NULL) - 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) - 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) - PHP_FE(libvirt_domain_migrate_to_uri, NULL) - PHP_FE(libvirt_domain_migrate_to_uri2, NULL) - PHP_FE(libvirt_domain_get_job_info, NULL) - PHP_FE(libvirt_domain_xml_xpath, NULL) - PHP_FE(libvirt_domain_get_block_info, NULL) - PHP_FE(libvirt_domain_get_network_info, NULL) - PHP_FE(libvirt_domain_get_autostart, NULL) - PHP_FE(libvirt_domain_set_autostart, NULL) - PHP_FE(libvirt_domain_get_metadata, NULL) - PHP_FE(libvirt_domain_set_metadata, NULL) - PHP_FE(libvirt_domain_is_active, NULL) - PHP_FE(libvirt_domain_get_next_dev_ids, NULL) - PHP_FE(libvirt_domain_get_screenshot, NULL) - PHP_FE(libvirt_domain_get_screenshot_api, NULL) - PHP_FE(libvirt_domain_get_screen_dimensions, NULL) - PHP_FE(libvirt_domain_send_keys, NULL) - PHP_FE(libvirt_domain_send_pointer_event, NULL) - PHP_FE(libvirt_domain_update_device, NULL) + PHP_FE(libvirt_domain_new, arginfo_libvirt_domain_new) + PHP_FE(libvirt_domain_new_get_vnc, arginfo_libvirt_void) + PHP_FE(libvirt_domain_get_counts, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_is_persistent, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_lookup_by_name, arginfo_libvirt_conn_name) + PHP_FE(libvirt_domain_get_xml_desc, arginfo_libvirt_conn_xpath) + PHP_FE(libvirt_domain_get_disk_devices, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_get_interface_devices, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_change_vcpus, arginfo_libvirt_domain_change_vcpus) + PHP_FE(libvirt_domain_change_memory, arginfo_libvirt_domain_change_memory) + PHP_FE(libvirt_domain_change_boot_devices, arginfo_libvirt_domain_change_boot_devices) + PHP_FE(libvirt_domain_disk_add, arginfo_libvirt_domain_disk_add) + PHP_FE(libvirt_domain_disk_remove, arginfo_libvirt_domain_disk_remove) + PHP_FE(libvirt_domain_nic_add, arginfo_libvirt_domain_nic_add) + PHP_FE(libvirt_domain_nic_remove, arginfo_libvirt_domain_nic_remove) + PHP_FE(libvirt_domain_get_info, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_get_name, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_get_uuid, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_get_uuid_string, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_get_id, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_lookup_by_id, arginfo_libvirt_domain_lookup_by_id) + PHP_FE(libvirt_domain_lookup_by_uuid, arginfo_libvirt_conn_uuid) + PHP_FE(libvirt_domain_lookup_by_uuid_string, arginfo_libvirt_conn_uuid) + PHP_FE(libvirt_domain_destroy, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_create, arginfo_libvirt_conn_xml) + PHP_FE(libvirt_domain_resume, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_core_dump, arginfo_libvirt_domain_core_dump) + PHP_FE(libvirt_domain_shutdown, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_suspend, arginfo_libvirt_conn) + 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_define_xml, arginfo_libvirt_conn_xml) + PHP_FE(libvirt_domain_create_xml, arginfo_libvirt_conn_xml) + PHP_FE(libvirt_domain_memory_peek, arginfo_libvirt_domain_memory_peek) + PHP_FE(libvirt_domain_memory_stats, arginfo_libvirt_conn_flags) + PHP_FE(libvirt_domain_set_memory, arginfo_libvirt_domain_set_memory) + PHP_FE(libvirt_domain_set_max_memory, arginfo_libvirt_domain_set_memory) + PHP_FE(libvirt_domain_set_memory_flags, arginfo_libvirt_domain_set_memory_flags) + PHP_FE(libvirt_domain_block_stats, arginfo_libvirt_conn_path) + PHP_FE(libvirt_domain_block_resize, arginfo_libvirt_domain_block_resize) + PHP_FE(libvirt_domain_block_job_abort, arginfo_libvirt_domain_block_job_abort) + PHP_FE(libvirt_domain_block_job_set_speed, arginfo_libvirt_domain_block_job_set_speed) + PHP_FE(libvirt_domain_interface_stats, arginfo_libvirt_conn_path) + PHP_FE(libvirt_domain_get_connect, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_migrate, arginfo_libvirt_domain_migrate) + PHP_FE(libvirt_domain_migrate_to_uri, arginfo_libvirt_domain_migrate_to_uri) + PHP_FE(libvirt_domain_migrate_to_uri2, arginfo_libvirt_domain_migrate_to_uri2) + PHP_FE(libvirt_domain_get_job_info, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_xml_xpath, arginfo_libvirt_domain_xml_xpath) + PHP_FE(libvirt_domain_get_block_info, arginfo_libvirt_domain_get_block_info) + PHP_FE(libvirt_domain_get_network_info, arginfo_libvirt_domain_get_network_info) + PHP_FE(libvirt_domain_get_autostart, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_set_autostart, arginfo_libvirt_domain_set_autostart) + PHP_FE(libvirt_domain_get_metadata, arginfo_libvirt_domain_get_metadata) + PHP_FE(libvirt_domain_set_metadata, arginfo_libvirt_domain_set_metadata) + PHP_FE(libvirt_domain_is_active, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_get_next_dev_ids, arginfo_libvirt_conn) + PHP_FE(libvirt_domain_get_screenshot, arginfo_libvirt_domain_get_screenshot) + PHP_FE(libvirt_domain_get_screenshot_api, arginfo_libvirt_domain_get_screenshot_api) + PHP_FE(libvirt_domain_get_screen_dimensions, arginfo_libvirt_domain_get_screen_dimensions) + PHP_FE(libvirt_domain_send_keys, arginfo_libvirt_domain_send_keys) + PHP_FE(libvirt_domain_send_pointer_event, arginfo_libvirt_domain_send_pointer_event) + PHP_FE(libvirt_domain_update_device, arginfo_libvirt_domain_update_device) /* Domain snapshot functions */ - PHP_FE(libvirt_domain_has_current_snapshot, NULL) - PHP_FE(libvirt_domain_snapshot_create, NULL) - PHP_FE(libvirt_domain_snapshot_get_xml, NULL) - PHP_FE(libvirt_domain_snapshot_revert, NULL) - PHP_FE(libvirt_domain_snapshot_delete, NULL) - PHP_FE(libvirt_domain_snapshot_lookup_by_name, NULL) + PHP_FE(libvirt_domain_has_current_snapshot, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_domain_snapshot_create, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_domain_snapshot_get_xml, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_domain_snapshot_revert, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_domain_snapshot_delete, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_domain_snapshot_lookup_by_name, arginfo_libvirt_domain_snapshot_lookup_by_name) /* Storagepool functions */ - PHP_FE(libvirt_storagepool_lookup_by_name,NULL) - PHP_FE(libvirt_storagepool_lookup_by_volume,NULL) - PHP_FE(libvirt_storagepool_get_info,NULL) - PHP_FE(libvirt_storagevolume_lookup_by_name,NULL) - PHP_FE(libvirt_storagevolume_lookup_by_path,NULL) - PHP_FE(libvirt_storagevolume_get_name,NULL) - PHP_FE(libvirt_storagevolume_get_path,NULL) - PHP_FE(libvirt_storagevolume_get_info,NULL) - PHP_FE(libvirt_storagevolume_get_xml_desc,NULL) - PHP_FE(libvirt_storagevolume_create_xml,NULL) - PHP_FE(libvirt_storagevolume_create_xml_from,NULL) - PHP_FE(libvirt_storagevolume_delete,NULL) - PHP_FE(libvirt_storagevolume_download,NULL) - PHP_FE(libvirt_storagevolume_upload,NULL) - PHP_FE(libvirt_storagevolume_resize,NULL) - PHP_FE(libvirt_storagepool_get_uuid_string, NULL) - PHP_FE(libvirt_storagepool_get_name, NULL) - PHP_FE(libvirt_storagepool_lookup_by_uuid_string, NULL) - PHP_FE(libvirt_storagepool_get_xml_desc, NULL) - PHP_FE(libvirt_storagepool_define_xml, NULL) - PHP_FE(libvirt_storagepool_undefine, NULL) - PHP_FE(libvirt_storagepool_create, NULL) - PHP_FE(libvirt_storagepool_destroy, NULL) - PHP_FE(libvirt_storagepool_is_active, NULL) - PHP_FE(libvirt_storagepool_get_volume_count, NULL) - PHP_FE(libvirt_storagepool_refresh, NULL) - PHP_FE(libvirt_storagepool_set_autostart, NULL) - PHP_FE(libvirt_storagepool_get_autostart, NULL) - PHP_FE(libvirt_storagepool_build, NULL) - PHP_FE(libvirt_storagepool_delete, NULL) + PHP_FE(libvirt_storagepool_lookup_by_name, arginfo_libvirt_conn_name) + PHP_FE(libvirt_storagepool_lookup_by_volume, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_get_info, arginfo_libvirt_conn) + PHP_FE(libvirt_storagevolume_lookup_by_name, arginfo_libvirt_conn_name) + PHP_FE(libvirt_storagevolume_lookup_by_path, arginfo_libvirt_storagevolume_lookup_by_path) + PHP_FE(libvirt_storagevolume_get_name, arginfo_libvirt_conn) + PHP_FE(libvirt_storagevolume_get_path, arginfo_libvirt_conn) + PHP_FE(libvirt_storagevolume_get_info, arginfo_libvirt_conn) + PHP_FE(libvirt_storagevolume_get_xml_desc, arginfo_libvirt_storagevolume_get_xml_desc) + PHP_FE(libvirt_storagevolume_create_xml, arginfo_libvirt_conn_xml) + PHP_FE(libvirt_storagevolume_create_xml_from,arginfo_libvirt_storagevolume_create_xml_from) + PHP_FE(libvirt_storagevolume_delete, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_storagevolume_download, arginfo_libvirt_storagevolume_download) + PHP_FE(libvirt_storagevolume_upload, arginfo_libvirt_storagevolume_download) + PHP_FE(libvirt_storagevolume_resize, arginfo_libvirt_storagevolume_resize) + PHP_FE(libvirt_storagepool_get_uuid_string, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_get_name, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_lookup_by_uuid_string, arginfo_libvirt_conn_uuid) + PHP_FE(libvirt_storagepool_get_xml_desc, arginfo_libvirt_conn_xpath) + PHP_FE(libvirt_storagepool_define_xml, arginfo_libvirt_storagepool_define_xml) + PHP_FE(libvirt_storagepool_undefine, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_create, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_destroy, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_is_active, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_get_volume_count, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_refresh, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_storagepool_set_autostart, arginfo_libvirt_conn_flags) + PHP_FE(libvirt_storagepool_get_autostart, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_build, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_delete, arginfo_libvirt_conn) /* Network functions */ - PHP_FE(libvirt_network_define_xml, NULL) - PHP_FE(libvirt_network_undefine, NULL) - PHP_FE(libvirt_network_get, NULL) - PHP_FE(libvirt_network_get_xml_desc, NULL) - PHP_FE(libvirt_network_get_bridge, NULL) - PHP_FE(libvirt_network_get_information, NULL) - PHP_FE(libvirt_network_get_active, NULL) - PHP_FE(libvirt_network_set_active, NULL) + PHP_FE(libvirt_network_define_xml, arginfo_libvirt_conn_xml) + PHP_FE(libvirt_network_undefine, arginfo_libvirt_conn) + PHP_FE(libvirt_network_get, arginfo_libvirt_conn_name) + PHP_FE(libvirt_network_get_xml_desc, arginfo_libvirt_conn_xpath) + PHP_FE(libvirt_network_get_bridge, arginfo_libvirt_conn) + PHP_FE(libvirt_network_get_information, arginfo_libvirt_conn) + PHP_FE(libvirt_network_get_active, arginfo_libvirt_conn) + PHP_FE(libvirt_network_set_active, arginfo_libvirt_conn_flags) /* Node functions */ - PHP_FE(libvirt_node_get_info, NULL) - PHP_FE(libvirt_node_get_cpu_stats, NULL) - PHP_FE(libvirt_node_get_cpu_stats_for_each_cpu, NULL) - PHP_FE(libvirt_node_get_mem_stats, NULL) + PHP_FE(libvirt_node_get_info, arginfo_libvirt_conn) + PHP_FE(libvirt_node_get_cpu_stats, arginfo_libvirt_conn_optcpunr) + PHP_FE(libvirt_node_get_cpu_stats_for_each_cpu, arginfo_libvirt_conn_opttime) + PHP_FE(libvirt_node_get_mem_stats, arginfo_libvirt_conn) /* Nodedev functions */ - PHP_FE(libvirt_nodedev_get, NULL) - PHP_FE(libvirt_nodedev_capabilities, NULL) - PHP_FE(libvirt_nodedev_get_xml_desc, NULL) - PHP_FE(libvirt_nodedev_get_information, NULL) + PHP_FE(libvirt_nodedev_get, arginfo_libvirt_conn) + PHP_FE(libvirt_nodedev_capabilities, arginfo_libvirt_conn) + PHP_FE(libvirt_nodedev_get_xml_desc, arginfo_libvirt_conn_xpath) + PHP_FE(libvirt_nodedev_get_information, arginfo_libvirt_conn) /* List functions */ - PHP_FE(libvirt_list_domains, NULL) - PHP_FE(libvirt_list_domain_snapshots, NULL) - PHP_FE(libvirt_list_domain_resources, NULL) - PHP_FE(libvirt_list_nodedevs, NULL) - PHP_FE(libvirt_list_networks,NULL) - PHP_FE(libvirt_list_storagepools,NULL) - PHP_FE(libvirt_list_active_storagepools,NULL) - PHP_FE(libvirt_list_inactive_storagepools,NULL) - PHP_FE(libvirt_storagepool_list_volumes,NULL) - PHP_FE(libvirt_list_active_domains, NULL) - PHP_FE(libvirt_list_active_domain_ids, NULL) - PHP_FE(libvirt_list_inactive_domains, NULL) + PHP_FE(libvirt_list_domains, arginfo_libvirt_conn) + PHP_FE(libvirt_list_domain_snapshots, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_list_domain_resources, arginfo_libvirt_conn) + PHP_FE(libvirt_list_nodedevs, arginfo_libvirt_conn_optcap) + PHP_FE(libvirt_list_networks, arginfo_libvirt_conn_optflags) + PHP_FE(libvirt_list_storagepools, arginfo_libvirt_conn) + PHP_FE(libvirt_list_active_storagepools, arginfo_libvirt_conn) + PHP_FE(libvirt_list_inactive_storagepools, arginfo_libvirt_conn) + PHP_FE(libvirt_storagepool_list_volumes, arginfo_libvirt_conn) + PHP_FE(libvirt_list_active_domains, arginfo_libvirt_conn) + PHP_FE(libvirt_list_active_domain_ids, arginfo_libvirt_conn) + PHP_FE(libvirt_list_inactive_domains, arginfo_libvirt_conn) /* Version information and common function */ - PHP_FE(libvirt_version, NULL) - PHP_FE(libvirt_check_version, NULL) - PHP_FE(libvirt_has_feature, NULL) - PHP_FE(libvirt_get_iso_images, NULL) - PHP_FE(libvirt_image_create, NULL) - PHP_FE(libvirt_image_remove, NULL) + PHP_FE(libvirt_version, arginfo_libvirt_opttype) + PHP_FE(libvirt_check_version, arginfo_libvirt_check_version) + PHP_FE(libvirt_has_feature, arginfo_libvirt_name) + PHP_FE(libvirt_get_iso_images, arginfo_libvirt_optpath) + PHP_FE(libvirt_image_create, arginfo_libvirt_image_create) + PHP_FE(libvirt_image_remove, arginfo_libvirt_conn_image) /* Debugging functions */ - PHP_FE(libvirt_logfile_set, NULL) - PHP_FE(libvirt_print_binding_resources, NULL) + PHP_FE(libvirt_logfile_set, arginfo_libvirt_logfile_set) + PHP_FE(libvirt_print_binding_resources, arginfo_libvirt_void) /* Agent functions */ - PHP_FE(libvirt_domain_qemu_agent_command, NULL) + PHP_FE(libvirt_domain_qemu_agent_command, arginfo_libvirt_domain_qemu_agent_command) +#ifdef PHP_FE_END + PHP_FE_END +#else {NULL, NULL, NULL} +#endif }; @@ -3692,6 +4071,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) * Since version: 0.5.2(-1) * Description: Function is used to send qemu-ga command * Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*() + * @cmd [string]: command * @timeout [int] timeout for waiting (-2 block, -1 default, 0 no wait, >0 wait specific time * @flags [int]: unknown * Returns: String on success and FALSE on error @@ -5199,6 +5579,7 @@ PHP_FUNCTION(libvirt_domain_change_vcpus) * Arguments: @res [resource]: libvirt domain resource * @allocMem [int]: number of MiBs to be set as immediate memory value * @allocMax [int]: number of MiBs to be set as the maximum allocation + * @flags [int]: flags * Returns: new domain resource */ PHP_FUNCTION(libvirt_domain_change_memory) @@ -5279,6 +5660,7 @@ PHP_FUNCTION(libvirt_domain_change_memory) * Arguments: @res [resource]: libvirt domain resource * @first [string]: first boot device to be set * @second [string]: second boot device to be set + * @flags [int]: flags * Returns: new domain resource */ PHP_FUNCTION(libvirt_domain_change_boot_devices) @@ -5784,6 +6166,7 @@ PHP_FUNCTION(libvirt_domain_resume) * Since version: 0.4.1(-2) * Description: Function is used to dump core of the domain identified by it's resource * Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*() + * @to [string]: to * Returns: TRUE for success, FALSE on error */ PHP_FUNCTION(libvirt_domain_core_dump) @@ -5890,6 +6273,7 @@ PHP_FUNCTION(libvirt_domain_undefine) * Since version: 0.4.1(-1) * Description: Function is used to reboot the domain identified by it's 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_reboot) @@ -5976,6 +6360,9 @@ PHP_FUNCTION(libvirt_domain_create_xml) * Since version: 0.4.1(-1) * Description: Function is used to get the domain's memory peek value * Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*() + * @start [int]: start + * @size [int]: size + * @flags [int]: optional flags * Returns: domain memory peek */ PHP_FUNCTION(libvirt_domain_memory_peek) @@ -5984,7 +6371,7 @@ PHP_FUNCTION(libvirt_domain_memory_peek) zval *zdomain; int retval; long flags=0; - long long start; + long start; long size; char *buff; @@ -6000,6 +6387,7 @@ PHP_FUNCTION(libvirt_domain_memory_peek) * Since version: 0.4.1(-1) * Description: Function is used to get the domain's memory stats * Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*() + * @flags [int]: optional flags * Returns: domain memory stats array (same fields as virDomainMemoryStats, please see libvirt documentation) */ PHP_FUNCTION(libvirt_domain_memory_stats) @@ -6419,6 +6807,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info) * Description: Function is used to get the result of xPath expression that's run against the domain * Arguments: @res [resource]: libvirt domain resource, e.g. from libvirt_domain_lookup_by_*() * @xpath [string]: xPath expression to parse against the domain + * @flags [int]: optional flags * Returns: result of the expression in an array */ PHP_FUNCTION(libvirt_domain_xml_xpath) @@ -7173,6 +7562,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_info) * Description: Function is used to get the storage volume XML description * Arguments: @res [resource]: libvirt storagevolume resource * @xpath [string]: optional xPath expression string to get just this entry, can be NULL + * @flags [int]: optional flags * Returns: storagevolume XML description or result of xPath expression */ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) @@ -8861,6 +9251,7 @@ PHP_FUNCTION(libvirt_network_get_information) * Since version: 0.4.1(-1) * Description: Function is used to set the activity state of the network * Arguments: @res [resource]: libvirt network resource + * @flags [int]: active * Returns: TRUE if success, FALSE on error */ PHP_FUNCTION(libvirt_network_set_active) -- 2.5.5

On 13.04.2016 18:13, Neal Gompa wrote:
From: Remi Collet <fedora@famillecollet.com>
--- src/libvirt-php.c | 715 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 553 insertions(+), 162 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 1af6077..3f06edc 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c
@@ -5984,7 +6371,7 @@ PHP_FUNCTION(libvirt_domain_memory_peek) zval *zdomain; int retval; long flags=0; - long long start; + long start;
This is spurious for two reasons: 1) this patch aims at something different. So this change does not belong here. 2) The @start variable is passed to virDomainMemoryPeek(). It expects unsigned long long. So this change does not belong here.
long size; char *buff;
Michal

Le 14/04/2016 18:30, Michal Privoznik a écrit :
On 13.04.2016 18:13, Neal Gompa wrote:
From: Remi Collet <fedora@famillecollet.com>
--- src/libvirt-php.c | 715 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 553 insertions(+), 162 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 1af6077..3f06edc 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c
@@ -5984,7 +6371,7 @@ PHP_FUNCTION(libvirt_domain_memory_peek) zval *zdomain; int retval; long flags=0; - long long start; + long start;
This is spurious for two reasons: 1) this patch aims at something different. So this change does not belong here. 2) The @start variable is passed to virDomainMemoryPeek(). It expects unsigned long long. So this change does not belong here.
I confirm this patch is correct and needed. GET_DOMAIN_FROM_ARGS("rlll",&zdomain,&start,&size,&flags); zend_parse_parameters expect a (long *) for "l" option Casting a (long long *) to a (long *) is terrible, mash the stack, can raise segfault, and very bad thing on big endian retval=virDomainMemoryPeek(domain->domain,start,size,buff,flags); Casting a (long) to a (long long) is perfectly OK. So current version is broken - zend_ulong64 start; + zend_long start; And if you want to manage the negative value, just add a test if (start<0) RETURN_FALSE; Remi.

On 15.04.2016 08:05, Remi Collet wrote:
Le 14/04/2016 18:30, Michal Privoznik a écrit :
On 13.04.2016 18:13, Neal Gompa wrote:
From: Remi Collet <fedora@famillecollet.com>
--- src/libvirt-php.c | 715 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 553 insertions(+), 162 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 1af6077..3f06edc 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c
@@ -5984,7 +6371,7 @@ PHP_FUNCTION(libvirt_domain_memory_peek) zval *zdomain; int retval; long flags=0; - long long start; + long start;
This is spurious for two reasons: 1) this patch aims at something different. So this change does not belong here. 2) The @start variable is passed to virDomainMemoryPeek(). It expects unsigned long long. So this change does not belong here.
I confirm this patch is correct and needed.
GET_DOMAIN_FROM_ARGS("rlll",&zdomain,&start,&size,&flags);
So this is broken too. But there's more similar bugs to this in our code.
zend_parse_parameters expect a (long *) for "l" option
Casting a (long long *) to a (long *) is terrible, mash the stack, can raise segfault, and very bad thing on big endian
How can it mash the stack? I'd expect sizeof(long long *) == sizeof (long *) == sizeof(void *). It's a pointer after all. True about endiandness though. But then again - bug is in GET_DOMAIN_FROM_ARGS() arg string. Then again, this commit focuses on adding missing arginfo. This should not had been here rather than a separate patch.
retval=virDomainMemoryPeek(domain->domain,start,size,buff,flags);
Casting a (long) to a (long long) is perfectly OK.
So current version is broken
- zend_ulong64 start; + zend_long start;
And if you want to manage the negative value, just add a test
if (start<0) RETURN_FALSE;
I don't think we need to come up with an extension to libvirt API. The @start argument tells an address from which the API should fetch data. Unsigned integer value is just fine for that. Michal

On Fri, Apr 15, 2016 at 3:14 AM, Michal Privoznik <mprivozn@redhat.com> wrote:
I don't think we need to come up with an extension to libvirt API. The @start argument tells an address from which the API should fetch data. Unsigned integer value is just fine for that.
Michal
If you prefer that, I did make a patch that adds a definition to satisfy that[1]. It compiles and runs properly after applying that patch to the git HEAD. [1]: https://www.redhat.com/archives/libvir-list/2016-April/msg00929.html -- 真実はいつも一つ!/ Always, there's only one truth!

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 258 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 200 insertions(+), 58 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 3f06edc..2bc0708 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1343,7 +1343,13 @@ int is_local_connection(virConnectPtr conn) } /* Destructor for connection resource */ -static void php_libvirt_connection_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_libvirt_connection_dtor( +#if PHP_MAJOR_VERSION >= 7 + zend_resource *rsrc +#else + zend_rsrc_list_entry *rsrc +#endif + TSRMLS_DC) { php_libvirt_connection *conn = (php_libvirt_connection*)rsrc->ptr; int rv = 0; @@ -1370,7 +1376,13 @@ static void php_libvirt_connection_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* Destructor for domain resource */ -static void php_libvirt_domain_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_libvirt_domain_dtor( +#if PHP_MAJOR_VERSION >= 7 + zend_resource *rsrc +#else + zend_rsrc_list_entry *rsrc +#endif + TSRMLS_DC) { php_libvirt_domain *domain = (php_libvirt_domain*)rsrc->ptr; int rv = 0; @@ -1401,7 +1413,13 @@ static void php_libvirt_domain_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* Destructor for stream resource */ -static void php_libvirt_stream_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_libvirt_stream_dtor( +#if PHP_MAJOR_VERSION >= 7 + zend_resource *rsrc +#else + zend_rsrc_list_entry *rsrc +#endif + TSRMLS_DC) { php_libvirt_stream *stream = (php_libvirt_stream*)rsrc->ptr; int rv = 0; @@ -1431,7 +1449,13 @@ static void php_libvirt_stream_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* Destructor for storagepool resource */ -static void php_libvirt_storagepool_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_libvirt_storagepool_dtor( +#if PHP_MAJOR_VERSION >= 7 + zend_resource *rsrc +#else + zend_rsrc_list_entry *rsrc +#endif + TSRMLS_DC) { php_libvirt_storagepool *pool = (php_libvirt_storagepool*)rsrc->ptr; int rv = 0; @@ -1461,7 +1485,13 @@ static void php_libvirt_storagepool_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* Destructor for volume resource */ -static void php_libvirt_volume_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_libvirt_volume_dtor( +#if PHP_MAJOR_VERSION >= 7 + zend_resource *rsrc +#else + zend_rsrc_list_entry *rsrc +#endif + TSRMLS_DC) { php_libvirt_volume *volume = (php_libvirt_volume*)rsrc->ptr; int rv = 0; @@ -1491,7 +1521,13 @@ static void php_libvirt_volume_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* Destructor for network resource */ -static void php_libvirt_network_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_libvirt_network_dtor( +#if PHP_MAJOR_VERSION >= 7 + zend_resource *rsrc +#else + zend_rsrc_list_entry *rsrc +#endif + TSRMLS_DC) { php_libvirt_network *network = (php_libvirt_network*)rsrc->ptr; int rv = 0; @@ -1521,7 +1557,13 @@ static void php_libvirt_network_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* Destructor for nodedev resource */ -static void php_libvirt_nodedev_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_libvirt_nodedev_dtor( +#if PHP_MAJOR_VERSION >= 7 + zend_resource *rsrc +#else + zend_rsrc_list_entry *rsrc +#endif + TSRMLS_DC) { php_libvirt_nodedev *nodedev = (php_libvirt_nodedev*)rsrc->ptr; int rv = 0; @@ -1551,7 +1593,13 @@ static void php_libvirt_nodedev_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* Destructor for snapshot resource */ -static void php_libvirt_snapshot_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_libvirt_snapshot_dtor( +#if PHP_MAJOR_VERSION >= 7 + zend_resource *rsrc +#else + zend_rsrc_list_entry *rsrc +#endif + TSRMLS_DC) { php_libvirt_snapshot *snapshot = (php_libvirt_snapshot*)rsrc->ptr; int rv = 0; @@ -1955,10 +2003,6 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU ZEND_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, -1, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\ -/* Macro to "recreate" string with emalloc */ -#define RECREATE_STRING_WITH_E(str_out, str_in) \ - str_out = estrdup(str_in); - #define LONGLONG_INIT \ char tmpnumber[64] @@ -2029,7 +2073,11 @@ static int libvirt_virConnectCredType[] = { PHP_FUNCTION(libvirt_get_last_error) { if (LIBVIRT_G (last_error) == NULL) RETURN_NULL(); +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRING(LIBVIRT_G (last_error)); +#else RETURN_STRING(LIBVIRT_G (last_error),1); +#endif } /* @@ -2642,7 +2690,6 @@ PHP_FUNCTION(libvirt_connect_get_uri) { zval *zconn; char *uri; - char *uri_out; php_libvirt_connection *conn = NULL; GET_CONNECTION_FROM_ARGS("r",&zconn); @@ -2650,9 +2697,12 @@ PHP_FUNCTION(libvirt_connect_get_uri) DPRINTF("%s: virConnectGetURI returned %s\n", PHPFUNC, uri); if (uri == NULL) RETURN_FALSE; - RECREATE_STRING_WITH_E(uri_out, uri); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(uri); +#else + RETVAL_STRING(uri, 1); +#endif free(uri); - RETURN_STRING(uri_out, 0); } /* @@ -2667,7 +2717,6 @@ PHP_FUNCTION(libvirt_connect_get_hostname) php_libvirt_connection *conn=NULL; zval *zconn; char *hostname; - char *hostname_out; GET_CONNECTION_FROM_ARGS("r",&zconn); @@ -2675,9 +2724,12 @@ PHP_FUNCTION(libvirt_connect_get_hostname) DPRINTF("%s: virConnectGetHostname returned %s\n", PHPFUNC, hostname); if (hostname==NULL) RETURN_FALSE; - RECREATE_STRING_WITH_E(hostname_out,hostname); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(hostname); +#else + RETVAL_STRING(hostname, 1); +#endif free(hostname); - RETURN_STRING(hostname_out,0); } /* @@ -2978,16 +3030,18 @@ PHP_FUNCTION(libvirt_connect_get_sysinfo) php_libvirt_connection *conn=NULL; zval *zconn; char *sysinfo; - char *sysinfo_out; GET_CONNECTION_FROM_ARGS("r",&zconn); sysinfo=virConnectGetSysinfo(conn->conn, 0); if (sysinfo==NULL) RETURN_FALSE; - RECREATE_STRING_WITH_E(sysinfo_out, sysinfo); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(sysinfo); +#else + RETVAL_STRING(sysinfo, 1); +#endif free(sysinfo); - RETURN_STRING(sysinfo_out,0); } /* @@ -3947,7 +4001,12 @@ PHP_FUNCTION(libvirt_domain_get_metadata) } } else { - RETURN_STRING(ret, 0); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(ret); +#else + RETVAL_STRING(ret, 1); +#endif + free(ret); } } @@ -4091,7 +4150,11 @@ PHP_FUNCTION(libvirt_domain_qemu_agent_command) ret = virDomainQemuAgentCommand(domain->domain, cmd, timeout, flags); if (ret == NULL) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRING(ret); +#else RETURN_STRING(ret, 1); +#endif } /* @@ -4379,7 +4442,11 @@ PHP_FUNCTION(libvirt_domain_get_name) DPRINTF("%s: virDomainGetName(%p) returned %s\n", PHPFUNC, domain->domain, name); if (name==NULL) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRING(name); +#else RETURN_STRING(name, 1); //we can use the copy mechanism as we need not to free name (we even can not!) +#endif } /* @@ -4403,7 +4470,12 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string) DPRINTF("%s: virDomainGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, domain->domain, retval, uuid); if (retval!=0) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(uuid); + efree(uuid); +#else RETURN_STRING(uuid,0); +#endif } /* @@ -4878,7 +4950,12 @@ PHP_FUNCTION(libvirt_domain_get_uuid) DPRINTF("%s: virDomainGetUUID(%p, %p) returned %d\n", PHPFUNC, domain->domain, uuid, retval); if (retval!=0) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(uuid); + efree(uuid); +#else RETURN_STRING(uuid,0); +#endif } /* @@ -4945,7 +5022,6 @@ PHP_FUNCTION(libvirt_connect_get_capabilities) php_libvirt_connection *conn=NULL; zval *zconn; char *caps; - char *caps_out; char *xpath = NULL; int xpath_len; char *tmp = NULL; @@ -4959,15 +5035,21 @@ PHP_FUNCTION(libvirt_connect_get_capabilities) tmp = get_string_from_xpath(caps, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RECREATE_STRING_WITH_E (caps_out, caps); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(caps); +#else + RETVAL_STRING(caps, 1); +#endif } else { - RECREATE_STRING_WITH_E (caps_out, tmp); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(tmp); +#else + RETVAL_STRING(tmp, 1); +#endif } free(caps); free(tmp); - - RETURN_STRING(caps_out,0); } /* @@ -4998,9 +5080,12 @@ PHP_FUNCTION(libvirt_connect_get_emulator) RETURN_FALSE; } - RECREATE_STRING_WITH_E(emulator, tmp); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(tmp); +#else + RETVAL_STRING(tmp, 1); +#endif free(tmp); - RETURN_STRING(emulator, 0); } /* @@ -5427,7 +5512,11 @@ PHP_FUNCTION(libvirt_domain_new) PHP_FUNCTION(libvirt_domain_new_get_vnc) { if (LIBVIRT_G(vnc_location)) +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRING(LIBVIRT_G(vnc_location)); +#else RETURN_STRING(LIBVIRT_G(vnc_location),1); +#endif RETURN_NULL(); } @@ -5446,7 +5535,6 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc) zval *zdomain; char *tmp = NULL; char *xml; - char *xml_out; char *xpath = NULL; int xpath_len; long flags=0; @@ -5466,15 +5554,21 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RECREATE_STRING_WITH_E (xml_out, xml); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(xml); +#else + RETVAL_STRING(xml, 1); +#endif } else { - RECREATE_STRING_WITH_E (xml_out, tmp); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(tmp); +#else + RETVAL_STRING(tmp, 1); +#endif } free(tmp); free(xml); - - RETURN_STRING(xml_out,0); } /* @@ -6379,7 +6473,12 @@ PHP_FUNCTION(libvirt_domain_memory_peek) buff=(char *)emalloc(size); retval=virDomainMemoryPeek(domain->domain,start,size,buff,flags); if (retval != 0) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRINGL(buff, size); + efree(buff); +#else RETURN_STRINGL(buff,size,0); +#endif } /* @@ -7178,7 +7277,6 @@ PHP_FUNCTION(libvirt_domain_snapshot_create) PHP_FUNCTION(libvirt_domain_snapshot_get_xml) { char *xml; - char *xml_out; zval *zsnapshot; php_libvirt_snapshot *snapshot; long flags = 0; @@ -7188,9 +7286,12 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml) xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags); if (xml==NULL) RETURN_FALSE; - RECREATE_STRING_WITH_E(xml_out,xml); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(xml); +#else + RETVAL_STRING(xml, 1); +#endif free(xml); - RETURN_STRING(xml_out,0); } /* @@ -7504,7 +7605,11 @@ PHP_FUNCTION(libvirt_storagevolume_get_name) DPRINTF("%s: virStorageVolGetName(%p) returned %s\n", PHPFUNC, volume->volume, retval); if (retval == NULL) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRING(retval); +#else RETURN_STRING (retval, 1); +#endif } /* @@ -7526,7 +7631,11 @@ PHP_FUNCTION(libvirt_storagevolume_get_path) DPRINTF("%s: virStorageVolGetPath(%p) returned %s\n", PHPFUNC, volume->volume, retval); if (retval == NULL) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRING(retval); +#else RETURN_STRING (retval, 1); +#endif } /* @@ -7571,7 +7680,6 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) zval *zvolume; char *tmp = NULL; char *xml; - char *xml_out; char *xpath = NULL; int xpath_len; long flags=0; @@ -7591,15 +7699,21 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RECREATE_STRING_WITH_E (xml_out, xml); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(xml); +#else + RETVAL_STRING(xml, 1); +#endif } else { - RECREATE_STRING_WITH_E(xml_out, tmp); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(tmp); +#else + RETVAL_STRING(tmp, 1); +#endif } free(xml); free(tmp); - - RETURN_STRING(xml_out,0); } /* @@ -7843,7 +7957,12 @@ PHP_FUNCTION(libvirt_storagepool_get_uuid_string) if (retval != 0) RETURN_FALSE; - RETURN_STRING(uuid, 0); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(uuid); + efree(uuid); +#else + RETURN_STRING(uuid,0); +#endif } /* @@ -7866,7 +7985,11 @@ PHP_FUNCTION(libvirt_storagepool_get_name) if (name == NULL) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRING(name); +#else RETURN_STRING(name, 1); +#endif } /* @@ -7918,7 +8041,6 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc) php_libvirt_storagepool *pool = NULL; zval *zpool; char *xml; - char *xml_out; char *xpath = NULL; char *tmp = NULL; long flags = 0; @@ -7940,15 +8062,21 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RECREATE_STRING_WITH_E (xml_out, xml); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(xml); +#else + RETVAL_STRING(xml, 1); +#endif } else { - RECREATE_STRING_WITH_E (xml_out, tmp); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(tmp); +#else + RETVAL_STRING(tmp, 1); +#endif } free(xml); free(tmp); - - RETURN_STRING (xml_out, 0); } /* @@ -8829,7 +8957,6 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) zval *znodedev; char *tmp = NULL; char *xml = NULL; - char *xml_out = NULL; char *xpath = NULL; int xpath_len; int retval = -1; @@ -8848,15 +8975,21 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RECREATE_STRING_WITH_E (xml_out, xml); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(xml); +#else + RETVAL_STRING(xml, 1); +#endif } else { - RECREATE_STRING_WITH_E (xml_out, tmp); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(tmp); +#else + RETVAL_STRING(tmp, 1); +#endif } free(xml); free(tmp); - - RETURN_STRING(xml_out, 0); } /* @@ -9125,7 +9258,11 @@ PHP_FUNCTION(libvirt_network_get_bridge) RETURN_FALSE; } +#if PHP_MAJOR_VERSION >= 7 + RETURN_STRING(name); +#else RETURN_STRING(name, 1); +#endif } /* @@ -9305,7 +9442,6 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) php_libvirt_network *network; zval *znetwork; char *xml = NULL; - char *xml_out = NULL; char *xpath = NULL; char *tmp; int xpath_len; @@ -9326,15 +9462,21 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RECREATE_STRING_WITH_E (xml_out, xml); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(xml); +#else + RETVAL_STRING(xml, 1); +#endif } else { - RECREATE_STRING_WITH_E (xml_out, tmp); +#if PHP_MAJOR_VERSION >= 7 + RETVAL_STRING(tmp); +#else + RETVAL_STRING(tmp, 1); +#endif } free(xml); free(tmp); - - RETURN_STRING(xml_out, 0); } /* -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 2bc0708..3603392 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -55,6 +55,12 @@ const char *features[] = { NULL }; const char *features_binaries[] = { NULL }; #endif +#if PHP_MAJOR_VERSION >= 7 +typedef size_t strsize_t; +#else +typedef int strsize_t; +typedef long zend_long; +#endif /* ZEND thread safe per request globals definition */ int le_libvirt_connection; int le_libvirt_domain; @@ -2102,8 +2108,8 @@ PHP_FUNCTION(libvirt_connect) virConnectAuth libvirt_virConnectAuth= { libvirt_virConnectCredType, sizeof(libvirt_virConnectCredType)/sizeof(int), libvirt_virConnectAuthCallback, NULL}; char *url=NULL; - int url_len=0; - int readonly=1; + strsize_t url_len=0; + zend_bool readonly=1; HashTable *arr_hash; HashPosition pointer; @@ -4321,7 +4327,7 @@ PHP_FUNCTION(libvirt_stream_recv) char *recv_buf; php_libvirt_stream *stream=NULL; int retval = -1; - long length = 0; + zend_long length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) { RETURN_LONG(retval); @@ -4368,7 +4374,7 @@ PHP_FUNCTION(libvirt_stream_send) zval *zstream, *zbuf; php_libvirt_stream *stream=NULL; int retval = -1; - long length = 0; + zend_long length = 0; char *cstr; //int cstrlen; @@ -7770,7 +7776,7 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) virStorageVolPtr volume=NULL; char *xml; - int xml_len; + strsize_t xml_len; if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, "rsr", &zpool, &xml, &xml_len, &zvolume) == FAILURE) { @@ -7870,9 +7876,9 @@ PHP_FUNCTION(libvirt_storagevolume_download) php_libvirt_stream *stream=NULL; zval *zvolume; zval *zstream; - long flags = 0; - long offset = 0; - long length = 0; + zend_long flags = 0; + zend_long offset = 0; + zend_long length = 0; int retval = -1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) { @@ -7911,9 +7917,9 @@ PHP_FUNCTION(libvirt_storagevolume_upload) php_libvirt_stream *stream=NULL; zval *zvolume; zval *zstream; - long flags = 0; - long offset = 0; - long length = 0; + zend_long flags = 0; + zend_long offset = 0; + zend_long length = 0; int retval = -1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) { @@ -9490,7 +9496,7 @@ PHP_FUNCTION(libvirt_version) { unsigned long libVer; unsigned long typeVer; - int type_len; + strsize_t type_len; char *type=NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type,&type_len) == FAILURE) { set_error("Invalid arguments" TSRMLS_CC); @@ -9537,7 +9543,7 @@ PHP_FUNCTION(libvirt_version) PHP_FUNCTION(libvirt_check_version) { unsigned long libVer; - unsigned long major = 0, minor = 0, micro = 0, type = VIR_VERSION_BINDING; + zend_long major = 0, minor = 0, micro = 0, type = VIR_VERSION_BINDING; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll|l", &major, &minor, µ, &type) == FAILURE) { set_error("Invalid arguments" TSRMLS_CC); @@ -9582,7 +9588,7 @@ PHP_FUNCTION(libvirt_check_version) PHP_FUNCTION(libvirt_has_feature) { char *name = NULL; - int name_len = 0; + strsize_t name_len = 0; const char *binary = NULL; int ret = 0; @@ -9610,7 +9616,7 @@ PHP_FUNCTION(libvirt_has_feature) PHP_FUNCTION(libvirt_get_iso_images) { char *path = NULL; - int path_len = 0; + strsize_t path_len = 0; #ifndef EXTWIN struct dirent *entry; DIR *d = NULL; @@ -9697,8 +9703,8 @@ PHP_FUNCTION(libvirt_print_binding_resources) PHP_FUNCTION(libvirt_logfile_set) { char *filename = NULL; - long maxsize = DEFAULT_LOG_MAXSIZE; - int filename_len = 0; + zend_long maxsize = DEFAULT_LOG_MAXSIZE; + strsize_t filename_len = 0; int err; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, &filename_len, &maxsize) == FAILURE) { -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 201 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 174 insertions(+), 27 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 3603392..3f47075 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -57,9 +57,20 @@ const char *features_binaries[] = { NULL }; #if PHP_MAJOR_VERSION >= 7 typedef size_t strsize_t; + +#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ + if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ + RETURN_FALSE; \ + } + #else typedef int strsize_t; typedef long zend_long; +typedef unsigned long zend_ulong; + +#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ + ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); + #endif /* ZEND thread safe per request globals definition */ int le_libvirt_connection; @@ -1946,7 +1957,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, -1, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);\ +VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);\ if ((conn==NULL) || (conn->conn==NULL)) RETURN_FALSE;\ #define GET_DOMAIN_FROM_ARGS(args, ...) \ @@ -1956,7 +1967,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(domain, php_libvirt_domain*, &zdomain, -1, PHP_LIBVIRT_DOMAIN_RES_NAME, le_libvirt_domain);\ +VIRT_FETCH_RESOURCE(domain, php_libvirt_domain*, &zdomain, PHP_LIBVIRT_DOMAIN_RES_NAME, le_libvirt_domain);\ if ((domain==NULL) || (domain->domain==NULL)) RETURN_FALSE;\ #define GET_NETWORK_FROM_ARGS(args, ...) \ @@ -1966,7 +1977,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(network, php_libvirt_network*, &znetwork, -1, PHP_LIBVIRT_NETWORK_RES_NAME, le_libvirt_network);\ +VIRT_FETCH_RESOURCE(network, php_libvirt_network*, &znetwork, PHP_LIBVIRT_NETWORK_RES_NAME, le_libvirt_network);\ if ((network==NULL) || (network->network==NULL)) RETURN_FALSE;\ #define GET_NODEDEV_FROM_ARGS(args, ...) \ @@ -1976,7 +1987,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(nodedev, php_libvirt_nodedev*, &znodedev, -1, PHP_LIBVIRT_NODEDEV_RES_NAME, le_libvirt_nodedev);\ +VIRT_FETCH_RESOURCE(nodedev, php_libvirt_nodedev*, &znodedev, PHP_LIBVIRT_NODEDEV_RES_NAME, le_libvirt_nodedev);\ if ((nodedev==NULL) || (nodedev->device==NULL)) RETURN_FALSE;\ #define GET_STORAGEPOOL_FROM_ARGS(args, ...) \ @@ -1986,7 +1997,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, -1, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool);\ +VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool);\ if ((pool==NULL) || (pool->pool==NULL)) RETURN_FALSE;\ #define GET_VOLUME_FROM_ARGS(args, ...) \ @@ -1996,7 +2007,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);\ +VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);\ if ((volume==NULL) || (volume->volume==NULL)) RETURN_FALSE;\ #define GET_SNAPSHOT_FROM_ARGS(args, ...) \ @@ -2006,7 +2017,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, -1, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ +VIRT_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\ #define LONGLONG_INIT \ @@ -2100,7 +2111,7 @@ PHP_FUNCTION(libvirt_connect) php_libvirt_connection *conn; php_libvirt_cred_value *creds=NULL; zval* zcreds=NULL; - zval **data; + zval *data; int i; int j; int credscount=0; @@ -2115,9 +2126,7 @@ PHP_FUNCTION(libvirt_connect) HashPosition pointer; int array_count; - char *key; - unsigned int key_len; - unsigned long index; + zend_ulong index; unsigned long libVer; @@ -2162,9 +2171,27 @@ PHP_FUNCTION(libvirt_connect) j=0; /* parse the input Array and create list of credentials. The list (array) is passed to callback function. */ for (zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); +#if PHP_MAJOR_VERSION >= 7 + (data = zend_hash_get_current_data_ex(arr_hash, &pointer)) != NULL; + zend_hash_move_forward_ex(arr_hash, &pointer)) { + if (Z_TYPE_P(data) == IS_STRING) { + zend_string *key; + if (zend_hash_get_current_key_ex(arr_hash, &key, &index, &pointer) == HASH_KEY_IS_STRING) { + PHPWRITE(ZSTR_VAL(key), ZSTR_LEN(key)); + } else { + DPRINTF("%s: credentials index %d\n", PHPFUNC, (int)index); + creds[j].type=index; + creds[j].result=(char *)emalloc( Z_STRLEN_P(data) + 1 ); + memset(creds[j].result, 0, Z_STRLEN_P(data) + 1); + creds[j].resultlen=Z_STRLEN_P(data); + strncpy(creds[j].result,Z_STRVAL_P(data),Z_STRLEN_P(data)); + j++; +#else zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { if (Z_TYPE_PP(data) == IS_STRING) { + char *key; + unsigned int key_len; if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer) == HASH_KEY_IS_STRING) { PHPWRITE(key, key_len); } else { @@ -2175,6 +2202,7 @@ PHP_FUNCTION(libvirt_connect) creds[j].resultlen=Z_STRLEN_PP(data); strncpy(creds[j].result,Z_STRVAL_PP(data),Z_STRLEN_PP(data)); j++; +#endif } } } @@ -2197,7 +2225,11 @@ PHP_FUNCTION(libvirt_connect) resource_change_counter(INT_RESOURCE_CONNECTION, NULL, conn->conn, 1 TSRMLS_CC); DPRINTF("%s: Connection to %s established, returning %p\n", PHPFUNC, url, conn->conn); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(conn, le_libvirt_connection)); +#else ZEND_REGISTER_RESOURCE(return_value, conn, le_libvirt_connection); +#endif conn->resource_id=Z_LVAL_P(return_value); } @@ -3330,9 +3362,7 @@ long get_next_free_numeric_value(virDomainPtr domain, char *xpath) HashTable *arr_hash; HashPosition pointer; // int array_count; - zval **data; - char *key; - unsigned int key_len; + zval *data; unsigned long index; long max_slot = -1; @@ -3344,13 +3374,26 @@ long get_next_free_numeric_value(virDomainPtr domain, char *xpath) arr_hash = Z_ARRVAL_P(output); // array_count = zend_hash_num_elements(arr_hash); for (zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); +#if PHP_MAJOR_VERSION >= 7 + (data = zend_hash_get_current_data_ex(arr_hash, &pointer)) != NULL; + zend_hash_move_forward_ex(arr_hash, &pointer)) { + if (Z_TYPE_P(data) == IS_STRING) { + zend_string *key; + if (zend_hash_get_current_key_ex(arr_hash, &key, &index, &pointer) != HASH_KEY_IS_STRING) { + long num = -1; + + sscanf(Z_STRVAL_P(data), "%lx", &num); +#else zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { if (Z_TYPE_PP(data) == IS_STRING) { + char *key; + unsigned int key_len; if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer) != HASH_KEY_IS_STRING) { long num = -1; sscanf(Z_STRVAL_PP(data), "%lx", &num); +#endif if (num > max_slot) max_slot = num; } @@ -4096,7 +4139,11 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) DPRINTF("%s: domain name = '%s', returning %p\n", PHPFUNC, name, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -4128,7 +4175,11 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) DPRINTF("%s: domain UUID = '%s', returning %p\n", PHPFUNC, uuid, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -4192,7 +4243,11 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) DPRINTF("%s: domain UUID string = '%s', returning %p\n", PHPFUNC, uuid, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -4212,7 +4267,7 @@ PHP_FUNCTION(libvirt_stream_create) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) == FAILURE) { RETURN_FALSE; } - ZEND_FETCH_RESOURCE (conn, php_libvirt_connection*, &zconn, -1, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); + VIRT_FETCH_RESOURCE (conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); if ((conn==NULL)||(conn->conn==NULL))RETURN_FALSE; stream = virStreamNew(conn->conn, 0); @@ -4226,7 +4281,11 @@ PHP_FUNCTION(libvirt_stream_create) res_stream->conn = conn; resource_change_counter(INT_RESOURCE_STREAM, conn->conn, res_stream->stream, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_stream, le_libvirt_stream)); +#else ZEND_REGISTER_RESOURCE(return_value, res_stream, le_libvirt_stream); +#endif } /* @@ -4245,7 +4304,7 @@ PHP_FUNCTION(libvirt_stream_close) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { RETURN_LONG(retval); } - ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); retval = virStreamFree(stream->stream); @@ -4274,7 +4333,7 @@ PHP_FUNCTION(libvirt_stream_abort) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { RETURN_LONG(retval); } - ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); retval = virStreamAbort(stream->stream); @@ -4301,7 +4360,7 @@ PHP_FUNCTION(libvirt_stream_finish) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { RETURN_LONG(retval); } - ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); retval = virStreamFinish(stream->stream); @@ -4332,7 +4391,7 @@ PHP_FUNCTION(libvirt_stream_recv) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) { RETURN_LONG(retval); } - ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); recv_buf = emalloc(length + 1); @@ -4381,7 +4440,7 @@ PHP_FUNCTION(libvirt_stream_send) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) { RETURN_LONG(retval); } - ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); cstr = Z_STRVAL_P(zbuf); @@ -4423,7 +4482,11 @@ PHP_FUNCTION(libvirt_domain_lookup_by_id) DPRINTF("%s: domain id = '%d', returning %p\n", PHPFUNC, (int)id, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -5505,7 +5568,11 @@ PHP_FUNCTION(libvirt_domain_new) DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -5750,7 +5817,11 @@ PHP_FUNCTION(libvirt_domain_change_memory) DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -5831,7 +5902,11 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -6419,7 +6494,11 @@ PHP_FUNCTION(libvirt_domain_define_xml) DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -6452,7 +6531,11 @@ PHP_FUNCTION(libvirt_domain_create_xml) DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -7131,7 +7214,7 @@ PHP_FUNCTION(libvirt_domain_migrate) RETURN_FALSE; } - ZEND_FETCH_RESOURCE(dconn, php_libvirt_connection*, &zdconn, -1, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); + VIRT_FETCH_RESOURCE(dconn, php_libvirt_connection*, &zdconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); if ((dconn==NULL) || (dconn->conn==NULL)) { set_error("Destination connection object is not valid" TSRMLS_CC); RETURN_FALSE; @@ -7146,7 +7229,11 @@ PHP_FUNCTION(libvirt_domain_migrate) DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, dconn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); +#endif } /* @@ -7238,7 +7325,11 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) DPRINTF("%s: returning %p\n", PHPFUNC, res_snapshot->snapshot); resource_change_counter(INT_RESOURCE_SNAPSHOT, domain->conn->conn, res_snapshot->snapshot, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_snapshot, le_libvirt_snapshot)); +#else ZEND_REGISTER_RESOURCE(return_value, res_snapshot, le_libvirt_snapshot); +#endif } /* @@ -7269,7 +7360,11 @@ PHP_FUNCTION(libvirt_domain_snapshot_create) DPRINTF("%s: returning %p\n", PHPFUNC, res_snapshot->snapshot); resource_change_counter(INT_RESOURCE_SNAPSHOT, domain->conn->conn, res_snapshot->snapshot, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_snapshot, le_libvirt_snapshot)); +#else ZEND_REGISTER_RESOURCE(return_value, res_snapshot, le_libvirt_snapshot); +#endif } /* @@ -7419,7 +7514,11 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) DPRINTF("%s: returning %p\n", PHPFUNC, res_pool->pool); resource_change_counter(INT_RESOURCE_STORAGEPOOL, conn->conn, res_pool->pool, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_storagepool)); +#else ZEND_REGISTER_RESOURCE(return_value, res_pool, le_libvirt_storagepool); +#endif } /* Storagepool functions */ @@ -7451,7 +7550,11 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_volume) DPRINTF("%s: returning %p\n", PHPFUNC, res_pool->pool); resource_change_counter(INT_RESOURCE_STORAGEPOOL, res_pool->conn->conn, res_pool->pool, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_storagepool)); +#else ZEND_REGISTER_RESOURCE(return_value, res_pool, le_libvirt_storagepool); +#endif } /* @@ -7552,7 +7655,11 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) DPRINTF("%s: returning %p\n", PHPFUNC, res_volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, pool->conn->conn, res_volume->volume, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_volume, le_libvirt_volume)); +#else ZEND_REGISTER_RESOURCE(return_value, res_volume, le_libvirt_volume); +#endif } /* @@ -7589,7 +7696,11 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) DPRINTF("%s: returning %p\n", PHPFUNC, res_volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, conn->conn, res_volume->volume, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_volume, le_libvirt_volume)); +#else ZEND_REGISTER_RESOURCE(return_value, res_volume, le_libvirt_volume); +#endif } /* @@ -7753,7 +7864,11 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml) DPRINTF("%s: returning %p\n", PHPFUNC, res_volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, pool->conn->conn, res_volume->volume, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_volume, le_libvirt_volume)); +#else ZEND_REGISTER_RESOURCE(return_value, res_volume, le_libvirt_volume); +#endif } /* @@ -7784,9 +7899,9 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) RETURN_FALSE; } - ZEND_FETCH_RESOURCE (pool, php_libvirt_storagepool*, &zpool, -1, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool); + VIRT_FETCH_RESOURCE (pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool); if ((pool==NULL)||(pool->pool==NULL))RETURN_FALSE; - ZEND_FETCH_RESOURCE (pl_volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); + VIRT_FETCH_RESOURCE (pl_volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); if ((pl_volume==NULL)||(pl_volume->volume==NULL))RETURN_FALSE; resource_change_counter(INT_RESOURCE_VOLUME, NULL, pl_volume->volume, 1 TSRMLS_CC); @@ -7800,7 +7915,11 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) DPRINTF("%s: returning %p\n", PHPFUNC, res_volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, pool->conn->conn, res_volume->volume, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_volume, le_libvirt_volume)); +#else ZEND_REGISTER_RESOURCE(return_value, res_volume, le_libvirt_volume); +#endif } /* @@ -7884,9 +8003,9 @@ PHP_FUNCTION(libvirt_storagevolume_download) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) { RETURN_LONG(retval); } - ZEND_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); + VIRT_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); if ((volume==NULL)||(volume->volume==NULL))RETURN_LONG(retval); - ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); retval = virStorageVolDownload(volume->volume, stream->stream, offset, length, flags); @@ -7925,9 +8044,9 @@ PHP_FUNCTION(libvirt_storagevolume_upload) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) { RETURN_LONG(retval); } - ZEND_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); + VIRT_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); if ((volume==NULL)||(volume->volume==NULL))RETURN_LONG(retval); - ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); retval = virStorageVolUpload(volume->volume, stream->stream, offset, length, flags); @@ -8031,7 +8150,11 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_uuid_string) DPRINTF("%s: returning %p\n", PHPFUNC, res_pool->pool); resource_change_counter(INT_RESOURCE_STORAGEPOOL, conn->conn, res_pool->pool, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_storagepool)); +#else ZEND_REGISTER_RESOURCE (return_value, res_pool, le_libvirt_storagepool); +#endif } /* @@ -8118,7 +8241,11 @@ PHP_FUNCTION(libvirt_storagepool_define_xml) DPRINTF("%s: returning %p\n", PHPFUNC, res_pool->pool); resource_change_counter(INT_RESOURCE_STORAGEPOOL, conn->conn, res_pool->pool, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_storagepool)); +#else ZEND_REGISTER_RESOURCE (return_value, res_pool, le_libvirt_storagepool); +#endif } /* @@ -8609,7 +8736,11 @@ PHP_FUNCTION(libvirt_list_domain_resources) res_domain->conn=conn; resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(zdomain, res_domain, le_libvirt_domain); +#endif add_next_index_zval(return_value, zdomain); } } @@ -8636,7 +8767,11 @@ PHP_FUNCTION(libvirt_list_domain_resources) ALLOC_INIT_ZVAL(zdomain); res_domain->conn=conn; +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); +#else ZEND_REGISTER_RESOURCE(zdomain, res_domain, le_libvirt_domain); +#endif resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); add_next_index_zval(return_value, zdomain); } @@ -8912,7 +9047,11 @@ PHP_FUNCTION(libvirt_nodedev_get) DPRINTF("%s: returning %p\n", PHPFUNC, res_dev->device); resource_change_counter(INT_RESOURCE_NODEDEV, conn->conn, res_dev->device, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_dev, le_libvirt_nodedev)); +#else ZEND_REGISTER_RESOURCE(return_value, res_dev, le_libvirt_nodedev); +#endif } /* @@ -9186,7 +9325,11 @@ PHP_FUNCTION(libvirt_network_define_xml) DPRINTF("%s: returning %p\n", PHPFUNC, res_net->network); resource_change_counter(INT_RESOURCE_NETWORK, conn->conn, res_net->network, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_net, le_libvirt_network)); +#else ZEND_REGISTER_RESOURCE(return_value, res_net, le_libvirt_network); +#endif } /* @@ -9239,7 +9382,11 @@ PHP_FUNCTION(libvirt_network_get) DPRINTF("%s: returning %p\n", PHPFUNC, res_net->network); resource_change_counter(INT_RESOURCE_NETWORK, conn->conn, res_net->network, 1 TSRMLS_CC); +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, zend_register_resource(res_net, le_libvirt_network)); +#else ZEND_REGISTER_RESOURCE(return_value, res_net, le_libvirt_network); +#endif } /* -- 2.5.5

On 13.04.2016 18:13, Neal Gompa wrote:
From: Remi Collet <fedora@famillecollet.com>
--- src/libvirt-php.c | 201 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 174 insertions(+), 27 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 3603392..3f47075 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -57,9 +57,20 @@ const char *features_binaries[] = { NULL };
#if PHP_MAJOR_VERSION >= 7 typedef size_t strsize_t; + +#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ + if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ + RETURN_FALSE; \ + } + #else typedef int strsize_t; typedef long zend_long; +typedef unsigned long zend_ulong; + +#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ + ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); + #endif /* ZEND thread safe per request globals definition */ int le_libvirt_connection; @@ -1946,7 +1957,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, -1, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);\ +VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);\ if ((conn==NULL) || (conn->conn==NULL)) RETURN_FALSE;\
#define GET_DOMAIN_FROM_ARGS(args, ...) \ @@ -1956,7 +1967,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(domain, php_libvirt_domain*, &zdomain, -1, PHP_LIBVIRT_DOMAIN_RES_NAME, le_libvirt_domain);\ +VIRT_FETCH_RESOURCE(domain, php_libvirt_domain*, &zdomain, PHP_LIBVIRT_DOMAIN_RES_NAME, le_libvirt_domain);\ if ((domain==NULL) || (domain->domain==NULL)) RETURN_FALSE;\
#define GET_NETWORK_FROM_ARGS(args, ...) \ @@ -1966,7 +1977,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(network, php_libvirt_network*, &znetwork, -1, PHP_LIBVIRT_NETWORK_RES_NAME, le_libvirt_network);\ +VIRT_FETCH_RESOURCE(network, php_libvirt_network*, &znetwork, PHP_LIBVIRT_NETWORK_RES_NAME, le_libvirt_network);\ if ((network==NULL) || (network->network==NULL)) RETURN_FALSE;\
#define GET_NODEDEV_FROM_ARGS(args, ...) \ @@ -1976,7 +1987,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(nodedev, php_libvirt_nodedev*, &znodedev, -1, PHP_LIBVIRT_NODEDEV_RES_NAME, le_libvirt_nodedev);\ +VIRT_FETCH_RESOURCE(nodedev, php_libvirt_nodedev*, &znodedev, PHP_LIBVIRT_NODEDEV_RES_NAME, le_libvirt_nodedev);\ if ((nodedev==NULL) || (nodedev->device==NULL)) RETURN_FALSE;\
#define GET_STORAGEPOOL_FROM_ARGS(args, ...) \ @@ -1986,7 +1997,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, -1, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool);\ +VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool);\ if ((pool==NULL) || (pool->pool==NULL)) RETURN_FALSE;\
#define GET_VOLUME_FROM_ARGS(args, ...) \ @@ -1996,7 +2007,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);\ +VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);\ if ((volume==NULL) || (volume->volume==NULL)) RETURN_FALSE;\
#define GET_SNAPSHOT_FROM_ARGS(args, ...) \ @@ -2006,7 +2017,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU RETURN_FALSE;\ }\ \ -ZEND_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, -1, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ +VIRT_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\
#define LONGLONG_INIT \ @@ -2100,7 +2111,7 @@ PHP_FUNCTION(libvirt_connect) php_libvirt_connection *conn; php_libvirt_cred_value *creds=NULL; zval* zcreds=NULL; - zval **data; + zval *data;
So @data is now a single pointer ...
int i; int j; int credscount=0; @@ -2115,9 +2126,7 @@ PHP_FUNCTION(libvirt_connect) HashPosition pointer; int array_count;
- char *key; - unsigned int key_len; - unsigned long index; + zend_ulong index;
unsigned long libVer;
@@ -2162,9 +2171,27 @@ PHP_FUNCTION(libvirt_connect) j=0; /* parse the input Array and create list of credentials. The list (array) is passed to callback function. */ for (zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); +#if PHP_MAJOR_VERSION >= 7 + (data = zend_hash_get_current_data_ex(arr_hash, &pointer)) != NULL; + zend_hash_move_forward_ex(arr_hash, &pointer)) { + if (Z_TYPE_P(data) == IS_STRING) { + zend_string *key; + if (zend_hash_get_current_key_ex(arr_hash, &key, &index, &pointer) == HASH_KEY_IS_STRING) { + PHPWRITE(ZSTR_VAL(key), ZSTR_LEN(key)); + } else { + DPRINTF("%s: credentials index %d\n", PHPFUNC, (int)index); + creds[j].type=index; + creds[j].result=(char *)emalloc( Z_STRLEN_P(data) + 1 ); + memset(creds[j].result, 0, Z_STRLEN_P(data) + 1); + creds[j].resultlen=Z_STRLEN_P(data); + strncpy(creds[j].result,Z_STRVAL_P(data),Z_STRLEN_P(data)); + j++; +#else zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { if (Z_TYPE_PP(data) == IS_STRING) {
.. but _PP says it's a double pointer. The !PHP7 code needs to be updated too.
+ char *key; + unsigned int key_len; if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer) == HASH_KEY_IS_STRING) { PHPWRITE(key, key_len); } else {
Michal

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 299 ++++++++++++++++++------------------------------------ 1 file changed, 99 insertions(+), 200 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 3f47075..80a947c 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -58,6 +58,7 @@ const char *features_binaries[] = { NULL }; #if PHP_MAJOR_VERSION >= 7 typedef size_t strsize_t; +#define VIRT_COPY_OPT #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ RETURN_FALSE; \ @@ -68,6 +69,8 @@ typedef int strsize_t; typedef long zend_long; typedef unsigned long zend_ulong; +#define VIRT_COPY_OPT ,1 + #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); @@ -2026,7 +2029,7 @@ if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\ #define LONGLONG_ASSOC(out,key,in) \ if (LIBVIRT_G(longlong_to_string_ini)) { \ snprintf(tmpnumber,63,"%llu",in); \ - add_assoc_string_ex(out,key,strlen(key)+1,tmpnumber,1); \ + add_assoc_string_ex(out,key,strlen(key)+1,tmpnumber VIRT_COPY_OPT); \ } \ else \ { \ @@ -2090,11 +2093,7 @@ static int libvirt_virConnectCredType[] = { PHP_FUNCTION(libvirt_get_last_error) { if (LIBVIRT_G (last_error) == NULL) RETURN_NULL(); -#if PHP_MAJOR_VERSION >= 7 - RETURN_STRING(LIBVIRT_G (last_error)); -#else - RETURN_STRING(LIBVIRT_G (last_error),1); -#endif + RETURN_STRING(LIBVIRT_G (last_error) VIRT_COPY_OPT); } /* @@ -2254,7 +2253,7 @@ PHP_FUNCTION(libvirt_node_get_info) if (retval==-1) RETURN_FALSE; array_init(return_value); - add_assoc_string_ex(return_value, "model", 6, info.model, 1); + add_assoc_string_ex(return_value, "model", 6, info.model VIRT_COPY_OPT); add_assoc_long(return_value, "memory", (long)info.memory); add_assoc_long(return_value, "cpus", (long)info.cpus); add_assoc_long(return_value, "nodes", (long)info.nodes); @@ -2349,9 +2348,9 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) add_assoc_long(return_value, "cpu", cpunr); else if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) - add_assoc_string_ex(return_value, "cpu", 4, "all", 1); + add_assoc_string_ex(return_value, "cpu", 4, "all" VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "cpu", 4, "unknown", 1); + add_assoc_string_ex(return_value, "cpu", 4, "unknown" VIRT_COPY_OPT); free(params); params = NULL; @@ -2563,21 +2562,21 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) char tmp3[2048] = { 0 }; snprintf(key, sizeof(key), "%d", k); - //add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k], 1); + //add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT); snprintf(tmp3, sizeof(tmp3), "//capabilities/guest/arch[@name=\"%s\"]/machine[text()=\"%s\"]/@maxCpus", ret[i], ret3[k]); numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL); if (numTmp == NULL) - add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k], 1); + add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT); else { zval *arr4; ALLOC_INIT_ZVAL(arr4); array_init(arr4); - add_assoc_string_ex(arr4, "name", 5, ret3[k], 1); - add_assoc_string_ex(arr4, "maxCpus", 9, numTmp, 1); + add_assoc_string_ex(arr4, "name", 5, ret3[k] VIRT_COPY_OPT); + add_assoc_string_ex(arr4, "maxCpus", 9, numTmp VIRT_COPY_OPT); add_assoc_zval_ex(arr2, key, strlen(key) + 1, arr4); free(numTmp); @@ -2605,14 +2604,14 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL); if (numTmp == NULL) - add_assoc_string_ex(arr3, key, strlen(key) + 1, ret3[k], 1); + add_assoc_string_ex(arr3, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT); else { zval *arr4; ALLOC_INIT_ZVAL(arr4); array_init(arr4); - add_assoc_string_ex(arr4, "name", 5, ret3[k], 1); - add_assoc_string_ex(arr4, "maxCpus", 9, numTmp, 1); + add_assoc_string_ex(arr4, "name", 5, ret3[k] VIRT_COPY_OPT); + add_assoc_string_ex(arr4, "maxCpus", 9, numTmp VIRT_COPY_OPT); add_assoc_zval_ex(arr3, key, strlen(key) + 1, arr4); free(numTmp); @@ -2655,21 +2654,21 @@ PHP_FUNCTION(libvirt_connect_get_information) tmp = virConnectGetURI(conn->conn); DPRINTF("%s: Got connection URI of %s...\n", PHPFUNC, tmp); array_init(return_value); - add_assoc_string_ex(return_value, "uri", 4, tmp ? tmp : "unknown", 1); + add_assoc_string_ex(return_value, "uri", 4, tmp ? tmp : "unknown" VIRT_COPY_OPT); free(tmp); tmp = virConnectGetHostname(conn->conn); - add_assoc_string_ex(return_value, "hostname", 9, tmp ? tmp : "unknown", 1); + add_assoc_string_ex(return_value, "hostname", 9, tmp ? tmp : "unknown" VIRT_COPY_OPT); free(tmp); if ((virConnectGetVersion(conn->conn, &hvVer) == 0) && (type = virConnectGetType(conn->conn))) { - add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type, 1); + add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type VIRT_COPY_OPT); add_assoc_long(return_value, "hypervisor_major",(long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "hypervisor_minor",(long)((hvVer/1000) % 1000)); add_assoc_long(return_value, "hypervisor_release",(long)(hvVer %1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); - add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr, 1); + add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr VIRT_COPY_OPT); } if (strcmp(type, "QEMU") == 0) { @@ -2682,21 +2681,21 @@ PHP_FUNCTION(libvirt_connect_get_information) add_assoc_long(return_value, "hypervisor_maxvcpus", maxvcpus); iTmp = virConnectIsEncrypted(conn->conn); if (iTmp == 1) - add_assoc_string_ex(return_value, "encrypted", 10, "Yes", 1); + add_assoc_string_ex(return_value, "encrypted", 10, "Yes" VIRT_COPY_OPT); else if (iTmp == 0) - add_assoc_string_ex(return_value, "encrypted", 10, "No", 1); + add_assoc_string_ex(return_value, "encrypted", 10, "No" VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "encrypted", 10, "unknown", 1); + add_assoc_string_ex(return_value, "encrypted", 10, "unknown" VIRT_COPY_OPT); iTmp = virConnectIsSecure(conn->conn); if (iTmp == 1) - add_assoc_string_ex(return_value, "secure", 7, "Yes", 1); + add_assoc_string_ex(return_value, "secure", 7, "Yes" VIRT_COPY_OPT); else if (iTmp == 0) - add_assoc_string_ex(return_value, "secure", 7, "No", 1); + add_assoc_string_ex(return_value, "secure", 7, "No" VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "secure", 7, "unknown", 1); + add_assoc_string_ex(return_value, "secure", 7, "unknown" VIRT_COPY_OPT); add_assoc_long(return_value, "num_inactive_domains", virConnectNumOfDefinedDomains(conn->conn)); add_assoc_long(return_value, "num_inactive_interfaces", virConnectNumOfDefinedInterfaces(conn->conn)); @@ -2735,11 +2734,7 @@ PHP_FUNCTION(libvirt_connect_get_uri) DPRINTF("%s: virConnectGetURI returned %s\n", PHPFUNC, uri); if (uri == NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(uri); -#else - RETVAL_STRING(uri, 1); -#endif + RETVAL_STRING(uri VIRT_COPY_OPT); free(uri); } @@ -2762,11 +2757,7 @@ PHP_FUNCTION(libvirt_connect_get_hostname) DPRINTF("%s: virConnectGetHostname returned %s\n", PHPFUNC, hostname); if (hostname==NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(hostname); -#else - RETVAL_STRING(hostname, 1); -#endif + RETVAL_STRING(hostname VIRT_COPY_OPT); free(hostname); } @@ -2919,14 +2910,14 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor) DPRINTF("%s: virConnectGetType returned %s\n", PHPFUNC, type); array_init(return_value); - add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type, 1); + add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type VIRT_COPY_OPT); add_assoc_long(return_value, "major",(long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "minor",(long)((hvVer/1000) % 1000)); add_assoc_long(return_value, "release",(long)(hvVer %1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); - add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr, 1); + add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr VIRT_COPY_OPT); } /* @@ -3021,7 +3012,7 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) add_assoc_bool(arr2, params.field, params.value.b); break; case VIR_TYPED_PARAM_STRING: - add_assoc_string_ex(arr2, params.field, strlen(params.field)+1, params.value.s, strlen(params.value.s)+1); + add_assoc_string_ex(arr2, params.field, strlen(params.field)+1, params.value.s VIRT_COPY_OPT); break; } } @@ -3074,11 +3065,7 @@ PHP_FUNCTION(libvirt_connect_get_sysinfo) sysinfo=virConnectGetSysinfo(conn->conn, 0); if (sysinfo==NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(sysinfo); -#else - RETVAL_STRING(sysinfo, 1); -#endif + RETVAL_STRING(sysinfo VIRT_COPY_OPT); free(sysinfo); } @@ -3146,7 +3133,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int *retVal) value = (char *)xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); snprintf(key, sizeof(key), "%d", i); - add_assoc_string_ex(*val, key, strlen(key)+1, value, 1); + add_assoc_string_ex(*val, key, strlen(key)+1, value VIRT_COPY_OPT); ret++; } } @@ -4050,11 +4037,7 @@ PHP_FUNCTION(libvirt_domain_get_metadata) } } else { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(ret); -#else - RETVAL_STRING(ret, 1); -#endif + RETVAL_STRING(ret VIRT_COPY_OPT); free(ret); } } @@ -4207,11 +4190,7 @@ PHP_FUNCTION(libvirt_domain_qemu_agent_command) ret = virDomainQemuAgentCommand(domain->domain, cmd, timeout, flags); if (ret == NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETURN_STRING(ret); -#else - RETURN_STRING(ret, 1); -#endif + RETURN_STRING(ret VIRT_COPY_OPT); } /* @@ -4511,11 +4490,7 @@ PHP_FUNCTION(libvirt_domain_get_name) DPRINTF("%s: virDomainGetName(%p) returned %s\n", PHPFUNC, domain->domain, name); if (name==NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETURN_STRING(name); -#else - RETURN_STRING(name, 1); //we can use the copy mechanism as we need not to free name (we even can not!) -#endif + RETURN_STRING(name VIRT_COPY_OPT); //we can use the copy mechanism as we need not to free name (we even can not!) } /* @@ -4540,7 +4515,7 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string) if (retval!=0) RETURN_FALSE; #if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(uuid); + RETVAL_STRING(uuid VIRT_COPY_OPT); efree(uuid); #else RETURN_STRING(uuid,0); @@ -4641,12 +4616,12 @@ PHP_FUNCTION(libvirt_domain_get_screenshot_api) if (WEXITSTATUS(exitStatus) != 0) RETURN_FALSE; - add_assoc_string_ex(return_value, "file", 5, fileNew, 1); - add_assoc_string_ex(return_value, "mime", 5, "image/png", 1); + add_assoc_string_ex(return_value, "file", 5, fileNew VIRT_COPY_OPT); + add_assoc_string_ex(return_value, "mime", 5, "image/png" VIRT_COPY_OPT); } else { - add_assoc_string_ex(return_value, "file", 5, file, 1); - add_assoc_string_ex(return_value, "mime", 5, mime, 1); + add_assoc_string_ex(return_value, "file", 5, file VIRT_COPY_OPT); + add_assoc_string_ex(return_value, "mime", 5, mime VIRT_COPY_OPT); } } @@ -5104,17 +5079,9 @@ PHP_FUNCTION(libvirt_connect_get_capabilities) tmp = get_string_from_xpath(caps, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(caps); -#else - RETVAL_STRING(caps, 1); -#endif + RETVAL_STRING(caps VIRT_COPY_OPT); } else { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(tmp); -#else - RETVAL_STRING(tmp, 1); -#endif + RETVAL_STRING(tmp VIRT_COPY_OPT); } free(caps); @@ -5149,11 +5116,7 @@ PHP_FUNCTION(libvirt_connect_get_emulator) RETURN_FALSE; } -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(tmp); -#else - RETVAL_STRING(tmp, 1); -#endif + RETVAL_STRING(tmp VIRT_COPY_OPT); free(tmp); } @@ -5218,7 +5181,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models) tTokenizer t = tokenize(tmp, ","); for (i = 0; i < t.numTokens; i++) { snprintf(tmp2, sizeof(tmp2), "%d", i); - add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[i], 1); + add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[i] VIRT_COPY_OPT); } free_tokens(t); } @@ -5311,14 +5274,14 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) zval *arr; ALLOC_INIT_ZVAL(arr); array_init(arr); - add_assoc_string_ex(arr, "name", 5, t.tokens[0], 1); - add_assoc_string_ex(arr, "description", 12, desc, 1); + add_assoc_string_ex(arr, "name", 5, t.tokens[0] VIRT_COPY_OPT); + add_assoc_string_ex(arr, "description", 12, desc VIRT_COPY_OPT); add_next_index_zval(return_value, arr); } else { char tmp2[16] = { 0 }; snprintf(tmp2, sizeof(tmp2), "%d", n++); - add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[0], 1); + add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[0] VIRT_COPY_OPT); } free_tokens(t); @@ -5585,11 +5548,7 @@ PHP_FUNCTION(libvirt_domain_new) PHP_FUNCTION(libvirt_domain_new_get_vnc) { if (LIBVIRT_G(vnc_location)) -#if PHP_MAJOR_VERSION >= 7 - RETURN_STRING(LIBVIRT_G(vnc_location)); -#else - RETURN_STRING(LIBVIRT_G(vnc_location),1); -#endif + RETURN_STRING(LIBVIRT_G(vnc_location) VIRT_COPY_OPT); RETURN_NULL(); } @@ -5627,17 +5586,9 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(xml); -#else - RETVAL_STRING(xml, 1); -#endif + RETVAL_STRING(xml VIRT_COPY_OPT); } else { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(tmp); -#else - RETVAL_STRING(tmp, 1); -#endif + RETVAL_STRING(tmp VIRT_COPY_OPT); } free(tmp); @@ -6858,8 +6809,8 @@ PHP_FUNCTION(libvirt_domain_get_network_info) } array_init(return_value); - add_assoc_string_ex(return_value, "mac", 4, mac, 1); - add_assoc_string_ex(return_value, "network", 8, tmp, 1); + add_assoc_string_ex(return_value, "mac", 4, mac VIRT_COPY_OPT); + add_assoc_string_ex(return_value, "network", 8, tmp VIRT_COPY_OPT); free(tmp); free(xpath); @@ -6870,9 +6821,9 @@ PHP_FUNCTION(libvirt_domain_get_network_info) } tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "nic_type", 9, tmp, 1); + add_assoc_string_ex(return_value, "nic_type", 9, tmp VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "nic_type", 9, "default", 1); + add_assoc_string_ex(return_value, "nic_type", 9, "default" VIRT_COPY_OPT); free(xml); free(xpath); @@ -6956,12 +6907,12 @@ PHP_FUNCTION(libvirt_domain_get_block_info) array_init(return_value); LONGLONG_INIT; - add_assoc_string_ex(return_value, "device", 7, dev, 1); + add_assoc_string_ex(return_value, "device", 7, dev VIRT_COPY_OPT); if (isFile) - add_assoc_string_ex(return_value, "file", 5, tmp, 1); + add_assoc_string_ex(return_value, "file", 5, tmp VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "partition", 10, tmp, 1); + add_assoc_string_ex(return_value, "partition", 10, tmp VIRT_COPY_OPT); free(xpath); if (asprintf(&xpath, "//domain/devices/disk/target[@dev='%s']/../driver/@type", dev) < 0) { @@ -6971,7 +6922,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info) free(tmp); tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if (tmp != NULL) - add_assoc_string_ex(return_value, "type", 5, tmp, 1); + add_assoc_string_ex(return_value, "type", 5, tmp VIRT_COPY_OPT); LONGLONG_ASSOC(return_value, "capacity", info.capacity); LONGLONG_ASSOC(return_value, "allocation", info.allocation); @@ -7027,7 +6978,7 @@ PHP_FUNCTION(libvirt_domain_xml_xpath) if (rc == 0) RETURN_FALSE; - add_assoc_string_ex(return_value, "xpath", 6, (char *)zpath, 1); + add_assoc_string_ex(return_value, "xpath", 6, (char *)zpath VIRT_COPY_OPT); if (rc < 0) add_assoc_long(return_value, "error_code", (long)rc); } @@ -7387,11 +7338,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml) xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags); if (xml==NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(xml); -#else - RETVAL_STRING(xml, 1); -#endif + RETVAL_STRING(xml VIRT_COPY_OPT); free(xml); } @@ -7722,11 +7669,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_name) DPRINTF("%s: virStorageVolGetName(%p) returned %s\n", PHPFUNC, volume->volume, retval); if (retval == NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETURN_STRING(retval); -#else - RETURN_STRING (retval, 1); -#endif + RETURN_STRING(retval VIRT_COPY_OPT); } /* @@ -7748,11 +7691,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_path) DPRINTF("%s: virStorageVolGetPath(%p) returned %s\n", PHPFUNC, volume->volume, retval); if (retval == NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETURN_STRING(retval); -#else - RETURN_STRING (retval, 1); -#endif + RETURN_STRING(retval VIRT_COPY_OPT); } /* @@ -7816,17 +7755,9 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(xml); -#else - RETVAL_STRING(xml, 1); -#endif + RETVAL_STRING(xml VIRT_COPY_OPT); } else { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(tmp); -#else - RETVAL_STRING(tmp, 1); -#endif + RETVAL_STRING(tmp VIRT_COPY_OPT); } free(xml); @@ -8110,11 +8041,7 @@ PHP_FUNCTION(libvirt_storagepool_get_name) if (name == NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >= 7 - RETURN_STRING(name); -#else - RETURN_STRING(name, 1); -#endif + RETURN_STRING(name VIRT_COPY_OPT); } /* @@ -8191,17 +8118,9 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(xml); -#else - RETVAL_STRING(xml, 1); -#endif + RETVAL_STRING(xml VIRT_COPY_OPT); } else { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(tmp); -#else - RETVAL_STRING(tmp, 1); -#endif + RETVAL_STRING(tmp VIRT_COPY_OPT); } free(xml); @@ -9120,17 +9039,9 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(xml); -#else - RETVAL_STRING(xml, 1); -#endif + RETVAL_STRING(xml VIRT_COPY_OPT); } else { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(tmp); -#else - RETVAL_STRING(tmp, 1); -#endif + RETVAL_STRING(tmp VIRT_COPY_OPT); } free(xml); @@ -9175,18 +9086,18 @@ PHP_FUNCTION(libvirt_nodedev_get_information) goto error; } - add_assoc_string_ex(return_value, "name", 5, tmp, 1); + add_assoc_string_ex(return_value, "name", 5, tmp VIRT_COPY_OPT); /* Get parent name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/parent", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "parent", 7, tmp, 1); + add_assoc_string_ex(return_value, "parent", 7, tmp VIRT_COPY_OPT); /* Get capability */ cap = get_string_from_xpath(xml, "//device/capability/@type", NULL, &retval); if ((cap != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "capability", 11, cap, 1); + add_assoc_string_ex(return_value, "capability", 11, cap VIRT_COPY_OPT); /* System capability is having hardware and firmware sub-blocks */ if (strcmp(cap, "system") == 0) { @@ -9194,92 +9105,92 @@ PHP_FUNCTION(libvirt_nodedev_get_information) free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "hardware_vendor", 16, tmp, 1); + add_assoc_string_ex(return_value, "hardware_vendor", 16, tmp VIRT_COPY_OPT); /* Get hardware version */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/version", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "hardware_version", 17, tmp, 1); + add_assoc_string_ex(return_value, "hardware_version", 17, tmp VIRT_COPY_OPT); /* Get hardware serial */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/serial", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "hardware_serial", 16, tmp, 1); + add_assoc_string_ex(return_value, "hardware_serial", 16, tmp VIRT_COPY_OPT); /* Get hardware UUID */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/uuid", NULL, &retval); if (tmp != NULL) - add_assoc_string_ex(return_value, "hardware_uuid", 15, tmp, 1); + add_assoc_string_ex(return_value, "hardware_uuid", 15, tmp VIRT_COPY_OPT); /* Get firmware vendor */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "firmware_vendor", 16, tmp, 1); + add_assoc_string_ex(return_value, "firmware_vendor", 16, tmp VIRT_COPY_OPT); /* Get firmware version */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/version", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "firmware_version", 17, tmp, 1); + add_assoc_string_ex(return_value, "firmware_version", 17, tmp VIRT_COPY_OPT); /* Get firmware release date */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/release_date", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "firmware_release_date", 22, tmp, 1); + add_assoc_string_ex(return_value, "firmware_release_date", 22, tmp VIRT_COPY_OPT); } /* Get product_id */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/product/@id", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "product_id", 11, tmp, 1); + add_assoc_string_ex(return_value, "product_id", 11, tmp VIRT_COPY_OPT); /* Get product_name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/product", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "product_name", 13, tmp, 1); + add_assoc_string_ex(return_value, "product_name", 13, tmp VIRT_COPY_OPT); /* Get vendor_id */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/vendor/@id", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "vendor_id", 10, tmp, 1); + add_assoc_string_ex(return_value, "vendor_id", 10, tmp VIRT_COPY_OPT); /* Get vendor_name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "vendor_name", 12, tmp, 1); + add_assoc_string_ex(return_value, "vendor_name", 12, tmp VIRT_COPY_OPT); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/driver/name", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "driver_name", 12, tmp, 1); + add_assoc_string_ex(return_value, "driver_name", 12, tmp VIRT_COPY_OPT); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/interface", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "interface_name", 15, tmp, 1); + add_assoc_string_ex(return_value, "interface_name", 15, tmp VIRT_COPY_OPT); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/address", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "address", 8, tmp, 1); + add_assoc_string_ex(return_value, "address", 8, tmp VIRT_COPY_OPT); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/capability/@type", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "capabilities", 11, tmp, 1); + add_assoc_string_ex(return_value, "capabilities", 11, tmp VIRT_COPY_OPT); free(cap); free(tmp); @@ -9411,11 +9322,7 @@ PHP_FUNCTION(libvirt_network_get_bridge) RETURN_FALSE; } -#if PHP_MAJOR_VERSION >= 7 - RETURN_STRING(name); -#else - RETURN_STRING(name, 1); -#endif + RETURN_STRING(name VIRT_COPY_OPT); } /* @@ -9488,42 +9395,42 @@ PHP_FUNCTION(libvirt_network_get_information) RETURN_FALSE; } - add_assoc_string_ex(return_value, "name", 5, name, 1); + add_assoc_string_ex(return_value, "name", 5, name VIRT_COPY_OPT); /* Get gateway IP address */ ipaddr = get_string_from_xpath(xml, "//network/ip/@address", NULL, &retval); if (ipaddr && retval > 0) - add_assoc_string_ex(return_value, "ip", 3, ipaddr, 1); + add_assoc_string_ex(return_value, "ip", 3, ipaddr VIRT_COPY_OPT); /* Get netmask */ netmask = get_string_from_xpath(xml, "//network/ip/@netmask", NULL, &retval); if (netmask && retval > 0) { int subnet_bits = get_subnet_bits(netmask); - add_assoc_string_ex(return_value, "netmask", 8, netmask, 1); + add_assoc_string_ex(return_value, "netmask", 8, netmask VIRT_COPY_OPT); add_assoc_long(return_value, "netmask_bits", (long) subnet_bits); /* Format CIDR address representation */ ipaddr[strlen(ipaddr) - 1] = ipaddr[strlen(ipaddr) - 1] - 1; snprintf(fixedtemp, sizeof(fixedtemp), "%s/%d", ipaddr, subnet_bits); - add_assoc_string_ex(return_value, "ip_range", 9, fixedtemp, 1); + add_assoc_string_ex(return_value, "ip_range", 9, fixedtemp VIRT_COPY_OPT); } /* Get forwarding settings */ mode = get_string_from_xpath(xml, "//network/forward/@mode", NULL, &retval); if (mode && retval > 0) - add_assoc_string_ex(return_value, "forwarding", 11, mode, 1); + add_assoc_string_ex(return_value, "forwarding", 11, mode VIRT_COPY_OPT); /* Get forwarding settings */ dev = get_string_from_xpath(xml, "//network/forward/@dev", NULL, &retval); if (dev && retval > 0) - add_assoc_string_ex(return_value, "forward_dev", 12, dev, 1); + add_assoc_string_ex(return_value, "forward_dev", 12, dev VIRT_COPY_OPT); /* Get DHCP values */ dhcp_start = get_string_from_xpath(xml, "//network/ip/dhcp/range/@start", NULL, &retval); dhcp_end = get_string_from_xpath(xml, "//network/ip/dhcp/range/@end", NULL, &retval); if (dhcp_start && dhcp_end && retval > 0) { - add_assoc_string_ex(return_value, "dhcp_start", 11, dhcp_start, 1); - add_assoc_string_ex(return_value, "dhcp_end", 9, dhcp_end, 1); + add_assoc_string_ex(return_value, "dhcp_start", 11, dhcp_start VIRT_COPY_OPT); + add_assoc_string_ex(return_value, "dhcp_end", 9, dhcp_end VIRT_COPY_OPT); } free(dhcp_end); @@ -9615,17 +9522,9 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(xml); -#else - RETVAL_STRING(xml, 1); -#endif + RETVAL_STRING(xml VIRT_COPY_OPT); } else { -#if PHP_MAJOR_VERSION >= 7 - RETVAL_STRING(tmp); -#else - RETVAL_STRING(tmp, 1); -#endif + RETVAL_STRING(tmp VIRT_COPY_OPT); } free(xml); @@ -9665,7 +9564,7 @@ PHP_FUNCTION(libvirt_version) add_assoc_long(return_value, "libvirt.minor",(long)((libVer/1000) % 1000)); add_assoc_long(return_value, "libvirt.major",(long)((libVer/1000000) % 1000)); - add_assoc_string_ex(return_value, "connector.version", 18, PHP_LIBVIRT_WORLD_VERSION, 1); + add_assoc_string_ex(return_value, "connector.version", 18, PHP_LIBVIRT_WORLD_VERSION VIRT_COPY_OPT); add_assoc_long(return_value, "connector.major", VERSION_MAJOR); add_assoc_long(return_value, "connector.minor", VERSION_MINOR); add_assoc_long(return_value, "connector.release", VERSION_MICRO); -- 2.5.5

On 13.04.2016 18:13, Neal Gompa wrote:
From: Remi Collet <fedora@famillecollet.com>
--- src/libvirt-php.c | 299 ++++++++++++++++++------------------------------------ 1 file changed, 99 insertions(+), 200 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 3f47075..80a947c 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -58,6 +58,7 @@ const char *features_binaries[] = { NULL }; #if PHP_MAJOR_VERSION >= 7 typedef size_t strsize_t;
+#define VIRT_COPY_OPT #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ RETURN_FALSE; \ @@ -68,6 +69,8 @@ typedef int strsize_t; typedef long zend_long; typedef unsigned long zend_ulong;
+#define VIRT_COPY_OPT ,1 +
This will still not fly. But I've rewritten the patch, so it builds. Michal

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 9 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 80a947c..6525ba5 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2316,7 +2316,11 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) array_init(return_value); for (i = 0; i < 2; i++) { +#if PHP_MAJOR_VERSION >= 7 + zval *arr, zarr; +#else zval *arr; +#endif if (i > 0) #ifdef EXTWIN Sleep(1000); @@ -2329,7 +2333,11 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) RETURN_FALSE; } +#if PHP_MAJOR_VERSION >= 7 + arr = &zarr; +#else ALLOC_INIT_ZVAL(arr); +#endif array_init(arr); for (j = 0; j < nparams; j++) { @@ -2375,7 +2383,11 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) int done = 0; int i, j, numCpus; time_t startTime = 0; +#if PHP_MAJOR_VERSION >= 7 + zval *time_array, ztime_array; +#else zval *time_array; +#endif GET_CONNECTION_FROM_ARGS("r|l", &zconn, &avg); @@ -2405,19 +2417,32 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) iter = 0; done = 0; while ( !done ) { +#if PHP_MAJOR_VERSION >= 7 + zval *arr, zarr; + arr = &zarr; +#else zval *arr; - ALLOC_INIT_ZVAL(arr); +#endif + array_init(arr); for (i = 0; i < numCpus; i++) { +#if PHP_MAJOR_VERSION >= 7 + zval *arr2, zarr2; +#else zval *arr2; +#endif if (virNodeGetCPUStats(conn->conn, i, params, &nparams, 0) != 0) { set_error("Unable to get node cpu stats" TSRMLS_CC); RETURN_FALSE; } +#if PHP_MAJOR_VERSION >= 7 + arr2 = &zarr2; +#else ALLOC_INIT_ZVAL(arr2); +#endif array_init(arr2); for (j = 0; j < nparams; j++) @@ -2442,7 +2467,11 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) iter++; } +#if PHP_MAJOR_VERSION >= 7 + time_array = &ztime_array; +#else ALLOC_INIT_ZVAL(time_array); +#endif array_init(time_array); add_assoc_long(time_array, "start", startTime); @@ -2538,8 +2567,13 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) snprintf(tmp, sizeof(tmp), "//capabilities/guest/arch[@name=\"%s\"]/domain/@type", ret[i]); char **ret2 = get_array_from_xpath(caps, tmp, &num2); if (ret2 != NULL) { +#if PHP_MAJOR_VERSION >= 7 + zval *arr2, zarr2; + arr2 = &zarr2; +#else zval *arr2; ALLOC_INIT_ZVAL(arr2); +#endif array_init(arr2); for (j = 0; j < num2; j++) { @@ -2547,8 +2581,13 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) char tmp2[1024] = { 0 }; /* Common */ +#if PHP_MAJOR_VERSION >= 7 + zval *arr3, zarr3; + arr3 = &zarr3; +#else zval *arr3; ALLOC_INIT_ZVAL(arr3); +#endif array_init(arr3); snprintf(tmp2, sizeof(tmp2), "//capabilities/guest/arch[@name=\"%s\"]/machine", @@ -2571,8 +2610,13 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) if (numTmp == NULL) add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT); else { +#if PHP_MAJOR_VERSION >= 7 + zval *arr4, zarr4; + arr4 = &zarr4; +#else zval *arr4; ALLOC_INIT_ZVAL(arr4); +#endif array_init(arr4); add_assoc_string_ex(arr4, "name", 5, ret3[k] VIRT_COPY_OPT); @@ -2606,8 +2650,13 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) if (numTmp == NULL) add_assoc_string_ex(arr3, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT); else { +#if PHP_MAJOR_VERSION >= 7 + zval *arr4, zarr4; + arr4 = &zarr4; +#else zval *arr4; ALLOC_INIT_ZVAL(arr4); +#endif array_init(arr4); add_assoc_string_ex(arr4, "name", 5, ret3[k] VIRT_COPY_OPT); @@ -2987,8 +3036,13 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) RETURN_FALSE; for (i=0; i < retval; i++) { +#if PHP_MAJOR_VERSION >= 7 + zval *arr2, zarr2; + arr2 = &zarr2; +#else zval *arr2; ALLOC_INIT_ZVAL(arr2); +#endif array_init(arr2); for (j = 0; j < retstats[i]->nparams; j++) { params = retstats[i]->params[j]; @@ -5264,6 +5318,13 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) continue; if ((i > 0) && (flags & CONNECT_FLAG_SOUNDHW_GET_NAMES)) { +#if PHP_MAJOR_VERSION >= 7 + zval *arr, zarr; + arr = &zarr; +#else + zval *arr; + ALLOC_INIT_ZVAL(arr); +#endif memset(desc, 0, sizeof(desc)); for (i = 1; i < t.numTokens; i++) { strcat(desc, t.tokens[i]); @@ -5271,8 +5332,6 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) strcat(desc, " "); } - zval *arr; - ALLOC_INIT_ZVAL(arr); array_init(arr); add_assoc_string_ex(arr, "name", 5, t.tokens[0] VIRT_COPY_OPT); add_assoc_string_ex(arr, "description", 12, desc VIRT_COPY_OPT); @@ -8620,7 +8679,11 @@ PHP_FUNCTION(libvirt_list_domain_resources) { php_libvirt_connection *conn=NULL; zval *zconn; +#if PHP_MAJOR_VERSION >= 7 + zval zdomain; +#else zval *zdomain; +#endif int count=-1; int expectedcount=-1; int *ids; @@ -8651,16 +8714,17 @@ PHP_FUNCTION(libvirt_list_domain_resources) res_domain= (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; - ALLOC_INIT_ZVAL(zdomain); res_domain->conn=conn; resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); #if PHP_MAJOR_VERSION >= 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); + ZVAL_RES(&zdomain, zend_register_resource(res_domain, le_libvirt_domain)); + add_next_index_zval(return_value, &zdomain); #else + ALLOC_INIT_ZVAL(zdomain); ZEND_REGISTER_RESOURCE(zdomain, res_domain, le_libvirt_domain); -#endif add_next_index_zval(return_value, zdomain); +#endif } } efree(ids); @@ -8683,16 +8747,17 @@ PHP_FUNCTION(libvirt_list_domain_resources) res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; - ALLOC_INIT_ZVAL(zdomain); res_domain->conn=conn; #if PHP_MAJOR_VERSION >= 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_domain)); + ZVAL_RES(&zdomain, zend_register_resource(res_domain, le_libvirt_domain)); + add_next_index_zval(return_value, &zdomain); #else + ALLOC_INIT_ZVAL(zdomain); ZEND_REGISTER_RESOURCE(zdomain, res_domain, le_libvirt_domain); + add_next_index_zval(return_value, zdomain); #endif resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); - add_next_index_zval(return_value, zdomain); } free(names[i]); } -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 6525ba5..ef732a3 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -3071,7 +3071,11 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) } } name = virDomainGetName(retstats[i]->dom); +#if PHP_MAJOR_VERSION >= 7 + zend_hash_update(Z_ARRVAL_P(return_value), zend_string_init(name, strlen(name), 0), arr2); +#else zend_hash_update(Z_ARRVAL_P(return_value), name, strlen(name)+1, &arr2, sizeof(arr2), NULL); +#endif } virDomainStatsRecordListFree(retstats); -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index ef732a3..771f3b4 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -7485,7 +7485,7 @@ PHP_FUNCTION(libvirt_list_domain_snapshots) array_init(return_value); for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i], 1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } } @@ -7598,7 +7598,7 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) if ((count != expectedcount) || (count<0)) RETURN_FALSE; for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i],1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } @@ -8491,7 +8491,7 @@ PHP_FUNCTION(libvirt_list_storagepools) array_init(return_value); for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i],1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } efree(names); @@ -8509,7 +8509,7 @@ PHP_FUNCTION(libvirt_list_storagepools) for (i = 0; i < count; i++) { - add_next_index_string (return_value, names[i], 1); + add_next_index_string (return_value, names[i] VIRT_COPY_OPT); free (names[i]); } efree (names); @@ -8547,7 +8547,7 @@ PHP_FUNCTION(libvirt_list_active_storagepools) array_init(return_value); for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i],1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } efree(names); @@ -8585,7 +8585,7 @@ PHP_FUNCTION(libvirt_list_inactive_storagepools) array_init(return_value); for (i = 0; i < count; i++) { - add_next_index_string (return_value, names[i], 1); + add_next_index_string (return_value, names[i] VIRT_COPY_OPT); free (names[i]); } efree (names); @@ -8631,7 +8631,7 @@ PHP_FUNCTION(libvirt_list_domains) name=virDomainGetName(domain); if (name != NULL) { DPRINTF("%s: Found running domain %s with ID = %d\n", PHPFUNC, name, ids[i]); - add_next_index_string(return_value, name, 1); + add_next_index_string(return_value, name VIRT_COPY_OPT); } else DPRINTF("%s: Cannot get ID for running domain %d\n", PHPFUNC, ids[i]); @@ -8665,7 +8665,7 @@ PHP_FUNCTION(libvirt_list_domains) for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i], 1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); DPRINTF("%s: Found inactive domain %s\n", PHPFUNC, names[i]); free(names[i]); } @@ -8852,7 +8852,7 @@ PHP_FUNCTION(libvirt_list_active_domains) RETURN_FALSE; } - add_next_index_string(return_value, name, 1); + add_next_index_string(return_value, name VIRT_COPY_OPT); } } efree(ids); @@ -8890,7 +8890,7 @@ PHP_FUNCTION(libvirt_list_inactive_domains) array_init(return_value); for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i],1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } efree(names); @@ -8931,7 +8931,7 @@ PHP_FUNCTION(libvirt_list_networks) for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i], 1); + add_next_index_string(return_value, names[i]); free(names[i]); } @@ -8997,7 +8997,7 @@ PHP_FUNCTION(libvirt_list_nodedevs) array_init(return_value); for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i], 1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } @@ -9069,7 +9069,7 @@ PHP_FUNCTION(libvirt_nodedev_capabilities) array_init(return_value); for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i], 1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } @@ -9758,7 +9758,7 @@ PHP_FUNCTION(libvirt_get_iso_images) array_init(return_value); while ((entry = readdir(d)) != NULL) { if (strcasecmp(entry->d_name + strlen(entry->d_name) - 4, ".iso") == 0) { - add_next_index_string(return_value, entry->d_name, 1); + add_next_index_string(return_value, entry->d_name VIRT_COPY_OPT); num++; } } @@ -9798,7 +9798,7 @@ PHP_FUNCTION(libvirt_print_binding_resources) else snprintf(tmp, sizeof(tmp), "Libvirt %s resource at 0x%"UINTx, translate_counter_type(binding_resources[i].type), binding_resources[i].mem); - add_next_index_string(return_value, tmp, 1); + add_next_index_string(return_value, tmp VIRT_COPY_OPT); } } -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 98 +++++++++++++++++++++++++++++++++++++++++++++---------- src/libvirt-php.h | 4 +++ 2 files changed, 85 insertions(+), 17 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 771f3b4..653d251 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2039,7 +2039,7 @@ else \ #define LONGLONG_INDEX(out,key,in) \ if (LIBVIRT_G(longlong_to_string_ini)) { \ snprintf(tmpnumber,63,"%llu",in); \ - add_index_string(out,key,tmpnumber,1); \ + add_index_string(out,key,tmpnumber VIRT_COPY_OPT); \ } \ else \ { \ @@ -2225,11 +2225,12 @@ PHP_FUNCTION(libvirt_connect) DPRINTF("%s: Connection to %s established, returning %p\n", PHPFUNC, url, conn->conn); #if PHP_MAJOR_VERSION >= 7 - ZVAL_RES(return_value, zend_register_resource(conn, le_libvirt_connection)); + conn->resource_id = zend_register_resource(conn, le_libvirt_connection); + ZVAL_RES(return_value, conn->resource_id); #else ZEND_REGISTER_RESOURCE(return_value, conn, le_libvirt_connection); + conn->resource_id = Z_LVAL_P(return_value); #endif - conn->resource_id=Z_LVAL_P(return_value); } /* @@ -4438,14 +4439,15 @@ PHP_FUNCTION(libvirt_stream_recv) if (retval < 0) { efree(recv_buf); zval_dtor(zbuf); - Z_TYPE_P(zbuf) = IS_NULL; + ZVAL_NULL(zbuf); } else { recv_buf[retval] = '\0'; - /* Rebuild buffer zval */ - zval_dtor(zbuf); - Z_STRVAL_P(zbuf) = recv_buf; - Z_STRLEN_P(zbuf) = retval; - Z_TYPE_P(zbuf) = IS_STRING; +#if PHP_MAJOR_VERSION >= 7 + ZVAL_STRINGL(zbuf, recv_buf, retval); + efree(recv_buf); +#else + ZVAL_STRINGL(zbuf, recv_buf, retval, 0) +#endif } if (retval == -1) { @@ -4806,9 +4808,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) } /* This is necessary to make the output binary safe */ - Z_STRLEN_P(return_value) = fsize; - Z_STRVAL_P(return_value) = buf; - Z_TYPE_P(return_value) = IS_STRING; + ZVAL_STRINGL(return_value, buf, fsize VIRT_COPY_OPT); efree(buf); free(tmp); @@ -5161,7 +5161,6 @@ PHP_FUNCTION(libvirt_connect_get_emulator) char *arch = NULL; int arch_len; char *tmp; - char *emulator; GET_CONNECTION_FROM_ARGS("r|s",&zconn,&arch,&arch_len); @@ -5358,10 +5357,15 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network) { HashTable *arr_hash; // int array_count; +#if PHP_MAJOR_VERSION >= 7 + zval *data; + zend_string *key; +#else zval **data; // removed **zvalue - HashPosition pointer; char *key; unsigned int key_len; +#endif + HashPosition pointer; unsigned long index; arr_hash = Z_ARRVAL_P(arr); @@ -5372,6 +5376,43 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network) if (network != NULL) memset(network, 0, sizeof(tVMNetwork)); +#if PHP_MAJOR_VERSION >= 7 + for (zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); + (data = zend_hash_get_current_data_ex(arr_hash, &pointer)) != NULL; + zend_hash_move_forward_ex(arr_hash, &pointer)) { + if ((Z_TYPE_P(data) == IS_STRING) || (Z_TYPE_P(data) == IS_LONG)) { + if (zend_hash_get_current_key_ex(arr_hash, &key, &index, &pointer) == HASH_KEY_IS_STRING) { + if (disk != NULL) { + if ((Z_TYPE_P(data) == IS_STRING) && strcmp(ZSTR_VAL(key), "path") == 0) + disk->path = strdup( Z_STRVAL_P(data) ); + else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(ZSTR_VAL(key), "driver") == 0) + disk->driver = strdup( Z_STRVAL_P(data) ); + else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(ZSTR_VAL(key), "bus") == 0) + disk->bus = strdup( Z_STRVAL_P(data) ); + else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(ZSTR_VAL(key), "dev") == 0) + disk->dev = strdup( Z_STRVAL_P(data) ); + else if (strcmp(ZSTR_VAL(key), "size") == 0) { + if (Z_TYPE_P(data) == IS_LONG) + disk->size = Z_LVAL_P(data); + else + disk->size = size_def_to_mbytes(Z_STRVAL_P(data)); + } + else if ((Z_TYPE_P(data) == IS_LONG) && strcmp(ZSTR_VAL(key), "dev") == 0) + disk->flags = Z_LVAL_P(data); + } else { + if (network != NULL) { + if ((Z_TYPE_P(data) == IS_STRING) && strcmp(ZSTR_VAL(key), "mac") == 0) + network->mac = strdup( Z_STRVAL_P(data) ); + else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(ZSTR_VAL(key), "network") == 0) + network->network = strdup( Z_STRVAL_P(data) ); + else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(ZSTR_VAL(key), "model") == 0) + network->model = strdup( Z_STRVAL_P(data) ); + } + } + } + } + } +#else for (zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { @@ -5410,6 +5451,7 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network) } } } +#endif } /* @@ -5451,7 +5493,11 @@ PHP_FUNCTION(libvirt_domain_new) long maxmemMB = -1; HashTable *arr_hash; int numDisks, numNets, i; +#if PHP_MAJOR_VERSION >= 7 + zval *data; +#else zval **data; // removed **zvalue +#endif HashPosition pointer; char vncl[2048] = { 0 }; char tmpname[1024] = { 0 }; @@ -5482,12 +5528,19 @@ PHP_FUNCTION(libvirt_domain_new) memset(vmDisks, 0, numDisks * sizeof(tVMDisk)); i = 0; for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); +#if PHP_MAJOR_VERSION >= 7 + (data = zend_hash_get_current_data_ex(arr_hash, &pointer)) != NULL; + zend_hash_move_forward_ex(arr_hash, &pointer)) { + if (Z_TYPE_P(data) == IS_ARRAY) { + tVMDisk disk; + parse_array(data, &disk, NULL); +#else zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { if (Z_TYPE_PP(data) == IS_ARRAY) { tVMDisk disk; parse_array(*data, &disk, NULL); - +#endif if (disk.path != NULL) { //DPRINTF("Disk => path = '%s', driver = '%s', bus = '%s', dev = '%s', size = %ld MB, flags = %d\n", // disk.path, disk.driver, disk.bus, disk.dev, disk.size, disk.flags); @@ -5504,12 +5557,19 @@ PHP_FUNCTION(libvirt_domain_new) memset(vmNetworks, 0, numNets * sizeof(tVMNetwork)); i = 0; for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); +#if PHP_MAJOR_VERSION >= 7 + (data = zend_hash_get_current_data_ex(arr_hash, &pointer)) != NULL; + zend_hash_move_forward_ex(arr_hash, &pointer)) { + if (Z_TYPE_P(data) == IS_ARRAY) { + tVMNetwork network; + parse_array(data, NULL, &network); +#else zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { if (Z_TYPE_PP(data) == IS_ARRAY) { tVMNetwork network; parse_array(*data, NULL, &network); - +#endif if (network.mac != NULL) { //DPRINTF("Network => mac = '%s', network = '%s', model = '%s'\n", network.mac, network.network, network.model); vmNetworks[i++] = network; @@ -7101,7 +7161,11 @@ PHP_FUNCTION(libvirt_domain_get_connect) conn= domain->conn; if (conn->conn == NULL) RETURN_FALSE; +#if PHP_MAJOR_VERSION >= 7 + ZVAL_RES(return_value, conn->resource_id); +#else RETURN_RESOURCE(conn->resource_id); +#endif } /* @@ -8952,7 +9016,7 @@ PHP_FUNCTION(libvirt_list_networks) for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i], 1); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } diff --git a/src/libvirt-php.h b/src/libvirt-php.h index bf33a57..9217b91 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -258,7 +258,11 @@ typedef struct tBMPFile { /* Libvirt-php types */ typedef struct _php_libvirt_connection { virConnectPtr conn; +#if PHP_MAJOR_VERSION >= 7 + zend_resource *resource_id; +#else long resource_id; +#endif } php_libvirt_connection; typedef struct _php_libvirt_stream { -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 9217b91..1562b32 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -74,10 +74,10 @@ #endif #ifndef VERSION -#define VERSION "0.5.1" +#define VERSION "0.5.2-dev" #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_MICRO 1 +#define VERSION_MICRO 2 #endif #include <libvirt/libvirt.h> -- 2.5.5

On 13.04.2016 18:13, Neal Gompa wrote:
From: Remi Collet <fedora@famillecollet.com>
--- src/libvirt-php.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 9217b91..1562b32 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -74,10 +74,10 @@ #endif
#ifndef VERSION -#define VERSION "0.5.1" +#define VERSION "0.5.2-dev" #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_MICRO 1 +#define VERSION_MICRO 2 #endif
#include <libvirt/libvirt.h>
This is not how we handle version numbers. Anything that's not released yet is a development version. NACK to this one. Michal

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 279 +++++++++++++++++++++++++++--------------------------- 1 file changed, 141 insertions(+), 138 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 653d251..fe84f16 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2279,7 +2279,7 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS; virNodeCPUStatsPtr params; virNodeInfo info; - long cpunr = -1; + zend_long cpunr = -1; int nparams = 0; int i, j, numCpus; @@ -2380,7 +2380,7 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) virNodeCPUStatsPtr params; virNodeInfo info; int nparams = 0; - long avg = 0, iter = 0; + zend_long avg = 0, iter = 0; int done = 0; int i, j, numCpus; time_t startTime = 0; @@ -2830,12 +2830,12 @@ PHP_FUNCTION(libvirt_image_create) char *path = NULL; char fpath[4096] = { 0 }; char *image = NULL; - int image_len; + strsize_t image_len; char *format; - int format_len; + strsize_t format_len; long long size; char *size_str; - int size_str_len; + strsize_t size_str_len; int cmdRet; if (LIBVIRT_G(image_path_ini)) @@ -2898,7 +2898,7 @@ PHP_FUNCTION(libvirt_image_remove) char name[1024]; char msg[4096] = { 0 }; char *image = NULL; - int image_len; + strsize_t image_len; GET_CONNECTION_FROM_ARGS("rs",&zconn,&image,&image_len); @@ -3020,8 +3020,8 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) php_libvirt_connection *conn = NULL; zval *zconn; int retval = -1; - long flags = 0; - long stats = 0; + zend_long flags = 0; + zend_long stats = 0; const char *name = NULL; int i; int j; @@ -3960,7 +3960,7 @@ PHP_FUNCTION(libvirt_domain_set_max_memory) { php_libvirt_domain *domain = NULL; zval *zdomain; - long memory = 0; + zend_long memory = 0; GET_DOMAIN_FROM_ARGS ("rl", &zdomain, &memory); @@ -3982,7 +3982,7 @@ PHP_FUNCTION(libvirt_domain_set_memory) { php_libvirt_domain *domain = NULL; zval *zdomain; - long memory = 0; + zend_long memory = 0; GET_DOMAIN_FROM_ARGS ("rl", &zdomain, &memory); @@ -4005,8 +4005,8 @@ PHP_FUNCTION(libvirt_domain_set_memory_flags) { php_libvirt_domain *domain = NULL; zval *zdomain; - long memory = 0; - long flags = 0; + zend_long memory = 0; + zend_long flags = 0; GET_DOMAIN_FROM_ARGS ("rl|l", &zdomain, &memory, &flags); @@ -4075,10 +4075,10 @@ PHP_FUNCTION(libvirt_domain_get_metadata) { php_libvirt_domain *domain = NULL; zval *zdomain; - long type = 0; - long flags = 0; + zend_long type = 0; + zend_long flags = 0; char *uri = NULL; - int uri_len; + strsize_t uri_len; char *ret = NULL; GET_DOMAIN_FROM_ARGS ("rlsl", &zdomain, &type, &uri, &uri_len, &flags); @@ -4117,12 +4117,12 @@ PHP_FUNCTION(libvirt_domain_set_metadata) { php_libvirt_domain *domain = NULL; zval *zdomain; - int metadata_len, key_len, uri_len; + strsize_t metadata_len, key_len, uri_len; char *metadata = NULL; char *key = NULL; char *uri = NULL; - long type = 0; - long flags = 0; + zend_long type = 0; + zend_long flags = 0; int rc; GET_DOMAIN_FROM_ARGS ("rlsssl", &zdomain, &type, &metadata, &metadata_len, &key, &key_len, &uri, &uri_len, &flags); @@ -4165,7 +4165,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) { php_libvirt_connection *conn=NULL; zval *zconn; - int name_len; + strsize_t name_len; char *name=NULL; virDomainPtr domain=NULL; php_libvirt_domain *res_domain; @@ -4200,7 +4200,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) { php_libvirt_connection *conn=NULL; zval *zconn; - int uuid_len; + strsize_t uuid_len; unsigned char *uuid=NULL; virDomainPtr domain=NULL; php_libvirt_domain *res_domain; @@ -4239,10 +4239,10 @@ PHP_FUNCTION(libvirt_domain_qemu_agent_command) php_libvirt_domain *domain=NULL; zval *zdomain; const char *cmd; - int cmd_len; + strsize_t cmd_len; char *ret; - long timeout = -1; - long flags = 0; + zend_long timeout = -1; + zend_long flags = 0; GET_DOMAIN_FROM_ARGS("rs|ll", &zdomain, &cmd, &cmd_len, &timeout, &flags); @@ -4264,7 +4264,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) { php_libvirt_connection *conn=NULL; zval *zconn; - int uuid_len; + strsize_t uuid_len; char *uuid=NULL; virDomainPtr domain=NULL; php_libvirt_domain *res_domain; @@ -4506,7 +4506,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_id) { php_libvirt_connection *conn=NULL; zval *zconn; - long id; + zend_long id; virDomainPtr domain=NULL; php_libvirt_domain *res_domain; @@ -4612,7 +4612,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot_api) { php_libvirt_domain *domain=NULL; zval *zdomain; - long screen = 0; + zend_long screen = 0; int fd = -1; char file[] = "/tmp/libvirt-php-tmp-XXXXXX"; virStreamPtr st = NULL; @@ -4709,8 +4709,8 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) char *xml = NULL; int port = -1; char *hostname = NULL; - int hostname_len; - long scancode = 10; + strsize_t hostname_len; + zend_long scancode = 10; const char *path; char *pathDup = NULL; char name[1024] = { 0 }; @@ -4845,7 +4845,7 @@ PHP_FUNCTION(libvirt_domain_get_screen_dimensions) char *tmp = NULL; char *xml = NULL; char *hostname = NULL; - int hostname_len; + strsize_t hostname_len; int ret; int width; int height; @@ -4914,9 +4914,9 @@ PHP_FUNCTION(libvirt_domain_send_keys) char *tmp = NULL; char *xml = NULL; char *hostname = NULL; - int hostname_len; + strsize_t hostname_len; char *keys = NULL; - int keys_len; + strsize_t keys_len; int ret = 0; GET_DOMAIN_FROM_ARGS("rss",&zdomain, &hostname, &hostname_len, &keys, &keys_len); @@ -4982,11 +4982,11 @@ PHP_FUNCTION(libvirt_domain_send_pointer_event) char *tmp = NULL; char *xml = NULL; char *hostname = NULL; - int hostname_len; - long pos_x = 0; - long pos_y = 0; - long clicked = 0; - int release = 1; + strsize_t hostname_len; + zend_long pos_x = 0; + zend_long pos_y = 0; + zend_long clicked = 0; + zend_bool release = 1; int ret; GET_DOMAIN_FROM_ARGS("rslll|b",&zdomain, &hostname, &hostname_len, &pos_x, &pos_y, &clicked, &release); @@ -5125,7 +5125,7 @@ PHP_FUNCTION(libvirt_connect_get_capabilities) zval *zconn; char *caps; char *xpath = NULL; - int xpath_len; + strsize_t xpath_len; char *tmp = NULL; int retval = -1; @@ -5159,7 +5159,7 @@ PHP_FUNCTION(libvirt_connect_get_emulator) php_libvirt_connection *conn=NULL; zval *zconn; char *arch = NULL; - int arch_len; + strsize_t arch_len; char *tmp; GET_CONNECTION_FROM_ARGS("r|s",&zconn,&arch,&arch_len); @@ -5190,7 +5190,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models) php_libvirt_connection *conn=NULL; zval *zconn; char *arch = NULL; - int arch_len; + strsize_t arch_len; char *tmp; GET_CONNECTION_FROM_ARGS("r|s",&zconn,&arch,&arch_len); @@ -5261,9 +5261,9 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) php_libvirt_connection *conn=NULL; zval *zconn; char *arch = NULL; - int arch_len; + strsize_t arch_len; char *tmp; - long flags = 0; + zend_long flags = 0; GET_CONNECTION_FROM_ARGS("r|sl",&zconn,&arch,&arch_len,&flags); @@ -5478,19 +5478,19 @@ PHP_FUNCTION(libvirt_domain_new) virDomainPtr domain=NULL; zval *zconn; char *arch = NULL; - int arch_len; + strsize_t arch_len; char *tmp; char *name; - int name_len=0; + strsize_t name_len=0; // char *emulator; char *iso_image = NULL; - int iso_image_len; - long vcpus = -1; - long memMB = -1; + strsize_t iso_image_len; + zend_long vcpus = -1; + zend_long memMB = -1; zval *disks, *networks; tVMDisk *vmDisks = NULL; tVMNetwork *vmNetworks = NULL; - long maxmemMB = -1; + zend_long maxmemMB = -1; HashTable *arr_hash; int numDisks, numNets, i; #if PHP_MAJOR_VERSION >= 7 @@ -5504,7 +5504,7 @@ PHP_FUNCTION(libvirt_domain_new) char *xml = NULL; int retval = 0; char *uuid = NULL; - long flags = 0; + zend_long flags = 0; int fd = -1; GET_CONNECTION_FROM_ARGS("rsslllsaa|l",&zconn,&name,&name_len,&arch,&arch_len,&memMB,&maxmemMB,&vcpus,&iso_image,&iso_image_len,&disks,&networks,&flags); @@ -5691,8 +5691,8 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc) char *tmp = NULL; char *xml; char *xpath = NULL; - int xpath_len; - long flags=0; + strsize_t xpath_len; + zend_long flags=0; int retval = -1; GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&xpath,&xpath_len,&flags); @@ -5799,7 +5799,7 @@ PHP_FUNCTION(libvirt_domain_get_interface_devices) */ PHP_FUNCTION(libvirt_domain_change_vcpus) { - long numCpus, flags = 0; + zend_long numCpus, flags = 0; php_libvirt_domain *domain=NULL; zval *zdomain; @@ -5834,9 +5834,9 @@ PHP_FUNCTION(libvirt_domain_change_memory) char *new_xml = NULL; int new_len; char *newXml = NULL; - long xflags = 0; - long allocMem = 0; - long allocMax = 0; + zend_long xflags = 0; + zend_long allocMem = 0; + zend_long allocMax = 0; // int pos = -1; int len = 0; php_libvirt_domain *res_domain = NULL; @@ -5919,11 +5919,11 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) char *new_xml = NULL; int new_len; char newXml[4096] = { 0 }; - long xflags = 0; + zend_long xflags = 0; char *first = NULL; - int first_len; + strsize_t first_len; char *second = NULL; - int second_len; + strsize_t second_len; // int pos = -1; int len = 0; php_libvirt_domain *res_domain = NULL; @@ -6001,15 +6001,15 @@ PHP_FUNCTION(libvirt_domain_disk_add) zval *zdomain; char *xml; char *img = NULL; - int img_len; + strsize_t img_len; char *dev = NULL; - int dev_len; + strsize_t dev_len; char *driver = NULL; - int driver_len; + strsize_t driver_len; char *typ = NULL; - int typ_len; + strsize_t typ_len; char *newXml = NULL; - long xflags = 0; + zend_long xflags = 0; int retval = -1; char *xpath = NULL; char *tmp = NULL; @@ -6097,9 +6097,9 @@ PHP_FUNCTION(libvirt_domain_disk_remove) zval *zdomain; char *xml; char *dev = NULL; - int dev_len; + strsize_t dev_len; char *newXml = NULL; - long xflags = 0; + zend_long xflags = 0; int retval = -1; char *xpath = NULL; char *tmp = NULL; @@ -6170,13 +6170,13 @@ PHP_FUNCTION(libvirt_domain_nic_add) zval *zdomain; char *xml; char *mac = NULL; - int mac_len; + strsize_t mac_len; char *net = NULL; - int net_len; + strsize_t net_len; char *model = NULL; - int model_len; + strsize_t model_len; char *newXml = NULL; - long xflags = 0; + zend_long xflags = 0; int retval = -1; char *xpath = NULL; char *tmp = NULL; @@ -6263,9 +6263,9 @@ PHP_FUNCTION(libvirt_domain_nic_remove) zval *zdomain; char *xml; char *mac = NULL; - int mac_len; + strsize_t mac_len; char *newXml = NULL; - long xflags = 0; + zend_long xflags = 0; int retval = -1; char *xpath = NULL; char *tmp = NULL; @@ -6423,7 +6423,7 @@ PHP_FUNCTION(libvirt_domain_core_dump) php_libvirt_domain *domain=NULL; zval *zdomain; int retval; - int to_len; + strsize_t to_len; char *to; GET_DOMAIN_FROM_ARGS("rs",&zdomain,&to,&to_len); @@ -6530,7 +6530,7 @@ PHP_FUNCTION(libvirt_domain_reboot) php_libvirt_domain *domain=NULL; zval *zdomain; int retval; - long flags=0; + zend_long flags=0; GET_DOMAIN_FROM_ARGS("r|l",&zdomain,&flags); @@ -6555,7 +6555,7 @@ PHP_FUNCTION(libvirt_domain_define_xml) zval *zconn; virDomainPtr domain=NULL; char *xml; - int xml_len; + strsize_t xml_len; GET_CONNECTION_FROM_ARGS("rs",&zconn,&xml,&xml_len); @@ -6590,8 +6590,8 @@ PHP_FUNCTION(libvirt_domain_create_xml) zval *zconn; virDomainPtr domain=NULL; char *xml; - int xml_len; - long flags=0; + strsize_t xml_len; + zend_long flags=0; GET_CONNECTION_FROM_ARGS("rs|l", &zconn, &xml, &xml_len, &flags); @@ -6627,9 +6627,9 @@ PHP_FUNCTION(libvirt_domain_memory_peek) php_libvirt_domain *domain=NULL; zval *zdomain; int retval; - long flags=0; - long start; - long size; + zend_long flags=0; + zend_long start; + zend_long size; char *buff; GET_DOMAIN_FROM_ARGS("rlll",&zdomain,&start,&size,&flags); @@ -6657,7 +6657,7 @@ PHP_FUNCTION(libvirt_domain_memory_stats) php_libvirt_domain *domain=NULL; zval *zdomain; int retval; - long flags=0; + zend_long flags=0; int i; struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR]; @@ -6689,8 +6689,8 @@ PHP_FUNCTION(libvirt_domain_update_device) php_libvirt_domain *domain=NULL; zval *zdomain; char *xml; - int xml_len; - long flags; + strsize_t xml_len; + zend_long flags; int res; GET_DOMAIN_FROM_ARGS("rsl",&zdomain,&xml,&xml_len,&flags); @@ -6717,7 +6717,7 @@ PHP_FUNCTION(libvirt_domain_block_stats) zval *zdomain; int retval; char *path; - int path_len; + strsize_t path_len; struct _virDomainBlockStats stats; @@ -6752,9 +6752,9 @@ PHP_FUNCTION(libvirt_domain_block_resize) zval *zdomain; int retval; char *path; - int path_len; - long size = 0; - long flags = 0; + strsize_t path_len; + zend_long size = 0; + zend_long flags = 0; GET_DOMAIN_FROM_ARGS("rsl|l",&zdomain, &path, &path_len, &size, &flags); @@ -6846,8 +6846,8 @@ PHP_FUNCTION(libvirt_domain_block_job_abort) zval *zdomain; int retval; char *path; - int path_len; - long flags = 0; + strsize_t path_len; + zend_long flags = 0; GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &path, &path_len, &flags); @@ -6873,9 +6873,9 @@ PHP_FUNCTION(libvirt_domain_block_job_set_speed) zval *zdomain; int retval; char *path; - int path_len; - long bandwidth = 0; - long flags = 0; + strsize_t path_len; + zend_long bandwidth = 0; + zend_long flags = 0; GET_DOMAIN_FROM_ARGS("rsl|l",&zdomain, &path, &path_len, &bandwidth, &flags); @@ -6903,7 +6903,7 @@ PHP_FUNCTION(libvirt_domain_get_network_info) char *mac; char *xml; char *tmp = NULL; - int mac_len; + strsize_t mac_len; char *xpath = NULL; GET_DOMAIN_FROM_ARGS("rs",&zdomain,&mac,&mac_len); @@ -6976,7 +6976,8 @@ PHP_FUNCTION(libvirt_domain_get_block_info) char *dev; char *xml; char *tmp = NULL; - int dev_len, isFile; + strsize_t dev_len; + int isFile; char *xpath = NULL; struct _virDomainBlockInfo info; @@ -7079,7 +7080,8 @@ PHP_FUNCTION(libvirt_domain_xml_xpath) zval *zpath; char *xml; char *tmp = NULL; - long path_len=-1, flags = 0; + strsize_t path_len = -1; + zend_long flags = 0; int rc = 0; GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &zpath, &path_len, &flags); @@ -7120,7 +7122,7 @@ PHP_FUNCTION(libvirt_domain_interface_stats) zval *zdomain; int retval; char *path; - int path_len; + strsize_t path_len; struct _virDomainInterfaceStats stats; @@ -7186,10 +7188,10 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri) int retval; long flags=0; char *duri; - int duri_len; + strsize_t duri_len; char *dname; - int dname_len; - long bandwidth; + strsize_t dname_len; + zend_long bandwidth; dname=NULL; dname_len=0; @@ -7222,15 +7224,15 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri2) zval *zdomain; int retval; char *dconnuri; - int dconnuri_len; + strsize_t dconnuri_len; char *miguri; - int miguri_len; + strsize_t miguri_len; char *dxml; - int dxml_len; - long flags=0; + strsize_t dxml_len; + zend_long flags=0; char *dname; - int dname_len; - long bandwidth; + strsize_t dname_len; + zend_long bandwidth; dconnuri=NULL; dconnuri_len=0; @@ -7276,10 +7278,10 @@ PHP_FUNCTION(libvirt_domain_migrate) virDomainPtr destdomain=NULL; php_libvirt_domain *res_domain; - long flags=0; + zend_long flags=0; char *dname; - int dname_len; - long bandwidth; + strsize_t dname_len; + zend_long bandwidth; dname=NULL; dname_len=0; @@ -7363,7 +7365,7 @@ PHP_FUNCTION(libvirt_domain_has_current_snapshot) php_libvirt_domain *domain=NULL; zval *zdomain; int retval; - long flags = 0; + zend_long flags = 0; GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags); @@ -7385,9 +7387,9 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) { php_libvirt_domain *domain=NULL; zval *zdomain; - int name_len; + strsize_t name_len; char *name=NULL; - long flags = 0; + zend_long flags = 0; php_libvirt_snapshot *res_snapshot; virDomainSnapshotPtr snapshot = NULL; @@ -7424,7 +7426,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_create) php_libvirt_snapshot *res_snapshot; zval *zdomain; virDomainSnapshotPtr snapshot = NULL; - long flags = 0; + zend_long flags = 0; GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags); @@ -7458,7 +7460,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml) char *xml; zval *zsnapshot; php_libvirt_snapshot *snapshot; - long flags = 0; + zend_long flags = 0; GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags); @@ -7482,7 +7484,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_revert) zval *zsnapshot; php_libvirt_snapshot *snapshot; int ret; - long flags = 0; + zend_long flags = 0; GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags); @@ -7504,7 +7506,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_delete) { zval *zsnapshot; php_libvirt_snapshot *snapshot; - long flags = 0; + zend_long flags = 0; int retval; GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags); @@ -7530,7 +7532,7 @@ PHP_FUNCTION(libvirt_list_domain_snapshots) int count=-1; int expectedcount=-1; char **names; - long flags = 0; + zend_long flags = 0; int i; GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags); @@ -7570,7 +7572,7 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) { php_libvirt_connection *conn=NULL; zval *zconn; - int name_len; + strsize_t name_len; char *name=NULL; virStoragePoolPtr pool=NULL; php_libvirt_storagepool *res_pool; @@ -7712,7 +7714,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) php_libvirt_storagepool *pool=NULL; php_libvirt_volume *res_volume; zval *zpool; - int name_len; + strsize_t name_len; char *name=NULL; virStorageVolPtr volume=NULL; @@ -7749,7 +7751,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) php_libvirt_connection *conn=NULL; php_libvirt_volume *res_volume; zval *zconn; - int name_len; + strsize_t name_len; char *name=NULL; virStorageVolPtr volume=NULL; @@ -7864,8 +7866,8 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) char *tmp = NULL; char *xml; char *xpath = NULL; - int xpath_len; - long flags=0; + strsize_t xpath_len; + zend_long flags=0; int retval = -1; GET_VOLUME_FROM_ARGS("rs|l",&zvolume,&xpath,&xpath_len,&flags); @@ -7907,8 +7909,8 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml) zval *zpool; virStorageVolPtr volume=NULL; char *xml; - long flags = 0; - int xml_len; + zend_long flags = 0; + strsize_t xml_len; GET_STORAGEPOOL_FROM_ARGS("rs|l",&zpool,&xml,&xml_len, &flags); @@ -7992,7 +7994,7 @@ PHP_FUNCTION(libvirt_storagevolume_delete) { php_libvirt_volume *volume=NULL; zval *zvolume; - long flags = 0; + zend_long flags = 0; int retval = 0; GET_VOLUME_FROM_ARGS("r|l",&zvolume,&flags); @@ -8020,8 +8022,8 @@ PHP_FUNCTION(libvirt_storagevolume_resize) { php_libvirt_volume *volume=NULL; zval *zvolume; - long flags = 0; - long capacity = 0; + zend_long flags = 0; + zend_long capacity = 0; int retval = -1; GET_VOLUME_FROM_ARGS("rl|l", &zvolume, &capacity, &flags); @@ -8184,7 +8186,7 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_uuid_string) php_libvirt_connection *conn = NULL; zval *zconn; char *uuid = NULL; - int uuid_len; + strsize_t uuid_len; virStoragePoolPtr storage=NULL; php_libvirt_storagepool *res_pool; @@ -8226,8 +8228,8 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc) char *xml; char *xpath = NULL; char *tmp = NULL; - long flags = 0; - int xpath_len; + zend_long flags = 0; + strsize_t xpath_len; int retval = -1; GET_STORAGEPOOL_FROM_ARGS("r|s", &zpool, &xpath, &xpath_len, &flags); @@ -8270,8 +8272,8 @@ PHP_FUNCTION(libvirt_storagepool_define_xml) zval *zconn; virStoragePoolPtr pool = NULL; char *xml; - int xml_len; - long flags = 0; + strsize_t xml_len; + zend_long flags = 0; GET_CONNECTION_FROM_ARGS ("rs|l", &zconn, &xml, &xml_len, &flags); @@ -8407,7 +8409,7 @@ PHP_FUNCTION(libvirt_storagepool_refresh) { php_libvirt_storagepool *pool = NULL; zval *zpool; - long flags = 0; + zend_long flags = 0; int retval; GET_STORAGEPOOL_FROM_ARGS ("r|l", &zpool, &flags); @@ -8972,7 +8974,7 @@ PHP_FUNCTION(libvirt_list_networks) { php_libvirt_connection *conn=NULL; zval *zconn; - long flags = VIR_NETWORKS_ACTIVE | VIR_NETWORKS_INACTIVE; + zend_long flags = VIR_NETWORKS_ACTIVE | VIR_NETWORKS_INACTIVE; int count=-1; int expectedcount=-1; char **names; @@ -9044,7 +9046,8 @@ PHP_FUNCTION(libvirt_list_nodedevs) int expectedcount=-1; char *cap = NULL; char **names; - int i, cap_len; + int i; + strsize_t cap_len; GET_CONNECTION_FROM_ARGS("r|s",&zconn,&cap,&cap_len); @@ -9084,7 +9087,7 @@ PHP_FUNCTION(libvirt_nodedev_get) virNodeDevice *dev; zval *zconn; char *name; - int name_len; + strsize_t name_len; GET_CONNECTION_FROM_ARGS("rs",&zconn,&name,&name_len); @@ -9155,7 +9158,7 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) char *tmp = NULL; char *xml = NULL; char *xpath = NULL; - int xpath_len; + strsize_t xpath_len; int retval = -1; GET_NODEDEV_FROM_ARGS("r|s",&znodedev,&xpath,&xpath_len); @@ -9354,7 +9357,7 @@ PHP_FUNCTION(libvirt_network_define_xml) virNetwork *net; zval *zconn; char *xml = NULL; - int xml_len; + strsize_t xml_len; GET_CONNECTION_FROM_ARGS("rs",&zconn,&xml,&xml_len); @@ -9411,7 +9414,7 @@ PHP_FUNCTION(libvirt_network_get) virNetwork *net; zval *zconn; char *name; - int name_len; + strsize_t name_len; GET_CONNECTION_FROM_ARGS("rs",&zconn,&name,&name_len); @@ -9588,7 +9591,7 @@ PHP_FUNCTION(libvirt_network_set_active) { php_libvirt_network *network; zval *znetwork; - long act = 0; + zend_long act = 0; DPRINTF("%s: Setting network activity...\n", PHPFUNC); @@ -9637,7 +9640,7 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) char *xml = NULL; char *xpath = NULL; char *tmp; - int xpath_len; + strsize_t xpath_len; int retval = -1; GET_NETWORK_FROM_ARGS("r|s",&znetwork,&xpath,&xpath_len); -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 75 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index fe84f16..e497c10 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -59,6 +59,9 @@ const char *features_binaries[] = { NULL }; typedef size_t strsize_t; #define VIRT_COPY_OPT +#define VIRT_RETVAL_STRING(str) RETVAL_STRING(str) +#define VIRT_ZVAL_STRINGL(zv,str,len) ZVAL_STRINGL(zv,str,len) + #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ RETURN_FALSE; \ @@ -70,6 +73,8 @@ typedef long zend_long; typedef unsigned long zend_ulong; #define VIRT_COPY_OPT ,1 +#define VIRT_RETVAL_STRING(str) RETVAL_STRING(str, 1) +#define VIRT_ZVAL_STRINGL(zv,str,len) ZVAL_STRINGL(zv,str,len,1) #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); @@ -2093,7 +2098,7 @@ static int libvirt_virConnectCredType[] = { PHP_FUNCTION(libvirt_get_last_error) { if (LIBVIRT_G (last_error) == NULL) RETURN_NULL(); - RETURN_STRING(LIBVIRT_G (last_error) VIRT_COPY_OPT); + VIRT_RETVAL_STRING(LIBVIRT_G(last_error)); } /* @@ -2110,7 +2115,11 @@ PHP_FUNCTION(libvirt_connect) php_libvirt_connection *conn; php_libvirt_cred_value *creds=NULL; zval* zcreds=NULL; +#if PHP_MAJOR_VERSION >= 7 zval *data; +#else + zval **data; +#endif int i; int j; int credscount=0; @@ -2784,7 +2793,7 @@ PHP_FUNCTION(libvirt_connect_get_uri) DPRINTF("%s: virConnectGetURI returned %s\n", PHPFUNC, uri); if (uri == NULL) RETURN_FALSE; - RETVAL_STRING(uri VIRT_COPY_OPT); + VIRT_RETVAL_STRING(uri); free(uri); } @@ -2807,7 +2816,7 @@ PHP_FUNCTION(libvirt_connect_get_hostname) DPRINTF("%s: virConnectGetHostname returned %s\n", PHPFUNC, hostname); if (hostname==NULL) RETURN_FALSE; - RETVAL_STRING(hostname VIRT_COPY_OPT); + VIRT_RETVAL_STRING(hostname); free(hostname); } @@ -3124,7 +3133,7 @@ PHP_FUNCTION(libvirt_connect_get_sysinfo) sysinfo=virConnectGetSysinfo(conn->conn, 0); if (sysinfo==NULL) RETURN_FALSE; - RETVAL_STRING(sysinfo VIRT_COPY_OPT); + VIRT_RETVAL_STRING(sysinfo); free(sysinfo); } @@ -3408,7 +3417,11 @@ long get_next_free_numeric_value(virDomainPtr domain, char *xpath) HashTable *arr_hash; HashPosition pointer; // int array_count; +#if PHP_MAJOR_VERSION >= 7 zval *data; +#else + zval **data; +#endif unsigned long index; long max_slot = -1; @@ -4096,7 +4109,7 @@ PHP_FUNCTION(libvirt_domain_get_metadata) } } else { - RETVAL_STRING(ret VIRT_COPY_OPT); + VIRT_RETVAL_STRING(ret); free(ret); } } @@ -4249,7 +4262,7 @@ PHP_FUNCTION(libvirt_domain_qemu_agent_command) ret = virDomainQemuAgentCommand(domain->domain, cmd, timeout, flags); if (ret == NULL) RETURN_FALSE; - RETURN_STRING(ret VIRT_COPY_OPT); + VIRT_RETVAL_STRING(ret); } /* @@ -4446,7 +4459,7 @@ PHP_FUNCTION(libvirt_stream_recv) ZVAL_STRINGL(zbuf, recv_buf, retval); efree(recv_buf); #else - ZVAL_STRINGL(zbuf, recv_buf, retval, 0) + ZVAL_STRINGL(zbuf, recv_buf, retval, 0); #endif } @@ -4550,7 +4563,7 @@ PHP_FUNCTION(libvirt_domain_get_name) DPRINTF("%s: virDomainGetName(%p) returned %s\n", PHPFUNC, domain->domain, name); if (name==NULL) RETURN_FALSE; - RETURN_STRING(name VIRT_COPY_OPT); //we can use the copy mechanism as we need not to free name (we even can not!) + VIRT_RETVAL_STRING(name); //we can use the copy mechanism as we need not to free name (we even can not!) } /* @@ -4808,7 +4821,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) } /* This is necessary to make the output binary safe */ - ZVAL_STRINGL(return_value, buf, fsize VIRT_COPY_OPT); + VIRT_ZVAL_STRINGL(return_value, buf, fsize); efree(buf); free(tmp); @@ -5137,9 +5150,9 @@ PHP_FUNCTION(libvirt_connect_get_capabilities) tmp = get_string_from_xpath(caps, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RETVAL_STRING(caps VIRT_COPY_OPT); + VIRT_RETVAL_STRING(caps); } else { - RETVAL_STRING(tmp VIRT_COPY_OPT); + VIRT_RETVAL_STRING(tmp); } free(caps); @@ -5173,7 +5186,7 @@ PHP_FUNCTION(libvirt_connect_get_emulator) RETURN_FALSE; } - RETVAL_STRING(tmp VIRT_COPY_OPT); + VIRT_RETVAL_STRING(tmp); free(tmp); } @@ -5671,9 +5684,9 @@ PHP_FUNCTION(libvirt_domain_new) PHP_FUNCTION(libvirt_domain_new_get_vnc) { if (LIBVIRT_G(vnc_location)) - RETURN_STRING(LIBVIRT_G(vnc_location) VIRT_COPY_OPT); - - RETURN_NULL(); + VIRT_RETVAL_STRING(LIBVIRT_G(vnc_location)); + else + RETVAL_NULL(); } /* @@ -5709,9 +5722,9 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RETVAL_STRING(xml VIRT_COPY_OPT); + VIRT_RETVAL_STRING(xml); } else { - RETVAL_STRING(tmp VIRT_COPY_OPT); + VIRT_RETVAL_STRING(tmp); } free(tmp); @@ -7467,7 +7480,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml) xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags); if (xml==NULL) RETURN_FALSE; - RETVAL_STRING(xml VIRT_COPY_OPT); + VIRT_RETVAL_STRING(xml); free(xml); } @@ -7798,7 +7811,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_name) DPRINTF("%s: virStorageVolGetName(%p) returned %s\n", PHPFUNC, volume->volume, retval); if (retval == NULL) RETURN_FALSE; - RETURN_STRING(retval VIRT_COPY_OPT); + VIRT_RETVAL_STRING(retval); } /* @@ -7820,7 +7833,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_path) DPRINTF("%s: virStorageVolGetPath(%p) returned %s\n", PHPFUNC, volume->volume, retval); if (retval == NULL) RETURN_FALSE; - RETURN_STRING(retval VIRT_COPY_OPT); + VIRT_RETVAL_STRING(retval); } /* @@ -7884,9 +7897,9 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RETVAL_STRING(xml VIRT_COPY_OPT); + VIRT_RETVAL_STRING(xml); } else { - RETVAL_STRING(tmp VIRT_COPY_OPT); + VIRT_RETVAL_STRING(tmp); } free(xml); @@ -8170,7 +8183,7 @@ PHP_FUNCTION(libvirt_storagepool_get_name) if (name == NULL) RETURN_FALSE; - RETURN_STRING(name VIRT_COPY_OPT); + VIRT_RETVAL_STRING(name); } /* @@ -8247,9 +8260,9 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RETVAL_STRING(xml VIRT_COPY_OPT); + VIRT_RETVAL_STRING(xml); } else { - RETVAL_STRING(tmp VIRT_COPY_OPT); + VIRT_RETVAL_STRING(tmp); } free(xml); @@ -8997,7 +9010,7 @@ PHP_FUNCTION(libvirt_list_networks) for (i=0;i<count;i++) { - add_next_index_string(return_value, names[i]); + add_next_index_string(return_value, names[i] VIRT_COPY_OPT); free(names[i]); } @@ -9175,9 +9188,9 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RETVAL_STRING(xml VIRT_COPY_OPT); + VIRT_RETVAL_STRING(xml); } else { - RETVAL_STRING(tmp VIRT_COPY_OPT); + VIRT_RETVAL_STRING(tmp); } free(xml); @@ -9458,7 +9471,7 @@ PHP_FUNCTION(libvirt_network_get_bridge) RETURN_FALSE; } - RETURN_STRING(name VIRT_COPY_OPT); + VIRT_RETVAL_STRING(name); } /* @@ -9658,9 +9671,9 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp == NULL) || (retval < 0)) { - RETVAL_STRING(xml VIRT_COPY_OPT); + VIRT_RETVAL_STRING(xml); } else { - RETVAL_STRING(tmp VIRT_COPY_OPT); + VIRT_RETVAL_STRING(tmp); } free(xml); -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 2 +- src/tests/skipif.inc | 3 +++ src/tests/test-version-get.phpt | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/tests/skipif.inc create mode 100644 src/tests/test-version-get.phpt diff --git a/src/libvirt-php.c b/src/libvirt-php.c index e497c10..640187c 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -9713,7 +9713,7 @@ PHP_FUNCTION(libvirt_version) add_assoc_long(return_value, "libvirt.minor",(long)((libVer/1000) % 1000)); add_assoc_long(return_value, "libvirt.major",(long)((libVer/1000000) % 1000)); - add_assoc_string_ex(return_value, "connector.version", 18, PHP_LIBVIRT_WORLD_VERSION VIRT_COPY_OPT); + add_assoc_string(return_value, "connector.version", PHP_LIBVIRT_WORLD_VERSION VIRT_COPY_OPT); add_assoc_long(return_value, "connector.major", VERSION_MAJOR); add_assoc_long(return_value, "connector.minor", VERSION_MINOR); add_assoc_long(return_value, "connector.release", VERSION_MICRO); diff --git a/src/tests/skipif.inc b/src/tests/skipif.inc new file mode 100644 index 0000000..9f3159b --- /dev/null +++ b/src/tests/skipif.inc @@ -0,0 +1,3 @@ +<?php + if (!extension_loaded('libvirt')) die('skip libvirt extension not available'); +?> diff --git a/src/tests/test-version-get.phpt b/src/tests/test-version-get.phpt new file mode 100644 index 0000000..b0ab5a3 --- /dev/null +++ b/src/tests/test-version-get.phpt @@ -0,0 +1,27 @@ +--TEST-- +libvirt_version +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +var_dump(libvirt_version()); +?> +Done +--EXPECTF-- +array(7) { + ["libvirt.release"]=> + int(%d) + ["libvirt.minor"]=> + int(%d) + ["libvirt.major"]=> + int(%d) + ["connector.version"]=> + string(%d) "%s" + ["connector.major"]=> + int(%d) + ["connector.minor"]=> + int(%d) + ["connector.release"]=> + int(%d) +} +Done -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/tests/test-connect.phpt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/tests/test-connect.phpt diff --git a/src/tests/test-connect.phpt b/src/tests/test-connect.phpt new file mode 100644 index 0000000..2aab021 --- /dev/null +++ b/src/tests/test-connect.phpt @@ -0,0 +1,15 @@ +--TEST-- +libvirt_version +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + $conn = libvirt_connect('test:///default'); + var_dump($conn); + unset($conn); +?> +Done +--EXPECTF-- +resource(%d) of type (Libvirt connection) +Done + -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> PHP 5 => #define add_assoc_string(__arg, __key, __str, __duplicate) add_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate) PHP 7 => #define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str) --- src/libvirt-php.c | 136 +++++++++++++++++++++++++++--------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 640187c..09be51b 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2034,7 +2034,7 @@ if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\ #define LONGLONG_ASSOC(out,key,in) \ if (LIBVIRT_G(longlong_to_string_ini)) { \ snprintf(tmpnumber,63,"%llu",in); \ - add_assoc_string_ex(out,key,strlen(key)+1,tmpnumber VIRT_COPY_OPT); \ + add_assoc_string(out,key,tmpnumber VIRT_COPY_OPT); \ } \ else \ { \ @@ -2263,7 +2263,7 @@ PHP_FUNCTION(libvirt_node_get_info) if (retval==-1) RETURN_FALSE; array_init(return_value); - add_assoc_string_ex(return_value, "model", 6, info.model VIRT_COPY_OPT); + add_assoc_string(return_value, "model", info.model VIRT_COPY_OPT); add_assoc_long(return_value, "memory", (long)info.memory); add_assoc_long(return_value, "cpus", (long)info.cpus); add_assoc_long(return_value, "nodes", (long)info.nodes); @@ -2366,9 +2366,9 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) add_assoc_long(return_value, "cpu", cpunr); else if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) - add_assoc_string_ex(return_value, "cpu", 4, "all" VIRT_COPY_OPT); + add_assoc_string(return_value, "cpu", "all" VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "cpu", 4, "unknown" VIRT_COPY_OPT); + add_assoc_string(return_value, "cpu", "unknown" VIRT_COPY_OPT); free(params); params = NULL; @@ -2611,14 +2611,14 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) char tmp3[2048] = { 0 }; snprintf(key, sizeof(key), "%d", k); - //add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT); + //add_assoc_string(arr2, key, ret3[k] VIRT_COPY_OPT); snprintf(tmp3, sizeof(tmp3), "//capabilities/guest/arch[@name=\"%s\"]/machine[text()=\"%s\"]/@maxCpus", ret[i], ret3[k]); numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL); if (numTmp == NULL) - add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT); + add_assoc_string(arr2, key, ret3[k] VIRT_COPY_OPT); else { #if PHP_MAJOR_VERSION >= 7 zval *arr4, zarr4; @@ -2629,8 +2629,8 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) #endif array_init(arr4); - add_assoc_string_ex(arr4, "name", 5, ret3[k] VIRT_COPY_OPT); - add_assoc_string_ex(arr4, "maxCpus", 9, numTmp VIRT_COPY_OPT); + add_assoc_string(arr4, "name", ret3[k] VIRT_COPY_OPT); + add_assoc_string(arr4, "maxCpus", numTmp VIRT_COPY_OPT); add_assoc_zval_ex(arr2, key, strlen(key) + 1, arr4); free(numTmp); @@ -2658,7 +2658,7 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL); if (numTmp == NULL) - add_assoc_string_ex(arr3, key, strlen(key) + 1, ret3[k] VIRT_COPY_OPT); + add_assoc_string(arr3, key, ret3[k] VIRT_COPY_OPT); else { #if PHP_MAJOR_VERSION >= 7 zval *arr4, zarr4; @@ -2669,8 +2669,8 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) #endif array_init(arr4); - add_assoc_string_ex(arr4, "name", 5, ret3[k] VIRT_COPY_OPT); - add_assoc_string_ex(arr4, "maxCpus", 9, numTmp VIRT_COPY_OPT); + add_assoc_string(arr4, "name", ret3[k] VIRT_COPY_OPT); + add_assoc_string(arr4, "maxCpus", numTmp VIRT_COPY_OPT); add_assoc_zval_ex(arr3, key, strlen(key) + 1, arr4); free(numTmp); @@ -2713,21 +2713,21 @@ PHP_FUNCTION(libvirt_connect_get_information) tmp = virConnectGetURI(conn->conn); DPRINTF("%s: Got connection URI of %s...\n", PHPFUNC, tmp); array_init(return_value); - add_assoc_string_ex(return_value, "uri", 4, tmp ? tmp : "unknown" VIRT_COPY_OPT); + add_assoc_string(return_value, "uri", tmp ? tmp : "unknown" VIRT_COPY_OPT); free(tmp); tmp = virConnectGetHostname(conn->conn); - add_assoc_string_ex(return_value, "hostname", 9, tmp ? tmp : "unknown" VIRT_COPY_OPT); + add_assoc_string(return_value, "hostname", tmp ? tmp : "unknown" VIRT_COPY_OPT); free(tmp); if ((virConnectGetVersion(conn->conn, &hvVer) == 0) && (type = virConnectGetType(conn->conn))) { - add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type VIRT_COPY_OPT); + add_assoc_string(return_value, "hypervisor", (char *)type VIRT_COPY_OPT); add_assoc_long(return_value, "hypervisor_major",(long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "hypervisor_minor",(long)((hvVer/1000) % 1000)); add_assoc_long(return_value, "hypervisor_release",(long)(hvVer %1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); - add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr VIRT_COPY_OPT); + add_assoc_string(return_value, "hypervisor_string", hvStr VIRT_COPY_OPT); } if (strcmp(type, "QEMU") == 0) { @@ -2740,21 +2740,21 @@ PHP_FUNCTION(libvirt_connect_get_information) add_assoc_long(return_value, "hypervisor_maxvcpus", maxvcpus); iTmp = virConnectIsEncrypted(conn->conn); if (iTmp == 1) - add_assoc_string_ex(return_value, "encrypted", 10, "Yes" VIRT_COPY_OPT); + add_assoc_string(return_value, "encrypted", "Yes" VIRT_COPY_OPT); else if (iTmp == 0) - add_assoc_string_ex(return_value, "encrypted", 10, "No" VIRT_COPY_OPT); + add_assoc_string(return_value, "encrypted", "No" VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "encrypted", 10, "unknown" VIRT_COPY_OPT); + add_assoc_string(return_value, "encrypted", "unknown" VIRT_COPY_OPT); iTmp = virConnectIsSecure(conn->conn); if (iTmp == 1) - add_assoc_string_ex(return_value, "secure", 7, "Yes" VIRT_COPY_OPT); + add_assoc_string(return_value, "secure", "Yes" VIRT_COPY_OPT); else if (iTmp == 0) - add_assoc_string_ex(return_value, "secure", 7, "No" VIRT_COPY_OPT); + add_assoc_string(return_value, "secure", "No" VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "secure", 7, "unknown" VIRT_COPY_OPT); + add_assoc_string(return_value, "secure", "unknown" VIRT_COPY_OPT); add_assoc_long(return_value, "num_inactive_domains", virConnectNumOfDefinedDomains(conn->conn)); add_assoc_long(return_value, "num_inactive_interfaces", virConnectNumOfDefinedInterfaces(conn->conn)); @@ -2969,14 +2969,14 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor) DPRINTF("%s: virConnectGetType returned %s\n", PHPFUNC, type); array_init(return_value); - add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type VIRT_COPY_OPT); + add_assoc_string(return_value, "hypervisor", (char *)type VIRT_COPY_OPT); add_assoc_long(return_value, "major",(long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "minor",(long)((hvVer/1000) % 1000)); add_assoc_long(return_value, "release",(long)(hvVer %1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); - add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr VIRT_COPY_OPT); + add_assoc_string(return_value, "hypervisor_string", hvStr VIRT_COPY_OPT); } /* @@ -3076,7 +3076,7 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) add_assoc_bool(arr2, params.field, params.value.b); break; case VIR_TYPED_PARAM_STRING: - add_assoc_string_ex(arr2, params.field, strlen(params.field)+1, params.value.s VIRT_COPY_OPT); + add_assoc_string(arr2, params.field, params.value.s VIRT_COPY_OPT); break; } } @@ -3201,7 +3201,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int *retVal) value = (char *)xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); snprintf(key, sizeof(key), "%d", i); - add_assoc_string_ex(*val, key, strlen(key)+1, value VIRT_COPY_OPT); + add_assoc_string(*val, key, value VIRT_COPY_OPT); ret++; } } @@ -4689,12 +4689,12 @@ PHP_FUNCTION(libvirt_domain_get_screenshot_api) if (WEXITSTATUS(exitStatus) != 0) RETURN_FALSE; - add_assoc_string_ex(return_value, "file", 5, fileNew VIRT_COPY_OPT); - add_assoc_string_ex(return_value, "mime", 5, "image/png" VIRT_COPY_OPT); + add_assoc_string(return_value, "file", fileNew VIRT_COPY_OPT); + add_assoc_string(return_value, "mime", "image/png" VIRT_COPY_OPT); } else { - add_assoc_string_ex(return_value, "file", 5, file VIRT_COPY_OPT); - add_assoc_string_ex(return_value, "mime", 5, mime VIRT_COPY_OPT); + add_assoc_string(return_value, "file", file VIRT_COPY_OPT); + add_assoc_string(return_value, "mime", mime VIRT_COPY_OPT); } } @@ -5251,7 +5251,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models) tTokenizer t = tokenize(tmp, ","); for (i = 0; i < t.numTokens; i++) { snprintf(tmp2, sizeof(tmp2), "%d", i); - add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[i] VIRT_COPY_OPT); + add_assoc_string(return_value, tmp2, t.tokens[i] VIRT_COPY_OPT); } free_tokens(t); } @@ -5349,14 +5349,14 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) } array_init(arr); - add_assoc_string_ex(arr, "name", 5, t.tokens[0] VIRT_COPY_OPT); - add_assoc_string_ex(arr, "description", 12, desc VIRT_COPY_OPT); + add_assoc_string(arr, "name", t.tokens[0] VIRT_COPY_OPT); + add_assoc_string(arr, "description", desc VIRT_COPY_OPT); add_next_index_zval(return_value, arr); } else { char tmp2[16] = { 0 }; snprintf(tmp2, sizeof(tmp2), "%d", n++); - add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[0] VIRT_COPY_OPT); + add_assoc_string(return_value, tmp2, t.tokens[0] VIRT_COPY_OPT); } free_tokens(t); @@ -6945,8 +6945,8 @@ PHP_FUNCTION(libvirt_domain_get_network_info) } array_init(return_value); - add_assoc_string_ex(return_value, "mac", 4, mac VIRT_COPY_OPT); - add_assoc_string_ex(return_value, "network", 8, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "mac", mac VIRT_COPY_OPT); + add_assoc_string(return_value, "network", tmp VIRT_COPY_OPT); free(tmp); free(xpath); @@ -6957,9 +6957,9 @@ PHP_FUNCTION(libvirt_domain_get_network_info) } tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "nic_type", 9, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "nic_type", tmp VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "nic_type", 9, "default" VIRT_COPY_OPT); + add_assoc_string(return_value, "nic_type", "default" VIRT_COPY_OPT); free(xml); free(xpath); @@ -7044,12 +7044,12 @@ PHP_FUNCTION(libvirt_domain_get_block_info) array_init(return_value); LONGLONG_INIT; - add_assoc_string_ex(return_value, "device", 7, dev VIRT_COPY_OPT); + add_assoc_string(return_value, "device", dev VIRT_COPY_OPT); if (isFile) - add_assoc_string_ex(return_value, "file", 5, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "file", tmp VIRT_COPY_OPT); else - add_assoc_string_ex(return_value, "partition", 10, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "partition", tmp VIRT_COPY_OPT); free(xpath); if (asprintf(&xpath, "//domain/devices/disk/target[@dev='%s']/../driver/@type", dev) < 0) { @@ -7059,7 +7059,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info) free(tmp); tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if (tmp != NULL) - add_assoc_string_ex(return_value, "type", 5, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "type", tmp VIRT_COPY_OPT); LONGLONG_ASSOC(return_value, "capacity", info.capacity); LONGLONG_ASSOC(return_value, "allocation", info.allocation); @@ -7116,7 +7116,7 @@ PHP_FUNCTION(libvirt_domain_xml_xpath) if (rc == 0) RETURN_FALSE; - add_assoc_string_ex(return_value, "xpath", 6, (char *)zpath VIRT_COPY_OPT); + add_assoc_string(return_value, "xpath", (char *)zpath VIRT_COPY_OPT); if (rc < 0) add_assoc_long(return_value, "error_code", (long)rc); } @@ -9235,18 +9235,18 @@ PHP_FUNCTION(libvirt_nodedev_get_information) goto error; } - add_assoc_string_ex(return_value, "name", 5, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "name", tmp VIRT_COPY_OPT); /* Get parent name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/parent", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "parent", 7, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "parent", tmp VIRT_COPY_OPT); /* Get capability */ cap = get_string_from_xpath(xml, "//device/capability/@type", NULL, &retval); if ((cap != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "capability", 11, cap VIRT_COPY_OPT); + add_assoc_string(return_value, "capability", cap VIRT_COPY_OPT); /* System capability is having hardware and firmware sub-blocks */ if (strcmp(cap, "system") == 0) { @@ -9254,92 +9254,92 @@ PHP_FUNCTION(libvirt_nodedev_get_information) free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "hardware_vendor", 16, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "hardware_vendor", tmp VIRT_COPY_OPT); /* Get hardware version */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/version", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "hardware_version", 17, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "hardware_version", tmp VIRT_COPY_OPT); /* Get hardware serial */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/serial", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "hardware_serial", 16, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "hardware_serial", tmp VIRT_COPY_OPT); /* Get hardware UUID */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/uuid", NULL, &retval); if (tmp != NULL) - add_assoc_string_ex(return_value, "hardware_uuid", 15, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "hardware_uuid", tmp VIRT_COPY_OPT); /* Get firmware vendor */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "firmware_vendor", 16, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "firmware_vendor", tmp VIRT_COPY_OPT); /* Get firmware version */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/version", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "firmware_version", 17, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "firmware_version", tmp VIRT_COPY_OPT); /* Get firmware release date */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/release_date", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "firmware_release_date", 22, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "firmware_release_date", tmp VIRT_COPY_OPT); } /* Get product_id */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/product/@id", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "product_id", 11, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "product_id", tmp VIRT_COPY_OPT); /* Get product_name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/product", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "product_name", 13, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "product_name", tmp VIRT_COPY_OPT); /* Get vendor_id */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/vendor/@id", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "vendor_id", 10, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "vendor_id", tmp VIRT_COPY_OPT); /* Get vendor_name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "vendor_name", 12, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "vendor_name", tmp VIRT_COPY_OPT); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/driver/name", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "driver_name", 12, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "driver_name", tmp VIRT_COPY_OPT); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/interface", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "interface_name", 15, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "interface_name", tmp VIRT_COPY_OPT); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/address", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "address", 8, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "address", tmp VIRT_COPY_OPT); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/capability/@type", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string_ex(return_value, "capabilities", 11, tmp VIRT_COPY_OPT); + add_assoc_string(return_value, "capabilities", tmp VIRT_COPY_OPT); free(cap); free(tmp); @@ -9544,42 +9544,42 @@ PHP_FUNCTION(libvirt_network_get_information) RETURN_FALSE; } - add_assoc_string_ex(return_value, "name", 5, name VIRT_COPY_OPT); + add_assoc_string(return_value, "name", name VIRT_COPY_OPT); /* Get gateway IP address */ ipaddr = get_string_from_xpath(xml, "//network/ip/@address", NULL, &retval); if (ipaddr && retval > 0) - add_assoc_string_ex(return_value, "ip", 3, ipaddr VIRT_COPY_OPT); + add_assoc_string(return_value, "ip", ipaddr VIRT_COPY_OPT); /* Get netmask */ netmask = get_string_from_xpath(xml, "//network/ip/@netmask", NULL, &retval); if (netmask && retval > 0) { int subnet_bits = get_subnet_bits(netmask); - add_assoc_string_ex(return_value, "netmask", 8, netmask VIRT_COPY_OPT); + add_assoc_string(return_value, "netmask", netmask VIRT_COPY_OPT); add_assoc_long(return_value, "netmask_bits", (long) subnet_bits); /* Format CIDR address representation */ ipaddr[strlen(ipaddr) - 1] = ipaddr[strlen(ipaddr) - 1] - 1; snprintf(fixedtemp, sizeof(fixedtemp), "%s/%d", ipaddr, subnet_bits); - add_assoc_string_ex(return_value, "ip_range", 9, fixedtemp VIRT_COPY_OPT); + add_assoc_string(return_value, "ip_range", fixedtemp VIRT_COPY_OPT); } /* Get forwarding settings */ mode = get_string_from_xpath(xml, "//network/forward/@mode", NULL, &retval); if (mode && retval > 0) - add_assoc_string_ex(return_value, "forwarding", 11, mode VIRT_COPY_OPT); + add_assoc_string(return_value, "forwarding", mode VIRT_COPY_OPT); /* Get forwarding settings */ dev = get_string_from_xpath(xml, "//network/forward/@dev", NULL, &retval); if (dev && retval > 0) - add_assoc_string_ex(return_value, "forward_dev", 12, dev VIRT_COPY_OPT); + add_assoc_string(return_value, "forward_dev", dev VIRT_COPY_OPT); /* Get DHCP values */ dhcp_start = get_string_from_xpath(xml, "//network/ip/dhcp/range/@start", NULL, &retval); dhcp_end = get_string_from_xpath(xml, "//network/ip/dhcp/range/@end", NULL, &retval); if (dhcp_start && dhcp_end && retval > 0) { - add_assoc_string_ex(return_value, "dhcp_start", 11, dhcp_start VIRT_COPY_OPT); - add_assoc_string_ex(return_value, "dhcp_end", 9, dhcp_end VIRT_COPY_OPT); + add_assoc_string(return_value, "dhcp_start", dhcp_start VIRT_COPY_OPT); + add_assoc_string(return_value, "dhcp_end", dhcp_end VIRT_COPY_OPT); } free(dhcp_end); -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> - %p doesn't work with PHP snprintf - store max_connections_ini as long instead of string - store mem as pointer instead of integer - convert test-conn-limit to phpt --- src/libvirt-php.c | 33 ++++++++++++--------------------- src/libvirt-php.h | 4 ++-- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 09be51b..ef8bb13 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -682,7 +682,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("libvirt.longlong_to_string", "1", PHP_INI_ALL, OnUpdateBool, longlong_to_string_ini, zend_libvirt_globals, libvirt_globals) STD_PHP_INI_ENTRY("libvirt.iso_path", "/var/lib/libvirt/images/iso", PHP_INI_ALL, OnUpdateString, iso_path_ini, zend_libvirt_globals, libvirt_globals) STD_PHP_INI_ENTRY("libvirt.image_path", "/var/lib/libvirt/images", PHP_INI_ALL, OnUpdateString, image_path_ini, zend_libvirt_globals, libvirt_globals) -STD_PHP_INI_ENTRY("libvirt.max_connections", "5", PHP_INI_ALL, OnUpdateString, max_connections_ini, zend_libvirt_globals, libvirt_globals) +STD_PHP_INI_ENTRY("libvirt.max_connections", "5", PHP_INI_ALL, OnUpdateLong, max_connections_ini, zend_libvirt_globals, libvirt_globals) PHP_INI_END() void change_debug(int val TSRMLS_DC) @@ -697,7 +697,7 @@ static void php_libvirt_init_globals(zend_libvirt_globals *libvirt_globals TSRML libvirt_globals->longlong_to_string_ini = 1; libvirt_globals->iso_path_ini = "/var/lib/libvirt/images/iso"; libvirt_globals->image_path_ini = "/var/lib/libvirt/images"; - libvirt_globals->max_connections_ini = "5"; + libvirt_globals->max_connections_ini = 5; libvirt_globals->binding_resources_count = 0; libvirt_globals->binding_resources = NULL; #ifdef DEBUG_SUPPORT @@ -877,18 +877,13 @@ void free_tokens(tTokenizer t) * @inc [int/bool]: Increment the counter (1 = add memory location) or decrement the counter (0 = remove memory location) from entries. * Returns: 0 on success, -errno otherwise */ -int resource_change_counter(int type, virConnectPtr conn, void *memp, int inc TSRMLS_DC) +int resource_change_counter(int type, virConnectPtr conn, void *mem, int inc TSRMLS_DC) { int i; int pos = -1; int binding_resources_count; - char tmp[64] = { 0 }; - arch_uint mem = 0; resource_info *binding_resources = NULL; - snprintf(tmp, sizeof(tmp), "%p", memp); - sscanf(tmp, "%"UINTx, &mem); - binding_resources_count = LIBVIRT_G(binding_resources_count); binding_resources = LIBVIRT_G(binding_resources); @@ -1011,7 +1006,8 @@ PHP_MINFO_FUNCTION(libvirt) php_info_print_table_row(2, "Libvirt version", version); } - php_info_print_table_row(2, "Max. connections", LIBVIRT_G(max_connections_ini)); + snprintf(path, sizeof(path), "%lu", (unsigned long)LIBVIRT_G(max_connections_ini)); + php_info_print_table_row(2, "Max. connections", path); if (!access(LIBVIRT_G(iso_path_ini), F_OK) == 0) snprintf(path, sizeof(path), "%s - path is invalid. To set the valid path modify the libvirt.iso_path in your php.ini configuration!", @@ -1254,16 +1250,11 @@ void free_resources_on_connection(virConnectPtr conn TSRMLS_DC) * @memp [pointer]: pointer to the memory * Returns: 1 if resource is allocated, 0 otherwise */ -int check_resource_allocation(virConnectPtr conn, int type, void *memp TSRMLS_DC) +int check_resource_allocation(virConnectPtr conn, int type, void *mem TSRMLS_DC) { int binding_resources_count = 0; resource_info *binding_resources = NULL; int i, allocated = 0; - char tmp[64] = { 0 }; - arch_uint mem = 0; - - snprintf(tmp, sizeof(tmp), "%p", memp); - sscanf(tmp, "%"UINTx, &mem); binding_resources_count = LIBVIRT_G(binding_resources_count); binding_resources = LIBVIRT_G(binding_resources); @@ -2151,8 +2142,8 @@ PHP_FUNCTION(libvirt_connect) RETURN_FALSE; } - if ((count_resources(INT_RESOURCE_CONNECTION TSRMLS_CC) + 1) > atoi(LIBVIRT_G(max_connections_ini))) { - DPRINTF("%s: maximum number of connections allowed exceeded (max %s)\n",PHPFUNC, LIBVIRT_G(max_connections_ini)); + if ((count_resources(INT_RESOURCE_CONNECTION TSRMLS_CC) + 1) > LIBVIRT_G(max_connections_ini)) { + DPRINTF("%s: maximum number of connections allowed exceeded (max %lu)\n",PHPFUNC, (unsigned long)LIBVIRT_G(max_connections_ini)); set_error("Maximum number of connections allowed exceeded" TSRMLS_CC); RETURN_FALSE; } @@ -9873,11 +9864,11 @@ PHP_FUNCTION(libvirt_print_binding_resources) for (i = 0; i < binding_resources_count; i++) { if (binding_resources[i].overwrite == 0) { if (binding_resources[i].conn != NULL) - snprintf(tmp, sizeof(tmp), "Libvirt %s resource at 0x%"UINTx" (connection %p)", translate_counter_type(binding_resources[i].type), - binding_resources[i].mem, binding_resources[i].conn); + snprintf(tmp, sizeof(tmp), "Libvirt %s resource at 0x%lx (connection %lx)", translate_counter_type(binding_resources[i].type), + (long)binding_resources[i].mem, (long)binding_resources[i].conn); else - snprintf(tmp, sizeof(tmp), "Libvirt %s resource at 0x%"UINTx, translate_counter_type(binding_resources[i].type), - binding_resources[i].mem); + snprintf(tmp, sizeof(tmp), "Libvirt %s resource at 0x%lx", translate_counter_type(binding_resources[i].type), + (long)binding_resources[i].mem); add_next_index_string(return_value, tmp VIRT_COPY_OPT); } } diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 1562b32..105be20 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -166,7 +166,7 @@ typedef struct tTokenizer { typedef struct _resource_info { int type; virConnectPtr conn; - arch_uint mem; + void *mem; int overwrite; } resource_info; @@ -176,7 +176,7 @@ ZEND_BEGIN_MODULE_GLOBALS(libvirt) zend_bool longlong_to_string_ini; char *iso_path_ini; char *image_path_ini; - char *max_connections_ini; + zend_long max_connections_ini; #ifdef DEBUG_SUPPORT int debug; #endif -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/tests/test-conn-limit.phpt | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/tests/test-conn-limit.phpt diff --git a/src/tests/test-conn-limit.phpt b/src/tests/test-conn-limit.phpt new file mode 100644 index 0000000..23f8e98 --- /dev/null +++ b/src/tests/test-conn-limit.phpt @@ -0,0 +1,49 @@ +--TEST-- +libvirt_version +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--INI-- +libvirt.max_connections=3 +--FILE-- +<?php + + $num_ini = ini_get("libvirt.max_connections"); + var_dump($num_ini); + + $num = $num_ini + 1; + + for ($i = 0; $i < $num; $i++) + $conn[] = libvirt_connect('test:///default', false); + var_dump($conn); + + $tmp = libvirt_print_binding_resources(); + var_dump($tmp); + + for ($i = 0; $i < $num; $i++) + unset($conn[$i]); +?> +Done +--EXPECTF-- +string(1) "3" + +%s Maximum number of connections allowed exceeded %s +array(4) { + [0]=> + resource(%d) of type (Libvirt connection) + [1]=> + resource(%d) of type (Libvirt connection) + [2]=> + resource(%d) of type (Libvirt connection) + [3]=> + bool(false) +} +array(3) { + [0]=> + string(%d) "Libvirt connection resource at %s" + [1]=> + string(%d) "Libvirt connection resource at %s" + [2]=> + string(%d) "Libvirt connection resource at %s" +} +Done + -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/tests/test-conn-limit.phpt | 2 +- src/tests/test-connect-get-emulator.phpt | 15 +++++++++++++++ src/tests/test-connect.phpt | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/tests/test-connect-get-emulator.phpt diff --git a/src/tests/test-conn-limit.phpt b/src/tests/test-conn-limit.phpt index 23f8e98..8fa0fc4 100644 --- a/src/tests/test-conn-limit.phpt +++ b/src/tests/test-conn-limit.phpt @@ -1,5 +1,5 @@ --TEST-- -libvirt_version +INI: libvirt.max_connections --SKIPIF-- <?php require_once('skipif.inc'); ?> --INI-- diff --git a/src/tests/test-connect-get-emulator.phpt b/src/tests/test-connect-get-emulator.phpt new file mode 100644 index 0000000..7d8e8ce --- /dev/null +++ b/src/tests/test-connect-get-emulator.phpt @@ -0,0 +1,15 @@ +--TEST-- +libvirt_connect_get_emulator +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + $conn = libvirt_connect('test:///default'); + var_dump(libvirt_connect_get_emulator($conn)); + unset($conn); +?> +Done +--EXPECTF-- +string(%d) "%s" +Done + diff --git a/src/tests/test-connect.phpt b/src/tests/test-connect.phpt index 2aab021..f0cfce9 100644 --- a/src/tests/test-connect.phpt +++ b/src/tests/test-connect.phpt @@ -1,5 +1,5 @@ --TEST-- -libvirt_version +libvirt_connect --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index ef8bb13..e1a9cef 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1128,11 +1128,11 @@ static void catch_error(void *userData, * @mem [uint]: memory location of the resource to be freed * Returns: None */ -void free_resource(int type, arch_uint mem TSRMLS_DC) +void free_resource(int type, void *mem TSRMLS_DC) { int rv; - DPRINTF("%s: Freeing libvirt %s resource at 0x%"UINTx"\n", __FUNCTION__, translate_counter_type(type), mem); + DPRINTF("%s: Freeing libvirt %s resource at 0x%lx\n", __FUNCTION__, translate_counter_type(type), (unsigned long)mem); if (type == INT_RESOURCE_DOMAIN) { rv = virDomainFree( (virDomainPtr)mem ); @@ -1269,8 +1269,8 @@ int check_resource_allocation(virConnectPtr conn, int type, void *mem TSRMLS_DC) allocated = 1; } - DPRINTF("%s: libvirt %s resource 0x%"UINTx" (conn %p) is%s allocated\n", __FUNCTION__, translate_counter_type(type), - mem, conn, !allocated ? " not" : ""); + DPRINTF("%s: libvirt %s resource 0x%lx (conn %p) is%s allocated\n", __FUNCTION__, translate_counter_type(type), + (unsigned long)mem, conn, !allocated ? " not" : ""); return allocated; } @@ -5396,12 +5396,13 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network) else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(ZSTR_VAL(key), "dev") == 0) disk->dev = strdup( Z_STRVAL_P(data) ); else if (strcmp(ZSTR_VAL(key), "size") == 0) { - if (Z_TYPE_P(data) == IS_LONG) + if (Z_TYPE_P(data) == IS_LONG) { disk->size = Z_LVAL_P(data); - else + } else { disk->size = size_def_to_mbytes(Z_STRVAL_P(data)); + } } - else if ((Z_TYPE_P(data) == IS_LONG) && strcmp(ZSTR_VAL(key), "dev") == 0) + else if ((Z_TYPE_P(data) == IS_LONG) && strcmp(ZSTR_VAL(key), "flags") == 0) disk->flags = Z_LVAL_P(data); } else { if (network != NULL) { -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/tests/test-install.phpt | 136 +++++++++++++++++++++++++++++++++++++++++ src/tests/test-libvirt-php.img | 0 2 files changed, 136 insertions(+) create mode 100644 src/tests/test-install.phpt create mode 100644 src/tests/test-libvirt-php.img diff --git a/src/tests/test-install.phpt b/src/tests/test-install.phpt new file mode 100644 index 0000000..eac0875 --- /dev/null +++ b/src/tests/test-install.phpt @@ -0,0 +1,136 @@ +--TEST-- +libvirt_domain_new +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + $logfile = __DIR__ . '/test-install.log'; + @unlink($logfile); + libvirt_logfile_set($logfile, 10); + + $name = 'test'; + $image = __DIR__.'/test-libvirt-php.img'; + $disk_image = '/tmp/test-libvirt-php.img'; + $local_test = true; + $show_vnc_location = false; + $memory = 64; + + echo "# libvirt_connect\n"; + $conn = libvirt_connect('test:///default', false); /* Enable read-write connection */ + var_dump($conn); + + //cleaning + if ($res = libvirt_domain_lookup_by_name($conn, "test")) { + libvirt_domain_destroy($res); + libvirt_domain_undefine($res); + } + + $disks = array( + array( 'path' => $disk_image, 'driver' => 'raw', 'bus' => 'ide', 'dev' => 'hda', 'size' => '1M', + 'flags' => VIR_DOMAIN_DISK_FILE | VIR_DOMAIN_DISK_ACCESS_ALL ) + ); + + $networks = array( + array( 'mac' => '00:11:22:33:44:55', 'network' => 'default', 'model' => 'e1000') + ); + + $networks = array(); + + $flags = VIR_DOMAIN_FLAG_FEATURE_ACPI | VIR_DOMAIN_FLAG_FEATURE_APIC | VIR_DOMAIN_FLAG_FEATURE_PAE; + + if ($local_test) + $flags |= VIR_DOMAIN_FLAG_TEST_LOCAL_VNC; + + echo "# libvirt_domain_new\n"; + $res = libvirt_domain_new($conn, $name, false, $memory, $memory, 1, $image, $disks, $networks, $flags); + var_dump($res); + if ($res == false) + echo 'Installation test failed with error: '.libvirt_get_last_error().'. More info saved into '.$logfile; + + echo "# libvirt_domain_get_name\n"; + var_dump(libvirt_domain_get_name($res)); + + echo "# libvirt_domain_get_id\n"; + var_dump(libvirt_domain_get_id($res)); + + echo "# libvirt_domain_get_uuid\n"; + var_dump(bin2hex(libvirt_domain_get_uuid($res))); + + echo "# libvirt_domain_get_uuid_string\n"; + var_dump(libvirt_domain_get_uuid_string($res)); + + echo "# libvirt_domain_get_info\n"; + var_dump(libvirt_domain_get_info($res)); + + $ok = is_resource($res); + + echo "# libvirt_domain_new_get_vnc\n"; + $vncloc = libvirt_domain_new_get_vnc(); + var_dump($vncloc); + + echo "libvirt_domain_destroy\n"; + var_dump($ret = libvirt_domain_destroy($res)); + if (!$ret) + echo 'Domain destroy failed with error: '.libvirt_get_last_error().'. More info saved into '.$logfile; + + unset($res); + + echo "# libvirt_domain_lookup_by_name\n"; + $res = libvirt_domain_lookup_by_name($conn, $name); + var_dump($res); + if (is_resource($res)) { + echo "# libvirt_domain_undefine\n"; + var_dump(libvirt_domain_undefine($res)); + } + unset($res); + + echo "# libvirt_domain_lookup_by_name\n"; + $res = libvirt_domain_lookup_by_name($conn, $name); + var_dump($res); + + unset($res); + unset($conn); + + @unlink($disk_image); + @unlink($logfile); +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_new +resource(%d) of type (Libvirt domain) +# libvirt_domain_get_name +string(12) "test-install" +# libvirt_domain_get_id +int(%d) +# libvirt_domain_get_uuid +string(%d) "%s" +# libvirt_domain_get_uuid_string +string(%d) "%s" +# libvirt_domain_get_info +array(5) { + ["maxMem"]=> + int(65536) + ["memory"]=> + int(65536) + ["state"]=> + int(1) + ["nrVirtCpu"]=> + int(1) + ["cpuUsed"]=> + float(%s) +} +# libvirt_domain_new_get_vnc +string(%d) "%s" +libvirt_domain_destroy +bool(true) +# libvirt_domain_lookup_by_name +resource(%d) of type (Libvirt domain) +# libvirt_domain_undefine +bool(true) +# libvirt_domain_lookup_by_name + +%s Domain not found %s +bool(false) +Done diff --git a/src/tests/test-libvirt-php.img b/src/tests/test-libvirt-php.img new file mode 100644 index 0000000..e69de29 -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/tests/example-no-disk-and-media.xml | 41 +++++++++++++++++++++ src/tests/test-domain-create-and-coredump.phpt | 49 ++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/tests/example-no-disk-and-media.xml create mode 100644 src/tests/test-domain-create-and-coredump.phpt diff --git a/src/tests/example-no-disk-and-media.xml b/src/tests/example-no-disk-and-media.xml new file mode 100644 index 0000000..a691ff4 --- /dev/null +++ b/src/tests/example-no-disk-and-media.xml @@ -0,0 +1,41 @@ +<domain type='test'> + <name>test-guest-no-disk-and-media</name> + <uuid>28a15e00-9c40-ddc1-b6df-9a08921b93f0</uuid> + <memory>65535</memory> + <currentMemory>65535</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686'>hvm</type> + <boot dev='cdrom'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + </controller> + <serial type='pty'> + <target port='0'/> + </serial> + <console type='pty'> + <target type='serial' port='0'/> + </console> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes'/> + <video> + <model type='cirrus' vram='9216' heads='1'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + </devices> +</domain> + diff --git a/src/tests/test-domain-create-and-coredump.phpt b/src/tests/test-domain-create-and-coredump.phpt new file mode 100644 index 0000000..790da97 --- /dev/null +++ b/src/tests/test-domain-create-and-coredump.phpt @@ -0,0 +1,49 @@ +--TEST-- +libvirt_domain_core_dump +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + echo "# libvirt_connect\n"; + var_dump($conn = libvirt_connect('test:///default', false)); + if (!is_resource($conn)) + die('Connection to default hypervisor failed'); + + $xml = file_get_contents(__DIR__.'/example-no-disk-and-media.xml'); + + echo "# libvirt_domain_create_xml\n"; + var_dump($res = libvirt_domain_create_xml($conn, $xml)); + if (!is_resource($res)) + die('Domain definition failed with error: '.libvirt_get_last_error()); + + $name = tempnam(sys_get_temp_dir(), 'guestdumptest'); + echo "# libvirt_domain_core_dump\n"; + var_dump($ret = libvirt_domain_core_dump($res, $name)); + if (!$ret) + die('Cannot dump core of the guest: '.libvirt_get_last_error()); + var_dump(file_exists($name)); + + echo "# libvirt_domain_destroy\n"; + var_dump($ret = libvirt_domain_destroy($res)); + if (!$ret) { + unlink($name); + die('Domain destroy failed with error: '.libvirt_get_last_error()); + } + + unset($res); + unset($conn); + unlink($name); +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_create_xml +resource(%d) of type (Libvirt domain) +# libvirt_domain_core_dump +bool(true) +bool(true) +# libvirt_domain_destroy +bool(true) +Done + -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/tests/test-domain-create-and-get-xpath.phpt | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/tests/test-domain-create-and-get-xpath.phpt diff --git a/src/tests/test-domain-create-and-get-xpath.phpt b/src/tests/test-domain-create-and-get-xpath.phpt new file mode 100644 index 0000000..84e8895 --- /dev/null +++ b/src/tests/test-domain-create-and-get-xpath.phpt @@ -0,0 +1,56 @@ +--TEST-- +libvirt_domain_xml_xpath +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + echo "# libvirt_connect\n"; + var_dump($conn = libvirt_connect('test:///default', false)); + if (!is_resource($conn)) + die('Connection to default hypervisor failed'); + + $xml = file_get_contents(__DIR__.'/example-no-disk-and-media.xml'); + + echo "# libvirt_domain_create_xml\n"; + var_dump($res = libvirt_domain_create_xml($conn, $xml)); + if (!is_resource($res)) + die('Domain definition failed with error: '.libvirt_get_last_error()); + + $info = libvirt_domain_xml_xpath($res, '/domain/name'); + if (!$info) + die('Cannot get domain XML and/or xPath expression'); + var_dump($info); + + if (!array_key_exists('num', $info)) + die('Num element is missing in the output array'); + + for ($i = 0; $i < $info['num']; $i++) + if (!array_key_exists($i, $info)) + die("Element $i doesn\'t exist in the output array"); + + echo "# libvirt_domain_destroy\n"; + var_dump($ret = libvirt_domain_destroy($res)); + if (!$ret) { + die('Domain destroy failed with error: '.libvirt_get_last_error()); + } + unset($res); + unset($conn); +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_create_xml +resource(%d) of type (Libvirt domain) +array(3) { + [0]=> + string(28) "test-guest-no-disk-and-media" + ["num"]=> + int(1) + ["xpath"]=> + string(12) "/domain/name" +} +# libvirt_domain_destroy +bool(true) +Done + -- 2.5.5

From: Remi Collet <fedora@famillecollet.com> --- src/libvirt-php.c | 163 +++++++++++++++++++++++------------------------------- src/libvirt-php.h | 26 +++++++++ 2 files changed, 95 insertions(+), 94 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index e1a9cef..4fa24d6 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -55,31 +55,6 @@ const char *features[] = { NULL }; const char *features_binaries[] = { NULL }; #endif -#if PHP_MAJOR_VERSION >= 7 -typedef size_t strsize_t; - -#define VIRT_COPY_OPT -#define VIRT_RETVAL_STRING(str) RETVAL_STRING(str) -#define VIRT_ZVAL_STRINGL(zv,str,len) ZVAL_STRINGL(zv,str,len) - -#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ - if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ - RETURN_FALSE; \ - } - -#else -typedef int strsize_t; -typedef long zend_long; -typedef unsigned long zend_ulong; - -#define VIRT_COPY_OPT ,1 -#define VIRT_RETVAL_STRING(str) RETVAL_STRING(str, 1) -#define VIRT_ZVAL_STRINGL(zv,str,len) ZVAL_STRINGL(zv,str,len,1) - -#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ - ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); - -#endif /* ZEND thread safe per request globals definition */ int le_libvirt_connection; int le_libvirt_domain; @@ -2025,7 +2000,7 @@ if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\ #define LONGLONG_ASSOC(out,key,in) \ if (LIBVIRT_G(longlong_to_string_ini)) { \ snprintf(tmpnumber,63,"%llu",in); \ - add_assoc_string(out,key,tmpnumber VIRT_COPY_OPT); \ + VIRT_ADD_ASSOC_STRING(out,key,tmpnumber); \ } \ else \ { \ @@ -2254,7 +2229,7 @@ PHP_FUNCTION(libvirt_node_get_info) if (retval==-1) RETURN_FALSE; array_init(return_value); - add_assoc_string(return_value, "model", info.model VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "model", info.model); add_assoc_long(return_value, "memory", (long)info.memory); add_assoc_long(return_value, "cpus", (long)info.cpus); add_assoc_long(return_value, "nodes", (long)info.nodes); @@ -2357,9 +2332,9 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) add_assoc_long(return_value, "cpu", cpunr); else if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) - add_assoc_string(return_value, "cpu", "all" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "cpu", "all"); else - add_assoc_string(return_value, "cpu", "unknown" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "cpu", "unknown"); free(params); params = NULL; @@ -2602,14 +2577,14 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) char tmp3[2048] = { 0 }; snprintf(key, sizeof(key), "%d", k); - //add_assoc_string(arr2, key, ret3[k] VIRT_COPY_OPT); + //VIRT_ADD_ASSOC_STRING(arr2, key, ret3[k]); snprintf(tmp3, sizeof(tmp3), "//capabilities/guest/arch[@name=\"%s\"]/machine[text()=\"%s\"]/@maxCpus", ret[i], ret3[k]); numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL); if (numTmp == NULL) - add_assoc_string(arr2, key, ret3[k] VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(arr2, key, ret3[k]); else { #if PHP_MAJOR_VERSION >= 7 zval *arr4, zarr4; @@ -2620,8 +2595,8 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) #endif array_init(arr4); - add_assoc_string(arr4, "name", ret3[k] VIRT_COPY_OPT); - add_assoc_string(arr4, "maxCpus", numTmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(arr4, "name", ret3[k]); + VIRT_ADD_ASSOC_STRING(arr4, "maxCpus", numTmp); add_assoc_zval_ex(arr2, key, strlen(key) + 1, arr4); free(numTmp); @@ -2649,7 +2624,7 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL); if (numTmp == NULL) - add_assoc_string(arr3, key, ret3[k] VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(arr3, key, ret3[k]); else { #if PHP_MAJOR_VERSION >= 7 zval *arr4, zarr4; @@ -2660,8 +2635,8 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) #endif array_init(arr4); - add_assoc_string(arr4, "name", ret3[k] VIRT_COPY_OPT); - add_assoc_string(arr4, "maxCpus", numTmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(arr4, "name", ret3[k]); + VIRT_ADD_ASSOC_STRING(arr4, "maxCpus", numTmp); add_assoc_zval_ex(arr3, key, strlen(key) + 1, arr4); free(numTmp); @@ -2704,21 +2679,21 @@ PHP_FUNCTION(libvirt_connect_get_information) tmp = virConnectGetURI(conn->conn); DPRINTF("%s: Got connection URI of %s...\n", PHPFUNC, tmp); array_init(return_value); - add_assoc_string(return_value, "uri", tmp ? tmp : "unknown" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "uri", tmp ? tmp : "unknown"); free(tmp); tmp = virConnectGetHostname(conn->conn); - add_assoc_string(return_value, "hostname", tmp ? tmp : "unknown" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hostname", tmp ? tmp : "unknown"); free(tmp); if ((virConnectGetVersion(conn->conn, &hvVer) == 0) && (type = virConnectGetType(conn->conn))) { - add_assoc_string(return_value, "hypervisor", (char *)type VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hypervisor", (char *)type); add_assoc_long(return_value, "hypervisor_major",(long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "hypervisor_minor",(long)((hvVer/1000) % 1000)); add_assoc_long(return_value, "hypervisor_release",(long)(hvVer %1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); - add_assoc_string(return_value, "hypervisor_string", hvStr VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hypervisor_string", hvStr); } if (strcmp(type, "QEMU") == 0) { @@ -2731,21 +2706,21 @@ PHP_FUNCTION(libvirt_connect_get_information) add_assoc_long(return_value, "hypervisor_maxvcpus", maxvcpus); iTmp = virConnectIsEncrypted(conn->conn); if (iTmp == 1) - add_assoc_string(return_value, "encrypted", "Yes" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "encrypted", "Yes"); else if (iTmp == 0) - add_assoc_string(return_value, "encrypted", "No" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "encrypted", "No"); else - add_assoc_string(return_value, "encrypted", "unknown" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "encrypted", "unknown"); iTmp = virConnectIsSecure(conn->conn); if (iTmp == 1) - add_assoc_string(return_value, "secure", "Yes" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "secure", "Yes"); else if (iTmp == 0) - add_assoc_string(return_value, "secure", "No" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "secure", "No"); else - add_assoc_string(return_value, "secure", "unknown" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "secure", "unknown"); add_assoc_long(return_value, "num_inactive_domains", virConnectNumOfDefinedDomains(conn->conn)); add_assoc_long(return_value, "num_inactive_interfaces", virConnectNumOfDefinedInterfaces(conn->conn)); @@ -2960,14 +2935,14 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor) DPRINTF("%s: virConnectGetType returned %s\n", PHPFUNC, type); array_init(return_value); - add_assoc_string(return_value, "hypervisor", (char *)type VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hypervisor", (char *)type); add_assoc_long(return_value, "major",(long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "minor",(long)((hvVer/1000) % 1000)); add_assoc_long(return_value, "release",(long)(hvVer %1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); - add_assoc_string(return_value, "hypervisor_string", hvStr VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hypervisor_string", hvStr); } /* @@ -3067,7 +3042,7 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) add_assoc_bool(arr2, params.field, params.value.b); break; case VIR_TYPED_PARAM_STRING: - add_assoc_string(arr2, params.field, params.value.s VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(arr2, params.field, params.value.s); break; } } @@ -3192,7 +3167,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int *retVal) value = (char *)xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1); snprintf(key, sizeof(key), "%d", i); - add_assoc_string(*val, key, value VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(*val, key, value); ret++; } } @@ -4680,12 +4655,12 @@ PHP_FUNCTION(libvirt_domain_get_screenshot_api) if (WEXITSTATUS(exitStatus) != 0) RETURN_FALSE; - add_assoc_string(return_value, "file", fileNew VIRT_COPY_OPT); - add_assoc_string(return_value, "mime", "image/png" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "file", fileNew); + VIRT_ADD_ASSOC_STRING(return_value, "mime", "image/png"); } else { - add_assoc_string(return_value, "file", file VIRT_COPY_OPT); - add_assoc_string(return_value, "mime", mime VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "file", file); + VIRT_ADD_ASSOC_STRING(return_value, "mime", mime); } } @@ -5242,7 +5217,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models) tTokenizer t = tokenize(tmp, ","); for (i = 0; i < t.numTokens; i++) { snprintf(tmp2, sizeof(tmp2), "%d", i); - add_assoc_string(return_value, tmp2, t.tokens[i] VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, tmp2, t.tokens[i]); } free_tokens(t); } @@ -5340,14 +5315,14 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) } array_init(arr); - add_assoc_string(arr, "name", t.tokens[0] VIRT_COPY_OPT); - add_assoc_string(arr, "description", desc VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(arr, "name", t.tokens[0]); + VIRT_ADD_ASSOC_STRING(arr, "description", desc); add_next_index_zval(return_value, arr); } else { char tmp2[16] = { 0 }; snprintf(tmp2, sizeof(tmp2), "%d", n++); - add_assoc_string(return_value, tmp2, t.tokens[0] VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, tmp2, t.tokens[0]); } free_tokens(t); @@ -6937,8 +6912,8 @@ PHP_FUNCTION(libvirt_domain_get_network_info) } array_init(return_value); - add_assoc_string(return_value, "mac", mac VIRT_COPY_OPT); - add_assoc_string(return_value, "network", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "mac", mac); + VIRT_ADD_ASSOC_STRING(return_value, "network", tmp); free(tmp); free(xpath); @@ -6949,9 +6924,9 @@ PHP_FUNCTION(libvirt_domain_get_network_info) } tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "nic_type", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "nic_type", tmp); else - add_assoc_string(return_value, "nic_type", "default" VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "nic_type", "default"); free(xml); free(xpath); @@ -7036,12 +7011,12 @@ PHP_FUNCTION(libvirt_domain_get_block_info) array_init(return_value); LONGLONG_INIT; - add_assoc_string(return_value, "device", dev VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "device", dev); if (isFile) - add_assoc_string(return_value, "file", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "file", tmp); else - add_assoc_string(return_value, "partition", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "partition", tmp); free(xpath); if (asprintf(&xpath, "//domain/devices/disk/target[@dev='%s']/../driver/@type", dev) < 0) { @@ -7051,7 +7026,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info) free(tmp); tmp = get_string_from_xpath(xml, xpath, NULL, &retval); if (tmp != NULL) - add_assoc_string(return_value, "type", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "type", tmp); LONGLONG_ASSOC(return_value, "capacity", info.capacity); LONGLONG_ASSOC(return_value, "allocation", info.allocation); @@ -7108,7 +7083,7 @@ PHP_FUNCTION(libvirt_domain_xml_xpath) if (rc == 0) RETURN_FALSE; - add_assoc_string(return_value, "xpath", (char *)zpath VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "xpath", (char *)zpath); if (rc < 0) add_assoc_long(return_value, "error_code", (long)rc); } @@ -9227,18 +9202,18 @@ PHP_FUNCTION(libvirt_nodedev_get_information) goto error; } - add_assoc_string(return_value, "name", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "name", tmp); /* Get parent name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/parent", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "parent", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "parent", tmp); /* Get capability */ cap = get_string_from_xpath(xml, "//device/capability/@type", NULL, &retval); if ((cap != NULL) && (retval > 0)) - add_assoc_string(return_value, "capability", cap VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "capability", cap); /* System capability is having hardware and firmware sub-blocks */ if (strcmp(cap, "system") == 0) { @@ -9246,92 +9221,92 @@ PHP_FUNCTION(libvirt_nodedev_get_information) free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "hardware_vendor", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hardware_vendor", tmp); /* Get hardware version */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/version", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "hardware_version", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hardware_version", tmp); /* Get hardware serial */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/serial", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "hardware_serial", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hardware_serial", tmp); /* Get hardware UUID */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/hardware/uuid", NULL, &retval); if (tmp != NULL) - add_assoc_string(return_value, "hardware_uuid", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "hardware_uuid", tmp); /* Get firmware vendor */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "firmware_vendor", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "firmware_vendor", tmp); /* Get firmware version */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/version", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "firmware_version", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "firmware_version", tmp); /* Get firmware release date */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/firmware/release_date", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "firmware_release_date", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "firmware_release_date", tmp); } /* Get product_id */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/product/@id", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "product_id", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "product_id", tmp); /* Get product_name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/product", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "product_name", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "product_name", tmp); /* Get vendor_id */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/vendor/@id", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "vendor_id", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "vendor_id", tmp); /* Get vendor_name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/vendor", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "vendor_name", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "vendor_name", tmp); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/driver/name", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "driver_name", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "driver_name", tmp); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/interface", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "interface_name", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "interface_name", tmp); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/address", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "address", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "address", tmp); /* Get driver name */ free(tmp); tmp = get_string_from_xpath(xml, "//device/capability/capability/@type", NULL, &retval); if ((tmp != NULL) && (retval > 0)) - add_assoc_string(return_value, "capabilities", tmp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "capabilities", tmp); free(cap); free(tmp); @@ -9536,42 +9511,42 @@ PHP_FUNCTION(libvirt_network_get_information) RETURN_FALSE; } - add_assoc_string(return_value, "name", name VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "name", name); /* Get gateway IP address */ ipaddr = get_string_from_xpath(xml, "//network/ip/@address", NULL, &retval); if (ipaddr && retval > 0) - add_assoc_string(return_value, "ip", ipaddr VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "ip", ipaddr); /* Get netmask */ netmask = get_string_from_xpath(xml, "//network/ip/@netmask", NULL, &retval); if (netmask && retval > 0) { int subnet_bits = get_subnet_bits(netmask); - add_assoc_string(return_value, "netmask", netmask VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "netmask", netmask); add_assoc_long(return_value, "netmask_bits", (long) subnet_bits); /* Format CIDR address representation */ ipaddr[strlen(ipaddr) - 1] = ipaddr[strlen(ipaddr) - 1] - 1; snprintf(fixedtemp, sizeof(fixedtemp), "%s/%d", ipaddr, subnet_bits); - add_assoc_string(return_value, "ip_range", fixedtemp VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "ip_range", fixedtemp); } /* Get forwarding settings */ mode = get_string_from_xpath(xml, "//network/forward/@mode", NULL, &retval); if (mode && retval > 0) - add_assoc_string(return_value, "forwarding", mode VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "forwarding", mode); /* Get forwarding settings */ dev = get_string_from_xpath(xml, "//network/forward/@dev", NULL, &retval); if (dev && retval > 0) - add_assoc_string(return_value, "forward_dev", dev VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "forward_dev", dev); /* Get DHCP values */ dhcp_start = get_string_from_xpath(xml, "//network/ip/dhcp/range/@start", NULL, &retval); dhcp_end = get_string_from_xpath(xml, "//network/ip/dhcp/range/@end", NULL, &retval); if (dhcp_start && dhcp_end && retval > 0) { - add_assoc_string(return_value, "dhcp_start", dhcp_start VIRT_COPY_OPT); - add_assoc_string(return_value, "dhcp_end", dhcp_end VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "dhcp_start", dhcp_start); + VIRT_ADD_ASSOC_STRING(return_value, "dhcp_end", dhcp_end); } free(dhcp_end); @@ -9705,7 +9680,7 @@ PHP_FUNCTION(libvirt_version) add_assoc_long(return_value, "libvirt.minor",(long)((libVer/1000) % 1000)); add_assoc_long(return_value, "libvirt.major",(long)((libVer/1000000) % 1000)); - add_assoc_string(return_value, "connector.version", PHP_LIBVIRT_WORLD_VERSION VIRT_COPY_OPT); + VIRT_ADD_ASSOC_STRING(return_value, "connector.version", PHP_LIBVIRT_WORLD_VERSION); add_assoc_long(return_value, "connector.major", VERSION_MAJOR); add_assoc_long(return_value, "connector.minor", VERSION_MINOR); add_assoc_long(return_value, "connector.release", VERSION_MICRO); diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 105be20..fa2cd2e 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -138,6 +138,32 @@ typedef uint64_t arch_uint; #define UINTx PRIx64 #endif +#if PHP_MAJOR_VERSION >= 7 +typedef size_t strsize_t; + +#define VIRT_COPY_OPT +#define VIRT_RETVAL_STRING(str) RETVAL_STRING(str) +#define VIRT_ZVAL_STRINGL(zv,str,len) ZVAL_STRINGL(zv,str,len) +#define VIRT_ADD_ASSOC_STRING(arr,name,val) add_assoc_string(arr,name,val) +#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ + if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ + RETURN_FALSE; \ + } + +#else +typedef int strsize_t; +typedef long zend_long; +typedef unsigned long zend_ulong; + +#define VIRT_COPY_OPT ,1 +#define VIRT_RETVAL_STRING(str) RETVAL_STRING(str, 1) +#define VIRT_ZVAL_STRINGL(zv,str,len) ZVAL_STRINGL(zv,str,len,1) +#define VIRT_ADD_ASSOC_STRING(arr,name,val) add_assoc_string(arr,name,val,1) +#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ + ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); + +#endif + int connect_socket(char *server, char *port, int keepalive, int nodelay, int allow_server_override); int socket_has_data(int sfd, long maxtime, int ignoremsg); void socket_read(int sfd, long length); -- 2.5.5

From: Chuck Roydhouse <cer@datto.com> --- src/libvirt-php.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 4fa24d6..36be055 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -213,6 +213,13 @@ ZEND_ARG_INFO(0, memory) ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_block_commit, 0, 0, 3) +ZEND_ARG_INFO(0, res) +ZEND_ARG_INFO(0, disk) +ZEND_ARG_INFO(0, base) +ZEND_ARG_INFO(0, top) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_conn_path, 0, 0, 2) ZEND_ARG_INFO(0, conn) ZEND_ARG_INFO(0, path) @@ -238,6 +245,12 @@ ZEND_ARG_INFO(0, bandwidth) ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_block_job_info, 0, 0, 2) +ZEND_ARG_INFO(0, dom) +ZEND_ARG_INFO(0, disk) +ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_migrate, 0, 0, 3) ZEND_ARG_INFO(0, res) ZEND_ARG_INFO(0, dest_conn) @@ -515,10 +528,12 @@ static zend_function_entry libvirt_functions[] = { PHP_FE(libvirt_domain_set_memory, arginfo_libvirt_domain_set_memory) PHP_FE(libvirt_domain_set_max_memory, arginfo_libvirt_domain_set_memory) PHP_FE(libvirt_domain_set_memory_flags, arginfo_libvirt_domain_set_memory_flags) + PHP_FE(libvirt_domain_block_commit, arginfo_libvirt_domain_block_commit) PHP_FE(libvirt_domain_block_stats, arginfo_libvirt_conn_path) PHP_FE(libvirt_domain_block_resize, arginfo_libvirt_domain_block_resize) PHP_FE(libvirt_domain_block_job_abort, arginfo_libvirt_domain_block_job_abort) PHP_FE(libvirt_domain_block_job_set_speed, arginfo_libvirt_domain_block_job_set_speed) + PHP_FE(libvirt_domain_block_job_info, arginfo_libvirt_domain_block_job_info) PHP_FE(libvirt_domain_interface_stats, arginfo_libvirt_conn_path) PHP_FE(libvirt_domain_get_connect, arginfo_libvirt_conn) PHP_FE(libvirt_domain_migrate, arginfo_libvirt_domain_migrate) -- 2.5.5

From: Frederic Mora <fmora@datto.com> --- src/tests/qemu-no-disk-and-media.xml | 41 +++++++++ src/tests/test-connect-get-capabilities.phpt | 27 ++++++ src/tests/test-connect-get-info.phpt | 110 +++++++++++++++++++++++++ src/tests/test-connect-get-machine-types.phpt | 30 +++++++ src/tests/test-domain-create-and-shutdown.phpt | 38 +++++++++ src/tests/test-domain-define.phpt | 38 +++++++++ src/tests/test-domain-disk.phpt | 71 ++++++++++++++++ src/tests/test-domain-get.phpt | 91 ++++++++++++++++++++ src/tests/test-domain-lookup-by-name.phpt | 35 ++++++++ src/tests/test-domain-nic.phpt | 52 ++++++++++++ src/tests/test-logfile.phpt | 43 ++++++++++ 11 files changed, 576 insertions(+) create mode 100644 src/tests/qemu-no-disk-and-media.xml create mode 100644 src/tests/test-connect-get-capabilities.phpt create mode 100644 src/tests/test-connect-get-info.phpt create mode 100644 src/tests/test-connect-get-machine-types.phpt create mode 100644 src/tests/test-domain-create-and-shutdown.phpt create mode 100644 src/tests/test-domain-define.phpt create mode 100644 src/tests/test-domain-disk.phpt create mode 100644 src/tests/test-domain-get.phpt create mode 100644 src/tests/test-domain-lookup-by-name.phpt create mode 100644 src/tests/test-domain-nic.phpt create mode 100644 src/tests/test-logfile.phpt diff --git a/src/tests/qemu-no-disk-and-media.xml b/src/tests/qemu-no-disk-and-media.xml new file mode 100644 index 0000000..bad09f9 --- /dev/null +++ b/src/tests/qemu-no-disk-and-media.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>test-guest-no-disk-and-media</name> + <uuid>28a15e00-9c40-ddc1-b6df-9a08921b93f0</uuid> + <memory>65535</memory> + <currentMemory>65535</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686'>hvm</type> + <boot dev='cdrom'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>restart</on_crash> + <devices> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='scsi' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> + </controller> + <serial type='pty'> + <target port='0'/> + </serial> + <console type='pty'> + <target type='serial' port='0'/> + </console> + <input type='mouse' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes'/> + <video> + <model type='cirrus' vram='9216' heads='1'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + </devices> +</domain> + diff --git a/src/tests/test-connect-get-capabilities.phpt b/src/tests/test-connect-get-capabilities.phpt new file mode 100644 index 0000000..3c3d50f --- /dev/null +++ b/src/tests/test-connect-get-capabilities.phpt @@ -0,0 +1,27 @@ +--TEST-- +libvirt_connect_get_capabilities +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + + echo "# libvirt_connect\n"; + var_dump($conn = libvirt_connect('test:///default', false)); + if (!is_resource($conn)) + die('Connection to default hypervisor failed'); + + echo "# libvirt_connect_get_capabilities\n"; + var_dump($res = libvirt_connect_get_emulator($conn)); + if (!$res) { + die('Connect get capabilities failed with error: '.libvirt_get_last_error()); + } + + unset($conn); +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_connect_get_capabilities +string(%d) "%s" +Done diff --git a/src/tests/test-connect-get-info.phpt b/src/tests/test-connect-get-info.phpt new file mode 100644 index 0000000..1cfa527 --- /dev/null +++ b/src/tests/test-connect-get-info.phpt @@ -0,0 +1,110 @@ +--TEST-- +libvirt_connect_get_information +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +echo "# libvirt_connect\n"; +var_dump($conn = libvirt_connect('test:///default', false)); +if (!is_resource($conn)) { + die('Connection to default hypervisor failed'); +} + +echo "# libvirt_node_get_info\n"; +$res = libvirt_node_get_info($conn); + +if (!is_array($res)) { + die("libvirt_node_get_info returned unexpected value: " . print_r($res, true) . + "\nFailed with error: ".libvirt_get_last_error()); +} + +foreach (array('memory', 'cpus') as $k) { + if (!array_key_exists($k, $res) || !is_numeric($res[$k])) { + die("libvirt_node_get_info: Absent or incorrect key \'$k\'. Value: " . print_r($res, true) . + "\nFailed with error: ".libvirt_get_last_error()); + } +} + +unset($res); + +echo "# libvirt_connect_get_uri\n"; +var_dump(libvirt_connect_get_uri($conn)); + +echo "# libvirt_connect_get_hostname\n"; +var_dump(libvirt_connect_get_hostname($conn)); + +echo "# libvirt_domain_get_counts\n"; +$counts = libvirt_domain_get_counts($conn); + +if (!is_array($counts)) { + die("libvirt_domain_get_counts returned unexpected value: " . print_r($counts, true) . + "\nFailed with error: ".libvirt_get_last_error()); +} + +foreach (array("total", "active", "inactive") as $k) { + if (!array_key_exists($k, $counts) || !is_numeric($counts[$k])) { + die("libvirt_domain_get_counts: Absent or incorrect key \'$k\'. Value: " . print_r($counts, true) . + "\nFailed with error: ".libvirt_get_last_error()); + } +} + +echo "# libvirt_list_active_domains\n"; +var_dump(count(libvirt_list_active_domains($conn)) == $counts['active']); + +echo "# libvirt_list_inactive_domains\n"; +var_dump(count(libvirt_list_inactive_domains($conn)) == $counts['inactive']); + +unset($count); + +echo "# libvirt_connect_get_hypervisor\n"; +$res = libvirt_connect_get_hypervisor($conn); +if (!is_array($res)) { + die("libvirt_connect_get_hypervisor returned unexpected value: " . print_r($res, true) . + "\nFailed with error: ".libvirt_get_last_error()); +} +unset($res); + +echo "# libvirt_connect_get_maxvcpus\n"; +var_dump(is_numeric(libvirt_connect_get_maxvcpus($conn))); + +echo "# libvirt_connect_get_information\n"; +$res = @libvirt_connect_get_information($conn); // Need to suppress driver-dependent warning messages +if (!is_array($res)) { + die("libvirt_connect_get_information returned unexpected value: " . print_r($res, true) . + "\nFailed with error: ".libvirt_get_last_error()); +} +unset($res); + +echo "# libvirt_connect_get_encrypted\n"; +var_dump(libvirt_connect_get_encrypted($conn) != -1); + +echo "# libvirt_connect_get_secure\n"; +var_dump(libvirt_connect_get_secure($conn) != -1); + +unset($conn); + +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_node_get_info +# libvirt_connect_get_uri +string(%d) "%s" +# libvirt_connect_get_hostname +string(%d) "%s" +# libvirt_domain_get_counts +# libvirt_list_active_domains +bool(true) +# libvirt_list_inactive_domains +bool(true) +# libvirt_connect_get_hypervisor +# libvirt_connect_get_maxvcpus +bool(true) +# libvirt_connect_get_information +# libvirt_connect_get_encrypted +bool(true) +# libvirt_connect_get_secure +bool(true) +Done diff --git a/src/tests/test-connect-get-machine-types.phpt b/src/tests/test-connect-get-machine-types.phpt new file mode 100644 index 0000000..c9b0cd8 --- /dev/null +++ b/src/tests/test-connect-get-machine-types.phpt @@ -0,0 +1,30 @@ +--TEST-- +libvirt_connect_get_machine_types +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + + echo "# libvirt_connect\n"; + var_dump($conn = libvirt_connect('test:///default', false)); + if (!is_resource($conn)) + die('Connection to default hypervisor failed'); + + echo "# libvirt_connect_get_machine_types\n"; + $res = libvirt_connect_get_machine_types($conn); + if (!$res) { + die('Get machine types failed with error: '.libvirt_get_last_error()); + } + if (!is_array($res)) { + die("libvirt_connect_get_machine_types returned unexpected value: " . print_r($res, true) . + "\nFailed with error: ".libvirt_get_last_error()); + } + unset($res); + unset($conn); +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_connect_get_machine_types +Done diff --git a/src/tests/test-domain-create-and-shutdown.phpt b/src/tests/test-domain-create-and-shutdown.phpt new file mode 100644 index 0000000..2bed1ab --- /dev/null +++ b/src/tests/test-domain-create-and-shutdown.phpt @@ -0,0 +1,38 @@ +--TEST-- +libvirt_domain_shutdown +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + echo "# libvirt_connect\n"; + var_dump($conn = libvirt_connect('test:///default', false)); + if (!is_resource($conn)) + die('Connection to default hypervisor failed'); + + $xml = file_get_contents(__DIR__.'/example-no-disk-and-media.xml'); + + echo "# libvirt_domain_create_xml\n"; + var_dump($res = libvirt_domain_create_xml($conn, $xml)); + if (!is_resource($res)) + die('Domain definition failed with error: '.libvirt_get_last_error()); + + echo "# libvirt_domain_shutdown\n"; + var_dump($ret = libvirt_domain_shutdown($res)); + if (!$ret) { + die('Domain shutdown failed with error: '.libvirt_get_last_error()); + } + + unset($res); + unset($conn); + +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_create_xml +resource(%d) of type (Libvirt domain) +# libvirt_domain_shutdown +bool(true) +Done + diff --git a/src/tests/test-domain-define.phpt b/src/tests/test-domain-define.phpt new file mode 100644 index 0000000..114a127 --- /dev/null +++ b/src/tests/test-domain-define.phpt @@ -0,0 +1,38 @@ +--TEST-- +libvirt_domain_define_xml +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + + echo "# libvirt_connect\n"; + var_dump($conn = libvirt_connect('test:///default', false)); + if (!is_resource($conn)) + die('Connection to default hypervisor failed'); + + $xml = file_get_contents(__DIR__.'/example-no-disk-and-media.xml'); + + echo "# libvirt_domain_define_xml\n"; + var_dump($dom = libvirt_domain_define_xml($conn, $xml)); + if (!is_resource($dom)) + die('Domain definition failed with error: '.libvirt_get_last_error()); + + echo "# libvirt_domain_undefine\n"; + var_dump($ret = libvirt_domain_undefine($dom)); + if (!$ret) { + unlink($name); + die('Domain undefine failed with error: '.libvirt_get_last_error()); + } + + unset($dom); + unset($conn); +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_define_xml +resource(%d) of type (Libvirt domain) +# libvirt_domain_undefine +bool(true) +Done diff --git a/src/tests/test-domain-disk.phpt b/src/tests/test-domain-disk.phpt new file mode 100644 index 0000000..c2b7cb5 --- /dev/null +++ b/src/tests/test-domain-disk.phpt @@ -0,0 +1,71 @@ +--TEST-- +libvirt_domain_disk +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$disk_devname = 'hda'; // Disk that will be added to existing guest config +$disk_devtype = 'ide'; +$disk_iodriver = 'raw'; +$disk_image = '/tmp/test-libvirt-php.img'; +touch($disk_image); + +$logfile = __DIR__ . '/test.log'; +@unlink($logfile); +echo "# libvirt_logfile_set\n"; +if (!libvirt_logfile_set($logfile, 100)) { // Log file will be 100 KB max + die('Logfile set failed with error: '.libvirt_get_last_error()); +} + +echo "# libvirt_connect\n"; +var_dump($conn = libvirt_connect('qemu:///session', false)); +if (!is_resource($conn)) + die('Connection to default hypervisor failed. Is libvirt started? What about the QEMU driver?'); + +// libvirt_domain_disk_add needs a persistent guest loaded from a file +$xml = file_get_contents(__DIR__.'/qemu-no-disk-and-media.xml'); +echo "# libvirt_domain_define_xml\n"; +var_dump($dom = libvirt_domain_define_xml($conn, $xml)); +if (!is_resource($dom)) { + die('Domain definition failed with error: '.libvirt_get_last_error()); +} + +echo "# libvirt_domain_disk_add\n"; +// The doc is a wrong. It says the function returns a domain resource. +// It actually returns a boolean! +var_dump($ret = libvirt_domain_disk_add($dom, $disk_image, $disk_devname, $disk_devtype, $disk_iodriver, 0)); +if (!$ret) { + die('Domain disk add failed with error: '.libvirt_get_last_error()); +} + +echo "# libvirt_domain_get_disk_devices\n"; +$info = libvirt_domain_get_disk_devices($dom); +var_dump(is_array($info)); +if (!array_key_exists('num', $info)) + die('libvirt_domain_get_disk_devices: Num element is missing in the output array'); + +echo "# libvirt_domain_undefine\n"; +var_dump($ret = libvirt_domain_undefine($dom)); +if (!$ret) { + die('Domain undefine failed with error: '.libvirt_get_last_error()); +} + +unset($dom); +unset($conn); + +?> +Done +--EXPECTF-- +# libvirt_logfile_set +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_define_xml +resource(%d) of type (Libvirt domain) +# libvirt_domain_disk_add +bool(true) +# libvirt_domain_get_disk_devices +bool(true) +# libvirt_domain_undefine +bool(true) +Done \ No newline at end of file diff --git a/src/tests/test-domain-get.phpt b/src/tests/test-domain-get.phpt new file mode 100644 index 0000000..c723210 --- /dev/null +++ b/src/tests/test-domain-get.phpt @@ -0,0 +1,91 @@ +--TEST-- +libvirt_domain_get_xml +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +echo "# libvirt_connect\n"; +var_dump($conn = libvirt_connect('test:///default', false)); +if (!is_resource($conn)) + die('Connection to default hypervisor failed'); + +// We need a running domain to be able to pull the id +$xml = file_get_contents(__DIR__.'/example-no-disk-and-media.xml'); +echo "# libvirt_domain_create_xml\n"; +var_dump($dom = libvirt_domain_create_xml($conn, $xml)); +if (!is_resource($dom)) { + die('Domain definition failed with error: '.libvirt_get_last_error()); +} + +echo "# libvirt_domain_get_name\n"; +var_dump($dom_name = libvirt_domain_get_name($dom)); + +echo "# libvirt_domain_get_uuid_string\n"; +var_dump($dom_uuid_str = libvirt_domain_get_uuid_string($dom)); + +echo "# libvirt_domain_get_uuid\n"; +var_dump($dom_uuid = libvirt_domain_get_uuid($dom)); + +echo "# libvirt_domain_get_id\n"; +var_dump($dom_id = libvirt_domain_get_id($dom)); + +echo "# libvirt_domain_lookup_by_uuid_string\n"; +var_dump($dom2 = libvirt_domain_lookup_by_uuid_string($conn, $dom_uuid_str)); +if (!is_resource($dom2)) { + die('Domain lookup by UUID string failed with error: '.libvirt_get_last_error()); +} +unset($dom2); + +echo "# libvirt_domain_lookup_by_id\n"; +var_dump($dom2 = libvirt_domain_lookup_by_id($conn, $dom_id)); +if (!is_resource($dom2)) { + die('Domain lookup by ID failed with error: '.libvirt_get_last_error()); +} +unset($dom2); + +echo "# libvirt_domain_is_persistent\n"; +var_dump(libvirt_domain_is_persistent($dom) !== -1); + +echo "# libvirt_domain_get_xml_desc\n"; +$xmlstr = libvirt_domain_get_xml_desc($dom, NULL); + +$xmlok = (strpos($xmlstr, "<name>{$dom_name}</name>") && + strpos($xmlstr, "<uuid>{$dom_uuid_str}</uuid>")); +var_dump($xmlok); + +echo "# libvirt_domain_shutdown\n"; +var_dump($ret = libvirt_domain_shutdown($dom)); +if (!$ret) { + die('Domain shutdown failed with error: '.libvirt_get_last_error()); +} + +unset($res); +unset($dom); +unset($conn); +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_create_xml +resource(%d) of type (Libvirt domain) +# libvirt_domain_get_name +string(%d) "test-guest-no-disk-and-media" +# libvirt_domain_get_uuid_string +string(36) "%s" +# libvirt_domain_get_uuid +string(%d) "%s" +# libvirt_domain_get_id +int(%d) +# libvirt_domain_lookup_by_uuid_string +resource(%d) of type (Libvirt domain) +# libvirt_domain_lookup_by_id +resource(%d) of type (Libvirt domain) +# libvirt_domain_is_persistent +bool(true) +# libvirt_domain_get_xml_desc +bool(true) +# libvirt_domain_shutdown +bool(true) +Done diff --git a/src/tests/test-domain-lookup-by-name.phpt b/src/tests/test-domain-lookup-by-name.phpt new file mode 100644 index 0000000..8beb43c --- /dev/null +++ b/src/tests/test-domain-lookup-by-name.phpt @@ -0,0 +1,35 @@ +--TEST-- +libvirt_domain_lookup_by_name +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + + echo "# libvirt_connect\n"; + var_dump($conn = libvirt_connect('test:///default', false)); + if (!is_resource($conn)) + die('Connection to default hypervisor failed'); + // Loads domain of type 'test', name 'test-guest-no-disk-and-media' + $xml = file_get_contents(__DIR__.'/example-no-disk-and-media.xml'); + + echo "# libvirt_domain_create_xml\n"; + var_dump($res = libvirt_domain_create_xml($conn, $xml)); + if (!is_resource($res)) + die('Domain definition failed with error: '.libvirt_get_last_error()); + + echo "# libvirt_domain_lookup_by_name\n"; + var_dump($dom = libvirt_domain_lookup_by_name($conn, "test")); + + unset($dom); + unset($res); + unset($conn); +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_create_xml +resource(%d) of type (Libvirt domain) +# libvirt_domain_lookup_by_name +resource(%d) of type (Libvirt domain) +Done diff --git a/src/tests/test-domain-nic.phpt b/src/tests/test-domain-nic.phpt new file mode 100644 index 0000000..ac72c64 --- /dev/null +++ b/src/tests/test-domain-nic.phpt @@ -0,0 +1,52 @@ +--TEST-- +libvirt_domain_nic +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$mac = '00:11:22:33:44:55'; // Parms for defining a NIC +$network = 'default'; +$model = 'e1000'; + +echo "# libvirt_connect\n"; +var_dump($conn = libvirt_connect('qemu:///session', false)); +if (!is_resource($conn)) + die('Connection to default hypervisor failed. Is libvirt started? What about the QEMU driver?'); + +// libvirt_domain_nic_add needs a persistent guest loaded from a file +$xml = file_get_contents(__DIR__.'/qemu-no-disk-and-media.xml'); +echo "# libvirt_domain_define_xml\n"; +var_dump($dom = libvirt_domain_define_xml($conn, $xml)); +if (!is_resource($dom)) { + die('Domain definition failed with error: '.libvirt_get_last_error()); +} + +echo "# libvirt_domain_nic_add\n"; +// The doc is wrong. It says the function returns a domain resource. +// It actually returns a boolean! +var_dump($ret = libvirt_domain_nic_add($dom, $mac, $network, $model, 0)); +if (!$ret) { + die('Domain nic add failed with error: '.libvirt_get_last_error()); +} + +echo "# libvirt_domain_get_interface_devices\n"; +$info = libvirt_domain_get_interface_devices($dom); +var_dump(is_array($info)); +if (!array_key_exists('num', $info)) + die('libvirt_domain_get_interface_devices: Num element is missing in the output array'); + +unset($conn); + +?> +Done +--EXPECTF-- +# libvirt_connect +resource(%d) of type (Libvirt connection) +# libvirt_domain_define_xml +resource(%d) of type (Libvirt domain) +# libvirt_domain_nic_add +bool(true) +# libvirt_domain_get_interface_devices +bool(true) +Done \ No newline at end of file diff --git a/src/tests/test-logfile.phpt b/src/tests/test-logfile.phpt new file mode 100644 index 0000000..4cfae15 --- /dev/null +++ b/src/tests/test-logfile.phpt @@ -0,0 +1,43 @@ +--TEST-- +libvirt_logfile_set +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$logfile = 'test.log'; +@unlink($logfile); + +echo "# libvirt_logfile_set\n"; +if (!libvirt_logfile_set($logfile, 1)) { + die('Logfile set failed with error: '.libvirt_get_last_error()); +} + +echo "# libvirt_connect\n"; +var_dump($conn = libvirt_connect('test:///default', false)); +if (!is_resource($conn)) { + die('Connection to default hypervisor failed'); +} + +unset($res); +unset($conn); + +$fp = fopen($logfile, 'r'); +$log = fread($fp, filesize($logfile)); +fclose($fp); + +$logok = (strpos($log, 'libvirt_connect: Connection') && + strpos($log, 'libvirt_connection_dtor: virConnectClose')); + +unlink($logfile); + +var_dump($logok); + +?> +Done +--EXPECTF-- +# libvirt_logfile_set +# libvirt_connect +resource(%d) of type (Libvirt connection) +bool(true) +Done -- 2.5.5

--- INSTALL.PHPEXT | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 INSTALL.PHPEXT diff --git a/INSTALL.PHPEXT b/INSTALL.PHPEXT new file mode 100644 index 0000000..41c2ef6 --- /dev/null +++ b/INSTALL.PHPEXT @@ -0,0 +1,14 @@ +Installing using the PHP extension build system +*********************************************** + +libvirt-php supports being built using `phpize`, +a tool that's part of the PHP SDK for building PHP +extensions. + +To build this way, change into the src subdirectory +and run `phpize`. Then run `./configure && make && make install` +to build and install it. Refer to INSTALL for more information +on how to use ./configure. + +The PHP extension build system also has its own tests, +which can be run by doing `make test`. -- 2.5.5

--- configure.ac | 2 +- src/libvirt-php.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 51a2cfe..ed3c9d6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libvirt-php], [0.5.1], [http://libvirt.org]) +AC_INIT([libvirt-php], [0.5.2], [http://libvirt.org]) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability]) AC_CONFIG_FILES([Makefile tools/Makefile src/Makefile tests/Makefile docs/Makefile]) AM_MAINTAINER_MODE([enable]) diff --git a/src/libvirt-php.h b/src/libvirt-php.h index fa2cd2e..b1c49a4 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -74,7 +74,7 @@ #endif #ifndef VERSION -#define VERSION "0.5.2-dev" +#define VERSION "0.5.2" #define VERSION_MAJOR 0 #define VERSION_MINOR 5 #define VERSION_MICRO 2 -- 2.5.5

On 13.04.2016 18:13, Neal Gompa wrote:
--- configure.ac | 2 +- src/libvirt-php.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac index 51a2cfe..ed3c9d6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libvirt-php], [0.5.1], [http://libvirt.org]) +AC_INIT([libvirt-php], [0.5.2], [http://libvirt.org]) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability]) AC_CONFIG_FILES([Makefile tools/Makefile src/Makefile tests/Makefile docs/Makefile]) AM_MAINTAINER_MODE([enable]) diff --git a/src/libvirt-php.h b/src/libvirt-php.h index fa2cd2e..b1c49a4 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -74,7 +74,7 @@ #endif
#ifndef VERSION -#define VERSION "0.5.2-dev" +#define VERSION "0.5.2" #define VERSION_MAJOR 0 #define VERSION_MINOR 5 #define VERSION_MICRO 2
I will push this one only after some testing of the patches I've just pushed. It has been a big change so I rather give our users chance to test it before calling it release. Michal

On Thu, Apr 14, 2016 at 12:30 PM, Michal Privoznik <mprivozn@redhat.com> wrote:
I will push this one only after some testing of the patches I've just pushed. It has been a big change so I rather give our users chance to test it before calling it release.
Michal
If it helps any, since this has all made it up to the libvirt-php git, I've tested it on PHP 5 and PHP 7 with some applications with good success, so it looks good to me. I'd definitely appreciate a libvirt 0.5.2 release. I'm also the php-libvirt package maintainer in Fedora and EPEL, and I'd like to update the package to the latest stuff once a release is made. And Remi can add it to his repository to provide SCL versions of libvirt-php across the different PHP versions he supports. Ubuntu is already shipping the snapshot[1] for the 16.04 LTS release coming out on Wednesday. A formal release would just make it easier for everyone else to update, as well. [1]: http://packages.ubuntu.com/xenial/php-libvirt-php -- 真実はいつも一つ!/ Always, there's only one truth!

2016-04-19 5:02 GMT+03:00 Neal Gompa <ngompa13@gmail.com>:
If it helps any, since this has all made it up to the libvirt-php git, I've tested it on PHP 5 and PHP 7 with some applications with good success, so it looks good to me. I'd definitely appreciate a libvirt 0.5.2 release. I'm also the php-libvirt package maintainer in Fedora and EPEL, and I'd like to update the package to the latest stuff once a release is made. And Remi can add it to his repository to provide SCL versions of libvirt-php across the different PHP versions he supports.
Ubuntu is already shipping the snapshot[1] for the 16.04 LTS release coming out on Wednesday.
A formal release would just make it easier for everyone else to update, as well.
I'm agree with new release, i'm use git snapshot under debian jessie for Russian cloud hosting . -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru

On 19.04.2016 04:02, Neal Gompa wrote:
On Thu, Apr 14, 2016 at 12:30 PM, Michal Privoznik <mprivozn@redhat.com> wrote:
I will push this one only after some testing of the patches I've just pushed. It has been a big change so I rather give our users chance to test it before calling it release.
Michal
If it helps any, since this has all made it up to the libvirt-php git, I've tested it on PHP 5 and PHP 7 with some applications with good success, so it looks good to me. I'd definitely appreciate a libvirt 0.5.2 release. I'm also the php-libvirt package maintainer in Fedora and EPEL, and I'd like to update the package to the latest stuff once a release is made. And Remi can add it to his repository to provide SCL versions of libvirt-php across the different PHP versions he supports.
Agreed. I want to do the release ASAP. All I wanted to do before is some testing because the patches I've merged were quite aggressive. Your testing shows we should be good to go. I'll test it and do the release probably later today. Michal

On 13.04.2016 18:13, Neal Gompa wrote:
This patch set is a revision of the first version, taking into account some of the feedback from Michal Privoznik.
I've done some patch surgery to rebase the patch set on the current git HEAD, so it should cleanly apply as-is. Additionally, I've squashed a few commits (mainly some of Remi's patches that were squashable that should be squashed). This means that Vasiliy's patches are no longer unnecessarily part of this patch set.
I've updated my patches for the instructions on the php extension build system method to correct a typo on how to run the tests (`make test` instead of `make tests`) and removed the "-dev" suffix that Remi attached to the version string in libvirt-php.h, as I expect that there will likely be a libvirt-php release after this patch set is merged.
I would greatly appreciate a quick review and merge of this patch set.
Chuck Roydhouse (1): add arginfo for libvirt_domain_block_commit and libvirt_domain_block_job_info
Frederic Mora (1): Add more tests
Neal Gompa (2): Commit short instructions to using the php extension build method Bump version to 0.5.2
Remi Collet (25): add config.m4 to allow standard PHP extension build system include config.h earlier add missing arginfo adapt RETURN_STRING work on zpp register + fetch resources + hash adapt add_assoc_string_ex clean ALLOC_INIT_ZVAL zend_hash_update add_next_index_string buildable with PHP 7 bump version 0.5.2-dev fix missed (hidden) zpp calls fix PHP 5 compat fix libvirt_version + add test port test-connect.phpt to real phpt Switch all add_assoc_string_ex to add_assoc_string to avoid nul char management Fix max_connections management add test-conn-limit.phpt (as real phpt) add test-connect-get-emulator.phpt fix parse_array + build warnings convert test-install.phpt to real phpt convert test-domain-create-and-coredump.phpt to real phpt convert test-domain-create-and-get-xpath.phpt to real phpt fix PHP 5 compat again (nested macro issue)
INSTALL.PHPEXT | 14 + configure.ac | 2 +- src/config.m4 | 52 + src/libvirt-php.c | 1796 ++++++++++++++++------- src/libvirt-php.h | 48 +- src/tests/example-no-disk-and-media.xml | 41 + src/tests/qemu-no-disk-and-media.xml | 41 + src/tests/skipif.inc | 3 + src/tests/test-conn-limit.phpt | 49 + src/tests/test-connect-get-capabilities.phpt | 27 + src/tests/test-connect-get-emulator.phpt | 15 + src/tests/test-connect-get-info.phpt | 110 ++ src/tests/test-connect-get-machine-types.phpt | 30 + src/tests/test-connect.phpt | 15 + src/tests/test-domain-create-and-coredump.phpt | 49 + src/tests/test-domain-create-and-get-xpath.phpt | 56 + src/tests/test-domain-create-and-shutdown.phpt | 38 + src/tests/test-domain-define.phpt | 38 + src/tests/test-domain-disk.phpt | 71 + src/tests/test-domain-get.phpt | 91 ++ src/tests/test-domain-lookup-by-name.phpt | 35 + src/tests/test-domain-nic.phpt | 52 + src/tests/test-install.phpt | 136 ++ src/tests/test-libvirt-php.img | 0 src/tests/test-logfile.phpt | 43 + src/tests/test-version-get.phpt | 27 + 26 files changed, 2330 insertions(+), 549 deletions(-) create mode 100644 INSTALL.PHPEXT create mode 100644 src/config.m4 create mode 100644 src/tests/example-no-disk-and-media.xml create mode 100644 src/tests/qemu-no-disk-and-media.xml create mode 100644 src/tests/skipif.inc create mode 100644 src/tests/test-conn-limit.phpt create mode 100644 src/tests/test-connect-get-capabilities.phpt create mode 100644 src/tests/test-connect-get-emulator.phpt create mode 100644 src/tests/test-connect-get-info.phpt create mode 100644 src/tests/test-connect-get-machine-types.phpt create mode 100644 src/tests/test-connect.phpt create mode 100644 src/tests/test-domain-create-and-coredump.phpt create mode 100644 src/tests/test-domain-create-and-get-xpath.phpt create mode 100644 src/tests/test-domain-create-and-shutdown.phpt create mode 100644 src/tests/test-domain-define.phpt create mode 100644 src/tests/test-domain-disk.phpt create mode 100644 src/tests/test-domain-get.phpt create mode 100644 src/tests/test-domain-lookup-by-name.phpt create mode 100644 src/tests/test-domain-nic.phpt create mode 100644 src/tests/test-install.phpt create mode 100644 src/tests/test-libvirt-php.img create mode 100644 src/tests/test-logfile.phpt create mode 100644 src/tests/test-version-get.phpt
My overall feeling is better after this version. It still has its issues though, e.g. does not even compile after each patch, some patches fix the ones just before and so on. But I'm too tired to point it out for every single occurrence. Therefore I've fixed the patches to my best knowledge and pushed them - with two exceptions: 12/29 and 29/29. Thank you both guys - Neal and Remi for proposing your patches! Michal
participants (4)
-
Michal Privoznik
-
Neal Gompa
-
Remi Collet
-
Vasiliy Tolstov