kvm: qemu: work around dhclient brokenness
[kvm-userspace.git] / libkvm / kvm-common.h
blob7092085a1a2fdc863601d7fffca7d38d875cddd3
1 /*
2 * This header is for functions & variables that will ONLY be
3 * used inside libkvm.
5 * derived from libkvm.c
7 * Copyright (C) 2006 Qumranet, Inc.
9 * Authors:
10 * Avi Kivity <avi@qumranet.com>
11 * Yaniv Kamay <yaniv@qumranet.com>
13 * This work is licensed under the GNU LGPL license, version 2.
16 #ifndef KVM_COMMON_H
17 #define KVM_COMMON_H
19 /* FIXME: share this number with kvm */
20 /* FIXME: or dynamically alloc/realloc regions */
21 #ifndef __s390__
22 #define KVM_MAX_NUM_MEM_REGIONS 8u
23 #define MAX_VCPUS 16
24 #else
25 #define KVM_MAX_NUM_MEM_REGIONS 1u
26 #define MAX_VCPUS 64
27 #define LIBKVM_S390_ORIGIN (0UL)
28 #endif
31 /* kvm abi verison variable */
32 extern int kvm_abi;
34 /**
35 * \brief The KVM context
37 * The verbose KVM context
40 struct kvm_context {
41 /// Filedescriptor to /dev/kvm
42 int fd;
43 int vm_fd;
44 int vcpu_fd[MAX_VCPUS];
45 struct kvm_run *run[MAX_VCPUS];
46 /// Callbacks that KVM uses to emulate various unvirtualizable functionality
47 struct kvm_callbacks *callbacks;
48 void *opaque;
49 /// is dirty pages logging enabled for all regions or not
50 int dirty_pages_log_all;
51 /// do not create in-kernel irqchip if set
52 int no_irqchip_creation;
53 /// in-kernel irqchip status
54 int irqchip_in_kernel;
55 /// do not create in-kernel pit if set
56 int no_pit_creation;
57 /// in-kernel pit status
58 int pit_in_kernel;
59 /// in-kernel coalesced mmio
60 int coalesced_mmio;
63 void init_slots(void);
64 int get_free_slot(kvm_context_t kvm);
65 void register_slot(int slot, unsigned long phys_addr, unsigned long len,
66 int user_alloc, unsigned long userspace_addr, unsigned flags);
68 void free_slot(int slot);
69 int get_slot(unsigned long phys_addr);
71 int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory,
72 void **vm_mem);
73 int kvm_alloc_userspace_memory(kvm_context_t kvm, unsigned long memory,
74 void **vm_mem);
75 void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
76 unsigned long len, int log, int writable);
79 int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
80 void **vm_mem);
81 int kvm_arch_create_default_phys_mem(kvm_context_t kvm,
82 unsigned long phys_mem_bytes,
83 void **vm_mem);
84 int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu);
87 void kvm_show_code(kvm_context_t kvm, int vcpu);
89 int handle_halt(kvm_context_t kvm, int vcpu);
90 int handle_shutdown(kvm_context_t kvm, int vcpu);
91 void post_kvm_run(kvm_context_t kvm, int vcpu);
92 int pre_kvm_run(kvm_context_t kvm, int vcpu);
93 int handle_io_window(kvm_context_t kvm);
94 int handle_debug(kvm_context_t kvm, int vcpu);
95 int try_push_interrupts(kvm_context_t kvm);
97 #endif