debuggers.hg

view tools/libxl/libxl.h @ 21067:b4a1832a916f

Update Xen version to 4.0.0-rc6
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 09 18:18:05 2010 +0000 (2010-03-09)
parents f300b53520d0
children fe30bd463e84
line source
1 /*
2 * Copyright (C) 2009 Citrix Ltd.
3 * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation; version 2.1 only. with the special
8 * exception on linking described in file LICENSE.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 */
15 #ifndef LIBXL_H
16 #define LIBXL_H
18 #include <stdint.h>
19 #include <stdarg.h>
20 #include <netinet/in.h>
21 #include <xenctrl.h>
22 #include <xs.h>
23 #include <sys/wait.h> /* for pid_t */
25 typedef void (*libxl_log_callback)(void *userdata, int loglevel, const char *file,
26 int line, const char *func, char *s);
27 struct libxl_dominfo {
28 uint8_t uuid[16];
29 uint32_t domid;
30 uint8_t dying:1;
31 uint8_t paused:1;
32 uint8_t running:1;
33 uint64_t max_memkb;
34 uint64_t cpu_time;
35 uint32_t vcpu_max_id;
36 uint32_t vcpu_online;
37 };
39 struct libxl_vminfo {
40 uint8_t uuid[16];
41 uint32_t domid;
42 };
44 struct libxl_ctx {
45 int xch;
46 struct xs_handle *xsh;
47 /* errors/debug buf */
48 void *log_userdata;
49 libxl_log_callback log_callback;
51 /* mini-GC */
52 int alloc_maxsize;
53 void **alloc_ptrs;
55 /* for callers who reap children willy-nilly; caller must only
56 * set this after libxl_init and before any other call - or
57 * may leave them untouched */
58 int (*waitpid_instead)(pid_t pid, int *status, int flags);
59 };
61 typedef struct {
62 bool hvm;
63 bool hap;
64 int ssidref;
65 char *name;
66 uint8_t uuid[16];
67 char **xsdata;
68 char **platformdata;
69 } libxl_domain_create_info;
71 typedef struct {
72 int timer_mode;
73 int hpet;
74 int vpt_align;
75 int max_vcpus;
76 int cur_vcpus;
77 uint32_t max_memkb;
78 uint32_t target_memkb;
79 uint32_t video_memkb;
80 uint32_t shadow_memkb;
81 const char *kernel;
82 int hvm;
83 union {
84 struct {
85 bool pae;
86 bool apic;
87 bool acpi;
88 bool nx;
89 bool viridian;
90 char *timeoffset;
91 } hvm;
92 struct {
93 uint32_t slack_memkb;
94 const char *cmdline;
95 const char *ramdisk;
96 const char *features;
97 } pv;
98 } u;
99 } libxl_domain_build_info;
101 typedef struct {
102 uint32_t store_port;
103 unsigned long store_mfn;
104 uint32_t console_port;
105 unsigned long console_mfn;
106 } libxl_domain_build_state;
108 typedef struct {
109 #define XL_SUSPEND_DEBUG 1
110 #define XL_SUSPEND_LIVE 2
111 int flags;
112 int (*suspend_callback)(void *, int);
113 } libxl_domain_suspend_info;
115 typedef enum {
116 XENFV = 1,
117 XENPV,
118 } libxl_qemu_machine_type;
120 typedef struct {
121 int domid;
122 uint8_t uuid[16]; /* this is use only with stubdom, and must be different from the domain uuid */
123 char *dom_name;
124 char *device_model;
125 char *saved_state;
126 libxl_qemu_machine_type type;
127 int videoram; /* size of the videoram in MB */
128 bool stdvga; /* stdvga enabled or disabled */
129 bool vnc; /* vnc enabled or disabled */
130 char *vnclisten; /* address:port that should be listened on for the VNC server if vnc is set */
131 int vncdisplay; /* set VNC display number */
132 bool vncunused; /* try to find an unused port for the VNC server */
133 char *keymap; /* set keyboard layout, default is en-us keyboard */
134 bool sdl; /* sdl enabled or disabled */
135 bool opengl; /* opengl enabled or disabled (if enabled requires sdl enabled) */
136 bool nographic; /* no graphics, use serial port */
137 char *serial; /* serial port re-direct to pty deivce */
138 char *boot; /* boot order, for example dca */
139 bool usb; /* usb support enabled or disabled */
140 char *usbdevice; /* enable usb mouse: tablet for absolute mouse, mouse for PS/2 protocol relative mouse */
141 bool apic; /* apic enabled or disabled */
142 char **extra; /* extra parameters pass directly to qemu, NULL terminated */
143 /* Network is missing */
144 } libxl_device_model_info;
146 typedef struct {
147 uint32_t backend_domid;
148 uint32_t domid;
149 int devid;
150 bool vnc; /* vnc enabled or disabled */
151 char *vnclisten; /* address:port that should be listened on for the VNC server if vnc is set */
152 int vncdisplay; /* set VNC display number */
153 bool vncunused; /* try to find an unused port for the VNC server */
154 char *keymap; /* set keyboard layout, default is en-us keyboard */
155 bool sdl; /* sdl enabled or disabled */
156 bool opengl; /* opengl enabled or disabled (if enabled requires sdl enabled) */
157 char *display;
158 char *xauthority;
159 } libxl_device_vfb;
161 typedef struct {
162 uint32_t backend_domid;
163 uint32_t domid;
164 int devid;
165 } libxl_device_vkb;
167 typedef enum {
168 CONSTYPE_XENCONSOLED,
169 CONSTYPE_IOEMU,
170 } libxl_console_constype;
172 typedef struct {
173 uint32_t backend_domid;
174 uint32_t domid;
175 int devid;
176 libxl_console_constype constype;
177 libxl_domain_build_state *build_state;
178 } libxl_device_console;
180 typedef enum {
181 PHYSTYPE_QCOW = 1,
182 PHYSTYPE_QCOW2,
183 PHYSTYPE_VHD,
184 PHYSTYPE_AIO,
185 PHYSTYPE_FILE,
186 PHYSTYPE_PHY,
187 } libxl_disk_phystype;
189 typedef struct {
190 uint32_t backend_domid;
191 uint32_t domid;
192 char *physpath;
193 libxl_disk_phystype phystype;
194 char *virtpath;
195 int unpluggable;
196 int readwrite;
197 int is_cdrom;
198 } libxl_device_disk;
200 typedef enum {
201 NICTYPE_IOEMU = 1,
202 NICTYPE_VIF,
203 } libxl_nic_type;
205 typedef struct {
206 uint32_t backend_domid;
207 uint32_t domid;
208 int devid;
209 int mtu;
210 char *model;
211 uint8_t mac[6];
212 struct in_addr ip;
213 char *bridge;
214 char *ifname;
215 char *script;
216 libxl_nic_type nictype;
217 } libxl_device_nic;
219 typedef struct {
220 union {
221 unsigned int value;
222 struct {
223 unsigned int reserved1:2;
224 unsigned int reg:6;
225 unsigned int func:3;
226 unsigned int dev:5;
227 unsigned int bus:8;
228 unsigned int reserved2:7;
229 unsigned int enable:1;
230 };
231 };
232 unsigned int domain;
233 unsigned int vdevfn;
234 bool msitranslate;
235 bool power_mgmt;
236 } libxl_device_pci;
238 enum {
239 ERROR_VERSION = -1,
240 ERROR_FAIL = -2,
241 ERROR_NI = -3,
242 ERROR_NOMEM = -4,
243 ERROR_INVAL = -5,
244 };
246 #define LIBXL_VERSION 0
248 /* context functions */
249 int libxl_ctx_init(struct libxl_ctx *ctx, int version);
250 int libxl_ctx_free(struct libxl_ctx *ctx);
251 int libxl_ctx_set_log(struct libxl_ctx *ctx, libxl_log_callback log_callback, void *log_data);
253 /* domain related functions */
254 int libxl_domain_make(struct libxl_ctx *ctx, libxl_domain_create_info *info, uint32_t *domid);
255 int libxl_domain_build(struct libxl_ctx *ctx, libxl_domain_build_info *info, uint32_t domid, /* out */ libxl_domain_build_state *state);
256 int libxl_domain_restore(struct libxl_ctx *ctx, libxl_domain_build_info *info,
257 uint32_t domid, int fd, libxl_domain_build_state *state,
258 libxl_device_model_info *dm_info);
259 int libxl_domain_suspend(struct libxl_ctx *ctx, libxl_domain_suspend_info *info,
260 uint32_t domid, int fd);
261 int libxl_domain_resume(struct libxl_ctx *ctx, uint32_t domid);
262 int libxl_domain_shutdown(struct libxl_ctx *ctx, uint32_t domid, int req);
263 int libxl_domain_destroy(struct libxl_ctx *ctx, uint32_t domid, int force);
265 /* events handling */
267 typedef enum {
268 DOMAIN_DEATH,
269 DISK_EJECT,
270 } libxl_event_type;
272 typedef struct {
273 /* event type */
274 libxl_event_type type;
275 /* data for internal use of the library */
276 char *path;
277 char *token;
278 } libxl_event;
280 typedef struct {
281 char *path;
282 char *token;
283 } libxl_waiter;
286 int libxl_get_wait_fd(struct libxl_ctx *ctx, int *fd);
287 /* waiter is allocated by the caller */
288 int libxl_wait_for_domain_death(struct libxl_ctx *ctx, uint32_t domid, libxl_waiter *waiter);
289 /* waiter is a preallocated array of num_disks libxl_waiter elements */
290 int libxl_wait_for_disk_ejects(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disks, int num_disks, libxl_waiter *waiter);
291 int libxl_get_event(struct libxl_ctx *ctx, libxl_event *event);
292 int libxl_stop_waiting(struct libxl_ctx *ctx, libxl_waiter *waiter);
293 int libxl_free_event(libxl_event *event);
294 int libxl_free_waiter(libxl_waiter *waiter);
296 int libxl_event_get_domain_death_info(struct libxl_ctx *ctx, uint32_t domid, libxl_event *event, xc_domaininfo_t *info);
297 int libxl_event_get_disk_eject_info(struct libxl_ctx *ctx, uint32_t domid, libxl_event *event, libxl_device_disk *disk);
300 int libxl_domain_pause(struct libxl_ctx *ctx, uint32_t domid);
301 int libxl_domain_unpause(struct libxl_ctx *ctx, uint32_t domid);
303 int libxl_set_memory_target(struct libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb);
305 int libxl_console_attach(struct libxl_ctx *ctx, uint32_t domid, int cons_num);
307 struct libxl_dominfo * libxl_list_domain(struct libxl_ctx *ctx, int *nb_domain);
308 struct libxl_vminfo * libxl_list_vm(struct libxl_ctx *ctx, int *nb_vm);
310 typedef struct libxl_device_model_starting libxl_device_model_starting;
311 int libxl_create_device_model(struct libxl_ctx *ctx,
312 libxl_device_model_info *info,
313 libxl_device_disk *disk, int num_disks,
314 libxl_device_nic *vifs, int num_vifs,
315 libxl_device_model_starting **starting_r);
316 int libxl_create_xenpv_qemu(struct libxl_ctx *ctx, libxl_device_vfb *vfb,
317 int num_console, libxl_device_console *console,
318 libxl_device_model_starting **starting_r);
319 /* Caller must either: pass starting_r==0, or on successful
320 * return pass *starting_r (which will be non-0) to
321 * libxl_confirm_device_model or libxl_detach_device_model. */
322 int libxl_confirm_device_model_startup(struct libxl_ctx *ctx,
323 libxl_device_model_starting *starting);
324 int libxl_detach_device_model(struct libxl_ctx *ctx,
325 libxl_device_model_starting *starting);
326 /* DM is detached even if error is returned */
328 int libxl_device_disk_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk);
329 int libxl_device_disk_del(struct libxl_ctx *ctx, libxl_device_disk *disk, int wait);
330 libxl_device_disk *libxl_device_disk_list(struct libxl_ctx *ctx, uint32_t domid, int *num);
331 int libxl_cdrom_insert(struct libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk);
333 int libxl_device_nic_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic);
334 int libxl_device_nic_del(struct libxl_ctx *ctx, libxl_device_nic *nic, int wait);
336 int libxl_device_console_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_console *console);
338 int libxl_device_vkb_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb);
339 int libxl_device_vkb_clean_shutdown(struct libxl_ctx *ctx, uint32_t domid);
340 int libxl_device_vkb_hard_shutdown(struct libxl_ctx *ctx, uint32_t domid);
342 int libxl_device_vfb_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb);
343 int libxl_device_vfb_clean_shutdown(struct libxl_ctx *ctx, uint32_t domid);
344 int libxl_device_vfb_hard_shutdown(struct libxl_ctx *ctx, uint32_t domid);
346 #define PCI_BDF "%04x:%02x:%02x.%01x"
347 #define PCI_BDF_VDEVFN "%04x:%02x:%02x.%01x@%02x"
348 int libxl_device_pci_add(struct libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev);
349 int libxl_device_pci_remove(struct libxl_ctx *ctx, uint32_t domid, libxl_device_pci *pcidev);
350 int libxl_device_pci_shutdown(struct libxl_ctx *ctx, uint32_t domid);
351 libxl_device_pci *libxl_device_pci_list(struct libxl_ctx *ctx, uint32_t domid, int *num);
352 int libxl_device_pci_init(libxl_device_pci *pcidev, unsigned int domain,
353 unsigned int bus, unsigned int dev,
354 unsigned int func, unsigned int vdevfn);
356 typedef enum {
357 POWER_BUTTON,
358 SLEEP_BUTTON
359 } libxl_button;
361 int libxl_button_press(struct libxl_ctx *ctx, uint32_t domid, libxl_button button);
363 #endif /* LIBXL_H */