From nobody Mon Feb 9 18:18:05 2026 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