[perl][PATCH] Add virConnectGetStoragePoolCapabilities binding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 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
 
 5.0.0 2019-01-21
 
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;
 
 use Sys::Virt;
+use XML::XPath;
+use XML::XPath::XMLParser;
 
 my $addr = @ARGV ? shift @ARGV : "";
 
@@ -33,5 +35,16 @@ foreach my $info (@info) {
     print "\n";
 }
 
+my $poolCaps = $hv->get_storage_pool_capabilities();
+my @poolTypes = ();
+
+my $xp = XML::XPath->new(xml => $poolCaps);
+my $nodeset = $xp->find('/storagepoolCapabilities/pool[@supported="yes"]/@type');
+foreach my $node ($nodeset->get_nodelist) {
+    push (@poolTypes, $node->getNodeValue());
+}
+
+print "Supported pool types: @poolTypes\n";
+
 my $xml = $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.
 
+=item my $xml = $con->get_storage_pool_capabilities($flags=0);
+
+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.
+
 =item my $result = $con->compare_cpu($xml, $flags=0);
 
 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
 
 
+SV *
+get_storage_pool_capabilities(con, flags=0)
+      virConnectPtr con;
+      unsigned int flags;
+PREINIT:
+      char *xml;
+   CODE:
+      if (!(xml = virConnectGetStoragePoolCapabilities(con, flags)))
+          _croak_error();
+
+      RETVAL = newSVpv(xml, 0);
+      free(xml);
+  OUTPUT:
+      RETVAL
+
+
 SV *
 compare_cpu(con, xml, flags=0)
       virConnectPtr con;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux