From nobody Sun May 5 21:00:13 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 1494258220650591.8625298038987; Mon, 8 May 2017 08:43:40 -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 DE0CB2DD4C; Mon, 8 May 2017 15:43:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A3767C144; Mon, 8 May 2017 15:43:37 +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 C01285EC60; Mon, 8 May 2017 15:43:34 +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 v48FhWos009745 for ; Mon, 8 May 2017 11:43:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id C96189FDF3; Mon, 8 May 2017 15:43:32 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C28749FDFF for ; Mon, 8 May 2017 15:43:32 +0000 (UTC) Received: from mail-qk0-f178.google.com (mail-qk0-f178.google.com [209.85.220.178]) (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 BCB117F4B8 for ; Mon, 8 May 2017 15:43:30 +0000 (UTC) Received: by mail-qk0-f178.google.com with SMTP id y201so22867817qka.0 for ; Mon, 08 May 2017 08:43:30 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id k10sm10082733qke.3.2017.05.08.08.43.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 May 2017 08:43:29 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DE0CB2DD4C 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 DE0CB2DD4C 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="nIxXXjTw" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BCB117F4B8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BCB117F4B8 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=2bhAY93w4lT0ONIUPQoaYFTm+7zC31jYRBWwhFdAMtY=; b=nIxXXjTwIgTpgtjrdVfjN+XdMtfeiGEtd17XSCvCul9pYWkKEOs1ba2NzU1eQPqb4f lL21BkDMTnbotBpAxdknZqTmhnCoNQ+FlAHHcLCSNCv31HS7AtX3gLuUBQrBsQIcHoz0 mxztvh5ZBtdX/8QiTKnJgh2I2LX+7yKx9a8C3C2kf8Bc0ZZbDT1yyF3HutRmdqwMpDy4 HPDow/zsLXCZ7z72GLyEtsOpGWeFEthnhqatgyNA9AoFqEnx9Nf6FSBvQWkVbnVgpNF0 UrYvGy9a6hoW5/Tzoe2Ln9YhC866hxGzppLjDWqbBObxOxxla9+EHxp5z/X766EMY1is qn4Q== 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=2bhAY93w4lT0ONIUPQoaYFTm+7zC31jYRBWwhFdAMtY=; b=Hustwpg9Ai1RIRtmFZlaO9NxnH9X7RjBXsSoGrl5nJn7amNT6RsUjMA+QWBQj5qCur Hnv4M1YfA9XBCYOals6jHddMiKWZbW0O/S0/q2Up0dvnoIoUBcYqcfZkjELRmSPd/bFw y/mFpn44OcjpVdIDudh+Pw+s1uSGixlW9oCUMRpRh73d9i3h0wbaby8EXPnBfef0b66F TX5cPRTo04erhaJvyscALjbTtbRQCPM7gnf7qzY2DLiyoUqqhH+L1x18Q5WnZU7gNWF9 jw2h6LhMEKs732aDL7fsLwWbdMN7CuBPacZpJiC0YczlNTO+H65sgVhFwg4nfw6He5z3 gDRg== X-Gm-Message-State: AODbwcAHPfzCNNuttNHU9FCvMB8oh1G+5urMIMBVdygnx8F8a3MKBS1U X3J2E7ilOTbiOWqViNpSIw== X-Received: by 10.55.137.7 with SMTP id l7mr1694482qkd.122.1494258209767; Mon, 08 May 2017 08:43:29 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Mon, 8 May 2017 11:43:26 -0400 Message-Id: <20170508154327.19094-2-dzamirski@datto.com> In-Reply-To: <20170508154327.19094-1-dzamirski@datto.com> References: <20170508154327.19094-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 08 May 2017 15:43:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 08 May 2017 15:43:31 +0000 (UTC) for IP:'209.85.220.178' DOMAIN:'mail-qk0-f178.google.com' HELO:'mail-qk0-f178.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.178 mail-qk0-f178.google.com 209.85.220.178 mail-qk0-f178.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 1/2] implement binding for virConnectListAllNetworks. 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]); Mon, 08 May 2017 15:43:38 +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" Some hypervisors (like Hyper-V) allow duplicate network names which makes existing libvirt_list_networks not very useful as it returns just names. Since virConnectListAllNetworks returns array of handles to virNetworkPtr, one can use e.g. virNetworkGetUUIDString to resolve such ambiguity issues. --- src/libvirt-php.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ src/libvirt-php.h | 1 + 2 files changed, 63 insertions(+) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 3a80a53..fa02457 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -737,6 +737,7 @@ static zend_function_entry libvirt_functions[] =3D { PHP_FE(libvirt_list_domain_snapshots, arginfo_libvirt_conn_optf= lags) PHP_FE(libvirt_list_domain_resources, arginfo_libvirt_conn) PHP_FE(libvirt_list_nodedevs, arginfo_libvirt_conn_optc= ap) + PHP_FE(libvirt_list_all_networks, arginfo_libvirt_conn_optf= lags) PHP_FE(libvirt_list_networks, arginfo_libvirt_conn_optf= lags) PHP_FE(libvirt_list_storagepools, arginfo_libvirt_conn) PHP_FE(libvirt_list_active_storagepools, arginfo_libvirt_conn) @@ -1814,6 +1815,13 @@ PHP_MINIT_FUNCTION(libvirt) REGISTER_LONG_CONSTANT("VIR_NETWORKS_INACTIVE", VIR_NETWORKS_INACT= IVE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("VIR_NETWORKS_ALL", VIR_NETWORKS_ACTIVE | VIR_NETWORKS_INACTIVE, CONST_CS | CONST_PERSIS= TENT); + REGISTER_LONG_CONSTANT("VIR_CONNECT_LIST_NETWORKS_INACTIVE", VIR_C= ONNECT_LIST_NETWORKS_INACTIVE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("VIR_CONNECT_LIST_NETWORKS_ACTIVE", VIR_C= ONNECT_LIST_NETWORKS_ACTIVE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("VIR_CONNECT_LIST_NETWORKS_PERSISTENT", VIR_C= ONNECT_LIST_NETWORKS_PERSISTENT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("VIR_CONNECT_LIST_NETWORKS_TRANSIENT", VIR_C= ONNECT_LIST_NETWORKS_TRANSIENT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("VIR_CONNECT_LIST_NETWORKS_AUTOSTART", VIR_C= ONNECT_LIST_NETWORKS_AUTOSTART, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART", VIR_C= ONNECT_LIST_NETWORKS_NO_AUTOSTART, CONST_CS | CONST_PERSISTENT); + =20 /* Credential constants */ REGISTER_LONG_CONSTANT("VIR_CRED_USERNAME", 1, CONST_CS | CONST_PE= RSISTENT); @@ -9160,6 +9168,60 @@ PHP_FUNCTION(libvirt_list_inactive_domains) } =20 /* + * Function name: libvirt_list_all_networks + * Since version: 0.5.3 + * Description: Function is used to list networks on the connection + * Arguments: @res [resource]: libvirt connection resource + * @flags [int]: optional flags to filter the results for= a smaller list of targetted networks (bitwise-OR VIR_CONNECT_LIST_NETWORKS= _* constants) + * Returns: libvirt network resources array for the connection + */ +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; + size_t i =3D 0; + virNetworkPtr *nets =3D NULL; + virNetworkPtr network =3D NULL; + php_libvirt_network *res_network; + + GET_CONNECTION_FROM_ARGS("r|l", &zconn, &flags); + + if ((count =3D virConnectListAllNetworks(conn->conn, &nets, flags)) < = 0) + RETURN_FALSE; + + DPRINTF("%s: Found %d networks\n", PHPFUNC, count); + + array_init(return_value); + + for (i =3D 0; i < count; i++) { + network =3D nets[i]; + res_network =3D (php_libvirt_network *) emalloc(sizeof(php_libvirt= _network)); + res_network->network =3D network; + res_network->conn =3D conn; + + 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 + } +} + +/* * Function name: libvirt_list_networks * Since version: 0.4.1(-1) * Description: Function is used to list networks on the connection diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 9978e27..1a003f5 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -427,6 +427,7 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc); PHP_FUNCTION(libvirt_nodedev_get_information); /* Listing functions */ PHP_FUNCTION(libvirt_list_nodedevs); +PHP_FUNCTION(libvirt_list_all_networks); PHP_FUNCTION(libvirt_list_networks); PHP_FUNCTION(libvirt_list_domains); PHP_FUNCTION(libvirt_list_domain_snapshots); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 21:00:13 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 1494258219855238.00110535891406; Mon, 8 May 2017 08:43:39 -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 E213880083; Mon, 8 May 2017 15:43:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCDD017B4C; Mon, 8 May 2017 15:43:37 +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 4218A5EC63; Mon, 8 May 2017 15:43:37 +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 v48FhYY5009754 for ; Mon, 8 May 2017 11:43:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 51DB118246; Mon, 8 May 2017 15:43:34 +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 49A8817CC1 for ; Mon, 8 May 2017 15:43:32 +0000 (UTC) Received: from mail-qt0-f181.google.com (mail-qt0-f181.google.com [209.85.216.181]) (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 220B8C05678E for ; Mon, 8 May 2017 15:43:31 +0000 (UTC) Received: by mail-qt0-f181.google.com with SMTP id m91so53016517qte.3 for ; Mon, 08 May 2017 08:43:31 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id k10sm10082733qke.3.2017.05.08.08.43.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 May 2017 08:43:29 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E213880083 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=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E213880083 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="oGw3+5DW" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 220B8C05678E 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 220B8C05678E 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=Uk5tXC0Bd+bNbE/hpNh9GSIuQeiHqoHw6PYP5T8xdJc=; b=oGw3+5DWFvOpKYpJkh1/BGdXNOTQgY2xavFczobHcEBuvgBrK4Vr6YYK7KOsKxHZYB x5ipCIddQnS+q9fLQYS/9ETe31K5ijePuoNMMFAwJvbFtEiH6abbYMOMW4hq3yN5Yr0K tpcXK8MeGoUUuKUpCu9WXQQ8qWH6HKXyc92ZHaE1cVxVR6o6Sy9EFqVnhwqrxrB9pukn DAKkWy5xK+Dqxpy2w7V/YkkCp6cytLQLNHsgKb65ftRuE0QP9qIEcWVr9AscRgVtzBzl Y3FGPP+0buJKkNOcpJJiVIQ715UKnAglmGr42fKUKNiP+abqQeY7taqrAhVmtpcJx5v7 lWKQ== 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=Uk5tXC0Bd+bNbE/hpNh9GSIuQeiHqoHw6PYP5T8xdJc=; b=FkaCEGMtjXMsxvPnWuBOBD2jYm4Nn2Y9742teo/7xVxmBdLLcwNo2NyRQHh+d8o2ut 6oowRroiv2olDtZicij41ls2+9LtttWUkwRBILBaENTsQYcXaUeEe+/GSyz3q7S3gMtW rGJ/CieMoPQD/U4PnAURp6DePtSvaFdjNV9pDTVdA++DCFMrhUECrtUunn7MueNk5fY2 wd6ACAglr5awv6G64tyEdEqSgVIaPK1SEkOeFLE/7kz4X2wJ23haoC7fTX7Tugl7F5WE 3G0jdjtKnex9mzI8tKSIy+geCdQmatYceKk+y+bSZi4j2ziJC8rZMMTcG5wo7Lywy8s4 V3Zw== X-Gm-Message-State: AODbwcC0OrmrckMIR5UZlGq5QD8Yx50tj/CWkrSeSD5Ma7SG2c0NABtF r3gi2mo/CqTPwsYo/ODw+Q== X-Received: by 10.200.33.232 with SMTP id 37mr11087987qtz.189.1494258210238; Mon, 08 May 2017 08:43:30 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Mon, 8 May 2017 11:43:27 -0400 Message-Id: <20170508154327.19094-3-dzamirski@datto.com> In-Reply-To: <20170508154327.19094-1-dzamirski@datto.com> References: <20170508154327.19094-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 08 May 2017 15:43:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 08 May 2017 15:43:31 +0000 (UTC) for IP:'209.85.216.181' DOMAIN:'mail-qt0-f181.google.com' HELO:'mail-qt0-f181.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.179 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.216.181 mail-qt0-f181.google.com 209.85.216.181 mail-qt0-f181.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 2/2] implement additional network functions. 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.28]); Mon, 08 May 2017 15:43:38 +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" * add libvirt_network_get_uuid_string * add libvirt_network_get_uuid * add libvirt_network_get_name Those are useful when working with network resources returned from libvirt_list_all_networks. --- src/libvirt-php.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ src/libvirt-php.h | 3 ++ 2 files changed, 90 insertions(+) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index fa02457..bfc9b7d 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -721,6 +721,9 @@ static zend_function_entry libvirt_functions[] =3D { PHP_FE(libvirt_network_get_information, arginfo_libvirt_conn) PHP_FE(libvirt_network_get_active, arginfo_libvirt_conn) PHP_FE(libvirt_network_set_active, arginfo_libvirt_conn_flag= s) + PHP_FE(libvirt_network_get_uuid_string, arginfo_libvirt_conn) + PHP_FE(libvirt_network_get_uuid, arginfo_libvirt_conn) + PHP_FE(libvirt_network_get_name, arginfo_libvirt_conn) /* Node functions */ PHP_FE(libvirt_node_get_info, arginfo_libvirt_conn) PHP_FE(libvirt_node_get_cpu_stats, arginfo_libvirt_conn_optc= punr) @@ -9915,6 +9918,90 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) } =20 /* + * Function name: libvirt_network_get_uuid_string + * Since version: 0.5.3 + * Description: Function is used to get network's UUID in string format + * Arguments: @res [resource]: libvirt network resource + * Returns: network UUID string or FALSE on failure + */ +PHP_FUNCTION(libvirt_network_get_uuid_string) +{ + php_libvirt_network *network =3D NULL; + zval *znetwork; + char *uuid =3D NULL; + int ret =3D -1; + + GET_NETWORK_FROM_ARGS("r", &znetwork); + + uuid =3D (char *) emalloc(VIR_UUID_STRING_BUFLEN); + ret =3D virNetworkGetUUIDString(network->network, uuid); + + DPRINTF("%s: virNetworkGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, + network->network, ret, uuid); + + if (ret !=3D 0) + RETURN_FALSE; + + VIRT_RETURN_STRING(uuid); + efree(uuid); +} + +/* + * Function name: libvirt_network_get_uuid + * Since version: 0.5.3 + * Descirption: Function is used to get network's UUID in binary format + * Arguments: @res [resource]: libvirt netowrk resource + * Returns: network UUID in binary format or FALSE on failure + */ +PHP_FUNCTION(libvirt_network_get_uuid) +{ + php_libvirt_network *network =3D NULL; + zval *znetwork; + char *uuid =3D NULL; + int ret =3D -1; + + GET_NETWORK_FROM_ARGS("r", &znetwork); + + uuid =3D (char *) emalloc(VIR_UUID_BUFLEN); + ret =3D virNetworkGetUUID(network->network, (unsigned char *)uuid); + + DPRINTF("%s: virNetworkGetUUID(%p, %p) returned %d\n", PHPFUNC, + network->network, uuid, ret); + + if (ret !=3D 0) + RETURN_FALSE; + + VIRT_RETVAL_STRING(uuid); + efree(uuid); +} + +/* + * Function name: libvirt_network_get_name + * Since version: 0.5.3 + * Description: Function is used to get network's name + * Arguments: @res [resource]: libvirt network resource + * Returns: network name string or FALSE on failure + */ +PHP_FUNCTION(libvirt_network_get_name) +{ + php_libvirt_network *network =3D NULL; + zval *znetwork; + const char *name =3D NULL; + + GET_NETWORK_FROM_ARGS("r", &znetwork); + name =3D virNetworkGetName(network->network); + + DPRINTF("%s: virNetworkGetName(%p) returned %s\n", PHPFUNC, + network->network, name); + + if (name =3D=3D NULL) + RETURN_FALSE; + + /* name should not be freed as its lifetime is the same as network res= ource */ + VIRT_RETURN_STRING(name); +} + +/* * Function name: libvirt_version * Since version: 0.4.1(-1) * Description: Function is used to get libvirt, driver and libvirt-ph= p version numbers. Can be used for information purposes, for version checki= ng please use libvirt_check_version() defined below diff --git a/src/libvirt-php.h b/src/libvirt-php.h index 1a003f5..f87d180 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -420,6 +420,9 @@ PHP_FUNCTION(libvirt_network_get_bridge); PHP_FUNCTION(libvirt_network_get_information); PHP_FUNCTION(libvirt_network_get_active); PHP_FUNCTION(libvirt_network_set_active); +PHP_FUNCTION(libvirt_network_get_uuid_string); +PHP_FUNCTION(libvirt_network_get_uuid); +PHP_FUNCTION(libvirt_network_get_name); /* Nodedev functions */ PHP_FUNCTION(libvirt_nodedev_get); PHP_FUNCTION(libvirt_nodedev_capabilities); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list