99cbc7
From 0d92907e2924ee8e0ee6577368e71375637f38c1 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <0d92907e2924ee8e0ee6577368e71375637f38c1@dist-git>
99cbc7
From: Andrea Bolognani <abologna@redhat.com>
99cbc7
Date: Tue, 4 Jun 2019 13:24:13 +0200
99cbc7
Subject: [PATCH] util: Propagate numad failures correctly
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
Right now, if numad fails, we raise an error but return an
99cbc7
empty string to the caller instead of a NULL pointer, which
99cbc7
means processing will continue and the user will see
99cbc7
99cbc7
  # virsh start guest
99cbc7
  error: Failed to start domain guest
99cbc7
  error: invalid argument: Failed to parse bitmap ''
99cbc7
99cbc7
instead of a more reasonable
99cbc7
99cbc7
  # virsh start guest
99cbc7
  error: Failed to start domain guest
99cbc7
  error: operation failed: Failed to query numad for the advisory nodeset
99cbc7
99cbc7
Make sure the user gets a better error message.
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1716387
99cbc7
99cbc7
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
99cbc7
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
(cherry picked from commit b34fb1fb6f99628932ad68db1ce4985a06def17f)
99cbc7
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
99cbc7
Message-Id: <20190604112413.361-2-abologna@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/util/virnuma.c | 6 ++++--
99cbc7
 1 file changed, 4 insertions(+), 2 deletions(-)
99cbc7
99cbc7
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
99cbc7
index 784db0a7ce..fd15714553 100644
99cbc7
--- a/src/util/virnuma.c
99cbc7
+++ b/src/util/virnuma.c
99cbc7
@@ -66,10 +66,12 @@ virNumaGetAutoPlacementAdvice(unsigned short vcpus,
99cbc7
 
99cbc7
     virCommandSetOutputBuffer(cmd, &output);
99cbc7
 
99cbc7
-    if (virCommandRun(cmd, NULL) < 0)
99cbc7
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
99cbc7
+    if (virCommandRun(cmd, NULL) < 0) {
99cbc7
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
99cbc7
                        _("Failed to query numad for the "
99cbc7
                          "advisory nodeset"));
99cbc7
+        VIR_FREE(output);
99cbc7
+    }
99cbc7
 
99cbc7
     virCommandFree(cmd);
99cbc7
     return output;
99cbc7
-- 
99cbc7
2.21.0
99cbc7