direct-io.hg

view tools/libxc/xc.h @ 3450:f8e1f285e41f

bitkeeper revision 1.1159.170.101 (41ebbffd4FxrNM4pQF5Ip7nRjrUUjg)

Merge font.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-2.0-testing.bk
into font.cl.cam.ac.uk:/local/scratch/sd386/xen-2.0-testing.bk
author sd386@font.cl.cam.ac.uk
date Mon Jan 17 13:39:09 2005 +0000 (2005-01-17)
parents 6d86ef2aeb06 52e7357311c2
children 3dc193a9786a
line source
1 /******************************************************************************
2 * xc.h
3 *
4 * A library for low-level access to the Xen control interfaces.
5 *
6 * Copyright (c) 2003-2004, K A Fraser.
7 */
9 #ifndef __XC_H__
10 #define __XC_H__
12 #include <stdint.h>
13 typedef uint8_t u8;
14 typedef uint16_t u16;
15 typedef uint32_t u32;
16 typedef uint64_t u64;
17 typedef int8_t s8;
18 typedef int16_t s16;
19 typedef int32_t s32;
20 typedef int64_t s64;
22 #include <xen/xen.h>
23 #include <xen/dom0_ops.h>
24 #include <xen/event_channel.h>
25 #include <xen/sched_ctl.h>
26 #include <xen/io/domain_controller.h>
28 /*\
29 * INITIALIZATION FUNCTIONS
30 \*/
32 /**
33 * This function opens a handle to the hypervisor interface. This function can
34 * be called multiple times within a single process. Multiple processes can
35 * have an open hypervisor interface at the same time.
36 *
37 * Each call to this function should have a corresponding call to
38 * xc_interface_close().
39 *
40 * This function can fail if the caller does not have superuser permission or
41 * if a Xen-enabled kernel is not currently running.
42 *
43 * @return a handle to the hypervisor interface or -1 on failure
44 */
45 int xc_interface_open(void);
47 /**
48 * This function closes an open hypervisor interface.
49 *
50 * This function can fail if the handle does not represent an open interface or
51 * if there were problems closing the interface.
52 *
53 * @parm xc_handle a handle to an open hypervisor interface
54 * @return 0 on success, -1 otherwise.
55 */
56 int xc_interface_close(int xc_handle);
58 /*\
59 * DOMAIN MANAGEMENT FUNCTIONS
60 \*/
62 typedef struct {
63 u32 domid;
64 unsigned int cpu;
65 unsigned int dying:1, crashed:1, shutdown:1,
66 paused:1, blocked:1, running:1;
67 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
68 unsigned long nr_pages;
69 unsigned long shared_info_frame;
70 u64 cpu_time;
71 unsigned long max_memkb;
72 } xc_dominfo_t;
74 typedef dom0_getdomaininfo_t xc_domaininfo_t;
75 int xc_domain_create(int xc_handle,
76 unsigned int mem_kb,
77 int cpu,
78 float cpu_weight,
79 u32 *pdomid);
81 /**
82 * This function pauses a domain. A paused domain still exists in memory
83 * however it does not receive any timeslices from the hypervisor.
84 *
85 * @parm xc_handle a handle to an open hypervisor interface
86 * @parm domid the domain id to pause
87 * @return 0 on success, -1 on failure.
88 */
89 int xc_domain_pause(int xc_handle,
90 u32 domid);
91 /**
92 * This function unpauses a domain. The domain should have been previously
93 * paused.
94 *
95 * @parm xc_handle a handle to an open hypervisor interface
96 * @parm domid the domain id to unpause
97 * return 0 on success, -1 on failure
98 */
99 int xc_domain_unpause(int xc_handle,
100 u32 domid);
102 /**
103 * This function will destroy a domain. Destroying a domain removes the domain
104 * completely from memory. This function should be called after sending the
105 * domain a SHUTDOWN control message to free up the domain resources.
106 *
107 * @parm xc_handle a handle to an open hypervisor interface
108 * @parm domid the domain id to destroy
109 * @return 0 on success, -1 on failure
110 */
111 int xc_domain_destroy(int xc_handle,
112 u32 domid);
113 int xc_domain_pincpu(int xc_handle,
114 u32 domid,
115 int cpu);
116 /**
117 * This function will return information about one or more domains.
118 *
119 * @parm xc_handle a handle to an open hypervisor interface
120 * @parm first_domid the first domain to enumerate information from. Domains
121 * are currently enumerate in order of creation.
122 * @parm max_doms the number of elements in info
123 * @parm info an array of max_doms size that will contain the information for
124 * the enumerated domains.
125 * @return the number of domains enumerated or -1 on error
126 */
127 int xc_domain_getinfo(int xc_handle,
128 u32 first_domid,
129 unsigned int max_doms,
130 xc_dominfo_t *info);
132 /**
133 * This function returns information about one domain. This information is
134 * more detailed than the information from xc_domain_getinfo().
135 *
136 * @parm xc_handle a handle to an open hypervisor interface
137 * @parm domid the domain to get information from
138 * @parm info a pointer to an xc_domaininfo_t to store the domain information
139 * @parm ctxt a pointer to a structure to store the execution context of the
140 * domain
141 * @return 0 on success, -1 on failure
142 */
143 int xc_domain_getfullinfo(int xc_handle,
144 u32 domid,
145 xc_domaininfo_t *info,
146 full_execution_context_t *ctxt);
147 int xc_domain_setcpuweight(int xc_handle,
148 u32 domid,
149 float weight);
150 long long xc_domain_get_cpu_usage(int xc_handle,
151 domid_t domid);
154 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
155 int xc_shadow_control(int xc_handle,
156 u32 domid,
157 unsigned int sop,
158 unsigned long *dirty_bitmap,
159 unsigned long pages,
160 xc_shadow_control_stats_t *stats);
163 #define XCFLAGS_VERBOSE 1
164 #define XCFLAGS_LIVE 2
165 #define XCFLAGS_DEBUG 4
166 #define XCFLAGS_CONFIGURE 8
168 struct XcIOContext;
170 /**
171 * This function will save a domain running Linux to an IO context. This
172 * IO context is currently a private interface making this function difficult
173 * to call. It's interface will likely change in the future.
174 *
175 * @parm xc_handle a handle to an open hypervisor interface
176 * @parm ioctxt the IO context to save a domain to
177 * @return 0 on success, -1 on failure
178 */
179 int xc_linux_save(int xc_handle, struct XcIOContext *ioctxt);
181 /**
182 * This function will restore a saved domain running Linux to an IO context.
183 * Like xc_linux_save(), this function uses a parameter who's structure is
184 * privately defined. It's interface will also likely change.
185 *
186 * @parm xc_handle a handle to an open hypervisor interface
187 * @parm ioctxt the IO context to restore a domain from
188 * @return 0 on success, -1 on failure
189 */
190 int xc_linux_restore(int xc_handle, struct XcIOContext *ioctxt);
192 int xc_linux_build(int xc_handle,
193 u32 domid,
194 const char *image_name,
195 const char *ramdisk_name,
196 const char *cmdline,
197 unsigned int control_evtchn,
198 unsigned long flags);
200 int
201 xc_plan9_build (int xc_handle,
202 u32 domid,
203 const char *image_name,
204 const char *cmdline,
205 unsigned int control_evtchn,
206 unsigned long flags);
208 int xc_bvtsched_global_set(int xc_handle,
209 unsigned long ctx_allow);
211 int xc_bvtsched_domain_set(int xc_handle,
212 u32 domid,
213 u32 mcuadv,
214 int warpback,
215 s32 warpvalue,
216 long long warpl,
217 long long warpu);
219 int xc_bvtsched_global_get(int xc_handle,
220 unsigned long *ctx_allow);
222 int xc_bvtsched_domain_get(int xc_handle,
223 u32 domid,
224 u32 *mcuadv,
225 int *warpback,
226 s32 *warpvalue,
227 long long *warpl,
228 long long *warpu);
230 int xc_atropos_domain_set(int xc_handle,
231 u32 domid,
232 u64 period, u64 slice, u64 latency,
233 int xtratime);
235 int xc_atropos_domain_get(int xc_handle,
236 u32 domid,
237 u64* period, u64 *slice, u64 *latency,
238 int *xtratime);
240 int xc_rrobin_global_set(int xc_handle, u64 slice);
242 int xc_rrobin_global_get(int xc_handle, u64 *slice);
244 int xc_sedf_domain_set(int xc_handle,
245 u32 domid,
246 u64 period, u64 slice);
248 int xc_sedf_domain_get(int xc_handle,
249 u32 domid,
250 u64* period, u64 *slice);
252 typedef evtchn_status_t xc_evtchn_status_t;
254 /*\
255 * EVENT CHANNEL FUNCTIONS
256 \*/
258 /**
259 * This function allocates an unbound port. Ports are named endpoints used for
260 * interdomain communication. This function is most useful in opening a
261 * well-known port within a domain to receive events on.
262 *
263 * @parm xc_handle a handle to an open hypervisor interface
264 * @parm dom the ID of the domain. This maybe DOMID_SELF
265 * @parm port a pointer to a port. This is an in/out parameter. If *port is
266 * 0, then a new port will be assigned, if port is > 0 then that
267 * port is allocated if the port is unallocated.
268 * @return 0 on success, -1 on failure
269 */
270 int xc_evtchn_alloc_unbound(int xc_handle,
271 u32 dom,
272 int *port);
274 /**
275 * This function creates a pair of ports between two domains. A port can only
276 * be bound once within a domain.
277 *
278 * @parm xc_handle a handle to an open hypervisor interface
279 * @parm dom1 one of the two domains to connect. Can be DOMID_SELF.
280 * @parm dom2 the other domain to connect. Can be DOMID_SELF.
281 * @parm port1 an in/out parameter. If > 0, then try to connect *port. If
282 * 0, then allocate a new port and store the port in *port.
283 * @parm port2 the port connected on port2. This parameter behaves the same
284 * way as port1.
285 * @return 0 on success, -1 on error.
286 */
287 int xc_evtchn_bind_interdomain(int xc_handle,
288 u32 dom1,
289 u32 dom2,
290 int *port1,
291 int *port2);
292 int xc_evtchn_bind_virq(int xc_handle,
293 int virq,
294 int *port);
296 /**
297 * This function will close a single port on an event channel.
298 *
299 * @parm xc_handle a handle to an open hypervisor interface
300 * @parm dom the domain that the port exists on. May be DOMID_SELF.
301 * @parm port the port to close
302 * @return 0 on success, -1 on error
303 */
304 int xc_evtchn_close(int xc_handle,
305 u32 dom, /* may be DOMID_SELF */
306 int port);
308 /**
309 * This function generates a notify event on a bound port.
310 *
311 * Notifies can be read within Linux by opening /dev/xen/evtchn and reading
312 * a 16 bit value. The result will be the port the event occurred on. When
313 * events occur, the port is masked until the 16 bit port value is written back
314 * to the file. When /dev/xen/evtchn is opened, it has to be bound via an
315 * ioctl to each port to listen on. The ioctl for binding is _IO('E', 2). The
316 * parameter is the port to listen on.
317 *
318 * @parm xc_handle a handle to an open hypervisor interface
319 * @parm local_port the port to generate the notify on
320 * @return 0 on success, -1 on error
321 */
322 int xc_evtchn_send(int xc_handle,
323 int local_port);
324 int xc_evtchn_status(int xc_handle,
325 u32 dom, /* may be DOMID_SELF */
326 int port,
327 xc_evtchn_status_t *status);
329 int xc_physdev_pci_access_modify(int xc_handle,
330 u32 domid,
331 int bus,
332 int dev,
333 int func,
334 int enable);
336 int xc_readconsolering(int xc_handle,
337 char *str,
338 unsigned int max_chars,
339 int clear);
341 typedef dom0_physinfo_t xc_physinfo_t;
342 int xc_physinfo(int xc_handle,
343 xc_physinfo_t *info);
345 int xc_sched_id(int xc_handle,
346 int *sched_id);
348 int xc_domain_setinitialmem(int xc_handle,
349 u32 domid,
350 unsigned int initial_memkb);
352 int xc_domain_setmaxmem(int xc_handle,
353 u32 domid,
354 unsigned int max_memkb);
356 int xc_domain_setvmassist(int xc_handle,
357 u32 domid,
358 unsigned int cmd,
359 unsigned int type);
361 typedef dom0_perfc_desc_t xc_perfc_desc_t;
362 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
363 int xc_perfc_control(int xc_handle,
364 u32 op,
365 xc_perfc_desc_t *desc);
367 /**
368 * Memory maps a range within one domain to a local address range. Mappings
369 * should be unmapped with munmap and should follow the same rules as mmap
370 * regarding page alignment.
371 *
372 * In Linux, the ring queue for the control channel is accessible by mapping
373 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
374 * stored there is of type control_if_t.
375 *
376 * @parm xc_handle a handle on an open hypervisor interface
377 * @parm dom the domain to map memory from
378 * @parm size the amount of memory to map (in multiples of page size)
379 * @parm prot same flag as in mmap().
380 * @parm mfn the frame address to map.
381 */
382 void *xc_map_foreign_range(int xc_handle, u32 dom,
383 int size, int prot,
384 unsigned long mfn );
386 void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot,
387 unsigned long *arr, int num );
389 #endif /* __XC_H__ */