ia64/xen-unstable

view tools/libxc/xenctrl.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3233e7ecfa9f
children ec01850d0ee9 872cf6ee0594
line source
1 /******************************************************************************
2 * xenctrl.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 XENCTRL_H
10 #define XENCTRL_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/version.h>
27 #include <xen/event_channel.h>
28 #include <xen/sched_ctl.h>
29 #include <xen/acm.h>
31 #ifdef __ia64__
32 #define XC_PAGE_SHIFT 14
33 #else
34 #define XC_PAGE_SHIFT 12
35 #endif
36 #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT)
37 #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1))
39 /*
40 * DEFINITIONS FOR CPU BARRIERS
41 */
43 #if defined(__i386__)
44 #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
45 #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
46 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
47 #elif defined(__x86_64__)
48 #define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
49 #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
50 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
51 #elif defined(__ia64__)
52 /* FIXME */
53 #define mb()
54 #define rmb()
55 #define wmb()
56 #else
57 #error "Define barriers"
58 #endif
60 /*
61 * INITIALIZATION FUNCTIONS
62 */
64 /**
65 * This function opens a handle to the hypervisor interface. This function can
66 * be called multiple times within a single process. Multiple processes can
67 * have an open hypervisor interface at the same time.
68 *
69 * Each call to this function should have a corresponding call to
70 * xc_interface_close().
71 *
72 * This function can fail if the caller does not have superuser permission or
73 * if a Xen-enabled kernel is not currently running.
74 *
75 * @return a handle to the hypervisor interface or -1 on failure
76 */
77 int xc_interface_open(void);
79 /**
80 * This function closes an open hypervisor interface.
81 *
82 * This function can fail if the handle does not represent an open interface or
83 * if there were problems closing the interface.
84 *
85 * @parm xc_handle a handle to an open hypervisor interface
86 * @return 0 on success, -1 otherwise.
87 */
88 int xc_interface_close(int xc_handle);
90 /*
91 * DOMAIN DEBUGGING FUNCTIONS
92 */
94 typedef struct xc_core_header {
95 unsigned int xch_magic;
96 unsigned int xch_nr_vcpus;
97 unsigned int xch_nr_pages;
98 unsigned int xch_ctxt_offset;
99 unsigned int xch_index_offset;
100 unsigned int xch_pages_offset;
101 } xc_core_header_t;
104 long xc_ptrace(enum __ptrace_request request,
105 u32 domid,
106 long addr,
107 long data);
109 long xc_ptrace_core(enum __ptrace_request request,
110 u32 domid,
111 long addr,
112 long data);
114 int xc_waitdomain(int domain,
115 int *status,
116 int options);
118 int xc_waitdomain_core(int domain,
119 int *status,
120 int options);
122 /*
123 * DOMAIN MANAGEMENT FUNCTIONS
124 */
126 typedef struct {
127 u32 domid;
128 u32 ssidref;
129 unsigned int dying:1, crashed:1, shutdown:1,
130 paused:1, blocked:1, running:1;
131 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
132 unsigned long nr_pages;
133 unsigned long shared_info_frame;
134 u64 cpu_time;
135 unsigned long max_memkb;
136 unsigned int vcpus;
137 s32 vcpu_to_cpu[MAX_VIRT_CPUS];
138 cpumap_t cpumap[MAX_VIRT_CPUS];
139 } xc_dominfo_t;
141 typedef dom0_getdomaininfo_t xc_domaininfo_t;
142 int xc_domain_create(int xc_handle,
143 u32 ssidref,
144 u32 *pdomid);
147 int xc_domain_dumpcore(int xc_handle,
148 u32 domid,
149 const char *corename);
152 /**
153 * This function pauses a domain. A paused domain still exists in memory
154 * however it does not receive any timeslices from the hypervisor.
155 *
156 * @parm xc_handle a handle to an open hypervisor interface
157 * @parm domid the domain id to pause
158 * @return 0 on success, -1 on failure.
159 */
160 int xc_domain_pause(int xc_handle,
161 u32 domid);
162 /**
163 * This function unpauses a domain. The domain should have been previously
164 * paused.
165 *
166 * @parm xc_handle a handle to an open hypervisor interface
167 * @parm domid the domain id to unpause
168 * return 0 on success, -1 on failure
169 */
170 int xc_domain_unpause(int xc_handle,
171 u32 domid);
173 /**
174 * This function will destroy a domain. Destroying a domain removes the domain
175 * completely from memory. This function should be called after sending the
176 * domain a SHUTDOWN control message to free up the domain resources.
177 *
178 * @parm xc_handle a handle to an open hypervisor interface
179 * @parm domid the domain id to destroy
180 * @return 0 on success, -1 on failure
181 */
182 int xc_domain_destroy(int xc_handle,
183 u32 domid);
184 int xc_domain_pincpu(int xc_handle,
185 u32 domid,
186 int vcpu,
187 cpumap_t *cpumap);
188 /**
189 * This function will return information about one or more domains. It is
190 * designed to iterate over the list of domains. If a single domain is
191 * requested, this function will return the next domain in the list - if
192 * one exists. It is, therefore, important in this case to make sure the
193 * domain requested was the one returned.
194 *
195 * @parm xc_handle a handle to an open hypervisor interface
196 * @parm first_domid the first domain to enumerate information from. Domains
197 * are currently enumerate in order of creation.
198 * @parm max_doms the number of elements in info
199 * @parm info an array of max_doms size that will contain the information for
200 * the enumerated domains.
201 * @return the number of domains enumerated or -1 on error
202 */
203 int xc_domain_getinfo(int xc_handle,
204 u32 first_domid,
205 unsigned int max_doms,
206 xc_dominfo_t *info);
208 /**
209 * This function will return information about one or more domains, using a
210 * single hypercall. The domain information will be stored into the supplied
211 * array of xc_domaininfo_t structures.
212 *
213 * @parm xc_handle a handle to an open hypervisor interface
214 * @parm first_domain the first domain to enumerate information from.
215 * Domains are currently enumerate in order of creation.
216 * @parm max_domains the number of elements in info
217 * @parm info an array of max_doms size that will contain the information for
218 * the enumerated domains.
219 * @return the number of domains enumerated or -1 on error
220 */
221 int xc_domain_getinfolist(int xc_handle,
222 u32 first_domain,
223 unsigned int max_domains,
224 xc_domaininfo_t *info);
226 /**
227 * This function returns information about one domain. This information is
228 * more detailed than the information from xc_domain_getinfo().
229 *
230 * @parm xc_handle a handle to an open hypervisor interface
231 * @parm domid the domain to get information from
232 * @parm info a pointer to an xc_domaininfo_t to store the domain information
233 * @parm ctxt a pointer to a structure to store the execution context of the
234 * domain
235 * @return 0 on success, -1 on failure
236 */
237 int xc_domain_get_vcpu_context(int xc_handle,
238 u32 domid,
239 u32 vcpu,
240 vcpu_guest_context_t *ctxt);
242 int xc_domain_setcpuweight(int xc_handle,
243 u32 domid,
244 float weight);
245 long long xc_domain_get_cpu_usage(int xc_handle,
246 domid_t domid,
247 int vcpu);
250 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
251 int xc_shadow_control(int xc_handle,
252 u32 domid,
253 unsigned int sop,
254 unsigned long *dirty_bitmap,
255 unsigned long pages,
256 xc_shadow_control_stats_t *stats);
258 int xc_bvtsched_global_set(int xc_handle,
259 unsigned long ctx_allow);
261 int xc_bvtsched_domain_set(int xc_handle,
262 u32 domid,
263 u32 mcuadv,
264 int warpback,
265 s32 warpvalue,
266 long long warpl,
267 long long warpu);
269 int xc_bvtsched_global_get(int xc_handle,
270 unsigned long *ctx_allow);
272 int xc_bvtsched_domain_get(int xc_handle,
273 u32 domid,
274 u32 *mcuadv,
275 int *warpback,
276 s32 *warpvalue,
277 long long *warpl,
278 long long *warpu);
280 int xc_sedf_domain_set(int xc_handle,
281 u32 domid,
282 u64 period, u64 slice, u64 latency, u16 extratime, u16 weight);
284 int xc_sedf_domain_get(int xc_handle,
285 u32 domid,
286 u64* period, u64 *slice, u64 *latency, u16 *extratime, u16* weight);
288 typedef evtchn_status_t xc_evtchn_status_t;
290 /*
291 * EVENT CHANNEL FUNCTIONS
292 */
294 /**
295 * This function allocates an unbound port. Ports are named endpoints used for
296 * interdomain communication. This function is most useful in opening a
297 * well-known port within a domain to receive events on.
298 *
299 * @parm xc_handle a handle to an open hypervisor interface
300 * @parm dom the ID of the domain. This maybe DOMID_SELF
301 * @parm port a pointer to a port. This is an in/out parameter. If *port is
302 * 0, then a new port will be assigned, if port is > 0 then that
303 * port is allocated if the port is unallocated.
304 * @return 0 on success, -1 on failure
305 */
306 int xc_evtchn_alloc_unbound(int xc_handle,
307 u32 dom,
308 int *port);
310 /**
311 * This function creates a pair of ports between two domains. A port can only
312 * be bound once within a domain.
313 *
314 * @parm xc_handle a handle to an open hypervisor interface
315 * @parm dom1 one of the two domains to connect. Can be DOMID_SELF.
316 * @parm dom2 the other domain to connect. Can be DOMID_SELF.
317 * @parm port1 an in/out parameter. If > 0, then try to connect *port. If
318 * 0, then allocate a new port and store the port in *port.
319 * @parm port2 the port connected on port2. This parameter behaves the same
320 * way as port1.
321 * @return 0 on success, -1 on error.
322 */
323 int xc_evtchn_bind_interdomain(int xc_handle,
324 u32 dom1,
325 u32 dom2,
326 int *port1,
327 int *port2);
328 int xc_evtchn_bind_virq(int xc_handle,
329 int virq,
330 int *port);
332 /**
333 * This function will close a single port on an event channel.
334 *
335 * @parm xc_handle a handle to an open hypervisor interface
336 * @parm dom the domain that the port exists on. May be DOMID_SELF.
337 * @parm port the port to close
338 * @return 0 on success, -1 on error
339 */
340 int xc_evtchn_close(int xc_handle,
341 u32 dom, /* may be DOMID_SELF */
342 int port);
344 /**
345 * This function generates a notify event on a bound port.
346 *
347 * Notifies can be read within Linux by opening /dev/xen/evtchn and reading
348 * a 16 bit value. The result will be the port the event occurred on. When
349 * events occur, the port is masked until the 16 bit port value is written back
350 * to the file. When /dev/xen/evtchn is opened, it has to be bound via an
351 * ioctl to each port to listen on. The ioctl for binding is _IO('E', 2). The
352 * parameter is the port to listen on.
353 *
354 * @parm xc_handle a handle to an open hypervisor interface
355 * @parm local_port the port to generate the notify on
356 * @return 0 on success, -1 on error
357 */
358 int xc_evtchn_send(int xc_handle,
359 int local_port);
360 int xc_evtchn_status(int xc_handle,
361 u32 dom, /* may be DOMID_SELF */
362 int port,
363 xc_evtchn_status_t *status);
365 int xc_physdev_pci_access_modify(int xc_handle,
366 u32 domid,
367 int bus,
368 int dev,
369 int func,
370 int enable);
372 int xc_readconsolering(int xc_handle,
373 char **pbuffer,
374 unsigned int *pnr_chars,
375 int clear);
377 typedef dom0_physinfo_t xc_physinfo_t;
378 int xc_physinfo(int xc_handle,
379 xc_physinfo_t *info);
381 int xc_sched_id(int xc_handle,
382 int *sched_id);
384 int xc_domain_setmaxmem(int xc_handle,
385 u32 domid,
386 unsigned int max_memkb);
388 int xc_domain_memory_increase_reservation(int xc_handle,
389 u32 domid,
390 unsigned long nr_extents,
391 unsigned int extent_order,
392 unsigned int address_bits,
393 unsigned long *extent_start);
395 int xc_domain_memory_decrease_reservation(int xc_handle,
396 u32 domid,
397 unsigned long nr_extents,
398 unsigned int extent_order,
399 unsigned long *extent_start);
401 unsigned long xc_make_page_below_4G(int xc_handle, u32 domid,
402 unsigned long mfn);
404 typedef dom0_perfc_desc_t xc_perfc_desc_t;
405 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
406 int xc_perfc_control(int xc_handle,
407 u32 op,
408 xc_perfc_desc_t *desc);
410 /* read/write msr */
411 long long xc_msr_read(int xc_handle, int cpu_mask, int msr);
412 int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
413 unsigned int high);
415 /**
416 * Memory maps a range within one domain to a local address range. Mappings
417 * should be unmapped with munmap and should follow the same rules as mmap
418 * regarding page alignment. Returns NULL on failure.
419 *
420 * In Linux, the ring queue for the control channel is accessible by mapping
421 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
422 * stored there is of type control_if_t.
423 *
424 * @parm xc_handle a handle on an open hypervisor interface
425 * @parm dom the domain to map memory from
426 * @parm size the amount of memory to map (in multiples of page size)
427 * @parm prot same flag as in mmap().
428 * @parm mfn the frame address to map.
429 */
430 void *xc_map_foreign_range(int xc_handle, u32 dom,
431 int size, int prot,
432 unsigned long mfn );
434 void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot,
435 unsigned long *arr, int num );
437 int xc_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf,
438 unsigned long max_pfns);
440 int xc_ia64_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf,
441 unsigned int start_page, unsigned int nr_pages);
443 long xc_get_max_pages(int xc_handle, u32 domid);
445 int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,
446 domid_t dom);
448 int xc_memory_op(int xc_handle, int cmd, void *arg);
450 int xc_get_pfn_type_batch(int xc_handle, u32 dom, int num, unsigned long *arr);
453 /*\
454 * GRANT TABLE FUNCTIONS
455 \*/
457 /**
458 * This function opens a handle to the more restricted grant table hypervisor
459 * interface. This may be used where the standard interface is not
460 * available because the domain is not privileged.
461 * This function can be called multiple times within a single process.
462 * Multiple processes can have an open hypervisor interface at the same time.
463 *
464 * Each call to this function should have a corresponding call to
465 * xc_grant_interface_close().
466 *
467 * This function can fail if a Xen-enabled kernel is not currently running.
468 *
469 * @return a handle to the hypervisor grant table interface or -1 on failure
470 */
471 int xc_grant_interface_open(void);
473 /**
474 * This function closes an open grant table hypervisor interface.
475 *
476 * This function can fail if the handle does not represent an open interface or
477 * if there were problems closing the interface.
478 *
479 * @parm xc_handle a handle to an open grant table hypervisor interface
480 * @return 0 on success, -1 otherwise.
481 */
482 int xc_grant_interface_close(int xc_handle);
484 int xc_gnttab_map_grant_ref(int xc_handle,
485 u64 host_virt_addr,
486 u32 dom,
487 u16 ref,
488 u16 flags,
489 s16 *handle,
490 u64 *dev_bus_addr);
492 int xc_gnttab_unmap_grant_ref(int xc_handle,
493 u64 host_virt_addr,
494 u64 dev_bus_addr,
495 u16 handle,
496 s16 *status);
498 int xc_gnttab_setup_table(int xc_handle,
499 u32 dom,
500 u16 nr_frames,
501 s16 *status,
502 unsigned long **frame_list);
504 /* Grant debug builds only: */
505 int xc_gnttab_dump_table(int xc_handle,
506 u32 dom,
507 s16 *status);
509 /* Get current total pages allocated to a domain. */
510 long xc_get_tot_pages(int xc_handle, u32 domid);
512 /* Execute a privileged dom0 operation. */
513 int xc_dom0_op(int xc_handle, dom0_op_t *op);
515 int xc_version(int xc_handle, int cmd, void *arg);
517 /* Initializes the store (for dom0)
518 remote_port should be the remote end of a bound interdomain channel between
519 the store and dom0.
521 This function returns a shared frame that should be passed to
522 xs_introduce_domain
523 */
524 long xc_init_store(int xc_handle, int remote_port);
526 /*
527 * MMU updates.
528 */
529 #define MAX_MMU_UPDATES 1024
530 struct xc_mmu {
531 mmu_update_t updates[MAX_MMU_UPDATES];
532 int idx;
533 domid_t subject;
534 };
535 typedef struct xc_mmu xc_mmu_t;
536 xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
537 int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
538 unsigned long long ptr, unsigned long long val);
539 int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
541 #endif