direct-io.hg

view tools/libxc/xc.h @ 5541:908cc62958b4

bitkeeper revision 1.1726.2.1 (42ba6dcaSODxvHIftq9c1t2jDb4htA)

Include ACM header file in libxc header file.
author kaf24@firebug.cl.cam.ac.uk
date Thu Jun 23 08:07:38 2005 +0000 (2005-06-23)
parents 649cd37aa1ab
children 76346519b28e
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 <sys/ptrace.h>
24 #include <xen/xen.h>
25 #include <xen/dom0_ops.h>
26 #include <xen/event_channel.h>
27 #include <xen/sched_ctl.h>
28 #include <xen/acm.h>
30 /*
31 * DEFINITIONS FOR CPU BARRIERS
32 */
34 #if defined(__i386__)
35 #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
36 #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
37 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
38 #elif defined(__x86_64__)
39 #define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
40 #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
41 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
42 #else
43 #error "Define barriers"
44 #endif
46 /*
47 * INITIALIZATION FUNCTIONS
48 */
50 /**
51 * This function opens a handle to the hypervisor interface. This function can
52 * be called multiple times within a single process. Multiple processes can
53 * have an open hypervisor interface at the same time.
54 *
55 * Each call to this function should have a corresponding call to
56 * xc_interface_close().
57 *
58 * This function can fail if the caller does not have superuser permission or
59 * if a Xen-enabled kernel is not currently running.
60 *
61 * @return a handle to the hypervisor interface or -1 on failure
62 */
63 int xc_interface_open(void);
65 /**
66 * This function closes an open hypervisor interface.
67 *
68 * This function can fail if the handle does not represent an open interface or
69 * if there were problems closing the interface.
70 *
71 * @parm xc_handle a handle to an open hypervisor interface
72 * @return 0 on success, -1 otherwise.
73 */
74 int xc_interface_close(int xc_handle);
76 /*
77 * DOMAIN DEBUGGING FUNCTIONS
78 */
80 typedef struct xc_core_header {
81 unsigned int xch_magic;
82 unsigned int xch_nr_vcpus;
83 unsigned int xch_nr_pages;
84 unsigned int xch_ctxt_offset;
85 unsigned int xch_index_offset;
86 unsigned int xch_pages_offset;
87 } xc_core_header_t;
90 long xc_ptrace(enum __ptrace_request request,
91 u32 domid,
92 long addr,
93 long data);
95 long xc_ptrace_core(enum __ptrace_request request,
96 u32 domid,
97 long addr,
98 long data);
100 int xc_waitdomain(int domain,
101 int *status,
102 int options);
104 int xc_waitdomain_core(int domain,
105 int *status,
106 int options);
108 /*
109 * DOMAIN MANAGEMENT FUNCTIONS
110 */
112 typedef struct {
113 u32 domid;
114 u32 ssidref;
115 unsigned int dying:1, crashed:1, shutdown:1,
116 paused:1, blocked:1, running:1;
117 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
118 unsigned long nr_pages;
119 unsigned long shared_info_frame;
120 u64 cpu_time;
121 unsigned long max_memkb;
122 unsigned int vcpus;
123 s32 vcpu_to_cpu[MAX_VIRT_CPUS];
124 cpumap_t cpumap[MAX_VIRT_CPUS];
125 } xc_dominfo_t;
127 typedef dom0_getdomaininfo_t xc_domaininfo_t;
128 int xc_domain_create(int xc_handle,
129 u32 ssidref,
130 u32 *pdomid);
133 int xc_domain_dumpcore(int xc_handle,
134 u32 domid,
135 const char *corename);
138 /**
139 * This function pauses a domain. A paused domain still exists in memory
140 * however it does not receive any timeslices from the hypervisor.
141 *
142 * @parm xc_handle a handle to an open hypervisor interface
143 * @parm domid the domain id to pause
144 * @return 0 on success, -1 on failure.
145 */
146 int xc_domain_pause(int xc_handle,
147 u32 domid);
148 /**
149 * This function unpauses a domain. The domain should have been previously
150 * paused.
151 *
152 * @parm xc_handle a handle to an open hypervisor interface
153 * @parm domid the domain id to unpause
154 * return 0 on success, -1 on failure
155 */
156 int xc_domain_unpause(int xc_handle,
157 u32 domid);
159 /**
160 * This function will destroy a domain. Destroying a domain removes the domain
161 * completely from memory. This function should be called after sending the
162 * domain a SHUTDOWN control message to free up the domain resources.
163 *
164 * @parm xc_handle a handle to an open hypervisor interface
165 * @parm domid the domain id to destroy
166 * @return 0 on success, -1 on failure
167 */
168 int xc_domain_destroy(int xc_handle,
169 u32 domid);
170 int xc_domain_pincpu(int xc_handle,
171 u32 domid,
172 int vcpu,
173 cpumap_t *cpumap);
174 /**
175 * This function will return information about one or more domains. It is
176 * designed to iterate over the list of domains. If a single domain is
177 * requested, this function will return the next domain in the list - if
178 * one exists. It is, therefore, important in this case to make sure the
179 * domain requested was the one returned.
180 *
181 * @parm xc_handle a handle to an open hypervisor interface
182 * @parm first_domid the first domain to enumerate information from. Domains
183 * are currently enumerate in order of creation.
184 * @parm max_doms the number of elements in info
185 * @parm info an array of max_doms size that will contain the information for
186 * the enumerated domains.
187 * @return the number of domains enumerated or -1 on error
188 */
189 int xc_domain_getinfo(int xc_handle,
190 u32 first_domid,
191 unsigned int max_doms,
192 xc_dominfo_t *info);
194 /**
195 * This function returns information about one domain. This information is
196 * more detailed than the information from xc_domain_getinfo().
197 *
198 * @parm xc_handle a handle to an open hypervisor interface
199 * @parm domid the domain to get information from
200 * @parm info a pointer to an xc_domaininfo_t to store the domain information
201 * @parm ctxt a pointer to a structure to store the execution context of the
202 * domain
203 * @return 0 on success, -1 on failure
204 */
205 int xc_domain_get_vcpu_context(int xc_handle,
206 u32 domid,
207 u32 vcpu,
208 vcpu_guest_context_t *ctxt);
210 int xc_domain_setcpuweight(int xc_handle,
211 u32 domid,
212 float weight);
213 long long xc_domain_get_cpu_usage(int xc_handle,
214 domid_t domid,
215 int vcpu);
218 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
219 int xc_shadow_control(int xc_handle,
220 u32 domid,
221 unsigned int sop,
222 unsigned long *dirty_bitmap,
223 unsigned long pages,
224 xc_shadow_control_stats_t *stats);
227 #define XCFLAGS_VERBOSE 1
228 #define XCFLAGS_LIVE 2
229 #define XCFLAGS_DEBUG 4
230 #define XCFLAGS_CONFIGURE 8
232 struct XcIOContext;
234 /**
235 * This function will save a domain running Linux.
236 *
237 * @parm xc_handle a handle to an open hypervisor interface
238 * @parm fd the file descriptor to save a domain to
239 * @parm dom the id of the domain
240 * @return 0 on success, -1 on failure
241 */
242 int xc_linux_save(int xc_handle, int fd, u32 dom);
244 /**
245 * This function will restore a saved domain running Linux.
246 *
247 * @parm xc_handle a handle to an open hypervisor interface
248 * @parm fd the file descriptor to restore a domain from
249 * @parm dom the id of the domain
250 * @parm nr_pfns the number of pages
251 * @return 0 on success, -1 on failure
252 */
253 int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns);
255 int xc_linux_build(int xc_handle,
256 u32 domid,
257 const char *image_name,
258 const char *ramdisk_name,
259 const char *cmdline,
260 unsigned int control_evtchn,
261 unsigned long flags,
262 unsigned int vcpus,
263 unsigned int store_evtchn,
264 unsigned long *store_mfn);
266 int
267 xc_plan9_build (int xc_handle,
268 u32 domid,
269 const char *image_name,
270 const char *cmdline,
271 unsigned int control_evtchn,
272 unsigned long flags);
274 struct mem_map;
275 int xc_vmx_build(int xc_handle,
276 u32 domid,
277 int memsize,
278 const char *image_name,
279 struct mem_map *memmap,
280 const char *ramdisk_name,
281 const char *cmdline,
282 unsigned int control_evtchn,
283 unsigned long flags);
285 int xc_bvtsched_global_set(int xc_handle,
286 unsigned long ctx_allow);
288 int xc_bvtsched_domain_set(int xc_handle,
289 u32 domid,
290 u32 mcuadv,
291 int warpback,
292 s32 warpvalue,
293 long long warpl,
294 long long warpu);
296 int xc_bvtsched_global_get(int xc_handle,
297 unsigned long *ctx_allow);
299 int xc_bvtsched_domain_get(int xc_handle,
300 u32 domid,
301 u32 *mcuadv,
302 int *warpback,
303 s32 *warpvalue,
304 long long *warpl,
305 long long *warpu);
307 int xc_sedf_domain_set(int xc_handle,
308 u32 domid,
309 u64 period, u64 slice, u64 latency, u16 extratime, u16 weight);
311 int xc_sedf_domain_get(int xc_handle,
312 u32 domid,
313 u64* period, u64 *slice, u64 *latency, u16 *extratime, u16* weight);
315 typedef evtchn_status_t xc_evtchn_status_t;
317 /*
318 * EVENT CHANNEL FUNCTIONS
319 */
321 /**
322 * This function allocates an unbound port. Ports are named endpoints used for
323 * interdomain communication. This function is most useful in opening a
324 * well-known port within a domain to receive events on.
325 *
326 * @parm xc_handle a handle to an open hypervisor interface
327 * @parm dom the ID of the domain. This maybe DOMID_SELF
328 * @parm port a pointer to a port. This is an in/out parameter. If *port is
329 * 0, then a new port will be assigned, if port is > 0 then that
330 * port is allocated if the port is unallocated.
331 * @return 0 on success, -1 on failure
332 */
333 int xc_evtchn_alloc_unbound(int xc_handle,
334 u32 dom,
335 int *port);
337 /**
338 * This function creates a pair of ports between two domains. A port can only
339 * be bound once within a domain.
340 *
341 * @parm xc_handle a handle to an open hypervisor interface
342 * @parm dom1 one of the two domains to connect. Can be DOMID_SELF.
343 * @parm dom2 the other domain to connect. Can be DOMID_SELF.
344 * @parm port1 an in/out parameter. If > 0, then try to connect *port. If
345 * 0, then allocate a new port and store the port in *port.
346 * @parm port2 the port connected on port2. This parameter behaves the same
347 * way as port1.
348 * @return 0 on success, -1 on error.
349 */
350 int xc_evtchn_bind_interdomain(int xc_handle,
351 u32 dom1,
352 u32 dom2,
353 int *port1,
354 int *port2);
355 int xc_evtchn_bind_virq(int xc_handle,
356 int virq,
357 int *port);
359 /**
360 * This function will close a single port on an event channel.
361 *
362 * @parm xc_handle a handle to an open hypervisor interface
363 * @parm dom the domain that the port exists on. May be DOMID_SELF.
364 * @parm port the port to close
365 * @return 0 on success, -1 on error
366 */
367 int xc_evtchn_close(int xc_handle,
368 u32 dom, /* may be DOMID_SELF */
369 int port);
371 /**
372 * This function generates a notify event on a bound port.
373 *
374 * Notifies can be read within Linux by opening /dev/xen/evtchn and reading
375 * a 16 bit value. The result will be the port the event occurred on. When
376 * events occur, the port is masked until the 16 bit port value is written back
377 * to the file. When /dev/xen/evtchn is opened, it has to be bound via an
378 * ioctl to each port to listen on. The ioctl for binding is _IO('E', 2). The
379 * parameter is the port to listen on.
380 *
381 * @parm xc_handle a handle to an open hypervisor interface
382 * @parm local_port the port to generate the notify on
383 * @return 0 on success, -1 on error
384 */
385 int xc_evtchn_send(int xc_handle,
386 int local_port);
387 int xc_evtchn_status(int xc_handle,
388 u32 dom, /* may be DOMID_SELF */
389 int port,
390 xc_evtchn_status_t *status);
392 int xc_physdev_pci_access_modify(int xc_handle,
393 u32 domid,
394 int bus,
395 int dev,
396 int func,
397 int enable);
399 int xc_readconsolering(int xc_handle,
400 char **pbuffer,
401 unsigned int *pnr_chars,
402 int clear);
404 typedef dom0_physinfo_t xc_physinfo_t;
405 int xc_physinfo(int xc_handle,
406 xc_physinfo_t *info);
408 int xc_sched_id(int xc_handle,
409 int *sched_id);
411 int xc_domain_setmaxmem(int xc_handle,
412 u32 domid,
413 unsigned int max_memkb);
415 int xc_domain_memory_increase_reservation(int xc_handle,
416 u32 domid,
417 unsigned int mem_kb);
419 typedef dom0_perfc_desc_t xc_perfc_desc_t;
420 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
421 int xc_perfc_control(int xc_handle,
422 u32 op,
423 xc_perfc_desc_t *desc);
425 /* read/write msr */
426 long long xc_msr_read(int xc_handle, int cpu_mask, int msr);
427 int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
428 unsigned int high);
430 /**
431 * Memory maps a range within one domain to a local address range. Mappings
432 * should be unmapped with munmap and should follow the same rules as mmap
433 * regarding page alignment. Returns NULL on failure.
434 *
435 * In Linux, the ring queue for the control channel is accessible by mapping
436 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
437 * stored there is of type control_if_t.
438 *
439 * @parm xc_handle a handle on an open hypervisor interface
440 * @parm dom the domain to map memory from
441 * @parm size the amount of memory to map (in multiples of page size)
442 * @parm prot same flag as in mmap().
443 * @parm mfn the frame address to map.
444 */
445 void *xc_map_foreign_range(int xc_handle, u32 dom,
446 int size, int prot,
447 unsigned long mfn );
449 void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot,
450 unsigned long *arr, int num );
452 int xc_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf,
453 unsigned long max_pfns);
455 /*\
456 * GRANT TABLE FUNCTIONS
457 \*/
459 /**
460 * This function opens a handle to the more restricted grant table hypervisor
461 * interface. This may be used where the standard interface is not
462 * available because the domain is not privileged.
463 * This function can be called multiple times within a single process.
464 * Multiple processes can have an open hypervisor interface at the same time.
465 *
466 * Each call to this function should have a corresponding call to
467 * xc_grant_interface_close().
468 *
469 * This function can fail if a Xen-enabled kernel is not currently running.
470 *
471 * @return a handle to the hypervisor grant table interface or -1 on failure
472 */
473 int xc_grant_interface_open(void);
475 /**
476 * This function closes an open grant table hypervisor interface.
477 *
478 * This function can fail if the handle does not represent an open interface or
479 * if there were problems closing the interface.
480 *
481 * @parm xc_handle a handle to an open grant table hypervisor interface
482 * @return 0 on success, -1 otherwise.
483 */
484 int xc_grant_interface_close(int xc_handle);
486 int xc_gnttab_map_grant_ref(int xc_handle,
487 memory_t host_virt_addr,
488 u32 dom,
489 u16 ref,
490 u16 flags,
491 s16 *handle,
492 memory_t *dev_bus_addr);
494 int xc_gnttab_unmap_grant_ref(int xc_handle,
495 memory_t host_virt_addr,
496 memory_t dev_bus_addr,
497 u16 handle,
498 s16 *status);
500 int xc_gnttab_setup_table(int xc_handle,
501 u32 dom,
502 u16 nr_frames,
503 s16 *status,
504 memory_t **frame_list);
506 /* Grant debug builds only: */
507 int xc_gnttab_dump_table(int xc_handle,
508 u32 dom,
509 s16 *status);
511 /* Get current total pages allocated to a domain. */
512 long xc_get_tot_pages(int xc_handle, u32 domid);
514 /* Execute a privileged dom0 operation. */
515 int xc_dom0_op(int xc_handle, dom0_op_t *op);
517 #endif /* __XC_H__ */