Patchwork [4/8] vl.c: Check for NUMA node limit inside numa_add()

login
register
mail settings
Submitter Eduardo Habkost
Date Feb. 4, 2013, 6:27 p.m.
Message ID <1360002472-17628-5-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/218037/
State New
Headers show

Comments

Eduardo Habkost - Feb. 4, 2013, 6:27 p.m.
Instead of checking the limit before calling numa_add(), check the limit
only when we already know we're going to add a new node.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 vl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Patch

diff --git a/vl.c b/vl.c
index 586aa9a..89de003 100644
--- a/vl.c
+++ b/vl.c
@@ -1258,6 +1258,12 @@  static void numa_add(const char *optarg)
         optarg++;
     }
     if (!strcmp(option, "node")) {
+
+        if (nb_numa_nodes >= MAX_NODES) {
+            fprintf(stderr, "qemu: too many NUMA nodes\n");
+            exit(1);
+        }
+
         if (get_param_value(option, 128, "nodeid", optarg) == 0) {
             nodenr = nb_numa_nodes;
         } else {
@@ -3003,10 +3009,6 @@  int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QEMU_OPTION_numa:
-                if (nb_numa_nodes >= MAX_NODES) {
-                    fprintf(stderr, "qemu: too many NUMA nodes\n");
-                    exit(1);
-                }
                 numa_add(optarg);
                 break;
             case QEMU_OPTION_display: