aboutsummaryrefslogtreecommitdiff
path: root/backends/hostmem.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2020-04-30 11:46:06 -0400
committerEduardo Habkost <ehabkost@redhat.com>2020-05-12 12:48:57 -0400
commit70b6d525dfb51d5e523d568d1139fc051bc223c5 (patch)
treed074d23bb88164f58180f4c5db6a09c78e2dea4a /backends/hostmem.c
parentde2f658b6bb422ec0e0fa94a49e476018602eeea (diff)
downloadqemu-70b6d525dfb51d5e523d568d1139fc051bc223c5.zip
qemu-70b6d525dfb51d5e523d568d1139fc051bc223c5.tar.gz
qemu-70b6d525dfb51d5e523d568d1139fc051bc223c5.tar.bz2
hostmem: don't use mbind() if host-nodes is empty
Since 5.0 QEMU uses hostmem backend for allocating main guest RAM. The backend however calls mbind() which is typically NOP in case of default policy/absent host-nodes bitmap. However when runing in container with black-listed mbind() syscall, QEMU fails to start with error "cannot bind memory to host NUMA nodes: Operation not permitted" even when user hasn't provided host-nodes to pin to explictly (which is the case with -m option) To fix issue, call mbind() only in case when user has provided host-nodes explicitly (i.e. host_nodes bitmap is not empty). That should allow to run QEMU in containers with black-listed mbind() without memory pinning. If QEMU provided memory-pinning is required user still has to white-list mbind() in container configuration. Reported-by: Manuel Hohmann <mhohmann@physnet.uni-hamburg.de> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20200430154606.6421-1-imammedo@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'backends/hostmem.c')
-rw-r--r--backends/hostmem.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 327f9ee..0efd7b7 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -383,8 +383,10 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
assert(sizeof(backend->host_nodes) >=
BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long));
assert(maxnode <= MAX_NODES);
- if (mbind(ptr, sz, backend->policy,
- maxnode ? backend->host_nodes : NULL, maxnode + 1, flags)) {
+
+ if (maxnode &&
+ mbind(ptr, sz, backend->policy, backend->host_nodes, maxnode + 1,
+ flags)) {
if (backend->policy != MPOL_DEFAULT || errno != ENOSYS) {
error_setg_errno(errp, errno,
"cannot bind memory to host NUMA nodes");