Debian Codegraph @

examples/vcpuinfo.pl

raw
1 # -*- perl -*-
2 use strict;
3 use warnings;
4 use Sys::Virt;
5
6 my $addr = @ARGV ? shift @ARGV : "";
7 print "Addr $addr\n";
8 my $con = Sys::Virt->new(address => $addr, readonly => 1);
9
10 print "VMM type: ", $con->get_type(), "\n";
11
12 foreach my $dom (sort { $a->get_id <=> $b->get_id } $con->list_all_domains) {
13 print "Domain: {\n";
14 print " ID: ", $dom->get_id(), " '" , $dom->get_name(), "'\n";
15 print " UUID: ", $dom->get_uuid_string(), "\n";
16 my $nodeinfo = $con->get_node_info;
17 my @info = $dom->get_vcpu_info(Sys::Virt::Domain::AFFECT_CONFIG);
18
19 foreach my $info (@info) {
20 print " VCPU: {\n";
21 foreach (sort { $a cmp $b } keys %{$info}) {
22 if ($_ eq "affinity") {
23 print " ", $_, ": ";
24 my @mask = split(//, unpack("b$nodeinfo->{cpus}", $info->{$_}));
25 print join ("", @mask), "\n";
26 print "\n";
27 } else {
28 print " ", $_, ": ", $info->{$_}, "\n";
29 }
30 }
31 print " }\n";
32 }
33 print "}\n";
34 }