[libvirt-perl PATCHv2 2/2] Update the vcpuinfo.pl example

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

 



Based on the review of my iothreadsinfo.pl example which I took from
vcpuinfo.pl, this patch updates the vcpuinfo.pl to follow the changes
made in iothreadsinfo.pl

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 Changes              | 1 +
 examples/vcpuinfo.pl | 6 ++----
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/Changes b/Changes
index 88f648c..124b798 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@ Revision history for perl module Sys::Virt
 1.2.14 2015-00-00
 
  - Add virDomainGetIOThreads and virDomainPinIOThread API bindings
+ - Update the vcpuinfo.pl example to use unpack
 
 1.2.13 2015-03-05
 
diff --git a/examples/vcpuinfo.pl b/examples/vcpuinfo.pl
index 6b07433..79dcf89 100644
--- a/examples/vcpuinfo.pl
+++ b/examples/vcpuinfo.pl
@@ -21,10 +21,8 @@ foreach my $dom (sort { $a->get_id <=> $b->get_id } $con->list_all_domains) {
 	foreach (sort { $a cmp $b } keys %{$info}) {
 	    if ($_ eq "affinity") {
 		print "    ", $_, ": ";
-		my @mask = split //, $info->{$_};
-		for (my $p = 0 ; $p < $nodeinfo->{cpus} ; $p++) {
-		    print ((ord($mask[$p/8]) & (1 << ($p % 8))) ? 1 : 0);
-		}
+                my @mask = split(//, unpack("b$nodeinfo->{cpus}", $info->{$_}));
+                print join ("", @mask), "\n";
 		print "\n";
 	    } else {
 		print "    ", $_, ": ", $info->{$_}, "\n";
-- 
2.1.0

--
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]