mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
virhostmem: Let caller pass max NUMA node to virHostMemAllocPages
In all three cases (LXC, QEMU and VBox drivers) the caller has access to host capabilities and thus know the maximum NUMA node. This means, that virHostMemAllocPages() doesn't have to query it. Querying may fail if libvirt was compiled without numactl support. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
59e3584f71
commit
ebec3de97d
@ -5041,6 +5041,9 @@ lxcNodeAllocPages(virConnectPtr conn,
|
||||
unsigned int cellCount,
|
||||
unsigned int flags)
|
||||
{
|
||||
virLXCDriver *driver = conn->privateData;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
int lastCell;
|
||||
bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
|
||||
|
||||
virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
|
||||
@ -5048,8 +5051,14 @@ lxcNodeAllocPages(virConnectPtr conn,
|
||||
if (virNodeAllocPagesEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
if (!(caps = virLXCDriverGetCapabilities(driver, false)))
|
||||
return -1;
|
||||
|
||||
lastCell = virCapabilitiesHostNUMAGetMaxNode(caps->host.numa);
|
||||
|
||||
return virHostMemAllocPages(npages, pageSizes, pageCounts,
|
||||
startCell, cellCount, add);
|
||||
startCell, cellCount,
|
||||
lastCell, add);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18802,6 +18802,9 @@ qemuNodeAllocPages(virConnectPtr conn,
|
||||
unsigned int cellCount,
|
||||
unsigned int flags)
|
||||
{
|
||||
virQEMUDriver *driver = conn->privateData;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
int lastCell;
|
||||
bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
|
||||
|
||||
virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
|
||||
@ -18809,8 +18812,14 @@ qemuNodeAllocPages(virConnectPtr conn,
|
||||
if (virNodeAllocPagesEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
return -1;
|
||||
|
||||
lastCell = virCapabilitiesHostNUMAGetMaxNode(caps->host.numa);
|
||||
|
||||
return virHostMemAllocPages(npages, pageSizes, pageCounts,
|
||||
startCell, cellCount, add);
|
||||
startCell, cellCount,
|
||||
lastCell, add);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -885,14 +885,12 @@ virHostMemAllocPages(unsigned int npages,
|
||||
unsigned long long *pageCounts,
|
||||
int startCell,
|
||||
unsigned int cellCount,
|
||||
int lastCell,
|
||||
bool add)
|
||||
{
|
||||
int cell, lastCell;
|
||||
int cell;
|
||||
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)"),
|
||||
|
@ -53,4 +53,5 @@ int virHostMemAllocPages(unsigned int npages,
|
||||
unsigned long long *pageCounts,
|
||||
int startCell,
|
||||
unsigned int cellCount,
|
||||
int lastCell,
|
||||
bool add);
|
||||
|
@ -7628,12 +7628,18 @@ vboxNodeAllocPages(virConnectPtr conn G_GNUC_UNUSED,
|
||||
unsigned int cellCount,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct _vboxDriver *driver = conn->privateData;
|
||||
int lastCell;
|
||||
bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
|
||||
|
||||
virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
|
||||
|
||||
virObjectLock(driver);
|
||||
lastCell = virCapabilitiesHostNUMAGetMaxNode(driver->caps->host.numa);
|
||||
virObjectUnlock(driver);
|
||||
|
||||
return virHostMemAllocPages(npages, pageSizes, pageCounts,
|
||||
startCell, cellCount, add);
|
||||
startCell, cellCount, lastCell, add);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user