diff options
author | 2009-10-09 15:03:13 -0300 | |
---|---|---|
committer | 2009-10-13 14:01:06 -0300 | |
commit | c73005d80e8de0a7f29ee632aa3d10fc3f9ea4fb (patch) | |
tree | f6a755468b502d646de9cfc544b639fe0ebc2c3e /qemu-kvm.c | |
parent | remove kvm_context from vcpu structure (diff) | |
download | qemu-kvm-c73005d80e8de0a7f29ee632aa3d10fc3f9ea4fb.tar.gz qemu-kvm-c73005d80e8de0a7f29ee632aa3d10fc3f9ea4fb.tar.bz2 qemu-kvm-c73005d80e8de0a7f29ee632aa3d10fc3f9ea4fb.zip |
Use kvm_run inside CPUState.
There is no need to replicate kvm_run inside vcpu context, since there
is already a field dedicated to that in CPUState. For now, keep both on,
so function can be converted slowly, since a lot of function headers
will be changed to take an env parameter, instead of a vcpu one.
This patch also converts functions that are static to this file as a
first step.
Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'qemu-kvm.c')
-rw-r--r-- | qemu-kvm.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/qemu-kvm.c b/qemu-kvm.c index 199e62031..363f89989 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -459,13 +459,16 @@ kvm_vcpu_context_t kvm_create_vcpu(CPUState *env, int id) fprintf(stderr, "get vcpu mmap size: %m\n"); goto err_fd; } - vcpu_ctx->run = + env->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, vcpu_ctx->fd, 0); - if (vcpu_ctx->run == MAP_FAILED) { + if (env->kvm_run == MAP_FAILED) { fprintf(stderr, "mmap vcpu area: %m\n"); goto err_fd; } + + vcpu_ctx->run = env->kvm_run; + return vcpu_ctx; err_fd: close(vcpu_ctx->fd); @@ -757,9 +760,9 @@ int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip) #endif -static int handle_io(kvm_vcpu_context_t vcpu) +static int handle_io(CPUState *env) { - struct kvm_run *run = vcpu->run; + struct kvm_run *run = env->kvm_run; uint16_t addr = run->io.port; int i; void *p = (void *) run + run->io.data_offset; @@ -809,10 +812,10 @@ static int handle_io(kvm_vcpu_context_t vcpu) return 0; } -int handle_debug(kvm_vcpu_context_t vcpu, void *env) +static int handle_debug(CPUState *env) { #ifdef KVM_CAP_SET_GUEST_DEBUG - struct kvm_run *run = vcpu->run; + struct kvm_run *run = env->kvm_run; return kvm_debug(env, &run->debug.arch); #else @@ -872,10 +875,10 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state) } #endif -static int handle_mmio(kvm_vcpu_context_t vcpu) +static int handle_mmio(CPUState *env) { - unsigned long addr = vcpu->run->mmio.phys_addr; - struct kvm_run *kvm_run = vcpu->run; + unsigned long addr = env->kvm_run->mmio.phys_addr; + struct kvm_run *kvm_run = env->kvm_run; void *data = kvm_run->mmio.data; /* hack: Red Hat 7.1 generates these weird accesses. */ @@ -1001,13 +1004,13 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env) abort(); break; case KVM_EXIT_IO: - r = handle_io(vcpu); + r = handle_io(env); break; case KVM_EXIT_DEBUG: - r = handle_debug(vcpu, env); + r = handle_debug(env); break; case KVM_EXIT_MMIO: - r = handle_mmio(vcpu); + r = handle_mmio(env); break; case KVM_EXIT_HLT: r = kvm_arch_halt(vcpu); |