@samitouri / QOSamiQemu / commits / fa6a91fd8c

target/ppc/cpu_init: make cpu listing deterministic

The existing compare function only make sure that we list cpus with PVR order. However, we never compare cpu names. As a result, while cpus are grouped per PVR, the order within a group is non deterministic. Depending on QOM type initialization order, we get different results for -cpu help. For instance, previous output could be: Available CPUs: 755_v1.0 PVR 00083100 745_v1.0 PVR 00083100 755_v1.1 PVR 00083101 745_v1.1 PVR 00083101 While a sorted output should be: Available CPUs: 745_v1.0 PVR 00083100 755_v1.0 PVR 00083100 745_v1.1 PVR 00083101 755_v1.1 PVR 00083101 Fix it by comparing cpu names to have a stable result. This allows us to record and compare various command line results across versions to make sure we didn't break anything while working on single-binary. Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Tested-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com> Tested-by: Amit Machhiwal <amachhiw@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260720192403.66694-1-pierrick.bouvier@oss.qualcomm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Pierrick Bouvier committed Jul 20, 2026 at 19:24 UTC fa6a91fd8cb917fbe08b701f861d8ece9d571b4e
1 file changed +1 -1
target/ppc/cpu_init.c
+1 -1
@@ -7130,7 +7130,7 @@ static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b, gpointer d)
7130 } else if (pcc_a->pvr > pcc_b->pvr) {
7131 return 1;
7132 } else {
7133 - return 0;
7133 + return strcmp(name_a, name_b);
7134 }
7135 }
7136 }