mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-20 11:48:28 -06:00
libxl: implement per NUMA node free memory reporting
By providing the implementation of nodeGetCellsFreeMemory for the driver. This is all just a matter of properly formatting, in a way that libvirt like, what Xen provides via libxl_get_numainfo(). [raistlin@Zhaman ~]$ sudo virsh --connect xen:/// freecell --all 0: 25004 KiB 1: 105848 KiB -------------------- Total: 130852 KiB Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
This commit is contained in:
parent
d79c9273b0
commit
4b9eec50fe
@ -4097,6 +4097,51 @@ libxlNodeGetFreeMemory(virConnectPtr conn)
|
||||
return phy_info.free_pages * ver_info->pagesize;
|
||||
}
|
||||
|
||||
static int
|
||||
libxlNodeGetCellsFreeMemory(virConnectPtr conn,
|
||||
unsigned long long *freeMems,
|
||||
int startCell,
|
||||
int maxCells)
|
||||
{
|
||||
int n, lastCell, numCells;
|
||||
int ret = -1, nr_nodes = 0;
|
||||
libxl_numainfo *numa_info = NULL;
|
||||
libxlDriverPrivatePtr driver = conn->privateData;
|
||||
|
||||
if (virNodeGetCellsFreeMemoryEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
/* Early failure is probably worth just a warning */
|
||||
numa_info = libxl_get_numainfo(driver->ctx, &nr_nodes);
|
||||
if (numa_info == NULL || nr_nodes == 0) {
|
||||
VIR_WARN("libxl_get_numainfo failed to retrieve NUMA data");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check/sanitize the cell range */
|
||||
if (startCell > nr_nodes) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("start cell %d out of range (0-%d)"),
|
||||
startCell, nr_nodes);
|
||||
goto cleanup;
|
||||
}
|
||||
lastCell = startCell + maxCells - 1;
|
||||
if (lastCell > nr_nodes)
|
||||
lastCell = nr_nodes;
|
||||
|
||||
for (numCells = 0, n = startCell; n <= lastCell; n++) {
|
||||
if (numa_info[n].size == LIBXL_NUMAINFO_INVALID_ENTRY)
|
||||
freeMems[numCells++] = 0;
|
||||
else
|
||||
freeMems[numCells++] = numa_info[n].free;
|
||||
}
|
||||
ret = numCells;
|
||||
|
||||
cleanup:
|
||||
libxl_numainfo_list_free(numa_info, nr_nodes);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
libxlConnectDomainEventRegister(virConnectPtr conn,
|
||||
virConnectDomainEventCallback callback, void *opaque,
|
||||
@ -4683,6 +4728,7 @@ static virDriver libxlDriver = {
|
||||
.domainSetSchedulerParameters = libxlDomainSetSchedulerParameters, /* 0.9.0 */
|
||||
.domainSetSchedulerParametersFlags = libxlDomainSetSchedulerParametersFlags, /* 0.9.2 */
|
||||
.nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
|
||||
.nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */
|
||||
.connectDomainEventRegister = libxlConnectDomainEventRegister, /* 0.9.0 */
|
||||
.connectDomainEventDeregister = libxlConnectDomainEventDeregister, /* 0.9.0 */
|
||||
.domainManagedSave = libxlDomainManagedSave, /* 0.9.2 */
|
||||
|
Loading…
Reference in New Issue
Block a user