hw/i386: -cpu model,-feature,+feature should enable feature
PATCH 1/1 hw/i386: -cpu model,-feature,+feature should enable feature
"Minus" features are applied after "plus" features, so ensure that a later "plus" feature causes an earlier "minus" feature to be removed.
This has no effect on the existing "-feature,feature=on" backward compatibility code (which warns and turns the feature off).
Signed-off-by David Edmondson <[email protected]>
--- target/i386/cpu.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
target/i386/cpu.c +24 -7
@@ -4720,13 +4720,30 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,GlobalProperty *prop;/* Compatibility syntax: */ -if (featurestr[0 ] =='+' ) { - plus_features =g_list_append (plus_features, -g_strdup (featurestr +1 )); -continue ; - }else if (featurestr[0 ] =='-' ) { - minus_features =g_list_append (minus_features, -g_strdup (featurestr +1 )); +if (featurestr[0 ] =='+' || featurestr[0 ] =='-' ) { +const char *feat = featurestr +1 ; +GList *val; +char *data; + +/* Remove any existing +/- setting. */ + val =g_list_find_custom (minus_features, feat, compare_string); +if (val) { + data = val->data; + minus_features =g_list_remove (minus_features, data); +g_free (data); + } + val =g_list_find_custom (plus_features, feat, compare_string); +if (val) { + data = val->data; + plus_features =g_list_remove (plus_features, data); +g_free (data); + } + +if (featurestr[0 ] =='+' ) { + plus_features =g_list_append (plus_features,g_strdup (feat)); + }else { + minus_features =g_list_append (minus_features,g_strdup (feat)); + }continue ; }
Signature · 1 line
2.28.0