From nobody Fri Apr 26 15:02:33 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=datto.com ARC-Seal: i=1; a=rsa-sha256; t=1562621596; cv=none; d=zoho.com; s=zohoarc; b=RwxRh/y5gYVtalZxBjiN3Qh9NK+WIrzHpFT73y6ONbicMJ7vadDKUiCfQMI32/mP1FZ8CdmoD151fd0fvSva3sJkE2Bfqud6laAVBdDVPjSFaQow6wEcUQoZR0pN+isxlGYltf8NPQI+IPksMSjYCARi8R4e/oF1qbusZ48C7zM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562621596; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jZHWAXMEE+nb7IXfbFFRRQVgBVy2ucaqq5Hf0Wp2F1A=; b=Rkl2T/LaxLVwJObvtite7BcXB8M+9c4F621Xc1xBLx6lhaYqVQUWJDn+/MWWbNklsonCMZruvTJADNohpK9tRuOnsjBK6rgyohQqHQbrTwLo8Cyms6xiIu/r3rLXI/komihWCUtCWwAJa+6Kjp8wgoXn06jb/f8mw7z23lkW+FE= ARC-Authentication-Results: i=1; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562621596725910.5999473901586; Mon, 8 Jul 2019 14:33: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 87050308621B; Mon, 8 Jul 2019 21:33:09 +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 554365D9C8; Mon, 8 Jul 2019 21:33:02 +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 BC5708E1F; Mon, 8 Jul 2019 21:32:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x68LWneO015220 for ; Mon, 8 Jul 2019 17:32:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id BE297111F3C2; Mon, 8 Jul 2019 21:32:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.rdu2.redhat.com [10.11.55.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B903C111F3B6 for ; Mon, 8 Jul 2019 21:32:47 +0000 (UTC) Received: from us-smtp-delivery-195.mimecast.com (us-smtp-delivery-195.mimecast.com [216.205.24.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D47877D89 for ; Mon, 8 Jul 2019 21:32:47 +0000 (UTC) Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-xIZUTJggPTOTSIenF0plzQ-1; Mon, 08 Jul 2019 17:32:15 -0400 Received: by mail-qt1-f200.google.com with SMTP id i12so14863678qtq.4 for ; Mon, 08 Jul 2019 14:32:15 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id j184sm7836012qkc.65.2019.07.08.14.32.14 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 14:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto.com; s=mimecast20190208; t=1562621567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E3THaBmGG6LKjzHR2taGWxhtQ1djEyB/h+HfyJmrOog=; b=X5JTSLll6RdzZ/zFVRPKBr8A+o5jvnTkJcgMazd55QDt1Recx/DWYbnZL2ilzXjRrtCaID Ht5N8Kv40yS3HnYbkyFpFaVuudUpSdBCIpIKsbDelM2Qn8NKHTgdh3B5KiDDQ1KeCfXRh8 5U8MNYkkpm3iOgFnv8/B947mBXDZB44= 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:mime-version:content-transfer-encoding; bh=VQX0uMV0mk7mZ9A0qFrC7+I6lEf9SP98/MeohAEYjSg=; b=CV/yUSSKlCLTAdBpTW6B0dT1kaVsHUE9HLuv/EZJvmp9b4AhOENQiNoWhQtkXE90VX Z8Pdxj3MGa+GYRcEWyoWTU42FAxlsxnXoSO3ri2a8sqZXmF2Bq2zOA9MwqI9gGwv4rEy IfktpKKWCMIwv/mgMqZN/jlRQYAyzjDtzwARMsh5FqYS62rUNs8lll9fbrUK2I28A3Dj xJnO++h4lJF5/AA5WTFnze3bqdFdRsejO0u1Qt7MpjGPCVdpim8SgmzVy0Aj+7xhgbyy XUObDwDOmK/UI1N9iqjs4oQanbhFrTK7CpT0b5vfoiLPERLmyH5u9fmvhPtPaJz6wL8F w8pQ== X-Gm-Message-State: APjAAAX46tTdKjDvbdYyjfe9eJ7gv1vvRFAD09w4F1mFllBlwEyXGdwN hQZgG6FBtcOXreLP4SYJ0XhkSz5QABB85MB8hdByXUgbTCmDfmL5YqmfJxbOId80x9pDcLC3xUm 8w81ArJo94E63nbWZ X-Received: by 2002:ac8:4413:: with SMTP id j19mr15599448qtn.281.1562621534737; Mon, 08 Jul 2019 14:32:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxxSruuktoMweAdgF4n37ZXN1nhYOL2xxDKEfQm1L0PqQlRYb3KnDx+JevF+OY7D2jdmdK3A== X-Received: by 2002:ac8:4413:: with SMTP id j19mr15599435qtn.281.1562621534559; Mon, 08 Jul 2019 14:32:14 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 17:32:11 -0400 Message-Id: <20190708213212.9002-2-dzamirski@datto.com> In-Reply-To: <20190708213212.9002-1-dzamirski@datto.com> References: <20190708213212.9002-1-dzamirski@datto.com> MIME-Version: 1.0 X-MC-Unique: xIZUTJggPTOTSIenF0plzQ-1 X-Mimecast-Spam-Score: 0 X-Greylist: Sender passed SPF test, ACL 243 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 08 Jul 2019 21:32:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 08 Jul 2019 21:32:47 +0000 (UTC) for IP:'216.205.24.195' DOMAIN:'us-smtp-delivery-195.mimecast.com' HELO:'us-smtp-delivery-195.mimecast.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -0.8 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS) 216.205.24.195 us-smtp-delivery-195.mimecast.com 216.205.24.195 us-smtp-delivery-195.mimecast.com X-Scanned-By: MIMEDefang 2.78 on 10.11.55.2 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id x68LWneO015220 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 1/2] Fix PHP7 VIRT_ARRAY_INIT macro 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: , 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.42]); Mon, 08 Jul 2019 21:33:13 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is a PHP 7 compatibilty macro which was segfaulting due to the temporary variable being defined in the do..while scoped block (to swallow semicolon for macros), e.g: zval *arr; VIRT_ARRAY_INIT(arr); VIRT_ADD_ASSOC_STRING(arr, "foo", "bar"); // <=3D segfault here The VIRT_ARRAY_INIT above was expanding to: do { zval z_arr; // <=3D local scope definition arr =3D &z_arr; array_init(arr); } while (0) After this patch, the macro expands to: zval z_arr; // now defined in the scope of the macro caller do { arr =3D &z_arr; array_init(arr); } while (0) which solved the issue. --- src/util.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util.h b/src/util.h index 3af77d4..c96fd0c 100644 --- a/src/util.h +++ b/src/util.h @@ -151,10 +151,11 @@ } \ } while(0) =20 -# define VIRT_ARRAY_INIT(_name) do { \ +# define VIRT_ARRAY_INIT(_name) \ zval z##_name; \ - _name =3D &z##_name; \ - array_init(_name); \ + do { \ + _name =3D &z##_name; \ + array_init(_name); \ } while(0) =20 # else /* PHP_MAJOR_VERSION < 7 */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 15:02:33 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=datto.com ARC-Seal: i=1; a=rsa-sha256; t=1562621597; cv=none; d=zoho.com; s=zohoarc; b=g375LSsAD4Bk3EFEtlFosuue3Ku1cDzfsxBD+81zov06Mvif+QKAfMzfybu1h6x6n5Tahyl6Mpbk3y/mCrYDjZkEstefjloIDtyEKK78CX83hDyIHImvcbO9w+3JXM9g1XLqH010nzpL3oJnCxNi1/Mo4CjWtopesVPwkTD2f4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562621597; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=TPydXPV1Ol7ju8v5wUMarQ4fFevREbKhCdU7P46pRYo=; b=FW9RIp4eVwW/lK/2RwwHpLqvMO0v7GNv/FHidOo9QL5G7FUFwcKsHwiEfNbCw6ArkDYIVpcyWtDu/ORqYZiu4NPx/+6Eka6BQHE7uPbmUnXaY7Wk9wXumXGCA+siaQolbwLY+7BS20ZZ2TsQHkOlfOaI++otTcVeuJ+4P76bGd8= ARC-Authentication-Results: i=1; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562621596961213.91265626706684; Mon, 8 Jul 2019 14:33: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 A48A8A3B66; Mon, 8 Jul 2019 21:33:08 +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 64E755D96E; Mon, 8 Jul 2019 21:33:06 +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 318DE18184AC; Mon, 8 Jul 2019 21:32:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x68LWpkC015232 for ; Mon, 8 Jul 2019 17:32:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5FE7C2027EA0; Mon, 8 Jul 2019 21:32:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.rdu2.redhat.com [10.11.55.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AA2F2026D5B for ; Mon, 8 Jul 2019 21:32:49 +0000 (UTC) Received: from us-smtp-delivery-195.mimecast.com (us-smtp-delivery-195.mimecast.com [63.128.21.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0EFD402611A for ; Mon, 8 Jul 2019 21:32:47 +0000 (UTC) Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-aY9BKKBnOjKlOShZx1mrew-1; Mon, 08 Jul 2019 17:32:15 -0400 Received: by mail-qk1-f199.google.com with SMTP id h198so17606449qke.1 for ; Mon, 08 Jul 2019 14:32:15 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id j184sm7836012qkc.65.2019.07.08.14.32.14 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 14:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto.com; s=mimecast20190208; t=1562621567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7F/46BnmvYOs+E79Tg+2i1tCFPMTwI2s0NPelrRO+ww=; b=HRNLTJr8pGtxlHAChmhB+bVDeDetFTaXWcum2CI8Ox2F6GSN3AXMsu22KSAoPLDtMRGzVm BhuXw78XevdEzhCvLH9cFuIR2r9zDJY2j2dvUlYN0lRlUkJGwh45n9F9NybPMtm7qIKpRW /S+Q/rZpO0JpAz8DNTFoLI04bBnVCqU= 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:mime-version:content-transfer-encoding; bh=Ac8PPUNwP+bdi6O2X7mWh5CNh9F52aIHAEaYddnxVS8=; b=una2VHtzO0l/guOhogNpK8xHZvWRigm6mZ/Qxa41mHtheGxFQDDF5/IGL0SIIyjOUg Iex8Mr73VaEK61ovzDhFwfrrjy6QgcWBlBIvOmoojgdBplN2WYhZbpw+eSYidCtqFe9m B2xzl6cNS1FUYkdCTXiOH2igfx03MW2LsuHW5ZZb3pZ6hQLJN9DfIF4VS1QPeJiJJ3rr 16zkqwmJg+j3l1fCadUSN4kNpDiaE0CJCikO/qBmlDHccH3Aw6iYGJTip3b90XCXJldI D74jYTGsj56IDmCg0ILZ6IBw7bFA1e8k5Ud5Dx53Jl+z7hiWRYuyY5cwCoHX3FHYk19r h2jQ== X-Gm-Message-State: APjAAAWxno5OkQpnPApCbz6Ic2F2a6CGsFfz3o2dEK+3c8YU6VhY4zI9 b6OXDEftQHI0pjjlo5iYVsRP3j+OTic3ss/gZ4eGuGUuWhHUjg5WlsTm3fFgnAWPZNUva4tOwrl omDkzgvy6WX7i53Dj X-Received: by 2002:a0c:b07b:: with SMTP id l56mr16434273qvc.114.1562621535242; Mon, 08 Jul 2019 14:32:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqy32LLLHYacryuO2ILc3aFSxdYW6zJQeb7lSGB/E5jeE34tYmPJ0LFhTcEcsmUjbYqcQIm6TQ== X-Received: by 2002:a0c:b07b:: with SMTP id l56mr16434263qvc.114.1562621535020; Mon, 08 Jul 2019 14:32:15 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 17:32:12 -0400 Message-Id: <20190708213212.9002-3-dzamirski@datto.com> In-Reply-To: <20190708213212.9002-1-dzamirski@datto.com> References: <20190708213212.9002-1-dzamirski@datto.com> MIME-Version: 1.0 X-MC-Unique: aY9BKKBnOjKlOShZx1mrew-1 X-Mimecast-Spam-Score: 0 X-Greylist: Sender passed SPF test, ACL 243 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 08 Jul 2019 21:32:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 08 Jul 2019 21:32:47 +0000 (UTC) for IP:'63.128.21.195' DOMAIN:'us-smtp-delivery-195.mimecast.com' HELO:'us-smtp-delivery-195.mimecast.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -0.8 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS) 63.128.21.195 us-smtp-delivery-195.mimecast.com 63.128.21.195 us-smtp-delivery-195.mimecast.com X-Scanned-By: MIMEDefang 2.78 on 10.11.55.6 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id x68LWpkC015232 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 2/2] Add binding for virDomainInterfaceAddresses. 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: , 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.30]); Mon, 08 Jul 2019 21:33:13 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" A straight-forward 1:1 mapping to the C API. Returns array in the following format: array ( 0 =3D> array ( 'name' =3D> 'vnet0', 'hwaddr' =3D> '52:54:00:3a:cd:94', 'naddrs' =3D> 1, 'addrs' =3D> array ( 'addr' =3D> '192.168.254.224', 'prefix' =3D> 24, 'type' =3D> 0, ), ), ) --- src/libvirt-domain.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ src/libvirt-domain.h | 2 ++ src/libvirt-php.c | 9 ++++++++ 3 files changed, 66 insertions(+) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 8b8bb45..877d311 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -1948,6 +1948,61 @@ PHP_FUNCTION(libvirt_domain_block_job_set_speed) RETURN_TRUE; } =20 +/* + * Function name: libvirt_domain_interface_addresses + * Since version: 0.5.5 + * Description: Function is used to get network interface addresses fo= r the domain + * Arguments: @domain [resource]: libvirt domain resource, e.g. from= libvirt_domain_lookup_by_*() + * @source [int]: one of the VIR_DOMAIN_ADDRESSES_SRC_* f= lags. + * Returns: interface array of a domain holding information about = addresses resembling the virDomainInterface structure, false on error + */ +PHP_FUNCTION(libvirt_domain_interface_addresses) +{ + php_libvirt_domain *domain =3D NULL; + zval *zdomain; + zend_long source =3D 0; + + virDomainInterfacePtr *ifaces =3D NULL; + int count =3D 0; + size_t i, j; + + GET_DOMAIN_FROM_ARGS("rl", &zdomain, &source); + + if ((count =3D virDomainInterfaceAddresses(domain->domain, &ifaces, so= urce, 0)) < 0) { + RETURN_FALSE + goto cleanup; + } + + array_init(return_value); + + for (i =3D 0; i < count; i++) { + zval *iface; + VIRT_ARRAY_INIT(iface); + VIRT_ADD_ASSOC_STRING(iface, "name", ifaces[i]->name); + VIRT_ADD_ASSOC_STRING(iface, "hwaddr", ifaces[i]->hwaddr); + add_assoc_long(iface, "naddrs", ifaces[i]->naddrs); + + for (j =3D 0; j < ifaces[i]->naddrs; j++) { + zval *ifaddr; + VIRT_ARRAY_INIT(ifaddr); + VIRT_ADD_ASSOC_STRING(ifaddr, "addr", ifaces[i]->addrs[j].addr= ); + add_assoc_long(ifaddr, "prefix", ifaces[i]->addrs[j].prefix); + add_assoc_long(ifaddr, "type", ifaces[i]->addrs[j].type); + + add_assoc_zval(iface, "addrs", ifaddr); + } + + add_index_zval(return_value, i, iface); + } + + cleanup: + if (ifaces && count > 0) { + for (i =3D 0; i < count; i++) + virDomainInterfaceFree(ifaces[i]); + } + VIR_FREE(ifaces); +} + /* * Function name: libvirt_domain_interface_stats * Since version: 0.4.1(-1) diff --git a/src/libvirt-domain.h b/src/libvirt-domain.h index dc0ab46..f15237f 100644 --- a/src/libvirt-domain.h +++ b/src/libvirt-domain.h @@ -89,6 +89,7 @@ PHP_FE(libvirt_domain_block_job_info, arginfo_libvirt_domain_bl= ock_job_info) \ PHP_FE(libvirt_domain_block_job_abort, arginfo_libvirt_domain_bl= ock_job_abort) \ PHP_FE(libvirt_domain_block_job_set_speed, arginfo_libvirt_domain_bl= ock_job_set_speed) \ + PHP_FE(libvirt_domain_interface_addresses, arginfo_libvirt_domain_in= terface_addresses) \ PHP_FE(libvirt_domain_interface_stats, arginfo_libvirt_conn_path= ) \ PHP_FE(libvirt_domain_get_connect, arginfo_libvirt_conn) = \ PHP_FE(libvirt_domain_migrate, arginfo_libvirt_domain_mi= grate) \ @@ -179,6 +180,7 @@ PHP_FUNCTION(libvirt_domain_block_resize); PHP_FUNCTION(libvirt_domain_block_job_info); PHP_FUNCTION(libvirt_domain_block_job_abort); PHP_FUNCTION(libvirt_domain_block_job_set_speed); +PHP_FUNCTION(libvirt_domain_interface_addresses); PHP_FUNCTION(libvirt_domain_interface_stats); PHP_FUNCTION(libvirt_domain_get_connect); PHP_FUNCTION(libvirt_domain_migrate); diff --git a/src/libvirt-php.c b/src/libvirt-php.c index cf8fd7f..04b7c07 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -248,6 +248,11 @@ ZEND_ARG_INFO(0, bandwidth) ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO() =20 +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_interface_addresses, 0, 0, 2) +ZEND_ARG_INFO(0, domain) +ZEND_ARG_INFO(0, source) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_block_job_info, 0, 0, 2) ZEND_ARG_INFO(0, dom) ZEND_ARG_INFO(0, disk) @@ -1476,6 +1481,10 @@ PHP_MINIT_FUNCTION(libvirt) REGISTER_LONG_CONSTANT("VIR_DOMAIN_MEM_LIVE", VIR_DOMAIN_MEM_LIVE, C= ONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("VIR_DOMAIN_MEM_MAXIMUM", VIR_DOMAIN_MEM_MAX= IMUM, CONST_CS | CONST_PERSISTENT); =20 + REGISTER_LONG_CONSTANT("VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE", VIR= _DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT", VIR= _DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP", VIR_D= OMAIN_INTERFACE_ADDRESSES_SRC_LEASE, CONST_CS | CONST_PERSISTENT); + /* Connect flags */ REGISTER_LONG_CONSTANT("VIR_CONNECT_FLAG_SOUNDHW_GET_NAMES", CONNEC= T_FLAG_SOUNDHW_GET_NAMES, CONST_CS | CONST_PERSISTENT); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list