mirror of https://gitee.com/openkylin/libvirt.git
nodeinfo: Implement nodeGetFreePages
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:
parent
9e3efe53de
commit
38fa03f4b0
|
@ -877,6 +877,7 @@ nodeGetCPUBitmap;
|
|||
nodeGetCPUCount;
|
||||
nodeGetCPUMap;
|
||||
nodeGetCPUStats;
|
||||
nodeGetFreePages;
|
||||
nodeGetInfo;
|
||||
nodeGetMemory;
|
||||
nodeGetMemoryParameters;
|
||||
|
|
|
@ -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 */
|
||||
static virDriver lxcDriver = {
|
||||
.no = VIR_DRV_LXC,
|
||||
|
@ -5745,6 +5763,7 @@ static virDriver lxcDriver = {
|
|||
.domainShutdownFlags = lxcDomainShutdownFlags, /* 1.0.1 */
|
||||
.domainReboot = lxcDomainReboot, /* 1.0.1 */
|
||||
.domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */
|
||||
.nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */
|
||||
};
|
||||
|
||||
static virStateDriver lxcStateDriver = {
|
||||
|
|
|
@ -2018,3 +2018,37 @@ nodeGetMemory(unsigned long long *mem,
|
|||
|
||||
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,
|
|||
unsigned int *online,
|
||||
unsigned int flags);
|
||||
|
||||
int nodeGetFreePages(unsigned int npages,
|
||||
unsigned int *pages,
|
||||
int startCell,
|
||||
unsigned int cellCount,
|
||||
unsigned long long *counts);
|
||||
#endif /* __VIR_NODEINFO_H__*/
|
||||
|
|
|
@ -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 = {
|
||||
.no = VIR_DRV_QEMU,
|
||||
.name = QEMU_DRIVER_NAME,
|
||||
|
@ -17073,6 +17091,7 @@ static virDriver qemuDriver = {
|
|||
.domainFSThaw = qemuDomainFSThaw, /* 1.2.5 */
|
||||
.domainGetTime = qemuDomainGetTime, /* 1.2.5 */
|
||||
.domainSetTime = qemuDomainSetTime, /* 1.2.5 */
|
||||
.nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
.no = VIR_DRV_UML,
|
||||
.name = "UML",
|
||||
|
@ -2931,6 +2949,7 @@ static virDriver umlDriver = {
|
|||
.nodeSuspendForDuration = umlNodeSuspendForDuration, /* 0.9.8 */
|
||||
.nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
|
||||
.nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
|
||||
.nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
|
||||
};
|
||||
|
||||
static virStateDriver umlStateDriver = {
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -11564,6 +11579,7 @@ virDriver NAME(Driver) = {
|
|||
.domainRevertToSnapshot = vboxDomainRevertToSnapshot, /* 0.8.0 */
|
||||
.domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
|
||||
.connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
|
||||
.nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
|
||||
};
|
||||
|
||||
virNetworkDriver NAME(NetworkDriver) = {
|
||||
|
|
Loading…
Reference in New Issue