All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH] target-i386: Print warning when mixing [+-]foo and foo=(on|off)
Date: Fri, 21 Oct 2016 16:49:48 -0200	[thread overview]
Message-ID: <1477075788-26632-1-git-send-email-ehabkost@redhat.com> (raw)

Print a warning when mixing [+-]foo and foo=(on|off) in the -cpu
argument in a way that will break in the future.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.c             | 20 ++++++++++++++++++++
 tests/test-x86-cpuid-compat.c | 19 ++++++++++++++-----
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index d95514c..3943382 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1973,6 +1973,11 @@ static const char *x86_cpu_feature_name(FeatureWord w, int bitnr)
  */
 static GList *plus_features, *minus_features;
 
+static gint compare_string(gconstpointer a, gconstpointer b)
+{
+    return g_strcmp0(a, b);
+}
+
 /* Parse "+feature,-feature,feature=foo" CPU feature string
  */
 static void x86_cpu_parse_featurestr(const char *typename, char *features,
@@ -2022,6 +2027,21 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
         feat2prop(featurestr);
         name = featurestr;
 
+        if (g_list_find_custom(plus_features, name, compare_string)) {
+            error_report("warning: Ambiguous CPU model string. "
+                         "Don't mix both \"+%s\" and \"%s=%s\"\n"
+                         "warning: Compatibility of ambiguous CPU model "
+                         "strings won't be kept on future QEMU versions",
+                         name, name, val);
+        }
+        if (g_list_find_custom(minus_features, name, compare_string)) {
+            error_report("warning: Ambiguous CPU model string. "
+                         "Don't mix both \"-%s\" and \"%s=%s\"\n"
+                         "warning: Compatibility of ambiguous CPU model "
+                         "strings won't be kept on future QEMU versions",
+                         name, name, val);
+        }
+
         /* Special case: */
         if (!strcmp(name, "tsc-freq")) {
             int64_t tsc_freq;
diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 260dd27..6cfcaca 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -76,7 +76,7 @@ static void add_cpuid_test(const char *name, const char *cmdline,
     qtest_add_data_func(name, args, test_cpuid_prop);
 }
 
-static void test_plus_minus(void)
+static void test_plus_minus_subprocess(void)
 {
     char *path;
 
@@ -86,9 +86,8 @@ static void test_plus_minus(void)
      * 3) Old feature names with underscores (e.g. "sse4_2")
      *    should keep working
      *
-     * Note: rules 1 and 2 are planned to be removed soon, but we
-     * need to keep compatibility for a while until we start
-     * warning users about it.
+     * Note: rules 1 and 2 are planned to be removed soon, and
+     * should generate a warning.
      */
     qtest_start("-cpu pentium,-fpu,+fpu,-mce,mce=on,+cx8,cx8=off,+sse4_1,sse4_2=on");
     path = get_cpu0_qom_path();
@@ -108,11 +107,21 @@ static void test_plus_minus(void)
     g_free(path);
 }
 
+static void test_plus_minus(void)
+{
+    g_test_trap_subprocess("/x86/cpuid/parsing-plus-minus/subprocess", 0, 0);
+    g_test_trap_assert_passed();
+    g_test_trap_assert_stderr("*Ambiguous CPU model string. Don't mix both \"-mce\" and \"mce=on\"*");
+    g_test_trap_assert_stderr("*Ambiguous CPU model string. Don't mix both \"+cx8\" and \"cx8=off\"*");
+    g_test_trap_assert_stdout("");
+}
+
 int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
 
-    qtest_add_func("x86/cpuid/parsing-plus-minus", test_plus_minus);
+    g_test_add_func("/x86/cpuid/parsing-plus-minus/subprocess", test_plus_minus_subprocess);
+    g_test_add_func("/x86/cpuid/parsing-plus-minus", test_plus_minus);
 
     /* Original level values for CPU models: */
     add_cpuid_test("x86/cpuid/phenom/level",
-- 
2.7.4

             reply	other threads:[~2016-10-21 18:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-21 18:49 Eduardo Habkost [this message]
2016-10-21 19:14 ` [Qemu-devel] [PATCH] target-i386: Print warning when mixing [+-]foo and foo=(on|off) no-reply
2016-10-21 19:15 ` no-reply
2016-10-21 19:31   ` Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477075788-26632-1-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.