提交 38fa03f4 编写于 作者: M Michal Privoznik

nodeinfo: Implement nodeGetFreePages

And add stubs to other drivers like: lxc, qemu, uml and vbox.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 9e3efe53
...@@ -877,6 +877,7 @@ nodeGetCPUBitmap; ...@@ -877,6 +877,7 @@ nodeGetCPUBitmap;
nodeGetCPUCount; nodeGetCPUCount;
nodeGetCPUMap; nodeGetCPUMap;
nodeGetCPUStats; nodeGetCPUStats;
nodeGetFreePages;
nodeGetInfo; nodeGetInfo;
nodeGetMemory; nodeGetMemory;
nodeGetMemoryParameters; nodeGetMemoryParameters;
......
...@@ -5656,6 +5656,24 @@ lxcDomainGetCPUStats(virDomainPtr dom, ...@@ -5656,6 +5656,24 @@ lxcDomainGetCPUStats(virDomainPtr dom,
} }
static int
lxcNodeGetFreePages(virConnectPtr conn,
unsigned int npages,
unsigned int *pages,
int startCell,
unsigned int cellCount,
unsigned long long *counts,
unsigned int flags)
{
virCheckFlags(0, -1);
if (virNodeGetFreePagesEnsureACL(conn) < 0)
return -1;
return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
}
/* Function Tables */ /* Function Tables */
static virDriver lxcDriver = { static virDriver lxcDriver = {
.no = VIR_DRV_LXC, .no = VIR_DRV_LXC,
...@@ -5745,6 +5763,7 @@ static virDriver lxcDriver = { ...@@ -5745,6 +5763,7 @@ static virDriver lxcDriver = {
.domainShutdownFlags = lxcDomainShutdownFlags, /* 1.0.1 */ .domainShutdownFlags = lxcDomainShutdownFlags, /* 1.0.1 */
.domainReboot = lxcDomainReboot, /* 1.0.1 */ .domainReboot = lxcDomainReboot, /* 1.0.1 */
.domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */ .domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */
.nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */
}; };
static virStateDriver lxcStateDriver = { static virStateDriver lxcStateDriver = {
......
...@@ -2018,3 +2018,37 @@ nodeGetMemory(unsigned long long *mem, ...@@ -2018,3 +2018,37 @@ nodeGetMemory(unsigned long long *mem,
return 0; return 0;
} }
int
nodeGetFreePages(unsigned int npages,
unsigned int *pages,
int startCell,
unsigned int cellCount,
unsigned long long *counts)
{
int ret = -1;
int cell;
size_t i, ncounts = 0;
for (cell = startCell; cell < (int) (startCell + cellCount); cell++) {
for (i = 0; i < npages; i++) {
unsigned int page_size = pages[i];
unsigned int page_free;
if (virNumaGetPageInfo(cell, page_size, NULL, &page_free) < 0)
goto cleanup;
counts[ncounts++] = page_free;
}
}
if (!ncounts) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("no suitable info found"));
goto cleanup;
}
ret = ncounts;
cleanup:
return ret;
}
...@@ -58,4 +58,9 @@ int nodeGetCPUMap(unsigned char **cpumap, ...@@ -58,4 +58,9 @@ int nodeGetCPUMap(unsigned char **cpumap,
unsigned int *online, unsigned int *online,
unsigned int flags); unsigned int flags);
int nodeGetFreePages(unsigned int npages,
unsigned int *pages,
int startCell,
unsigned int cellCount,
unsigned long long *counts);
#endif /* __VIR_NODEINFO_H__*/ #endif /* __VIR_NODEINFO_H__*/
...@@ -16879,6 +16879,24 @@ qemuDomainFSThaw(virDomainPtr dom, ...@@ -16879,6 +16879,24 @@ qemuDomainFSThaw(virDomainPtr dom,
} }
static int
qemuNodeGetFreePages(virConnectPtr conn,
unsigned int npages,
unsigned int *pages,
int startCell,
unsigned int cellCount,
unsigned long long *counts,
unsigned int flags)
{
virCheckFlags(0, -1);
if (virNodeGetFreePagesEnsureACL(conn) < 0)
return -1;
return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
}
static virDriver qemuDriver = { static virDriver qemuDriver = {
.no = VIR_DRV_QEMU, .no = VIR_DRV_QEMU,
.name = QEMU_DRIVER_NAME, .name = QEMU_DRIVER_NAME,
...@@ -17073,6 +17091,7 @@ static virDriver qemuDriver = { ...@@ -17073,6 +17091,7 @@ static virDriver qemuDriver = {
.domainFSThaw = qemuDomainFSThaw, /* 1.2.5 */ .domainFSThaw = qemuDomainFSThaw, /* 1.2.5 */
.domainGetTime = qemuDomainGetTime, /* 1.2.5 */ .domainGetTime = qemuDomainGetTime, /* 1.2.5 */
.domainSetTime = qemuDomainSetTime, /* 1.2.5 */ .domainSetTime = qemuDomainSetTime, /* 1.2.5 */
.nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
}; };
......
...@@ -2870,6 +2870,24 @@ umlNodeSuspendForDuration(virConnectPtr conn, ...@@ -2870,6 +2870,24 @@ umlNodeSuspendForDuration(virConnectPtr conn,
} }
static int
umlNodeGetFreePages(virConnectPtr conn,
unsigned int npages,
unsigned int *pages,
int startCell,
unsigned int cellCount,
unsigned long long *counts,
unsigned int flags)
{
virCheckFlags(0, -1);
if (virNodeGetFreePagesEnsureACL(conn) < 0)
return -1;
return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
}
static virDriver umlDriver = { static virDriver umlDriver = {
.no = VIR_DRV_UML, .no = VIR_DRV_UML,
.name = "UML", .name = "UML",
...@@ -2931,6 +2949,7 @@ static virDriver umlDriver = { ...@@ -2931,6 +2949,7 @@ static virDriver umlDriver = {
.nodeSuspendForDuration = umlNodeSuspendForDuration, /* 0.9.8 */ .nodeSuspendForDuration = umlNodeSuspendForDuration, /* 0.9.8 */
.nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */ .nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
.nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */ .nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
.nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
}; };
static virStateDriver umlStateDriver = { static virStateDriver umlStateDriver = {
......
...@@ -11483,6 +11483,21 @@ vboxNodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED) ...@@ -11483,6 +11483,21 @@ vboxNodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
} }
static int
vboxNodeGetFreePages(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned int npages,
unsigned int *pages,
int startCell,
unsigned int cellCount,
unsigned long long *counts,
unsigned int flags)
{
virCheckFlags(0, -1);
return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
}
/** /**
* Function Tables * Function Tables
*/ */
...@@ -11564,6 +11579,7 @@ virDriver NAME(Driver) = { ...@@ -11564,6 +11579,7 @@ virDriver NAME(Driver) = {
.domainRevertToSnapshot = vboxDomainRevertToSnapshot, /* 0.8.0 */ .domainRevertToSnapshot = vboxDomainRevertToSnapshot, /* 0.8.0 */
.domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */ .domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
.connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */ .connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
.nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
}; };
virNetworkDriver NAME(NetworkDriver) = { virNetworkDriver NAME(NetworkDriver) = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册