aboutsummaryrefslogtreecommitdiff
path: root/softmmu
diff options
context:
space:
mode:
authorClaudio Fontana <cfontana@suse.de>2020-07-07 10:54:37 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-10-05 16:41:22 +0200
commit57038a92bb06111fbee57f56c0231359573e805d (patch)
tree4a094bb895a08591845a9dd788244d700ab4c3e0 /softmmu
parent1583a389885346208217e8170395624b3aa90480 (diff)
cpus: extract out kvm-specific code to accel/kvm
register a "CpusAccel" interface for KVM as well. Signed-off-by: Claudio Fontana <cfontana@suse.de> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> [added const] Signed-off-by: Claudio Fontana <cfontana@suse.de> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'softmmu')
-rw-r--r--softmmu/cpus.c77
1 files changed, 0 insertions, 77 deletions
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index b14b22161f..9fa73735a2 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -179,9 +179,6 @@ void cpu_synchronize_state(CPUState *cpu)
if (cpus_accel && cpus_accel->synchronize_state) {
cpus_accel->synchronize_state(cpu);
}
- if (kvm_enabled()) {
- kvm_cpu_synchronize_state(cpu);
- }
if (hax_enabled()) {
hax_cpu_synchronize_state(cpu);
}
@@ -195,9 +192,6 @@ void cpu_synchronize_post_reset(CPUState *cpu)
if (cpus_accel && cpus_accel->synchronize_post_reset) {
cpus_accel->synchronize_post_reset(cpu);
}
- if (kvm_enabled()) {
- kvm_cpu_synchronize_post_reset(cpu);
- }
if (hax_enabled()) {
hax_cpu_synchronize_post_reset(cpu);
}
@@ -211,9 +205,6 @@ void cpu_synchronize_post_init(CPUState *cpu)
if (cpus_accel && cpus_accel->synchronize_post_init) {
cpus_accel->synchronize_post_init(cpu);
}
- if (kvm_enabled()) {
- kvm_cpu_synchronize_post_init(cpu);
- }
if (hax_enabled()) {
hax_cpu_synchronize_post_init(cpu);
}
@@ -227,9 +218,6 @@ void cpu_synchronize_pre_loadvm(CPUState *cpu)
if (cpus_accel && cpus_accel->synchronize_pre_loadvm) {
cpus_accel->synchronize_pre_loadvm(cpu);
}
- if (kvm_enabled()) {
- kvm_cpu_synchronize_pre_loadvm(cpu);
- }
if (hax_enabled()) {
hax_cpu_synchronize_pre_loadvm(cpu);
}
@@ -384,14 +372,6 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data)
do_run_on_cpu(cpu, func, data, &qemu_global_mutex);
}
-static void qemu_kvm_destroy_vcpu(CPUState *cpu)
-{
- if (kvm_destroy_vcpu(cpu) < 0) {
- error_report("kvm_destroy_vcpu failed");
- exit(EXIT_FAILURE);
- }
-}
-
static void qemu_cpu_stop(CPUState *cpu, bool exit)
{
g_assert(qemu_cpu_is_self(cpu));
@@ -436,48 +416,6 @@ void qemu_wait_io_event(CPUState *cpu)
qemu_wait_io_event_common(cpu);
}
-static void *qemu_kvm_cpu_thread_fn(void *arg)
-{
- CPUState *cpu = arg;
- int r;
-
- rcu_register_thread();
-
- qemu_mutex_lock_iothread();
- qemu_thread_get_self(cpu->thread);
- cpu->thread_id = qemu_get_thread_id();
- cpu->can_do_io = 1;
- current_cpu = cpu;
-
- r = kvm_init_vcpu(cpu);
- if (r < 0) {
- error_report("kvm_init_vcpu failed: %s", strerror(-r));
- exit(1);
- }
-
- kvm_init_cpu_signals(cpu);
-
- /* signal CPU creation */
- cpu_thread_signal_created(cpu);
- qemu_guest_random_seed_thread_part2(cpu->random_seed);
-
- do {
- if (cpu_can_run(cpu)) {
- r = kvm_cpu_exec(cpu);
- if (r == EXCP_DEBUG) {
- cpu_handle_guest_debug(cpu);
- }
- }
- qemu_wait_io_event(cpu);
- } while (!cpu->unplug || cpu_can_run(cpu));
-
- qemu_kvm_destroy_vcpu(cpu);
- cpu_thread_signal_destroyed(cpu);
- qemu_mutex_unlock_iothread();
- rcu_unregister_thread();
- return NULL;
-}
-
static void *qemu_hax_cpu_thread_fn(void *arg)
{
CPUState *cpu = arg;
@@ -801,19 +739,6 @@ static void qemu_hax_start_vcpu(CPUState *cpu)
#endif
}
-static void qemu_kvm_start_vcpu(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- cpu->thread = g_malloc0(sizeof(QemuThread));
- cpu->halt_cond = g_malloc0(sizeof(QemuCond));
- qemu_cond_init(cpu->halt_cond);
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/KVM",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, qemu_kvm_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
-}
-
static void qemu_hvf_start_vcpu(CPUState *cpu)
{
char thread_name[VCPU_THREAD_NAME_SIZE];
@@ -875,8 +800,6 @@ void qemu_init_vcpu(CPUState *cpu)
if (cpus_accel) {
/* accelerator already implements the CpusAccel interface */
cpus_accel->create_vcpu_thread(cpu);
- } else if (kvm_enabled()) {
- qemu_kvm_start_vcpu(cpu);
} else if (hax_enabled()) {
qemu_hax_start_vcpu(cpu);
} else if (hvf_enabled()) {