ia64/xen-unstable

view tools/libxc/xenctrl.h @ 7800:5aad7e145e50

If /sbin/ isn't in the path, udev rules will erroneously not get
installed.

Signed-off-by: Nivedita Singhvi <niv@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Nov 14 11:05:34 2005 +0100 (2005-11-14)
parents b3c2bc39d815
children 8ee7df2c18d1
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>
13 #include <sys/ptrace.h>
14 #include <xen/xen.h>
15 #include <xen/dom0_ops.h>
16 #include <xen/version.h>
17 #include <xen/event_channel.h>
18 #include <xen/sched.h>
19 #include <xen/sched_ctl.h>
20 #include <xen/memory.h>
21 #include <xen/acm.h>
23 #ifdef __ia64__
24 #define XC_PAGE_SHIFT 14
25 #else
26 #define XC_PAGE_SHIFT 12
27 #endif
28 #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT)
29 #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1))
31 /*
32 * DEFINITIONS FOR CPU BARRIERS
33 */
35 #if defined(__i386__)
36 #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
37 #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
38 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
39 #elif defined(__x86_64__)
40 #define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
41 #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
42 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
43 #elif defined(__ia64__)
44 /* FIXME */
45 #define mb()
46 #define rmb()
47 #define wmb()
48 #else
49 #error "Define barriers"
50 #endif
52 /*
53 * INITIALIZATION FUNCTIONS
54 */
56 /**
57 * This function opens a handle to the hypervisor interface. This function can
58 * be called multiple times within a single process. Multiple processes can
59 * have an open hypervisor interface at the same time.
60 *
61 * Each call to this function should have a corresponding call to
62 * xc_interface_close().
63 *
64 * This function can fail if the caller does not have superuser permission or
65 * if a Xen-enabled kernel is not currently running.
66 *
67 * @return a handle to the hypervisor interface or -1 on failure
68 */
69 int xc_interface_open(void);
71 /**
72 * This function closes an open hypervisor interface.
73 *
74 * This function can fail if the handle does not represent an open interface or
75 * if there were problems closing the interface.
76 *
77 * @parm xc_handle a handle to an open hypervisor interface
78 * @return 0 on success, -1 otherwise.
79 */
80 int xc_interface_close(int xc_handle);
82 /*
83 * DOMAIN DEBUGGING FUNCTIONS
84 */
86 typedef struct xc_core_header {
87 unsigned int xch_magic;
88 unsigned int xch_nr_vcpus;
89 unsigned int xch_nr_pages;
90 unsigned int xch_ctxt_offset;
91 unsigned int xch_index_offset;
92 unsigned int xch_pages_offset;
93 } xc_core_header_t;
96 long xc_ptrace(
97 int xc_handle,
98 enum __ptrace_request request,
99 uint32_t domid,
100 long addr,
101 long data);
103 long xc_ptrace_core(
104 int xc_handle,
105 enum __ptrace_request request,
106 uint32_t domid,
107 long addr,
108 long data);
110 int xc_waitdomain(
111 int xc_handle,
112 int domain,
113 int *status,
114 int options);
116 int xc_waitdomain_core(
117 int xc_handle,
118 int domain,
119 int *status,
120 int options);
122 /*
123 * DOMAIN MANAGEMENT FUNCTIONS
124 */
126 typedef struct {
127 uint32_t domid;
128 uint32_t 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 uint64_t cpu_time;
135 unsigned long max_memkb;
136 unsigned int nr_online_vcpus;
137 unsigned int max_vcpu_id;
138 xen_domain_handle_t handle;
139 } xc_dominfo_t;
141 typedef dom0_getdomaininfo_t xc_domaininfo_t;
142 int xc_domain_create(int xc_handle,
143 uint32_t ssidref,
144 xen_domain_handle_t handle,
145 uint32_t *pdomid);
148 int xc_domain_dumpcore(int xc_handle,
149 uint32_t domid,
150 const char *corename);
152 /*
153 * This function sets the maximum number of vcpus that a domain may create.
154 *
155 * @parm xc_handle a handle to an open hypervisor interface.
156 * @parm domid the domain id in which vcpus are to be created.
157 * @parm max the maximum number of vcpus that the domain may create.
158 * @return 0 on success, -1 on failure.
159 */
160 int xc_domain_max_vcpus(int xc_handle,
161 uint32_t domid,
162 unsigned int max);
164 /**
165 * This function pauses a domain. A paused domain still exists in memory
166 * however it does not receive any timeslices from the hypervisor.
167 *
168 * @parm xc_handle a handle to an open hypervisor interface
169 * @parm domid the domain id to pause
170 * @return 0 on success, -1 on failure.
171 */
172 int xc_domain_pause(int xc_handle,
173 uint32_t domid);
174 /**
175 * This function unpauses a domain. The domain should have been previously
176 * paused.
177 *
178 * @parm xc_handle a handle to an open hypervisor interface
179 * @parm domid the domain id to unpause
180 * return 0 on success, -1 on failure
181 */
182 int xc_domain_unpause(int xc_handle,
183 uint32_t domid);
185 /**
186 * This function will destroy a domain. Destroying a domain removes the domain
187 * completely from memory. This function should be called after sending the
188 * domain a SHUTDOWN control message to free up the domain resources.
189 *
190 * @parm xc_handle a handle to an open hypervisor interface
191 * @parm domid the domain id to destroy
192 * @return 0 on success, -1 on failure
193 */
194 int xc_domain_destroy(int xc_handle,
195 uint32_t domid);
196 int xc_domain_pincpu(int xc_handle,
197 uint32_t domid,
198 int vcpu,
199 cpumap_t cpumap);
201 /**
202 * This function will return information about one or more domains. It is
203 * designed to iterate over the list of domains. If a single domain is
204 * requested, this function will return the next domain in the list - if
205 * one exists. It is, therefore, important in this case to make sure the
206 * domain requested was the one returned.
207 *
208 * @parm xc_handle a handle to an open hypervisor interface
209 * @parm first_domid the first domain to enumerate information from. Domains
210 * are currently enumerate in order of creation.
211 * @parm max_doms the number of elements in info
212 * @parm info an array of max_doms size that will contain the information for
213 * the enumerated domains.
214 * @return the number of domains enumerated or -1 on error
215 */
216 int xc_domain_getinfo(int xc_handle,
217 uint32_t first_domid,
218 unsigned int max_doms,
219 xc_dominfo_t *info);
221 /**
222 * This function will return information about one or more domains, using a
223 * single hypercall. The domain information will be stored into the supplied
224 * array of xc_domaininfo_t structures.
225 *
226 * @parm xc_handle a handle to an open hypervisor interface
227 * @parm first_domain the first domain to enumerate information from.
228 * Domains are currently enumerate in order of creation.
229 * @parm max_domains the number of elements in info
230 * @parm info an array of max_doms size that will contain the information for
231 * the enumerated domains.
232 * @return the number of domains enumerated or -1 on error
233 */
234 int xc_domain_getinfolist(int xc_handle,
235 uint32_t first_domain,
236 unsigned int max_domains,
237 xc_domaininfo_t *info);
239 /**
240 * This function returns information about the execution context of a
241 * particular vcpu of a domain.
242 *
243 * @parm xc_handle a handle to an open hypervisor interface
244 * @parm domid the domain to get information from
245 * @parm vcpu the vcpu number
246 * @parm ctxt a pointer to a structure to store the execution context of the
247 * domain
248 * @return 0 on success, -1 on failure
249 */
250 int xc_domain_get_vcpu_context(int xc_handle,
251 uint32_t domid,
252 uint32_t vcpu,
253 vcpu_guest_context_t *ctxt);
255 typedef dom0_getvcpuinfo_t xc_vcpuinfo_t;
256 int xc_domain_get_vcpu_info(int xc_handle,
257 uint32_t domid,
258 uint32_t vcpu,
259 xc_vcpuinfo_t *info);
262 int xc_domain_setcpuweight(int xc_handle,
263 uint32_t domid,
264 float weight);
265 long long xc_domain_get_cpu_usage(int xc_handle,
266 domid_t domid,
267 int vcpu);
269 int xc_domain_sethandle(int xc_handle, uint32_t domid,
270 xen_domain_handle_t handle);
272 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
273 int xc_shadow_control(int xc_handle,
274 uint32_t domid,
275 unsigned int sop,
276 unsigned long *dirty_bitmap,
277 unsigned long pages,
278 xc_shadow_control_stats_t *stats);
280 int xc_bvtsched_global_set(int xc_handle,
281 unsigned long ctx_allow);
283 int xc_bvtsched_domain_set(int xc_handle,
284 uint32_t domid,
285 uint32_t mcuadv,
286 int warpback,
287 int32_t warpvalue,
288 long long warpl,
289 long long warpu);
291 int xc_bvtsched_global_get(int xc_handle,
292 unsigned long *ctx_allow);
294 int xc_bvtsched_domain_get(int xc_handle,
295 uint32_t domid,
296 uint32_t *mcuadv,
297 int *warpback,
298 int32_t *warpvalue,
299 long long *warpl,
300 long long *warpu);
302 int xc_sedf_domain_set(int xc_handle,
303 uint32_t domid,
304 uint64_t period, uint64_t slice,
305 uint64_t latency, uint16_t extratime,
306 uint16_t weight);
308 int xc_sedf_domain_get(int xc_handle,
309 uint32_t domid,
310 uint64_t* period, uint64_t *slice,
311 uint64_t *latency, uint16_t *extratime,
312 uint16_t *weight);
314 typedef evtchn_status_t xc_evtchn_status_t;
316 /*
317 * EVENT CHANNEL FUNCTIONS
318 */
320 /**
321 * This function allocates an unbound port. Ports are named endpoints used for
322 * interdomain communication. This function is most useful in opening a
323 * well-known port within a domain to receive events on.
324 *
325 * @parm xc_handle a handle to an open hypervisor interface
326 * @parm dom the ID of the local domain (the 'allocatee')
327 * @parm remote_dom the ID of the domain who will later bind
328 * @return allocated port (in @dom) on success, -1 on failure
329 */
330 int xc_evtchn_alloc_unbound(int xc_handle,
331 uint32_t dom,
332 uint32_t remote_dom);
334 int xc_evtchn_status(int xc_handle,
335 uint32_t dom, /* may be DOMID_SELF */
336 int port,
337 xc_evtchn_status_t *status);
339 int xc_physdev_pci_access_modify(int xc_handle,
340 uint32_t domid,
341 int bus,
342 int dev,
343 int func,
344 int enable);
346 int xc_readconsolering(int xc_handle,
347 char **pbuffer,
348 unsigned int *pnr_chars,
349 int clear);
351 typedef dom0_physinfo_t xc_physinfo_t;
352 int xc_physinfo(int xc_handle,
353 xc_physinfo_t *info);
355 int xc_sched_id(int xc_handle,
356 int *sched_id);
358 int xc_domain_setmaxmem(int xc_handle,
359 uint32_t domid,
360 unsigned int max_memkb);
362 int xc_domain_memory_increase_reservation(int xc_handle,
363 uint32_t domid,
364 unsigned long nr_extents,
365 unsigned int extent_order,
366 unsigned int address_bits,
367 unsigned long *extent_start);
369 int xc_domain_memory_decrease_reservation(int xc_handle,
370 uint32_t domid,
371 unsigned long nr_extents,
372 unsigned int extent_order,
373 unsigned long *extent_start);
375 int xc_domain_ioport_permission(int xc_handle,
376 uint32_t domid,
377 uint16_t first_port,
378 uint16_t nr_ports,
379 uint16_t allow_access);
381 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
382 unsigned long mfn);
384 typedef dom0_perfc_desc_t xc_perfc_desc_t;
385 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
386 int xc_perfc_control(int xc_handle,
387 uint32_t op,
388 xc_perfc_desc_t *desc);
390 /* read/write msr */
391 long long xc_msr_read(int xc_handle, int cpu_mask, int msr);
392 int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
393 unsigned int high);
395 /**
396 * Memory maps a range within one domain to a local address range. Mappings
397 * should be unmapped with munmap and should follow the same rules as mmap
398 * regarding page alignment. Returns NULL on failure.
399 *
400 * In Linux, the ring queue for the control channel is accessible by mapping
401 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
402 * stored there is of type control_if_t.
403 *
404 * @parm xc_handle a handle on an open hypervisor interface
405 * @parm dom the domain to map memory from
406 * @parm size the amount of memory to map (in multiples of page size)
407 * @parm prot same flag as in mmap().
408 * @parm mfn the frame address to map.
409 */
410 void *xc_map_foreign_range(int xc_handle, uint32_t dom,
411 int size, int prot,
412 unsigned long mfn );
414 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
415 unsigned long *arr, int num );
417 int xc_get_pfn_list(int xc_handle, uint32_t domid, unsigned long *pfn_buf,
418 unsigned long max_pfns);
420 int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
421 unsigned long *pfn_buf,
422 unsigned int start_page, unsigned int nr_pages);
424 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
425 unsigned long dst_pfn, void *src_page);
427 int xc_clear_domain_page(int xc_handle, uint32_t domid,
428 unsigned long dst_pfn);
430 int xc_ia64_copy_to_domain_pages(int xc_handle, uint32_t domid,
431 void* src_page, unsigned long dst_pfn, int nr_pages);
433 long xc_get_max_pages(int xc_handle, uint32_t domid);
435 int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,
436 domid_t dom);
438 int xc_memory_op(int xc_handle, int cmd, void *arg);
440 int xc_get_pfn_type_batch(int xc_handle, uint32_t dom,
441 int num, unsigned long *arr);
444 /*\
445 * GRANT TABLE FUNCTIONS
446 \*/
448 /**
449 * This function opens a handle to the more restricted grant table hypervisor
450 * interface. This may be used where the standard interface is not
451 * available because the domain is not privileged.
452 * This function can be called multiple times within a single process.
453 * Multiple processes can have an open hypervisor interface at the same time.
454 *
455 * Each call to this function should have a corresponding call to
456 * xc_grant_interface_close().
457 *
458 * This function can fail if a Xen-enabled kernel is not currently running.
459 *
460 * @return a handle to the hypervisor grant table interface or -1 on failure
461 */
462 int xc_grant_interface_open(void);
464 /**
465 * This function closes an open grant table hypervisor interface.
466 *
467 * This function can fail if the handle does not represent an open interface or
468 * if there were problems closing the interface.
469 *
470 * @parm xc_handle a handle to an open grant table hypervisor interface
471 * @return 0 on success, -1 otherwise.
472 */
473 int xc_grant_interface_close(int xc_handle);
475 int xc_gnttab_map_grant_ref(int xc_handle,
476 uint64_t host_virt_addr,
477 uint32_t dom,
478 uint16_t ref,
479 uint16_t flags,
480 int16_t *handle,
481 uint64_t *dev_bus_addr);
483 int xc_gnttab_unmap_grant_ref(int xc_handle,
484 uint64_t host_virt_addr,
485 uint64_t dev_bus_addr,
486 uint16_t handle,
487 int16_t *status);
489 int xc_gnttab_setup_table(int xc_handle,
490 uint32_t dom,
491 uint16_t nr_frames,
492 int16_t *status,
493 unsigned long **frame_list);
495 /* Grant debug builds only: */
496 int xc_gnttab_dump_table(int xc_handle,
497 uint32_t dom,
498 int16_t *status);
500 /* Get current total pages allocated to a domain. */
501 long xc_get_tot_pages(int xc_handle, uint32_t domid);
504 /*
505 * Trace Buffer Operations
506 */
508 /**
509 * This function enables or disables tracing. Trace buffer memory must
510 * be already allocated by setting the size to a non-zero value, otherwise
511 * tracing cannot be enabled.
512 *
513 * @parm xc_handle a handle to an open hypervisor interface
514 * @parm enable the desired action, 1 for enable, 0 for disable
515 * @return 0 on success, -1 on failure.
516 */
517 int xc_tbuf_enable(int xc_handle, int enable);
519 /**
520 * This function sets the size of the trace buffers. Setting the size
521 * is currently a one-shot operation that may be performed either at boot
522 * time or via this interface, not both. The buffer size must be set before
523 * enabling tracing.
524 *
525 * @parm xc_handle a handle to an open hypervisor interface
526 * @parm size the size in pages per cpu for the trace buffers
527 * @return 0 on success, -1 on failure.
528 */
529 int xc_tbuf_set_size(int xc_handle, uint32_t size);
531 /**
532 * This function retrieves the current size of the trace buffers.
533 * Note that the size returned is in terms of bytes, not pages.
535 * @parm xc_handle a handle to an open hypervisor interface
536 * @parm size will contain the size in bytes for the trace buffers
537 * @return 0 on success, -1 on failure.
538 */
539 int xc_tbuf_get_size(int xc_handle, uint32_t *size);
542 /* Execute a privileged dom0 operation. */
543 int xc_dom0_op(int xc_handle, dom0_op_t *op);
545 int xc_version(int xc_handle, int cmd, void *arg);
547 /*
548 * MMU updates.
549 */
550 #define MAX_MMU_UPDATES 1024
551 struct xc_mmu {
552 mmu_update_t updates[MAX_MMU_UPDATES];
553 int idx;
554 domid_t subject;
555 };
556 typedef struct xc_mmu xc_mmu_t;
557 xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
558 int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
559 unsigned long long ptr, unsigned long long val);
560 int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
562 #endif