direct-io.hg

annotate tools/libxc/xenctrl.h @ 15482:89d2192942be

Extended the physinfo sysctl to export NUMA cpu_to_node topology info.
Print this in 'xm info'.
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Jul 06 16:12:07 2007 +0100 (2007-07-06)
parents 05331a29f3cb
children d7e3224b661a
rev   line source
mjw@1623 1 /******************************************************************************
cl349@6388 2 * xenctrl.h
kaf24@9660 3 *
mjw@1623 4 * A library for low-level access to the Xen control interfaces.
kaf24@9660 5 *
kaf24@2787 6 * Copyright (c) 2003-2004, K A Fraser.
keir@14681 7 *
keir@14681 8 * xc_gnttab functions:
keir@14681 9 * Copyright (c) 2007, D G Murray <Derek.Murray@cl.cam.ac.uk>
mjw@1623 10 */
mjw@1623 11
cl349@6389 12 #ifndef XENCTRL_H
cl349@6389 13 #define XENCTRL_H
mjw@1623 14
kaf24@11393 15 /* Tell the Xen public headers we are a user-space tools build. */
kaf24@11393 16 #ifndef __XEN_TOOLS__
kaf24@11393 17 #define __XEN_TOOLS__ 1
kaf24@11393 18 #endif
kaf24@11393 19
kaf24@9999 20 #include <stddef.h>
kaf24@3266 21 #include <stdint.h>
kaf24@2821 22 #include <xen/xen.h>
kfraser@11257 23 #include <xen/domctl.h>
kfraser@11257 24 #include <xen/sysctl.h>
vh249@6549 25 #include <xen/version.h>
kaf24@2821 26 #include <xen/event_channel.h>
kaf24@7196 27 #include <xen/sched.h>
smh22@7702 28 #include <xen/memory.h>
kaf24@5541 29 #include <xen/acm.h>
kaf24@9907 30 #include <xen/acm_ops.h>
kaf24@2787 31
kaf24@5914 32 #ifdef __ia64__
kaf24@5914 33 #define XC_PAGE_SHIFT 14
kaf24@5914 34 #else
kaf24@5914 35 #define XC_PAGE_SHIFT 12
kaf24@5914 36 #endif
kaf24@5914 37 #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT)
kaf24@5914 38 #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1))
kaf24@5914 39
kaf24@3961 40 /*
kaf24@3961 41 * DEFINITIONS FOR CPU BARRIERS
kaf24@9660 42 */
kaf24@3961 43
kaf24@3961 44 #if defined(__i386__)
kaf24@3966 45 #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
kaf24@3966 46 #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
kaf24@3966 47 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
kaf24@3961 48 #elif defined(__x86_64__)
kaf24@3966 49 #define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
kaf24@3966 50 #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
kaf24@3966 51 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
kaf24@5914 52 #elif defined(__ia64__)
kfraser@12271 53 #define mb() __asm__ __volatile__ ("mf" ::: "memory")
kfraser@12271 54 #define rmb() __asm__ __volatile__ ("mf" ::: "memory")
kfraser@12271 55 #define wmb() __asm__ __volatile__ ("mf" ::: "memory")
kaf24@10687 56 #elif defined(__powerpc__)
kaf24@10687 57 /* XXX loosen these up later */
kaf24@10687 58 #define mb() __asm__ __volatile__ ("sync" : : : "memory")
kaf24@10687 59 #define rmb() __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
kaf24@10687 60 #define wmb() __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
kaf24@3961 61 #else
kaf24@3961 62 #error "Define barriers"
kaf24@3961 63 #endif
kaf24@3961 64
kaf24@3961 65 /*
iap10@3443 66 * INITIALIZATION FUNCTIONS
kaf24@9660 67 */
iap10@3443 68
iap10@3443 69 /**
iap10@3443 70 * This function opens a handle to the hypervisor interface. This function can
iap10@3443 71 * be called multiple times within a single process. Multiple processes can
iap10@3443 72 * have an open hypervisor interface at the same time.
iap10@3443 73 *
iap10@3443 74 * Each call to this function should have a corresponding call to
iap10@3443 75 * xc_interface_close().
iap10@3443 76 *
iap10@3443 77 * This function can fail if the caller does not have superuser permission or
iap10@3443 78 * if a Xen-enabled kernel is not currently running.
iap10@3443 79 *
iap10@3443 80 * @return a handle to the hypervisor interface or -1 on failure
iap10@3443 81 */
mjw@1623 82 int xc_interface_open(void);
iap10@3443 83
iap10@3443 84 /**
iap10@3443 85 * This function closes an open hypervisor interface.
iap10@3443 86 *
iap10@3443 87 * This function can fail if the handle does not represent an open interface or
iap10@3443 88 * if there were problems closing the interface.
iap10@3443 89 *
iap10@3443 90 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 91 * @return 0 on success, -1 otherwise.
iap10@3443 92 */
mjw@1623 93 int xc_interface_close(int xc_handle);
mjw@1623 94
kaf24@3961 95 /*
kfraser@11672 96 * KERNEL INTERFACES
kfraser@11672 97 */
kfraser@11672 98
kfraser@11672 99 /*
kfraser@11672 100 * Resolve a kernel device name (e.g., "evtchn", "blktap0") into a kernel
kfraser@11672 101 * device number. Returns -1 on error (and sets errno).
kfraser@11672 102 */
kfraser@11672 103 int xc_find_device_number(const char *name);
kfraser@11672 104
kfraser@11672 105 /*
kaf24@4719 106 * DOMAIN DEBUGGING FUNCTIONS
kaf24@4719 107 */
kaf24@4719 108
kaf24@4719 109 typedef struct xc_core_header {
kaf24@4719 110 unsigned int xch_magic;
kaf24@4719 111 unsigned int xch_nr_vcpus;
kaf24@4719 112 unsigned int xch_nr_pages;
kaf24@4719 113 unsigned int xch_ctxt_offset;
kaf24@4719 114 unsigned int xch_index_offset;
kaf24@4719 115 unsigned int xch_pages_offset;
kaf24@4719 116 } xc_core_header_t;
kaf24@4719 117
kfraser@12224 118 #define XC_CORE_MAGIC 0xF00FEBED
kfraser@12224 119 #define XC_CORE_MAGIC_HVM 0xF00FEBEE
kaf24@4719 120
kfraser@11791 121 #ifdef __linux__
kfraser@11791 122
kfraser@11791 123 #include <sys/ptrace.h>
kfraser@11791 124 #include <thread_db.h>
kfraser@11791 125
kfraser@11774 126 typedef void (*thr_ev_handler_t)(long);
kfraser@11774 127
kfraser@11774 128 void xc_register_event_handler(
kfraser@11774 129 thr_ev_handler_t h,
kfraser@11774 130 td_event_e e);
kfraser@11774 131
kfraser@11774 132 long xc_ptrace(
kfraser@11774 133 int xc_handle,
kfraser@11774 134 enum __ptrace_request request,
kfraser@11774 135 uint32_t domid,
kfraser@11774 136 long addr,
kfraser@11774 137 long data);
kfraser@11774 138
kfraser@11774 139 int xc_waitdomain(
kfraser@11774 140 int xc_handle,
kfraser@11774 141 int domain,
kfraser@11774 142 int *status,
kfraser@11774 143 int options);
kfraser@11774 144
kfraser@11774 145 #endif /* __linux__ */
kaf24@4719 146
kaf24@4719 147 /*
iap10@3443 148 * DOMAIN MANAGEMENT FUNCTIONS
kaf24@3961 149 */
iap10@3443 150
kfraser@12224 151 typedef struct xc_dominfo {
kaf24@7378 152 uint32_t domid;
kaf24@7378 153 uint32_t ssidref;
kaf24@9660 154 unsigned int dying:1, crashed:1, shutdown:1,
kfraser@12224 155 paused:1, blocked:1, running:1,
kfraser@15478 156 hvm:1, debugged:1;
mjw@1623 157 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
mjw@1623 158 unsigned long nr_pages;
mjw@1623 159 unsigned long shared_info_frame;
kaf24@7378 160 uint64_t cpu_time;
mjw@1623 161 unsigned long max_memkb;
kaf24@7397 162 unsigned int nr_online_vcpus;
kaf24@7397 163 unsigned int max_vcpu_id;
kaf24@7378 164 xen_domain_handle_t handle;
mjw@1623 165 } xc_dominfo_t;
mjw@1623 166
kfraser@11257 167 typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
kaf24@9660 168 int xc_domain_create(int xc_handle,
kaf24@7339 169 uint32_t ssidref,
kaf24@7378 170 xen_domain_handle_t handle,
kfraser@12196 171 uint32_t flags,
kaf24@7339 172 uint32_t *pdomid);
iap10@3443 173
kaf24@4719 174
kaf24@9221 175 /* Functions to produce a dump of a given domain
kaf24@9221 176 * xc_domain_dumpcore - produces a dump to a specified file
kaf24@9221 177 * xc_domain_dumpcore_via_callback - produces a dump, using a specified
kaf24@9221 178 * callback function
kaf24@9221 179 */
kaf24@9660 180 int xc_domain_dumpcore(int xc_handle,
kaf24@7339 181 uint32_t domid,
cl349@4853 182 const char *corename);
kaf24@4719 183
kaf24@9221 184 /* Define the callback function type for xc_domain_dumpcore_via_callback.
kaf24@9221 185 *
kaf24@9221 186 * This function is called by the coredump code for every "write",
kaf24@9221 187 * and passes an opaque object for the use of the function and
kaf24@9221 188 * created by the caller of xc_domain_dumpcore_via_callback.
kaf24@9221 189 */
kaf24@9221 190 typedef int (dumpcore_rtn_t)(void *arg, char *buffer, unsigned int length);
kaf24@9221 191
kaf24@9660 192 int xc_domain_dumpcore_via_callback(int xc_handle,
kaf24@9221 193 uint32_t domid,
kaf24@9221 194 void *arg,
kaf24@9221 195 dumpcore_rtn_t dump_rtn);
kaf24@9221 196
kaf24@7354 197 /*
kaf24@7566 198 * This function sets the maximum number of vcpus that a domain may create.
kaf24@7354 199 *
kaf24@7354 200 * @parm xc_handle a handle to an open hypervisor interface.
kaf24@7354 201 * @parm domid the domain id in which vcpus are to be created.
kaf24@7354 202 * @parm max the maximum number of vcpus that the domain may create.
kaf24@7354 203 * @return 0 on success, -1 on failure.
kaf24@7354 204 */
kaf24@7354 205 int xc_domain_max_vcpus(int xc_handle,
kaf24@9660 206 uint32_t domid,
kaf24@7354 207 unsigned int max);
kaf24@4719 208
iap10@3443 209 /**
iap10@3443 210 * This function pauses a domain. A paused domain still exists in memory
iap10@3443 211 * however it does not receive any timeslices from the hypervisor.
iap10@3443 212 *
iap10@3443 213 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 214 * @parm domid the domain id to pause
iap10@3443 215 * @return 0 on success, -1 on failure.
iap10@3443 216 */
kaf24@9660 217 int xc_domain_pause(int xc_handle,
kaf24@7339 218 uint32_t domid);
iap10@3443 219 /**
iap10@3443 220 * This function unpauses a domain. The domain should have been previously
iap10@3443 221 * paused.
iap10@3443 222 *
iap10@3443 223 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 224 * @parm domid the domain id to unpause
iap10@3443 225 * return 0 on success, -1 on failure
iap10@3443 226 */
kaf24@9660 227 int xc_domain_unpause(int xc_handle,
kaf24@7339 228 uint32_t domid);
iap10@3443 229
iap10@3443 230 /**
iap10@3443 231 * This function will destroy a domain. Destroying a domain removes the domain
iap10@3443 232 * completely from memory. This function should be called after sending the
iap10@3443 233 * domain a SHUTDOWN control message to free up the domain resources.
iap10@3443 234 *
iap10@3443 235 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 236 * @parm domid the domain id to destroy
iap10@3443 237 * @return 0 on success, -1 on failure
iap10@3443 238 */
kaf24@9660 239 int xc_domain_destroy(int xc_handle,
kaf24@7339 240 uint32_t domid);
kaf24@8500 241
kfraser@13516 242
kfraser@13516 243 /**
kfraser@13516 244 * This function resumes a suspended domain. The domain should have
kfraser@13516 245 * been previously suspended.
kfraser@13516 246 *
kfraser@13516 247 * @parm xc_handle a handle to an open hypervisor interface
kfraser@13516 248 * @parm domid the domain id to resume
kfraser@14160 249 * @parm fast use cooperative resume (guest must support this)
kfraser@13516 250 * return 0 on success, -1 on failure
kfraser@13516 251 */
kfraser@13516 252 int xc_domain_resume(int xc_handle,
kfraser@14160 253 uint32_t domid,
kfraser@14160 254 int fast);
kfraser@13516 255
kaf24@9560 256 /**
kaf24@9560 257 * This function will shutdown a domain. This is intended for use in
kaf24@9560 258 * fully-virtualized domains where this operation is analogous to the
kaf24@9560 259 * sched_op operations in a paravirtualized domain. The caller is
kaf24@9560 260 * expected to give the reason for the shutdown.
kaf24@9560 261 *
kaf24@9560 262 * @parm xc_handle a handle to an open hypervisor interface
kaf24@9560 263 * @parm domid the domain id to destroy
kaf24@9560 264 * @parm reason is the reason (SHUTDOWN_xxx) for the shutdown
kaf24@9560 265 * @return 0 on success, -1 on failure
kaf24@9560 266 */
kaf24@9660 267 int xc_domain_shutdown(int xc_handle,
kaf24@9560 268 uint32_t domid,
kaf24@9560 269 int reason);
kaf24@9560 270
kaf24@8500 271 int xc_vcpu_setaffinity(int xc_handle,
kaf24@8500 272 uint32_t domid,
kaf24@8500 273 int vcpu,
kfraser@11257 274 uint64_t cpumap);
kfraser@11257 275 int xc_vcpu_getaffinity(int xc_handle,
kfraser@11257 276 uint32_t domid,
kfraser@11257 277 int vcpu,
kfraser@11257 278 uint64_t *cpumap);
kaf24@7378 279
iap10@3443 280 /**
dsteklof@5498 281 * This function will return information about one or more domains. It is
dsteklof@5498 282 * designed to iterate over the list of domains. If a single domain is
dsteklof@5498 283 * requested, this function will return the next domain in the list - if
dsteklof@5498 284 * one exists. It is, therefore, important in this case to make sure the
dsteklof@5498 285 * domain requested was the one returned.
iap10@3443 286 *
iap10@3443 287 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 288 * @parm first_domid the first domain to enumerate information from. Domains
iap10@3443 289 * are currently enumerate in order of creation.
iap10@3443 290 * @parm max_doms the number of elements in info
iap10@3443 291 * @parm info an array of max_doms size that will contain the information for
iap10@3443 292 * the enumerated domains.
iap10@3443 293 * @return the number of domains enumerated or -1 on error
iap10@3443 294 */
mjw@1623 295 int xc_domain_getinfo(int xc_handle,
kaf24@9660 296 uint32_t first_domid,
mjw@1623 297 unsigned int max_doms,
mjw@1623 298 xc_dominfo_t *info);
iap10@3443 299
kaf24@8381 300
kaf24@8381 301 /**
kaf24@8500 302 * This function will set the execution context for the specified vcpu.
kaf24@8381 303 *
kaf24@8381 304 * @parm xc_handle a handle to an open hypervisor interface
kaf24@8381 305 * @parm domid the domain to set the vcpu context for
kaf24@8381 306 * @parm vcpu the vcpu number for the context
kaf24@8381 307 * @parm ctxt pointer to the the cpu context with the values to set
kaf24@8381 308 * @return the number of domains enumerated or -1 on error
kaf24@8381 309 */
kaf24@8500 310 int xc_vcpu_setcontext(int xc_handle,
kaf24@8500 311 uint32_t domid,
kaf24@8500 312 uint32_t vcpu,
kaf24@8500 313 vcpu_guest_context_t *ctxt);
iap10@3443 314 /**
kaf24@5699 315 * This function will return information about one or more domains, using a
kaf24@5699 316 * single hypercall. The domain information will be stored into the supplied
kaf24@5699 317 * array of xc_domaininfo_t structures.
kaf24@5699 318 *
kaf24@5699 319 * @parm xc_handle a handle to an open hypervisor interface
kaf24@5699 320 * @parm first_domain the first domain to enumerate information from.
kaf24@5699 321 * Domains are currently enumerate in order of creation.
kaf24@5699 322 * @parm max_domains the number of elements in info
kaf24@5699 323 * @parm info an array of max_doms size that will contain the information for
kaf24@5699 324 * the enumerated domains.
kaf24@5699 325 * @return the number of domains enumerated or -1 on error
kaf24@5699 326 */
kaf24@5699 327 int xc_domain_getinfolist(int xc_handle,
kaf24@7339 328 uint32_t first_domain,
kaf24@5699 329 unsigned int max_domains,
kaf24@5699 330 xc_domaininfo_t *info);
kaf24@5699 331
kaf24@5699 332 /**
Tim@13414 333 * This function returns information about the context of a hvm domain
Tim@13414 334 * @parm xc_handle a handle to an open hypervisor interface
Tim@13414 335 * @parm domid the domain to get information from
Tim@13757 336 * @parm ctxt_buf a pointer to a structure to store the execution context of
Tim@13757 337 * the hvm domain
Tim@13757 338 * @parm size the size of ctxt_buf in bytes
Tim@13414 339 * @return 0 on success, -1 on failure
Tim@13414 340 */
Tim@13414 341 int xc_domain_hvm_getcontext(int xc_handle,
Tim@13414 342 uint32_t domid,
Tim@13757 343 uint8_t *ctxt_buf,
Tim@13757 344 uint32_t size);
Tim@13414 345
Tim@13414 346 /**
Tim@13414 347 * This function will set the context for hvm domain
Tim@13414 348 *
Tim@13414 349 * @parm xc_handle a handle to an open hypervisor interface
Tim@13414 350 * @parm domid the domain to set the hvm domain context for
Tim@13414 351 * @parm hvm_ctxt pointer to the the hvm context with the values to set
Tim@13757 352 * @parm size the size of hvm_ctxt in bytes
Tim@13414 353 * @return 0 on success, -1 on failure
Tim@13414 354 */
Tim@13414 355 int xc_domain_hvm_setcontext(int xc_handle,
Tim@13414 356 uint32_t domid,
Tim@13757 357 uint8_t *hvm_ctxt,
Tim@13757 358 uint32_t size);
Tim@13414 359
Tim@13414 360 /**
emellor@7404 361 * This function returns information about the execution context of a
emellor@7404 362 * particular vcpu of a domain.
iap10@3443 363 *
iap10@3443 364 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 365 * @parm domid the domain to get information from
emellor@7404 366 * @parm vcpu the vcpu number
iap10@3443 367 * @parm ctxt a pointer to a structure to store the execution context of the
iap10@3443 368 * domain
iap10@3443 369 * @return 0 on success, -1 on failure
iap10@3443 370 */
kaf24@8500 371 int xc_vcpu_getcontext(int xc_handle,
kfraser@13525 372 uint32_t domid,
kfraser@13525 373 uint32_t vcpu,
kfraser@13525 374 vcpu_guest_context_t *ctxt);
cl349@4849 375
kfraser@11257 376 typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t;
kaf24@8500 377 int xc_vcpu_getinfo(int xc_handle,
kaf24@8500 378 uint32_t domid,
kaf24@8500 379 uint32_t vcpu,
kaf24@8500 380 xc_vcpuinfo_t *info);
kaf24@7397 381
gm281@2236 382 int xc_domain_setcpuweight(int xc_handle,
kaf24@7339 383 uint32_t domid,
gm281@2236 384 float weight);
kaf24@2787 385 long long xc_domain_get_cpu_usage(int xc_handle,
mafetter@3435 386 domid_t domid,
mafetter@3435 387 int vcpu);
mjw@1623 388
kaf24@9660 389 int xc_domain_sethandle(int xc_handle, uint32_t domid,
kaf24@7379 390 xen_domain_handle_t handle);
kaf24@2787 391
kfraser@11257 392 typedef xen_domctl_shadow_op_stats_t xc_shadow_op_stats_t;
mjw@1623 393 int xc_shadow_control(int xc_handle,
kaf24@9660 394 uint32_t domid,
mjw@1623 395 unsigned int sop,
mjw@1623 396 unsigned long *dirty_bitmap,
mjw@1623 397 unsigned long pages,
tdeegan@11151 398 unsigned long *mb,
tdeegan@11151 399 uint32_t mode,
kfraser@11257 400 xc_shadow_op_stats_t *stats);
mjw@1623 401
sd386@3449 402 int xc_sedf_domain_set(int xc_handle,
kaf24@7339 403 uint32_t domid,
kaf24@7339 404 uint64_t period, uint64_t slice,
kaf24@7339 405 uint64_t latency, uint16_t extratime,
kaf24@7339 406 uint16_t weight);
sd386@3449 407
sd386@3449 408 int xc_sedf_domain_get(int xc_handle,
kaf24@7339 409 uint32_t domid,
kaf24@7339 410 uint64_t* period, uint64_t *slice,
kaf24@7339 411 uint64_t *latency, uint16_t *extratime,
kaf24@7339 412 uint16_t *weight);
sd386@3449 413
kaf24@10174 414 int xc_sched_credit_domain_set(int xc_handle,
kaf24@10174 415 uint32_t domid,
kfraser@11257 416 struct xen_domctl_sched_credit *sdom);
ack@10168 417
kaf24@10174 418 int xc_sched_credit_domain_get(int xc_handle,
kaf24@10174 419 uint32_t domid,
kfraser@11257 420 struct xen_domctl_sched_credit *sdom);
ack@10168 421
keir@14098 422 /**
keir@14098 423 * This function sends a trigger to a domain.
keir@14098 424 *
keir@14098 425 * @parm xc_handle a handle to an open hypervisor interface
keir@14098 426 * @parm domid the domain id to send trigger
keir@14098 427 * @parm trigger the trigger type
keir@14098 428 * @parm vcpu the vcpu number to send trigger
keir@14098 429 * return 0 on success, -1 on failure
keir@14098 430 */
keir@14098 431 int xc_domain_send_trigger(int xc_handle,
keir@14098 432 uint32_t domid,
keir@14098 433 uint32_t trigger,
keir@14098 434 uint32_t vcpu);
keir@14098 435
kaf24@3961 436 /*
iap10@3443 437 * EVENT CHANNEL FUNCTIONS
kaf24@3961 438 */
iap10@3443 439
iap10@3443 440 /**
iap10@3443 441 * This function allocates an unbound port. Ports are named endpoints used for
iap10@3443 442 * interdomain communication. This function is most useful in opening a
iap10@3443 443 * well-known port within a domain to receive events on.
kfraser@12694 444 *
kfraser@12694 445 * NOTE: If you are allocating a *local* unbound port, you probably want to
kfraser@12694 446 * use xc_evtchn_bind_unbound_port(). This function is intended for allocating
kfraser@12694 447 * ports *only* during domain creation.
iap10@3443 448 *
iap10@3443 449 * @parm xc_handle a handle to an open hypervisor interface
kaf24@7223 450 * @parm dom the ID of the local domain (the 'allocatee')
kaf24@7237 451 * @parm remote_dom the ID of the domain who will later bind
kaf24@7237 452 * @return allocated port (in @dom) on success, -1 on failure
iap10@3443 453 */
kaf24@2713 454 int xc_evtchn_alloc_unbound(int xc_handle,
kaf24@7339 455 uint32_t dom,
kaf24@7339 456 uint32_t remote_dom);
iap10@3443 457
kfraser@13521 458 int xc_evtchn_reset(int xc_handle,
kfraser@13521 459 uint32_t dom);
kfraser@13521 460
mjw@1623 461 int xc_physdev_pci_access_modify(int xc_handle,
kaf24@7339 462 uint32_t domid,
mjw@1623 463 int bus,
mjw@1623 464 int dev,
mjw@1623 465 int func,
mjw@1623 466 int enable);
mjw@1623 467
mjw@1623 468 int xc_readconsolering(int xc_handle,
kaf24@5327 469 char **pbuffer,
kaf24@9660 470 unsigned int *pnr_chars,
mjw@1623 471 int clear);
mjw@1623 472
kfraser@14309 473 int xc_send_debug_keys(int xc_handle, char *keys);
kfraser@14309 474
kfraser@11257 475 typedef xen_sysctl_physinfo_t xc_physinfo_t;
kfraser@15482 476 typedef uint32_t xc_cpu_to_node_t;
mjw@1623 477 int xc_physinfo(int xc_handle,
mjw@1623 478 xc_physinfo_t *info);
mjw@1623 479
gm281@2236 480 int xc_sched_id(int xc_handle,
gm281@2236 481 int *sched_id);
gm281@2236 482
keir@15431 483 typedef xen_sysctl_cpuinfo_t xc_cpuinfo_t;
keir@15431 484 int xc_getcpuinfo(int xc_handle, int max_cpus,
keir@15431 485 xc_cpuinfo_t *info, int *nr_cpus);
steven@15427 486
mjw@1623 487 int xc_domain_setmaxmem(int xc_handle,
kaf24@9660 488 uint32_t domid,
kaf24@3231 489 unsigned int max_memkb);
mjw@1623 490
kfraser@12803 491 int xc_domain_set_memmap_limit(int xc_handle,
kfraser@12803 492 uint32_t domid,
kfraser@12803 493 unsigned long map_limitkb);
kfraser@12803 494
kaf24@10474 495 int xc_domain_set_time_offset(int xc_handle,
kaf24@10474 496 uint32_t domid,
kaf24@10474 497 int32_t time_offset_seconds);
kaf24@10474 498
cl349@5045 499 int xc_domain_memory_increase_reservation(int xc_handle,
kaf24@9660 500 uint32_t domid,
iap10@6688 501 unsigned long nr_extents,
iap10@6682 502 unsigned int extent_order,
iap10@6688 503 unsigned int address_bits,
kaf24@10276 504 xen_pfn_t *extent_start);
iap10@6688 505
iap10@6688 506 int xc_domain_memory_decrease_reservation(int xc_handle,
kaf24@9660 507 uint32_t domid,
iap10@6688 508 unsigned long nr_extents,
iap10@6688 509 unsigned int extent_order,
kaf24@10276 510 xen_pfn_t *extent_start);
iap10@6688 511
kaf24@8856 512 int xc_domain_memory_populate_physmap(int xc_handle,
kaf24@8856 513 uint32_t domid,
kaf24@8856 514 unsigned long nr_extents,
kaf24@8856 515 unsigned int extent_order,
kaf24@8856 516 unsigned int address_bits,
kaf24@10276 517 xen_pfn_t *extent_start);
kaf24@8856 518
kaf24@7624 519 int xc_domain_ioport_permission(int xc_handle,
kaf24@7624 520 uint32_t domid,
kaf24@8121 521 uint32_t first_port,
kaf24@8121 522 uint32_t nr_ports,
kaf24@8121 523 uint32_t allow_access);
kaf24@7624 524
kaf24@8460 525 int xc_domain_irq_permission(int xc_handle,
kaf24@8460 526 uint32_t domid,
kaf24@8460 527 uint8_t pirq,
kaf24@8460 528 uint8_t allow_access);
kaf24@8460 529
kaf24@8460 530 int xc_domain_iomem_permission(int xc_handle,
kaf24@8460 531 uint32_t domid,
kaf24@8736 532 unsigned long first_mfn,
kaf24@8736 533 unsigned long nr_mfns,
kaf24@8460 534 uint8_t allow_access);
kaf24@8460 535
kaf24@10266 536 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
kaf24@10266 537 unsigned long mfn);
kaf24@10266 538
kfraser@11257 539 typedef xen_sysctl_perfc_desc_t xc_perfc_desc_t;
kfraser@11257 540 typedef xen_sysctl_perfc_val_t xc_perfc_val_t;
kaf24@10953 541 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc and @val
kaf24@10953 542 arrays. */
kaf24@3231 543 int xc_perfc_control(int xc_handle,
kaf24@7339 544 uint32_t op,
kaf24@10953 545 xc_perfc_desc_t *desc,
kaf24@10953 546 xc_perfc_val_t *val,
kaf24@10953 547 int *nbr_desc,
kaf24@10953 548 int *nbr_val);
mjw@1623 549
iap10@3443 550 /**
iap10@3443 551 * Memory maps a range within one domain to a local address range. Mappings
iap10@3443 552 * should be unmapped with munmap and should follow the same rules as mmap
rusty@4866 553 * regarding page alignment. Returns NULL on failure.
iap10@3443 554 *
iap10@3443 555 * In Linux, the ring queue for the control channel is accessible by mapping
iap10@3443 556 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
iap10@3443 557 * stored there is of type control_if_t.
iap10@3443 558 *
iap10@3443 559 * @parm xc_handle a handle on an open hypervisor interface
iap10@3443 560 * @parm dom the domain to map memory from
iap10@3443 561 * @parm size the amount of memory to map (in multiples of page size)
iap10@3443 562 * @parm prot same flag as in mmap().
iap10@3443 563 * @parm mfn the frame address to map.
iap10@3443 564 */
kaf24@7339 565 void *xc_map_foreign_range(int xc_handle, uint32_t dom,
iap10@2325 566 int size, int prot,
iap10@2325 567 unsigned long mfn );
iap10@2325 568
kaf24@7339 569 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
kaf24@10276 570 xen_pfn_t *arr, int num );
iap10@2325 571
Ian@8435 572 /**
Ian@8435 573 * Translates a virtual address in the context of a given domain and
Ian@8435 574 * vcpu returning the machine page frame number of the associated
Ian@8435 575 * page.
Ian@8435 576 *
Ian@8435 577 * @parm xc_handle a handle on an open hypervisor interface
Ian@8435 578 * @parm dom the domain to perform the translation in
Ian@8435 579 * @parm vcpu the vcpu to perform the translation on
Ian@8435 580 * @parm virt the virtual address to translate
Ian@8435 581 */
Ian@8435 582 unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
kaf24@9221 583 int vcpu, unsigned long long virt);
Ian@8435 584
keir@14101 585
keir@14101 586 /**
keir@14101 587 * DEPRECATED. Avoid using this, as it does not correctly account for PFNs
keir@14101 588 * without a backing MFN.
keir@14101 589 */
kfraser@13594 590 int xc_get_pfn_list(int xc_handle, uint32_t domid, uint64_t *pfn_buf,
cl349@4853 591 unsigned long max_pfns);
iap10@3390 592
awilliam@12005 593 unsigned long xc_ia64_fpsr_default(void);
awilliam@12005 594
kaf24@7339 595 int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
kaf24@10276 596 xen_pfn_t *pfn_buf,
kaf24@7339 597 unsigned int start_page, unsigned int nr_pages);
kaf24@5914 598
djm@7536 599 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
kaf24@9221 600 unsigned long dst_pfn, const char *src_page);
djm@7536 601
kaf24@7786 602 int xc_clear_domain_page(int xc_handle, uint32_t domid,
kaf24@7786 603 unsigned long dst_pfn);
kaf24@7786 604
kaf24@7339 605 long xc_get_max_pages(int xc_handle, uint32_t domid);
djm@6856 606
cl349@6389 607 int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,
kaf24@9221 608 domid_t dom);
cl349@6389 609
kaf24@6468 610 int xc_memory_op(int xc_handle, int cmd, void *arg);
cl349@6389 611
kaf24@7339 612 int xc_get_pfn_type_batch(int xc_handle, uint32_t dom,
kfraser@13594 613 int num, uint32_t *arr);
cl349@6389 614
cl349@6389 615
kaf24@5318 616 /* Get current total pages allocated to a domain. */
kaf24@7339 617 long xc_get_tot_pages(int xc_handle, uint32_t domid);
kaf24@5318 618
kaf24@7566 619
kaf24@7566 620 /*
kaf24@7566 621 * Trace Buffer Operations
kaf24@7566 622 */
kaf24@7566 623
kaf24@7566 624 /**
kaf24@9996 625 * xc_tbuf_enable - enable tracing buffers
kaf24@7566 626 *
kaf24@7566 627 * @parm xc_handle a handle to an open hypervisor interface
kaf24@9996 628 * @parm cnt size of tracing buffers to create (in pages)
kaf24@9996 629 * @parm mfn location to store mfn of the trace buffers to
kaf24@9996 630 * @parm size location to store the size (in bytes) of a trace buffer to
kaf24@9996 631 *
kaf24@9996 632 * Gets the machine address of the trace pointer area and the size of the
kaf24@9996 633 * per CPU buffers.
kaf24@7566 634 */
kfraser@12485 635 int xc_tbuf_enable(int xc_handle, unsigned long pages,
kfraser@12485 636 unsigned long *mfn, unsigned long *size);
kaf24@9996 637
kaf24@9996 638 /*
kaf24@9996 639 * Disable tracing buffers.
kaf24@9996 640 */
kaf24@9996 641 int xc_tbuf_disable(int xc_handle);
kaf24@7566 642
kaf24@7566 643 /**
kaf24@7571 644 * This function sets the size of the trace buffers. Setting the size
kaf24@7571 645 * is currently a one-shot operation that may be performed either at boot
kaf24@7571 646 * time or via this interface, not both. The buffer size must be set before
kaf24@7571 647 * enabling tracing.
kaf24@7566 648 *
kaf24@7566 649 * @parm xc_handle a handle to an open hypervisor interface
kaf24@7566 650 * @parm size the size in pages per cpu for the trace buffers
kaf24@7566 651 * @return 0 on success, -1 on failure.
kaf24@7566 652 */
kaf24@9996 653 int xc_tbuf_set_size(int xc_handle, unsigned long size);
kaf24@7566 654
kaf24@7566 655 /**
kaf24@9660 656 * This function retrieves the current size of the trace buffers.
kaf24@7566 657 * Note that the size returned is in terms of bytes, not pages.
kaf24@7566 658
kaf24@7566 659 * @parm xc_handle a handle to an open hypervisor interface
kaf24@7566 660 * @parm size will contain the size in bytes for the trace buffers
kaf24@7566 661 * @return 0 on success, -1 on failure.
kaf24@7566 662 */
kaf24@9996 663 int xc_tbuf_get_size(int xc_handle, unsigned long *size);
kaf24@9907 664
kaf24@9907 665 int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask);
kaf24@9907 666
kaf24@9907 667 int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask);
kaf24@7566 668
kfraser@11257 669 int xc_domctl(int xc_handle, struct xen_domctl *domctl);
kfraser@11257 670 int xc_sysctl(int xc_handle, struct xen_sysctl *sysctl);
cwc22@3985 671
vh249@6549 672 int xc_version(int xc_handle, int cmd, void *arg);
vh249@6549 673
kfraser@12485 674 int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size);
kaf24@9907 675
kaf24@10355 676 /*
kaf24@10355 677 * Return a handle to the event channel driver, or -1 on failure, in which case
kaf24@10355 678 * errno will be set appropriately.
kaf24@10355 679 */
kaf24@10355 680 int xc_evtchn_open(void);
kaf24@10355 681
kaf24@10355 682 /*
kaf24@10355 683 * Close a handle previously allocated with xc_evtchn_open().
kaf24@10355 684 */
kaf24@10355 685 int xc_evtchn_close(int xce_handle);
kaf24@10355 686
kaf24@10355 687 /*
kaf24@10355 688 * Return an fd that can be select()ed on for further calls to
kaf24@10355 689 * xc_evtchn_pending().
kaf24@10355 690 */
kaf24@10355 691 int xc_evtchn_fd(int xce_handle);
kaf24@10355 692
kaf24@10355 693 /*
kaf24@10355 694 * Notify the given event channel. Returns -1 on failure, in which case
kaf24@10355 695 * errno will be set appropriately.
kaf24@10355 696 */
kaf24@10355 697 int xc_evtchn_notify(int xce_handle, evtchn_port_t port);
kaf24@10355 698
kaf24@10355 699 /*
kfraser@12694 700 * Returns a new event port awaiting interdomain connection from the given
kfraser@12694 701 * domain ID, or -1 on failure, in which case errno will be set appropriately.
kfraser@12694 702 */
kfraser@12694 703 evtchn_port_t xc_evtchn_bind_unbound_port(int xce_handle, int domid);
kfraser@12694 704
kfraser@12694 705 /*
kaf24@10355 706 * Returns a new event port bound to the remote port for the given domain ID,
kaf24@10355 707 * or -1 on failure, in which case errno will be set appropriately.
kaf24@10355 708 */
kaf24@10355 709 evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
kaf24@10355 710 evtchn_port_t remote_port);
kaf24@10355 711
kaf24@10355 712 /*
kaf24@10355 713 * Unbind the given event channel. Returns -1 on failure, in which case errno
kaf24@10355 714 * will be set appropriately.
kaf24@10355 715 */
kaf24@10355 716 int xc_evtchn_unbind(int xce_handle, evtchn_port_t port);
kaf24@10355 717
kaf24@10355 718 /*
kaf24@10355 719 * Bind an event channel to the given VIRQ. Returns the event channel bound to
kaf24@10355 720 * the VIRQ, or -1 on failure, in which case errno will be set appropriately.
kaf24@10355 721 */
kaf24@10355 722 evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq);
kaf24@10355 723
kaf24@10355 724 /*
kaf24@10355 725 * Return the next event channel to become pending, or -1 on failure, in which
kaf24@10355 726 * case errno will be set appropriately.
kaf24@10355 727 */
kaf24@10355 728 evtchn_port_t xc_evtchn_pending(int xce_handle);
kaf24@10355 729
kaf24@10355 730 /*
kaf24@10355 731 * Unmask the given event channel. Returns -1 on failure, in which case errno
kaf24@10355 732 * will be set appropriately.
kaf24@10355 733 */
kaf24@10355 734 int xc_evtchn_unmask(int xce_handle, evtchn_port_t port);
kaf24@10355 735
keir@14681 736 /**************************
keir@14681 737 * GRANT TABLE OPERATIONS *
keir@14681 738 **************************/
keir@14681 739
keir@14681 740 /*
keir@14681 741 * Return a handle to the grant table driver, or -1 on failure, in which case
keir@14681 742 * errno will be set appropriately.
keir@14681 743 */
keir@14681 744 int xc_gnttab_open(void);
keir@14681 745
keir@14681 746 /*
keir@14681 747 * Close a handle previously allocated with xc_gnttab_open().
keir@14681 748 */
keir@14681 749 int xc_gnttab_close(int xcg_handle);
keir@14681 750
keir@14681 751 /*
keir@14681 752 * Memory maps a grant reference from one domain to a local address range.
keir@14681 753 * Mappings should be unmapped with xc_gnttab_munmap. Returns NULL on failure.
keir@14681 754 *
keir@14681 755 * @parm xcg_handle a handle on an open grant table interface
keir@14681 756 * @parm domid the domain to map memory from
keir@14681 757 * @parm ref the grant reference ID to map
keir@14681 758 * @parm prot same flag as in mmap()
keir@14681 759 */
keir@14681 760 void *xc_gnttab_map_grant_ref(int xcg_handle,
keir@14681 761 uint32_t domid,
keir@14681 762 uint32_t ref,
keir@14681 763 int prot);
keir@14681 764
keir@14681 765 /**
keir@14681 766 * Memory maps one or more grant references from one or more domains to a
keir@14681 767 * contiguous local address range. Mappings should be unmapped with
keir@14681 768 * xc_gnttab_munmap. Returns NULL on failure.
keir@14681 769 *
keir@14681 770 * @parm xcg_handle a handle on an open grant table interface
keir@14681 771 * @parm count the number of grant references to be mapped
keir@14681 772 * @parm domids an array of @count domain IDs by which the corresponding @refs
keir@14681 773 * were granted
keir@14681 774 * @parm refs an array of @count grant references to be mapped
keir@14681 775 * @parm prot same flag as in mmap()
keir@14681 776 */
keir@14681 777 void *xc_gnttab_map_grant_refs(int xcg_handle,
keir@14681 778 uint32_t count,
keir@14685 779 uint32_t *domids,
keir@14685 780 uint32_t *refs,
keir@14681 781 int prot);
keir@14681 782
keir@14681 783 /*
keir@14681 784 * Unmaps the @count pages starting at @start_address, which were mapped by a
keir@14681 785 * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Returns zero
keir@14681 786 * on success, otherwise sets errno and returns non-zero.
keir@14681 787 */
keir@14681 788 int xc_gnttab_munmap(int xcg_handle,
keir@14681 789 void *start_address,
keir@14681 790 uint32_t count);
keir@14681 791
kfraser@12504 792 int xc_hvm_set_pci_intx_level(
kfraser@12694 793 int xc_handle, domid_t dom,
kfraser@12504 794 uint8_t domain, uint8_t bus, uint8_t device, uint8_t intx,
kfraser@12504 795 unsigned int level);
kfraser@12504 796 int xc_hvm_set_isa_irq_level(
kfraser@12694 797 int xc_handle, domid_t dom,
kfraser@12504 798 uint8_t isa_irq,
kfraser@12504 799 unsigned int level);
kfraser@12504 800
kfraser@12504 801 int xc_hvm_set_pci_link_route(
kfraser@12694 802 int xc_handle, domid_t dom, uint8_t link, uint8_t isa_irq);
kfraser@12275 803
kfraser@12765 804
kfraser@12765 805 typedef enum {
kfraser@12765 806 XC_ERROR_NONE = 0,
kfraser@12765 807 XC_INTERNAL_ERROR = 1,
kfraser@12765 808 XC_INVALID_KERNEL = 2,
ack@13623 809 XC_INVALID_PARAM = 3,
ack@13623 810 XC_OUT_OF_MEMORY = 4,
kfraser@12765 811 } xc_error_code;
kfraser@12765 812
kfraser@12765 813 #define XC_MAX_ERROR_MSG_LEN 1024
kfraser@12765 814 typedef struct {
kfraser@12765 815 int code;
kfraser@12765 816 char message[XC_MAX_ERROR_MSG_LEN];
kfraser@12765 817 } xc_error;
kfraser@12765 818
kfraser@12765 819 /*
kfraser@12765 820 * Return a pointer to the last error. This pointer and the
kfraser@12765 821 * data pointed to are only valid until the next call to
kfraser@12765 822 * libxc.
kfraser@12765 823 */
ewan@14296 824 const xc_error *xc_get_last_error(void);
kfraser@12765 825
kfraser@12765 826 /*
kfraser@12765 827 * Clear the last error
kfraser@12765 828 */
kfraser@12765 829 void xc_clear_last_error(void);
kfraser@12765 830
kfraser@15263 831 typedef void (*xc_error_handler)(const xc_error *err);
kfraser@12765 832
kfraser@12765 833 /*
kfraser@12765 834 * The default error handler which prints to stderr
kfraser@12765 835 */
kfraser@15263 836 void xc_default_error_handler(const xc_error *err);
kfraser@12765 837
kfraser@12765 838 /*
kfraser@12765 839 * Convert an error code into a text description
kfraser@12765 840 */
kfraser@12765 841 const char *xc_error_code_to_desc(int code);
kfraser@12765 842
kfraser@12765 843 /*
kfraser@12765 844 * Registers a callback to handle errors
kfraser@12765 845 */
kfraser@12765 846 xc_error_handler xc_set_error_handler(xc_error_handler handler);
kfraser@12765 847
kfraser@14823 848 int xc_set_hvm_param(int handle, domid_t dom, int param, unsigned long value);
kfraser@14823 849 int xc_get_hvm_param(int handle, domid_t dom, int param, unsigned long *value);
kfraser@14823 850
kfraser@12988 851 /* PowerPC specific. */
kfraser@12988 852 int xc_alloc_real_mode_area(int xc_handle,
kfraser@12988 853 uint32_t domid,
kfraser@12988 854 unsigned int log);
kfraser@15132 855
kfraser@15132 856 /* IA64 specific, nvram save */
kfraser@15132 857 int xc_ia64_save_to_nvram(int xc_handle, uint32_t dom);
kfraser@15132 858
kfraser@15132 859 /* IA64 specific, nvram init */
kfraser@15132 860 int xc_ia64_nvram_init(int xc_handle, char *dom_name, uint32_t dom);
kfraser@15132 861
kfraser@15132 862 #endif /* XENCTRL_H */