Skip to contentSkip to conversation

target-i386: add a list of enforceable CPU models to the help output

PATCH In review Peter Lieven 5 participants 16 messages Aug 24, 2015 – Aug 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-i386: add a list of enforceable CPU models to the help output

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

---
 target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
target-i386/cpu.c +49 -0
index cfb8aa7..3a56d3f 100644
@@ -1961,6 +1961,45 @@ static void listflags(FILE *f, fprintf_function print, const char **featureset)
     }
 }
 
+/*
+ * Check if the CPU Definition is enforcable on the current host CPU
+ * and contains no unmigratable flags.
+ *
+ * Returns: true if the CPU can be enforced and migrated.
+ */
+static bool x86_cpu_enforce_and_migratable(X86CPUDefinition *def)
+{
+    int i;
+    for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
+        FeatureWordInfo *fw = &feature_word_info[i];
+        uint32_t eax, ebx, ecx, edx, host;
+        host_cpuid(fw->cpuid_eax, 0, &eax, &ebx, &ecx, &edx);
+        switch (fw->cpuid_reg) {
+        case R_EAX:
+            host = eax;
+            break;
+        case R_EBX:
+            host = ebx;
+            break;
+        case R_ECX:
+            host = ecx;
+            break;
+        case R_EDX:
+            host = edx;
+            break;
+        default:
+            return false;
+        }
+        if (def->features[i] & ~host) {
+            return false;
+        }
+        if (def->features[i] & fw->unmigratable_flags) {
+            return false;
+        }
+    }
+    return true;
+}
+
 /* generate CPU information. */
 void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
@@ -1987,6 +2026,16 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
         listflags(f, cpu_fprintf, fw->feat_names);
         (*cpu_fprintf)(f, "\n");
     }
+
+    (*cpu_fprintf)(f, "\nEnforceable and migratable x86 CPU models in KVM mode:\n");
+    (*cpu_fprintf)(f, " ");
+    for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
+        def = &builtin_x86_defs[i];
+        if (x86_cpu_enforce_and_migratable(def)) {
+            (*cpu_fprintf)(f, " %s", def->name);
+        }
+    }
+    (*cpu_fprintf)(f, "\n");
 }
 
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
Signature · 1 line
1.9.1
#1 lore raw

[Qemu-devel] CPU Model kvm64 and Windows2012R2

Hi,

I noticed that Win2012R2 will not boot with CPU model kvm64. The reason is that the feature lahf_lm is missing.

Is that an error or correct?

Thanks,
Peter

#2 lore raw

Re: [Qemu-devel] CPU Model kvm64 and Windows2012R2

Hi, some very old 64-bit processors had virtualization extensions but not lahf_lm. However, they are very rare, so it is probably a good idea to add it for the 2.5 machine type.

Thanks,

Paolo

Inviato dal telefono Android mediante TouchDown (www.nitrodesk.com)

-----Original Message-----
From: Peter Lieven [[email protected]]
Received: lunedì, 24 ago 2015, 12:28
To: [email protected]
CC: [email protected], [email protected], [email protected], [email protected]
Subject: CPU Model kvm64 and Windows2012R2

Hi,

I noticed that Win2012R2 will not boot with CPU model kvm64. The reason is that the feature lahf_lm is missing.

Is that an error or correct?

Thanks,
Peter

#3 lore raw

Re: [Qemu-devel] CPU Model kvm64 and Windows2012R2

Am 24.08.2015 um 13:50 schrieb Paolo Bonzini:

Quoted 1 line

Hi, some very old 64-bit processors had virtualization extensions but not lahf_lm. However, they are very rare, so it is probably a good idea to add it for the 2.5 machine type.

Maybe same accounts for "sep" ?

Will you send a patch?

BR,
Peter

#4 lore raw

Re: [Qemu-devel] CPU Model kvm64 and Windows2012R2

In reply to Peter Lieven

Hi, some very old 64-bit processors had virtualization extensions but not lahf_lm. However, they are very rare, so it is probably a good idea to add it for the 2.5 machine type.

Thanks,

Paolo

Inviato dal telefono Android mediante TouchDown (www.nitrodesk.com)

-----Original Message-----
From: Peter Lieven [[email protected]]
Received: lunedì, 24 ago 2015, 12:28
To: [email protected]
CC: [email protected], [email protected], [email protected], [email protected]
Subject: CPU Model kvm64 and Windows2012R2

Hi,

I noticed that Win2012R2 will not boot with CPU model kvm64. The reason is that the feature lahf_lm is missing.

Is that an error or correct?

Thanks,
Peter

#5 lore raw
In reply to Peter Lieven
Quoted 9 lines · Peter Lieven

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

---
 target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

Is this same sort of listing available through QMP? Parsing '-cpu help' output is undesirable from libvirt point of view.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#6 lore raw

Am 24.08.2015 um 17:46 schrieb Eric Blake:

Quoted 6 lines · Peter Lieven
Quoted 5 lines

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

Quoted 7 lines
Quoted 4 lines
---
 target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

Is this same sort of listing available through QMP? Parsing '-cpu help' output is undesirable from libvirt point of view.

A good point. But is there a QMP command to list available CPU types? In this case it should be easy to extend.

But, I wonder how to issue a QMP command before the vserver is actually running? Is there a common way to do it?

Peter

#7 lore raw
Quoted 11 lines · Peter Lieven

Am 24.08.2015 um 17:46 schrieb Eric Blake:

Quoted 10 lines · Peter Lieven
Quoted 9 lines

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

---
 target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
Quoted 6 lines
Quoted 3 lines

Is this same sort of listing available through QMP? Parsing '-cpu help' output is undesirable from libvirt point of view.

A good point. But is there a QMP command to list available CPU types? In this case it should be easy to extend.

Yes, that's query-cpu-definitions. See past discussion at:
http://thread.gmane.org/gmane.comp.emulators.qemu/332554

Some of the assumptions at that thread changed. See:
http://thread.gmane.org/gmane.comp.emulators.qemu/342582/focus=346651
That means runnability should depend only on the accelerator type, and not on the machine-type anymore.

Quoted 3 lines

But, I wonder how to issue a QMP command before the vserver is actually running? Is there a common way to do it?

What's a vserver?

Signature · 1 line
Eduardo
#8 lore raw

Am 26.08.2015 um 20:38 schrieb Eduardo Habkost:

Quoted 17 lines · Peter Lieven
Quoted 11 lines

Am 24.08.2015 um 17:46 schrieb Eric Blake:

Quoted 10 lines · Peter Lieven
Quoted 9 lines

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

---
 target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
Quoted 5 lines
Quoted 3 lines

Is this same sort of listing available through QMP? Parsing '-cpu help' output is undesirable from libvirt point of view.

A good point. But is there a QMP command to list available CPU types? In this case it should be easy to extend.

Quoted 7 lines

Yes, that's query-cpu-definitions. See past discussion at:
http://thread.gmane.org/gmane.comp.emulators.qemu/332554

Some of the assumptions at that thread changed. See:
http://thread.gmane.org/gmane.comp.emulators.qemu/342582/focus=346651
That means runnability should depend only on the accelerator type, and not on the machine-type anymore.

Thanks for the pointer. But is it possible to query cpu definitions without a running Qemu? Like passing a QMP command on the commandline and receive the answer on stdout?

Quoted 5 lines
Quoted 3 lines

But, I wonder how to issue a QMP command before the vserver is actually running? Is there a common way to do it?

What's a vserver?

A Virtual Server.

Thanks,
Peter

#9 lore raw
Quoted 21 lines · Peter Lieven

Am 26.08.2015 um 20:38 schrieb Eduardo Habkost:

Quoted 20 lines · Peter Lieven
Quoted 11 lines

Am 24.08.2015 um 17:46 schrieb Eric Blake:

Quoted 10 lines · Peter Lieven
Quoted 9 lines

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

---
 target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
Quoted 5 lines
Quoted 3 lines

Is this same sort of listing available through QMP? Parsing '-cpu help' output is undesirable from libvirt point of view.

A good point. But is there a QMP command to list available CPU types? In this case it should be easy to extend.

Yes, that's query-cpu-definitions. See past discussion at:
http://thread.gmane.org/gmane.comp.emulators.qemu/332554

Quoted 8 lines
Quoted 4 lines

Some of the assumptions at that thread changed. See:
http://thread.gmane.org/gmane.comp.emulators.qemu/342582/focus=346651
That means runnability should depend only on the accelerator type, and not on the machine-type anymore.

Thanks for the pointer. But is it possible to query cpu definitions without a running Qemu? Like passing a QMP command on the commandline and receive the answer on stdout?

Well, it's impossible to check if a CPU model is runnable without running QEMU. :)

I don't think you can send a QMP command through command-line arguments, but you can easily start a QMP monitor on stdin/stdio.

Example:

  $ (echo '{ "execute": "qmp_capabilities" }';echo '{"execute":"query-cpu-definitions"}';echo '{"execute":"quit"}';) | ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -S -qmp stdio -machine none -nographic
  {"QMP": {"version": {"qemu": {"micro": 50, "minor": 4, "major": 2}, "package": ""}, "capabilities": []}}
  {"return": {}}
  {"return": [{"name": "Opteron_G5"}, {"name": "Opteron_G4"}, {"name": "Opteron_G3"}, {"name": "Opteron_G2"}, {"name": "Opteron_G1"}, {"name": "Broadwell"}, {"name": "Broadwell-noTSX"}, {"name": "Haswell"}, {"name": "Haswell-noTSX"}, {"name": "IvyBridge"}, {"name": "SandyBridge"}, {"name": "Westmere"}, {"name": "Nehalem"}, {"name": "Penryn"}, {"name": "Conroe"}, {"name": "n270"}, {"name": "athlon"}, {"name": "pentium3"}, {"name": "pentium2"}, {"name": "pentium"}, {"name": "486"}, {"name": "coreduo"}, {"name": "kvm32"}, {"name": "qemu32"}, {"name": "kvm64"}, {"name": "core2duo"}, {"name": "phenom"}, {"name": "qemu64"}]}
  {"return": {}}
  {"timestamp": {"seconds": 1440615228, "microseconds": 854114}, "event": "SHUTDOWN"}
  $ 
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

But, I wonder how to issue a QMP command before the vserver is actually running? Is there a common way to do it?

What's a vserver?

A Virtual Server.

You mean the virtual machine? Yes, it is possible to run QMP commands before the machine is running (you just need to use -S). You can also use "-machine none" if you don't want any machine-specific initialization code to run at all.

Signature · 1 line
Eduardo
#10 lore raw
Quoted 41 lines

Am 26.08.2015 um 21:00 schrieb Eduardo Habkost <[email protected]>:

Quoted 22 lines · Peter Lieven
Quoted 21 lines

Am 26.08.2015 um 20:38 schrieb Eduardo Habkost:

Quoted 12 lines · Peter Lieven
Quoted 11 lines

Am 24.08.2015 um 17:46 schrieb Eric Blake:

Quoted 10 lines · Peter Lieven

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

---
target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++

1 file changed, 49 insertions(+)
Quoted 5 lines
Quoted 3 lines

Is this same sort of listing available through QMP? Parsing '-cpu help' output is undesirable from libvirt point of view.

A good point. But is there a QMP command to list available CPU types? In this case it should be easy to extend.

Yes, that's query-cpu-definitions. See past discussion at:
http://thread.gmane.org/gmane.comp.emulators.qemu/332554

Quoted 8 lines
Quoted 4 lines

Some of the assumptions at that thread changed. See:
http://thread.gmane.org/gmane.comp.emulators.qemu/342582/focus=346651
That means runnability should depend only on the accelerator type, and not on the machine-type anymore.

Thanks for the pointer. But is it possible to query cpu definitions without a running Qemu? Like passing a QMP command on the commandline and receive the answer on stdout?

Well, it's impossible to check if a CPU model is runnable without running QEMU. :)

I don't think you can send a QMP command through command-line arguments, but you can easily start a QMP monitor on stdin/stdio.

Quoted 9 lines

Example:

 $ (echo '{ "execute": "qmp_capabilities" }';echo '{"execute":"query-cpu-definitions"}';echo '{"execute":"quit"}';) | ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -S -qmp stdio -machine none -nographic
 {"QMP": {"version": {"qemu": {"micro": 50, "minor": 4, "major": 2}, "package": ""}, "capabilities": []}}
 {"return": {}}
 {"return": [{"name": "Opteron_G5"}, {"name": "Opteron_G4"}, {"name": "Opteron_G3"}, {"name": "Opteron_G2"}, {"name": "Opteron_G1"}, {"name": "Broadwell"}, {"name": "Broadwell-noTSX"}, {"name": "Haswell"}, {"name": "Haswell-noTSX"}, {"name": "IvyBridge"}, {"name": "SandyBridge"}, {"name": "Westmere"}, {"name": "Nehalem"}, {"name": "Penryn"}, {"name": "Conroe"}, {"name": "n270"}, {"name": "athlon"}, {"name": "pentium3"}, {"name": "pentium2"}, {"name": "pentium"}, {"name": "486"}, {"name": "coreduo"}, {"name": "kvm32"}, {"name": "qemu32"}, {"name": "kvm64"}, {"name": "core2duo"}, {"name": "phenom"}, {"name": "qemu64"}]}
 {"return": {}}
 {"timestamp": {"seconds": 1440615228, "microseconds": 854114}, "event": "SHUTDOWN"}
 $ 

ok, now I have a list of cpu models.
what I could do now is fire up a qemu process for each model with enforce and look at the exit code to see if it is enforcable on my host.

for me this would work as well.

or add a qmp command that lists all enforcable models.

Thanks for your help.
Peter

Quoted 16 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

But, I wonder how to issue a QMP command before the vserver is actually running? Is there a common way to do it?

What's a vserver?

A Virtual Server.

You mean the virtual machine? Yes, it is possible to run QMP commands before the machine is running (you just need to use -S). You can also use "-machine none" if you don't want any machine-specific initialization code to run at all.

Signature · 1 line
Eduardo
#11 lore raw
In reply to Peter Lieven

Hi,

Am 24.08.2015 um 03:17 schrieb Peter Lieven:

Quoted 3 lines

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any

models

Quoted 11 lines

feature flags.

---
 target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
target-i386/cpu.c +0 -0
index cfb8aa7..3a56d3f 100644

[...]

Quoted 7 lines
target-i386/cpu.c +3 -0
@@ -1987,6 +2026,16 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
         listflags(f, cpu_fprintf, fw->feat_names);
         (*cpu_fprintf)(f, "\n");
     }
+
+    (*cpu_fprintf)(f, "\nEnforceable and migratable x86 CPU models in KVM mode:\n");
+    (*cpu_fprintf)(f, " ");

target-i386/cpu.c void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf) · line 2041

Quoted 10 lines
target-i386/cpu.c +7 -0
+    for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
+        def = &builtin_x86_defs[i];
+        if (x86_cpu_enforce_and_migratable(def)) {
+            (*cpu_fprintf)(f, " %s", def->name);
+        }
+    }
+    (*cpu_fprintf)(f, "\n");
 }
 
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)

I don't think adding a new section is such a good idea here, it may add more confusion than it helps. I would rather suggest to add some annotation to the existing list.

Regards,
Andreas

Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
#12 lore raw
Quoted 41 lines

Am 24.08.2015 um 22:22 schrieb Andreas Färber <[email protected]>:

Hi,

Quoted 4 lines

Am 24.08.2015 um 03:17 schrieb Peter Lieven:
this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any

models

Quoted 11 lines

feature flags.

---
target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++

1 file changed, 49 insertions(+)
target-i386/cpu.c +0 -0
index cfb8aa7..3a56d3f 100644

[...]

Quoted 16 lines
target-i386/cpu.c +10 -0
@@ -1987,6 +2026,16 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
        listflags(f, cpu_fprintf, fw->feat_names);
        (*cpu_fprintf)(f, "\n");
    }
+
+    (*cpu_fprintf)(f, "\nEnforceable and migratable x86 CPU models in KVM mode:\n");
+    (*cpu_fprintf)(f, " ");
+    for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
+        def = &builtin_x86_defs[i];
+        if (x86_cpu_enforce_and_migratable(def)) {
+            (*cpu_fprintf)(f, " %s", def->name);
+        }
+    }
+    (*cpu_fprintf)(f, "\n");
 }
 
Quoted 5 lines

target-i386/cpu.c void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf) · line 2041

Quoted 1 line
target-i386/cpu.c +0 -0
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)

I don't think adding a new section is such a good idea here, it may add more confusion than it helps. I would rather suggest to add some annotation to the existing list.

I have also thought of this first, but found it confusing as well. But maybe you have a good idea how to format it?

I also think of Erics concern that it might be a good idea to get a json output of supported models somehow.

Peter

Quoted 7 lines

Regards,
Andreas

Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
#13 lore raw
In reply to Peter Lieven
Quoted 6 lines · Peter Lieven

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

[...]

target-i386/cpu.c static void listflags(FILE *f, fprintf_function print, const char **featureset) · line 1976

Quoted 13 lines
target-i386/cpu.c +13 -0
+/*
+ * Check if the CPU Definition is enforcable on the current host CPU
+ * and contains no unmigratable flags.
+ *
+ * Returns: true if the CPU can be enforced and migrated.
+ */
+static bool x86_cpu_enforce_and_migratable(X86CPUDefinition *def)
+{
+    int i;
+    for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
+        FeatureWordInfo *fw = &feature_word_info[i];
+        uint32_t eax, ebx, ecx, edx, host;
+        host_cpuid(fw->cpuid_eax, 0, &eax, &ebx, &ecx, &edx);

This isn't how you check if the CPU model can run in "enforce" mode. Please read x86_cpu_filter_features().

Also, you can't tell if a CPU model is runnable in enforce mode unless you know what's the accelerator being used (see x86_cpu_filter_features()). How do you suggest we show accelerator-specific information in help output?

Signature · 1 line
Eduardo
#14 lore raw

Am 26.08.2015 um 17:54 schrieb Eduardo Habkost:

Quoted 8 lines · Peter Lieven
Quoted 6 lines

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

[...]

Quoted 15 lines

target-i386/cpu.c static void listflags(FILE *f, fprintf_function print, const char **featureset) · line 1976

Quoted 13 lines
target-i386/cpu.c +13 -0
+/*
+ * Check if the CPU Definition is enforcable on the current host CPU
+ * and contains no unmigratable flags.
+ *
+ * Returns: true if the CPU can be enforced and migrated.
+ */
+static bool x86_cpu_enforce_and_migratable(X86CPUDefinition *def)
+{
+    int i;
+    for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
+        FeatureWordInfo *fw = &feature_word_info[i];
+        uint32_t eax, ebx, ecx, edx, host;
+        host_cpuid(fw->cpuid_eax, 0, &eax, &ebx, &ecx, &edx);

This isn't how you check if the CPU model can run in "enforce" mode. Please read x86_cpu_filter_features().

I did, but will do again. The problem is that x86_cpu_filter_features requires enabled KVM to run. I believed internally it does something similar to what I do here.

Quoted 6 lines

Also, you can't tell if a CPU model is runnable in enforce mode unless you know what's the accelerator being used (see x86_cpu_filter_features()). How do you suggest we show accelerator-specific information in help output?

The subject was missing that the goal was to list enforceable models in KVM mode. The output of the help page mentions this.

Andreas suggested to make annotations to the list of CPU models. In theory it would be possible to have different annotations for different accelerators.

Peter

#15 lore raw
Quoted 25 lines · Peter Lieven

Am 26.08.2015 um 17:54 schrieb Eduardo Habkost:

Quoted 8 lines · Peter Lieven
Quoted 6 lines

this patch adds a probe that lists all enforceable and migrateable CPU models to the -cpu help output. The idea is to know a priory which CPU modules can be exposed to the user without loosing any feature flags.

[...]

Quoted 15 lines

target-i386/cpu.c static void listflags(FILE *f, fprintf_function print, const char **featureset) · line 1976

Quoted 13 lines
target-i386/cpu.c +13 -0
+/*
+ * Check if the CPU Definition is enforcable on the current host CPU
+ * and contains no unmigratable flags.
+ *
+ * Returns: true if the CPU can be enforced and migrated.
+ */
+static bool x86_cpu_enforce_and_migratable(X86CPUDefinition *def)
+{
+    int i;
+    for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
+        FeatureWordInfo *fw = &feature_word_info[i];
+        uint32_t eax, ebx, ecx, edx, host;
+        host_cpuid(fw->cpuid_eax, 0, &eax, &ebx, &ecx, &edx);

This isn't how you check if the CPU model can run in "enforce" mode. Please read x86_cpu_filter_features().

Quoted 2 lines

I did, but will do again. The problem is that x86_cpu_filter_features requires enabled KVM to run.

You don't have any choice: you need to initialize KVM to be able to report correct results.

See this:
http://article.gmane.org/gmane.comp.emulators.kvm.devel/133288
and the rest of the "s390x cpu model implementation" threads for some information about accel object creation, and what's needed.

Quoted 2 lines

I believed internally it does something
similar to what I do here.

It doesn't. Please read the code.

Quoted 10 lines
Quoted 7 lines

Also, you can't tell if a CPU model is runnable in enforce mode unless you know what's the accelerator being used (see x86_cpu_filter_features()). How do you suggest we show accelerator-specific information in help output?

The subject was missing that the goal was to list enforceable models in KVM mode. The output of the help page mentions this.

There are zero mentions to KVM in x86_cpu_enforce_and_migratable(). If the code is KVM-specific, please name functions and comment the code accordingly.

Quoted 4 lines

Andreas suggested to make annotations to the list of CPU models. In theory it would be possible to have different annotations for different accelerators.

That's one possible way to implement it, but maybe there's no need to make the code more complex for that. We can't check if the CPU model is runnable at class_init time, anyway, and re-running the runnability-check code in case the query is made multiple times won't be be a problem.

Signature · 1 line
Eduardo