From 0b69bdefc1132b5e9130d26ecfba0caa5f47c1f2 Mon Sep 17 00:00:00 2001 From: Matt Evans Date: Fri, 9 Dec 2011 17:54:11 +1100 Subject: [PATCH] kvm tools: Add kvm__arch_periodic_poll() Currently, the SIGALRM handler calls device poll functions (for serial, virtio console) directly. Which devices are present and which require polling is a system-specific decision, so create a new function called from common code & move the x86-specific poll calls into it. Signed-off-by: Matt Evans Signed-off-by: Pekka Enberg --- builtin-run.c | 3 +-- include/kvm/kvm.h | 1 + x86/kvm.c | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/builtin-run.c b/builtin-run.c index e273398..47a2f09 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -522,8 +522,7 @@ static void handle_debug(int fd, u32 type, u32 len, u8 *msg) static void handle_sigalrm(int sig) { - serial8250__inject_interrupt(kvm); - virtio_console__inject_interrupt(kvm); + kvm__arch_periodic_poll(kvm); } static void handle_stop(int fd, u32 type, u32 len, u8 *msg) diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index ca1acc0..60842d5 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -56,6 +56,7 @@ void kvm__remove_socket(const char *name); void kvm__arch_init(struct kvm *kvm, const char *kvm_dev, u64 ram_size, const char *name); void kvm__arch_setup_firmware(struct kvm *kvm); bool kvm__arch_cpu_supports_vm(void); +void kvm__arch_periodic_poll(struct kvm *kvm); int load_flat_binary(struct kvm *kvm, int fd); bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline, u16 vidmode); diff --git a/x86/kvm.c b/x86/kvm.c index ac6c91e..70df27e 100644 --- a/x86/kvm.c +++ b/x86/kvm.c @@ -4,6 +4,8 @@ #include "kvm/interrupt.h" #include "kvm/mptable.h" #include "kvm/util.h" +#include "kvm/8250-serial.h" +#include "kvm/virtio-console.h" #include #include @@ -328,3 +330,9 @@ void kvm__arch_setup_firmware(struct kvm *kvm) /* MP table */ mptable_setup(kvm, kvm->nrcpus); } + +void kvm__arch_periodic_poll(struct kvm *kvm) +{ + serial8250__inject_interrupt(kvm); + virtio_console__inject_interrupt(kvm); +}