]> git.proxmox.com Git - mirror_qemu.git/blame - hw/xen_common.h
Merge remote-tracking branch 'aneesh/for-upstream' into staging
[mirror_qemu.git] / hw / xen_common.h
CommitLineData
d94f9486
AL
1#ifndef QEMU_HW_XEN_COMMON_H
2#define QEMU_HW_XEN_COMMON_H 1
3
d5b93ddf
AP
4#include "config-host.h"
5
d94f9486
AL
6#include <stddef.h>
7#include <inttypes.h>
8
9#include <xenctrl.h>
e108a3c1
AP
10#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 420
11# include <xs.h>
12#else
13# include <xenstore.h>
14#endif
d94f9486
AL
15#include <xen/io/xenbus.h>
16
17#include "hw.h"
18#include "xen.h"
d8becc35 19#include "qemu-queue.h"
d94f9486
AL
20
21/*
d5b93ddf 22 * We don't support Xen prior to 3.3.0.
d94f9486 23 */
d5b93ddf
AP
24
25/* Xen before 4.0 */
26#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 400
27static inline void *xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot,
28 xen_pfn_t *arr, int *err,
29 unsigned int num)
30{
31 return xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
32}
d94f9486 33#endif
d5b93ddf
AP
34
35
36/* Xen before 4.1 */
37#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 410
38
39typedef int XenXC;
40typedef int XenEvtchn;
41typedef int XenGnttab;
42
43# define XC_INTERFACE_FMT "%i"
44# define XC_HANDLER_INITIAL_VALUE -1
45
46static inline XenEvtchn xen_xc_evtchn_open(void *logger,
47 unsigned int open_flags)
48{
49 return xc_evtchn_open();
50}
51
52static inline XenGnttab xen_xc_gnttab_open(void *logger,
53 unsigned int open_flags)
54{
55 return xc_gnttab_open();
56}
57
58static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger,
59 unsigned int open_flags)
60{
61 return xc_interface_open();
62}
63
64static inline int xc_fd(int xen_xc)
65{
66 return xen_xc;
67}
68
69
432d268c
JN
70static inline int xc_domain_populate_physmap_exact
71 (XenXC xc_handle, uint32_t domid, unsigned long nr_extents,
72 unsigned int extent_order, unsigned int mem_flags, xen_pfn_t *extent_start)
73{
74 return xc_domain_memory_populate_physmap
75 (xc_handle, domid, nr_extents, extent_order, mem_flags, extent_start);
76}
77
b87de24e
AP
78static inline int xc_domain_add_to_physmap(int xc_handle, uint32_t domid,
79 unsigned int space, unsigned long idx,
80 xen_pfn_t gpfn)
81{
82 struct xen_add_to_physmap xatp = {
83 .domid = domid,
84 .space = space,
85 .idx = idx,
86 .gpfn = gpfn,
87 };
88
89 return xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp);
90}
91
0f51726a
SS
92static inline struct xs_handle *xs_open(unsigned long flags)
93{
94 return xs_daemon_open();
95}
96
97static inline void xs_close(struct xs_handle *xsh)
98{
99 if (xsh != NULL) {
100 xs_daemon_close(xsh);
101 }
102}
103
432d268c 104
d5b93ddf
AP
105/* Xen 4.1 */
106#else
107
108typedef xc_interface *XenXC;
109typedef xc_evtchn *XenEvtchn;
110typedef xc_gnttab *XenGnttab;
111
112# define XC_INTERFACE_FMT "%p"
113# define XC_HANDLER_INITIAL_VALUE NULL
114
115static inline XenEvtchn xen_xc_evtchn_open(void *logger,
116 unsigned int open_flags)
117{
118 return xc_evtchn_open(logger, open_flags);
119}
120
121static inline XenGnttab xen_xc_gnttab_open(void *logger,
122 unsigned int open_flags)
123{
124 return xc_gnttab_open(logger, open_flags);
125}
126
127static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger,
128 unsigned int open_flags)
129{
130 return xc_interface_open(logger, dombuild_logger, open_flags);
131}
132
133/* FIXME There is now way to have the xen fd */
134static inline int xc_fd(xc_interface *xen_xc)
135{
136 return -1;
137}
d94f9486
AL
138#endif
139
4c9f8d1b
SS
140/* Xen before 4.2 */
141#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 420
142static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
143 uint64_t addr, uint32_t data)
144{
145 return -ENOSYS;
146}
147#else
148static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
149 uint64_t addr, uint32_t data)
150{
151 return xc_hvm_inject_msi(xen_xc, dom, addr, data);
152}
153#endif
154
180640ea 155void destroy_hvm_domain(bool reboot);
9ce94e7c 156
eaab4d60
AK
157/* shutdown/destroy current domain because of an error */
158void xen_shutdown_fatal_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
159
d94f9486 160#endif /* QEMU_HW_XEN_COMMON_H */