From nobody Sat Sep 21 01:04: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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552120796965537.8186846565884; Sat, 9 Mar 2019 00:39:56 -0800 (PST) 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 1A048368E7; Sat, 9 Mar 2019 08:39:54 +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 4A8A35D70A; Sat, 9 Mar 2019 08:39:51 +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 0455341F3D; Sat, 9 Mar 2019 08:39:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x298dhVF008943 for ; Sat, 9 Mar 2019 03:39:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 952F35D9D1; Sat, 9 Mar 2019 08:39:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72CCC5D9C4 for ; Sat, 9 Mar 2019 08:39:39 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Sat, 9 Mar 2019 09:39:32 +0100 Message-Id: <7aea03904811fbd6393d10f3d429056347a740bc.1552120746.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [perl][PATCH] Add virConnectGetStoragePoolCapabilities binding 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 09 Mar 2019 08:39:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- Changes | 1 + examples/node-info.pl | 13 +++++++++++++ lib/Sys/Virt.pm | 6 ++++++ lib/Sys/Virt.xs | 16 ++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/Changes b/Changes index 6bff52d..39a1bd5 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,7 @@ Revision history for perl module Sys::Virt - Add VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY constant - Add VIR_DOMAIN_SAVE_IMAGE_XML_SECURE and VIR_DOMAIN_SNAPSHOT_XML_SECURE constants + - Add virConnectGetStoragePoolCapabilities binding =20 5.0.0 2019-01-21 =20 diff --git a/examples/node-info.pl b/examples/node-info.pl index 9655ab4..b31e90f 100644 --- a/examples/node-info.pl +++ b/examples/node-info.pl @@ -4,6 +4,8 @@ use strict; use warnings; =20 use Sys::Virt; +use XML::XPath; +use XML::XPath::XMLParser; =20 my $addr =3D @ARGV ? shift @ARGV : ""; =20 @@ -33,5 +35,16 @@ foreach my $info (@info) { print "\n"; } =20 +my $poolCaps =3D $hv->get_storage_pool_capabilities(); +my @poolTypes =3D (); + +my $xp =3D XML::XPath->new(xml =3D> $poolCaps); +my $nodeset =3D $xp->find('/storagepoolCapabilities/pool[@supported=3D"yes= "]/@type'); +foreach my $node ($nodeset->get_nodelist) { + push (@poolTypes, $node->getNodeValue()); +} + +print "Supported pool types: @poolTypes\n"; + my $xml =3D $hv->get_domain_capabilities(undef, "x86_64", undef, "kvm"); print $xml; diff --git a/lib/Sys/Virt.pm b/lib/Sys/Virt.pm index 8fd3e23..549dc54 100644 --- a/lib/Sys/Virt.pm +++ b/lib/Sys/Virt.pm @@ -1869,6 +1869,12 @@ an optional name of a guest machine, and C<$virttype= > is an optional name of the virtualization type. C<$flags> is unused and defaults to zero. =20 +=3Ditem my $xml =3D $con->get_storage_pool_capabilities($flags=3D0); + +Returns an XML document describing the storage pool driver +capabilities (e.g. which storage pool types are supported and so +on). C<$flags> is currently unused and defaults to zero. + =3Ditem my $result =3D $con->compare_cpu($xml, $flags=3D0); =20 Checks whether the CPU definition in C<$xml> is compatible with the diff --git a/lib/Sys/Virt.xs b/lib/Sys/Virt.xs index bc9320d..056d767 100644 --- a/lib/Sys/Virt.xs +++ b/lib/Sys/Virt.xs @@ -2774,6 +2774,22 @@ PREINIT: RETVAL =20 =20 +SV * +get_storage_pool_capabilities(con, flags=3D0) + virConnectPtr con; + unsigned int flags; +PREINIT: + char *xml; + CODE: + if (!(xml =3D virConnectGetStoragePoolCapabilities(con, flags))) + _croak_error(); + + RETVAL =3D newSVpv(xml, 0); + free(xml); + OUTPUT: + RETVAL + + SV * compare_cpu(con, xml, flags=3D0) virConnectPtr con; --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list