testQemuInfoInitArgs: Report error if path to 'latest' caps for an arch is NULL

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-09-22 10:53:58 +02:00
parent 1bb7b3aa9c
commit 4560736c9c
1 changed files with 6 additions and 0 deletions

View File

@ -772,6 +772,12 @@ testQemuInfoInitArgs(struct testQemuInfo *info)
if (STREQ(info->args.capsver, "latest")) { if (STREQ(info->args.capsver, "latest")) {
capsfile = g_strdup(virHashLookup(info->conf->capslatest, info->args.capsarch)); 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; stripmachinealiases = true;
} else { } else {
capsfile = g_strdup_printf("%s/caps_%s.%s.xml", capsfile = g_strdup_printf("%s/caps_%s.%s.xml",