From nobody Thu May 2 02:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 149815932264391.42454947832266; Thu, 22 Jun 2017 12:22:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70AA719D28C; Thu, 22 Jun 2017 19:21:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4442052FC3; Thu, 22 Jun 2017 19:21:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EC7A14E986; Thu, 22 Jun 2017 19:21:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJEEGC013743 for ; Thu, 22 Jun 2017 15:14:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B27760630; Thu, 22 Jun 2017 19:14:14 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0373C6BF97 for ; Thu, 22 Jun 2017 19:14:11 +0000 (UTC) Received: from mail-qt0-f173.google.com (mail-qt0-f173.google.com [209.85.216.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A2A4627C8 for ; Thu, 22 Jun 2017 19:14:10 +0000 (UTC) Received: by mail-qt0-f173.google.com with SMTP id f92so19462519qtb.2 for ; Thu, 22 Jun 2017 12:14:10 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:09 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 70AA719D28C Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 70AA719D28C Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="sdGr2Ke6" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7A2A4627C8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7A2A4627C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=m6cqjLbHNSoGcNg3AOhxMypvNu5ADmJPABidH2GyscA=; b=sdGr2Ke6bczmDLXKFZ5HbeMtAmRmaMVofnRaeV0k7rDC5bvjTqdVZoSC8RZBTl7lfx LOGeYn4NWQa79oFa2isMT5jmN3p4bLUCoUfFQaUWuCHcmqA/Ki2qHWsIk0anw+P/PMQR sFKR8MKkBNWZxhCuYoeqRRtFg2XEckfgpho4aoargXy9UZor+z/2uhrpmu4oR+Xu3fgu 54icADt9CvPjWtil3pzuq3erxzOyNDnptAZppJEpZCtZGUdq0gGY5Sdn4ukCSuQza17p jskSRVyqF3hVRMZeP8rwso7MHZhGnrqga2Pd6AWNckYZJQKALbYvcL6YsNEEIAGNlq5S n2Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=m6cqjLbHNSoGcNg3AOhxMypvNu5ADmJPABidH2GyscA=; b=pxXWmj8UmUXZ5BAZ6HpgrpoT6z5Gy2yjHOxPHVKYjGWMzh2e8OYK5TeAQc5Syg4P6m 5Uck3mXavamo1d28SuUHWsHbYxDAylg3FEydO3xzcz691jeF3Gu8rsxMPbhFQbVfpHfc SxLSIPsfQCK4p6eZmHcLigMg7Cf3RNmvVHzP7/i2fUUdqRXv/AdIDfkGpkvWo5R2X/0a ZVdys6XMXs78a3WZvO7aIFHtR3PnQWQwglOteNsyyqyJeVCLmOa7H2+G11KuTU3RMmAd HoqA/gHKRRL43FbE604ZEUULk4CoW55fWBvhx8ybdzn9nSh9j7KROhqD8PwZ37WgyNVd KZaQ== X-Gm-Message-State: AKS2vOxX3FIqnwbGnCErG35tc/GvgcGMFxB58gD3T0aJb50zTdytxspk +zlS/DAxjAlrGWvr7PoSnA== X-Received: by 10.237.33.187 with SMTP id l56mr4924840qtc.165.1498158849546; Thu, 22 Jun 2017 12:14:09 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:01 -0400 Message-Id: <20170622191407.15570-2-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 22 Jun 2017 19:14:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 22 Jun 2017 19:14:10 +0000 (UTC) for IP:'209.85.216.173' DOMAIN:'mail-qt0-f173.google.com' HELO:'mail-qt0-f173.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.369 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.216.173 mail-qt0-f173.google.com 209.85.216.173 mail-qt0-f173.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 1/7] move macros to header file. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 22 Jun 2017 19:22:01 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" So that PHP version handling wrappers are all in one place --- src/libvirt-php.c | 88 ---------------------------------------------------= ---- src/libvirt-php.h | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 88 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index c2ab0da..ece98d6 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -45,94 +45,6 @@ const char *features[] =3D { NULL }; const char *features_binaries[] =3D { NULL }; #endif =20 -#if PHP_MAJOR_VERSION >=3D 7 -typedef size_t strsize_t; - - -#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ - if ((_state =3D (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le= )) =3D=3D NULL) { \ - RETURN_FALSE; \ - } - -#define VIRT_RETVAL_STRING(_str) \ - RETVAL_STRING(_str) -#define VIRT_RETVAL_STRINGL(_str, _len) \ - RETVAL_STRINGL(_str, _len) -#define VIRT_RETURN_STRING(_str) \ - RETURN_STRING(_str) -#define VIRT_RETURN_STRINGL(_str, _len) \ - RETURN_STRINGL(_str, _len) -#define VIRT_ZVAL_STRINGL(_zv, _str, _len) \ - ZVAL_STRINGL(_zv, _str, _len) -#define VIRT_ADD_INDEX_STRING(_arg, _idx, _str) \ - add_index_string(_arg, _idx, _str) -#define VIRT_ADD_NEXT_INDEX_STRING(_arg, _str) \ - add_next_index_string(_arg, _str) -#define VIRT_ADD_ASSOC_STRING(_arg, _key, _str) \ - add_assoc_string(_arg, _key, _str) -#define VIRT_ADD_ASSOC_STRING_EX(_arg, _key, _key_len, _value) \ - add_assoc_string_ex(_arg, _key, _key_len, _value) - -#define VIRT_FOREACH(_ht, _pos, _zv) \ - for (zend_hash_internal_pointer_reset_ex(_ht, &_pos); \ - (_zv =3D zend_hash_get_current_data_ex(_ht, &_pos)) !=3D NULL; \ - zend_hash_move_forward_ex(_ht, &_pos)) \ - -#define VIRT_FOREACH_END(_dummy) - -#define VIRT_HASH_CURRENT_KEY_INFO(_ht, _pos, _idx, _info) \ - do { \ - zend_string *tmp_key_info; \ - _info.type =3D zend_hash_get_current_key_ex(_ht, &tmp_key_info, &_idx,= &_pos); \ - _info.name =3D ZSTR_VAL(tmp_key_info); \ - _info.length =3D ZSTR_LEN(tmp_key_info); \ - } while(0) - -#else /* PHP_MAJOR_VERSION < 7 */ -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); - -#define VIRT_RETVAL_STRING(_str) \ - RETVAL_STRING(_str, 1) -#define VIRT_RETVAL_STRINGL(_str, _len) \ - RETVAL_STRINGL(_str, _len, 1) -#define VIRT_RETURN_STRING(_str) \ - RETURN_STRING(_str, 1) -#define VIRT_RETURN_STRINGL(_str, _len) \ - RETURN_STRINGL(_str, _len, 1) -#define VIRT_ZVAL_STRINGL(_zv, _str, _len) \ - ZVAL_STRINGL(_zv, _str, _len, 1) -#define VIRT_ADD_INDEX_STRING(_arg, _idx, _str) \ - add_index_string(_arg, _idx, _str, 1) -#define VIRT_ADD_NEXT_INDEX_STRING(_arg, _str) \ - add_next_index_string(_arg, _str, 1) -#define VIRT_ADD_ASSOC_STRING(_arg, _key, _str) \ - add_assoc_string(_arg, _key, _str, 1) -#define VIRT_ADD_ASSOC_STRING_EX(_arg, _key, _key_len, _value) \ - add_assoc_string_ex(_arg, _key, _key_len, _value, 1) - -#define VIRT_FOREACH(_ht, _pos, _zv) \ - { \ - zval **pzv =3D &_zv; \ - for (zend_hash_internal_pointer_reset_ex(_ht, &_pos); \ - zend_hash_get_current_data_ex(_ht, (void **) &pzv, &_pos) =3D=3D = SUCCESS; \ - zend_hash_move_forward_ex(_ht, &_pos)) { \ - _zv =3D *pzv; - -#define VIRT_FOREACH_END(_dummy) \ - }} - -#define VIRT_HASH_CURRENT_KEY_INFO(_ht, _pos, _idx, _info) \ - do { \ - _info.type =3D zend_hash_get_current_key_ex(_ht, &_info.name, &_info.l= ength, &_idx, 0, &_pos); \ - } while(0) - -#endif /* PHP_MAJOR_VERSION < 7 */ - /* ZEND thread safe per request globals definition */ int le_libvirt_connection; int le_libvirt_domain; diff --git a/src/libvirt-php.h b/src/libvirt-php.h index f9dec09..d25fa94 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -121,10 +121,89 @@ typedef uint64_t arch_uint; =20 #if PHP_MAJOR_VERSION >=3D 7 typedef size_t strsize_t; + +#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ + if ((_state =3D (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le= )) =3D=3D NULL) { \ + RETURN_FALSE; \ + } + +#define VIRT_RETVAL_STRING(_str) \ + RETVAL_STRING(_str) +#define VIRT_RETVAL_STRINGL(_str, _len) \ + RETVAL_STRINGL(_str, _len) +#define VIRT_RETURN_STRING(_str) \ + RETURN_STRING(_str) +#define VIRT_RETURN_STRINGL(_str, _len) \ + RETURN_STRINGL(_str, _len) +#define VIRT_ZVAL_STRINGL(_zv, _str, _len) \ + ZVAL_STRINGL(_zv, _str, _len) +#define VIRT_ADD_INDEX_STRING(_arg, _idx, _str) \ + add_index_string(_arg, _idx, _str) +#define VIRT_ADD_NEXT_INDEX_STRING(_arg, _str) \ + add_next_index_string(_arg, _str) +#define VIRT_ADD_ASSOC_STRING(_arg, _key, _str) \ + add_assoc_string(_arg, _key, _str) +#define VIRT_ADD_ASSOC_STRING_EX(_arg, _key, _key_len, _value) \ + add_assoc_string_ex(_arg, _key, _key_len, _value) + +#define VIRT_FOREACH(_ht, _pos, _zv) \ + for (zend_hash_internal_pointer_reset_ex(_ht, &_pos); \ + (_zv =3D zend_hash_get_current_data_ex(_ht, &_pos)) !=3D NULL; \ + zend_hash_move_forward_ex(_ht, &_pos)) \ + +#define VIRT_FOREACH_END(_dummy) + +#define VIRT_HASH_CURRENT_KEY_INFO(_ht, _pos, _idx, _info) \ + do { \ + zend_string *tmp_key_info; \ + _info.type =3D zend_hash_get_current_key_ex(_ht, &tmp_key_info, &_idx,= &_pos); \ + _info.name =3D ZSTR_VAL(tmp_key_info); \ + _info.length =3D ZSTR_LEN(tmp_key_info); \ + } while(0) + #else /* PHP_MAJOR_VERSION < 7 */ 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); + +#define VIRT_RETVAL_STRING(_str) \ + RETVAL_STRING(_str, 1) +#define VIRT_RETVAL_STRINGL(_str, _len) \ + RETVAL_STRINGL(_str, _len, 1) +#define VIRT_RETURN_STRING(_str) \ + RETURN_STRING(_str, 1) +#define VIRT_RETURN_STRINGL(_str, _len) \ + RETURN_STRINGL(_str, _len, 1) +#define VIRT_ZVAL_STRINGL(_zv, _str, _len) \ + ZVAL_STRINGL(_zv, _str, _len, 1) +#define VIRT_ADD_INDEX_STRING(_arg, _idx, _str) \ + add_index_string(_arg, _idx, _str, 1) +#define VIRT_ADD_NEXT_INDEX_STRING(_arg, _str) \ + add_next_index_string(_arg, _str, 1) +#define VIRT_ADD_ASSOC_STRING(_arg, _key, _str) \ + add_assoc_string(_arg, _key, _str, 1) +#define VIRT_ADD_ASSOC_STRING_EX(_arg, _key, _key_len, _value) \ + add_assoc_string_ex(_arg, _key, _key_len, _value, 1) + +#define VIRT_FOREACH(_ht, _pos, _zv) \ + { \ + zval **pzv =3D &_zv; \ + for (zend_hash_internal_pointer_reset_ex(_ht, &_pos); \ + zend_hash_get_current_data_ex(_ht, (void **) &pzv, &_pos) =3D=3D = SUCCESS; \ + zend_hash_move_forward_ex(_ht, &_pos)) { \ + _zv =3D *pzv; + +#define VIRT_FOREACH_END(_dummy) \ + }} + +#define VIRT_HASH_CURRENT_KEY_INFO(_ht, _pos, _idx, _info) \ + do { \ + _info.type =3D zend_hash_get_current_key_ex(_ht, &_info.name, &_info.l= ength, &_idx, 0, &_pos); \ + } while(0) + #endif /* PHP_MAJOR_VERSION < 7 */ =20 typedef struct tTokenizer { --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498159318621263.8890001922483; Thu, 22 Jun 2017 12:21:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5ADC63E1B; Thu, 22 Jun 2017 19:21:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A885C5C542; Thu, 22 Jun 2017 19:21:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4D27C41F63; Thu, 22 Jun 2017 19:21:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJED5q013738 for ; Thu, 22 Jun 2017 15:14:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id BDD6968D46; Thu, 22 Jun 2017 19:14:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7B2B65E9B for ; Thu, 22 Jun 2017 19:14:11 +0000 (UTC) Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com [209.85.220.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0AE7C0587C3 for ; Thu, 22 Jun 2017 19:14:10 +0000 (UTC) Received: by mail-qk0-f179.google.com with SMTP id d14so19992489qkb.1 for ; Thu, 22 Jun 2017 12:14:10 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:09 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D5ADC63E1B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D5ADC63E1B Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="qlNLOLL+" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C0AE7C0587C3 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C0AE7C0587C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=b7KSNtFFFGH3dEO3l0cMATfzFx3d1NcKPlrtZq7/YQs=; b=qlNLOLL+/7PGqlQg7XYoPrZy0ms9sVpTtwJ+7gEV4757l1w6UpVNmh7RpiDS2LhKiW K+ESL/I3aqPR4TM3yxUUPMbKg4CXDa8v3CzasbMy5VneeBowZgAmDIxcFVBiJ2wsovie p6JyxUjAN/BWBYQK/xv3gm30aY3mJXubNp9XBsIQ4u+eiiH2hxMpp12M+IQY4N8JRddL pIlb1mgFf5wL/JeERQe3zbqohn9Go5Gi8fsuyhSVdiSBCLt9b787sd44GdZVwm7ifyML OPaf/k3A0yzvW8D0mjHvyg8zziuKgI57S2/UUHE5Kr01R5osYt0M8ZZtJM/mD4tDg2HZ TgBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=b7KSNtFFFGH3dEO3l0cMATfzFx3d1NcKPlrtZq7/YQs=; b=U8+OTh/TNz0vX+UlxUZ2D3gXiSmXFoLWjdhWj9FDscQQ278Q7jTmTwWAcReafaGMfk 0FgOAiOo+F8IpHHGAmFxaevyxFCjgKZZEnyIBAsW3ZGCy9Lnaqim/X90e3IJagweQOMB DKDedrCqSadkKcg1xiYyOJMTkpYhnaNDqM4hHFg09LXqJAQmmXqW00xuQ0D0BzftmsWe TVMvrqY17APahQNGeXd1c40sliI6Uthqjx7QVfpigsmdfU10ZdE6ZFmgZlS33JWdGjv9 j5yxzAxmdpIPE3U9/E+tRdZ7Cnyszuap6//5w9QsrTSRJgy5jaWO46oZlvI9Ew71RhZG 8bBA== X-Gm-Message-State: AKS2vOx93p8Z5qr9FZG5+q62gQFkRIIh4rykQbVoSRHWUmmOsc64BB2E /+JOoRc6f+sLvs8UCAjhDQ== X-Received: by 10.55.71.20 with SMTP id u20mr4596733qka.66.1498158849962; Thu, 22 Jun 2017 12:14:09 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:02 -0400 Message-Id: <20170622191407.15570-3-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Jun 2017 19:14:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Jun 2017 19:14:11 +0000 (UTC) for IP:'209.85.220.179' DOMAIN:'mail-qk0-f179.google.com' HELO:'mail-qk0-f179.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.369 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.179 mail-qk0-f179.google.com 209.85.220.179 mail-qk0-f179.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 2/7] add wrappers for PHP resource handling. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 22 Jun 2017 19:21:56 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There were quite a few places in code that were using preprocessor directives to handle differences in dealing with resources between PHP versions which can be dealt with by using typdefs and macros. --- src/libvirt-php.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/libvirt-php.h b/src/libvirt-php.h index d25fa94..0422661 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -121,6 +121,19 @@ typedef uint64_t arch_uint; =20 #if PHP_MAJOR_VERSION >=3D 7 typedef size_t strsize_t; +typedef zend_resource virt_resource; + +#define VIRT_RETURN_RESOURCE(_resource) \ + RETVAL_RES(_resource) + +#define VIRT_REGISTER_RESOURCE(_resource, _le_resource) \ + VIRT_RETURN_RESOURCE(zend_register_resource(_resource, _le_resource)) + +#define VIRT_REGISTER_LIST_RESOURCE(_name) do { \ + zval zret; \ + ZVAL_RES(&zret, zend_register_resource(res_##_name, le_libvirt_##_name= )); \ + add_next_index_zval(return_value, &zret); \ + } while(0) =20 #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ if ((_state =3D (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le= )) =3D=3D NULL) { \ @@ -165,6 +178,20 @@ typedef size_t strsize_t; typedef int strsize_t; typedef long zend_long; typedef unsigned long zend_ulong; +typedef zend_rsrc_list_entry virt_resource; + +#define VIRT_RETURN_RESOURCE(_resource) \ + RETVAL_RESOURCE((long) _resource) + +#define VIRT_REGISTER_RESOURCE(_resource, _le_resource) \ + ZEND_REGISTER_RESOURCE(return_value, _resource, _le_resource) + +#define VIRT_REGISTER_LIST_RESOURCE(_name) do { \ + zval *zret; \ + ALLOC_INIT_ZVAL(zret); \ + ZEND_REGISTER_RESOURCE(zret, res_##_name, le_libvirt_##_name); \ + add_next_index_zval(return_value, zret); \ + } while(0) =20 #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498158935780428.973919263967; Thu, 22 Jun 2017 12:15:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 209977C82E; Thu, 22 Jun 2017 19:15:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0C1D17103; Thu, 22 Jun 2017 19:15:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A665F184383E; Thu, 22 Jun 2017 19:15:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJEFaG013759 for ; Thu, 22 Jun 2017 15:14:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 784E65C7A7; Thu, 22 Jun 2017 19:14:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 725915C7A5 for ; Thu, 22 Jun 2017 19:14:13 +0000 (UTC) Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E4937D4E0 for ; Thu, 22 Jun 2017 19:14:11 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id r62so20074397qkf.0 for ; Thu, 22 Jun 2017 12:14:11 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:10 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 209977C82E Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 209977C82E Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="oJD/4N9d" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8E4937D4E0 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8E4937D4E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=q7U9u18goEWYiov0uqwuJfW67Bkd4aDTwBPP92Ly2S4=; b=oJD/4N9d7VS+nXd9GmonAcFwrgz2cL8vzpSiCXdcu5vVUQ8j/mrrma3+DyMKG3fhvo 0fVKx4jtb5aQ0F/MRJR7mRVo4eE0Rsay0covkg+RA0ApWiMYpwbmoN6StskoghM8KgLR uipFxTEClZTXbu0Ctw4REWXYq4p8I9affBPTeAmgucoF0gZxw3znag1Bd49zOUZ/nrq1 TEoG6IdYBr1kOQgbrPk95IVjZzcg2UrHMKwaLXkN7Fy6xdApVF79Qjimydeo+mztWKEH 2m+tu2p6oJrypPBgPRwej3b+iRywBTzYm+kXrBlp4GekPG1z62C6E50Gd0AOmNIBI3ci IJUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=q7U9u18goEWYiov0uqwuJfW67Bkd4aDTwBPP92Ly2S4=; b=eweE5DBKZUJpGVL14nqC+PFN8Wih8YR3aI+LfUA8L5uvxigfjhoEDcrT0tkec13+qJ kGRyCAW/hsl0xzIu2PPZir7FaqJIbMbYNPMrpx9MC1/M6LnmkKyoRPlkdFmdlGQJ4nM7 4N5iM1KvOzqFZ454r1oyaxxooH2munw0YY07q/p0TBExKVAOF8w0RsQZDosb2NjmpcE6 RIxAM83jbx9ePdmX2COS/oKqfCxnURGqFqq0P1c9jXHg2lH3yk3yRRHoaKL0vgNYkZrs ZnAcoGl6mgzBHzlrALBRvtXxAA/AFJswtqZ+Njj51pTiHznS1/p7gnuJkhTqJOciph/n rxdg== X-Gm-Message-State: AKS2vOxLeSt3DKV2ID4gPXf4nKmB5VZAOzykTwaeKyWos2wxFJH0xnjP CmaBT2wKAmFvKkwpQ/IrvQ== X-Received: by 10.55.59.10 with SMTP id i10mr4778227qka.15.1498158850480; Thu, 22 Jun 2017 12:14:10 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:03 -0400 Message-Id: <20170622191407.15570-4-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 22 Jun 2017 19:14:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 22 Jun 2017 19:14:11 +0000 (UTC) for IP:'209.85.220.176' DOMAIN:'mail-qk0-f176.google.com' HELO:'mail-qk0-f176.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -0.611 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.220.176 mail-qk0-f176.google.com 209.85.220.176 mail-qk0-f176.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 3/7] update code to use resource handling macros X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 22 Jun 2017 19:15:33 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/libvirt-php.c | 270 ++++++++++++--------------------------------------= ---- 1 file changed, 59 insertions(+), 211 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index ece98d6..73466f1 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1368,13 +1368,7 @@ int is_local_connection(virConnectPtr conn) } =20 /* Destructor for connection resource */ -static void php_libvirt_connection_dtor( -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *rsrc -#else - zend_rsrc_list_entry *rsrc -#endif - TSRMLS_DC) +static void php_libvirt_connection_dtor(virt_resource *rsrc TSRMLS_DC) { php_libvirt_connection *conn =3D (php_libvirt_connection *)rsrc->ptr; int rv =3D 0; @@ -1398,13 +1392,7 @@ static void php_libvirt_connection_dtor( } =20 /* Destructor for domain resource */ -static void php_libvirt_domain_dtor( -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *rsrc -#else - zend_rsrc_list_entry *rsrc -#endif - TSRMLS_DC) +static void php_libvirt_domain_dtor(virt_resource *rsrc TSRMLS_DC) { php_libvirt_domain *domain =3D (php_libvirt_domain *)rsrc->ptr; int rv =3D 0; @@ -1432,13 +1420,7 @@ static void php_libvirt_domain_dtor( } =20 /* Destructor for stream resource */ -static void php_libvirt_stream_dtor( -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *rsrc -#else - zend_rsrc_list_entry *rsrc -#endif - TSRMLS_DC) +static void php_libvirt_stream_dtor(virt_resource *rsrc TSRMLS_DC) { php_libvirt_stream *stream =3D (php_libvirt_stream *)rsrc->ptr; int rv =3D 0; @@ -1465,13 +1447,7 @@ static void php_libvirt_stream_dtor( } =20 /* Destructor for storagepool resource */ -static void php_libvirt_storagepool_dtor( -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *rsrc -#else - zend_rsrc_list_entry *rsrc -#endif - TSRMLS_DC) +static void php_libvirt_storagepool_dtor(virt_resource *rsrc TSRMLS_DC) { php_libvirt_storagepool *pool =3D (php_libvirt_storagepool *)rsrc->ptr; int rv =3D 0; @@ -1498,13 +1474,7 @@ static void php_libvirt_storagepool_dtor( } =20 /* Destructor for volume resource */ -static void php_libvirt_volume_dtor( -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *rsrc -#else - zend_rsrc_list_entry *rsrc -#endif - TSRMLS_DC) +static void php_libvirt_volume_dtor(virt_resource *rsrc TSRMLS_DC) { php_libvirt_volume *volume =3D (php_libvirt_volume *)rsrc->ptr; int rv =3D 0; @@ -1531,13 +1501,7 @@ static void php_libvirt_volume_dtor( } =20 /* Destructor for network resource */ -static void php_libvirt_network_dtor( -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *rsrc -#else - zend_rsrc_list_entry *rsrc -#endif - TSRMLS_DC) +static void php_libvirt_network_dtor(virt_resource *rsrc TSRMLS_DC) { php_libvirt_network *network =3D (php_libvirt_network *)rsrc->ptr; int rv =3D 0; @@ -1564,13 +1528,7 @@ static void php_libvirt_network_dtor( } =20 /* Destructor for nodedev resource */ -static void php_libvirt_nodedev_dtor( -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *rsrc -#else - zend_rsrc_list_entry *rsrc -#endif - TSRMLS_DC) +static void php_libvirt_nodedev_dtor(virt_resource *rsrc TSRMLS_DC) { php_libvirt_nodedev *nodedev =3D (php_libvirt_nodedev *)rsrc->ptr; int rv =3D 0; @@ -1597,13 +1555,7 @@ static void php_libvirt_nodedev_dtor( } =20 /* Destructor for snapshot resource */ -static void php_libvirt_snapshot_dtor( -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *rsrc -#else - zend_rsrc_list_entry *rsrc -#endif - TSRMLS_DC) +static void php_libvirt_snapshot_dtor(virt_resource *rsrc TSRMLS_DC) { php_libvirt_snapshot *snapshot =3D (php_libvirt_snapshot *)rsrc->ptr; int rv =3D 0; @@ -4198,11 +4150,8 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) =20 DPRINTF("%s: domain name =3D '%s', returning %p\n", PHPFUNC, name, res= _domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -4236,11 +4185,8 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) =20 DPRINTF("%s: domain UUID =3D '%s', returning %p\n", PHPFUNC, uuid, res= _domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -4304,11 +4250,8 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) =20 DPRINTF("%s: domain UUID string =3D '%s', returning %p\n", PHPFUNC, uu= id, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -4342,11 +4285,8 @@ PHP_FUNCTION(libvirt_stream_create) res_stream->conn =3D conn; =20 resource_change_counter(INT_RESOURCE_STREAM, conn->conn, res_stream->s= tream, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_stream, le_libvirt_s= tream)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_stream, le_libvirt_stream); -#endif + + VIRT_REGISTER_RESOURCE(res_stream, le_libvirt_stream); } =20 /* @@ -4533,11 +4473,8 @@ PHP_FUNCTION(libvirt_domain_lookup_by_id) =20 DPRINTF("%s: domain id =3D '%d', returning %p\n", PHPFUNC, (int)id, re= s_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -5644,11 +5581,8 @@ PHP_FUNCTION(libvirt_domain_new) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -5880,11 +5814,8 @@ PHP_FUNCTION(libvirt_domain_change_memory) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -5965,11 +5896,8 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -6618,11 +6546,8 @@ PHP_FUNCTION(libvirt_domain_define_xml) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -6656,11 +6581,8 @@ PHP_FUNCTION(libvirt_domain_create_xml) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->d= omain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -7447,11 +7369,8 @@ PHP_FUNCTION(libvirt_domain_migrate) =20 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 >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_domain, le_libvirt_d= omain)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_domain, le_libvirt_domain); -#endif + + VIRT_REGISTER_RESOURCE(res_domain, le_libvirt_domain); } =20 /* @@ -7547,11 +7466,8 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) =20 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 >=3D 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 + + VIRT_REGISTER_RESOURCE(res_snapshot, le_libvirt_snapshot); } =20 /* @@ -7583,11 +7499,8 @@ PHP_FUNCTION(libvirt_domain_snapshot_create) =20 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 >=3D 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 + + VIRT_REGISTER_RESOURCE(res_snapshot, le_libvirt_snapshot); } =20 /* @@ -7737,11 +7650,8 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) =20 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 >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_sto= ragepool)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_pool, le_libvirt_storagepool); -#endif + + VIRT_REGISTER_RESOURCE(res_pool, le_libvirt_storagepool); } =20 /* Storagepool functions */ @@ -7773,11 +7683,8 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_volume) =20 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 >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_sto= ragepool)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_pool, le_libvirt_storagepool); -#endif + + VIRT_REGISTER_RESOURCE(res_pool, le_libvirt_storagepool); } =20 /* @@ -7881,11 +7788,8 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, pool->conn->conn, res_vol= ume->volume, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_volume, le_libvirt_v= olume)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_volume, le_libvirt_volume); -#endif + + VIRT_REGISTER_RESOURCE(res_volume, le_libvirt_volume); } =20 /* @@ -7922,11 +7826,8 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, conn->conn, res_volume->v= olume, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_volume, le_libvirt_v= olume)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_volume, le_libvirt_volume); -#endif + + VIRT_REGISTER_RESOURCE(res_volume, le_libvirt_volume); } =20 /* @@ -8079,11 +7980,8 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, pool->conn->conn, res_vol= ume->volume, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_volume, le_libvirt_v= olume)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_volume, le_libvirt_volume); -#endif + + VIRT_REGISTER_RESOURCE(res_volume, le_libvirt_volume); } =20 /* @@ -8132,11 +8030,8 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, pool->conn->conn, res_vol= ume->volume, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_volume, le_libvirt_v= olume)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_volume, le_libvirt_volume); -#endif + + VIRT_REGISTER_RESOURCE(res_volume, le_libvirt_volume); } =20 /* @@ -8361,11 +8256,8 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_uuid_stri= ng) =20 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 >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_sto= ragepool)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_pool, le_libvirt_storagepool); -#endif + + VIRT_REGISTER_RESOURCE(res_pool, le_libvirt_storagepool); } =20 /* @@ -8443,11 +8335,8 @@ PHP_FUNCTION(libvirt_storagepool_define_xml) =20 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 >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_sto= ragepool)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_pool, le_libvirt_storagepool); -#endif + + VIRT_REGISTER_RESOURCE(res_pool, le_libvirt_storagepool); } =20 /* @@ -8883,11 +8772,6 @@ PHP_FUNCTION(libvirt_list_domain_resources) { php_libvirt_connection *conn =3D NULL; zval *zconn; -#if PHP_MAJOR_VERSION >=3D 7 - zval zdomain; -#else - zval *zdomain; -#endif int count =3D -1; int expectedcount =3D -1; int *ids; @@ -8917,15 +8801,8 @@ PHP_FUNCTION(libvirt_list_domain_resources) =20 res_domain->conn =3D conn; =20 + VIRT_REGISTER_LIST_RESOURCE(domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_d= omain->domain, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(&zdomain, zend_register_resource(res_domain, le_libvi= rt_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 } } efree(ids); @@ -8947,14 +8824,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) =20 res_domain->conn =3D conn; =20 -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(&zdomain, zend_register_resource(res_domain, le_libvi= rt_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 + VIRT_REGISTER_LIST_RESOURCE(domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_d= omain->domain, 1 TSRMLS_CC); } free(names[i]); @@ -9091,11 +8961,6 @@ PHP_FUNCTION(libvirt_list_all_networks) { php_libvirt_connection *conn =3D NULL; zval *zconn; -#if PHP_MAJOR_VERSION >=3D 7 - zval znetwork; -#else - zval *znetwork; -#endif zend_long flags =3D VIR_CONNECT_LIST_NETWORKS_ACTIVE | VIR_CONNECT_LIST_NETWORKS_INACTIVE; int count =3D -1; @@ -9119,17 +8984,9 @@ PHP_FUNCTION(libvirt_list_all_networks) res_network->network =3D network; res_network->conn =3D conn; =20 + VIRT_REGISTER_LIST_RESOURCE(network); resource_change_counter(INT_RESOURCE_NETWORK, conn->conn, res_network->network, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(&znetwork, zend_register_resource(res_network, - le_libvirt_network)); - add_next_index_zval(return_value, &znetwork); -#else - ALLOC_INIT_ZVAL(znetwork); - ZEND_REGISTER_RESOURCE(znetwork, res_network, le_libvirt_network); - add_next_index_zval(return_value, znetwork); -#endif } } =20 @@ -9267,11 +9124,8 @@ PHP_FUNCTION(libvirt_nodedev_get) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_dev->device); resource_change_counter(INT_RESOURCE_NODEDEV, conn->conn, res_dev->dev= ice, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_dev, le_libvirt_node= dev)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_dev, le_libvirt_nodedev); -#endif + + VIRT_REGISTER_RESOURCE(res_dev, le_libvirt_nodedev); } =20 /* @@ -9534,11 +9388,8 @@ PHP_FUNCTION(libvirt_network_define_xml) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_net->network); resource_change_counter(INT_RESOURCE_NETWORK, conn->conn, res_net->net= work, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_net, le_libvirt_netw= ork)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_net, le_libvirt_network); -#endif + + VIRT_REGISTER_RESOURCE(res_net, le_libvirt_network); } =20 /* @@ -9591,11 +9442,8 @@ PHP_FUNCTION(libvirt_network_get) =20 DPRINTF("%s: returning %p\n", PHPFUNC, res_net->network); resource_change_counter(INT_RESOURCE_NETWORK, conn->conn, res_net->net= work, 1 TSRMLS_CC); -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, zend_register_resource(res_net, le_libvirt_netw= ork)); -#else - ZEND_REGISTER_RESOURCE(return_value, res_net, le_libvirt_network); -#endif + + VIRT_REGISTER_RESOURCE(res_net, le_libvirt_network); } =20 /* --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498158929907828.1095168150182; Thu, 22 Jun 2017 12:15:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B862C07454E; Thu, 22 Jun 2017 19:15:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B67BD68D46; Thu, 22 Jun 2017 19:15:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 388BC184383E; Thu, 22 Jun 2017 19:15:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJEFqO013758 for ; Thu, 22 Jun 2017 15:14:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 76E0E600C8; Thu, 22 Jun 2017 19:14:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71B8219658 for ; Thu, 22 Jun 2017 19:14:13 +0000 (UTC) Received: from mail-qk0-f180.google.com (mail-qk0-f180.google.com [209.85.220.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0375843A25 for ; Thu, 22 Jun 2017 19:14:12 +0000 (UTC) Received: by mail-qk0-f180.google.com with SMTP id d14so19992947qkb.1 for ; Thu, 22 Jun 2017 12:14:11 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:10 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0B862C07454E Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0B862C07454E Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="NgOFnc+m" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0375843A25 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0375843A25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=3F+DFXvokWcMfxyG5gOV68QhQNSc+iMButqJULfCykc=; b=NgOFnc+mrKcvu176bXPJRZjggCgEvwMO1Jd7B9Xp+p6qCbwepYJYPHuuWxJVdvV+GP leMUPl4Tls71o1t6ykUSOUl6E7zQih5UvHA5cN/z91igJhd/t/PgCADKm31FzouiJ6wz 9+B9GEH6bwZ3noeplylRlk8sQUmZ0Y11zpvsrdGQVcLHoEQcOh9K3648Fv35Zel45hDk u6AU8Wwz0fZI7i1WVoUeOKoEzV2CWe1fZ8fTMyauYf6a2rxRYiypQnudc7xE4fkqbx7U fiJGwbbUcmXoPPUbefKgMJ7aAeysPDlJKnnXG3iuC+n0/e557R1LFB7Q3IAEm534z+ey P8Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=3F+DFXvokWcMfxyG5gOV68QhQNSc+iMButqJULfCykc=; b=GG832g6ePP9GJJ/YBdObjCfT/zj81x/DRRbUm+NYaxWJvgy37Fl/F5AbIb5/oDesIs ed5iazLSbES3SPhUpQF9GwkslvvtQ7o+dESyqbXa9DRQmZ0FkDWljtxkCCuJLYgtCUg5 jSc02yfp5mdHpRj/1ey58jJIbOAXjljOwTq5ASja/B9rNwVEDCe7io6cjoZvnY8AxKzR YShA+gfH8zvs+B65pCyMg56NyqYj1ZThPbiS+mUI4M865vX0RbdDlil6F+98x7Lc1zXQ WlTzqCEMWsMKgX1YQ7jsVtbQA22RoRuIO7JPZoUa2HC4D7voRQRcq80yLBBkz4O8z+un UUtw== X-Gm-Message-State: AKS2vOxZzejWxpTRtt/l3nHd06t6ddWISHtRnbXf7//xvimJclYlNkji k9jNIrty5iiqk/bbxuj/eA== X-Received: by 10.55.155.141 with SMTP id d135mr4535273qke.11.1498158851021; Thu, 22 Jun 2017 12:14:11 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:04 -0400 Message-Id: <20170622191407.15570-5-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 22 Jun 2017 19:14:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 22 Jun 2017 19:14:12 +0000 (UTC) for IP:'209.85.220.180' DOMAIN:'mail-qk0-f180.google.com' HELO:'mail-qk0-f180.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.369 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.180 mail-qk0-f180.google.com 209.85.220.180 mail-qk0-f180.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 4/7] fix libvirt_doman_get_connect implementation. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Jun 2017 19:15:28 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function must bump refcount of the returned resource because it just returns the one that was registered with libvirt_connect call, otherwise it would sefgault if calling code called this function more than once and the return of the first call would be GCd before the 2nd call. --- src/libvirt-php.c | 18 ++++++------------ src/libvirt-php.h | 14 +++++++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 73466f1..89b17bb 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2177,13 +2177,8 @@ PHP_FUNCTION(libvirt_connect) resource_change_counter(INT_RESOURCE_CONNECTION, NULL, conn->conn, 1 T= SRMLS_CC); DPRINTF("%s: Connection to %s established, returning %p\n", PHPFUNC, u= rl, conn->conn); =20 -#if PHP_MAJOR_VERSION >=3D 7 - conn->resource_id =3D zend_register_resource(conn, le_libvirt_connecti= on); - ZVAL_RES(return_value, conn->resource_id); -#else - ZEND_REGISTER_RESOURCE(return_value, conn, le_libvirt_connection); - conn->resource_id =3D Z_LVAL_P(return_value); -#endif + VIRT_REGISTER_RESOURCE(conn, le_libvirt_connection); + conn->resource =3D VIRT_RESOURCE_HANDLE(return_value); } =20 /* @@ -7216,11 +7211,10 @@ PHP_FUNCTION(libvirt_domain_get_connect) conn =3D domain->conn; if (conn->conn =3D=3D NULL) RETURN_FALSE; -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_RES(return_value, conn->resource_id); -#else - RETURN_RESOURCE(conn->resource_id); -#endif + + VIRT_RETURN_RESOURCE(conn->resource); + /* since we're returning already registered resource, bump refcount */ + Z_ADDREF_P(return_value); } =20 /* diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 0422661..ed6a8bc 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -122,6 +122,7 @@ typedef uint64_t arch_uint; #if PHP_MAJOR_VERSION >=3D 7 typedef size_t strsize_t; typedef zend_resource virt_resource; +typedef virt_resource *virt_resource_handle; =20 #define VIRT_RETURN_RESOURCE(_resource) \ RETVAL_RES(_resource) @@ -135,6 +136,9 @@ typedef zend_resource virt_resource; add_next_index_zval(return_value, &zret); \ } while(0) =20 +#define VIRT_RESOURCE_HANDLE(_resource) \ + Z_RES_P(_resource) + #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ if ((_state =3D (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le= )) =3D=3D NULL) { \ RETURN_FALSE; \ @@ -179,6 +183,7 @@ typedef int strsize_t; typedef long zend_long; typedef unsigned long zend_ulong; typedef zend_rsrc_list_entry virt_resource; +typedef long virt_resource_handle; =20 #define VIRT_RETURN_RESOURCE(_resource) \ RETVAL_RESOURCE((long) _resource) @@ -193,6 +198,9 @@ typedef zend_rsrc_list_entry virt_resource; add_next_index_zval(return_value, zret); \ } while(0) =20 +#define VIRT_RESOURCE_HANDLE(_resource) \ + Z_LVAL_P(_resource) + #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); =20 @@ -298,11 +306,7 @@ typedef struct tVMNetwork { /* Libvirt-php types */ typedef struct _php_libvirt_connection { virConnectPtr conn; -#if PHP_MAJOR_VERSION >=3D 7 - zend_resource *resource_id; -#else - long resource_id; -#endif + virt_resource_handle resource; } php_libvirt_connection; =20 typedef struct _php_libvirt_stream { --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498159255996222.46044077425097; Thu, 22 Jun 2017 12:20:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 526EE14287F; Thu, 22 Jun 2017 19:20:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4C6568D80; Thu, 22 Jun 2017 19:20:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AFA181804753; Thu, 22 Jun 2017 19:20:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJEGds013768 for ; Thu, 22 Jun 2017 15:14:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id B620A1883B; Thu, 22 Jun 2017 19:14:16 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADE886EE2C for ; Thu, 22 Jun 2017 19:14:13 +0000 (UTC) Received: from mail-qk0-f173.google.com (mail-qk0-f173.google.com [209.85.220.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56EB8C0587D8 for ; Thu, 22 Jun 2017 19:14:12 +0000 (UTC) Received: by mail-qk0-f173.google.com with SMTP id d14so19993078qkb.1 for ; Thu, 22 Jun 2017 12:14:12 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:11 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 526EE14287F Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 526EE14287F Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="XdJCm5er" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 56EB8C0587D8 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 56EB8C0587D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=H3AxBCMnUpVRW4Aasn+abgGuCHWvaWTxmF2FUPK3nhE=; b=XdJCm5erUUnZQnTho5RbxoqG7cBP7h/om8OgP86ia8R1SZkwIfy67j/0al3S6b1Pf4 xL7woTcU5Rl5/jQLIq1EaYNlJMO9dgthCnIkiUd9ygeiu/yYtsmHdElpH/BIyDmW3sY1 g7J74PL/poHv/oPM3Nm9Bt+tvY9aSgdCY5OeI6bvZyr+sgv7YpJFR71/ncESvO/mitEI 0yCZEMB7HYtU3B+p04C9MnrU+X/aMfjw9YBs2w2eKBnfYbWM5lxzEMA14f58mYd2Kdjr phdNA4vcoBn2rtoLCWbgeBHcdU1I/pThauzd6bO3MpzXn6yyYLUKdtE9cd8yIl7P9zk4 OjRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=H3AxBCMnUpVRW4Aasn+abgGuCHWvaWTxmF2FUPK3nhE=; b=c0vgF+tWn04AKF+O7O9kQwJ9p87f20pe//Xk6K52UqqGriz2zPTLNbNEM0E+J7Knm5 uWOCLoCUb6r12NZou6ZKxONQNiCSYf9bjLnuwU9XkEM2lrVCz/aM1hpIIWpRdKJWd3qg 02OWhVfYR9Od0ADmUCN0cxrMkC3gaZa9Z5A4GsxpCkfeOWs5hvTGXsYeI/B3WpIX/rhP kD7xeLm3fXvK2ogVhja1oZBVUz2H0lhZTfjgU9cE4OT35fgle/boJIrUSOkxZHzvVzKe vHaL32GkOyqRJCzc85M4AWBnQCywNxZ11pVCVJJ3gLthBV7X4aDI/SI8GSKRKxpImyqS UZSw== X-Gm-Message-State: AKS2vOwrk3C6q9lrviDtmtlLZWQkZBS8MiApeMSb1vD+I02rKDfG/W10 NuE2RWOTxTW3ET5mh4ouJw== X-Received: by 10.55.151.69 with SMTP id z66mr4958263qkd.90.1498158851415; Thu, 22 Jun 2017 12:14:11 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:05 -0400 Message-Id: <20170622191407.15570-6-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Jun 2017 19:14:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Jun 2017 19:14:12 +0000 (UTC) for IP:'209.85.220.173' DOMAIN:'mail-qk0-f173.google.com' HELO:'mail-qk0-f173.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.369 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.173 mail-qk0-f173.google.com 209.85.220.173 mail-qk0-f173.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 5/7] add and use VIRT_ARRAY_INIT macro X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 22 Jun 2017 19:20:55 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This macro handles differences in array initialization between PHP7 and older. --- src/libvirt-php.c | 96 ++++++++-------------------------------------------= ---- src/libvirt-php.h | 11 +++++++ 2 files changed, 24 insertions(+), 83 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 89b17bb..7784450 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2265,11 +2265,8 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) =20 array_init(return_value); for (i =3D 0; i < 2; i++) { -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr, zarr; -#else zval *arr; -#endif + if (i > 0) #ifdef EXTWIN Sleep(1000); @@ -2282,12 +2279,7 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) RETURN_FALSE; } =20 -#if PHP_MAJOR_VERSION >=3D 7 - arr =3D &zarr; -#else - ALLOC_INIT_ZVAL(arr); -#endif - array_init(arr); + VIRT_ARRAY_INIT(arr); =20 for (j =3D 0; j < nparams; j++) { DPRINTF("%s: Field %s has value of %llu\n", __FUNCTION__, para= ms[j].field, params[j].value); @@ -2333,11 +2325,7 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) int done =3D 0; int i, j, numCpus; time_t startTime =3D 0; -#if PHP_MAJOR_VERSION >=3D 7 - zval *time_array, ztime_array; -#else zval *time_array; -#endif =20 GET_CONNECTION_FROM_ARGS("r|l", &zconn, &avg); =20 @@ -2366,33 +2354,18 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cp= u) iter =3D 0; done =3D 0; while (!done) { -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr, zarr; - arr =3D &zarr; -#else zval *arr; - ALLOC_INIT_ZVAL(arr); -#endif + VIRT_ARRAY_INIT(arr); =20 - array_init(arr); for (i =3D 0; i < numCpus; i++) { -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr2, zarr2; -#else zval *arr2; -#endif =20 if (virNodeGetCPUStats(conn->conn, i, params, &nparams, 0) != =3D 0) { set_error("Unable to get node cpu stats" TSRMLS_CC); RETURN_FALSE; } =20 -#if PHP_MAJOR_VERSION >=3D 7 - arr2 =3D &zarr2; -#else - ALLOC_INIT_ZVAL(arr2); -#endif - array_init(arr2); + VIRT_ARRAY_INIT(arr2); =20 for (j =3D 0; j < nparams; j++) add_assoc_long(arr2, params[j].field, params[j].value); @@ -2416,13 +2389,7 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) iter++; } =20 -#if PHP_MAJOR_VERSION >=3D 7 - time_array =3D &ztime_array; -#else - ALLOC_INIT_ZVAL(time_array); -#endif - array_init(time_array); - + VIRT_ARRAY_INIT(time_array); add_assoc_long(time_array, "start", startTime); add_assoc_long(time_array, "finish", time(NULL)); add_assoc_long(time_array, "duration", time(NULL) - startTime); @@ -2539,28 +2506,15 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) snprintf(tmp, sizeof(tmp), "//capabilities/guest/arch[@name=3D= \"%s\"]/domain/@type", ret[i]); char **ret2 =3D get_array_from_xpath(caps, tmp, &num2); if (ret2 !=3D NULL) { -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr2, zarr2; - arr2 =3D &zarr2; -#else zval *arr2; - ALLOC_INIT_ZVAL(arr2); -#endif - array_init(arr2); + VIRT_ARRAY_INIT(arr2); =20 for (j =3D 0; j < num2; j++) { int num3, k; char tmp2[1024] =3D { 0 }; - - /* Common */ -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr3, zarr3; - arr3 =3D &zarr3; -#else zval *arr3; - ALLOC_INIT_ZVAL(arr3); -#endif - array_init(arr3); + + VIRT_ARRAY_INIT(arr3); =20 snprintf(tmp2, sizeof(tmp2), "//capabilities/guest/arc= h[@name=3D\"%s\"]/machine", ret[i]); @@ -2582,15 +2536,8 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) if (numTmp =3D=3D NULL) { VIRT_ADD_ASSOC_STRING(arr2, key, ret3[k]); } else { -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr4, zarr4; - arr4 =3D &zarr4; -#else zval *arr4; - ALLOC_INIT_ZVAL(arr4); -#endif - array_init(arr4); - + VIRT_ARRAY_INIT(arr4); VIRT_ADD_ASSOC_STRING(arr4, "name", ret3[k= ]); VIRT_ADD_ASSOC_STRING(arr4, "maxCpus", num= Tmp); =20 @@ -2622,14 +2569,8 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) if (numTmp =3D=3D NULL) { VIRT_ADD_ASSOC_STRING(arr3, key, ret3[k]); } else { -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr4, zarr4; - arr4 =3D &zarr4; -#else zval *arr4; - ALLOC_INIT_ZVAL(arr4); -#endif - array_init(arr4); + VIRT_ARRAY_INIT(arr4); =20 VIRT_ADD_ASSOC_STRING(arr4, "name", ret3[k= ]); VIRT_ADD_ASSOC_STRING(arr4, "maxCpus", num= Tmp); @@ -3007,14 +2948,9 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) RETURN_FALSE; =20 for (i =3D 0; i < retval; i++) { -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr2, zarr2; - arr2 =3D &zarr2; -#else zval *arr2; - ALLOC_INIT_ZVAL(arr2); -#endif - array_init(arr2); + VIRT_ARRAY_INIT(arr2); + for (j =3D 0; j < retstats[i]->nparams; j++) { params =3D retstats[i]->params[j]; switch (params.type) { @@ -5316,13 +5252,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) continue; =20 if ((i > 0) && (flags & CONNECT_FLAG_SOUNDHW_GET_NAMES)) { -#if PHP_MAJOR_VERSION >=3D 7 - zval *arr, zarr; - arr =3D &zarr; -#else zval *arr; - ALLOC_INIT_ZVAL(arr); -#endif memset(desc, 0, sizeof(desc)); for (i =3D 1; i < t.numTokens; i++) { strcat(desc, t.tokens[i]); @@ -5330,7 +5260,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) strcat(desc, " "); } =20 - array_init(arr); + VIRT_ARRAY_INIT(arr); VIRT_ADD_ASSOC_STRING(arr, "name", t.tokens[0]); VIRT_ADD_ASSOC_STRING(arr, "description", desc); add_next_index_zval(return_value, arr); diff --git a/src/libvirt-php.h b/src/libvirt-php.h index ed6a8bc..757c5f5 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -178,6 +178,12 @@ typedef virt_resource *virt_resource_handle; _info.length =3D ZSTR_LEN(tmp_key_info); \ } while(0) =20 +#define VIRT_ARRAY_INIT(_name) do { \ + zval z##_name; \ + _name =3D &z##_name; \ + array_init(_name); \ + } while(0) + #else /* PHP_MAJOR_VERSION < 7 */ typedef int strsize_t; typedef long zend_long; @@ -239,6 +245,11 @@ typedef long virt_resource_handle; _info.type =3D zend_hash_get_current_key_ex(_ht, &_info.name, &_info.l= ength, &_idx, 0, &_pos); \ } while(0) =20 +#define VIRT_ARRAY_INIT(_name) do {\ + ALLOC_INIT_ZVAL(_name); \ + array_init(_name); \ + } while(0) + #endif /* PHP_MAJOR_VERSION < 7 */ =20 typedef struct tTokenizer { --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 149815926200560.45783143168046; Thu, 22 Jun 2017 12:21:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AFA330AF59; Thu, 22 Jun 2017 19:21:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CDB352FC3; Thu, 22 Jun 2017 19:21:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B3D5218437C6; Thu, 22 Jun 2017 19:20:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJEJ6g013784 for ; Thu, 22 Jun 2017 15:14:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 35A7F17103; Thu, 22 Jun 2017 19:14:19 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3008162929 for ; Thu, 22 Jun 2017 19:14:13 +0000 (UTC) Received: from mail-qt0-f173.google.com (mail-qt0-f173.google.com [209.85.216.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAD3F43A20 for ; Thu, 22 Jun 2017 19:14:12 +0000 (UTC) Received: by mail-qt0-f173.google.com with SMTP id u12so19565577qth.0 for ; Thu, 22 Jun 2017 12:14:12 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:11 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4AFA330AF59 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4AFA330AF59 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="ZTgSTBj7" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BAD3F43A20 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BAD3F43A20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=NrgNvKTyvsm7tqQwPFC1CSXI/mFHsrGi+cWJ86+Ibi4=; b=ZTgSTBj7AieAvBN8RQIGTlTpFzhHNruOKWGST4aMTmC2MeFdmh2dZcZ+zL5mQu8zAh cLgoiJwr4jbPNv86sS0E8d9+RglRXcYD4M60BK3vpa335NCTO+co4sNwdk5NEK2aqU4A ulp/nRiDS7CzTwxA//HAgNm6MBkHxh+ESCkKQ+Or7FeqxusONYPP9n397cjJjAmbGXTK Z7v9udsxpV5GrsnnqOlrCa7Kwkl2c1d3OfIgd0vtkeHhXuHhzUdrctx9s1GYLUUcC4Cn Q88en9IstjF79w6oh23Mwor8cIOSBEwShXLyppTAw4oGMuoPUn72AtZZ+1jMGhNKlDoP 5QIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=NrgNvKTyvsm7tqQwPFC1CSXI/mFHsrGi+cWJ86+Ibi4=; b=BIR9qu1l9QBA5NdlsRaW5wsXKNpDJL3Pb7thxnUwN6dxWMfPAS/PArQIOjpIYz0dKV 9uWMd/UEFc4ALJh139WON6GLi6wJYvyW/rLaHKrIeKmNUdQZS2vFFlFUdvaK4rdrWJEL mSsYwfcEfgNwMti0nExMg7n0Wfvn6/kO+sE5vbwOR4abwlVBjGTw+GLILn1a5Mnn+JEJ IPOKzoqkToyx0Vt1w8d9OSFmCWRboIYEgX4QThfJU+6snx/1MSWT8Obr8YQupvPCsCBd KFqZLYCdP81ALGjO+0AixRts5efQGf3n318liiNHvA0iVc+J3nV2Iny9LacNAM3CCuOz EfTA== X-Gm-Message-State: AKS2vOyTDXNWmlvXy+p0v5gDUd/eJRtFCBrfHv1DY9p3oENHy28n3Z5y 16IgQ5oyTckiKKDVyXR11Q== X-Received: by 10.200.57.228 with SMTP id v91mr5443007qte.116.1498158851813; Thu, 22 Jun 2017 12:14:11 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:06 -0400 Message-Id: <20170622191407.15570-7-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 22 Jun 2017 19:14:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 22 Jun 2017 19:14:13 +0000 (UTC) for IP:'209.85.216.173' DOMAIN:'mail-qt0-f173.google.com' HELO:'mail-qt0-f173.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.369 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.216.173 mail-qt0-f173.google.com 209.85.216.173 mail-qt0-f173.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 6/7] add nwfilter resource type X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 22 Jun 2017 19:21:01 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/libvirt-php.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++-- src/libvirt-php.h | 7 +++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 7784450..535d321 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -54,6 +54,7 @@ int le_libvirt_network; int le_libvirt_nodedev; int le_libvirt_stream; int le_libvirt_snapshot; +int le_libvirt_nwfilter; =20 ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_connect, 0, 0, 0) ZEND_ARG_INFO(0, url) @@ -823,6 +824,8 @@ translate_counter_type(int type) return "storage volume"; case INT_RESOURCE_SNAPSHOT: return "snapshot"; + case INT_RESOURCE_NWFILTER: + return "nwfilter"; } =20 return "unknown"; @@ -1226,6 +1229,17 @@ void free_resource(int type, void *mem TSRMLS_DC) resource_change_counter(INT_RESOURCE_SNAPSHOT, NULL, (virDomai= nSnapshotPtr)mem, 0 TSRMLS_CC); } } + + if (type =3D=3D INT_RESOURCE_NWFILTER) { + rv =3D virNWFilterFree((virNWFilterPtr) mem); + if (rv !=3D 0) { + DPRINTF("%s: virNWFilterFree(%p) returned %d (%s)\n", __FUNCTI= ON__, (virNWFilterPtr) mem, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainSnapshot= Free failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); + } else { + DPRINTF("%s: virNWFilterFree(%p) completed successfully\n", __= FUNCTION__, (virNWFilterPtr) mem); + resource_change_counter(INT_RESOURCE_NWFILTER, NULL, (virNWFil= terPtr) mem, 0 TSRMLS_CC); + } + } } =20 /* @@ -1570,7 +1584,7 @@ static void php_libvirt_snapshot_dtor(virt_resource *= rsrc TSRMLS_DC) rv =3D virDomainSnapshotFree(snapshot->snapshot); if (rv !=3D 0) { DPRINTF("%s: virDomainSnapshotFree(%p) returned %d\n", __F= UNCTION__, snapshot->snapshot, rv); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVol= Free failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainSnap= shotFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virDomainSnapshotFree(%p) completed successfu= lly\n", __FUNCTION__, snapshot->snapshot); resource_change_counter(INT_RESOURCE_SNAPSHOT, snapshot->d= omain->conn->conn, snapshot->snapshot, 0 TSRMLS_CC); @@ -1581,6 +1595,34 @@ static void php_libvirt_snapshot_dtor(virt_resource = *rsrc TSRMLS_DC) } } =20 +/* Destructor for nwfilter resource */ +static void php_libvirt_nwfilter_dtor(virt_resource *rsrc) +{ + php_libvirt_nwfilter *nwfilter =3D (php_libvirt_nwfilter *) rsrc->ptr; + int rv =3D 0; + + if (nwfilter !=3D NULL) { + if (nwfilter->nwfilter !=3D NULL) { + if (!check_resource_allocation(NULL, INT_RESOURCE_NWFILTER, nw= filter->nwfilter TSRMLS_CC)) { + nwfilter->nwfilter =3D NULL; + efree(nwfilter); + + return; + } + rv =3D virNWFilterFree(nwfilter->nwfilter); + if (rv !=3D 0) { + DPRINTF("%s: virNWFilterFree(%p) returned %d\n", __FUNCTIO= N__, nwfilter->nwfilter, rv); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNWFilterFr= ee failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); + } else { + DPRINTF("%s: virNWFilterFee(%p) completed successfully\n",= __FUNCTION__, nwfilter->nwfilter); + resource_change_counter(INT_RESOURCE_NWFILTER, nwfilter->c= onn->conn, nwfilter->nwfilter, 0 TSRMLS_CC); + } + nwfilter->nwfilter =3D NULL; + } + efree(nwfilter); + } +} + /* ZEND Module inicialization function */ PHP_MINIT_FUNCTION(libvirt) { @@ -1593,6 +1635,7 @@ PHP_MINIT_FUNCTION(libvirt) le_libvirt_network =3D zend_register_list_destructors_ex(php_libvirt_n= etwork_dtor, NULL, PHP_LIBVIRT_NETWORK_RES_NAME, module_number); le_libvirt_nodedev =3D zend_register_list_destructors_ex(php_libvirt_n= odedev_dtor, NULL, PHP_LIBVIRT_NODEDEV_RES_NAME, module_number); le_libvirt_snapshot =3D zend_register_list_destructors_ex(php_libvirt_= snapshot_dtor, NULL, PHP_LIBVIRT_SNAPSHOT_RES_NAME, module_number); + le_libvirt_nwfilter =3D zend_register_list_destructors_ex(php_libvirt_= nwfilter_dtor, NULL, PHP_LIBVIRT_NWFILTER_RES_NAME, module_number); =20 ZEND_INIT_MODULE_GLOBALS(libvirt, php_libvirt_init_globals, NULL); =20 @@ -1994,7 +2037,21 @@ PHP_MSHUTDOWN_FUNCTION(libvirt) VIRT_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, P= HP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ if ((snapshot =3D=3D NULL) || (snapshot->snapshot =3D=3D NULL)) = \ RETURN_FALSE; = \ -} while (0) = \ + } while (0) = \ + +#define GET_NWFILTER_FROM_ARGS(args, ...) = \ + do { = \ + reset_error(TSRMLS_C); = \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_AR= GS__) =3D=3D FAILURE) { \ + set_error("Invalid arguments" TSRMLS_CC); = \ + RETURN_FALSE; = \ + } = \ + = \ + VIRT_FETCH_RESOURCE(nwfilter, php_libvirt_nwfilter *, &znwfilter, = \ + PHP_LIBVIRT_NWFILTER_RES_NAME, le_libvirt_nwfi= lter); \ + if ((nwfilter =3D=3D NULL) || (nwfilter->nwfilter =3D=3D NULL)) = \ + RETURN_FALSE; = \ + } while (0) = \ =20 #define LONGLONG_INIT \ char tmpnumber[64] diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 757c5f5..2e7a3ca 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -298,6 +298,7 @@ typedef struct _resource_info { #define INT_RESOURCE_VOLUME 0x20 #define INT_RESOURCE_SNAPSHOT 0x40 #define INT_RESOURCE_STREAM 0x50 +#define INT_RESOURCE_NWFILTER 0x60 =20 typedef struct tVMDisk { char *path; @@ -355,6 +356,11 @@ typedef struct _php_libvirt_volume { php_libvirt_connection* conn; } php_libvirt_volume; =20 +typedef struct _php_libvirt_nwfilter { + virNWFilterPtr nwfilter; + php_libvirt_connection* conn; +} php_libvirt_nwfilter; + typedef struct _php_libvirt_cred_value { int count; int type; @@ -382,6 +388,7 @@ char **get_array_from_xpath(char *xml, char *xpath, int= *num); #define PHP_LIBVIRT_NETWORK_RES_NAME "Libvirt virtual network" #define PHP_LIBVIRT_NODEDEV_RES_NAME "Libvirt node device" #define PHP_LIBVIRT_SNAPSHOT_RES_NAME "Libvirt domain snapshot" +#define PHP_LIBVIRT_NWFILTER_RES_NAME "Libvirt nwfilter" =20 PHP_MINIT_FUNCTION(libvirt); PHP_MSHUTDOWN_FUNCTION(libvirt); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498158916052849.3431053708957; Thu, 22 Jun 2017 12:15:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8E19142890; Thu, 22 Jun 2017 19:15:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B0365D967; Thu, 22 Jun 2017 19:15:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E09E61800C88; Thu, 22 Jun 2017 19:15:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJEFdm013753 for ; Thu, 22 Jun 2017 15:14:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3EBCC68D42; Thu, 22 Jun 2017 19:14:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3771F65E9B for ; Thu, 22 Jun 2017 19:14:15 +0000 (UTC) Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F1E514288E for ; Thu, 22 Jun 2017 19:14:13 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id d14so19993443qkb.1 for ; Thu, 22 Jun 2017 12:14:13 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:11 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C8E19142890 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C8E19142890 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="jBAwSdag" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3F1E514288E Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3F1E514288E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=iIFyq+tiER7tI+xr5jD74yRFK1LeIxvzJtX3CdaMCAY=; b=jBAwSdag0T6coQwtcmma3poTpP+8lHZKF+0r6plaUaz7VOnR3hBX0eq9jSVNNDr0rI FItlMYntz0vaFmjRMgeKDhEqbg+ok1pWIUpNTjR6eTPB6f2XJQzE17BKYT9aqSigcPJs pzA4rh5ATWFh3X2kVzZvvI0jrxgStC0rUpW4lWSab85XQX0HaUPTjSR9ln63BIOTjtCW C1u74uBHtoNKyPgCGU3rEqctnlSHKuHeYuiG2a4lia8z93ePP8p76OoV5Cr+dxxlvAbK j1H9OfAoMz/puM+j13F3HtOA2KiHZTBkvuHbH/1wUdK/IQBoXlb9VQqeMHatexMG3R6u mQ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=iIFyq+tiER7tI+xr5jD74yRFK1LeIxvzJtX3CdaMCAY=; b=fiVYrBVFZ6Or5+LUM1/EZ/vSFljUbjxz/f4eKyG4AKJWswgw9YmRE28xe+Q7fkuZ/U 5ll22xjMAhOIJMdmlZDrdjDI6hzVcksjxQTi/yktzOqbqRo7ZJQZAygvDgzLeFbf7eIT As54pk1MaTIVGNm9AK9OxFE39QiFWqjanJmd9zMMlbAPsRd0xJOWur6X8dDAq6Ydw1EV e1farH3lnmetViWrZ2gAGEBTtgJiTtNhBfLIK0Y5UyDOOZ9C+IeOoPmBwdpRgX4BWGtt qpDdohbciwKVyfAxdd3z3L1YWHuTokdwz81X3JgqSaGuEs0XrNWEOxme6+nyBEUxlNV8 7zqw== X-Gm-Message-State: AKS2vOwGBQdL5PX0/xOONWUxvozXIm/42xV/R6PJVrqpX9n30+DF7bpv iAP5tWWNpDJAOxZdWYzcyw== X-Received: by 10.55.74.131 with SMTP id x125mr4958176qka.5.1498158852216; Thu, 22 Jun 2017 12:14:12 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:07 -0400 Message-Id: <20170622191407.15570-8-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 22 Jun 2017 19:14:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 22 Jun 2017 19:14:13 +0000 (UTC) for IP:'209.85.220.176' DOMAIN:'mail-qk0-f176.google.com' HELO:'mail-qk0-f176.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -0.611 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.220.176 mail-qk0-f176.google.com 209.85.220.176 mail-qk0-f176.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 7/7] implement NWFilter API bindings. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 22 Jun 2017 19:15:14 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" adds the following functions: * libvirt_nwfilter_define_xml * libvirt_nwfilter_undefine * libvirt_nwfilter_get_xml_desc * libvirt_nwfilter_get_name * libvirt_nwfilter_get_uuid * libvirt_nwfilter_get_uuid_string * libvirt_nwfilter_lookup_by_name * libvirt_nwfilter_lookup_by_uuid * libvirt_nwfilter_lookup_by_uuid_string * libvirt_list_nwfilters * libvirt_list_all_nwfilters --- src/libvirt-php.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ src/libvirt-php.h | 12 ++ 2 files changed, 402 insertions(+) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 535d321..5893742 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -645,6 +645,16 @@ static zend_function_entry libvirt_functions[] =3D { PHP_FE(libvirt_nodedev_capabilities, arginfo_libvirt_conn) PHP_FE(libvirt_nodedev_get_xml_desc, arginfo_libvirt_conn_xpat= h) PHP_FE(libvirt_nodedev_get_information, arginfo_libvirt_conn) + /* NWFilter functions */ + PHP_FE(libvirt_nwfilter_define_xml, arginfo_libvirt_conn_xml) + PHP_FE(libvirt_nwfilter_undefine, arginfo_libvirt_conn) + PHP_FE(libvirt_nwfilter_get_xml_desc, arginfo_libvirt_conn_xpat= h) + PHP_FE(libvirt_nwfilter_get_uuid_string, arginfo_libvirt_conn) + PHP_FE(libvirt_nwfilter_get_uuid, arginfo_libvirt_conn) + PHP_FE(libvirt_nwfilter_get_name, arginfo_libvirt_conn) + PHP_FE(libvirt_nwfilter_lookup_by_name, arginfo_libvirt_conn_name) + PHP_FE(libvirt_nwfilter_lookup_by_uuid_string, arginfo_libvirt_conn_uu= id) + PHP_FE(libvirt_nwfilter_lookup_by_uuid, arginfo_libvirt_conn_uuid) /* List functions */ PHP_FE(libvirt_list_domains, arginfo_libvirt_conn) PHP_FE(libvirt_list_domain_snapshots, arginfo_libvirt_conn_optf= lags) @@ -659,6 +669,8 @@ static zend_function_entry libvirt_functions[] =3D { 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) + PHP_FE(libvirt_list_all_nwfilters, arginfo_libvirt_conn) + PHP_FE(libvirt_list_nwfilters, arginfo_libvirt_conn) /* Version information and common function */ PHP_FE(libvirt_version, arginfo_libvirt_opttype) PHP_FE(libvirt_check_version, arginfo_libvirt_check_ver= sion) @@ -9074,7 +9086,93 @@ PHP_FUNCTION(libvirt_list_nodedevs) efree(names); } =20 + +/* + * Function name: libvirt_list_all_nwfilters + * Since version: 0.5.4 + * Description: Function is used to list nwfilters on the connection + * Arguments: @res [resource]: libvirt connection resource + * Returns: libvirt nwfilter resources array for the connection + */ +PHP_FUNCTION(libvirt_list_all_nwfilters) +{ + php_libvirt_nwfilter *res_nwfilter; + php_libvirt_connection *conn =3D NULL; + virNWFilterPtr *filters =3D NULL; + virNWFilterPtr nwfilter =3D NULL; + zval *zconn; + int count =3D -1; + size_t i =3D 0; + + GET_CONNECTION_FROM_ARGS("r", &zconn); + + /* in current libvirt version, flags are not used for this, so passing= 0 */ + if ((count =3D virConnectListAllNWFilters(conn->conn, &filters, 0)) < = 0) + RETURN_FALSE; + + DPRINTF("%s: Found %d nwfilters\n", PHPFUNC, count); + + array_init(return_value); + + for (i =3D 0; i < count; i++) { + nwfilter =3D filters[i]; + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvi= rt_nwfilter)); + res_nwfilter->nwfilter =3D nwfilter; + res_nwfilter->conn =3D conn; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + VIRT_REGISTER_LIST_RESOURCE(nwfilter); + } +} + +/* + * Function name: libvirt_list_nwfilters + * Since version: 0.5.4 + * Description: Function is used to list nwfilters on the connection + * Arguments: @res [resource]: libvirt connection resource + * Returns: libvirt nwfilter names array for the connection + */ +PHP_FUNCTION(libvirt_list_nwfilters) +{ + php_libvirt_connection *conn =3D NULL; + zval *zconn; + int count =3D -1; + int expectedcount =3D -1; + char **names; + int i, done =3D 0; + + GET_CONNECTION_FROM_ARGS("r", &zconn); + + array_init(return_value); + + if ((expectedcount =3D virConnectNumOfNWFilters(conn->conn)) < 0) + RETURN_FALSE; + + names =3D (char **) emalloc(expectedcount * sizeof(char *)); + count =3D virConnectListNWFilters(conn->conn, names, expectedcount); + + if (count !=3D expectedcount || count < 0) { + efree(names); + DPRINTF("%s: virConnectListNWFilters returned %d filters, while %d= was " + "expected\n", PHPFUNC, count, expectedcount); + RETURN_FALSE; + } + + for (i =3D 0; i < count; i++) { + VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); + free(names[i]); + } + + efree(names); + done++; + + + if (!done) + RETURN_FALSE; +} /* Nodedev functions */ + /* * Function name: libvirt_nodedev_get * Since version: 0.4.1(-1) @@ -9782,6 +9880,298 @@ PHP_FUNCTION(libvirt_network_set_autostart) RETURN_TRUE; } =20 +/* NWFilter functions */ + +/* + * Function name: libvirt_nwfilter_define_xml + * Since version: 0.5.4 + * Description: Function is used to define a new nwfilter based on the= XML description + * Arguments: @res [resource]: libvirt connection resource + * @xml [string]: XML string definition of nwfilter to be= defined + * Returns: libvirt nwfilter resource of newly defined nwfilter + */ +PHP_FUNCTION(libvirt_nwfilter_define_xml) +{ + php_libvirt_connection *conn =3D NULL; + php_libvirt_nwfilter *res_nwfilter =3D NULL; + virNWFilter *nwfilter; + zval *zconn; + char *xml =3D NULL; + strsize_t xml_len; + + GET_CONNECTION_FROM_ARGS("rs", &zconn, &xml, &xml_len); + + if ((nwfilter =3D virNWFilterDefineXML(conn->conn, xml)) =3D=3D NULL) { + set_error_if_unset("Cannot define a new NWFilter" TSRMLS_CC); + RETURN_FALSE; + } + + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); + res_nwfilter->nwfilter =3D nwfilter; + res_nwfilter->conn =3D conn; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + + VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); +} + +/* + * Function name: libvirt_nwfilter_undefine + * Since version: 0.5.4 + * Description: Function is used to undefine already defined nwfilter + * Arguments: @res [resource]: libvirt nwfilter resource + * Returns: TRUE for success, FALSE on error + */ +PHP_FUNCTION(libvirt_nwfilter_undefine) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + + GET_NWFILTER_FROM_ARGS("r", &znwfilter); + + if (virNWFilterUndefine(nwfilter->nwfilter) !=3D 0) + RETURN_FALSE; + + RETURN_TRUE; +} + +/* + * Function name: libvirt_nwfilter_get_xml_desc + * Since version: 0.5.4 + * Description: Function is used to get the XML description for the nw= filter + * Arguments: @res [resource]: libvirt nwfilter resource + * @xpath [string]: optional xPath expression string to g= et just this entry, can be NULL + * Returns: nwfilter XML string or result of xPath expression + */ +PHP_FUNCTION(libvirt_nwfilter_get_xml_desc) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + char *xml =3D NULL; + char *xpath =3D NULL; + char *tmp; + strsize_t xpath_len; + int retval =3D -1; + + GET_NWFILTER_FROM_ARGS("r|s", &znwfilter, &xpath, &xpath_len); + + if (xpath_len < 1) + xpath =3D NULL; + + xml =3D virNWFilterGetXMLDesc(nwfilter->nwfilter, 0); + + if (xml =3D=3D NULL) { + set_error_if_unset("Cannot get nwfilter XML" TSRMLS_CC); + RETURN_FALSE; + } + + tmp =3D get_string_from_xpath(xml, xpath, NULL, &retval); + + if (tmp =3D=3D NULL || retval < 0) + VIRT_RETVAL_STRING(xml); + else + VIRT_RETVAL_STRING(tmp); + + free(xml); + free(tmp); +} + +/* + * Function name: libvirt_nwfilter_get_uuid_string + * Since version: 0.5.4 + * Description: Function is used to get nwfilter's UUID in string form= at + * Arguments: @res [resource]: libvirt nwfilter resource + * Returns: nwfilter UUID string or FALSE on failure + */ +PHP_FUNCTION(libvirt_nwfilter_get_uuid_string) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + char *uuid =3D NULL; + int ret =3D -1; + + GET_NWFILTER_FROM_ARGS("r", &znwfilter); + + uuid =3D (char *) emalloc(VIR_UUID_STRING_BUFLEN); + ret =3D virNWFilterGetUUIDString(nwfilter->nwfilter, uuid); + + DPRINTF("%s: virNWFilterGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, + nwfilter->nwfilter, ret, uuid); + + if (ret !=3D 0) + RETURN_FALSE; + + VIRT_RETURN_STRING(uuid); + efree(uuid); +} + +/* + * Function name: libvirt_nwfilter_get_uuid + * Since version: 0.5.3 + * Descirption: Function is used to get nwfilter's UUID in binary form= at + * Arguments: @res [resource]: libvirt netowrk resource + * Returns: nwfilter UUID in binary format or FALSE on failure + */ +PHP_FUNCTION(libvirt_nwfilter_get_uuid) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + char *uuid =3D NULL; + int ret =3D -1; + + GET_NWFILTER_FROM_ARGS("r", &znwfilter); + + uuid =3D (char *) emalloc(VIR_UUID_BUFLEN); + ret =3D virNWFilterGetUUID(nwfilter->nwfilter, (unsigned char *) uuid); + + DPRINTF("%s: virNWFilterUUID(%p, %p) returned %d\n", PHPFUNC, + nwfilter->nwfilter, uuid, ret); + + if (ret !=3D 0) + RETURN_FALSE; + + VIRT_RETVAL_STRING(uuid); + efree(uuid); +} + +/* + * Function name: libvirt_nwfilter_get_name + * Since version: 0.5.4 + * Description: Function is used to get nwfilter's name + * Arguments: @res [resource]: libvirt nwfilter resource + * Returns: nwfilter name string or FALSE on failure + */ +PHP_FUNCTION(libvirt_nwfilter_get_name) +{ + php_libvirt_nwfilter *nwfilter =3D NULL; + zval *znwfilter; + const char *name =3D NULL; + + GET_NWFILTER_FROM_ARGS("r", &znwfilter); + name =3D virNWFilterGetName(nwfilter->nwfilter); + + DPRINTF("%s: virNWFilterGetName(%p) returned %s\n", PHPFUNC, + nwfilter->nwfilter, name); + + if (name =3D=3D NULL) + RETURN_FALSE; + + /* name should not be freed as its lifetime is the same as nwfilter re= source */ + VIRT_RETURN_STRING(name); +} + +/* + * Function name: libvirt_nwfilter_lookup_by_name + * Since version: 0.5.4 + * Description: This functions is used to lookup for the nwfilter by i= t's name + * Arguments: @res [resource]: libvirt connection resource + * @name [string]: name of the nwfilter to get the resour= ce + * Returns: libvirt nwfilter resource + */ +PHP_FUNCTION(libvirt_nwfilter_lookup_by_name) +{ + php_libvirt_nwfilter *res_nwfilter =3D NULL; + php_libvirt_connection *conn =3D NULL; + virNWFilterPtr nwfilter =3D NULL; + zval *zconn; + strsize_t name_len; + char *name =3D NULL; + + GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); + + if (name =3D=3D NULL || name_len < 1) + RETURN_FALSE; + + nwfilter =3D virNWFilterLookupByName(conn->conn, name); + + if (nwfilter =3D=3D NULL) + RETURN_FALSE; + + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); + res_nwfilter->conn =3D conn; + res_nwfilter->nwfilter =3D nwfilter; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + + VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); +} + +/* + * Function name: libvirt_nwfilter_lookup_by_uuid_string + * Since version: 0.5.4 + * Description: Function is used to lookup for nwfilter identified by = UUID string + * Arguments: @res [resource]: libvirt connection resource + * @uuid [string]: UUID string to look for nwfilter + * Returns: libvirt nwfilter resource + */ +PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid_string) +{ + php_libvirt_nwfilter *res_nwfilter =3D NULL; + php_libvirt_connection *conn =3D NULL; + virNWFilterPtr nwfilter =3D NULL; + zval *zconn; + char *uuid =3D NULL; + strsize_t uuid_len; + + GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); + + if (uuid =3D=3D NULL || uuid_len < 1) + RETURN_FALSE; + + nwfilter =3D virNWFilterLookupByUUIDString(conn->conn, uuid); + + if (nwfilter =3D=3D NULL) + RETURN_FALSE; + + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); + res_nwfilter->conn =3D conn; + res_nwfilter->nwfilter =3D nwfilter; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + + VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); +} + +/* + * Function name: libvirt_nwfilter_lookup_by_uuid + * Since version: 0.5.4 + * Description: Function is used to lookup for nwfilter by it's UUID i= n the binary format + * Arguments: @res [resource]: libvirt connection resource from libv= irt_connect() + * @uuid [string]: binary defined UUID to look for + * Returns: libvirt nwfilter resource + */ +PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid) +{ + php_libvirt_nwfilter *res_nwfilter =3D NULL; + php_libvirt_connection *conn =3D NULL; + virNWFilterPtr nwfilter =3D NULL; + zval *zconn; + strsize_t uuid_len; + unsigned char *uuid =3D NULL; + + GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); + + if ((uuid =3D=3D NULL) || (uuid_len < 1)) + RETURN_FALSE; + + nwfilter =3D virNWFilterLookupByUUID(conn->conn, uuid); + + if (nwfilter =3D=3D NULL) + RETURN_FALSE; + + res_nwfilter =3D (php_libvirt_nwfilter *) emalloc(sizeof(php_libvirt_n= wfilter)); + res_nwfilter->conn =3D conn; + res_nwfilter->nwfilter =3D nwfilter; + + resource_change_counter(INT_RESOURCE_NWFILTER, conn->conn, + res_nwfilter->nwfilter, 1 TSRMLS_CC); + + VIRT_REGISTER_RESOURCE(res_nwfilter, le_libvirt_nwfilter); +} + /* * Function name: libvirt_version * Since version: 0.4.1(-1) diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 2e7a3ca..7962e33 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -558,10 +558,22 @@ PHP_FUNCTION(libvirt_nodedev_get); PHP_FUNCTION(libvirt_nodedev_capabilities); PHP_FUNCTION(libvirt_nodedev_get_xml_desc); PHP_FUNCTION(libvirt_nodedev_get_information); +/* NWFilter functions */ +PHP_FUNCTION(libvirt_nwfilter_define_xml); +PHP_FUNCTION(libvirt_nwfilter_undefine); +PHP_FUNCTION(libvirt_nwfilter_get_xml_desc); +PHP_FUNCTION(libvirt_nwfilter_get_name); +PHP_FUNCTION(libvirt_nwfilter_get_uuid_string); +PHP_FUNCTION(libvirt_nwfilter_get_uuid); +PHP_FUNCTION(libvirt_nwfilter_lookup_by_name); +PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid_string); +PHP_FUNCTION(libvirt_nwfilter_lookup_by_uuid); /* Listing functions */ PHP_FUNCTION(libvirt_list_nodedevs); PHP_FUNCTION(libvirt_list_all_networks); PHP_FUNCTION(libvirt_list_networks); +PHP_FUNCTION(libvirt_list_all_nwfilters); +PHP_FUNCTION(libvirt_list_nwfilters); PHP_FUNCTION(libvirt_list_domains); PHP_FUNCTION(libvirt_list_domain_snapshots); PHP_FUNCTION(libvirt_list_domain_resources); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list