[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RHEL6 qemu-kvm PATCH 11/11] add "default" pseudo CPU model
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RHEL6 qemu-kvm PATCH 11/11] add "default" pseudo CPU model name |
Date: |
Thu, 2 Jun 2011 16:13:10 -0300 |
From: john cooper <address@hidden>
Launching qemu with "-cpu [check|enforce]" without explicitly
prefixing a valid model name doesn't do as intuitively expected.
Rather qemu exits with a CLI parse error.
Unfortunately due to qemu's CLI argument parsing structure and
the fact cpu models are initialized depending on build configuration,
supporting the above implicitly for the default model is far more
clunky than it ought to be. So as a minor concession to a far more
simple solution, a pseudo model name of "default" is added which
expands internally to qemu's build configuration default and is then
interpreted conventionally. The result is then the following example
usage:
# x86_64-softmmu/qemu-system-x86_64 -cpu default,check
Using CPU model "qemu64,check"
warning: host cpuid 0000_0001 lacks requested flag 'popcnt' [0x00800000]
warning: host cpuid 8000_0001 lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001 lacks requested flag 'sse4a' [0x00000040]
# x86_64-softmmu/qemu-system-x86_64 -cpu default,+aes,enforce
Using CPU model "qemu64,+aes,enforce"
warning: host cpuid 0000_0001 lacks requested flag 'popcnt' [0x00800000]
warning: host cpuid 0000_0001 lacks requested flag 'aes' [0x02000000]
warning: host cpuid 8000_0001 lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001 lacks requested flag 'sse4a' [0x00000040]
Unable to support requested x86 CPU definition
etc.. allowing both the ability here to "check|enforce" the default
model, as well as accepting arbitrary feature flags due to fan into the
existing flag parsing. The resulting patch, which also indicates the CPU
model in use, is minimal.
Please review and apply.
[ehabkost: edited commit message to have a better Subject line]
Signed-off-by: john cooper <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
hw/pc.c | 39 +++++++++++++++++++++++++++++++++++----
target-i386/helper.c | 1 +
2 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 5b94e53..7949f18 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -939,18 +939,49 @@ static CPUState *pc_new_cpu(const char *cpu_model)
return env;
}
+/* CLI cpu model name which expands to the actual configuration default
+ */
+#define CMDEF_KEYWORD "default"
+#define CMDEF_KEYWORD_LN (sizeof(CMDEF_KEYWORD) - 1)
+
+/* set configuration default cpu model if current model string is
+ * uninitialized, or if user explicitly requests use of the config'ed
+ * default by specifying a cpu model name of "default".
+ * Use of "default" as a cpu model pseudo-name exists primarily to
+ * ease treatment of qualifier flags requested by the user without
+ * requiring knowledge of all cpu model names in advance of full "-cpu"
+ * option parsing.
+ */
+static const char *setdef_cpu_model(const char *model_str,
+ const char *default_str)
+{
+ int default_str_ln = strlen(default_str);
+
+ if (!model_str || !*model_str) {
+ return default_str;
+ } else if (strncmp(model_str, CMDEF_KEYWORD, CMDEF_KEYWORD_LN)) {
+ return model_str;
+ } else {
+ char *new = qemu_malloc(strlen(model_str) - CMDEF_KEYWORD_LN +
+ default_str_ln + 1);
+
+ strcpy(new, default_str);
+ strcpy(new + default_str_ln, model_str + CMDEF_KEYWORD_LN);
+ return new;
+ }
+}
+
void pc_cpus_init(const char *cpu_model)
{
int i;
/* init CPUs */
- if (cpu_model == NULL) {
+ cpu_model = setdef_cpu_model(cpu_model,
#ifdef TARGET_X86_64
- cpu_model = "qemu64";
+ "qemu64");
#else
- cpu_model = "qemu32";
+ "qemu32");
#endif
- }
for(i = 0; i < smp_cpus; i++) {
pc_new_cpu(cpu_model);
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 73f44e8..0b37063 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1251,6 +1251,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
env = qemu_mallocz(sizeof(CPUX86State));
cpu_exec_init(env);
env->cpu_model_str = cpu_model;
+ fprintf(stderr, "Using CPU model \"%s\"\n", cpu_model);
/* init various static tables */
if (!inited) {
--
1.7.3.2
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 00/11] cpu model bug fixes and definition corrections (v2), Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 02/11] Allow an optional qemu_early_init_vcpu(), Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 05/11] cpu defs: use Intel flag names for Intel models, Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 08/11] reorder cpuid feature bits on target-x86_64.conf, Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 04/11] Support -readconfig "?" to debug config file loading, Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 03/11] Add kvm emulated x2apic flag to config defined cpu models (v2), Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 01/11] correct archaic CPU model "model" field for Intel CPUs., Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 09/11] cpu defs: add pse36, mca, mtrr to AMD CPU definitions, Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 10/11] add Westmere as a qemu cpu model, Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 07/11] cpu defs: uncomment empty extfeatures_ecx definition for Opteron_G1, Eduardo Habkost, 2011/06/02
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 11/11] add "default" pseudo CPU model name,
Eduardo Habkost <=
- [Qemu-devel] [RHEL6 qemu-kvm PATCH 06/11] cpu defs: remove replicated flags from Intel, Eduardo Habkost, 2011/06/02
- Re: [Qemu-devel] [PATCH 00/11] cpu model bug fixes and definition corrections (v2), Eduardo Habkost, 2011/06/02