direct-io.hg

view tools/libxc/xc.h @ 5498:ae0cf78f78bd

bitkeeper revision 1.1159.258.169 (42b35222QJFB1A-V4mSUnrUrLfA8xA)

[PATCH] RE: [Xen-devel] DOM0_GETDOMAININFO intended behavior

Ok... now that I (unintentionally) went overboard on this, why not just
document how it works and leave it as is?

signed-off-by: dsteklof@us.ibm.com
signed-off-by: ian@xensource.com
author dsteklof@us.ibm.com[iap10]
date Fri Jun 17 22:43:46 2005 +0000 (2005-06-17)
parents 6d86ef2aeb06
children 0d1166678d9b
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. It is
118 * designed to iterate over the list of domains. If a single domain is
119 * requested, this function will return the next domain in the list - if
120 * one exists. It is, therefore, important in this case to make sure the
121 * domain requested was the one returned.
122 *
123 * @parm xc_handle a handle to an open hypervisor interface
124 * @parm first_domid the first domain to enumerate information from. Domains
125 * are currently enumerate in order of creation.
126 * @parm max_doms the number of elements in info
127 * @parm info an array of max_doms size that will contain the information for
128 * the enumerated domains.
129 * @return the number of domains enumerated or -1 on error
130 */
131 int xc_domain_getinfo(int xc_handle,
132 u32 first_domid,
133 unsigned int max_doms,
134 xc_dominfo_t *info);
136 /**
137 * This function returns information about one domain. This information is
138 * more detailed than the information from xc_domain_getinfo().
139 *
140 * @parm xc_handle a handle to an open hypervisor interface
141 * @parm domid the domain to get information from
142 * @parm info a pointer to an xc_domaininfo_t to store the domain information
143 * @parm ctxt a pointer to a structure to store the execution context of the
144 * domain
145 * @return 0 on success, -1 on failure
146 */
147 int xc_domain_getfullinfo(int xc_handle,
148 u32 domid,
149 xc_domaininfo_t *info,
150 full_execution_context_t *ctxt);
151 int xc_domain_setcpuweight(int xc_handle,
152 u32 domid,
153 float weight);
154 long long xc_domain_get_cpu_usage(int xc_handle,
155 domid_t domid);
158 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
159 int xc_shadow_control(int xc_handle,
160 u32 domid,
161 unsigned int sop,
162 unsigned long *dirty_bitmap,
163 unsigned long pages,
164 xc_shadow_control_stats_t *stats);
167 #define XCFLAGS_VERBOSE 1
168 #define XCFLAGS_LIVE 2
169 #define XCFLAGS_DEBUG 4
170 #define XCFLAGS_CONFIGURE 8
172 struct XcIOContext;
174 /**
175 * This function will save a domain running Linux to an IO context. This
176 * IO context is currently a private interface making this function difficult
177 * to call. It's interface will likely change in the future.
178 *
179 * @parm xc_handle a handle to an open hypervisor interface
180 * @parm ioctxt the IO context to save a domain to
181 * @return 0 on success, -1 on failure
182 */
183 int xc_linux_save(int xc_handle, struct XcIOContext *ioctxt);
185 /**
186 * This function will restore a saved domain running Linux to an IO context.
187 * Like xc_linux_save(), this function uses a parameter who's structure is
188 * privately defined. It's interface will also likely change.
189 *
190 * @parm xc_handle a handle to an open hypervisor interface
191 * @parm ioctxt the IO context to restore a domain from
192 * @return 0 on success, -1 on failure
193 */
194 int xc_linux_restore(int xc_handle, struct XcIOContext *ioctxt);
196 int xc_linux_build(int xc_handle,
197 u32 domid,
198 const char *image_name,
199 const char *ramdisk_name,
200 const char *cmdline,
201 unsigned int control_evtchn,
202 unsigned long flags);
204 int
205 xc_plan9_build (int xc_handle,
206 u32 domid,
207 const char *image_name,
208 const char *cmdline,
209 unsigned int control_evtchn,
210 unsigned long flags);
212 int xc_bvtsched_global_set(int xc_handle,
213 unsigned long ctx_allow);
215 int xc_bvtsched_domain_set(int xc_handle,
216 u32 domid,
217 u32 mcuadv,
218 int warpback,
219 s32 warpvalue,
220 long long warpl,
221 long long warpu);
223 int xc_bvtsched_global_get(int xc_handle,
224 unsigned long *ctx_allow);
226 int xc_bvtsched_domain_get(int xc_handle,
227 u32 domid,
228 u32 *mcuadv,
229 int *warpback,
230 s32 *warpvalue,
231 long long *warpl,
232 long long *warpu);
234 int xc_atropos_domain_set(int xc_handle,
235 u32 domid,
236 u64 period, u64 slice, u64 latency,
237 int xtratime);
239 int xc_atropos_domain_get(int xc_handle,
240 u32 domid,
241 u64* period, u64 *slice, u64 *latency,
242 int *xtratime);
244 int xc_rrobin_global_set(int xc_handle, u64 slice);
246 int xc_rrobin_global_get(int xc_handle, u64 *slice);
248 typedef evtchn_status_t xc_evtchn_status_t;
250 /*\
251 * EVENT CHANNEL FUNCTIONS
252 \*/
254 /**
255 * This function allocates an unbound port. Ports are named endpoints used for
256 * interdomain communication. This function is most useful in opening a
257 * well-known port within a domain to receive events on.
258 *
259 * @parm xc_handle a handle to an open hypervisor interface
260 * @parm dom the ID of the domain. This maybe DOMID_SELF
261 * @parm port a pointer to a port. This is an in/out parameter. If *port is
262 * 0, then a new port will be assigned, if port is > 0 then that
263 * port is allocated if the port is unallocated.
264 * @return 0 on success, -1 on failure
265 */
266 int xc_evtchn_alloc_unbound(int xc_handle,
267 u32 dom,
268 int *port);
270 /**
271 * This function creates a pair of ports between two domains. A port can only
272 * be bound once within a domain.
273 *
274 * @parm xc_handle a handle to an open hypervisor interface
275 * @parm dom1 one of the two domains to connect. Can be DOMID_SELF.
276 * @parm dom2 the other domain to connect. Can be DOMID_SELF.
277 * @parm port1 an in/out parameter. If > 0, then try to connect *port. If
278 * 0, then allocate a new port and store the port in *port.
279 * @parm port2 the port connected on port2. This parameter behaves the same
280 * way as port1.
281 * @return 0 on success, -1 on error.
282 */
283 int xc_evtchn_bind_interdomain(int xc_handle,
284 u32 dom1,
285 u32 dom2,
286 int *port1,
287 int *port2);
288 int xc_evtchn_bind_virq(int xc_handle,
289 int virq,
290 int *port);
292 /**
293 * This function will close a single port on an event channel.
294 *
295 * @parm xc_handle a handle to an open hypervisor interface
296 * @parm dom the domain that the port exists on. May be DOMID_SELF.
297 * @parm port the port to close
298 * @return 0 on success, -1 on error
299 */
300 int xc_evtchn_close(int xc_handle,
301 u32 dom, /* may be DOMID_SELF */
302 int port);
304 /**
305 * This function generates a notify event on a bound port.
306 *
307 * Notifies can be read within Linux by opening /dev/xen/evtchn and reading
308 * a 16 bit value. The result will be the port the event occurred on. When
309 * events occur, the port is masked until the 16 bit port value is written back
310 * to the file. When /dev/xen/evtchn is opened, it has to be bound via an
311 * ioctl to each port to listen on. The ioctl for binding is _IO('E', 2). The
312 * parameter is the port to listen on.
313 *
314 * @parm xc_handle a handle to an open hypervisor interface
315 * @parm local_port the port to generate the notify on
316 * @return 0 on success, -1 on error
317 */
318 int xc_evtchn_send(int xc_handle,
319 int local_port);
320 int xc_evtchn_status(int xc_handle,
321 u32 dom, /* may be DOMID_SELF */
322 int port,
323 xc_evtchn_status_t *status);
325 int xc_physdev_pci_access_modify(int xc_handle,
326 u32 domid,
327 int bus,
328 int dev,
329 int func,
330 int enable);
332 int xc_readconsolering(int xc_handle,
333 char *str,
334 unsigned int max_chars,
335 int clear);
337 typedef dom0_physinfo_t xc_physinfo_t;
338 int xc_physinfo(int xc_handle,
339 xc_physinfo_t *info);
341 int xc_sched_id(int xc_handle,
342 int *sched_id);
344 int xc_domain_setinitialmem(int xc_handle,
345 u32 domid,
346 unsigned int initial_memkb);
348 int xc_domain_setmaxmem(int xc_handle,
349 u32 domid,
350 unsigned int max_memkb);
352 int xc_domain_setvmassist(int xc_handle,
353 u32 domid,
354 unsigned int cmd,
355 unsigned int type);
357 typedef dom0_perfc_desc_t xc_perfc_desc_t;
358 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
359 int xc_perfc_control(int xc_handle,
360 u32 op,
361 xc_perfc_desc_t *desc);
363 /**
364 * Memory maps a range within one domain to a local address range. Mappings
365 * should be unmapped with munmap and should follow the same rules as mmap
366 * regarding page alignment.
367 *
368 * In Linux, the ring queue for the control channel is accessible by mapping
369 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
370 * stored there is of type control_if_t.
371 *
372 * @parm xc_handle a handle on an open hypervisor interface
373 * @parm dom the domain to map memory from
374 * @parm size the amount of memory to map (in multiples of page size)
375 * @parm prot same flag as in mmap().
376 * @parm mfn the frame address to map.
377 */
378 void *xc_map_foreign_range(int xc_handle, u32 dom,
379 int size, int prot,
380 unsigned long mfn );
382 void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot,
383 unsigned long *arr, int num );
385 #endif /* __XC_H__ */