And add stubs to other drivers like: lxc, qemu, uml and vbox.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
nodeGetCPUCount;
nodeGetCPUMap;
nodeGetCPUStats;
+nodeGetFreePages;
nodeGetInfo;
nodeGetMemory;
nodeGetMemoryParameters;
}
+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,
.domainShutdownFlags = lxcDomainShutdownFlags, /* 1.0.1 */
.domainReboot = lxcDomainReboot, /* 1.0.1 */
.domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */
+ .nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */
};
static virStateDriver lxcStateDriver = {
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;
+}
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__*/
}
+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,
.domainFSThaw = qemuDomainFSThaw, /* 1.2.5 */
.domainGetTime = qemuDomainGetTime, /* 1.2.5 */
.domainSetTime = qemuDomainSetTime, /* 1.2.5 */
+ .nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
};
}
+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",
.nodeSuspendForDuration = umlNodeSuspendForDuration, /* 0.9.8 */
.nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
.nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
+ .nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
};
static virStateDriver umlStateDriver = {
}
+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
*/
.domainRevertToSnapshot = vboxDomainRevertToSnapshot, /* 0.8.0 */
.domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
.connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
+ .nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
};
virNetworkDriver NAME(NetworkDriver) = {