]> xenbits.xensource.com Git - libvirt.git/commitdiff
domaincapstest: Make construction of filename more extensible
authorPeter Krempa <pkrempa@redhat.com>
Wed, 8 Mar 2023 12:18:57 +0000 (13:18 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 3 Apr 2023 07:19:06 +0000 (09:19 +0200)
Rather than trying to cram everything into one printf statement format
the type with prefix and machine with prefix separately and then
concatenate everything into the filename.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/domaincapstest.c

index 359ead2d3203a440d2c7bb1f1e2e79604e0b1232..2120e7efd59d748859696a057878f64d06118452 100644 (file)
@@ -252,13 +252,31 @@ doTestQemuInternal(const char *version,
     g_autofree char *name = NULL;
     g_autofree char *capsName = NULL;
     g_autofree char *emulator = NULL;
+    const char *typestr = NULL;
+    g_autofree char *mach = NULL;
     int rc;
 
-    name = g_strdup_printf("qemu_%s%s%s%s.%s",
-                           version,
-                           (type == VIR_DOMAIN_VIRT_QEMU ? "-tcg" : ""),
-                           (machine ? "-" : ""), (machine ? machine : ""),
-                           arch);
+    switch ((unsigned int) type) {
+    case VIR_DOMAIN_VIRT_QEMU:
+        typestr = "-tcg";
+        break;
+
+    case VIR_DOMAIN_VIRT_KVM:
+        typestr = "";
+        break;
+
+    default:
+        abort();
+        break;
+    }
+
+    if (machine)
+        mach = g_strdup_printf("-%s", machine);
+    else
+        mach = g_strdup("");
+
+    name = g_strdup_printf("qemu_%s%s%s.%s",
+                           version, typestr, mach, arch);
     capsName = g_strdup_printf("caps_%s", version);
     emulator = g_strdup_printf("/usr/bin/qemu-system-%s", arch);