And add stubs to other drivers like: lxc, qemu, uml and vbox.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
# nodeinfo.h
+nodeAllocPages;
nodeCapsInitNUMA;
nodeGetCellsFreeMemory;
nodeGetCPUBitmap;
}
+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,
.domainReboot = lxcDomainReboot, /* 1.0.1 */
.domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */
.nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */
+ .nodeAllocPages = lxcNodeAllocPages, /* 1.2.8 */
};
static virStateDriver lxcStateDriver = {
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;
+}
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__*/
}
+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,
.nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
.connectGetDomainCapabilities = qemuConnectGetDomainCapabilities, /* 1.2.7 */
.connectGetAllDomainStats = qemuConnectGetAllDomainStats, /* 1.2.8 */
+ .nodeAllocPages = qemuNodeAllocPages, /* 1.2.8 */
};
}
+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",
.nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
.nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
.nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
+ .nodeAllocPages = umlNodeAllocPages, /* 1.2.8 */
};
static virStateDriver umlStateDriver = {
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
*/
.domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
.connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
.nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
+ .nodeAllocPages = vboxNodeAllocPages, /* 1.2.8 */
};
static void updateDriver(void)