Only the x86 'nitro-enclave', 'microvm', 'q35' and 'i440fx' machine
classes set a non-NULL 'family' field. This results in a fairly
strange looking sort order in the '-machine help' output, such that
from a user POV is appears largely unsorted. No other targets bother
to set 'family', even though they have far larger lists of machines.

It is sufficient to sort exclusively based on the machine type name
to get a purely alphabetical sorting.

Signed-off-by: Daniel P. Berrangé <[email protected]>
---
 system/vl.c | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/system/vl.c b/system/vl.c
index fb5d55f3d68..a187d10ad9c 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1536,33 +1536,7 @@ static bool debugcon_parse(const char *devname, Error 
**errp)
 static gint machine_class_cmp(gconstpointer a, gconstpointer b, gpointer d)
 {
     const MachineClass *mc1 = a, *mc2 = b;
-    int res;
 
-    if (mc1->family == NULL) {
-        if (mc2->family == NULL) {
-            /* Compare standalone machine types against each other; they sort
-             * in increasing order.
-             */
-            return strcmp(object_class_get_name(OBJECT_CLASS(mc1)),
-                          object_class_get_name(OBJECT_CLASS(mc2)));
-        }
-
-        /* Standalone machine types sort after families. */
-        return 1;
-    }
-
-    if (mc2->family == NULL) {
-        /* Families sort before standalone machine types. */
-        return -1;
-    }
-
-    /* Families sort between each other alphabetically increasingly. */
-    res = strcmp(mc1->family, mc2->family);
-    if (res != 0) {
-        return res;
-    }
-
-    /* Within the same family, machine types sort in decreasing order. */
     return strcmp(object_class_get_name(OBJECT_CLASS(mc2)),
                   object_class_get_name(OBJECT_CLASS(mc1)));
 }
-- 
2.56.1


Reply via email to