Blob Blame History Raw
From: Roberto Campesato <render@metalabs.org>
diff --git a/linux-user/main.c b/linux-user/main.c
index 0cdaf30d34..553faf1309 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -357,6 +357,10 @@ static void handle_arg_uname(const char *arg)

 static void handle_arg_cpu(const char *arg)
 {
+    if (cpu_model != NULL) {
+        free(cpu_model);
+        cpu_model = NULL;
+    }
     cpu_model = strdup(arg);
     if (cpu_model == NULL || is_help_option(cpu_model)) {
         list_cpus();
@@ -717,7 +721,16 @@ int main(int argc, char **argv, char **envp)
         }
     }

+    /* This is a pretty disgusting hack, in place to get a default
+       CPU that has x86_64-v2 support, required for emulating a
+       CPU that CentOS 9 is happy to run on (via binfmt_misc).  */
+#if defined(TARGET_X86_64) && !defined(__x86_64__)
+    cpu_model = strdup("Nehalem-v1");
+#elif defined(TARGET_AARCH64) && !defined(__aarch64__)
+    cpu_model = strdup("cortex-a72");
+#else
     cpu_model = NULL;
+#endif

     qemu_add_opts(&qemu_trace_opts);
     qemu_plugin_add_opts();