summaryrefslogtreecommitdiff
path: root/libkvm
diff options
context:
space:
mode:
Diffstat (limited to 'libkvm')
-rw-r--r--libkvm/kvm-common.h2
-rw-r--r--libkvm/libkvm.c18
-rw-r--r--libkvm/libkvm.h9
3 files changed, 21 insertions, 8 deletions
diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h
index 9dae17b4..c5beacc3 100644
--- a/libkvm/kvm-common.h
+++ b/libkvm/kvm-common.h
@@ -88,7 +88,7 @@ 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, void *env);
+int handle_debug(kvm_context_t kvm, int vcpu, void *env);
int try_push_interrupts(kvm_context_t kvm);
#endif
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index ede64178..9d3139e9 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -738,9 +738,15 @@ static int handle_io(kvm_context_t kvm, struct kvm_run *run, int vcpu)
return 0;
}
-int handle_debug(kvm_context_t kvm, void *env)
+int handle_debug(kvm_context_t kvm, int vcpu, void *env)
{
- return kvm->callbacks->debug(kvm->opaque, env);
+#ifdef KVM_CAP_SET_GUEST_DEBUG
+ struct kvm_run *run = kvm->run[vcpu];
+
+ return kvm->callbacks->debug(kvm->opaque, env, &run->debug.arch);
+#else
+ return 0;
+#endif
}
int kvm_get_regs(kvm_context_t kvm, int vcpu, struct kvm_regs *regs)
@@ -937,7 +943,7 @@ again:
r = handle_io(kvm, run, vcpu);
break;
case KVM_EXIT_DEBUG:
- r = handle_debug(kvm, env);
+ r = handle_debug(kvm, vcpu, env);
break;
case KVM_EXIT_MMIO:
r = handle_mmio(kvm, run);
@@ -982,10 +988,12 @@ int kvm_inject_irq(kvm_context_t kvm, int vcpu, unsigned irq)
return ioctl(kvm->vcpu_fd[vcpu], KVM_INTERRUPT, &intr);
}
-int kvm_guest_debug(kvm_context_t kvm, int vcpu, struct kvm_debug_guest *dbg)
+#ifdef KVM_CAP_SET_GUEST_DEBUG
+int kvm_set_guest_debug(kvm_context_t kvm, int vcpu, struct kvm_guest_debug *dbg)
{
- return ioctl(kvm->vcpu_fd[vcpu], KVM_DEBUG_GUEST, dbg);
+ return ioctl(kvm->vcpu_fd[vcpu], KVM_SET_GUEST_DEBUG, dbg);
}
+#endif
int kvm_set_signal_mask(kvm_context_t kvm, int vcpu, const sigset_t *sigset)
{
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index 392065ba..d068fb31 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -55,7 +55,10 @@ 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, void *env);
+#ifdef KVM_CAP_SET_GUEST_DEBUG
+ int (*debug)(void *opaque, void *env,
+ struct kvm_debug_exit_arch *arch_info);
+#endif
/*!
* \brief Called when the VCPU issues an 'hlt' instruction.
*
@@ -350,7 +353,9 @@ static inline int kvm_reset_mpstate(kvm_context_t kvm, int vcpu)
*/
int kvm_inject_irq(kvm_context_t kvm, int vcpu, unsigned irq);
-int kvm_guest_debug(kvm_context_t, int vcpu, struct kvm_debug_guest *dbg);
+#ifdef KVM_CAP_SET_GUEST_DEBUG
+int kvm_set_guest_debug(kvm_context_t, int vcpu, struct kvm_guest_debug *dbg);
+#endif
#if defined(__i386__) || defined(__x86_64__)
/*!