Use signalfd() in io-thread
[qemu-kvm/fedora.git] / qemu-kvm.h
blobdf573ecfaeff49036c3a6133b0d9e9bc6345e4bb
1 /*
2 * qemu/kvm integration
4 * Copyright (C) 2006-2008 Qumranet Technologies
6 * Licensed under the terms of the GNU GPL version 2 or higher.
7 */
8 #ifndef QEMU_KVM_H
9 #define QEMU_KVM_H
11 #include "cpu.h"
13 #include <signal.h>
15 #include <signal.h>
17 int kvm_main_loop(void);
18 int kvm_qemu_init(void);
19 int kvm_qemu_create_context(void);
20 void kvm_init_new_ap(int cpu, CPUState *env);
21 int kvm_init_ap(void);
22 void kvm_qemu_destroy(void);
23 void kvm_load_registers(CPUState *env);
24 void kvm_save_registers(CPUState *env);
25 void kvm_load_mpstate(CPUState *env);
26 void kvm_save_mpstate(CPUState *env);
27 int kvm_cpu_exec(CPUState *env);
28 int kvm_update_debugger(CPUState *env);
29 int kvm_qemu_init_env(CPUState *env);
30 int kvm_qemu_check_extension(int ext);
31 void kvm_apic_init(CPUState *env);
32 int kvm_set_irq(int irq, int level);
34 int kvm_physical_memory_set_dirty_tracking(int enable);
35 int kvm_update_dirty_pages_log(void);
36 int kvm_get_phys_ram_page_bitmap(unsigned char *bitmap);
38 void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *env);
39 void qemu_kvm_cpuid_on_env(CPUState *env);
40 void kvm_update_after_sipi(CPUState *env);
41 void kvm_update_interrupt_request(CPUState *env);
42 void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
43 unsigned long size,
44 unsigned long phys_offset);
45 void *kvm_cpu_create_phys_mem(target_phys_addr_t start_addr,
46 unsigned long size, int log, int writable);
48 void kvm_cpu_destroy_phys_mem(target_phys_addr_t start_addr,
49 unsigned long size);
51 int kvm_arch_qemu_create_context(void);
53 void kvm_arch_save_regs(CPUState *env);
54 void kvm_arch_load_regs(CPUState *env);
55 int kvm_arch_qemu_init_env(CPUState *cenv);
56 int kvm_arch_halt(void *opaque, int vcpu);
57 void kvm_arch_pre_kvm_run(void *opaque, int vcpu);
58 void kvm_arch_post_kvm_run(void *opaque, int vcpu);
59 int kvm_arch_has_work(CPUState *env);
60 int kvm_arch_try_push_interrupts(void *opaque);
61 void kvm_arch_update_regs_for_sipi(CPUState *env);
63 CPUState *qemu_kvm_cpu_env(int index);
65 void qemu_kvm_aio_wait_start(void);
66 void qemu_kvm_aio_wait(void);
67 void qemu_kvm_aio_wait_end(void);
69 void qemu_kvm_notify_work(void);
71 void kvm_tpr_opt_setup();
72 void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write);
73 int handle_tpr_access(void *opaque, int vcpu,
74 uint64_t rip, int is_write);
75 void kvm_tpr_vcpu_start(CPUState *env);
77 int qemu_kvm_get_dirty_pages(unsigned long phys_addr, void *buf);
79 void qemu_kvm_system_reset_request(void);
81 #ifdef TARGET_PPC
82 int handle_powerpc_dcr_read(int vcpu, uint32_t dcrn, uint32_t *data);
83 int handle_powerpc_dcr_write(int vcpu,uint32_t dcrn, uint32_t data);
84 #endif
86 #if !defined(SYS_signalfd)
87 struct signalfd_siginfo {
88 uint32_t ssi_signo;
89 uint8_t pad[124];
91 #else
92 #include <linux/signalfd.h>
93 #endif
95 int kvm_signalfd(const sigset_t *mask);
96 int kvm_eventfd(int *fds);
98 #define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1))
99 #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8)
101 #ifdef USE_KVM
102 #include "libkvm.h"
104 extern int kvm_allowed;
105 extern kvm_context_t kvm_context;
107 #define kvm_enabled() (kvm_allowed)
108 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
109 #define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
110 #else
111 #define kvm_enabled() (0)
112 #define qemu_kvm_irqchip_in_kernel() (0)
113 #define qemu_kvm_pit_in_kernel() (0)
114 #endif
116 void kvm_mutex_unlock(void);
117 void kvm_mutex_lock(void);
119 static inline void kvm_sleep_begin(void)
121 if (kvm_enabled())
122 kvm_mutex_unlock();
125 static inline void kvm_sleep_end(void)
127 if (kvm_enabled())
128 kvm_mutex_lock();
131 int kvm_check_received_signal(void);
133 static inline int kvm_received_signal(void)
135 if (kvm_enabled())
136 return kvm_check_received_signal();
137 return 0;
140 #endif