From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Igor Mammedov" <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH for-2.4 v5 7/7] tests: test-x86-cpu: Ensure that -cpu override KVM-specific defaults
Date: Mon, 23 Mar 2015 16:37:12 -0300 [thread overview]
Message-ID: <1427139432-27530-8-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1427139432-27530-1-git-send-email-ehabkost@redhat.com>
Add a test case to ensure reordering the feature handling code won't
make accelerator-specific defaults override explicit command-line
options. Explicit command-line options should always override the CPU
model defaults.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
tests/test-x86-cpu.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/tests/test-x86-cpu.c b/tests/test-x86-cpu.c
index b1b04ea..618624b 100644
--- a/tests/test-x86-cpu.c
+++ b/tests/test-x86-cpu.c
@@ -160,6 +160,36 @@ static void test_host_cpu_features_kvm(void)
all_unsupported = false;
}
+/* Ensure that explicit CPU options always override KVM-specific defaults */
+static void test_kvm_override(void)
+{
+ int i;
+ kvm_allowed = true;
+
+ /* Even KVM defaults change on cpu.c, this test relies on x2apic being
+ * always enabled, and monitor being always disabled by KVM:
+ */
+ kvm_default_features[FEAT_1_ECX] |= CPUID_EXT_X2APIC;
+ kvm_default_unset_features[FEAT_1_ECX] |= CPUID_EXT_MONITOR;
+
+ for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); ++i) {
+ ObjectClass *oc;
+ X86CPU *cpu;
+ X86CPUDefinition *def = &builtin_x86_defs[i];
+ char features[] = "-x2apic,+monitor";
+
+ oc = x86_cpu_class_by_name(def->name);
+ cpu = X86_CPU(object_new(object_class_get_name(oc)));
+ x86_cpu_parse_featurestr(CPU(cpu), features, &error_abort);
+
+ g_assert_cmpint(cpu->env.features[FEAT_1_ECX] & CPUID_EXT_MONITOR, ==,
+ CPUID_EXT_MONITOR);
+ g_assert_cmpint(cpu->env.features[FEAT_1_ECX] & CPUID_EXT_X2APIC, ==,
+ 0);
+ object_unref(OBJECT(cpu));
+ }
+}
+
int main(int argc, char *argv[])
{
module_call_init(MODULE_INIT_QOM);
@@ -170,6 +200,7 @@ int main(int argc, char *argv[])
g_test_add_func("/cpu/x86/features/tcg", test_cpu_features_tcg);
g_test_add_func("/cpu/x86/features/kvm", test_cpu_features_kvm);
g_test_add_func("/cpu/x86/features/host", test_host_cpu_features_kvm);
+ g_test_add_func("/cpu/x86/features/kvm-override", test_kvm_override);
g_test_run();
--
2.1.0
next prev parent reply other threads:[~2015-03-23 19:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 19:37 [Qemu-devel] [PATCH for-2.4 v5 0/7] Target-specific unit test support, add unit tests for target-i386/cpu.c code Eduardo Habkost
2015-03-23 19:37 ` [Qemu-devel] [PATCH for-2.4 v5 1/7] tests: Support target-specific unit tests Eduardo Habkost
2015-03-23 19:37 ` [Qemu-devel] [PATCH for-2.4 v5 2/7] tests: Make test-x86-cpuid target-specific Eduardo Habkost
2015-03-23 19:37 ` [Qemu-devel] [PATCH for-2.4 v5 3/7] tests: Add unit test for X86CPU code Eduardo Habkost
2015-03-23 19:37 ` [Qemu-devel] [PATCH for-2.4 v5 4/7] target-i386: Isolate enabled-by-default features to a separate array Eduardo Habkost
2015-03-23 19:37 ` [Qemu-devel] [PATCH for-2.4 v5 5/7] tests: test-x86-cpu: Add TCG feature bit initialization test Eduardo Habkost
2015-03-23 19:37 ` [Qemu-devel] [PATCH for-2.4 v5 6/7] tests: test-x86-cpu: Add KVM " Eduardo Habkost
2015-03-23 19:37 ` Eduardo Habkost [this message]
2015-04-08 13:06 ` [Qemu-devel] [PATCH for-2.4 v5 0/7] Target-specific unit test support, add unit tests for target-i386/cpu.c code Andreas Färber
2015-04-08 13:42 ` Eduardo Habkost
2015-04-08 14:05 ` Andreas Färber
2015-04-08 14:57 ` 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=1427139432-27530-8-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=afaerber@suse.de \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 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).