* [PATCH] hw/i386: -cpu model,-feature,+feature should enable feature
@ 2020-10-27 10:28 David Edmondson
0 siblings, 0 replies; only message in thread
From: David Edmondson @ 2020-10-27 10:28 UTC (permalink / raw)
To: qemu-devel
Cc: David Edmondson, Paolo Bonzini, Eduardo Habkost,
Richard Henderson
"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 <david.edmondson@oracle.com>
---
target/i386/cpu.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 0d8606958e..c3dcfb868c 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -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;
}
--
2.28.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-27 10:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-27 10:28 [PATCH] hw/i386: -cpu model,-feature,+feature should enable feature David Edmondson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).