]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Propagate numad failures correctly
authorAndrea Bolognani <abologna@redhat.com>
Mon, 3 Jun 2019 16:45:27 +0000 (18:45 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 4 Jun 2019 08:13:07 +0000 (10:13 +0200)
Right now, if numad fails, we raise an error but return an
empty string to the caller instead of a NULL pointer, which
means processing will continue and the user will see

  # virsh start guest
  error: Failed to start domain guest
  error: invalid argument: Failed to parse bitmap ''

instead of a more reasonable

  # virsh start guest
  error: Failed to start domain guest
  error: operation failed: Failed to query numad for the advisory nodeset

Make sure the user gets a better error message.

https://bugzilla.redhat.com/show_bug.cgi?id=1716387

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virnuma.c

index fc593d2955a7f6be6f824e20207f1b7a8ced39ae..34f2c5c38df424f26f045f46332bbb9f0fde77cb 100644 (file)
@@ -66,10 +66,12 @@ virNumaGetAutoPlacementAdvice(unsigned short vcpus,
 
     virCommandSetOutputBuffer(cmd, &output);
 
-    if (virCommandRun(cmd, NULL) < 0)
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+    if (virCommandRun(cmd, NULL) < 0) {
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
                        _("Failed to query numad for the "
                          "advisory nodeset"));
+        VIR_FREE(output);
+    }
 
     return output;
 }