Re: [Qemu-devel] [PATCH v4 01/11] tests: Add test case for x86 feature parsing compatibility

2016-09-30 Thread Paolo Bonzini


On 30/09/2016 20:33, Eduardo Habkost wrote:
> On Fri, Sep 30, 2016 at 09:55:33AM +0200, Paolo Bonzini wrote:
>>
>>
>> On 29/09/2016 23:14, Eduardo Habkost wrote:
>>> + * "-foo" overrides "+foo"
>>> + * "[+-]foo" overrides "foo=..."
>>
>> Is this something that people are actually using?  Can we detect it and
>> deprecate it in 2.8, and drop it in 2.9?
> 
> We can, but I would like to keep the test cases there in 2.8, at
> least. I will update the test case to note that this is legacy
> behavior that we plan to remove in 2.9, and send a separate
> follow-up patch to detect when people mix both formats.

Yes, of course!  Sounds like a very good plan.

Paolo



Re: [Qemu-devel] [PATCH v4 01/11] tests: Add test case for x86 feature parsing compatibility

2016-09-30 Thread Eduardo Habkost
On Fri, Sep 30, 2016 at 09:55:33AM +0200, Paolo Bonzini wrote:
> 
> 
> On 29/09/2016 23:14, Eduardo Habkost wrote:
> > + * "-foo" overrides "+foo"
> > + * "[+-]foo" overrides "foo=..."
> 
> Is this something that people are actually using?  Can we detect it and
> deprecate it in 2.8, and drop it in 2.9?

We can, but I would like to keep the test cases there in 2.8, at
least. I will update the test case to note that this is legacy
behavior that we plan to remove in 2.9, and send a separate
follow-up patch to detect when people mix both formats.

-- 
Eduardo



Re: [Qemu-devel] [PATCH v4 01/11] tests: Add test case for x86 feature parsing compatibility

2016-09-30 Thread Jiri Denemark
On Fri, Sep 30, 2016 at 09:55:33 +0200, Paolo Bonzini wrote:
> 
> 
> On 29/09/2016 23:14, Eduardo Habkost wrote:
> > + * "-foo" overrides "+foo"
> > + * "[+-]foo" overrides "foo=..."
> 
> Is this something that people are actually using?  Can we detect it and
> deprecate it in 2.8, and drop it in 2.9?

Libvirt uses -cpu Model,+foo,-bar style, but we do not mix mix -foo and
+foo, or even [+-]foo and foo= if this is what you asked.

Jirka



Re: [Qemu-devel] [PATCH v4 01/11] tests: Add test case for x86 feature parsing compatibility

2016-09-30 Thread Paolo Bonzini


On 29/09/2016 23:14, Eduardo Habkost wrote:
> + * "-foo" overrides "+foo"
> + * "[+-]foo" overrides "foo=..."

Is this something that people are actually using?  Can we detect it and
deprecate it in 2.8, and drop it in 2.9?

Paolo

> + * "foo_bar" should be translated to "foo-bar"



Re: [Qemu-devel] [PATCH v4 01/11] tests: Add test case for x86 feature parsing compatibility

2016-09-29 Thread Jonathan Neuschäfer
On Thu, Sep 29, 2016 at 06:14:49PM -0300, Eduardo Habkost wrote:
> Add a new test case to ensure the existing behavior of the
> feature parsing code wlil be kept.

s/wlil/will/

> 
> Signed-off-by: Eduardo Habkost 


Jonathan Neuschäfer


signature.asc
Description: PGP signature


[Qemu-devel] [PATCH v4 01/11] tests: Add test case for x86 feature parsing compatibility

2016-09-29 Thread Eduardo Habkost
Add a new test case to ensure the existing behavior of the
feature parsing code wlil be kept.

Signed-off-by: Eduardo Habkost 
---
Changes series v3 -> v4:
* New patch added to series
---
 tests/test-x86-cpuid-compat.c | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 83162a4..7cff2b5 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -3,6 +3,7 @@
 #include "qapi/qmp/qlist.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qint.h"
+#include "qapi/qmp/qbool.h"
 #include "libqtest.h"
 
 static char *get_cpu0_qom_path(void)
@@ -34,6 +35,15 @@ static QObject *qom_get(const char *path, const char *prop)
 return ret;
 }
 
+static bool qom_get_bool(const char *path, const char *prop)
+{
+QBool *value = qobject_to_qbool(qom_get(path, prop));
+bool b = qbool_get_bool(value);
+
+QDECREF(value);
+return b;
+}
+
 typedef struct CpuidTestArgs {
 const char *cmdline;
 const char *property;
@@ -66,10 +76,39 @@ 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)
+{
+char *path;
+
+/* Rules:
+ * "-foo" overrides "+foo"
+ * "[+-]foo" overrides "foo=..."
+ * "foo_bar" should be translated to "foo-bar"
+ */
+qtest_start("-cpu 
pentium,-fpu,+fpu,-mce,mce=on,+cx8,cx8=off,+sse4_1,sse4_2=on");
+path = get_cpu0_qom_path();
+
+g_assert_false(qom_get_bool(path, "fpu"));
+g_assert_false(qom_get_bool(path, "mce"));
+g_assert_true(qom_get_bool(path, "cx8"));
+
+/* Test both the original and the alias feature names: */
+g_assert_true(qom_get_bool(path, "sse4-1"));
+g_assert_true(qom_get_bool(path, "sse4.1"));
+
+g_assert_true(qom_get_bool(path, "sse4-2"));
+g_assert_true(qom_get_bool(path, "sse4.2"));
+
+qtest_end();
+g_free(path);
+}
+
 int main(int argc, char **argv)
 {
 g_test_init(&argc, &argv, NULL);
 
+qtest_add_func("x86/cpuid/parsing-plus-minus", test_plus_minus);
+
 /* Original level values for CPU models: */
 add_cpuid_test("x86/cpuid/phenom/level",
"-cpu phenom", "level", 5);
-- 
2.7.4