[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/4] target-i386: Add optional class name to kvm_def
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH 3/4] target-i386: Add optional class name to kvm_default_props |
Date: |
Fri, 11 Sep 2015 16:25:08 -0300 |
This will allow us to define class-specific KVM defaults, instead of
defaults that apply to all CPU models.
If this table is starting to look like the global properties tables,
that's not a coincidence: in the future, we might convert this to
accelerator-specific code that simply register global properties when
the machine is initialized.
Signed-off-by: Eduardo Habkost <address@hidden>
---
hw/i386/pc_piix.c | 8 ++++----
hw/i386/pc_q35.c | 4 ++--
target-i386/cpu.c | 29 +++++++++++++++++------------
target-i386/cpu.h | 3 ++-
4 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index e79ef0d..ad98735 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -325,7 +325,7 @@ static void pc_compat_2_1(MachineState *machine)
pc_compat_2_2(machine);
smbios_uuid_encoded = false;
- x86_cpu_change_kvm_default("svm", NULL);
+ x86_cpu_change_kvm_default(NULL, "svm", NULL);
pcms->enforce_aligned_dimm = false;
}
@@ -361,7 +361,7 @@ static void pc_compat_1_7(MachineState *machine)
gigabyte_align = false;
option_rom_has_mr = true;
legacy_acpi_table_size = 6414;
- x86_cpu_change_kvm_default("x2apic", NULL);
+ x86_cpu_change_kvm_default(NULL, "x2apic", NULL);
}
static void pc_compat_1_6(MachineState *machine)
@@ -391,7 +391,7 @@ static void pc_compat_1_3(MachineState *machine)
static void pc_compat_1_2(MachineState *machine)
{
pc_compat_1_3(machine);
- x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
+ x86_cpu_change_kvm_default(NULL, "kvm-pv-eoi", NULL);
}
/* PC compat function for pc-0.10 to pc-0.13 */
@@ -414,7 +414,7 @@ static void pc_init_isa(MachineState *machine)
if (!machine->cpu_model) {
machine->cpu_model = "486";
}
- x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
+ x86_cpu_change_kvm_default(NULL, "kvm-pv-eoi", NULL);
enable_compat_apic_id_mode();
pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index c17d9df..94d417e 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -309,7 +309,7 @@ static void pc_compat_2_1(MachineState *machine)
pc_compat_2_2(machine);
pcms->enforce_aligned_dimm = false;
smbios_uuid_encoded = false;
- x86_cpu_change_kvm_default("svm", NULL);
+ x86_cpu_change_kvm_default(NULL, "svm", NULL);
}
static void pc_compat_2_0(MachineState *machine)
@@ -326,7 +326,7 @@ static void pc_compat_1_7(MachineState *machine)
smbios_defaults = false;
gigabyte_align = false;
option_rom_has_mr = true;
- x86_cpu_change_kvm_default("x2apic", NULL);
+ x86_cpu_change_kvm_default(NULL, "x2apic", NULL);
}
static void pc_compat_1_6(MachineState *machine)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 9a4bfa3..ec9eca2 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1367,6 +1367,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
};
typedef struct PropValue {
+ const char *type;
const char *prop, *value;
} PropValue;
@@ -1374,24 +1375,25 @@ typedef struct PropValue {
* from all CPU models when KVM is enabled.
*/
static PropValue kvm_default_props[] = {
- { "kvmclock", "on" },
- { "kvm-nopiodelay", "on" },
- { "kvm-asyncpf", "on" },
- { "kvm-steal-time", "on" },
- { "kvm-pv-eoi", "on" },
- { "kvmclock-stable-bit", "on" },
- { "x2apic", "on" },
- { "acpi", "off" },
- { "monitor", "off" },
- { "svm", "off" },
+ { NULL, "kvmclock", "on" },
+ { NULL, "kvm-nopiodelay", "on" },
+ { NULL, "kvm-asyncpf", "on" },
+ { NULL, "kvm-steal-time", "on" },
+ { NULL, "kvm-pv-eoi", "on" },
+ { NULL, "kvmclock-stable-bit", "on" },
+ { NULL, "x2apic", "on" },
+ { NULL, "acpi", "off" },
+ { NULL, "monitor", "off" },
+ { NULL, "svm", "off" },
{ NULL, NULL },
};
-void x86_cpu_change_kvm_default(const char *prop, const char *value)
+void x86_cpu_change_kvm_default(const char *type, const char *prop,
+ const char *value)
{
PropValue *pv;
for (pv = kvm_default_props; pv->prop; pv++) {
- if (!strcmp(pv->prop, prop)) {
+ if (!g_strcmp0(pv->type, type) && !strcmp(pv->prop, prop)) {
pv->value = value;
break;
}
@@ -2079,6 +2081,9 @@ static void x86_cpu_apply_props(X86CPU *cpu, PropValue
*props)
if (!pv->value) {
continue;
}
+ if (pv->type && !object_dynamic_cast(OBJECT(cpu), pv->type)) {
+ continue;
+ }
object_property_parse(OBJECT(cpu), pv->value, pv->prop,
&error_abort);
}
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index f7c733b..c77d455 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -1340,7 +1340,8 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess
access);
* It is valid to call this funciton only for properties that
* are already present in the kvm_default_props table.
*/
-void x86_cpu_change_kvm_default(const char *prop, const char *value);
+void x86_cpu_change_kvm_default(const char *type, const char *prop,
+ const char *value);
/* Return name of 32-bit register, from a R_* constant */
--
2.1.0
- [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Eduardo Habkost, 2015/09/11
- [Qemu-devel] [PATCH 1/4] target-i386: Expand PPRO_FEATURES on qemu64/qemu32 definitions, Eduardo Habkost, 2015/09/11
- [Qemu-devel] [PATCH 2/4] target-i386: Convert kvm_default_*features to property/value pairs, Eduardo Habkost, 2015/09/11
- [Qemu-devel] [PATCH 4/4] target-i386: Disable DE on qemu64 & qemu32 on TCG, Eduardo Habkost, 2015/09/11
- [Qemu-devel] [PATCH 3/4] target-i386: Add optional class name to kvm_default_props,
Eduardo Habkost <=
- Re: [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Richard Henderson, 2015/09/11
- Re: [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Eduardo Habkost, 2015/09/11
- Re: [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Paolo Bonzini, 2015/09/12
- Re: [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Eduardo Habkost, 2015/09/14
- Re: [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Richard Henderson, 2015/09/14
- Re: [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Paolo Bonzini, 2015/09/14
- Re: [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Richard Henderson, 2015/09/14
- Re: [Qemu-devel] [PATCH 0/4] target-i386: Don't try to enable unsupported TCG features by default, Paolo Bonzini, 2015/09/14