Skip to contentSkip to conversation

backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT

PATCH In review Pavel Fedin 2 participants 3 messages Oct 27, 2015 Arm STM32

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT

Currently hostmem backend fails if CONFIG_NUMA is enabled for the qemu (default), but NUMA is not supported by the kernel. This makes it impossible to use ivshmem in such configurations.

This patch fixes the problem by ignoring ENOSYS error if policy is set to MPOL_DEFAULT. This way the code behaves in the same way as if CONFIG_NUMA was not defined. qemu will still fail if the user specifies some other policy, so that the user knows it.

---
 backends/hostmem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
backends/hostmem.c +4 -2
index 41ba2af..94a4ac0 100644
@@ -313,9 +313,11 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
         assert(maxnode <= MAX_NODES);
         if (mbind(ptr, sz, backend->policy,
                   maxnode ? backend->host_nodes : NULL, maxnode + 1, flags)) {
-            error_setg_errno(errp, errno,
+            if (backend->policy != MPOL_DEFAULT || errno != ENOSYS) {
+                error_setg_errno(errp, errno,
                              "cannot bind memory to host NUMA nodes");
-            return;
+                return;
+            }
         }
 #endif
         /* Preallocate memory after the NUMA policy has been instantiated.
Signature · 1 line
1.9.5.msysgit.0
#1 lore raw

Sorry, guys, i forgot to add "v2" and simply sent the mail. Log is:

v1 => v2:
- Removed unnecessary parenthesis

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

Quoted 43 lines

-----Original Message-----
From: [email protected] [mailto:qemu-devel- [email protected]] On Behalf Of Pavel Fedin
Sent: Tuesday, October 27, 2015 3:52 PM
To: [email protected]
Cc: 'Paolo Bonzini'; 'Eduardo Habkost'
Subject: [Qemu-devel] [PATCH] backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT

Currently hostmem backend fails if CONFIG_NUMA is enabled for the qemu (default), but NUMA is not supported by the kernel. This makes it impossible to use ivshmem in such configurations.

This patch fixes the problem by ignoring ENOSYS error if policy is set to MPOL_DEFAULT. This way the code behaves in the same way as if CONFIG_NUMA was not defined. qemu will still fail if the user specifies some other policy, so that the user knows it.

---
 backends/hostmem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
backends/hostmem.c +4 -3
index 41ba2af..94a4ac0 100644
@@ -313,9 +313,11 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
         assert(maxnode <= MAX_NODES);
         if (mbind(ptr, sz, backend->policy,
                   maxnode ? backend->host_nodes : NULL, maxnode + 1, flags)) {
-            error_setg_errno(errp, errno,
+            if (backend->policy != MPOL_DEFAULT || errno != ENOSYS) {
+                error_setg_errno(errp, errno,
                              "cannot bind memory to host NUMA nodes");
-            return;
+                return;
+            }
         }
 #endif
         /* Preallocate memory after the NUMA policy has been instantiated.
--

1.9.5.msysgit.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Pavel Fedin
Quoted 10 lines · Pavel Fedin

Currently hostmem backend fails if CONFIG_NUMA is enabled for the qemu (default), but NUMA is not supported by the kernel. This makes it impossible to use ivshmem in such configurations.

This patch fixes the problem by ignoring ENOSYS error if policy is set to MPOL_DEFAULT. This way the code behaves in the same way as if CONFIG_NUMA was not defined. qemu will still fail if the user specifies some other policy, so that the user knows it.

Thanks. Applied to numa tree, with the following indentation fix:

backends/hostmem.c +1 -1
index 94a4ac0..1b4eb45 100644
@@ -315,7 +315,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
                   maxnode ? backend->host_nodes : NULL, maxnode + 1, flags)) {
             if (backend->policy != MPOL_DEFAULT || errno != ENOSYS) {
                 error_setg_errno(errp, errno,
-                             "cannot bind memory to host NUMA nodes");
+                                 "cannot bind memory to host NUMA nodes");
                 return;
             }
         }
Quoted 26 lines
---
 backends/hostmem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
backends/hostmem.c +4 -2
index 41ba2af..94a4ac0 100644
@@ -313,9 +313,11 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
         assert(maxnode <= MAX_NODES);
         if (mbind(ptr, sz, backend->policy,
                   maxnode ? backend->host_nodes : NULL, maxnode + 1, flags)) {
-            error_setg_errno(errp, errno,
+            if (backend->policy != MPOL_DEFAULT || errno != ENOSYS) {
+                error_setg_errno(errp, errno,
                              "cannot bind memory to host NUMA nodes");
-            return;
+                return;
+            }
         }
 #endif
         /* Preallocate memory after the NUMA policy has been instantiated.
Signature · 1 line
1.9.5.msysgit.0
Signature · 1 line
Eduardo