[PATCH 02/20] testQemuInfoInitArgs: Report error if path to 'latest' caps for an arch is NULL

Peter Krempa pkrempa at redhat.com
Wed Sep 22 13:02:11 UTC 2021


When looking up the 'latest' caps they might not be present. Report an
error instead of crashing.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tests/testutilsqemu.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 164d601613..505c66b818 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -772,6 +772,12 @@ testQemuInfoInitArgs(struct testQemuInfo *info)

         if (STREQ(info->args.capsver, "latest")) {
             capsfile = g_strdup(virHashLookup(info->conf->capslatest, info->args.capsarch));
+
+            if (!capsfile) {
+                fprintf(stderr, "'latest' caps for '%s' were not found\n", info->args.capsarch);
+                return -1;
+            }
+
             stripmachinealiases = true;
         } else {
             capsfile = g_strdup_printf("%s/caps_%s.%s.xml",
-- 
2.31.1




More information about the libvir-list mailing list