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
16 /*
17 * libxl API compatibility
18 *
19 * From Xen 4.2 onwards the API of libxl will be maintained in a
20 * stable manner. This means that it should be possible to write an
21 * application against the API provided by libxl in Xen 4.2 and expect
22 * that it will continue to compile against future versions of Xen
23 * without source modification.
24 *
25 * In order to make such compatibility possible it is required that
26 * application which want to be exposed to a particular API #define
27 * LIBXL_API_VERSION before including libxl.h or any other libxl
28 * header. The syntax of the LIBXL_API_VERSION is:
29 * 0xVVSSEE
30 * where ($(XEN_xxx) from xen/Makefile):
31 * VV is the Xen major release number, $(XEN_VERSION)
32 * SS is the Xen sub version number, $(XEN_SUBVERSION)
33 * EE is the Xen extra version digit, first numeric part of
34 * $(XEN_EXTRAVERSION) not including the leading "."
35 * For example the first stable API version, supported by Xen 4.2.0,
36 * is 0x040200.
37 *
38 * Lack of LIBXL_API_VERSION means "the latest" which will
39 * change. Specifying an unknown LIBXL_API_VERSION will result in a
40 * compile time error.
41 *
42 * Identical versions of the libxl API will represented by the version
43 * containing the earliest instance of that API. e.g. if 4.2.0 and
44 * 4.3.0 contain an identical libxl API then only LIBXL_API_VERSION
45 * 0x040200 will be valid.
46 *
47 * We will try especially hard to avoid changing the API during a
48 * stable series, i.e. it should be unusual for the last byte of
49 * LIBXL_API_VERSION to be non-zero.
50 *
51 * In the event that a change is required which cannot be made
52 * backwards compatible in this manner a #define of the form
53 * LIBXL_HAVE_<interface> will always be added in order to make it
54 * possible to write applications which build against any version of
55 * libxl. Such changes are expected to be exceptional and used as a
56 * last resort. The barrier for backporting such a change to a stable
57 * branch will be very high.
58 *
59 * These guarantees apply only to stable releases of Xen. When an
60 * incompatible change is made in the unstable tree then
61 * LIBXL_API_VERSION will be bumped to the next expected stable
62 * release number on the first such change only. Applications which
63 * want to support building against Xen unstable are expected to track
64 * API changes in that tree until it is released as a stable release.
65 *
66 * API compatibility will be maintained for all versions of Xen using
67 * the same $(XEN_VERSION) (e.g. throughout a major release).
68 */
69
70 /* LIBXL_HAVE_PHYSINFO_CAP_PV
71 *
72 * If this is defined, libxl_physinfo has a "cap_pv" field.
73 */
74 #define LIBXL_HAVE_PHYSINFO_CAP_PV 1
75
76 /* LIBXL_HAVE_CONSOLE_NOTIFY_FD
77 *
78 * If this is defined, libxl_console_exec and
79 * libxl_primary_console_exe take a notify_fd parameter. That
80 * parameter will be used to notify the caller that the console is connected.
81 */
82 #define LIBXL_HAVE_CONSOLE_NOTIFY_FD 1
83
84 /* LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS
85 *
86 * If this is defined, the copy functions have constified src parameter and the
87 * length functions accept constified parameter.
88 */
89 #define LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS 1
90
91 /* LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO
92 *
93 * If this is defined, libxl_domain_need_memory no longer modifies
94 * the b_info paseed in.
95 */
96 #define LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO 1
97
98 /* LIBXL_HAVE_VNUMA
99 *
100 * If this is defined the type libxl_vnode_info exists, and a
101 * field 'vnuma_nodes' is present in libxl_domain_build_info.
102 */
103 #define LIBXL_HAVE_VNUMA 1
104
105 /* LIBXL_HAVE_USERDATA_UNLINK
106 *
107 * If it is defined, libxl has a library function called
108 * libxl_userdata_unlink.
109 */
110 #define LIBXL_HAVE_USERDATA_UNLINK 1
111
112 /* LIBXL_HAVE_CPUPOOL_QUALIFIER_TO_CPUPOOLID
113 *
114 * If this is defined, libxl has a library function called
115 * libxl_cpupool_qualifier_to_cpupoolid, which takes in a CPU pool
116 * qualifier in the form of number or string, then returns the ID of
117 * that CPU pool.
118 */
119 #define LIBXL_HAVE_CPUPOOL_QUALIFIER_TO_CPUPOOLID 1
120
121 /* LIBXL_HAVE_CPUPOOL_ADD_REM_CPUMAP
122 *
123 * If this is defined, libxl has two library functions called
124 * libxl_cpupool_cpuadd_cpumap and libxl_cpupool_cpuremove_cpumap,
125 * which allow to add to or remove from a cpupool all the cpus
126 * specified in a bitmap.
127 */
128 #define LIBXL_HAVE_CPUPOOL_ADD_REM_CPUMAP 1
129
130 /*
131 *
132 * LIBXL_HAVE_BITMAP_AND_OR
133 *
134 * If this is defined, libxl has two library functions, libxl_bitmap_and
135 * and libxl_bitmap_or to compute the logical and and or of two bitmaps
136 */
137 #define LIBXL_HAVE_BITMAP_AND_OR 1
138
139 /*
140 * LIBXL_HAVE_FIRMWARE_PASSTHROUGH indicates the feature for
141 * passing in SMBIOS and ACPI firmware to HVM guests is present
142 * in the library.
143 */
144 #define LIBXL_HAVE_FIRMWARE_PASSTHROUGH 1
145
146 /*
147 * LIBXL_HAVE_DOMAIN_NODEAFFINITY indicates that a 'nodemap' field
148 * (of libxl_bitmap type) is present in libxl_domain_build_info,
149 * containing the node-affinity for the domain.
150 */
151 #define LIBXL_HAVE_DOMAIN_NODEAFFINITY 1
152
153 /*
154 * LIBXL_HAVE_PVUSB indicates functions for plugging in USB devices
155 * through pvusb -- both hotplug and at domain creation time..
156 */
157 #define LIBXL_HAVE_PVUSB 1
158
159 /*
160 * LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE indicates that the
161 * libxl_vendor_device field is present in the hvm sections of
162 * libxl_domain_build_info. This field tells libxl which
163 * flavour of xen-pvdevice to enable in QEMU.
164 */
165 #define LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE 1
166
167 /*
168 * The libxl_domain_build_info has the event_channels field.
169 */
170 #define LIBXL_HAVE_BUILDINFO_EVENT_CHANNELS 1
171
172 /*
173 * libxl_domain_build_info has the u.hvm.ms_vm_genid field.
174 */
175 #define LIBXL_HAVE_BUILDINFO_HVM_MS_VM_GENID 1
176
177 /*
178 * LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY indicates that a 'cpumap_soft'
179 * field (of libxl_bitmap type) is present in libxl_vcpuinfo,
180 * containing the soft affinity of a vcpu.
181 */
182 #define LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY 1
183
184 /*
185 * LIBXL_HAVE_SET_VCPUAFFINITY_FORCE indicates that the
186 * libxl_set_vcpuaffinity_force() library call is available.
187 */
188 #define LIBXL_HAVE_SET_VCPUAFFINITY_FORCE 1
189
190 /*
191 * LIBXL_HAVE_DEVICE_DISK_DIRECT_IO_SAFE indicates that a
192 * 'direct_io_safe' field (of boolean type) is present in
193 * libxl_device_disk.
194 */
195 #define LIBXL_HAVE_DEVICE_DISK_DIRECT_IO_SAFE 1
196
197 /*
198 * The libxl_device_disk has the discard_enable field.
199 */
200 #define LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE 1
201
202 /*
203 * LIBXL_HAVE_BUILDINFO_IOMEM_START_GFN indicates that it is possible
204 * to specify the start guest frame number used to map a range of I/O
205 * memory machine frame numbers via the 'gfn' field (of type uint64)
206 * of the 'iomem' structure. An array of iomem structures is embedded
207 * in libxl_domain_build_info and used to map the indicated memory
208 * ranges during domain build.
209 */
210 #define LIBXL_HAVE_BUILDINFO_IOMEM_START_GFN 1
211
212 /*
213 * LIBXL_HAVE_SCHED_RTDS indicates that the RTDS real time scheduler
214 * is available. A 'budget' field added in libxl_domain_sched_params.
215 */
216 #define LIBXL_HAVE_SCHED_RTDS 1
217
218 /*
219 * LIBXL_HAVE_SCHED_NULL indicates that the 'null' static scheduler
220 * is available.
221 */
222 #define LIBXL_HAVE_SCHED_NULL 1
223
224 /*
225 * libxl_domain_build_info has u.hvm.viridian_enable and _disable bitmaps
226 * of the specified width.
227 */
228 #define LIBXL_HAVE_BUILDINFO_HVM_VIRIDIAN_ENABLE_DISABLE 1
229 #define LIBXL_BUILDINFO_HVM_VIRIDIAN_ENABLE_DISABLE_WIDTH 64
230
231 /*
232 * libxl_domain_build_info has the u.hvm.mmio_hole_memkb field.
233 */
234 #define LIBXL_HAVE_BUILDINFO_HVM_MMIO_HOLE_MEMKB 1
235
236 /*
237 * libxl_domain_info returns ERROR_DOMAIN_NOTFOUND if the domain
238 * is not present, instead of ERROR_INVAL.
239 */
240 #define LIBXL_HAVE_ERROR_DOMAIN_NOTFOUND 1
241
242 /*
243 * libxl_domain_build_info has device_tree and libxl_device_dtdev
244 * exists. This mean Device Tree passthrough is supported for ARM
245 */
246 #define LIBXL_HAVE_DEVICETREE_PASSTHROUGH 1
247
248 /*
249 * libxl_domain_build_info has device_model_user to specify the user to
250 * run the device model with. See docs/misc/qemu-deprivilege.txt.
251 */
252 #define LIBXL_HAVE_DEVICE_MODEL_USER 1
253
254 /*
255 * libxl_vcpu_sched_params is used to store per-vcpu params.
256 */
257 #define LIBXL_HAVE_VCPU_SCHED_PARAMS 1
258
259 /*
260 * LIBXL_HAVE_SCHED_RTDS_VCPU_PARAMS indicates RTDS scheduler
261 * now supports per-vcpu settings.
262 */
263 #define LIBXL_HAVE_SCHED_RTDS_VCPU_PARAMS 1
264
265 /*
266 * LIBXL_HAVE_SCHED_RTDS_VCPU_EXTRA indicates RTDS scheduler
267 * now supports per-vcpu extratime settings.
268 */
269 #define LIBXL_HAVE_SCHED_RTDS_VCPU_EXTRA 1
270
271 /*
272 * libxl_domain_build_info has the arm.gic_version field.
273 */
274 #define LIBXL_HAVE_BUILDINFO_ARM_GIC_VERSION 1
275
276 /*
277 * libxl_domain_build_info has the arch_arm.tee field.
278 */
279 #define LIBXL_HAVE_BUILDINFO_ARCH_ARM_TEE 1
280
281 /*
282 * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing
283 * 'soft reset' for domains and there is 'soft_reset' shutdown reason
284 * in enum libxl_shutdown_reason.
285 */
286 #define LIBXL_HAVE_SOFT_RESET 1
287
288 /*
289 * LIBXL_HAVE_APIC_ASSIST indicates that the 'apic_assist' value
290 * is present in the viridian enlightenment enumeration.
291 */
292 #define LIBXL_HAVE_APIC_ASSIST 1
293
294 /*
295 * LIBXL_HAVE_BUILD_ID means that libxl_version_info has the extra
296 * field for the hypervisor build_id.
297 */
298 #define LIBXL_HAVE_BUILD_ID 1
299
300 /*
301 * LIBXL_HAVE_QEMU_MONITOR_COMMAND indiactes the availability of the
302 * libxl_qemu_monitor_command() function.
303 */
304 #define LIBXL_HAVE_QEMU_MONITOR_COMMAND 1
305
306 /*
307 * LIBXL_HAVE_SCHED_CREDIT2_PARAMS indicates the existance of a
308 * libxl_sched_credit2_params structure, containing Credit2 scheduler
309 * wide parameters (i.e., the ratelimiting value).
310 */
311 #define LIBXL_HAVE_SCHED_CREDIT2_PARAMS 1
312
313 /*
314 * LIBXL_HAVE_SCHED_CREDIT_MIGR_DELAY indicates that there is a field
315 * in libxl_sched_credit_params called vcpu_migr_delay_us which controls
316 * the resistance of the vCPUs of the cpupool to migrations among pCPUs.
317 */
318 #define LIBXL_HAVE_SCHED_CREDIT_MIGR_DELAY
319
320 /*
321 * LIBXL_HAVE_VIRIDIAN_CRASH_CTL indicates that the 'crash_ctl' value
322 * is present in the viridian enlightenment enumeration.
323 */
324 #define LIBXL_HAVE_VIRIDIAN_CRASH_CTL 1
325
326 /*
327 * LIBXL_HAVE_VIRIDIAN_SYNIC indicates that the 'synic' value
328 * is present in the viridian enlightenment enumeration.
329 */
330 #define LIBXL_HAVE_VIRIDIAN_SYNIC 1
331
332 /*
333 * LIBXL_HAVE_VIRIDIAN_STIMER indicates that the 'stimer' value
334 * is present in the viridian enlightenment enumeration.
335 */
336 #define LIBXL_HAVE_VIRIDIAN_STIMER 1
337
338 /*
339 * LIBXL_HAVE_VIRIDIAN_HCALL_IPI indicates that the 'hcall_ipi' value
340 * is present in the viridian enlightenment enumeration.
341 */
342 #define LIBXL_HAVE_VIRIDIAN_HCALL_IPI 1
343
344 /*
345 * LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE indicates that
346 * libxl_domain_build_info has the u.hvm.acpi_laptop_slate field.
347 */
348 #define LIBXL_HAVE_BUILDINFO_HVM_ACPI_LAPTOP_SLATE 1
349
350 /*
351 * LIBXL_HAVE_P9S indicates that the p9 field in IDL has been changed to p9s
352 */
353 #define LIBXL_HAVE_P9S 1
354
355 /*
356 * LIBXL_HAVE_BUILDINFO_ARM_VUART indicates that the toolstack supports virtual UART
357 * for ARM.
358 */
359 #define LIBXL_HAVE_BUILDINFO_ARM_VUART 1
360
361 /*
362 * LIBXL_HAVE_BUILDINFO_GRANT_LIMITS indicates that libxl_domain_build_info
363 * has the max_grant_frames and max_maptrack_frames fields.
364 */
365 #define LIBXL_HAVE_BUILDINFO_GRANT_LIMITS 1
366
367 #define LIBXL_MAX_GRANT_DEFAULT (~(uint32_t)0)
368 #define LIBXL_MAX_GRANT_FRAMES_DEFAULT 32 /* deprecated */
369 #define LIBXL_MAX_MAPTRACK_FRAMES_DEFAULT 1024 /* deprecated */
370 /*
371 * LIBXL_HAVE_BUILDINFO_GRANT_DEFAULT indicates that the default
372 * values of max_grant_frames and max_maptrack_frames fields in
373 * libxl_domain_build_info are the special sentinel value
374 * LIBXL_MAX_GRANT_DEFAULT rather than the fixed values above.
375 * This means to use the hypervisor's default.
376 */
377 #define LIBXL_HAVE_BUILDINFO_GRANT_DEFAULT 1
378
379 /*
380 * LIBXL_HAVE_BUILDINFO_* indicates that libxl_domain_build_info has
381 * the field represented by the '*'. The original position of those
382 * fields is:
383 * - u.hvm.timer_mode
384 * - u.hvm.apic
385 * - u.hvm.nested_hvm
386 * - u.pv.bootloader
387 * - u.pv.bootloader_args
388 */
389 #define LIBXL_HAVE_BUILDINFO_TIMER_MODE 1
390 #define LIBXL_HAVE_BUILDINFO_APIC 1
391 #define LIBXL_HAVE_BUILDINFO_NESTED_HVM 1
392 #define LIBXL_HAVE_BUILDINFO_BOOTLOADER 1
393 #define LIBXL_HAVE_BUILDINFO_BOOTLOADER_ARGS 1
394
395 /*
396 * LIBXL_HAVE_EXTENDED_VKB indicates that libxl_device_vkb has extended fields:
397 * - unique_id;
398 * - feature_disable_keyboard;
399 * - feature_disable_pointer;
400 * - feature_abs_pointer;
401 * - feature_raw_pointer;
402 * - feature_multi_touch;
403 * - width;
404 * - height;
405 * - multi_touch_width;
406 * - multi_touch_height;
407 * - multi_touch_num_contacts.
408 */
409 #define LIBXL_HAVE_EXTENDED_VKB 1
410
411 /*
412 * LIBXL_HAVE_PHYSINFO_CAP_HAP_SHADOW indicates that libxl_physinfo has
413 * cap_hap and cap_shadow fields reflecting the hardware and Xen availability
414 * of Hardware Assisted, and Shadow paging support.
415 */
416 #define LIBXL_HAVE_PHYSINFO_CAP_HAP_SHADOW 1
417
418 /*
419 * LIBXL_HAVE_PHYSINFO_CAP_IOMMU_HAP_PT_SHARE indicates that libxl_physinfo
420 * has a cap_iommu_hap_pt_share field that indicates whether the hardware
421 * supports sharing the IOMMU and HAP page tables.
422 */
423 #define LIBXL_HAVE_PHYSINFO_CAP_IOMMU_HAP_PT_SHARE 1
424
425 /*
426 * LIBXL_HAVE_BUILDINFO_IOMMU_MEMKB indicates thate libxl_domain_build_info
427 * has an iommu_memkb field which should be set with the amount of memory
428 * overhead needed by the domain for populating IOMMU page tables.
429 */
430 #define LIBXL_HAVE_BUILDINFO_IOMMU_MEMKB 1
431
432 /*
433 * LIBXL_HAVE_CREATEINFO_PASSTHROUGH indicates that
434 * libxl_domain_create_info has a passthrough field (which is a
435 * libxl_passthrough enumeration) that indicates whether device pass-
436 * through is enabled for the domain and, if so, whether the IOMMU and
437 * HAP page tables may be shared or not.
438 */
439 #define LIBXL_HAVE_CREATEINFO_PASSTHROUGH 1
440
441 /*
442 * libxl ABI compatibility
443 *
444 * The only guarantee which libxl makes regarding ABI compatibility
445 * across releases is that the SONAME will always be bumped whenever
446 * the ABI is changed in an incompatible way.
447 *
448 * This applies within stable branches as well as
449 * development branches. It is possible that a new stable release of
450 * Xen may require a rebuild of applications using the
451 * library. However per the API compatibility gaurantees such a
452 * rebuild should not normally require any source level changes.
453 *
454 * As with the API compatiblity the SONAME will only be bumped for the
455 * first ABI incompatible change in a development branch.
456 */
457
458 /*
459 * libxl memory management
460 *
461 * From the point of view of the application (ie, libxl's caller),
462 * struct libxl_ctx* is threadsafe, and all returned allocated
463 * structures are obtained from malloc(), and must be freed by the
464 * caller either directly or by calling an appropriate free function
465 * provided by libxl. Ie the application does not get automatic
466 * assistance from libxl in managing these allocations.
467 *
468 * Specific details are in the header comments which should be found
469 * in libxl.h or libxlutil.h, next to the relevant function
470 * declarations.
471 *
472 * Internally, libxl has a garbage collection scheme which allows much libxl
473 * code to allocate strings etc. for internal use without needing to
474 * free them. These are called "temporary allocations".
475 *
476 * The pool for these temporary allocations, along with any other
477 * thread-specific data which is private to libxl but shared between
478 * libxl functions (such as the current xenstore transaction), is
479 * stored in the "gc context" which is a special enhanced context
480 * structure allocated automatically by convenience macros at every
481 * entry to libxl.
482 *
483 * Every libxl function falls into one of these categories:
484 *
485 * 1. Public functions (declared in libxl.h, libxlutil.h), which may
486 * be called by libxl applications. If a public function returns
487 * any allocated object to its caller, that object must have come
488 * from malloc.
489 *
490 * The definitions of public functions MUST use the gc context
491 * initialisation macros (or do the equivalent work themselves).
492 * These macros will ensure that all temporary allocations will be
493 * automatically freed before the function returns to its caller.
494 *
495 * A public function may be called from within libxl; the call
496 * context initialisation macros will make sure that the internal
497 * caller's context is reused (eg, so that the same xenstore
498 * transaction is used). But in-libxl callers of libxl public
499 * functions should note that any libxl public function may cause
500 * recursively reentry into libxl via the application's event
501 * callback hook.
502 *
503 * Public functions have names like libxl_foobar.
504 *
505 * 2. Private functions, which may not be called by libxl
506 * applications; they are not declared in libxl.h or libxlutil.h
507 * and they may not be called other than by other libxl functions.
508 *
509 * Private functions should not use the gc context initialisation
510 * macros.
511 *
512 * Private functions have names like libxl__foobar (NB, two underscores).
513 * Also the declaration of such functions must be preceeded by the _hidden
514 * macro.
515 *
516 * Allocations made by a libxl function fall into one of the following
517 * categories (where "object" includes any memory allocation):
518 *
519 * (a) Objects which are not returned to the function's caller.
520 * These should be allocated from the temporary pool.
521 *
522 * (b) Objects which are intended for return to the calling
523 * application. This includes all allocated objects returned by
524 * any public function.
525 *
526 * It may also include objects allocated by an internal function
527 * specifically for eventual return by the function's external
528 * callers, but this situation should be clearly documented in
529 * comments.
530 *
531 * These should be allocated from malloc() et al. and comments
532 * near the function declaration should explain the memory
533 * ownership. If a simple free() by the application is not
534 * sufficient, a suitable public freeing function should be
535 * provided.
536 *
537 * (c) Internal objects whose size and/or lifetime dictate explicit
538 * memory management within libxl. This includes objects which
539 * will be embedded in opaque structures which will be returned to
540 * the libxl caller (more generally, any internal object whose
541 * lifetime exceeds the libxl entrypoint which creates it) and
542 * objects which are so large or numerous that explicit memory
543 * management is required.
544 *
545 * These should be allocated from malloc() et al., and freed
546 * explicitly at the appropriate point. The situation should be
547 * documented in comments.
548 *
549 * (d) Objects which are allocated by internal-only functions and
550 * returned to the function's (therefore, internal) caller but are
551 * strictly for internal use by other parts of libxl. These
552 * should be allocated from the temporary pool.
553 *
554 * Where a function's primary purpose is to return such an object,
555 * it should have a libxl__gc * as it's first argument.
556 *
557 * Note that there are two ways to change an allocation from this
558 * category to the "public" category. Either the implementation
559 * is kept internal and a wrapper function duplicates all memory
560 * allocations so that they are suitable for return to external
561 * callers or the implementation uses plain malloc() et al calls
562 * and an internal wrapper adds the relevant pointers to the gc.
563 * The latter method is preferred for obvious performance reasons.
564 *
565 * No temporary objects allocated from the pool may be explicitly freed.
566 * Therefore public functions which initialize a libxl__gc MUST call
567 * libxl__free_all() before returning.
568 *
569 * Memory allocation failures are not handled gracefully. If malloc
570 * (or realloc) fails, libxl will cause the entire process to print
571 * a message to stderr and exit with status 255.
572 */
573 /*
574 * libxl types
575 *
576 * Most libxl types are defined by the libxl IDL (see
577 * libxl_types.idl). The library provides a common set of methods for
578 * initialising and freeing these types.
579 *
580 * IDL-generated libxl types should be used as follows: the user must
581 * always call the "init" function before using a type, even if the
582 * variable is simply being passed by reference as an out parameter
583 * to a libxl function. The user must always calls "dispose" exactly
584 * once afterwards, to clean up, regardless of whether operations on
585 * this object succeeded or failed. See the xl code for examples.
586 *
587 * "init" and "dispose" are idempotent.
588 *
589 * void libxl_<type>_init(<type> *p):
590 *
591 * Initialises the members of "p" to all defaults. These may either
592 * be special value which indicates to the library that it should
593 * select an appropriate default when using this field or actual
594 * default values.
595 *
596 * Some fields within a data type (e.g. unions) cannot be sensibly
597 * initialised without further information. In these cases a
598 * separate subfield initialisation function is provided (see
599 * below).
600 *
601 * An instance which has been initialised using this method can
602 * always be safely passed to the dispose function (see
603 * below). This is true even if the data type contains fields which
604 * require a separate call to a subfield initialisation function.
605 *
606 * This method is provided for any aggregate type which is used as
607 * an input parameter.
608 *
609 * void libxl_<type>_init_<subfield>(<type> *p, subfield):
610 *
611 * Initialise those parts of "p" which are not initialised by the
612 * main init function due to the unknown value of "subfield". Sets
613 * p->subfield as well as initialising any fields to their default
614 * values.
615 *
616 * p->subfield must not have been previously initialised.
617 *
618 * This method is provided for any aggregate type.
619 *
620 * void libxl_<type>_dispose(instance *p):
621 *
622 * Frees any dynamically allocated memory used by the members of
623 * "p" but not the storage used by "p" itself (this allows for the
624 * allocation of arrays of types and for the composition of types).
625 *
626 * char *libxl_<type>_to_json(instance *p)
627 *
628 * Generates a JSON object from "p" in the form of a NULL terminated
629 * string.
630 *
631 * <type *> libxl_<type>_from_json(const char *json)
632 * int libxl_<type>_from_json(const char *json)
633 *
634 * Parses "json" and returns:
635 *
636 * an int value, if <type> is enumeration type. The value is the enum value
637 * representing the respective string in "json".
638 *
639 * an instance of <type>, if <type> is aggregate type. The returned
640 * instance has its fields filled in by the parser according to "json".
641 *
642 * If the parsing fails, caller cannot rely on the value / instance
643 * returned.
644 */
645 #ifndef LIBXL_H
646 #define LIBXL_H
647
648 #include <stdbool.h>
649 #include <stdint.h>
650 #include <stdarg.h>
651 #include <string.h>
652 #include <errno.h>
653 #include <netinet/in.h>
654 #include <sys/wait.h> /* for pid_t */
655
656 #include <xentoollog.h>
657
658 typedef struct libxl__ctx libxl_ctx;
659
660 #include <libxl_uuid.h>
661 #include <_libxl_list.h>
662
663 /* API compatibility. */
664 #ifdef LIBXL_API_VERSION
665 #if LIBXL_API_VERSION != 0x040200 && LIBXL_API_VERSION != 0x040300 && \
666 LIBXL_API_VERSION != 0x040400 && LIBXL_API_VERSION != 0x040500 && \
667 LIBXL_API_VERSION != 0x040700 && LIBXL_API_VERSION != 0x040800 && \
668 LIBXL_API_VERSION != 0x041300 && LIBXL_API_VERSION != 0x041400
669 #error Unknown LIBXL_API_VERSION
670 #endif
671 #endif
672
673 /* LIBXL_HAVE_RETRIEVE_DOMAIN_CONFIGURATION
674 *
675 * If this is defined we have libxl_retrieve_domain_configuration which
676 * returns the current configuration of a domain, which can be used to
677 * rebuild a domain.
678 */
679 #define LIBXL_HAVE_RETRIEVE_DOMAIN_CONFIGURATION 1
680
681 /*
682 * LIBXL_HAVE_BUILDINFO_VCPU_AFFINITY_ARRAYS
683 *
684 * If this is defined, then the libxl_domain_build_info structure will
685 * contain two arrays of libxl_bitmap-s, with all the necessary information
686 * to set the hard affinity (vcpu_hard_affinity) and the soft affinity
687 * (vcpu_soft_affinity) of the VCPUs.
688 *
689 * Note that, if the vcpu_hard_affinity array is used, libxl will ignore
690 * the content of the cpumap field of libxl_domain_build_info. That is to
691 * say, if the array is allocated and used by the caller, it is it and
692 * only it that determines the hard affinity of the domain's VCPUs.
693 *
694 * The number of libxl_bitmap-s in the arrays should be equal to the
695 * maximum number of VCPUs of the domain. If there only are N elements in
696 * an array, with N smaller the the maximum number of VCPUs, the hard or
697 * soft affinity (depending on which array we are talking about) will be
698 * set only for the first N VCPUs. The other VCPUs will just have affinity,
699 * both hard and soft, with all the host PCPUs.
700 * Each bitmap should be big enough to accommodate the maximum number of
701 * PCPUs of the host.
702 */
703 #define LIBXL_HAVE_BUILDINFO_VCPU_AFFINITY_ARRAYS 1
704
705 /*
706 * LIBXL_HAVE_BUILDINFO_VKB_DEVICE
707 *
708 * If this is defined, then the libxl_domain_build_info structure will
709 * contain a boolean hvm.vkb_device which instructs libxl whether to include
710 * a vkbd at build time or not.
711 */
712 #define LIBXL_HAVE_BUILDINFO_VKB_DEVICE 1
713
714 /*
715 * LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
716 *
717 * If this is defined, then the libxl_domain_build_info structure will
718 * contain hvm.usbdevice_list, a libxl_string_list type that contains
719 * a list of USB devices to specify on the qemu command-line.
720 *
721 * If it is set, callers may use either hvm.usbdevice or
722 * hvm.usbdevice_list, but not both; if both are set, libxl will
723 * throw an error.
724 *
725 * If this is not defined, callers can only use hvm.usbdevice. Note
726 * that this means only one device can be added at domain build time.
727 */
728 #define LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST 1
729
730 /*
731 * LIBXL_HAVE_BUILDINFO_USBVERSION
732 *
733 * If this is defined, then the libxl_domain_build_info structure will
734 * contain hvm.usbversion, a integer type that contains a USB
735 * controller version to specify on the qemu upstream command-line.
736 *
737 * If it is set, callers may use hvm.usbversion to specify if the usb
738 * controller is usb1, usb2 or usb3.
739 *
740 * If this is not defined, the hvm.usbversion field does not exist.
741 */
742 #define LIBXL_HAVE_BUILDINFO_USBVERSION 1
743
744 /*
745 * LIBXL_HAVE_DEVICE_BACKEND_DOMNAME
746 *
747 * If this is defined, libxl_device_* structures containing a backend_domid
748 * field also contain a backend_domname field. If backend_domname is set, it is
749 * resolved to a domain ID when the device is used and takes precedence over the
750 * backend_domid field.
751 *
752 * If this is not defined, the backend_domname field does not exist.
753 */
754 #define LIBXL_HAVE_DEVICE_BACKEND_DOMNAME 1
755
756 /*
757 * LIBXL_HAVE_NONCONST_EVENT_OCCURS_EVENT_ARG
758 *
759 * This argument was erroneously "const" in the 4.2 release despite
760 * the requirement for the callback to free the event.
761 */
762 #if LIBXL_API_VERSION != 0x040200
763 #define LIBXL_HAVE_NONCONST_EVENT_OCCURS_EVENT_ARG 1
764 #endif
765
766 /*
767 * LIBXL_HAVE_NONCONST_LIBXL_BASENAME_RETURN_VALUE
768 *
769 * The return value of libxl_basename is malloc'ed but the erroneously
770 * marked as "const" in releases before 4.5.
771 */
772 #if !defined(LIBXL_API_VERSION) || LIBXL_API_VERSION >= 0x040500
773 #define LIBXL_HAVE_NONCONST_LIBXL_BASENAME_RETURN_VALUE 1
774 #endif
775
776 /*
777 * LIBXL_HAVE_PHYSINFO_OUTSTANDING_PAGES
778 *
779 * If this is defined, libxl_physinfo structure will contain an uint64 field
780 * called outstanding_pages, containing the number of pages claimed but not
781 * yet allocated for all domains.
782 */
783 #define LIBXL_HAVE_PHYSINFO_OUTSTANDING_PAGES 1
784
785 /*
786 * LIBXL_HAVE_PHYSINFO_MAX_POSSIBLE_MFN
787 *
788 * If this is defined, libxl_physinfo structure will contain an uint64 field
789 * called max_possible_mfn, containing the highest possible mfn on this host,
790 * possibly taking memory hotplug into account.
791 */
792 #define LIBXL_HAVE_PHYSINFO_MAX_POSSIBLE_MFN 1
793
794 /*
795 * LIBXL_HAVE_DOMINFO_OUTSTANDING_MEMKB 1
796 *
797 * If this is defined, libxl_dominfo will contain a MemKB type field called
798 * outstanding_memkb, containing the amount of claimed but not yet allocated
799 * memory for a specific domain.
800 */
801 #define LIBXL_HAVE_DOMINFO_OUTSTANDING_MEMKB 1
802
803 /*
804 * LIBXL_HAVE_DOMINFO_NEVER_STOP
805 *
806 * If this is defined, libxl_dominfo will contain a flag called never_stop
807 * indicating that the specific domain should never be stopped by the
808 * toolstack.
809 */
810 #define LIBXL_HAVE_DOMINFO_NEVER_STOP 1
811
812 /*
813 * LIBXL_HAVE_QXL
814 *
815 * If defined, then the libxl_vga_interface_type will contain another value:
816 * "QXL". This value define if qxl vga is supported.
817 *
818 * If this is not defined, the qxl vga support is missed.
819 */
820 #define LIBXL_HAVE_QXL 1
821
822 /*
823 * LIBXL_HAVE_SPICE_VDAGENT
824 *
825 * If defined, then the libxl_spice_info structure will contain a boolean type:
826 * vdagent and clipboard_sharing. These values define if Spice vdagent and
827 * clipboard sharing are enabled.
828 *
829 * If this is not defined, the Spice vdagent support is ignored.
830 */
831 #define LIBXL_HAVE_SPICE_VDAGENT 1
832
833 /*
834 * LIBXL_HAVE_SPICE_USBREDIRECTION
835 *
836 * If defined, then the libxl_spice_info structure will contain an integer type
837 * field: usbredirection. This value defines if Spice usbredirection is enabled
838 * and with how much channels.
839 *
840 * If this is not defined, the Spice usbredirection support is ignored.
841 */
842 #define LIBXL_HAVE_SPICE_USBREDIREDIRECTION 1
843
844 /*
845 * LIBXL_HAVE_SPICE_IMAGECOMPRESSION
846 *
847 * If defined, then the libxl_spice_info structure will contain a string type
848 * field: image_compression. This value defines what Spice image compression
849 * is used.
850 *
851 * If this is not defined, the Spice image compression setting support is ignored.
852 */
853 #define LIBXL_HAVE_SPICE_IMAGECOMPRESSION 1
854
855 /*
856 * LIBXL_HAVE_SPICE_STREAMINGVIDEO
857 *
858 * If defined, then the libxl_spice_info structure will contain a string type
859 * field: streaming_video. This value defines what Spice streaming video setting
860 * is used.
861 *
862 * If this is not defined, the Spice streaming video setting support is ignored.
863 */
864 #define LIBXL_HAVE_SPICE_STREAMINGVIDEO 1
865
866 /*
867 * LIBXL_HAVE_HVM_HDTYPE
868 *
869 * If defined, then the u.hvm structure will contain a enum type
870 * hdtype.
871 */
872 #define LIBXL_HAVE_HVM_HDTYPE 1
873
874 /*
875 * LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS 1
876 *
877 * If this is defined, libxl_domain_create_restore()'s API has changed to
878 * include a params structure.
879 */
880 #define LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS 1
881
882 /*
883 * LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD 1
884 *
885 * If this is defined, libxl_domain_create_restore()'s API includes the
886 * send_back_fd param. This is used only with COLO, for the libxl migration
887 * back channel; other callers should pass -1.
888 */
889 #define LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD 1
890
891 /*
892 * LIBXL_HAVE_DRIVER_DOMAIN_CREATION 1
893 *
894 * If this is defined, libxl_domain_create_info contains a driver_domain
895 * field that can be used to tell libxl that the domain that is going
896 * to be created is a driver domain, so the necessary actions are taken.
897 */
898 #define LIBXL_HAVE_DRIVER_DOMAIN_CREATION 1
899
900 /*
901 * LIBXL_HAVE_SIGCHLD_SELECTIVE_REAP
902 *
903 * If this is defined:
904 *
905 * Firstly, the enum libxl_sigchld_owner (in libxl_event.h) has the
906 * value libxl_sigchld_owner_libxl_always_selective_reap which may be
907 * passed to libxl_childproc_setmode in hooks->chldmode.
908 *
909 * Secondly, the function libxl_childproc_sigchld_occurred exists.
910 */
911 #define LIBXL_HAVE_SIGCHLD_OWNER_SELECTIVE_REAP 1
912
913 /*
914 * LIBXL_HAVE_SIGCHLD_SHARING
915 *
916 * If this is defined, it is permissible for multiple libxl ctxs
917 * to simultaneously "own" SIGCHLD. See "Subprocess handling"
918 * in libxl_event.h.
919 */
920 #define LIBXL_HAVE_SIGCHLD_SHARING 1
921
922 /*
923 * LIBXL_HAVE_NO_SUSPEND_RESUME
924 *
925 * Is this is defined then the platform has no support for saving,
926 * restoring or migrating a domain. In this case the related functions
927 * should be expected to return failure. That is:
928 * - libxl_domain_suspend
929 * - libxl_domain_resume
930 * - libxl_domain_remus_start
931 */
932 #if defined(__arm__) || defined(__aarch64__)
933 #define LIBXL_HAVE_NO_SUSPEND_RESUME 1
934 #endif
935
936 /*
937 * LIBXL_HAVE_DOMAIN_SUSPEND_ONLY
938 *
939 * If this is defined, function libxl_domains_suspend_only() is available.
940 */
941
942 #define LIBXL_HAVE_DOMAIN_SUSPEND_ONLY 1
943
944 /*
945 * LIBXL_HAVE_DEVICE_PCI_SEIZE
946 *
947 * If this is defined, then the libxl_device_pci struct will contain
948 * the "seize" boolean field. If this field is set, libxl_pci_add will
949 * check to see if the device is currently assigned to pciback, and if not,
950 * it will attempt to do so (unbinding the device from the existing driver).
951 */
952 #define LIBXL_HAVE_DEVICE_PCI_SEIZE 1
953
954 /*
955 * LIBXL_HAVE_BUILDINFO_KERNEL
956 *
957 * If this is defined, then the libxl_domain_build_info structure will
958 * contain 'kernel', 'ramdisk', 'cmdline' fields. 'kernel' is a string
959 * to indicate kernel image location, 'ramdisk' is a string to indicate
960 * ramdisk location, 'cmdline' is a string to indicate the paramters which
961 * would be appended to kernel image.
962 *
963 * Both PV guest and HVM guest can use these fields for direct kernel boot.
964 * But for compatibility reason, u.pv.kernel, u.pv.ramdisk and u.pv.cmdline
965 * still exist.
966 */
967 #define LIBXL_HAVE_BUILDINFO_KERNEL 1
968
969 /*
970 * LIBXL_HAVE_DEVICE_CHANNEL
971 *
972 * If this is defined, then the libxl_device_channel struct exists
973 * and channels can be attached to a domain. Channels manifest as consoles
974 * with names, see docs/misc/console.txt.
975 */
976 #define LIBXL_HAVE_DEVICE_CHANNEL 1
977
978 /*
979 * LIBXL_HAVE_AO_ABORT indicates the availability of libxl_ao_abort
980 */
981 #define LIBXL_HAVE_AO_ABORT 1
982
983 /* Functions annotated with LIBXL_EXTERNAL_CALLERS_ONLY may not be
984 * called from within libxl itself. Callers outside libxl, who
985 * do not #include libxl_internal.h, are fine. */
986 #ifndef LIBXL_EXTERNAL_CALLERS_ONLY
987 #define LIBXL_EXTERNAL_CALLERS_ONLY /* disappears for callers outside libxl */
988 #endif
989
990 /*
991 * LIBXL_HAVE_UUID_COPY_CTX_PARAM
992 *
993 * If this is defined, libxl_uuid_copy has changed to take a libxl_ctx
994 * structure.
995 */
996 #define LIBXL_HAVE_UUID_COPY_CTX_PARAM 1
997
998 /*
999 * LIBXL_HAVE_SSID_LABEL
1000 *
1001 * If this is defined, then libxl IDL contains string of XSM security
1002 * label in all XSM related structures.
1003 *
1004 * If set this string takes precedence over the numeric field.
1005 */
1006 #define LIBXL_HAVE_SSID_LABEL 1
1007
1008 /*
1009 * LIBXL_HAVE_CPUPOOL_NAME
1010 *
1011 * If this is defined, then libxl IDL contains string of CPU pool
1012 * name in all CPU pool related structures.
1013 *
1014 * If set this string takes precedence over the numeric field.
1015 */
1016 #define LIBXL_HAVE_CPUPOOL_NAME 1
1017
1018 /*
1019 * LIBXL_HAVE_BUILDINFO_SERIAL_LIST
1020 *
1021 * If this is defined, then the libxl_domain_build_info structure will
1022 * contain hvm.serial_list, a libxl_string_list type that contains
1023 * a list of serial ports to specify on the qemu command-line.
1024 *
1025 * If it is set, callers may use either hvm.serial or
1026 * hvm.serial_list, but not both; if both are set, libxl will
1027 * throw an error.
1028 *
1029 * If this is not defined, callers can only use hvm.serial. Note
1030 * that this means only one serial port can be added at domain build time.
1031 */
1032 #define LIBXL_HAVE_BUILDINFO_SERIAL_LIST 1
1033
1034 /*
1035 * LIBXL_HAVE_ALTP2M
1036 * If this is defined, then libxl supports alternate p2m functionality.
1037 */
1038 #define LIBXL_HAVE_ALTP2M 1
1039
1040 /*
1041 * LIBXL_HAVE_REMUS
1042 * If this is defined, then libxl supports remus.
1043 */
1044 #define LIBXL_HAVE_REMUS 1
1045
1046 /*
1047 * LIBXL_HAVE_COLO_USERSPACE_PROXY
1048 * If this is defined, then libxl supports COLO userspace proxy.
1049 */
1050 #define LIBXL_HAVE_COLO_USERSPACE_PROXY 1
1051
1052 typedef uint8_t libxl_mac[6];
1053 #define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
1054 #define LIBXL_MAC_FMTLEN ((2*6)+5) /* 6 hex bytes plus 5 colons */
1055 #define LIBXL_MAC_BYTES(mac) mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
1056 void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src);
1057
1058 #if defined(__i386__) || defined(__x86_64__)
1059 /*
1060 * LIBXL_HAVE_PSR_CMT
1061 *
1062 * If this is defined, the Cache Monitoring Technology feature is supported.
1063 */
1064 #define LIBXL_HAVE_PSR_CMT 1
1065
1066 /*
1067 * LIBXL_HAVE_PSR_MBM
1068 *
1069 * If this is defined, the Memory Bandwidth Monitoring feature is supported.
1070 */
1071 #define LIBXL_HAVE_PSR_MBM 1
1072
1073 /*
1074 * LIBXL_HAVE_PSR_CAT
1075 *
1076 * If this is defined, the Cache Allocation Technology feature is supported.
1077 */
1078 #define LIBXL_HAVE_PSR_CAT 1
1079
1080 /*
1081 * LIBXL_HAVE_PSR_CDP
1082 *
1083 * If this is defined, the Code and Data Prioritization feature is supported.
1084 */
1085 #define LIBXL_HAVE_PSR_CDP 1
1086
1087 /*
1088 * LIBXL_HAVE_PSR_L2_CAT
1089 *
1090 * If this is defined, the L2 Cache Allocation Technology feature is supported.
1091 */
1092 #define LIBXL_HAVE_PSR_L2_CAT 1
1093
1094 /*
1095 * LIBXL_HAVE_PSR_GENERIC
1096 *
1097 * If this is defined, the Memory Bandwidth Allocation feature is supported.
1098 * The following public functions are available:
1099 * libxl_psr_{set/get}_val
1100 * libxl_psr_get_hw_info
1101 * libxl_psr_hw_info_list_free
1102 */
1103 #define LIBXL_HAVE_PSR_GENERIC 1
1104
1105 /*
1106 * LIBXL_HAVE_MCA_CAPS
1107 *
1108 * If this is defined, setting MCA capabilities for HVM domain is supported.
1109 */
1110 #define LIBXL_HAVE_MCA_CAPS 1
1111 #endif
1112
1113 /*
1114 * LIBXL_HAVE_PCITOPOLOGY
1115 *
1116 * If this is defined, then interface to query hypervisor about PCI device
1117 * topology is available.
1118 */
1119 #define LIBXL_HAVE_PCITOPOLOGY 1
1120
1121 /*
1122 * LIBXL_HAVE_SOCKET_BITMAP
1123 *
1124 * If this is defined, then libxl_socket_bitmap_alloc and
1125 * libxl_get_online_socketmap exist.
1126 */
1127 #define LIBXL_HAVE_SOCKET_BITMAP 1
1128
1129 /*
1130 * LIBXL_HAVE_SRM_V2
1131 *
1132 * If this is defined, then the libxl_domain_create_restore() interface takes
1133 * a "stream_version" parameter and supports a value of 2.
1134 *
1135 * libxl_domain_suspend() will produce a v2 stream.
1136 */
1137 #define LIBXL_HAVE_SRM_V2 1
1138
1139 /*
1140 * LIBXL_HAVE_SRM_V1
1141 *
1142 * In the case that LIBXL_HAVE_SRM_V2 is set, LIBXL_HAVE_SRM_V1
1143 * indicates that libxl_domain_create_restore() can handle a "stream_version"
1144 * parameter of 1, and convert the stream format automatically.
1145 */
1146 #define LIBXL_HAVE_SRM_V1 1
1147
1148 /*
1149 * libxl_domain_build_info has the u.hvm.gfx_passthru_kind field and
1150 * the libxl_gfx_passthru_kind enumeration is defined.
1151 */
1152 #define LIBXL_HAVE_GFX_PASSTHRU_KIND
1153
1154 /*
1155 * LIBXL_HAVE_CHECKPOINTED_STREAM
1156 *
1157 * If this is defined, then libxl_checkpointed_stream exists.
1158 */
1159 #define LIBXL_HAVE_CHECKPOINTED_STREAM 1
1160
1161 /*
1162 * LIBXL_HAVE_BUILDINFO_HVM_SYSTEM_FIRMWARE
1163 *
1164 * libxl_domain_build_info has u.hvm.system_firmware field which can be use
1165 * to provide a different firmware blob (like SeaBIOS or OVMF).
1166 */
1167 #define LIBXL_HAVE_BUILDINFO_HVM_SYSTEM_FIRMWARE
1168
1169 /*
1170 * ERROR_REMUS_XXX error code only exists from Xen 4.5, Xen 4.6 and it
1171 * is changed to ERROR_CHECKPOINT_XXX in Xen 4.7
1172 */
1173 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION >= 0x040500 \
1174 && LIBXL_API_VERSION < 0x040700
1175 #define ERROR_REMUS_DEVOPS_DOES_NOT_MATCH \
1176 ERROR_CHECKPOINT_DEVOPS_DOES_NOT_MATCH
1177 #define ERROR_REMUS_DEVICE_NOT_SUPPORTED \
1178 ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED
1179 #endif
1180
1181 /*
1182 * LIBXL_HAVE_VGA_INTERFACE_TYPE_UNKNOWN
1183 *
1184 * In the case that LIBXL_HAVE_VGA_INTERFACE_TYPE_UNKNOWN is set the
1185 * libxl_vga_interface_type enumeration type contains a
1186 * LIBXL_VGA_INTERFACE_TYPE_UNKNOWN identifier. This is used to signal
1187 * that a libxl_vga_interface_type type has not been initialized yet.
1188 */
1189 #define LIBXL_HAVE_VGA_INTERFACE_TYPE_UNKNOWN 1
1190
1191 /*
1192 * LIBXL_HAVE_BYTEARRAY_UUID
1193 *
1194 * If this is defined, the internal member of libxl_uuid is defined
1195 * as a 16 byte array that contains the UUID in big endian format.
1196 * Also, the same structure layout is used across all OSes.
1197 */
1198 #define LIBXL_HAVE_BYTEARRAY_UUID 1
1199
1200 /*
1201 * LIBXL_HAVE_MEMKB_64BITS
1202 *
1203 * If this is defined libxl_set_memory_target(), libxl_domain_setmaxmem()
1204 * and libxl_wait_for_free_memory() will take a 64 bit value for the memory
1205 * size parameter.
1206 * From Xen 4.8 on libxl_get_memory_target(), libxl_domain_need_memory() and
1207 * libxl_get_free_memory() return the memory size in a 64 bit value, too.
1208 */
1209 #define LIBXL_HAVE_MEMKB_64BITS 1
1210
1211 /*
1212 * LIBXL_HAVE_QED
1213 *
1214 * If this is defined QED disk formats can be used for both HVM and PV guests.
1215 */
1216 #define LIBXL_HAVE_QED 1
1217
1218 /*
1219 * LIBXL_HAVE_SET_PARAMETERS
1220 *
1221 * If this is defined setting hypervisor parameters is supported.
1222 */
1223 #define LIBXL_HAVE_SET_PARAMETERS 1
1224
1225 /*
1226 * LIBXL_HAVE_PV_SHIM
1227 *
1228 * If this is defined, libxl_domain_build_info's pvh type information
1229 * contains members pvshim, pvshim_path, pvshim_cmdline, pvshim_extra.
1230 */
1231 #define LIBXL_HAVE_PV_SHIM 1
1232
1233 /*
1234 * LIBXL_HAVE_PVCALLS
1235 *
1236 * If this is defined, libxl supports creating pvcalls interfaces.
1237 */
1238 #define LIBXL_HAVE_PVCALLS 1
1239
1240 /*
1241 * LIBXL_HAVE_FN_USING_QMP_ASYNC
1242 *
1243 * This define indicates that some function's API has changed and have an
1244 * extra parameter "ao_how" which means that the function can be executed
1245 * asynchronously. Those functions are:
1246 * libxl_domain_pause()
1247 * libxl_domain_unpause()
1248 * libxl_send_trigger()
1249 * libxl_set_vcpuonline()
1250 * libxl_retrieve_domain_configuration()
1251 * libxl_qemu_monitor_command()
1252 * libxl_domain_shutdown()
1253 * libxl_domain_reboot()
1254 */
1255 #define LIBXL_HAVE_FN_USING_QMP_ASYNC 1
1256
1257 /*
1258 * LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG
1259 *
1260 * If this is set, libxl_domain_need_memory takes a
1261 * libxl_domain_config* (non-const) and uint32_t domid_for_logging
1262 * (instead of a const libxl_domain_build_info*).
1263 *
1264 * If this is set, there is no need to call
1265 * libxl_get_required_shadow_memory and instead the caller should
1266 * simply leave shadow_memkb set to LIBXL_MEMKB_DEFAULT and allow
1267 * libxl to fill in a suitable default in the usual way.
1268 */
1269 #define LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG
1270
1271 /*
1272 * LIBXL_HAVE_CREATEINFO_DOMID
1273 *
1274 * libxl_domain_create_new() and libxl_domain_create_restore() will use
1275 * a domid specified in libxl_domain_create_info.
1276 */
1277 #define LIBXL_HAVE_CREATEINFO_DOMID
1278
1279 /*
1280 * LIBXL_HAVE_CREATEINFO_XEND_SUSPEND_EVTCHN_COMPAT
1281 *
1282 * libxl_domain_create_info contains a boolean 'xend_suspend_evtchn_compat'
1283 * value to control creation of the xenstore path for a domain's suspend
1284 * event channel.
1285 */
1286 #define LIBXL_HAVE_CREATEINFO_XEND_SUSPEND_EVTCHN_COMPAT
1287
1288 typedef char **libxl_string_list;
1289 void libxl_string_list_dispose(libxl_string_list *sl);
1290 int libxl_string_list_length(const libxl_string_list *sl);
1291 void libxl_string_list_copy(libxl_ctx *ctx, libxl_string_list *dst,
1292 const libxl_string_list *src);
1293
1294 typedef char **libxl_key_value_list;
1295 void libxl_key_value_list_dispose(libxl_key_value_list *kvl);
1296 int libxl_key_value_list_length(const libxl_key_value_list *kvl);
1297 void libxl_key_value_list_copy(libxl_ctx *ctx,
1298 libxl_key_value_list *dst,
1299 const libxl_key_value_list *src);
1300
1301 typedef uint32_t libxl_hwcap[8];
1302 void libxl_hwcap_copy(libxl_ctx *ctx, libxl_hwcap *dst, const libxl_hwcap *src);
1303
1304 typedef uint64_t libxl_ev_user;
1305
1306 typedef struct {
1307 uint32_t size; /* number of bytes in map */
1308 uint8_t *map;
1309 } libxl_bitmap;
1310 void libxl_bitmap_init(libxl_bitmap *map);
1311 void libxl_bitmap_dispose(libxl_bitmap *map);
1312
1313 /*
1314 * libxl_cpuid_policy is opaque in the libxl ABI. Users of both libxl and
1315 * libxc may not make assumptions about xc_xend_cpuid.
1316 */
1317 typedef struct xc_xend_cpuid libxl_cpuid_policy;
1318 typedef libxl_cpuid_policy * libxl_cpuid_policy_list;
1319 void libxl_cpuid_dispose(libxl_cpuid_policy_list *cpuid_list);
1320 int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *l);
1321 void libxl_cpuid_policy_list_copy(libxl_ctx *ctx,
1322 libxl_cpuid_policy_list *dst,
1323 const libxl_cpuid_policy_list *src);
1324
1325 #define LIBXL_PCI_FUNC_ALL (~0U)
1326
1327 typedef uint32_t libxl_domid;
1328 typedef int libxl_devid;
1329
1330 /*
1331 * Formatting Enumerations.
1332 *
1333 * Each enumeration type libxl_E declares an associated lookup table
1334 * libxl_E_string_table and a lookup function libxl_E_from_string.
1335 */
1336 typedef struct {
1337 const char *s;
1338 int v;
1339 } libxl_enum_string_table;
1340
1341 struct libxl_event;
1342 typedef LIBXL_TAILQ_ENTRY(struct libxl_event) libxl_ev_link;
1343
1344 /*
1345 * A boolean variable with an explicit default state.
1346 *
1347 * Users should treat this struct as opaque and use the following
1348 * defined macros and accessor functions.
1349 *
1350 * To allow users of the library to naively select all defaults this
1351 * state is represented as 0. False is < 0 and True is > 0.
1352 */
1353 typedef struct {
1354 int val;
1355 } libxl_defbool;
1356
1357 void libxl_defbool_set(libxl_defbool *db, bool b);
1358 /* Resets to default */
1359 void libxl_defbool_unset(libxl_defbool *db);
1360 /* Sets db only if it is currently == default */
1361 void libxl_defbool_setdefault(libxl_defbool *db, bool b);
1362 bool libxl_defbool_is_default(libxl_defbool db);
1363 /* db must not be == default */
1364 bool libxl_defbool_val(libxl_defbool db);
1365
1366 const char *libxl_defbool_to_string(libxl_defbool b);
1367
1368 #define LIBXL_TIMER_MODE_DEFAULT -1
1369 #define LIBXL_MEMKB_DEFAULT ~0ULL
1370
1371 /*
1372 * We'd like to set a memory boundary to determine if we need to check
1373 * any overlap with reserved device memory.
1374 */
1375 #define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)
1376
1377 #define LIBXL_MS_VM_GENID_LEN 16
1378 typedef struct {
1379 uint8_t bytes[LIBXL_MS_VM_GENID_LEN];
1380 } libxl_ms_vm_genid;
1381
1382 #include "_libxl_types.h"
1383
1384 const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx);
1385
1386 /*
1387 * Some libxl operations can take a long time. These functions take a
1388 * parameter to control their concurrency:
1389 * libxl_asyncop_how *ao_how
1390 *
1391 * If ao_how==NULL, the function will be synchronous.
1392 *
1393 * If ao_how!=NULL, the function will set the operation going, and if
1394 * this is successful will return 0. In this case the zero error
1395 * response does NOT mean that the operation was successful; it just
1396 * means that it has been successfully started. It will finish later,
1397 * perhaps with an error.
1398 *
1399 * If ao_how->callback!=NULL, the callback will be called when the
1400 * operation completes. The same rules as for libxl_event_hooks
1401 * apply, including the reentrancy rules and the possibility of
1402 * "disaster", except that libxl calls ao_how->callback instead of
1403 * libxl_event_hooks.event_occurs. (See libxl_event.h.)
1404 *
1405 * If ao_how->callback==NULL, a libxl_event will be generated which
1406 * can be obtained from libxl_event_wait or libxl_event_check. The
1407 * event will have type OPERATION_COMPLETE (which is not used
1408 * elsewhere).
1409 *
1410 * Note that it is possible for an asynchronous operation which is to
1411 * result in a callback to complete during its initiating function
1412 * call. In this case the initiating function will return 0
1413 * indicating the at the operation is "in progress", even though by
1414 * the time it returns the operation is complete and the callback has
1415 * already happened.
1416 *
1417 * The application must set and use ao_how->for_event (which will be
1418 * copied into libxl_event.for_user) or ao_how->for_callback (passed
1419 * to the callback) to determine which operation finished, and it must
1420 * of course check the rc value for errors.
1421 *
1422 * *ao_how does not need to remain valid after the initiating function
1423 * returns. All other parameters must remain valid for the lifetime of
1424 * the asynchronous operation, unless otherwise specified.
1425 *
1426 * Callbacks may occur on any thread in which the application calls
1427 * libxl.
1428 */
1429
1430 typedef struct {
1431 void (*callback)(libxl_ctx *ctx, int rc, void *for_callback);
1432 union {
1433 libxl_ev_user for_event; /* used if callback==NULL */
1434 void *for_callback; /* passed to callback */
1435 } u;
1436 } libxl_asyncop_how;
1437
1438 /*
1439 * Some more complex asynchronous operations can report intermediate
1440 * progress. How this is to be reported is controlled, for each
1441 * function, by a parameter
1442 * libxl_asyncprogress_how *aop_FOO_how;
1443 * for each kind of progress FOO supported by that function. Each
1444 * such kind of progress is associated with an event type.
1445 *
1446 * The function description will document whether, when, and how
1447 * many times, the intermediate progress will be reported, and
1448 * what the corresponding event type(s) are.
1449 *
1450 * If aop_FOO_how==NULL, intermediate progress reports are discarded.
1451 *
1452 * If aop_FOO_how->callback==NULL, intermediate progress reports
1453 * generate libxl events which can be obtained from libxl_event_wait
1454 * or libxl_event_check.
1455 *
1456 * If aop_FOO_how->callback!=NULL, libxl will report intermediate
1457 * progress by calling callback(ctx, &event, for_callback).
1458 *
1459 * The rules for these events are otherwise the same as those for
1460 * ordinary events. The reentrancy and threading rules for the
1461 * callback are the same as those for ao completion callbacks.
1462 *
1463 * Note that the callback, if provided, is responsible for freeing
1464 * the event.
1465 *
1466 * If callbacks are requested, they will be made, and returned, before
1467 * the long-running libxl operation is considered finished (so if the
1468 * long-running libxl operation was invoked with ao_how==NULL then any
1469 * callbacks will occur strictly before the long-running operation
1470 * returns). However, the callbacks may occur on any thread.
1471 *
1472 * In general, otherwise, no promises are made about the relative
1473 * order of callbacks in a multithreaded program. In particular
1474 * different callbacks relating to the same long-running operation may
1475 * be delivered out of order.
1476 */
1477
1478 typedef struct {
1479 void (*callback)(libxl_ctx *ctx, libxl_event*, void *for_callback);
1480 libxl_ev_user for_event; /* always used */
1481 void *for_callback; /* passed to callback */
1482 } libxl_asyncprogress_how;
1483
1484 /*
1485 * It is sometimes possible to abort an asynchronous operation.
1486 *
1487 * libxl_ao_abort searches for an ongoing asynchronous operation whose
1488 * ao_how is identical to *how, and tries to abort it. The return
1489 * values from libxl_ao_abort are as follows:
1490 *
1491 * 0
1492 *
1493 * The operation was found, and attempts are being made to cut it
1494 * short. However, it may still take some time to stop. It is
1495 * also possible that the operation will nevertheless complete
1496 * successfully.
1497 *
1498 * ERROR_NOTFOUND
1499 *
1500 * No matching ongoing operation was found. This might happen
1501 * for an actual operation if the operation has already completed
1502 * (perhaps on another thread). The call to libxl_ao_abort has
1503 * had no effect.
1504 *
1505 * ERROR_ABORTED
1506 *
1507 * The operation has already been the subject of at least one
1508 * call to libxl_ao_abort.
1509 *
1510 * If the operation was indeed cut short due to the abort request, it
1511 * will complete, at some point in the future, with ERROR_ABORTED. In
1512 * that case, depending on the operation it have performed some of the
1513 * work in question and left the operation half-done. Consult the
1514 * documentation for individual operations.
1515 *
1516 * Note that an aborted operation might still fail for other reasons
1517 * even after the abort was requested.
1518 *
1519 * If your application is multithreaded you must not reuse an
1520 * ao_how->for_event or ao_how->for_callback value (with a particular
1521 * ao_how->callback) unless you are sure that none of your other
1522 * threads are going to abort the previous operation using that
1523 * value; otherwise you risk aborting the wrong operation if the
1524 * intended target of the abort request completes in the meantime.
1525 *
1526 * It is possible to abort even an operation which is being performed
1527 * synchronously, but since in that case how==NULL you had better only
1528 * have one such operation, because it is not possible to tell them
1529 * apart (and libxl_ao_abort will abort only the first one it finds).
1530 * (And, if you want to do this, obviously the abort would have to be
1531 * requested on a different thread.)
1532 */
1533 int libxl_ao_abort(libxl_ctx *ctx, const libxl_asyncop_how *how)
1534 LIBXL_EXTERNAL_CALLERS_ONLY;
1535
1536
1537 #define LIBXL_VERSION 0
1538
1539 /* context functions */
1540 int libxl_ctx_alloc(libxl_ctx **pctx, int version,
1541 unsigned flags /* none currently defined */,
1542 xentoollog_logger *lg);
1543 int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */);
1544
1545 /* domain related functions */
1546
1547 #define INVALID_DOMID ~0
1548 #define RANDOM_DOMID (INVALID_DOMID - 1)
1549
1550 /* If the result is ERROR_ABORTED, the domain may or may not exist
1551 * (in a half-created state). *domid will be valid and will be the
1552 * domain id, or INVALID_DOMID, as appropriate */
1553
1554 int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
1555 uint32_t *domid,
1556 const libxl_asyncop_how *ao_how,
1557 const libxl_asyncprogress_how *aop_console_how)
1558 LIBXL_EXTERNAL_CALLERS_ONLY;
1559 int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
1560 uint32_t *domid, int restore_fd,
1561 int send_back_fd,
1562 const libxl_domain_restore_params *params,
1563 const libxl_asyncop_how *ao_how,
1564 const libxl_asyncprogress_how *aop_console_how)
1565 LIBXL_EXTERNAL_CALLERS_ONLY;
1566
1567 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040400
1568
libxl_domain_create_restore_0x040200(libxl_ctx * ctx,libxl_domain_config * d_config,uint32_t * domid,int restore_fd,const libxl_asyncop_how * ao_how,const libxl_asyncprogress_how * aop_console_how)1569 static inline int libxl_domain_create_restore_0x040200(
1570 libxl_ctx *ctx, libxl_domain_config *d_config,
1571 uint32_t *domid, int restore_fd,
1572 const libxl_asyncop_how *ao_how,
1573 const libxl_asyncprogress_how *aop_console_how)
1574 LIBXL_EXTERNAL_CALLERS_ONLY
1575 {
1576 libxl_domain_restore_params params;
1577 int ret;
1578
1579 libxl_domain_restore_params_init(¶ms);
1580
1581 ret = libxl_domain_create_restore(
1582 ctx, d_config, domid, restore_fd, -1, ¶ms, ao_how, aop_console_how);
1583
1584 libxl_domain_restore_params_dispose(¶ms);
1585 return ret;
1586 }
1587
1588 #define libxl_domain_create_restore libxl_domain_create_restore_0x040200
1589
1590 #elif defined(LIBXL_API_VERSION) && LIBXL_API_VERSION >= 0x040400 \
1591 && LIBXL_API_VERSION < 0x040700
1592
libxl_domain_create_restore_0x040400(libxl_ctx * ctx,libxl_domain_config * d_config,uint32_t * domid,int restore_fd,const libxl_domain_restore_params * params,const libxl_asyncop_how * ao_how,const libxl_asyncprogress_how * aop_console_how)1593 static inline int libxl_domain_create_restore_0x040400(
1594 libxl_ctx *ctx, libxl_domain_config *d_config,
1595 uint32_t *domid, int restore_fd,
1596 const libxl_domain_restore_params *params,
1597 const libxl_asyncop_how *ao_how,
1598 const libxl_asyncprogress_how *aop_console_how)
1599 LIBXL_EXTERNAL_CALLERS_ONLY
1600 {
1601 return libxl_domain_create_restore(ctx, d_config, domid, restore_fd,
1602 -1, params, ao_how, aop_console_how);
1603 }
1604
1605 #define libxl_domain_create_restore libxl_domain_create_restore_0x040400
1606
1607 #endif
1608
1609 int libxl_domain_soft_reset(libxl_ctx *ctx,
1610 libxl_domain_config *d_config,
1611 uint32_t domid,
1612 const libxl_asyncop_how *ao_how,
1613 const libxl_asyncprogress_how
1614 *aop_console_how)
1615 LIBXL_EXTERNAL_CALLERS_ONLY;
1616
1617 /* A progress report will be made via ao_console_how, of type
1618 * domain_create_console_available, when the domain's primary
1619 * console is available and can be connected to.
1620 */
1621
1622 void libxl_domain_config_init(libxl_domain_config *d_config);
1623 void libxl_domain_config_dispose(libxl_domain_config *d_config);
1624
1625 /*
1626 * Retrieve domain configuration and filled it in d_config. The
1627 * returned configuration can be used to rebuild a domain. It only
1628 * works with DomU.
1629 */
1630 int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
1631 libxl_domain_config *d_config,
1632 const libxl_asyncop_how *ao_how)
1633 LIBXL_EXTERNAL_CALLERS_ONLY;
1634 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
libxl_retrieve_domain_configuration_0x041200(libxl_ctx * ctx,uint32_t domid,libxl_domain_config * d_config)1635 static inline int libxl_retrieve_domain_configuration_0x041200(
1636 libxl_ctx *ctx, uint32_t domid, libxl_domain_config *d_config)
1637 {
1638 return libxl_retrieve_domain_configuration(ctx, domid, d_config, NULL);
1639 }
1640 #define libxl_retrieve_domain_configuration \
1641 libxl_retrieve_domain_configuration_0x041200
1642 #endif
1643
1644 int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd,
1645 int flags, /* LIBXL_SUSPEND_* */
1646 const libxl_asyncop_how *ao_how)
1647 LIBXL_EXTERNAL_CALLERS_ONLY;
1648 #define LIBXL_SUSPEND_DEBUG 1
1649 #define LIBXL_SUSPEND_LIVE 2
1650
1651 /*
1652 * Only suspend domain, do not save its state to file, do not destroy it.
1653 * Suspended domain can be resumed with libxl_domain_resume()
1654 */
1655 int libxl_domain_suspend_only(libxl_ctx *ctx, uint32_t domid,
1656 const libxl_asyncop_how *ao_how)
1657 LIBXL_EXTERNAL_CALLERS_ONLY;
1658
1659 /* @param suspend_cancel [from xenctrl.h:xc_domain_resume( @param fast )]
1660 * If this parameter is true, use co-operative resume. The guest
1661 * must support this.
1662 */
1663 int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel,
1664 const libxl_asyncop_how *ao_how)
1665 LIBXL_EXTERNAL_CALLERS_ONLY;
1666
1667 /*
1668 * This function doesn't return unless something has gone wrong with
1669 * the replication to the secondary. If this function returns then the
1670 * caller should resume the (primary) domain.
1671 */
1672 int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
1673 uint32_t domid, int send_fd, int recv_fd,
1674 const libxl_asyncop_how *ao_how)
1675 LIBXL_EXTERNAL_CALLERS_ONLY;
1676
1677 int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid,
1678 const libxl_asyncop_how *ao_how)
1679 LIBXL_EXTERNAL_CALLERS_ONLY;
1680 int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid,
1681 const libxl_asyncop_how *ao_how)
1682 LIBXL_EXTERNAL_CALLERS_ONLY;
1683 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
libxl_domain_shutdown_0x041200(libxl_ctx * ctx,uint32_t domid)1684 static inline int libxl_domain_shutdown_0x041200(libxl_ctx *ctx,
1685 uint32_t domid)
1686 {
1687 return libxl_domain_shutdown(ctx, domid, NULL);
1688 }
1689 #define libxl_domain_shutdown libxl_domain_shutdown_0x041200
libxl_domain_reboot_0x041200(libxl_ctx * ctx,uint32_t domid)1690 static inline int libxl_domain_reboot_0x041200(libxl_ctx *ctx,
1691 uint32_t domid)
1692 {
1693 return libxl_domain_reboot(ctx, domid, NULL);
1694 }
1695 #define libxl_domain_reboot libxl_domain_reboot_0x041200
1696 #endif
1697
1698 int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid,
1699 const libxl_asyncop_how *ao_how)
1700 LIBXL_EXTERNAL_CALLERS_ONLY;
1701 int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_info *info, const char *name_suffix, libxl_uuid new_uuid);
1702
1703 /* get max. number of cpus supported by hypervisor */
1704 int libxl_get_max_cpus(libxl_ctx *ctx);
1705
1706 /* get the actual number of currently online cpus on the host */
1707 int libxl_get_online_cpus(libxl_ctx *ctx);
1708 /* Beware that no locking or serialization is provided by libxl,
1709 * so the information can be outdated as far as the function
1710 * returns. If there are other entities in the system capable
1711 * of onlining/offlining CPUs, it is up to the application
1712 * to guarantee consistency, if that is important. */
1713
1714 /* get max. number of NUMA nodes supported by hypervisor */
1715 int libxl_get_max_nodes(libxl_ctx *ctx);
1716
1717 int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid,
1718 const char *old_name, const char *new_name);
1719
1720 /* if old_name is NULL, any old name is OK; otherwise we check
1721 * transactionally that the domain has the old old name; if
1722 * trans is not 0 we use caller's transaction and caller must do retries */
1723
1724 int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid,
1725 const libxl_asyncop_how *ao_how)
1726 LIBXL_EXTERNAL_CALLERS_ONLY;
1727 int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid,
1728 const libxl_asyncop_how *ao_how)
1729 LIBXL_EXTERNAL_CALLERS_ONLY;
1730 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
libxl_domain_pause_0x041200(libxl_ctx * ctx,uint32_t domid)1731 static inline int libxl_domain_pause_0x041200(
1732 libxl_ctx *ctx, uint32_t domid)
1733 {
1734 return libxl_domain_pause(ctx, domid, NULL);
1735 }
libxl_domain_unpause_0x041200(libxl_ctx * ctx,uint32_t domid)1736 static inline int libxl_domain_unpause_0x041200(
1737 libxl_ctx *ctx, uint32_t domid)
1738 {
1739 return libxl_domain_unpause(ctx, domid, NULL);
1740 }
1741 #define libxl_domain_pause libxl_domain_pause_0x041200
1742 #define libxl_domain_unpause libxl_domain_unpause_0x041200
1743 #endif
1744
1745
1746 int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid,
1747 const char *filename,
1748 const libxl_asyncop_how *ao_how)
1749 LIBXL_EXTERNAL_CALLERS_ONLY;
1750
1751 int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t target_memkb);
1752 int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, int64_t target_memkb, int relative, int enforce);
1753 int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid, uint64_t *out_target);
1754 int libxl_get_memory_target_0x040700(libxl_ctx *ctx, uint32_t domid,
1755 uint32_t *out_target)
1756 LIBXL_EXTERNAL_CALLERS_ONLY;
1757
1758 /*
1759 * WARNING
1760 * This memory management API is unstable even in Xen 4.2.
1761 * It has a numer of deficiencies and we intend to replace it.
1762 *
1763 * The semantics of these functions should not be relied on to be very
1764 * coherent or stable. We will however endeavour to keep working
1765 * existing programs which use them in roughly the same way as libxl.
1766 */
1767 /* how much free memory in the system a domain needs to be built */
1768 int libxl_domain_need_memory(libxl_ctx *ctx,
1769 libxl_domain_config *config
1770 /* ^ will be partially defaulted */,
1771 uint32_t domid_for_logging /* INVALID_DOMID ok */,
1772 uint64_t *need_memkb);
1773 int libxl_domain_need_memory_0x041200(libxl_ctx *ctx,
1774 const libxl_domain_build_info *b_info_in,
1775 uint64_t *need_memkb);
1776 int libxl_domain_need_memory_0x040700(libxl_ctx *ctx,
1777 const libxl_domain_build_info *b_info_in,
1778 uint32_t *need_memkb)
1779 LIBXL_EXTERNAL_CALLERS_ONLY;
1780 /* how much free memory is available in the system */
1781 int libxl_get_free_memory(libxl_ctx *ctx, uint64_t *memkb);
1782 int libxl_get_free_memory_0x040700(libxl_ctx *ctx, uint32_t *memkb)
1783 LIBXL_EXTERNAL_CALLERS_ONLY;
1784 /* wait for a given amount of memory to be free in the system */
1785 int libxl_wait_for_free_memory(libxl_ctx *ctx, uint32_t domid, uint64_t memory_kb, int wait_secs);
1786 /*
1787 * Wait for the memory target of a domain to be reached. Does not
1788 * decrement wait_secs if the domain is making progress toward reaching
1789 * the target. If the domain is not making progress, wait_secs is
1790 * decremented. If the timeout expires before the target is reached, the
1791 * function returns ERROR_FAIL.
1792 *
1793 * Older versions of this function (Xen 4.5 and older), decremented
1794 * wait_secs even if the domain was making progress, resulting in far
1795 * lower overall wait times. To make sure that your calling routine
1796 * works with new and old implementations of the function, pass enough
1797 * time for the guest to reach its target as an argument.
1798 */
1799 int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs);
1800
1801 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040800
1802 #define libxl_get_memory_target libxl_get_memory_target_0x040700
1803 #define libxl_domain_need_memory libxl_domain_need_memory_0x040700
1804 #define libxl_get_free_memory libxl_get_free_memory_0x040700
1805 #elif defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
1806 #define libxl_domain_need_memory libxl_domain_need_memory_0x041200
1807 #endif
1808
1809 int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass);
1810
1811 /*
1812 * If notify_fd is not -1, xenconsole will write 0x00 to it to nofity
1813 * the caller that it has connected to the guest console.
1814 */
1815 int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
1816 libxl_console_type type, int notify_fd);
1817 /* libxl_primary_console_exec finds the domid and console number
1818 * corresponding to the primary console of the given vm, then calls
1819 * libxl_console_exec with the right arguments (domid might be different
1820 * if the guest is using stubdoms).
1821 * This function can be called after creating the device model, in
1822 * case of HVM guests, and before libxl_run_bootloader in case of PV
1823 * guests using pygrub.
1824 * If notify_fd is not -1, xenconsole will write 0x00 to it to nofity
1825 * the caller that it has connected to the guest console.
1826 */
1827 int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm,
1828 int notify_fd);
1829
1830 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040800
1831
libxl_console_exec_0x040700(libxl_ctx * ctx,uint32_t domid,int cons_num,libxl_console_type type)1832 static inline int libxl_console_exec_0x040700(libxl_ctx *ctx,
1833 uint32_t domid, int cons_num,
1834 libxl_console_type type)
1835 {
1836 return libxl_console_exec(ctx, domid, cons_num, type, -1);
1837 }
1838 #define libxl_console_exec libxl_console_exec_0x040700
1839
libxl_primary_console_exec_0x040700(libxl_ctx * ctx,uint32_t domid_vm)1840 static inline int libxl_primary_console_exec_0x040700(libxl_ctx *ctx,
1841 uint32_t domid_vm)
1842 {
1843 return libxl_primary_console_exec(ctx, domid_vm, -1);
1844 }
1845 #define libxl_primary_console_exec libxl_primary_console_exec_0x040700
1846
1847 #endif
1848
1849 /* libxl_console_get_tty retrieves the specified domain's console tty path
1850 * and stores it in path. Caller is responsible for freeing the memory.
1851 */
1852 int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num,
1853 libxl_console_type type, char **path);
1854
1855 /* libxl_primary_console_get_tty retrieves the specified domain's primary
1856 * console tty path and stores it in path. Caller is responsible for freeing
1857 * the memory.
1858 */
1859 int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm, char **path);
1860
1861 /* May be called with info_r == NULL to check for domain's existence.
1862 * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return
1863 * ERROR_INVAL for this scenario). */
1864 int libxl_domain_info(libxl_ctx*, libxl_dominfo *info_r,
1865 uint32_t domid);
1866
1867 /* These functions each return (on success) an array of elements,
1868 * and the length via the int* out parameter. These arrays and
1869 * their contents come from malloc, and must be freed with the
1870 * corresponding libxl_THING_list_free function.
1871 */
1872 libxl_dominfo * libxl_list_domain(libxl_ctx*, int *nb_domain_out);
1873 void libxl_dominfo_list_free(libxl_dominfo *list, int nb_domain);
1874
1875 libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx*, int *nb_pool_out);
1876 void libxl_cpupoolinfo_list_free(libxl_cpupoolinfo *list, int nb_pool);
1877
1878 libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm_out);
1879 void libxl_vminfo_list_free(libxl_vminfo *list, int nb_vm);
1880
1881 #define LIBXL_CPUTOPOLOGY_INVALID_ENTRY (~(uint32_t)0)
1882 libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nb_cpu_out);
1883 void libxl_cputopology_list_free(libxl_cputopology *, int nb_cpu);
1884
1885 #define LIBXL_PCITOPOLOGY_INVALID_ENTRY (~(uint32_t)0)
1886 libxl_pcitopology *libxl_get_pci_topology(libxl_ctx *ctx, int *num_devs);
1887 void libxl_pcitopology_list_free(libxl_pcitopology *, int num_devs);
1888
1889 #define LIBXL_NUMAINFO_INVALID_ENTRY (~(uint32_t)0)
1890 libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr);
1891 void libxl_numainfo_list_free(libxl_numainfo *, int nr);
1892
1893 libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
1894 int *nb_vcpu, int *nr_cpus_out);
1895 void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus);
1896
1897 /*
1898 * Devices
1899 * =======
1900 *
1901 * Each device is represented by a libxl_device_<TYPE> data structure
1902 * which is defined via the IDL. In addition some devices have an
1903 * additional data type libxl_device_<TYPE>_getinfo which contains
1904 * further runtime information about the device.
1905 *
1906 * In addition to the general methods available for libxl types (see
1907 * "libxl types" above) a common set of methods are available for each
1908 * device type. These are described below.
1909 *
1910 * Querying
1911 * --------
1912 *
1913 * libxl_device_<type>_list(ctx, domid, nr):
1914 *
1915 * Returns an array of libxl_device_<type> length nr representing
1916 * the devices attached to the specified domain.
1917 *
1918 * libxl_device_<type>_getinfo(ctx, domid, device, info):
1919 *
1920 * Initialises info with details of the given device which must be
1921 * attached to the specified domain.
1922 *
1923 * Creation / Control
1924 * ------------------
1925 *
1926 * libxl_device_<type>_add(ctx, domid, device):
1927 *
1928 * Adds the given device to the specified domain. This can be called
1929 * while the guest is running (hotplug) or before boot (coldplug).
1930 *
1931 * This function only sets up the device but does not wait for the
1932 * domain to connect to the device and therefore cannot block on the
1933 * guest.
1934 *
1935 * device is an in/out parameter: fields left unspecified when the
1936 * structure is passed in are filled in with appropriate values for
1937 * the device created.
1938 *
1939 * libxl_device_<type>_remove(ctx, domid, device):
1940 *
1941 * Removes the given device from the specified domain by performing
1942 * an orderly unplug with guest co-operation. This requires that the
1943 * guest is running.
1944 *
1945 * This method is currently synchronous and therefore can block
1946 * while interacting with the guest.
1947 *
1948 * libxl_device_<type>_destroy(ctx, domid, device):
1949 *
1950 * Removes the given device from the specified domain without guest
1951 * co-operation. It is guest specific what affect this will have on
1952 * a running guest.
1953 *
1954 * This function does not interact with the guest and therefore
1955 * cannot block on the guest.
1956 *
1957 * Controllers
1958 * -----------
1959 *
1960 * Most devices are treated individually. Some classes of device,
1961 * however, like USB or SCSI, inherently have the need to have a
1962 * hierarchy of different levels, with lower-level devices "attached"
1963 * to higher-level ones. USB for instance has "controllers" at the
1964 * top, which have buses, on which are devices, which consist of
1965 * multiple interfaces. SCSI has "hosts" at the top, then buses,
1966 * targets, and LUNs.
1967 *
1968 * In that case, for each <class>, there will be a set of functions
1969 * and types for each <level>. For example, for <class>=usb, there
1970 * may be <levels> ctrl (controller) and dev (device), with ctrl being
1971 * level 0.
1972 *
1973 * libxl_device_<class><level0>_<function> will act more or
1974 * less like top-level non-bus devices: they will either create or
1975 * accept a libxl_devid which will be unique within the
1976 * <class><level0> libxl_devid namespace.
1977 *
1978 * Lower-level devices must have a unique way to be identified. One
1979 * way to do this would be to name it via the name of the next level
1980 * up plus an index; for instance, <ctrl devid, port number>. Another
1981 * way would be to have another devid namespace for that level. This
1982 * identifier will be used for queries and removals.
1983 *
1984 * Lower-level devices will include in their
1985 * libxl_device_<class><level> struct a field referring to the unique
1986 * index of the level above. For instance, libxl_device_usbdev might
1987 * contain the controller devid.
1988 *
1989 * In the case where there are multiple different ways to implement a
1990 * given device -- for instance, one which is fully PV and one which
1991 * uses an emulator -- the controller will contain a field which
1992 * specifies what type of implementation is used. The implementations
1993 * of individual devices will be known by the controller to which they
1994 * are attached.
1995 *
1996 * If libxl_device_<class><level>_add receives an empty reference to
1997 * the level above, it may return an error. Or it may (but is not
1998 * required to) automatically choose a suitable device in the level
1999 * above to which to attach the new device at this level. It may also
2000 * (but is not required to) automatically create a new device at the
2001 * level above if no suitable devices exist. Each class should
2002 * document its behavior.
2003 *
2004 * libxl_device_<class><level>_list will list all devices of <class>
2005 * at <level> in the domain. For example, libxl_device_usbctrl_list
2006 * will list all usb controllers; libxl_class_usbdev_list will list
2007 * all usb devices across all controllers.
2008 *
2009 * For each class, the domain config file will contain a single list
2010 * for each level. libxl will first iterate through the list of
2011 * top-level devices, then iterate through each level down in turn,
2012 * adding devices to devices in the level above. For instance, there
2013 * will be one list for all usb controllers, and one list for all usb
2014 * devices.
2015 *
2016 * If libxl_device_<class><level>_add automatically creates
2017 * higher-level devices as necessary, then it is permissible for the
2018 * higher-level lists to be empty and the device list to have devices
2019 * with the field containing a reference to the higher level device
2020 * uninitialized.
2021 */
2022
2023 /* Disks */
2024 int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid,
2025 libxl_device_disk *disk,
2026 const libxl_asyncop_how *ao_how)
2027 LIBXL_EXTERNAL_CALLERS_ONLY;
2028 int libxl_device_disk_remove(libxl_ctx *ctx, uint32_t domid,
2029 libxl_device_disk *disk,
2030 const libxl_asyncop_how *ao_how)
2031 LIBXL_EXTERNAL_CALLERS_ONLY;
2032 int libxl_device_disk_destroy(libxl_ctx *ctx, uint32_t domid,
2033 libxl_device_disk *disk,
2034 const libxl_asyncop_how *ao_how)
2035 LIBXL_EXTERNAL_CALLERS_ONLY;
2036
2037 libxl_device_disk *libxl_device_disk_list(libxl_ctx *ctx,
2038 uint32_t domid, int *num)
2039 LIBXL_EXTERNAL_CALLERS_ONLY;
2040 void libxl_device_disk_list_free(libxl_device_disk* list, int num)
2041 LIBXL_EXTERNAL_CALLERS_ONLY;
2042 int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
2043 const libxl_device_disk *disk, libxl_diskinfo *diskinfo)
2044 LIBXL_EXTERNAL_CALLERS_ONLY;
2045
2046 /*
2047 * Insert a CD-ROM device. A device corresponding to disk must already
2048 * be attached to the guest.
2049 */
2050 int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,
2051 const libxl_asyncop_how *ao_how)
2052 LIBXL_EXTERNAL_CALLERS_ONLY;
2053
2054 /*
2055 * USB
2056 *
2057 * For each device removed or added, one of these protocols is available:
2058 * - PV (i.e., PVUSB)
2059 * - DEVICEMODEL (i.e, qemu)
2060 *
2061 * PV is available for either PV or HVM domains. DEVICEMODEL is only
2062 * available for HVM domains. The caller can additionally specify
2063 * "AUTO", in which case the library will try to determine the best
2064 * protocol automatically.
2065 *
2066 * At the moment, the only protocol implemented is PV.
2067 *
2068 * One can add/remove USB controllers to/from guest, and attach/detach USB
2069 * devices to/from USB controllers.
2070 *
2071 * To add USB controllers and USB devices, one can adding USB controllers
2072 * first and then attaching USB devices to some USB controller, or adding
2073 * USB devices to guest directly, it will automatically create a USB
2074 * controller for USB devices to attach.
2075 *
2076 * To remove USB controllers or USB devices, one can remove USB devices
2077 * under USB controller one by one and then remove USB controller, or
2078 * remove USB controller directly, it will remove all USB devices under
2079 * it automatically.
2080 *
2081 */
2082 /* USB Controllers*/
2083 int libxl_device_usbctrl_add(libxl_ctx *ctx, uint32_t domid,
2084 libxl_device_usbctrl *usbctrl,
2085 const libxl_asyncop_how *ao_how)
2086 LIBXL_EXTERNAL_CALLERS_ONLY;
2087
2088 int libxl_device_usbctrl_remove(libxl_ctx *ctx, uint32_t domid,
2089 libxl_device_usbctrl *usbctrl,
2090 const libxl_asyncop_how *ao_how)
2091 LIBXL_EXTERNAL_CALLERS_ONLY;
2092
2093 int libxl_device_usbctrl_destroy(libxl_ctx *ctx, uint32_t domid,
2094 libxl_device_usbctrl *usbctrl,
2095 const libxl_asyncop_how *ao_how)
2096 LIBXL_EXTERNAL_CALLERS_ONLY;
2097
2098 libxl_device_usbctrl *libxl_device_usbctrl_list(libxl_ctx *ctx,
2099 uint32_t domid, int *num);
2100
2101 void libxl_device_usbctrl_list_free(libxl_device_usbctrl *list, int nr);
2102
2103
2104 int libxl_device_usbctrl_getinfo(libxl_ctx *ctx, uint32_t domid,
2105 const libxl_device_usbctrl *usbctrl,
2106 libxl_usbctrlinfo *usbctrlinfo);
2107
2108 /* USB Devices */
2109
2110 int libxl_device_usbdev_add(libxl_ctx *ctx, uint32_t domid,
2111 libxl_device_usbdev *usbdev,
2112 const libxl_asyncop_how *ao_how)
2113 LIBXL_EXTERNAL_CALLERS_ONLY;
2114
2115 int libxl_device_usbdev_remove(libxl_ctx *ctx, uint32_t domid,
2116 libxl_device_usbdev *usbdev,
2117 const libxl_asyncop_how *ao_how)
2118 LIBXL_EXTERNAL_CALLERS_ONLY;
2119
2120 libxl_device_usbdev *
2121 libxl_device_usbdev_list(libxl_ctx *ctx, uint32_t domid, int *num);
2122
2123 void libxl_device_usbdev_list_free(libxl_device_usbdev *list, int nr);
2124
2125 /* Network Interfaces */
2126 int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic,
2127 const libxl_asyncop_how *ao_how)
2128 LIBXL_EXTERNAL_CALLERS_ONLY;
2129 int libxl_device_nic_remove(libxl_ctx *ctx, uint32_t domid,
2130 libxl_device_nic *nic,
2131 const libxl_asyncop_how *ao_how)
2132 LIBXL_EXTERNAL_CALLERS_ONLY;
2133 int libxl_device_nic_destroy(libxl_ctx *ctx, uint32_t domid,
2134 libxl_device_nic *nic,
2135 const libxl_asyncop_how *ao_how)
2136 LIBXL_EXTERNAL_CALLERS_ONLY;
2137
2138 libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx,
2139 uint32_t domid, int *num)
2140 LIBXL_EXTERNAL_CALLERS_ONLY;
2141 void libxl_device_nic_list_free(libxl_device_nic* list, int num)
2142 LIBXL_EXTERNAL_CALLERS_ONLY;
2143 int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
2144 const libxl_device_nic *nic, libxl_nicinfo *nicinfo)
2145 LIBXL_EXTERNAL_CALLERS_ONLY;
2146
2147 /*
2148 * Virtual Channels
2149 * Channels manifest as consoles with names, see docs/misc/channels.txt
2150 */
2151 libxl_device_channel *libxl_device_channel_list(libxl_ctx *ctx,
2152 uint32_t domid,
2153 int *num);
2154 int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid,
2155 const libxl_device_channel *channel,
2156 libxl_channelinfo *channelinfo);
2157
2158 /* Virtual TPMs */
2159 int libxl_device_vtpm_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vtpm *vtpm,
2160 const libxl_asyncop_how *ao_how)
2161 LIBXL_EXTERNAL_CALLERS_ONLY;
2162 int libxl_device_vtpm_remove(libxl_ctx *ctx, uint32_t domid,
2163 libxl_device_vtpm *vtpm,
2164 const libxl_asyncop_how *ao_how)
2165 LIBXL_EXTERNAL_CALLERS_ONLY;
2166 int libxl_device_vtpm_destroy(libxl_ctx *ctx, uint32_t domid,
2167 libxl_device_vtpm *vtpm,
2168 const libxl_asyncop_how *ao_how)
2169 LIBXL_EXTERNAL_CALLERS_ONLY;
2170
2171 libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx,
2172 uint32_t domid, int *num)
2173 LIBXL_EXTERNAL_CALLERS_ONLY;
2174 void libxl_device_vtpm_list_free(libxl_device_vtpm*, int num)
2175 LIBXL_EXTERNAL_CALLERS_ONLY;
2176 int libxl_device_vtpm_getinfo(libxl_ctx *ctx, uint32_t domid,
2177 const libxl_device_vtpm *vtpm, libxl_vtpminfo *vtpminfo)
2178 LIBXL_EXTERNAL_CALLERS_ONLY;
2179
2180 /* Virtual displays */
2181 int libxl_device_vdispl_add(libxl_ctx *ctx, uint32_t domid,
2182 libxl_device_vdispl *displ,
2183 const libxl_asyncop_how *ao_how)
2184 LIBXL_EXTERNAL_CALLERS_ONLY;
2185 int libxl_device_vdispl_remove(libxl_ctx *ctx, uint32_t domid,
2186 libxl_device_vdispl *vdispl,
2187 const libxl_asyncop_how *ao_how)
2188 LIBXL_EXTERNAL_CALLERS_ONLY;
2189 int libxl_device_vdispl_destroy(libxl_ctx *ctx, uint32_t domid,
2190 libxl_device_vdispl *vdispl,
2191 const libxl_asyncop_how *ao_how)
2192 LIBXL_EXTERNAL_CALLERS_ONLY;
2193
2194 libxl_device_vdispl *libxl_device_vdispl_list(libxl_ctx *ctx,
2195 uint32_t domid, int *num)
2196 LIBXL_EXTERNAL_CALLERS_ONLY;
2197 void libxl_device_vdispl_list_free(libxl_device_vdispl* list, int num)
2198 LIBXL_EXTERNAL_CALLERS_ONLY;
2199 int libxl_device_vdispl_getinfo(libxl_ctx *ctx, uint32_t domid,
2200 const libxl_device_vdispl *vdispl,
2201 libxl_vdisplinfo *vdisplinfo)
2202 LIBXL_EXTERNAL_CALLERS_ONLY;
2203
2204 /* Virtual sounds */
2205 int libxl_device_vsnd_add(libxl_ctx *ctx, uint32_t domid,
2206 libxl_device_vsnd *vsnd,
2207 const libxl_asyncop_how *ao_how)
2208 LIBXL_EXTERNAL_CALLERS_ONLY;
2209 int libxl_device_vsnd_remove(libxl_ctx *ctx, uint32_t domid,
2210 libxl_device_vsnd *vsnd,
2211 const libxl_asyncop_how *ao_how)
2212 LIBXL_EXTERNAL_CALLERS_ONLY;
2213 int libxl_device_vsnd_destroy(libxl_ctx *ctx, uint32_t domid,
2214 libxl_device_vsnd *vsnd,
2215 const libxl_asyncop_how *ao_how)
2216 LIBXL_EXTERNAL_CALLERS_ONLY;
2217
2218 libxl_device_vsnd *libxl_device_vsnd_list(libxl_ctx *ctx,
2219 uint32_t domid, int *num)
2220 LIBXL_EXTERNAL_CALLERS_ONLY;
2221 void libxl_device_vsnd_list_free(libxl_device_vsnd* list, int num)
2222 LIBXL_EXTERNAL_CALLERS_ONLY;
2223 int libxl_device_vsnd_getinfo(libxl_ctx *ctx, uint32_t domid,
2224 const libxl_device_vsnd *vsnd,
2225 libxl_vsndinfo *vsndlinfo)
2226 LIBXL_EXTERNAL_CALLERS_ONLY;
2227
2228 /* Keyboard */
2229 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
2230 const libxl_asyncop_how *ao_how)
2231 LIBXL_EXTERNAL_CALLERS_ONLY;
2232 int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
2233 libxl_device_vkb *vkb,
2234 const libxl_asyncop_how *ao_how)
2235 LIBXL_EXTERNAL_CALLERS_ONLY;
2236 int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid,
2237 libxl_device_vkb *vkb,
2238 const libxl_asyncop_how *ao_how)
2239 LIBXL_EXTERNAL_CALLERS_ONLY;
2240
2241 libxl_device_vkb *libxl_device_vkb_list(libxl_ctx *ctx,
2242 uint32_t domid, int *num)
2243 LIBXL_EXTERNAL_CALLERS_ONLY;
2244 void libxl_device_vkb_list_free(libxl_device_vkb* list, int num)
2245 LIBXL_EXTERNAL_CALLERS_ONLY;
2246 int libxl_device_vkb_getinfo(libxl_ctx *ctx, uint32_t domid,
2247 const libxl_device_vkb *vkb,
2248 libxl_vkbinfo *vkbinfo)
2249 LIBXL_EXTERNAL_CALLERS_ONLY;
2250
2251 /* Framebuffer */
2252 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
2253 const libxl_asyncop_how *ao_how)
2254 LIBXL_EXTERNAL_CALLERS_ONLY;
2255 int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
2256 libxl_device_vfb *vfb,
2257 const libxl_asyncop_how *ao_how)
2258 LIBXL_EXTERNAL_CALLERS_ONLY;
2259 int libxl_device_vfb_destroy(libxl_ctx *ctx, uint32_t domid,
2260 libxl_device_vfb *vfb,
2261 const libxl_asyncop_how *ao_how)
2262 LIBXL_EXTERNAL_CALLERS_ONLY;
2263
2264 /* 9pfs */
2265 int libxl_device_p9_remove(libxl_ctx *ctx, uint32_t domid,
2266 libxl_device_p9 *p9,
2267 const libxl_asyncop_how *ao_how)
2268 LIBXL_EXTERNAL_CALLERS_ONLY;
2269 int libxl_device_p9_destroy(libxl_ctx *ctx, uint32_t domid,
2270 libxl_device_p9 *p9,
2271 const libxl_asyncop_how *ao_how)
2272 LIBXL_EXTERNAL_CALLERS_ONLY;
2273
2274 /* pvcalls interface */
2275 int libxl_device_pvcallsif_remove(libxl_ctx *ctx, uint32_t domid,
2276 libxl_device_pvcallsif *pvcallsif,
2277 const libxl_asyncop_how *ao_how)
2278 LIBXL_EXTERNAL_CALLERS_ONLY;
2279 int libxl_device_pvcallsif_destroy(libxl_ctx *ctx, uint32_t domid,
2280 libxl_device_pvcallsif *pvcallsif,
2281 const libxl_asyncop_how *ao_how)
2282 LIBXL_EXTERNAL_CALLERS_ONLY;
2283
2284 /* PCI Passthrough */
2285 int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid,
2286 libxl_device_pci *pcidev,
2287 const libxl_asyncop_how *ao_how)
2288 LIBXL_EXTERNAL_CALLERS_ONLY;
2289 int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid,
2290 libxl_device_pci *pcidev,
2291 const libxl_asyncop_how *ao_how)
2292 LIBXL_EXTERNAL_CALLERS_ONLY;
2293 int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid,
2294 libxl_device_pci *pcidev,
2295 const libxl_asyncop_how *ao_how)
2296 LIBXL_EXTERNAL_CALLERS_ONLY;
2297
2298 libxl_device_pci *libxl_device_pci_list(libxl_ctx *ctx, uint32_t domid,
2299 int *num);
2300
2301 /*
2302 * Turns the current process into a backend device service daemon
2303 * for a driver domain.
2304 *
2305 * From a libxl API point of view, this starts a long-running
2306 * operation. That operation consists of "being a driver domain"
2307 * and never completes.
2308 *
2309 * Attempting to abort this operation is not advisable; proper
2310 * shutdown of the driver domain task is not supported.
2311 */
2312 int libxl_device_events_handler(libxl_ctx *ctx,
2313 const libxl_asyncop_how *ao_how)
2314 LIBXL_EXTERNAL_CALLERS_ONLY;
2315
2316 /*
2317 * Functions related to making devices assignable -- that is, bound to
2318 * the pciback driver, ready to be given to a guest via
2319 * libxl_pci_device_add.
2320 *
2321 * - ..._add() will unbind the device from its current driver (if
2322 * already bound) and re-bind it to pciback; at that point it will be
2323 * ready to be assigned to a VM. If rebind is set, it will store the
2324 * path to the old driver in xenstore so that it can be handed back to
2325 * dom0 on restore.
2326 *
2327 * - ..._remove() will unbind the device from pciback, and if
2328 * rebind is non-zero, attempt to assign it back to the driver
2329 * from whence it came.
2330 *
2331 * - ..._list() will return a list of the PCI devices available to be
2332 * assigned.
2333 *
2334 * add and remove are idempotent: if the device in question is already
2335 * added or is not bound, the functions will emit a warning but return
2336 * SUCCESS.
2337 */
2338 int libxl_device_pci_assignable_add(libxl_ctx *ctx, libxl_device_pci *pcidev, int rebind);
2339 int libxl_device_pci_assignable_remove(libxl_ctx *ctx, libxl_device_pci *pcidev, int rebind);
2340 libxl_device_pci *libxl_device_pci_assignable_list(libxl_ctx *ctx, int *num);
2341
2342 /* CPUID handling */
2343 int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str);
2344 int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid,
2345 const char* str);
2346 #if LIBXL_API_VERSION < 0x041400
2347 /*
2348 * Dropped from the API in Xen 4.14. At the time of writing, these functions
2349 * don't appear to ever have had external callers.
2350 *
2351 * These have always been used internally during domain construction, and
2352 * can't easily be used externally because of their implicit parameters in
2353 * other pieces of global state.
2354 *
2355 * Furthermore, an API user can't usefully determine whether they get
2356 * libxl_cpuid (the real implementation) or libxl_nocpuid (no-op stubs).
2357 *
2358 * The internal behaviour of these functions also needs to change. Therefore
2359 * for simplicitly, provide the no-op stubs. Yes technically this is an API
2360 * change in some cases for existing software, but there is 0 of that in
2361 * practice.
2362 */
libxl_cpuid_apply_policy(libxl_ctx * ctx,uint32_t domid)2363 static inline void libxl_cpuid_apply_policy(libxl_ctx *ctx __attribute__((unused)),
2364 uint32_t domid __attribute__((unused)))
2365 {}
libxl_cpuid_set(libxl_ctx * ctx,uint32_t domid,libxl_cpuid_policy_list cpuid)2366 static inline void libxl_cpuid_set(libxl_ctx *ctx __attribute__((unused)),
2367 uint32_t domid __attribute__((unused)),
2368 libxl_cpuid_policy_list cpuid __attribute__((unused)))
2369 {}
2370 #endif
2371
2372 /*
2373 * Functions for allowing users of libxl to store private data
2374 * relating to a domain. The data is an opaque sequence of bytes and
2375 * is not interpreted or used by libxl.
2376 *
2377 * Data is indexed by the userdata userid, which is a short printable
2378 * ASCII string. The following list is a registry of userdata userids
2379 * (the registry may be updated by posting a patch to xen-devel):
2380 *
2381 * userid Data contents
2382 * "xl" domain config file in xl format, Unix line endings
2383 * "libvirt-xml" domain config file in libvirt XML format. See
2384 * http://libvirt.org/formatdomain.html
2385 * "domain-userdata-lock" lock file to protect domain userdata in libxl.
2386 * It's a per-domain lock. Applications should
2387 * not touch this file.
2388 * "libxl-json" libxl_domain_config object in JSON format, generated
2389 * by libxl. Applications should not access this file
2390 * directly. This file is protected by domain-userdata-lock
2391 * for against Read-Modify-Write operation and domain
2392 * destruction.
2393 *
2394 * libxl does not enforce the registration of userdata userids or the
2395 * semantics of the data. For specifications of the data formats
2396 * see the code or documentation for the libxl caller in question.
2397 */
2398 int libxl_userdata_store(libxl_ctx *ctx, uint32_t domid,
2399 const char *userdata_userid,
2400 const uint8_t *data, int datalen)
2401 LIBXL_EXTERNAL_CALLERS_ONLY;
2402 /* If datalen==0, data is not used and the user data for
2403 * that domain and userdata_userid is deleted. */
2404 int libxl_userdata_retrieve(libxl_ctx *ctx, uint32_t domid,
2405 const char *userdata_userid,
2406 uint8_t **data_r, int *datalen_r)
2407 LIBXL_EXTERNAL_CALLERS_ONLY;
2408 /* On successful return, *data_r is from malloc.
2409 * If there is no data for that domain and userdata_userid,
2410 * *data_r and *datalen_r will be set to 0.
2411 * data_r and datalen_r may be 0.
2412 * On error return, *data_r and *datalen_r are undefined.
2413 */
2414 int libxl_userdata_unlink(libxl_ctx *ctx, uint32_t domid,
2415 const char *userdata_userid);
2416
2417
2418 int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
2419 int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
2420 const libxl_bitmap *cpumap_hard,
2421 const libxl_bitmap *cpumap_soft);
2422 int libxl_set_vcpuaffinity_force(libxl_ctx *ctx, uint32_t domid,
2423 uint32_t vcpuid,
2424 const libxl_bitmap *cpumap_hard,
2425 const libxl_bitmap *cpumap_soft);
2426 int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,
2427 unsigned int max_vcpus,
2428 const libxl_bitmap *cpumap_hard,
2429 const libxl_bitmap *cpumap_soft);
2430
2431 #if defined (LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040500
2432
2433 #define libxl_set_vcpuaffinity(ctx, domid, vcpuid, map) \
2434 libxl_set_vcpuaffinity((ctx), (domid), (vcpuid), (map), NULL)
2435 #define libxl_set_vcpuaffinity_all(ctx, domid, max_vcpus, map) \
2436 libxl_set_vcpuaffinity_all((ctx), (domid), (max_vcpus), (map), NULL)
2437
2438 #endif
2439
2440 int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
2441 libxl_bitmap *nodemap);
2442 int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
2443 libxl_bitmap *nodemap);
2444 int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid,
2445 libxl_bitmap *cpumap,
2446 const libxl_asyncop_how *ao_how)
2447 LIBXL_EXTERNAL_CALLERS_ONLY;
2448 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
libxl_set_vcpuonline_0x041200(libxl_ctx * ctx,uint32_t domid,libxl_bitmap * cpumap)2449 static inline int libxl_set_vcpuonline_0x041200(libxl_ctx *ctx,
2450 uint32_t domid,
2451 libxl_bitmap *cpumap)
2452 {
2453 return libxl_set_vcpuonline(ctx, domid, cpumap, NULL);
2454 }
2455 #define libxl_set_vcpuonline libxl_set_vcpuonline_0x041200
2456 #endif
2457
2458 /* A return value less than 0 should be interpreted as a libxl_error, while a
2459 * return value greater than or equal to 0 should be interpreted as a
2460 * libxl_scheduler. */
2461 int libxl_get_scheduler(libxl_ctx *ctx);
2462
2463 /* Per-scheduler parameters */
2464 int libxl_sched_credit_params_get(libxl_ctx *ctx, uint32_t poolid,
2465 libxl_sched_credit_params *scinfo);
2466 int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid,
2467 libxl_sched_credit_params *scinfo);
2468 int libxl_sched_credit2_params_get(libxl_ctx *ctx, uint32_t poolid,
2469 libxl_sched_credit2_params *scinfo);
2470 int libxl_sched_credit2_params_set(libxl_ctx *ctx, uint32_t poolid,
2471 libxl_sched_credit2_params *scinfo);
2472
2473 /* Scheduler Per-domain parameters */
2474
2475 #define LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT -1
2476 #define LIBXL_DOMAIN_SCHED_PARAM_CAP_DEFAULT -1
2477 #define LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT -1
2478 #define LIBXL_DOMAIN_SCHED_PARAM_SLICE_DEFAULT -1
2479 #define LIBXL_DOMAIN_SCHED_PARAM_LATENCY_DEFAULT -1
2480 #define LIBXL_DOMAIN_SCHED_PARAM_EXTRATIME_DEFAULT -1
2481 #define LIBXL_DOMAIN_SCHED_PARAM_BUDGET_DEFAULT -1
2482
2483 /* Per-VCPU parameters */
2484 #define LIBXL_SCHED_PARAM_VCPU_INDEX_DEFAULT -1
2485
2486 /* Get the per-domain scheduling parameters.
2487 * For schedulers that support per-vcpu settings (e.g., RTDS),
2488 * calling *_domain_get functions will get default scheduling
2489 * parameters.
2490 */
2491 int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
2492 libxl_domain_sched_params *params);
2493
2494 /* Set the per-domain scheduling parameters.
2495 * For schedulers that support per-vcpu settings (e.g., RTDS),
2496 * calling *_domain_set functions will set all vcpus with the same
2497 * scheduling parameters.
2498 */
2499 int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,
2500 const libxl_domain_sched_params *params);
2501
2502 /* Get the per-vcpu scheduling parameters */
2503 int libxl_vcpu_sched_params_get(libxl_ctx *ctx, uint32_t domid,
2504 libxl_vcpu_sched_params *params);
2505
2506 /* Get the per-vcpu scheduling parameters of all vcpus of a domain */
2507 int libxl_vcpu_sched_params_get_all(libxl_ctx *ctx, uint32_t domid,
2508 libxl_vcpu_sched_params *params);
2509
2510 /* Set the per-vcpu scheduling parameters */
2511 int libxl_vcpu_sched_params_set(libxl_ctx *ctx, uint32_t domid,
2512 const libxl_vcpu_sched_params *params);
2513
2514 /* Set the per-vcpu scheduling parameters of all vcpus of a domain */
2515 int libxl_vcpu_sched_params_set_all(libxl_ctx *ctx, uint32_t domid,
2516 const libxl_vcpu_sched_params *params);
2517
2518 int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
2519 libxl_trigger trigger, uint32_t vcpuid,
2520 const libxl_asyncop_how *ao_how)
2521 LIBXL_EXTERNAL_CALLERS_ONLY;
2522 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
libxl_send_trigger_0x041200(libxl_ctx * ctx,uint32_t domid,libxl_trigger trigger,uint32_t vcpuid)2523 static inline int libxl_send_trigger_0x041200(
2524 libxl_ctx *ctx, uint32_t domid, libxl_trigger trigger, uint32_t vcpuid)
2525 {
2526 return libxl_send_trigger(ctx, domid, trigger, vcpuid, NULL);
2527 }
2528 #define libxl_send_trigger libxl_send_trigger_0x041200
2529 #endif
2530 int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq);
2531 int libxl_send_debug_keys(libxl_ctx *ctx, char *keys);
2532 int libxl_set_parameters(libxl_ctx *ctx, char *params);
2533
2534 typedef struct libxl__xen_console_reader libxl_xen_console_reader;
2535
2536 libxl_xen_console_reader *
2537 libxl_xen_console_read_start(libxl_ctx *ctx, int clear);
2538 int libxl_xen_console_read_line(libxl_ctx *ctx,
2539 libxl_xen_console_reader *cr,
2540 char **line_r);
2541 void libxl_xen_console_read_finish(libxl_ctx *ctx,
2542 libxl_xen_console_reader *cr);
2543
2544 uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, uint32_t domid);
2545
2546 char *libxl_tmem_list(libxl_ctx *ctx, uint32_t domid, int use_long);
2547 int libxl_tmem_freeze(libxl_ctx *ctx, uint32_t domid);
2548 int libxl_tmem_thaw(libxl_ctx *ctx, uint32_t domid);
2549 int libxl_tmem_set(libxl_ctx *ctx, uint32_t domid, char* name,
2550 uint32_t set);
2551 int libxl_tmem_shared_auth(libxl_ctx *ctx, uint32_t domid, char* uuid,
2552 int auth);
2553 int libxl_tmem_freeable(libxl_ctx *ctx);
2554
2555 int libxl_get_freecpus(libxl_ctx *ctx, libxl_bitmap *cpumap);
2556
2557 /*
2558 * Set poolid to LIBXL_CPUOOL_POOLID_ANY to have Xen choose a
2559 * free poolid for you.
2560 */
2561 #define LIBXL_CPUPOOL_POOLID_ANY 0xFFFFFFFF
2562 int libxl_cpupool_create(libxl_ctx *ctx, const char *name,
2563 libxl_scheduler sched,
2564 libxl_bitmap cpumap, libxl_uuid *uuid,
2565 uint32_t *poolid);
2566 int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid);
2567 int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid);
2568 int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu);
2569 int libxl_cpupool_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
2570 int libxl_cpupool_cpuadd_cpumap(libxl_ctx *ctx, uint32_t poolid,
2571 const libxl_bitmap *cpumap);
2572 int libxl_cpupool_cpuremove(libxl_ctx *ctx, uint32_t poolid, int cpu);
2573 int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
2574 int libxl_cpupool_cpuremove_cpumap(libxl_ctx *ctx, uint32_t poolid,
2575 const libxl_bitmap *cpumap);
2576 int libxl_cpupool_movedomain(libxl_ctx *ctx, uint32_t poolid, uint32_t domid);
2577 int libxl_cpupool_info(libxl_ctx *ctx, libxl_cpupoolinfo *info, uint32_t poolid);
2578
2579 int libxl_domid_valid_guest(uint32_t domid);
2580
2581 int libxl_flask_context_to_sid(libxl_ctx *ctx, char *buf, size_t len,
2582 uint32_t *ssidref);
2583 int libxl_flask_sid_to_context(libxl_ctx *ctx, uint32_t ssidref, char **buf,
2584 size_t *len);
2585 int libxl_flask_getenforce(libxl_ctx *ctx);
2586 int libxl_flask_setenforce(libxl_ctx *ctx, int mode);
2587 int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);
2588
2589 int libxl_ms_vm_genid_generate(libxl_ctx *ctx, libxl_ms_vm_genid *id);
2590 bool libxl_ms_vm_genid_is_zero(const libxl_ms_vm_genid *id);
2591 void libxl_ms_vm_genid_copy(libxl_ctx *ctx, libxl_ms_vm_genid *dst,
2592 const libxl_ms_vm_genid *src);
2593
2594 #if defined(__i386__) || defined(__x86_64__)
2595 int libxl_psr_cmt_attach(libxl_ctx *ctx, uint32_t domid);
2596 int libxl_psr_cmt_detach(libxl_ctx *ctx, uint32_t domid);
2597 int libxl_psr_cmt_domain_attached(libxl_ctx *ctx, uint32_t domid);
2598 int libxl_psr_cmt_enabled(libxl_ctx *ctx);
2599 int libxl_psr_cmt_get_total_rmid(libxl_ctx *ctx, uint32_t *total_rmid);
2600 int libxl_psr_cmt_get_l3_cache_size(libxl_ctx *ctx,
2601 uint32_t socketid,
2602 uint32_t *l3_cache_size);
2603 int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx,
2604 uint32_t domid,
2605 uint32_t socketid,
2606 uint32_t *l3_cache_occupancy);
2607
2608 int libxl_psr_cmt_type_supported(libxl_ctx *ctx, libxl_psr_cmt_type type);
2609 int libxl_psr_cmt_get_sample(libxl_ctx *ctx,
2610 uint32_t domid,
2611 libxl_psr_cmt_type type,
2612 uint64_t scope,
2613 uint64_t *sample_r,
2614 uint64_t *tsc_r);
2615
2616 /*
2617 * Function to set a domain's cbm. It operates on a single or multiple
2618 * target(s) defined in 'target_map'. The definition of 'target_map' is
2619 * related to 'type':
2620 * 'L3_CBM': 'target_map' specifies all the sockets to be operated on.
2621 */
2622 int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
2623 libxl_psr_cbm_type type, libxl_bitmap *target_map,
2624 uint64_t cbm);
2625 /*
2626 * Function to get a domain's cbm. It operates on a single 'target'.
2627 * The definition of 'target' is related to 'type':
2628 * 'L3_CBM': 'target' specifies which socket to be operated on.
2629 */
2630 int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
2631 libxl_psr_cbm_type type, uint32_t target,
2632 uint64_t *cbm_r);
2633
2634 /*
2635 * On success, the function returns an array of elements in 'info',
2636 * and the length in 'nr'.
2637 */
2638 int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
2639 unsigned int *nr, unsigned int lvl);
2640 int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
2641 int *nr);
2642 void libxl_psr_cat_info_list_free(libxl_psr_cat_info *list, int nr);
2643
2644 typedef enum libxl_psr_cbm_type libxl_psr_type;
2645
2646 /*
2647 * Function to set a domain's value. It operates on a single or multiple
2648 * target(s) defined in 'target_map'. 'target_map' specifies all the sockets
2649 * to be operated on.
2650 */
2651 int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
2652 libxl_psr_type type, libxl_bitmap *target_map,
2653 uint64_t val);
2654 /*
2655 * Function to get a domain's cbm. It operates on a single 'target'.
2656 * 'target' specifies which socket to be operated on.
2657 */
2658 int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
2659 libxl_psr_type type, unsigned int target,
2660 uint64_t *val);
2661 /*
2662 * On success, the function returns an array of elements in 'info',
2663 * and the length in 'nr'.
2664 */
2665 int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_feat_type type,
2666 unsigned int lvl, unsigned int *nr,
2667 libxl_psr_hw_info **info);
2668 void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr);
2669 #endif
2670
2671 /* misc */
2672
2673 /* Each of these sets or clears the flag according to whether the
2674 * 2nd parameter is nonzero. On failure, they log, and
2675 * return ERROR_FAIL, but also leave errno valid. */
2676 int libxl_fd_set_cloexec(libxl_ctx *ctx, int fd, int cloexec);
2677 int libxl_fd_set_nonblock(libxl_ctx *ctx, int fd, int nonblock);
2678
2679 /*
2680 * Issue a qmp monitor command to the device model of the specified domain.
2681 * The function returns the output of the command in a new allocated buffer
2682 * via output.
2683 */
2684 int libxl_qemu_monitor_command(libxl_ctx *ctx, uint32_t domid,
2685 const char *command_line, char **output,
2686 const libxl_asyncop_how *ao_how)
2687 LIBXL_EXTERNAL_CALLERS_ONLY;
2688 #if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300
libxl_qemu_monitor_command_0x041200(libxl_ctx * ctx,uint32_t domid,const char * command_line,char ** output)2689 static inline int libxl_qemu_monitor_command_0x041200(libxl_ctx *ctx,
2690 uint32_t domid, const char *command_line, char **output)
2691 {
2692 return libxl_qemu_monitor_command(ctx, domid, command_line, output,
2693 NULL);
2694 }
2695 #define libxl_qemu_monitor_command libxl_qemu_monitor_command_0x041200
2696 #endif
2697
2698 #include <libxl_event.h>
2699
2700 /*
2701 * This function is for use only during host initialisation. If it is
2702 * invoked on a host with running domains, or concurrent libxl
2703 * processes then the system may malfuntion.
2704 */
2705 int libxl_clear_domid_history(libxl_ctx *ctx);
2706
2707 #endif /* LIBXL_H */
2708
2709 /*
2710 * Local variables:
2711 * mode: C
2712 * c-basic-offset: 4
2713 * indent-tabs-mode: nil
2714 * End:
2715 */
2716