Commit 74a79738 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add virNodeGetFreePages method

Signed-off-by: 's avatarDaniel P. Berrange <berrange@redhat.com>
parent 268e0e0c
......@@ -5,6 +5,7 @@ Revision history for perl module Sys::Virt
- Add VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT and
VIR_DOMAIN_BLOCK_COMMIT_ACTIVE constants
- Add VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2 constant
- Add virNodeGetFreePages method
1.2.5 2014-06-02
......
......@@ -1781,6 +1781,57 @@ PREINIT:
Safefree(mem);
void
get_node_free_pages(con, pagesizes, start, end, flags=0)
virConnectPtr con;
SV *pagesizes;
int start;
int end;
unsigned int flags;
PREINIT:
AV *pagesizeslist;
unsigned int *pages;
unsigned int npages;
unsigned long long *counts;
int ncells;
int i, j;
PPCODE:
ncells = (end - start) + 1;
pagesizeslist = (AV *)SvRV(pagesizes);
npages = av_len(pagesizeslist) + 1;
Newx(pages, npages, unsigned int);
for (i = 0; i < npages; i++) {
SV **pagesize = av_fetch(pagesizeslist, i, 0);
pages[i] = SvIV(*pagesize);
}
Newx(counts, npages * ncells, unsigned long long);
if (virNodeGetFreePages(con, npages, pages, start,
ncells, counts, flags) < 0) {
Safefree(counts);
Safefree(pages);
_croak_error();
}
EXTEND(SP, ncells);
for (i = 0; i < ncells; i++) {
HV *rec = newHV();
HV *prec = newHV();
(void)hv_store(rec, "cell", 4, newSViv(start + i), 0);
(void)hv_store(rec, "pages", 5, newRV_noinc((SV *)prec), 0);
for (j = 0; j < npages; j++) {
(void)hv_store_ent(prec,
newSViv(pages[j]),
virt_newSVull(counts[(i * npages) + j]),
0);
}
PUSHs(newRV_noinc((SV *)rec));
}
Safefree(counts);
Safefree(pages);
HV *
get_node_cpu_stats(con, cpuNum=VIR_NODE_CPU_STATS_ALL_CPUS, flags=0)
virConnectPtr con;
......
......@@ -14,3 +14,8 @@ my $info = $hv->get_node_info();
my @models = $hv->get_cpu_model_names($info->{model});
print join ("\n", sort{ lc $a cmp lc $b } @models), "\n";
my @info = $hv->get_node_free_pages([2048], 0, 0);
use Data::Dumper;
print Dumper(\@info);
......@@ -1625,6 +1625,19 @@ Returns the current free memory on the host
Returns the free memory on each NUMA cell between C<$start> and C<$end>.
=item @pages = $con->get_node_free_pages(\@pagesizes, $start, $end);
Returns information about the number of pages free on each NUMA cell
between C<$start> and C<$end> inclusive. The C<@pagesizes> parameter
should be an arrayref specifying which pages sizes information should
be returned for. Information about supported page sizes is available
in the capabilities XML. The returned array has an element for each
NUMA cell requested. The elements are hash references with two keys,
'cell' specifies the NUMA cell number and 'pages' specifies the
free page information for that cell. The 'pages' value is another
hash reference where the keys are the page sizes and the values
are the free count for that size.
=back
=head1 CONSTANTS
......
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