qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT
@ 2015-10-27 12:11 Pavel Fedin
  2015-10-27 12:28 ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Fedin @ 2015-10-27 12:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: 'Eduardo Habkost'

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.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
---
 backends/hostmem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/backends/hostmem.c b/backends/hostmem.c
index 41ba2af..826141b 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT
  2015-10-27 12:11 [Qemu-devel] [PATCH] backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT Pavel Fedin
@ 2015-10-27 12:28 ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2015-10-27 12:28 UTC (permalink / raw)
  To: Pavel Fedin, qemu-devel; +Cc: 'Eduardo Habkost'



On 27/10/2015 13:11, Pavel Fedin wrote:
> +            if ((backend->policy != MPOL_DEFAULT) || (errno != ENOSYS)) {

Can you remove parentheses around conditions?

Paolo

> +                error_setg_errno(errp, errno,
>                               "cannot bind memory to host NUMA nodes");
> -            return;
> +                return;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH] backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT
@ 2015-10-27 12:51 Pavel Fedin
  2015-10-27 12:53 ` Pavel Fedin
  2015-10-27 17:31 ` Eduardo Habkost
  0 siblings, 2 replies; 5+ messages in thread
From: Pavel Fedin @ 2015-10-27 12:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: 'Paolo Bonzini', 'Eduardo Habkost'

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.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
---
 backends/hostmem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/backends/hostmem.c b/backends/hostmem.c
index 41ba2af..94a4ac0 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT
  2015-10-27 12:51 Pavel Fedin
@ 2015-10-27 12:53 ` Pavel Fedin
  2015-10-27 17:31 ` Eduardo Habkost
  1 sibling, 0 replies; 5+ messages in thread
From: Pavel Fedin @ 2015-10-27 12:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: 'Paolo Bonzini', 'Eduardo Habkost'

 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

> -----Original Message-----
> From: qemu-devel-bounces+p.fedin=samsung.com@nongnu.org [mailto:qemu-devel-
> bounces+p.fedin=samsung.com@nongnu.org] On Behalf Of Pavel Fedin
> Sent: Tuesday, October 27, 2015 3:52 PM
> To: qemu-devel@nongnu.org
> 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.
> 
> Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
> ---
>  backends/hostmem.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/backends/hostmem.c b/backends/hostmem.c
> index 41ba2af..94a4ac0 100644
> --- a/backends/hostmem.c
> +++ b/backends/hostmem.c
> @@ -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
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT
  2015-10-27 12:51 Pavel Fedin
  2015-10-27 12:53 ` Pavel Fedin
@ 2015-10-27 17:31 ` Eduardo Habkost
  1 sibling, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-10-27 17:31 UTC (permalink / raw)
  To: Pavel Fedin; +Cc: 'Paolo Bonzini', qemu-devel

On Tue, Oct 27, 2015 at 03:51:31PM +0300, Pavel Fedin wrote:
> 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.
> 
> Signed-off-by: Pavel Fedin <p.fedin@samsung.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

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

diff --git a/backends/hostmem.c b/backends/hostmem.c
index 94a4ac0..1b4eb45 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -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;
             }
         }

> ---
>  backends/hostmem.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/backends/hostmem.c b/backends/hostmem.c
> index 41ba2af..94a4ac0 100644
> --- a/backends/hostmem.c
> +++ b/backends/hostmem.c
> @@ -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
> 
> 

-- 
Eduardo

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-27 17:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 12:11 [Qemu-devel] [PATCH] backends/hostmem: Ignore ENOSYS while setting MPOL_DEFAULT Pavel Fedin
2015-10-27 12:28 ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2015-10-27 12:51 Pavel Fedin
2015-10-27 12:53 ` Pavel Fedin
2015-10-27 17:31 ` Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).