Commit bedfea18 authored by John Ferlan's avatar John Ferlan

Add virDomainGetIOThreads and virDomainPinIOThread bindings

Test results in the following output:

$ perl examples/iothreadsinfo.pl
Addr
VMM type: QEMU
...
Domain: {
  ID: 2 'f18iothr'
  UUID: fb9f7826-b5d7-4f74-b962-7181ef3fc9ec
  IOThread: {
    affinity: 0010
    number: 1
  }
  IOThread: {
    affinity: 0001
    number: 2
  }
  IOThread: {
    affinity: 1100
    number: 3
  }
}
parent 313ca20b
......@@ -4,6 +4,7 @@ Revision history for perl module Sys::Virt
- Add VIR_CONNECT_BASELINE_CPU_MIGRATABLE constant
- Add VIR_DOMAIN_CONTROL_ERROR_* constants
- Add virDomainGetIOThreads and virDomainPinIOThread API bindings
1.2.13 2015-03-05
......
......@@ -5014,6 +5014,48 @@ get_emulator_pin_info(dom, flags=0)
RETVAL
void
get_iothread_info(dom, flags=0)
virDomainPtr dom;
unsigned int flags;
PREINIT:
virDomainIOThreadInfoPtr *iothrinfo;
int niothreads;
int i;
PPCODE:
if ((niothreads = virDomainGetIOThreadsInfo(dom, &iothrinfo,
flags)) < 0)
_croak_error();
EXTEND(SP, niothreads);
for (i = 0 ; i < niothreads ; i++) {
HV *rec = newHV();
(void)hv_store(rec, "number", 6,
newSViv(iothrinfo[i]->iothread_id), 0);
(void)hv_store(rec, "affinity", 8,
newSVpvn((char*)iothrinfo[i]->cpumap,
iothrinfo[i]->cpumaplen), 0);
PUSHs(newRV_noinc((SV *)rec));
}
Safefree(iothrinfo);
void
pin_iothread(dom, iothread_id, mask, flags=0)
virDomainPtr dom;
unsigned int iothread_id;
SV *mask;
unsigned int flags;
PREINIT:
STRLEN masklen;
unsigned char *maps;
PPCODE:
maps = (unsigned char *)SvPV(mask, masklen);
if (virDomainPinVcpuFlags(dom, iothread_id, maps, masklen, flags) < 0)
_croak_error();
int
num_of_snapshots(dom, flags=0)
virDomainPtr dom;
......
# -*- perl -*-
use strict;
use warnings;
use Sys::Virt;
my $addr = @ARGV ? shift @ARGV : "";
print "Addr $addr\n";
my $con = Sys::Virt->new(address => $addr, readonly => 1);
print "VMM type: ", $con->get_type(), "\n";
foreach my $dom (sort { $a->get_id <=> $b->get_id } $con->list_all_domains) {
print "Domain: {\n";
print " ID: ", $dom->get_id(), " '" , $dom->get_name(), "'\n";
print " UUID: ", $dom->get_uuid_string(), "\n";
my $nodeinfo = $con->get_node_info;
my @info = $dom->get_iothread_info(Sys::Virt::Domain::AFFECT_CONFIG);
foreach my $info (@info) {
print " IOThread: {\n";
foreach (sort { $a cmp $b } keys %{$info}) {
if ($_ eq "affinity") {
print " ", $_, ": ";
my @bits = split(//, unpack("b$nodeinfo->{cpus}", $info->{$_}));
print join ("", @bits), "\n";
} else {
print " ", $_, ": ", $info->{$_}, "\n";
}
}
print " }\n";
}
print "}\n";
}
......@@ -1216,6 +1216,23 @@ the physical CPUa, 8 cpus per character. To create a suitable
bitstring, use the C<vec> function with a value of C<1> for the
C<BITS> parameter.
=item @iothreadinfo = $dom->get_iothread_info($flags=0)
Obtain information about the state of all IOThreads in a running
guest domain. The returned list will have one element for each IOThread,
where each elements contains a hash reference. The keys in the hash
are, C<number> the IOThread number and C<affinity> giving the allowed
schedular placement. The value for C<affinity> is a
string representing a bitmask against physical CPUs, 8 cpus per
character. To extract the bits use the C<unpack> function with
the C<b*> template.
=item $dom->pin_iothread($iothread, $mask)
Pin the IOThread given by index C<$iothread> to physical CPUs
given by C<$mask>. The C<$mask> is a string representing a bitmask
against physical CPUs, 8 cpus per character.
=item my @stats = $dom->get_cpu_stats($startCpu, $numCpus, $flags=0)
Requests the guests host physical CPU usage statistics, starting
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment