direct-io.hg

view tools/libxc/xc.h @ 3762:0a4b76b6b5a0

bitkeeper revision 1.1161 (420b5ed6DpcotfvpA5TTxShadFd_MQ)

Merge with non-ancient version of Xen.
author sos22@douglas.cl.cam.ac.uk
date Thu Feb 10 13:17:10 2005 +0000 (2005-02-10)
parents 1ac7603a60bd bbe8541361dd
children a19f7bbbe144 cfee4c4a8ed6 f7c31440d003
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>
14 typedef uint8_t u8;
15 typedef uint16_t u16;
16 typedef uint32_t u32;
17 typedef uint64_t u64;
18 typedef int8_t s8;
19 typedef int16_t s16;
20 typedef int32_t s32;
21 typedef int64_t s64;
23 #include <xen/xen.h>
24 #include <xen/dom0_ops.h>
25 #include <xen/event_channel.h>
26 #include <xen/sched_ctl.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 u32 vcpu,
146 xc_domaininfo_t *info,
147 full_execution_context_t *ctxt);
148 int xc_domain_setcpuweight(int xc_handle,
149 u32 domid,
150 float weight);
151 long long xc_domain_get_cpu_usage(int xc_handle,
152 domid_t domid,
153 int vcpu);
156 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
157 int xc_shadow_control(int xc_handle,
158 u32 domid,
159 unsigned int sop,
160 unsigned long *dirty_bitmap,
161 unsigned long pages,
162 xc_shadow_control_stats_t *stats);
165 #define XCFLAGS_VERBOSE 1
166 #define XCFLAGS_LIVE 2
167 #define XCFLAGS_DEBUG 4
168 #define XCFLAGS_CONFIGURE 8
170 struct XcIOContext;
172 /**
173 * This function will save a domain running Linux to an IO context. This
174 * IO context is currently a private interface making this function difficult
175 * to call. It's interface will likely change in the future.
176 *
177 * @parm xc_handle a handle to an open hypervisor interface
178 * @parm ioctxt the IO context to save a domain to
179 * @return 0 on success, -1 on failure
180 */
181 int xc_linux_save(int xc_handle, struct XcIOContext *ioctxt);
183 /**
184 * This function will restore a saved domain running Linux to an IO context.
185 * Like xc_linux_save(), this function uses a parameter who's structure is
186 * privately defined. It's interface will also likely change.
187 *
188 * @parm xc_handle a handle to an open hypervisor interface
189 * @parm ioctxt the IO context to restore a domain from
190 * @return 0 on success, -1 on failure
191 */
192 int xc_linux_restore(int xc_handle, struct XcIOContext *ioctxt);
194 int xc_linux_build(int xc_handle,
195 u32 domid,
196 const char *image_name,
197 const char *ramdisk_name,
198 const char *cmdline,
199 unsigned int control_evtchn,
200 unsigned long flags,
201 unsigned int vcpus);
203 int
204 xc_plan9_build (int xc_handle,
205 u32 domid,
206 const char *image_name,
207 const char *cmdline,
208 unsigned int control_evtchn,
209 unsigned long flags);
211 struct mem_map;
212 int xc_vmx_build(int xc_handle,
213 u32 domid,
214 int memsize,
215 const char *image_name,
216 struct mem_map *memmap,
217 const char *ramdisk_name,
218 const char *cmdline,
219 unsigned int control_evtchn,
220 unsigned long flags);
222 int xc_bvtsched_global_set(int xc_handle,
223 unsigned long ctx_allow);
225 int xc_bvtsched_domain_set(int xc_handle,
226 u32 domid,
227 u32 mcuadv,
228 int warpback,
229 s32 warpvalue,
230 long long warpl,
231 long long warpu);
233 int xc_bvtsched_global_get(int xc_handle,
234 unsigned long *ctx_allow);
236 int xc_bvtsched_domain_get(int xc_handle,
237 u32 domid,
238 u32 *mcuadv,
239 int *warpback,
240 s32 *warpvalue,
241 long long *warpl,
242 long long *warpu);
244 int xc_atropos_domain_set(int xc_handle,
245 u32 domid,
246 u64 period, u64 slice, u64 latency,
247 int xtratime);
249 int xc_atropos_domain_get(int xc_handle,
250 u32 domid,
251 u64* period, u64 *slice, u64 *latency,
252 int *xtratime);
254 int xc_rrobin_global_set(int xc_handle, u64 slice);
256 int xc_rrobin_global_get(int xc_handle, u64 *slice);
258 typedef evtchn_status_t xc_evtchn_status_t;
260 /*\
261 * EVENT CHANNEL FUNCTIONS
262 \*/
264 /**
265 * This function allocates an unbound port. Ports are named endpoints used for
266 * interdomain communication. This function is most useful in opening a
267 * well-known port within a domain to receive events on.
268 *
269 * @parm xc_handle a handle to an open hypervisor interface
270 * @parm dom the ID of the domain. This maybe DOMID_SELF
271 * @parm port a pointer to a port. This is an in/out parameter. If *port is
272 * 0, then a new port will be assigned, if port is > 0 then that
273 * port is allocated if the port is unallocated.
274 * @return 0 on success, -1 on failure
275 */
276 int xc_evtchn_alloc_unbound(int xc_handle,
277 u32 dom,
278 int *port);
280 /**
281 * This function creates a pair of ports between two domains. A port can only
282 * be bound once within a domain.
283 *
284 * @parm xc_handle a handle to an open hypervisor interface
285 * @parm dom1 one of the two domains to connect. Can be DOMID_SELF.
286 * @parm dom2 the other domain to connect. Can be DOMID_SELF.
287 * @parm port1 an in/out parameter. If > 0, then try to connect *port. If
288 * 0, then allocate a new port and store the port in *port.
289 * @parm port2 the port connected on port2. This parameter behaves the same
290 * way as port1.
291 * @return 0 on success, -1 on error.
292 */
293 int xc_evtchn_bind_interdomain(int xc_handle,
294 u32 dom1,
295 u32 dom2,
296 int *port1,
297 int *port2);
298 int xc_evtchn_bind_virq(int xc_handle,
299 int virq,
300 int *port);
302 /**
303 * This function will close a single port on an event channel.
304 *
305 * @parm xc_handle a handle to an open hypervisor interface
306 * @parm dom the domain that the port exists on. May be DOMID_SELF.
307 * @parm port the port to close
308 * @return 0 on success, -1 on error
309 */
310 int xc_evtchn_close(int xc_handle,
311 u32 dom, /* may be DOMID_SELF */
312 int port);
314 /**
315 * This function generates a notify event on a bound port.
316 *
317 * Notifies can be read within Linux by opening /dev/xen/evtchn and reading
318 * a 16 bit value. The result will be the port the event occurred on. When
319 * events occur, the port is masked until the 16 bit port value is written back
320 * to the file. When /dev/xen/evtchn is opened, it has to be bound via an
321 * ioctl to each port to listen on. The ioctl for binding is _IO('E', 2). The
322 * parameter is the port to listen on.
323 *
324 * @parm xc_handle a handle to an open hypervisor interface
325 * @parm local_port the port to generate the notify on
326 * @return 0 on success, -1 on error
327 */
328 int xc_evtchn_send(int xc_handle,
329 int local_port);
330 int xc_evtchn_status(int xc_handle,
331 u32 dom, /* may be DOMID_SELF */
332 int port,
333 xc_evtchn_status_t *status);
335 int xc_physdev_pci_access_modify(int xc_handle,
336 u32 domid,
337 int bus,
338 int dev,
339 int func,
340 int enable);
342 int xc_readconsolering(int xc_handle,
343 char *str,
344 unsigned int max_chars,
345 int clear);
347 typedef dom0_physinfo_t xc_physinfo_t;
348 int xc_physinfo(int xc_handle,
349 xc_physinfo_t *info);
351 int xc_sched_id(int xc_handle,
352 int *sched_id);
354 int xc_domain_setinitialmem(int xc_handle,
355 u32 domid,
356 unsigned int initial_memkb);
358 int xc_domain_setmaxmem(int xc_handle,
359 u32 domid,
360 unsigned int max_memkb);
362 int xc_domain_setvmassist(int xc_handle,
363 u32 domid,
364 unsigned int cmd,
365 unsigned int type);
367 typedef dom0_perfc_desc_t xc_perfc_desc_t;
368 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
369 int xc_perfc_control(int xc_handle,
370 u32 op,
371 xc_perfc_desc_t *desc);
373 /**
374 * Memory maps a range within one domain to a local address range. Mappings
375 * should be unmapped with munmap and should follow the same rules as mmap
376 * regarding page alignment.
377 *
378 * In Linux, the ring queue for the control channel is accessible by mapping
379 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
380 * stored there is of type control_if_t.
381 *
382 * @parm xc_handle a handle on an open hypervisor interface
383 * @parm dom the domain to map memory from
384 * @parm size the amount of memory to map (in multiples of page size)
385 * @parm prot same flag as in mmap().
386 * @parm mfn the frame address to map.
387 */
388 void *xc_map_foreign_range(int xc_handle, u32 dom,
389 int size, int prot,
390 unsigned long mfn );
392 void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot,
393 unsigned long *arr, int num );
395 int xc_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf,
396 unsigned long max_pfns);
398 #endif /* __XC_H__ */