1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

nodeinfo: Implement nodeAllocPages

And add stubs to other drivers like: lxc, qemu, uml and vbox.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2014-09-18 09:47:07 +02:00
parent d1fd4a9b3b
commit 0228fa11c0
7 changed files with 134 additions and 0 deletions

View File

@ -893,6 +893,7 @@ virLockManagerRelease;
# nodeinfo.h
nodeAllocPages;
nodeCapsInitNUMA;
nodeGetCellsFreeMemory;
nodeGetCPUBitmap;

View File

@ -5685,6 +5685,27 @@ lxcNodeGetFreePages(virConnectPtr conn,
}
static int
lxcNodeAllocPages(virConnectPtr conn,
unsigned int npages,
unsigned int *pageSizes,
unsigned long long *pageCounts,
int startCell,
unsigned int cellCount,
unsigned int flags)
{
bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
if (virNodeAllocPagesEnsureACL(conn) < 0)
return -1;
return nodeAllocPages(npages, pageSizes, pageCounts,
startCell, cellCount, add);
}
/* Function Tables */
static virDriver lxcDriver = {
.no = VIR_DRV_LXC,
@ -5776,6 +5797,7 @@ static virDriver lxcDriver = {
.domainReboot = lxcDomainReboot, /* 1.0.1 */
.domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */
.nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */
.nodeAllocPages = lxcNodeAllocPages, /* 1.2.8 */
};
static virStateDriver lxcStateDriver = {

View File

@ -2065,3 +2065,44 @@ nodeGetFreePages(unsigned int npages,
cleanup:
return ret;
}
int
nodeAllocPages(unsigned int npages,
unsigned int *pageSizes,
unsigned long long *pageCounts,
int startCell,
unsigned int cellCount,
bool add)
{
int ret = -1;
int cell, lastCell;
size_t i, ncounts = 0;
if ((lastCell = virNumaGetMaxNode()) < 0)
return 0;
if (startCell > lastCell) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("start cell %d out of range (0-%d)"),
startCell, lastCell);
goto cleanup;
}
lastCell = MIN(lastCell, startCell + (int) cellCount - 1);
for (cell = startCell; cell <= lastCell; cell++) {
for (i = 0; i < npages; i++) {
unsigned int page_size = pageSizes[i];
unsigned long long page_count = pageCounts[i];
if (virNumaSetPagePoolSize(cell, page_size, page_count, add) < 0)
goto cleanup;
ncounts++;
}
}
ret = ncounts;
cleanup:
return ret;
}

View File

@ -63,4 +63,11 @@ int nodeGetFreePages(unsigned int npages,
int startCell,
unsigned int cellCount,
unsigned long long *counts);
int nodeAllocPages(unsigned int npages,
unsigned int *pageSizes,
unsigned long long *pageCounts,
int startCell,
unsigned int cellCount,
bool add);
#endif /* __VIR_NODEINFO_H__*/

View File

@ -18142,6 +18142,27 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
}
static int
qemuNodeAllocPages(virConnectPtr conn,
unsigned int npages,
unsigned int *pageSizes,
unsigned long long *pageCounts,
int startCell,
unsigned int cellCount,
unsigned int flags)
{
bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
if (virNodeAllocPagesEnsureACL(conn) < 0)
return -1;
return nodeAllocPages(npages, pageSizes, pageCounts,
startCell, cellCount, add);
}
static virDriver qemuDriver = {
.no = VIR_DRV_QEMU,
.name = QEMU_DRIVER_NAME,
@ -18341,6 +18362,7 @@ static virDriver qemuDriver = {
.nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
.connectGetDomainCapabilities = qemuConnectGetDomainCapabilities, /* 1.2.7 */
.connectGetAllDomainStats = qemuConnectGetAllDomainStats, /* 1.2.8 */
.nodeAllocPages = qemuNodeAllocPages, /* 1.2.8 */
};

View File

@ -2897,6 +2897,27 @@ umlNodeGetFreePages(virConnectPtr conn,
}
static int
umlNodeAllocPages(virConnectPtr conn,
unsigned int npages,
unsigned int *pageSizes,
unsigned long long *pageCounts,
int startCell,
unsigned int cellCount,
unsigned int flags)
{
bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
if (virNodeAllocPagesEnsureACL(conn) < 0)
return -1;
return nodeAllocPages(npages, pageSizes, pageCounts,
startCell, cellCount, add);
}
static virDriver umlDriver = {
.no = VIR_DRV_UML,
.name = "UML",
@ -2959,6 +2980,7 @@ static virDriver umlDriver = {
.nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
.nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
.nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
.nodeAllocPages = umlNodeAllocPages, /* 1.2.8 */
};
static virStateDriver umlStateDriver = {

View File

@ -7462,6 +7462,24 @@ vboxNodeGetFreePages(virConnectPtr conn ATTRIBUTE_UNUSED,
return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
}
static int
vboxNodeAllocPages(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned int npages,
unsigned int *pageSizes,
unsigned long long *pageCounts,
int startCell,
unsigned int cellCount,
unsigned int flags)
{
bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
return nodeAllocPages(npages, pageSizes, pageCounts,
startCell, cellCount, add);
}
/**
* Function Tables
*/
@ -7533,6 +7551,7 @@ virDriver vboxCommonDriver = {
.domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
.connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
.nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
.nodeAllocPages = vboxNodeAllocPages, /* 1.2.8 */
};
static void updateDriver(void)