[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v3 1/3] target-i386: add a subsection for migrating vc
From: |
Haozhong Zhang |
Subject: |
[Qemu-ppc] [PATCH v3 1/3] target-i386: add a subsection for migrating vcpu's TSC rate |
Date: |
Mon, 2 Nov 2015 17:26:41 +0800 |
A new subsection 'vmstate_tsc_khz' is added to migrate vcpu's TSC
rate. For the backwards compatibility, this subsection is not migrated
on pc-*-2.4 and older machine types.
Signed-off-by: Haozhong Zhang <address@hidden>
---
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 1 +
hw/i386/pc_q35.c | 1 +
include/hw/i386/pc.h | 1 +
target-i386/cpu.h | 1 +
target-i386/machine.c | 21 +++++++++++++++++++++
6 files changed, 26 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 0cb8afd..2f2fc93 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1952,6 +1952,7 @@ static void pc_machine_class_init(ObjectClass *oc, void
*data)
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
pcmc->get_hotplug_handler = mc->get_hotplug_handler;
+ pcmc->save_tsc_khz = true;
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->cpu_index_to_socket_id = pc_cpu_index_to_socket_id;
mc->default_boot_order = "cad";
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 393dcc4..fc71321 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -487,6 +487,7 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m)
m->alias = NULL;
m->is_default = 0;
pcmc->broken_reserved_end = true;
+ pcmc->save_tsc_khz = false;
SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 2f8f396..858ed69 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -385,6 +385,7 @@ static void pc_q35_2_4_machine_options(MachineClass *m)
pc_q35_2_5_machine_options(m);
m->alias = NULL;
pcmc->broken_reserved_end = true;
+ pcmc->save_tsc_khz = false;
SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
}
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 606dbc2..875d099 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -60,6 +60,7 @@ struct PCMachineClass {
/*< public >*/
bool broken_reserved_end;
+ bool save_tsc_khz;
HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
DeviceState *dev);
};
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 62f7879..4f2f4a3 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -970,6 +970,7 @@ typedef struct CPUX86State {
uint32_t sipi_vector;
bool tsc_valid;
int64_t tsc_khz;
+ int64_t tsc_khz_saved;
void *kvm_xsave_buf;
uint64_t mcg_cap;
diff --git a/target-i386/machine.c b/target-i386/machine.c
index a18e16e..4d8157c 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -775,6 +775,26 @@ static const VMStateDescription vmstate_xss = {
}
};
+static bool tsc_khz_needed(void *opaque)
+{
+ X86CPU *cpu = opaque;
+ CPUX86State *env = &cpu->env;
+ MachineClass *mc = MACHINE_GET_CLASS((qdev_get_machine()));
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(mc);
+ return env->tsc_khz_saved && pcmc->save_tsc_khz;
+}
+
+static const VMStateDescription vmstate_tsc_khz = {
+ .name = "cpu/tsc_khz",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = tsc_khz_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_INT64(env.tsc_khz_saved, X86CPU),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
VMStateDescription vmstate_x86_cpu = {
.name = "cpu",
.version_id = 12,
@@ -895,6 +915,7 @@ VMStateDescription vmstate_x86_cpu = {
&vmstate_msr_hyperv_runtime,
&vmstate_avx512,
&vmstate_xss,
+ &vmstate_tsc_khz,
NULL
}
};
--
2.4.8
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, (continued)
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Eduardo Habkost, 2015/11/06
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, haozhong . zhang, 2015/11/08
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Eduardo Habkost, 2015/11/09
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Dr. David Alan Gilbert, 2015/11/09
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Haozhong Zhang, 2015/11/09
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Eduardo Habkost, 2015/11/11
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Haozhong Zhang, 2015/11/11
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Haozhong Zhang, 2015/11/10
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Eduardo Habkost, 2015/11/11
- Re: [Qemu-ppc] [PATCH v3 2/3] target-i386: calculate vcpu's TSC rate to be migrated, Haozhong Zhang, 2015/11/11
[Qemu-ppc] [PATCH v3 1/3] target-i386: add a subsection for migrating vcpu's TSC rate,
Haozhong Zhang <=
[Qemu-ppc] [PATCH v3 3/3] target-i386: load the migrated vcpu's TSC rate, Haozhong Zhang, 2015/11/02