Commit acea6e31 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add binding for virNodeGetCPUMap API

Signed-off-by: 's avatarDaniel P. Berrange <berrange@redhat.com>
parent 962218ba
......@@ -1551,6 +1551,23 @@ get_node_security_model(con)
OUTPUT:
RETVAL
void
get_node_cpu_map(con, flags=0)
virConnectPtr con;
unsigned int flags;
PREINIT:
unsigned char *cpumaps;
unsigned int online;
int ncpus;
PPCODE:
if ((ncpus = virNodeGetCPUMap(con, &cpumaps, &online, flags)) < 0)
_croak_error();
EXTEND(SP, 3);
PUSHs(sv_2mortal(newSViv(ncpus)));
PUSHs(sv_2mortal(newSVpvn((char*)cpumaps, VIR_CPU_MAPLEN(ncpus))));
PUSHs(sv_2mortal(newSViv(online)));
free(cpumaps);
SV *
get_node_free_memory(con)
......
......@@ -47,3 +47,12 @@ for (my $i = 0 ; $i < $iterations ; $i++) {
$then = $now;
}
my ($totcpus, $onlinemask, $nonline) = $hv->get_node_cpu_map();
printf "CPUs total %d, online %d\n", $totcpus, $nonline;
my @bits = split(//, unpack("b*", $onlinemask));
for (my $i = 0 ; $i < $totcpus ; $i++) {
printf " %d: %d\n", $i, $bits[$i];
}
......@@ -1284,7 +1284,7 @@ The model of the CPU, eg x86_64
=item cpus
The total number of logical CPUs
The total number of logical CPUs.
=item mhz
......@@ -1308,6 +1308,22 @@ The number of threads per core
=back
NB, more accurate information about the total number of CPUs
and those online can be obtained using the C<get_node_cpu_map>
method.
=item my ($totcpus, $onlinemap, $totonline) = $con->get_node_cpu_map();
Returns an array containing information about the CPUs available
on the host. The first element, C<totcpus>, specifies the total
number of CPUs available to the host regardles of their online
stat. The second element, C<onlinemap>, provides a bitmap detailing
which CPUs are currently online. The third element, C<totonline>,
specifies the total number of online CPUs. The values in the bitmap
can be extracted using the C<unpack> method as follows:
my @onlinemap = split(//, unpack("b*", $onlinemap));
=item my $info = $con->get_node_cpu_stats($cpuNum=-1, $flags=0)
Returns a hash reference providing information about the host
......
......@@ -131,6 +131,7 @@ LIBVIR_VERSION_NUMBER
VIR_COPY_CPUMAP
VIR_CPU_MAPLEN
VIR_CPU_USABLE
VIR_CPU_USED
VIR_DOMAIN_BLKIO_FIELD_LENGTH
VIR_DOMAIN_BLOCK_STATS_FIELD_LENGTH
VIR_DOMAIN_EVENT_CALLBACK
......
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