diff options
author | Jes Sorensen <jes@sgi.com> | 2008-11-13 17:46:21 +0100 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-11-18 16:12:54 +0200 |
commit | c9fc8403d65487386d9f0e9ee20b87bbdb963f24 (patch) | |
tree | 2f7c08c1354194683231b73f6519a6d3ce7637bb /libkvm | |
parent | ee6085b5acf9e359cffe2292a26c2dfd746d609c (diff) |
kvm: libkvm: pass opague cpu state through libkvm instead of int vcpu
Change code to pass around opague pointer to CPUState through libkvm,
avoiding conversion from CPUState to int vcpu and back in the callbacks
into qemu.
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'libkvm')
-rw-r--r-- | libkvm/kvm-common.h | 8 | ||||
-rw-r--r-- | libkvm/libkvm.c | 28 | ||||
-rw-r--r-- | libkvm/libkvm.h | 10 |
3 files changed, 23 insertions, 23 deletions
diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h index da56e22e..9dae17b4 100644 --- a/libkvm/kvm-common.h +++ b/libkvm/kvm-common.h @@ -84,11 +84,11 @@ int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu); void kvm_show_code(kvm_context_t kvm, int vcpu); int handle_halt(kvm_context_t kvm, int vcpu); -int handle_shutdown(kvm_context_t kvm, int vcpu); -void post_kvm_run(kvm_context_t kvm, int vcpu); -int pre_kvm_run(kvm_context_t kvm, int vcpu); +int handle_shutdown(kvm_context_t kvm, void *env); +void post_kvm_run(kvm_context_t kvm, void *env); +int pre_kvm_run(kvm_context_t kvm, void *env); int handle_io_window(kvm_context_t kvm); -int handle_debug(kvm_context_t kvm, int vcpu); +int handle_debug(kvm_context_t kvm, void *env); int try_push_interrupts(kvm_context_t kvm); #endif diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index e7dba8a6..f6948f57 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -738,9 +738,9 @@ static int handle_io(kvm_context_t kvm, struct kvm_run *run, int vcpu) return 0; } -int handle_debug(kvm_context_t kvm, int vcpu) +int handle_debug(kvm_context_t kvm, void *env) { - return kvm->callbacks->debug(kvm->opaque, vcpu); + return kvm->callbacks->debug(kvm->opaque, env); } int kvm_get_regs(kvm_context_t kvm, int vcpu, struct kvm_regs *regs) @@ -822,9 +822,9 @@ int handle_halt(kvm_context_t kvm, int vcpu) return kvm->callbacks->halt(kvm->opaque, vcpu); } -int handle_shutdown(kvm_context_t kvm, int vcpu) +int handle_shutdown(kvm_context_t kvm, void *env) { - return kvm->callbacks->shutdown(kvm->opaque, vcpu); + return kvm->callbacks->shutdown(kvm->opaque, env); } int try_push_interrupts(kvm_context_t kvm) @@ -837,14 +837,14 @@ int try_push_nmi(kvm_context_t kvm) return kvm->callbacks->try_push_nmi(kvm->opaque); } -void post_kvm_run(kvm_context_t kvm, int vcpu) +void post_kvm_run(kvm_context_t kvm, void *env) { - kvm->callbacks->post_kvm_run(kvm->opaque, vcpu); + kvm->callbacks->post_kvm_run(kvm->opaque, env); } -int pre_kvm_run(kvm_context_t kvm, int vcpu) +int pre_kvm_run(kvm_context_t kvm, void *env) { - return kvm->callbacks->pre_kvm_run(kvm->opaque, vcpu); + return kvm->callbacks->pre_kvm_run(kvm->opaque, env); } int kvm_get_interrupt_flag(kvm_context_t kvm, int vcpu) @@ -872,7 +872,7 @@ int kvm_is_ready_for_nmi_injection(kvm_context_t kvm, int vcpu) #endif } -int kvm_run(kvm_context_t kvm, int vcpu) +int kvm_run(kvm_context_t kvm, int vcpu, void *env) { int r; int fd = kvm->vcpu_fd[vcpu]; @@ -886,19 +886,19 @@ again: if (!kvm->irqchip_in_kernel) run->request_interrupt_window = try_push_interrupts(kvm); #endif - r = pre_kvm_run(kvm, vcpu); + r = pre_kvm_run(kvm, env); if (r) return r; r = ioctl(fd, KVM_RUN, 0); if (r == -1 && errno != EINTR && errno != EAGAIN) { r = -errno; - post_kvm_run(kvm, vcpu); + post_kvm_run(kvm, env); fprintf(stderr, "kvm_run: %s\n", strerror(-r)); return r; } - post_kvm_run(kvm, vcpu); + post_kvm_run(kvm, env); #if defined(KVM_CAP_COALESCED_MMIO) if (kvm->coalesced_mmio) { @@ -948,7 +948,7 @@ again: r = handle_io(kvm, run, vcpu); break; case KVM_EXIT_DEBUG: - r = handle_debug(kvm, vcpu); + r = handle_debug(kvm, env); break; case KVM_EXIT_MMIO: r = handle_mmio(kvm, run); @@ -962,7 +962,7 @@ again: #endif break; case KVM_EXIT_SHUTDOWN: - r = handle_shutdown(kvm, vcpu); + r = handle_shutdown(kvm, env); break; #if defined(__s390__) case KVM_EXIT_S390_SIEIC: diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h index 53d67f23..aae9f038 100644 --- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -55,7 +55,7 @@ struct kvm_callbacks { /// generic memory writes to unmapped memory (For MMIO devices) int (*mmio_write)(void *opaque, uint64_t addr, uint8_t *data, int len); - int (*debug)(void *opaque, int vcpu); + int (*debug)(void *opaque, void *env); /*! * \brief Called when the VCPU issues an 'hlt' instruction. * @@ -63,12 +63,12 @@ struct kvm_callbacks { * on the host CPU. */ int (*halt)(void *opaque, int vcpu); - int (*shutdown)(void *opaque, int vcpu); + int (*shutdown)(void *opaque, void *env); int (*io_window)(void *opaque); int (*try_push_interrupts)(void *opaque); int (*try_push_nmi)(void *opaque); - void (*post_kvm_run)(void *opaque, int vcpu); - int (*pre_kvm_run)(void *opaque, int vcpu); + void (*post_kvm_run)(void *opaque, void *env); + int (*pre_kvm_run)(void *opaque, void *env); int (*tpr_access)(void *opaque, int vcpu, uint64_t rip, int is_write); #if defined(__powerpc__) int (*powerpc_dcr_read)(int vcpu, uint32_t dcrn, uint32_t *data); @@ -181,7 +181,7 @@ int kvm_create_vcpu(kvm_context_t kvm, int slot); * return except for when an error has occured, or when you have sent it * an EINTR signal. */ -int kvm_run(kvm_context_t kvm, int vcpu); +int kvm_run(kvm_context_t kvm, int vcpu, void *env); /*! * \brief Get interrupt flag from on last exit to userspace |