Okay enclosed is a first patch to add the new entry point for getting
the available memeory in the NUMA cells:
/**
* virNodeGetCellFreeMemory:
* @conn: pointer to the hypervisor connection
* @freeMems: pointer to the array of unsigned long
* @nbCells: number of entries available in freeMems
*
* This call allows to ask the amount of free memory in each NUMA cell.
* The @freeMems array must be allocated by the caller and will be filled
* with the amounts of free memory in kilobytes for each cell starting
* from cell #0 and up to @nbCells -1 or the number of cell in the Node
* (which can be found using virNodeGetInfo() see the nodes entry in the
* structure).
*
* Returns the number of entries filled in freeMems, or -1 in case of error.
*/
int
virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long *freeMems,
int nbCells)
based on the feedback, it seems it's better to provide an API checking
a range of cells. This version suggest to always start at cell 0, it could be
extended to start at a base cell number, not a big change, is it needed ?
The patch adds it to the driver interfaces and put the entry point
needed in the xen_internal.c module xenHypervisorNodeGetCellsFreeMemory() .
From there it needs a new function (or set of functions) actually doing
one hypercall to get the free mem for a NUMA cell, and the loop to fill
the array @freeMems. The hard part is of course to set the definitions
and code doing the hypercall:
We will need to check the current hypercall version since this was added
recently, see how xenHypervisorGetSchedulerType() does the versionning,
we will have to write a similar routine , extend xen_op_v2_sys to
add support for the availheap call structures, add the define for
the availheap system call, glue the whole and call the new function
from the loop in xenHypervisorNodeGetCellsFreeMemory() ... this can be
a little fun to debug.
Now for extending virConnectGetCapabilities() it is a bit messy not not
that much. First it's implemented on Xen using xenHypervisorGetCapabilities,
unfortunately it seems the easiest way to get the NUMA capabilities is by
asking though xend. Calling xend_internals.c from xen_internals.c is not
nice, but xenHypervisorGetCapabilities() is actually noty using any
hypervisor call as far as I can see, it's all about opening/parsing
files from /proc and /sys and returning the result as XML, so this could
as well be done in the xend_internals (or xen_unified.c) module.
so we will have a bit of surgery to do, but for the first steps of
writing the patch I would not be too concerned by calling a function
in xend_internal.c from xenHypervisorGetCapabilities (or
xenHypervisorMakeCapabilitiesXML) we will just move those 2 in the end
(only problem may be the access to hv_version variable).
Hope this helps, I will not be online most of the week but I will try
to help when possible :-)
Daniel
--
Red Hat Virtualization group
http://redhat.com/virtualization/
Daniel Veillard | virtualization library
http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/