direct-io.hg

annotate tools/libxc/xc.h @ 3605:a920f0ced90f

bitkeeper revision 1.1159.212.66 (42001b6f4kUEhmWXQmgg_vNH-AqiWQ)

Right now, the memory for the 1:1 physical mode page tables comes from the
VMX domain's memory. With this change, when the user asks for a domain with
M Megabytes of memory, we actually allocate M+N megabytes in xend, where
N is the memory for the page table pages.

This simplifies the code in the device models that maps guest memory (we
now map all of it) and the E820 map can also give the full M megabytes to
the guest.

Signed-off-by: Xin B Li <xin.b.li@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
Signed-off-by: ian.pratt@cl.cam.ac.uk
author iap10@labyrinth.cl.cam.ac.uk
date Wed Feb 02 00:14:39 2005 +0000 (2005-02-02)
parents 3c69b6ca4021
children bbe8541361dd
rev   line source
mjw@1623 1 /******************************************************************************
mjw@1623 2 * xc.h
mjw@1623 3 *
mjw@1623 4 * A library for low-level access to the Xen control interfaces.
mjw@1623 5 *
kaf24@2787 6 * Copyright (c) 2003-2004, K A Fraser.
mjw@1623 7 */
mjw@1623 8
mjw@1623 9 #ifndef __XC_H__
mjw@1623 10 #define __XC_H__
mjw@1623 11
kaf24@3266 12 #include <stdint.h>
iap10@3390 13
kaf24@3266 14 typedef uint8_t u8;
kaf24@3266 15 typedef uint16_t u16;
kaf24@3266 16 typedef uint32_t u32;
kaf24@3266 17 typedef uint64_t u64;
kaf24@3266 18 typedef int8_t s8;
kaf24@3266 19 typedef int16_t s16;
kaf24@3266 20 typedef int32_t s32;
kaf24@3266 21 typedef int64_t s64;
mjw@1623 22
kaf24@2821 23 #include <xen/xen.h>
kaf24@2821 24 #include <xen/dom0_ops.h>
kaf24@2821 25 #include <xen/event_channel.h>
kaf24@2821 26 #include <xen/sched_ctl.h>
kaf24@2787 27
iap10@3443 28 /*\
iap10@3443 29 * INITIALIZATION FUNCTIONS
iap10@3443 30 \*/
iap10@3443 31
iap10@3443 32 /**
iap10@3443 33 * This function opens a handle to the hypervisor interface. This function can
iap10@3443 34 * be called multiple times within a single process. Multiple processes can
iap10@3443 35 * have an open hypervisor interface at the same time.
iap10@3443 36 *
iap10@3443 37 * Each call to this function should have a corresponding call to
iap10@3443 38 * xc_interface_close().
iap10@3443 39 *
iap10@3443 40 * This function can fail if the caller does not have superuser permission or
iap10@3443 41 * if a Xen-enabled kernel is not currently running.
iap10@3443 42 *
iap10@3443 43 * @return a handle to the hypervisor interface or -1 on failure
iap10@3443 44 */
mjw@1623 45 int xc_interface_open(void);
iap10@3443 46
iap10@3443 47 /**
iap10@3443 48 * This function closes an open hypervisor interface.
iap10@3443 49 *
iap10@3443 50 * This function can fail if the handle does not represent an open interface or
iap10@3443 51 * if there were problems closing the interface.
iap10@3443 52 *
iap10@3443 53 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 54 * @return 0 on success, -1 otherwise.
iap10@3443 55 */
mjw@1623 56 int xc_interface_close(int xc_handle);
mjw@1623 57
iap10@3443 58 /*\
iap10@3443 59 * DOMAIN MANAGEMENT FUNCTIONS
iap10@3443 60 \*/
iap10@3443 61
mjw@1623 62 typedef struct {
mjw@1623 63 u32 domid;
mjw@1623 64 unsigned int cpu;
mjw@1623 65 unsigned int dying:1, crashed:1, shutdown:1,
mjw@1623 66 paused:1, blocked:1, running:1;
mjw@1623 67 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
mjw@1623 68 unsigned long nr_pages;
mjw@1623 69 unsigned long shared_info_frame;
mjw@1623 70 u64 cpu_time;
mjw@1623 71 unsigned long max_memkb;
mjw@1623 72 } xc_dominfo_t;
mjw@1623 73
kaf24@2787 74 typedef dom0_getdomaininfo_t xc_domaininfo_t;
mjw@1623 75 int xc_domain_create(int xc_handle,
mjw@1623 76 unsigned int mem_kb,
mjw@1623 77 int cpu,
gm281@2236 78 float cpu_weight,
mjw@1623 79 u32 *pdomid);
iap10@3443 80
iap10@3443 81 /**
iap10@3443 82 * This function pauses a domain. A paused domain still exists in memory
iap10@3443 83 * however it does not receive any timeslices from the hypervisor.
iap10@3443 84 *
iap10@3443 85 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 86 * @parm domid the domain id to pause
iap10@3443 87 * @return 0 on success, -1 on failure.
iap10@3443 88 */
mjw@1623 89 int xc_domain_pause(int xc_handle,
mjw@1623 90 u32 domid);
iap10@3443 91 /**
iap10@3443 92 * This function unpauses a domain. The domain should have been previously
iap10@3443 93 * paused.
iap10@3443 94 *
iap10@3443 95 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 96 * @parm domid the domain id to unpause
iap10@3443 97 * return 0 on success, -1 on failure
iap10@3443 98 */
mjw@1623 99 int xc_domain_unpause(int xc_handle,
mjw@1623 100 u32 domid);
iap10@3443 101
iap10@3443 102 /**
iap10@3443 103 * This function will destroy a domain. Destroying a domain removes the domain
iap10@3443 104 * completely from memory. This function should be called after sending the
iap10@3443 105 * domain a SHUTDOWN control message to free up the domain resources.
iap10@3443 106 *
iap10@3443 107 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 108 * @parm domid the domain id to destroy
iap10@3443 109 * @return 0 on success, -1 on failure
iap10@3443 110 */
mjw@1623 111 int xc_domain_destroy(int xc_handle,
mjw@1623 112 u32 domid);
mjw@1623 113 int xc_domain_pincpu(int xc_handle,
mjw@1623 114 u32 domid,
mjw@1623 115 int cpu);
iap10@3443 116 /**
iap10@3443 117 * This function will return information about one or more domains.
iap10@3443 118 *
iap10@3443 119 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 120 * @parm first_domid the first domain to enumerate information from. Domains
iap10@3443 121 * are currently enumerate in order of creation.
iap10@3443 122 * @parm max_doms the number of elements in info
iap10@3443 123 * @parm info an array of max_doms size that will contain the information for
iap10@3443 124 * the enumerated domains.
iap10@3443 125 * @return the number of domains enumerated or -1 on error
iap10@3443 126 */
mjw@1623 127 int xc_domain_getinfo(int xc_handle,
mjw@1623 128 u32 first_domid,
mjw@1623 129 unsigned int max_doms,
mjw@1623 130 xc_dominfo_t *info);
iap10@3443 131
iap10@3443 132 /**
iap10@3443 133 * This function returns information about one domain. This information is
iap10@3443 134 * more detailed than the information from xc_domain_getinfo().
iap10@3443 135 *
iap10@3443 136 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 137 * @parm domid the domain to get information from
iap10@3443 138 * @parm info a pointer to an xc_domaininfo_t to store the domain information
iap10@3443 139 * @parm ctxt a pointer to a structure to store the execution context of the
iap10@3443 140 * domain
iap10@3443 141 * @return 0 on success, -1 on failure
iap10@3443 142 */
kaf24@2787 143 int xc_domain_getfullinfo(int xc_handle,
kaf24@2787 144 u32 domid,
mafetter@3435 145 u32 vcpu,
kaf24@2787 146 xc_domaininfo_t *info,
kaf24@2787 147 full_execution_context_t *ctxt);
gm281@2236 148 int xc_domain_setcpuweight(int xc_handle,
gm281@2236 149 u32 domid,
gm281@2236 150 float weight);
kaf24@2787 151 long long xc_domain_get_cpu_usage(int xc_handle,
mafetter@3435 152 domid_t domid,
mafetter@3435 153 int vcpu);
mjw@1623 154
kaf24@2787 155
kaf24@2787 156 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
mjw@1623 157 int xc_shadow_control(int xc_handle,
mjw@1623 158 u32 domid,
mjw@1623 159 unsigned int sop,
mjw@1623 160 unsigned long *dirty_bitmap,
mjw@1623 161 unsigned long pages,
mjw@1623 162 xc_shadow_control_stats_t *stats);
mjw@1623 163
mjw@1623 164
mjw@2574 165 #define XCFLAGS_VERBOSE 1
mjw@2574 166 #define XCFLAGS_LIVE 2
mjw@2574 167 #define XCFLAGS_DEBUG 4
mjw@2574 168 #define XCFLAGS_CONFIGURE 8
mjw@1623 169
mjw@1623 170 struct XcIOContext;
iap10@3443 171
iap10@3443 172 /**
iap10@3443 173 * This function will save a domain running Linux to an IO context. This
iap10@3443 174 * IO context is currently a private interface making this function difficult
iap10@3443 175 * to call. It's interface will likely change in the future.
iap10@3443 176 *
iap10@3443 177 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 178 * @parm ioctxt the IO context to save a domain to
iap10@3443 179 * @return 0 on success, -1 on failure
iap10@3443 180 */
mjw@1623 181 int xc_linux_save(int xc_handle, struct XcIOContext *ioctxt);
iap10@3443 182
iap10@3443 183 /**
iap10@3443 184 * This function will restore a saved domain running Linux to an IO context.
iap10@3443 185 * Like xc_linux_save(), this function uses a parameter who's structure is
iap10@3443 186 * privately defined. It's interface will also likely change.
iap10@3443 187 *
iap10@3443 188 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 189 * @parm ioctxt the IO context to restore a domain from
iap10@3443 190 * @return 0 on success, -1 on failure
iap10@3443 191 */
mjw@1623 192 int xc_linux_restore(int xc_handle, struct XcIOContext *ioctxt);
mjw@1623 193
mjw@1623 194 int xc_linux_build(int xc_handle,
mjw@1623 195 u32 domid,
mjw@1623 196 const char *image_name,
mjw@1623 197 const char *ramdisk_name,
mjw@1623 198 const char *cmdline,
mjw@1623 199 unsigned int control_evtchn,
cl349@3451 200 unsigned long flags,
cl349@3451 201 unsigned int vcpus);
mjw@1623 202
iap10@3326 203 int
iap10@3326 204 xc_plan9_build (int xc_handle,
iap10@3326 205 u32 domid,
iap10@3326 206 const char *image_name,
iap10@3326 207 const char *cmdline,
iap10@3326 208 unsigned int control_evtchn,
iap10@3326 209 unsigned long flags);
iap10@3326 210
kaf24@3420 211 struct mem_map;
iap10@3390 212 int xc_vmx_build(int xc_handle,
iap10@3390 213 u32 domid,
iap10@3605 214 int memsize,
iap10@3390 215 const char *image_name,
iap10@3390 216 struct mem_map *memmap,
iap10@3390 217 const char *ramdisk_name,
iap10@3390 218 const char *cmdline,
iap10@3390 219 unsigned int control_evtchn,
iap10@3390 220 unsigned long flags);
iap10@3390 221
mjw@1623 222 int xc_bvtsched_global_set(int xc_handle,
mjw@1623 223 unsigned long ctx_allow);
mjw@1623 224
mjw@1623 225 int xc_bvtsched_domain_set(int xc_handle,
mjw@1623 226 u32 domid,
gm281@2058 227 u32 mcuadv,
gm281@2058 228 int warpback,
gm281@2058 229 s32 warpvalue,
gm281@2058 230 long long warpl,
gm281@2058 231 long long warpu);
mjw@1623 232
mjw@1623 233 int xc_bvtsched_global_get(int xc_handle,
mjw@1623 234 unsigned long *ctx_allow);
mjw@1623 235
mjw@1623 236 int xc_bvtsched_domain_get(int xc_handle,
mjw@1623 237 u32 domid,
gm281@2058 238 u32 *mcuadv,
gm281@2058 239 int *warpback,
gm281@2058 240 s32 *warpvalue,
gm281@2058 241 long long *warpl,
gm281@2058 242 long long *warpu);
mjw@1623 243
mjw@1623 244 int xc_atropos_domain_set(int xc_handle,
mjw@1623 245 u32 domid,
mjw@1623 246 u64 period, u64 slice, u64 latency,
mjw@1623 247 int xtratime);
mjw@1623 248
mjw@1623 249 int xc_atropos_domain_get(int xc_handle,
mjw@1623 250 u32 domid,
mjw@1623 251 u64* period, u64 *slice, u64 *latency,
mjw@1623 252 int *xtratime);
mjw@1623 253
mjw@1623 254 int xc_rrobin_global_set(int xc_handle, u64 slice);
mjw@1623 255
mjw@1623 256 int xc_rrobin_global_get(int xc_handle, u64 *slice);
mjw@1623 257
kaf24@2787 258 typedef evtchn_status_t xc_evtchn_status_t;
iap10@3443 259
iap10@3443 260 /*\
iap10@3443 261 * EVENT CHANNEL FUNCTIONS
iap10@3443 262 \*/
iap10@3443 263
iap10@3443 264 /**
iap10@3443 265 * This function allocates an unbound port. Ports are named endpoints used for
iap10@3443 266 * interdomain communication. This function is most useful in opening a
iap10@3443 267 * well-known port within a domain to receive events on.
iap10@3443 268 *
iap10@3443 269 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 270 * @parm dom the ID of the domain. This maybe DOMID_SELF
iap10@3443 271 * @parm port a pointer to a port. This is an in/out parameter. If *port is
iap10@3443 272 * 0, then a new port will be assigned, if port is > 0 then that
iap10@3443 273 * port is allocated if the port is unallocated.
iap10@3443 274 * @return 0 on success, -1 on failure
iap10@3443 275 */
kaf24@2713 276 int xc_evtchn_alloc_unbound(int xc_handle,
kaf24@2713 277 u32 dom,
kaf24@2713 278 int *port);
iap10@3443 279
iap10@3443 280 /**
iap10@3443 281 * This function creates a pair of ports between two domains. A port can only
iap10@3443 282 * be bound once within a domain.
iap10@3443 283 *
iap10@3443 284 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 285 * @parm dom1 one of the two domains to connect. Can be DOMID_SELF.
iap10@3443 286 * @parm dom2 the other domain to connect. Can be DOMID_SELF.
iap10@3443 287 * @parm port1 an in/out parameter. If > 0, then try to connect *port. If
iap10@3443 288 * 0, then allocate a new port and store the port in *port.
iap10@3443 289 * @parm port2 the port connected on port2. This parameter behaves the same
iap10@3443 290 * way as port1.
iap10@3443 291 * @return 0 on success, -1 on error.
iap10@3443 292 */
mjw@1623 293 int xc_evtchn_bind_interdomain(int xc_handle,
iap10@3443 294 u32 dom1,
iap10@3443 295 u32 dom2,
mjw@1623 296 int *port1,
mjw@1623 297 int *port2);
mjw@1623 298 int xc_evtchn_bind_virq(int xc_handle,
mjw@1623 299 int virq,
mjw@1623 300 int *port);
iap10@3443 301
iap10@3443 302 /**
iap10@3443 303 * This function will close a single port on an event channel.
iap10@3443 304 *
iap10@3443 305 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 306 * @parm dom the domain that the port exists on. May be DOMID_SELF.
iap10@3443 307 * @parm port the port to close
iap10@3443 308 * @return 0 on success, -1 on error
iap10@3443 309 */
mjw@1623 310 int xc_evtchn_close(int xc_handle,
mjw@1623 311 u32 dom, /* may be DOMID_SELF */
mjw@1623 312 int port);
iap10@3443 313
iap10@3443 314 /**
iap10@3443 315 * This function generates a notify event on a bound port.
iap10@3443 316 *
iap10@3443 317 * Notifies can be read within Linux by opening /dev/xen/evtchn and reading
iap10@3443 318 * a 16 bit value. The result will be the port the event occurred on. When
iap10@3443 319 * events occur, the port is masked until the 16 bit port value is written back
iap10@3443 320 * to the file. When /dev/xen/evtchn is opened, it has to be bound via an
iap10@3443 321 * ioctl to each port to listen on. The ioctl for binding is _IO('E', 2). The
iap10@3443 322 * parameter is the port to listen on.
iap10@3443 323 *
iap10@3443 324 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 325 * @parm local_port the port to generate the notify on
iap10@3443 326 * @return 0 on success, -1 on error
iap10@3443 327 */
mjw@1623 328 int xc_evtchn_send(int xc_handle,
mjw@1623 329 int local_port);
mjw@1623 330 int xc_evtchn_status(int xc_handle,
mjw@1623 331 u32 dom, /* may be DOMID_SELF */
mjw@1623 332 int port,
mjw@1623 333 xc_evtchn_status_t *status);
mjw@1623 334
mjw@1623 335 int xc_physdev_pci_access_modify(int xc_handle,
mjw@1623 336 u32 domid,
mjw@1623 337 int bus,
mjw@1623 338 int dev,
mjw@1623 339 int func,
mjw@1623 340 int enable);
mjw@1623 341
mjw@1623 342 int xc_readconsolering(int xc_handle,
mjw@1623 343 char *str,
mjw@1623 344 unsigned int max_chars,
mjw@1623 345 int clear);
mjw@1623 346
kaf24@2787 347 typedef dom0_physinfo_t xc_physinfo_t;
mjw@1623 348 int xc_physinfo(int xc_handle,
mjw@1623 349 xc_physinfo_t *info);
mjw@1623 350
gm281@2236 351 int xc_sched_id(int xc_handle,
gm281@2236 352 int *sched_id);
gm281@2236 353
mjw@1623 354 int xc_domain_setinitialmem(int xc_handle,
mjw@1623 355 u32 domid,
mjw@1623 356 unsigned int initial_memkb);
mjw@1623 357
mjw@1623 358 int xc_domain_setmaxmem(int xc_handle,
kaf24@3231 359 u32 domid,
kaf24@3231 360 unsigned int max_memkb);
mjw@1623 361
cl349@2449 362 int xc_domain_setvmassist(int xc_handle,
cl349@2449 363 u32 domid,
cl349@2449 364 unsigned int cmd,
cl349@2449 365 unsigned int type);
cl349@2449 366
kaf24@3231 367 typedef dom0_perfc_desc_t xc_perfc_desc_t;
kaf24@3231 368 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
kaf24@3231 369 int xc_perfc_control(int xc_handle,
kaf24@3231 370 u32 op,
kaf24@3231 371 xc_perfc_desc_t *desc);
mjw@1623 372
iap10@3443 373 /**
iap10@3443 374 * Memory maps a range within one domain to a local address range. Mappings
iap10@3443 375 * should be unmapped with munmap and should follow the same rules as mmap
iap10@3443 376 * regarding page alignment.
iap10@3443 377 *
iap10@3443 378 * In Linux, the ring queue for the control channel is accessible by mapping
iap10@3443 379 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
iap10@3443 380 * stored there is of type control_if_t.
iap10@3443 381 *
iap10@3443 382 * @parm xc_handle a handle on an open hypervisor interface
iap10@3443 383 * @parm dom the domain to map memory from
iap10@3443 384 * @parm size the amount of memory to map (in multiples of page size)
iap10@3443 385 * @parm prot same flag as in mmap().
iap10@3443 386 * @parm mfn the frame address to map.
iap10@3443 387 */
iap10@2325 388 void *xc_map_foreign_range(int xc_handle, u32 dom,
iap10@2325 389 int size, int prot,
iap10@2325 390 unsigned long mfn );
iap10@2325 391
iap10@2325 392 void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot,
iap10@2325 393 unsigned long *arr, int num );
iap10@2325 394
iap10@3390 395 int xc_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf,
iap10@3390 396 unsigned long max_pfns);
iap10@3390 397
mjw@1623 398 #endif /* __XC_H__ */