diff mbox

[v3,2/4] numa: Reject CPU indexes > max_cpus

Message ID 1423763435-3696-3-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Feb. 12, 2015, 5:50 p.m. UTC
CPU index is always less than max_cpus, as documented at sysemu.h:

> The following shall be true for all CPUs:
>   cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS

Reject configuration which uses invalid CPU indexes.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
v1 -> v2: (no changes)

v2 -> v3:
 * Check for (cpu >= max_cpus) instead of (cpu > max_cpus)
 * Reword error message as we are not checking for "bigger than maxcpus"
   CPU indexes
---
 numa.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Igor Mammedov Feb. 24, 2015, 6:49 a.m. UTC | #1
On Thu, 12 Feb 2015 15:50:33 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> CPU index is always less than max_cpus, as documented at sysemu.h:
> 
> > The following shall be true for all CPUs:
> >   cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS
> 
> Reject configuration which uses invalid CPU indexes.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Excluding nitpicking below
Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
> v1 -> v2: (no changes)
> 
> v2 -> v3:
>  * Check for (cpu >= max_cpus) instead of (cpu > max_cpus)
>  * Reword error message as we are not checking for "bigger than maxcpus"
>    CPU indexes
> ---
>  numa.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/numa.c b/numa.c
> index 41e496b..4139e46 100644
> --- a/numa.c
> +++ b/numa.c
> @@ -76,9 +76,11 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
>      }
>  
>      for (cpus = node->cpus; cpus; cpus = cpus->next) {
> -        if (cpus->value >= MAX_CPUMASK_BITS) {
> -            error_setg(errp, "CPU number %" PRIu16 " is bigger than %d",
> -                       cpus->value, MAX_CPUMASK_BITS - 1);
> +        if (cpus->value >= max_cpus) {
> +            error_setg(errp,
> +                       "CPU index (%" PRIu16 ")" \
'\' is not really necessary here

> +                       " should be smaller than maxcpus (%d)",
> +                       cpus->value, max_cpus);
>              return;
>          }
>          bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);
diff mbox

Patch

diff --git a/numa.c b/numa.c
index 41e496b..4139e46 100644
--- a/numa.c
+++ b/numa.c
@@ -76,9 +76,11 @@  static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
     }
 
     for (cpus = node->cpus; cpus; cpus = cpus->next) {
-        if (cpus->value >= MAX_CPUMASK_BITS) {
-            error_setg(errp, "CPU number %" PRIu16 " is bigger than %d",
-                       cpus->value, MAX_CPUMASK_BITS - 1);
+        if (cpus->value >= max_cpus) {
+            error_setg(errp,
+                       "CPU index (%" PRIu16 ")" \
+                       " should be smaller than maxcpus (%d)",
+                       cpus->value, max_cpus);
             return;
         }
         bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);