Patchwork [RFC,5/6] target-i386: Move kvm_features/hypervisor initialization to cpu_x86_find_by_name()

login
register
mail settings
Submitter Eduardo Habkost
Date Jan. 4, 2013, 7:56 p.m.
Message ID <1357329382-20944-6-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/209530/
State New
Headers show

Comments

Eduardo Habkost - Jan. 4, 2013, 7:56 p.m.
Move the initialization to the cpu_x86_find_by_name(), inside the block
for predefined CPU models.

That code is not necessary for -cpu "host", because:

- kvm_features doesn't need to be set because kvm_cpu_fill_host()
  already sets all bits supported by the host.
- the CPUID_EXT_HYPERVISOR flag doesn't need to be manually set because
  kvm_arch_get_supported_cpuid() already sets it.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 54be18c..03b7f55 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1281,6 +1281,15 @@  static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name)
             host_cpuid(0, 0, NULL, &ebx, &ecx, &edx);
             x86cpu_vendor_words2str(x86_cpu_def->vendor, ebx, edx, ecx);
         }
+
+        x86_cpu_def->kvm_features |= kvm_default_features;
+        add_flagname_to_bitmaps("hypervisor", &x86_cpu_def->features,
+                                &x86_cpu_def->ext_features,
+                                &x86_cpu_def->ext2_features,
+                                &x86_cpu_def->ext3_features,
+                                &x86_cpu_def->kvm_features,
+                                &x86_cpu_def->svm_features,
+                                &x86_cpu_def->cpuid_7_0_ebx_features);
     }
 
     return 0;
@@ -1555,12 +1564,6 @@  X86CPU *cpu_x86_create(const char *cpu_model, Error **errp)
     env = &cpu->env;
     env->cpu_model_str = cpu_model;
 
-    def->kvm_features |= kvm_default_features;
-    add_flagname_to_bitmaps("hypervisor", &def->features,
-                            &def->ext_features, &def->ext2_features,
-                            &def->ext3_features, &def->kvm_features,
-                            &def->svm_features, &def->cpuid_7_0_ebx_features);
-
     cpudef_2_x86_cpu(cpu, def, &error);
 
     if (cpu_x86_parse_featurestr(cpu, features, &props) < 0) {