domain_conf.h 31.0 KB
Newer Older
1 2 3
/*
 * domain_conf.h: domain XML processing
 *
4
 * Copyright (C) 2006-2008, 2010 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * Copyright (C) 2006-2008 Daniel P. Berrange
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __DOMAIN_CONF_H
25
# define __DOMAIN_CONF_H
26

27 28 29
# include <libxml/parser.h>
# include <libxml/tree.h>
# include <libxml/xpath.h>
30

31 32 33 34 35 36 37 38
# include "internal.h"
# include "capabilities.h"
# include "storage_encryption_conf.h"
# include "cpu_conf.h"
# include "util.h"
# include "threads.h"
# include "hash.h"
# include "network.h"
39 40
# include "nwfilter_params.h"
# include "nwfilter_conf.h"
41
# include "macvtap.h"
42

43 44 45 46 47
/* Private component of virDomainXMLFlags */
typedef enum {
   VIR_DOMAIN_XML_INTERNAL_STATUS = (1<<16), /* dump internal domain status information */
} virDomainXMLInternalFlags;

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */
enum virDomainVirtType {
    VIR_DOMAIN_VIRT_QEMU,
    VIR_DOMAIN_VIRT_KQEMU,
    VIR_DOMAIN_VIRT_KVM,
    VIR_DOMAIN_VIRT_XEN,
    VIR_DOMAIN_VIRT_LXC,
    VIR_DOMAIN_VIRT_UML,
    VIR_DOMAIN_VIRT_OPENVZ,
    VIR_DOMAIN_VIRT_VSERVER,
    VIR_DOMAIN_VIRT_LDOM,
    VIR_DOMAIN_VIRT_TEST,
    VIR_DOMAIN_VIRT_VMWARE,
    VIR_DOMAIN_VIRT_HYPERV,
63
    VIR_DOMAIN_VIRT_VBOX,
D
Daniel Veillard 已提交
64
    VIR_DOMAIN_VIRT_ONE,
65
    VIR_DOMAIN_VIRT_PHYP,
66 67 68 69

    VIR_DOMAIN_VIRT_LAST,
};

70 71 72
enum virDomainDeviceAddressType {
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
73
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
74
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
75 76 77 78 79 80 81 82 83 84 85 86 87

    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
};

typedef struct _virDomainDevicePCIAddress virDomainDevicePCIAddress;
typedef virDomainDevicePCIAddress *virDomainDevicePCIAddressPtr;
struct _virDomainDevicePCIAddress {
    unsigned int domain;
    unsigned int bus;
    unsigned int slot;
    unsigned int function;
};

88 89 90 91 92 93 94 95
typedef struct _virDomainDeviceDriveAddress virDomainDeviceDriveAddress;
typedef virDomainDeviceDriveAddress *virDomainDeviceDriveAddressPtr;
struct _virDomainDeviceDriveAddress {
    unsigned int controller;
    unsigned int bus;
    unsigned int unit;
};

96 97 98 99 100
typedef struct _virDomainDeviceVirtioSerialAddress virDomainDeviceVirtioSerialAddress;
typedef virDomainDeviceVirtioSerialAddress *virDomainDeviceVirtioSerialAddressPtr;
struct _virDomainDeviceVirtioSerialAddress {
    unsigned int controller;
    unsigned int bus;
101
    unsigned int port;
102 103
};

104 105 106
typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
struct _virDomainDeviceInfo {
D
Daniel P. Berrange 已提交
107
    char *alias;
108 109 110
    int type;
    union {
        virDomainDevicePCIAddress pci;
111
        virDomainDeviceDriveAddress drive;
112
        virDomainDeviceVirtioSerialAddress vioserial;
113 114 115 116
    } addr;
};


117 118 119 120
/* Two types of disk backends */
enum virDomainDiskType {
    VIR_DOMAIN_DISK_TYPE_BLOCK,
    VIR_DOMAIN_DISK_TYPE_FILE,
121
    VIR_DOMAIN_DISK_TYPE_DIR,
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140

    VIR_DOMAIN_DISK_TYPE_LAST
};

/* Three types of disk frontend */
enum virDomainDiskDevice {
    VIR_DOMAIN_DISK_DEVICE_DISK,
    VIR_DOMAIN_DISK_DEVICE_CDROM,
    VIR_DOMAIN_DISK_DEVICE_FLOPPY,

    VIR_DOMAIN_DISK_DEVICE_LAST
};

enum virDomainDiskBus {
    VIR_DOMAIN_DISK_BUS_IDE,
    VIR_DOMAIN_DISK_BUS_FDC,
    VIR_DOMAIN_DISK_BUS_SCSI,
    VIR_DOMAIN_DISK_BUS_VIRTIO,
    VIR_DOMAIN_DISK_BUS_XEN,
141
    VIR_DOMAIN_DISK_BUS_USB,
142
    VIR_DOMAIN_DISK_BUS_UML,
143
    VIR_DOMAIN_DISK_BUS_SATA,
144 145 146 147

    VIR_DOMAIN_DISK_BUS_LAST
};

148 149 150 151 152 153 154 155 156
enum  virDomainDiskCache {
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,

    VIR_DOMAIN_DISK_CACHE_LAST
};

157 158 159 160
enum  virDomainDiskErrorPolicy {
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
161
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
162 163 164 165

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
};

166 167 168 169 170 171 172 173 174 175 176
/* Stores the virtual disk configuration */
typedef struct _virDomainDiskDef virDomainDiskDef;
typedef virDomainDiskDef *virDomainDiskDefPtr;
struct _virDomainDiskDef {
    int type;
    int device;
    int bus;
    char *src;
    char *dst;
    char *driverName;
    char *driverType;
177
    char *serial;
178
    int cachemode;
179
    int error_policy;
180 181
    unsigned int readonly : 1;
    unsigned int shared : 1;
182
    virDomainDeviceInfo info;
183
    virStorageEncryptionPtr encryption;
184 185 186
};


187 188 189 190 191
enum virDomainControllerType {
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
192
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
193 194 195 196

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
};

197 198 199 200 201 202 203
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

204 205 206 207 208 209
/* Stores the virtual disk controller configuration */
typedef struct _virDomainControllerDef virDomainControllerDef;
typedef virDomainControllerDef *virDomainControllerDefPtr;
struct _virDomainControllerDef {
    int type;
    int idx;
210 211 212
    union {
        virDomainVirtioSerialOpts vioserial;
    } opts;
213 214 215 216
    virDomainDeviceInfo info;
};


217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
/* Two types of disk backends */
enum virDomainFSType {
    VIR_DOMAIN_FS_TYPE_MOUNT,   /* Better named 'bind' */
    VIR_DOMAIN_FS_TYPE_BLOCK,
    VIR_DOMAIN_FS_TYPE_FILE,
    VIR_DOMAIN_FS_TYPE_TEMPLATE,

    VIR_DOMAIN_FS_TYPE_LAST
};

typedef struct _virDomainFSDef virDomainFSDef;
typedef virDomainFSDef *virDomainFSDefPtr;
struct _virDomainFSDef {
    int type;
    char *src;
    char *dst;
    unsigned int readonly : 1;
234
    virDomainDeviceInfo info;
235 236 237
};


238 239 240 241 242 243 244 245 246
/* 5 different types of networking config */
enum virDomainNetType {
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
    VIR_DOMAIN_NET_TYPE_SERVER,
    VIR_DOMAIN_NET_TYPE_CLIENT,
    VIR_DOMAIN_NET_TYPE_MCAST,
    VIR_DOMAIN_NET_TYPE_NETWORK,
    VIR_DOMAIN_NET_TYPE_BRIDGE,
D
Daniel Veillard 已提交
247
    VIR_DOMAIN_NET_TYPE_INTERNAL,
248
    VIR_DOMAIN_NET_TYPE_DIRECT,
249 250 251 252 253

    VIR_DOMAIN_NET_TYPE_LAST,
};


254 255 256 257 258 259 260 261 262 263
/* the mode type for macvtap devices */
enum virDomainNetdevMacvtapType {
    VIR_DOMAIN_NETDEV_MACVTAP_MODE_VEPA,
    VIR_DOMAIN_NETDEV_MACVTAP_MODE_PRIVATE,
    VIR_DOMAIN_NETDEV_MACVTAP_MODE_BRIDGE,

    VIR_DOMAIN_NETDEV_MACVTAP_MODE_LAST,
};


264 265 266 267
/* Stores the virtual network interface configuration */
typedef struct _virDomainNetDef virDomainNetDef;
typedef virDomainNetDef *virDomainNetDefPtr;
struct _virDomainNetDef {
S
Stefan Berger 已提交
268
    enum virDomainNetType type;
269
    unsigned char mac[VIR_MAC_BUFLEN];
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
    char *model;
    union {
        struct {
            char *dev;
            char *script;
            char *ipaddr;
        } ethernet;
        struct {
            char *address;
            int port;
        } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
        struct {
            char *name;
        } network;
        struct {
            char *brname;
286
            char *script;
287
            char *ipaddr;
288
        } bridge;
D
Daniel Veillard 已提交
289 290 291
        struct {
            char *name;
        } internal;
292 293 294
        struct {
            char *linkdev;
            int mode;
295
            virVirtualPortProfileParams virtPortProfile;
296
        } direct;
297 298
    } data;
    char *ifname;
299
    virDomainDeviceInfo info;
300 301
    char *filter;
    virNWFilterHashTablePtr filterparams;
302 303
};

304 305 306 307 308 309
enum virDomainChrTargetType {
    VIR_DOMAIN_CHR_TARGET_TYPE_NULL = 0,
    VIR_DOMAIN_CHR_TARGET_TYPE_MONITOR,
    VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL,
    VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL,
    VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE,
310
    VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD,
311
    VIR_DOMAIN_CHR_TARGET_TYPE_VIRTIO,
312 313 314 315 316

    VIR_DOMAIN_CHR_TARGET_TYPE_LAST
};

enum virDomainChrType {
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
    VIR_DOMAIN_CHR_TYPE_NULL,
    VIR_DOMAIN_CHR_TYPE_VC,
    VIR_DOMAIN_CHR_TYPE_PTY,
    VIR_DOMAIN_CHR_TYPE_DEV,
    VIR_DOMAIN_CHR_TYPE_FILE,
    VIR_DOMAIN_CHR_TYPE_PIPE,
    VIR_DOMAIN_CHR_TYPE_STDIO,
    VIR_DOMAIN_CHR_TYPE_UDP,
    VIR_DOMAIN_CHR_TYPE_TCP,
    VIR_DOMAIN_CHR_TYPE_UNIX,

    VIR_DOMAIN_CHR_TYPE_LAST,
};

enum virDomainChrTcpProtocol {
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW,
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,

    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST,
};

typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr;
struct _virDomainChrDef {
341 342 343
    int targetType;
    union {
        int port; /* parallel, serial, console */
344
        virSocketAddrPtr addr; /* guestfwd */
345
        char *name; /* virtio */
346
    } target;
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369

    int type;
    union {
        struct {
            char *path;
        } file; /* pty, file, pipe, or device */
        struct {
            char *host;
            char *service;
            int listen;
            int protocol;
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
            int listen;
        } nix;
    } data;
370 371

    virDomainDeviceInfo info;
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
};

enum virDomainInputType {
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,

    VIR_DOMAIN_INPUT_TYPE_LAST,
};

enum virDomainInputBus {
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,

    VIR_DOMAIN_INPUT_BUS_LAST
};

typedef struct _virDomainInputDef virDomainInputDef;
typedef virDomainInputDef *virDomainInputDefPtr;
struct _virDomainInputDef {
    int type;
    int bus;
394
    virDomainDeviceInfo info;
395 396 397 398 399 400
};

enum virDomainSoundModel {
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
401
    VIR_DOMAIN_SOUND_MODEL_AC97,
402 403 404 405 406 407 408 409

    VIR_DOMAIN_SOUND_MODEL_LAST
};

typedef struct _virDomainSoundDef virDomainSoundDef;
typedef virDomainSoundDef *virDomainSoundDefPtr;
struct _virDomainSoundDef {
    int model;
410
    virDomainDeviceInfo info;
411 412
};

R
Richard Jones 已提交
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
enum virDomainWatchdogModel {
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
};

enum virDomainWatchdogAction {
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
};

typedef struct _virDomainWatchdogDef virDomainWatchdogDef;
typedef virDomainWatchdogDef *virDomainWatchdogDefPtr;
struct _virDomainWatchdogDef {
    int model;
    int action;
435
    virDomainDeviceInfo info;
R
Richard Jones 已提交
436 437
};

438 439 440 441 442 443 444 445 446 447 448 449

enum virDomainVideoType {
    VIR_DOMAIN_VIDEO_TYPE_VGA,
    VIR_DOMAIN_VIDEO_TYPE_CIRRUS,
    VIR_DOMAIN_VIDEO_TYPE_VMVGA,
    VIR_DOMAIN_VIDEO_TYPE_XEN,
    VIR_DOMAIN_VIDEO_TYPE_VBOX,

    VIR_DOMAIN_VIDEO_TYPE_LAST
};


450 451 452
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
453 454
    unsigned int support3d :1;
    unsigned int support2d :1;
455 456 457
};


458 459 460 461 462 463
typedef struct _virDomainVideoDef virDomainVideoDef;
typedef virDomainVideoDef *virDomainVideoDefPtr;
struct _virDomainVideoDef {
    int type;
    unsigned int vram;
    unsigned int heads;
464
    virDomainVideoAccelDefPtr accel;
465
    virDomainDeviceInfo info;
466 467
};

468 469 470 471
/* 3 possible graphics console modes */
enum virDomainGraphicsType {
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
472 473
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
474 475 476 477 478 479 480 481 482 483 484

    VIR_DOMAIN_GRAPHICS_TYPE_LAST,
};

typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;
struct _virDomainGraphicsDef {
    int type;
    union {
        struct {
            int port;
485
            unsigned int autoport :1;
486 487 488 489 490 491 492
            char *listenAddr;
            char *keymap;
            char *passwd;
        } vnc;
        struct {
            char *display;
            char *xauth;
493
            int fullscreen;
494
        } sdl;
495 496 497
        struct {
            int port;
            char *listenAddr;
498 499 500
            unsigned int autoport :1;
            unsigned int replaceUser :1;
            unsigned int multiUser :1;
501 502 503
        } rdp;
        struct {
            char *display;
504
            unsigned int fullscreen :1;
505
        } desktop;
506 507 508
    } data;
};

509 510 511
enum virDomainHostdevMode {
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
512

513 514 515 516 517 518 519 520 521 522 523 524 525 526
    VIR_DOMAIN_HOSTDEV_MODE_LAST,
};

enum virDomainHostdevSubsysType {
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
};

typedef struct _virDomainHostdevDef virDomainHostdevDef;
typedef virDomainHostdevDef *virDomainHostdevDefPtr;
struct _virDomainHostdevDef {
    int mode; /* enum virDomainHostdevMode */
527
    unsigned int managed : 1;
528 529 530 531 532 533 534 535 536 537 538
    union {
        struct {
            int type; /* enum virDomainHostdevBusType */
            union {
                struct {
                    unsigned bus;
                    unsigned device;

                    unsigned vendor;
                    unsigned product;
                } usb;
539
                virDomainDevicePCIAddress pci; /* host address */
540
            } u;
541 542 543 544 545
        } subsys;
        struct {
            /* TBD: struct capabilities see:
             * https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
             */
546
            int dummy;
547 548 549
        } caps;
    } source;
    char* target;
550
    virDomainDeviceInfo info; /* Guest address */
551
};
552 553 554 555

/* Flags for the 'type' field in next struct */
enum virDomainDeviceType {
    VIR_DOMAIN_DEVICE_DISK,
556
    VIR_DOMAIN_DEVICE_FS,
557 558 559
    VIR_DOMAIN_DEVICE_NET,
    VIR_DOMAIN_DEVICE_INPUT,
    VIR_DOMAIN_DEVICE_SOUND,
560
    VIR_DOMAIN_DEVICE_VIDEO,
561
    VIR_DOMAIN_DEVICE_HOSTDEV,
R
Richard Jones 已提交
562
    VIR_DOMAIN_DEVICE_WATCHDOG,
563
    VIR_DOMAIN_DEVICE_CONTROLLER,
564
    VIR_DOMAIN_DEVICE_GRAPHICS,
565 566

    VIR_DOMAIN_DEVICE_LAST,
567 568 569 570 571 572 573 574
};

typedef struct _virDomainDeviceDef virDomainDeviceDef;
typedef virDomainDeviceDef *virDomainDeviceDefPtr;
struct _virDomainDeviceDef {
    int type;
    union {
        virDomainDiskDefPtr disk;
575
        virDomainControllerDefPtr controller;
576
        virDomainFSDefPtr fs;
577 578 579
        virDomainNetDefPtr net;
        virDomainInputDefPtr input;
        virDomainSoundDefPtr sound;
580
        virDomainVideoDefPtr video;
581
        virDomainHostdevDefPtr hostdev;
R
Richard Jones 已提交
582
        virDomainWatchdogDefPtr watchdog;
583
        virDomainGraphicsDefPtr graphics;
584 585 586 587
    } data;
};


588
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625

/* 3 possible boot devices */
enum virDomainBootOrder {
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

    VIR_DOMAIN_BOOT_LAST,
};

enum virDomainFeature {
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,

    VIR_DOMAIN_FEATURE_LAST
};

enum virDomainLifecycleAction {
    VIR_DOMAIN_LIFECYCLE_DESTROY,
    VIR_DOMAIN_LIFECYCLE_RESTART,
    VIR_DOMAIN_LIFECYCLE_RESTART_RENAME,
    VIR_DOMAIN_LIFECYCLE_PRESERVE,

    VIR_DOMAIN_LIFECYCLE_LAST
};

/* Operating system configuration data & machine / arch */
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
    char *type;
    char *arch;
    char *machine;
    int nBootDevs;
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
626
    char *init;
627 628 629 630 631 632 633 634 635
    char *kernel;
    char *initrd;
    char *cmdline;
    char *root;
    char *loader;
    char *bootloader;
    char *bootloaderArgs;
};

636 637 638 639 640 641 642
enum virDomainSeclabelType {
    VIR_DOMAIN_SECLABEL_DYNAMIC,
    VIR_DOMAIN_SECLABEL_STATIC,

    VIR_DOMAIN_SECLABEL_LAST,
};

643 644 645 646 647 648 649
/* Security configuration for domain */
typedef struct _virSecurityLabelDef virSecurityLabelDef;
typedef virSecurityLabelDef *virSecurityLabelDefPtr;
struct _virSecurityLabelDef {
    char *model;        /* name of security model */
    char *label;        /* security label string */
    char *imagelabel;   /* security image label string */
650
    int type;
651 652
};

653 654 655 656 657 658 659 660 661 662
enum virDomainTimerNameType {
    VIR_DOMAIN_TIMER_NAME_PLATFORM = 0,
    VIR_DOMAIN_TIMER_NAME_PIT,
    VIR_DOMAIN_TIMER_NAME_RTC,
    VIR_DOMAIN_TIMER_NAME_HPET,
    VIR_DOMAIN_TIMER_NAME_TSC,

    VIR_DOMAIN_TIMER_NAME_LAST,
};

663 664 665 666
enum virDomainTimerTrackType {
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
667

668
    VIR_DOMAIN_TIMER_TRACK_LAST,
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
};

enum virDomainTimerTickpolicyType {
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

    VIR_DOMAIN_TIMER_TICKPOLICY_LAST,
};

enum virDomainTimerModeType {
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
685
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
686 687 688 689

    VIR_DOMAIN_TIMER_MODE_LAST,
};

690 691 692 693 694 695 696 697
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

698 699 700 701 702 703 704
typedef struct _virDomainTimerDef virDomainTimerDef;
typedef virDomainTimerDef *virDomainTimerDefPtr;
struct _virDomainTimerDef {
    int name;
    int present;    /* unspecified = -1, no = 0, yes = 1 */
    int tickpolicy; /* none|catchup|merge|discard */

705 706 707 708
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
709 710 711 712 713 714

    /* frequency & mode are only valid for name='tsc' */
    unsigned long frequency; /* in Hz, unspecified = 0 */
    int mode;       /* auto|native|emulate|paravirt */
};

715 716 717
enum virDomainClockOffsetType {
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
718
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
719
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
720 721 722 723 724 725 726 727

    VIR_DOMAIN_CLOCK_OFFSET_LAST,
};

typedef struct _virDomainClockDef virDomainClockDef;
typedef virDomainClockDef *virDomainClockDefPtr;
struct _virDomainClockDef {
    int offset;
728

729 730 731 732 733 734 735 736 737
    union {
        /* Adjustment in seconds, relative to UTC, when
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
        long long adjustment;

        /* Timezone name, when
         * offset == VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME */
        char *timezone;
    } data;
738 739 740

    int ntimers;
    virDomainTimerDefPtr *timers;
741 742
};

743
# define VIR_DOMAIN_CPUMASK_LEN 1024
744

C
Chris Lalancette 已提交
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795

/* Snapshot state */
typedef struct _virDomainSnapshotDef virDomainSnapshotDef;
typedef virDomainSnapshotDef *virDomainSnapshotDefPtr;
struct _virDomainSnapshotDef {
    char *name;
    char *description;
    char *parent;
    time_t creationTime;
    int state;

    long active;
};

typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;
struct _virDomainSnapshotObj {
    int refs;

    virDomainSnapshotDefPtr def;
};

typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
typedef virDomainSnapshotObjList *virDomainSnapshotObjListPtr;
struct _virDomainSnapshotObjList {
    /* name string -> virDomainSnapshotObj  mapping
     * for O(1), lockless lookup-by-name */
    virHashTable *objs;
};

virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
                                                        int newSnapshot);
void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
char *virDomainSnapshotDefFormat(char *domain_uuid,
                                 virDomainSnapshotDefPtr def,
                                 int internal);
virDomainSnapshotObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr snapshots,
                                                   const virDomainSnapshotDefPtr def);

int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr objs);
int virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots,
                                     char **const names, int maxnames);
int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr snapshots);
virDomainSnapshotObjPtr virDomainSnapshotFindByName(const virDomainSnapshotObjListPtr snapshots,
                                                    const char *name);
void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
                                    virDomainSnapshotObjPtr snapshot);
int virDomainSnapshotObjUnref(virDomainSnapshotObjPtr snapshot);
int virDomainSnapshotHasChildren(virDomainSnapshotObjPtr snap,
                                virDomainSnapshotObjListPtr snapshots);

796 797 798 799 800 801 802 803
/* Guest VM main configuration */
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
struct _virDomainDef {
    int virtType;
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
    char *name;
804
    char *description;
805 806 807

    unsigned long memory;
    unsigned long maxmem;
808
    unsigned char hugepage_backed;
809 810 811 812 813 814 815 816 817 818 819 820 821
    unsigned long vcpus;
    int cpumasklen;
    char *cpumask;

    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

    virDomainOSDef os;
    char *emulator;
    int features;

822
    virDomainClockDef clock;
823

824 825
    int ngraphics;
    virDomainGraphicsDefPtr *graphics;
826 827 828 829

    int ndisks;
    virDomainDiskDefPtr *disks;

830 831 832
    int ncontrollers;
    virDomainControllerDefPtr *controllers;

833 834 835 836 837 838 839 840 841 842 843 844
    int nfss;
    virDomainFSDefPtr *fss;

    int nnets;
    virDomainNetDefPtr *nets;

    int ninputs;
    virDomainInputDefPtr *inputs;

    int nsounds;
    virDomainSoundDefPtr *sounds;

845 846 847
    int nvideos;
    virDomainVideoDefPtr *videos;

848 849 850 851 852 853 854 855 856
    int nhostdevs;
    virDomainHostdevDefPtr *hostdevs;

    int nserials;
    virDomainChrDefPtr *serials;

    int nparallels;
    virDomainChrDefPtr *parallels;

857 858 859
    int nchannels;
    virDomainChrDefPtr *channels;

860
    /* Only 1 */
861
    virDomainChrDefPtr console;
862
    virSecurityLabelDef seclabel;
R
Richard Jones 已提交
863
    virDomainWatchdogDefPtr watchdog;
864
    virCPUDefPtr cpu;
865 866 867 868 869 870
};

/* Guest VM runtime state */
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
871
    virMutex lock;
872
    int refs;
873

874 875 876 877 878 879 880 881
    int pid;
    int state;

    unsigned int autostart : 1;
    unsigned int persistent : 1;

    virDomainDefPtr def; /* The current definition */
    virDomainDefPtr newDef; /* New definition to activate at shutdown */
882

C
Chris Lalancette 已提交
883 884 885
    virDomainSnapshotObjList snapshots;
    virDomainSnapshotObjPtr current_snapshot;

886 887
    void *privateData;
    void (*privateDataFreeFunc)(void *);
888 889
};

890 891 892
typedef struct _virDomainObjList virDomainObjList;
typedef virDomainObjList *virDomainObjListPtr;
struct _virDomainObjList {
893 894 895
    /* uuid string -> virDomainObj  mapping
     * for O(1), lockless lookup-by-uuid */
    virHashTable *objs;
896
};
897 898

static inline int
D
Daniel P. Berrange 已提交
899
virDomainObjIsActive(virDomainObjPtr dom)
900 901 902 903
{
    return dom->def->id != -1;
}

904

905 906
int virDomainObjListInit(virDomainObjListPtr objs);
void virDomainObjListDeinit(virDomainObjListPtr objs);
907

908
virDomainObjPtr virDomainFindByID(const virDomainObjListPtr doms,
909
                                  int id);
910
virDomainObjPtr virDomainFindByUUID(const virDomainObjListPtr doms,
911
                                    const unsigned char *uuid);
912
virDomainObjPtr virDomainFindByName(const virDomainObjListPtr doms,
913 914 915 916 917 918
                                    const char *name);


void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
void virDomainDiskDefFree(virDomainDiskDefPtr def);
919
void virDomainControllerDefFree(virDomainControllerDefPtr def);
920
void virDomainFSDefFree(virDomainFSDefPtr def);
921 922 923
void virDomainNetDefFree(virDomainNetDefPtr def);
void virDomainChrDefFree(virDomainChrDefPtr def);
void virDomainSoundDefFree(virDomainSoundDefPtr def);
R
Richard Jones 已提交
924
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
925
void virDomainVideoDefFree(virDomainVideoDefPtr def);
926
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
927
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
928 929 930
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                  int type);
int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
931
int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr);
932
int virDomainDeviceVirtioSerialAddressIsValid(virDomainDeviceVirtioSerialAddressPtr addr);
933 934
int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info);
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
935
void virDomainDefClearPCIAddresses(virDomainDefPtr def);
D
Daniel P. Berrange 已提交
936
void virDomainDefClearDeviceAliases(virDomainDefPtr def);
937

938 939 940 941 942 943 944 945
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
                                           virDomainDeviceInfoPtr dev,
                                           void *opaque);

int virDomainDeviceInfoIterate(virDomainDefPtr def,
                               virDomainDeviceInfoCallback cb,
                               void *opaque);

946
void virDomainDefFree(virDomainDefPtr vm);
947 948 949
void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
int virDomainObjUnref(virDomainObjPtr vm);
950

951 952
/* live == true means def describes an active domain (being migrated or
 * restored) as opposed to a new persistent configuration of the domain */
953
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
954
                                   virDomainObjListPtr doms,
955 956
                                   const virDomainDefPtr def,
                                   bool live);
957 958 959
void virDomainObjAssignDef(virDomainObjPtr domain,
                           const virDomainDefPtr def,
                           bool live);
960
void virDomainRemoveInactive(virDomainObjListPtr doms,
961 962
                             virDomainObjPtr dom);

963
# ifndef PROXY
964
virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
965
                                              const virDomainDefPtr def,
966 967
                                              const char *xmlStr,
                                              int flags);
968
virDomainDefPtr virDomainDefParseString(virCapsPtr caps,
969 970
                                        const char *xmlStr,
                                        int flags);
971
virDomainDefPtr virDomainDefParseFile(virCapsPtr caps,
972 973
                                      const char *filename,
                                      int flags);
974
virDomainDefPtr virDomainDefParseNode(virCapsPtr caps,
975
                                      xmlDocPtr doc,
976 977
                                      xmlNodePtr root,
                                      int flags);
978

979
virDomainObjPtr virDomainObjParseFile(virCapsPtr caps,
980
                                      const char *filename);
981
virDomainObjPtr virDomainObjParseNode(virCapsPtr caps,
982 983 984
                                      xmlDocPtr xml,
                                      xmlNodePtr root);

985
int virDomainDefAddImplicitControllers(virDomainDefPtr def);
986

987
# endif
988
char *virDomainDefFormat(virDomainDefPtr def,
989 990
                         int flags);

991
int virDomainCpuSetParse(const char **str,
992 993 994
                         char sep,
                         char *cpuset,
                         int maxcpu);
995
char *virDomainCpuSetFormat(char *cpuset,
996 997
                            int maxcpu);

998 999 1000 1001
int virDomainDiskInsert(virDomainDefPtr def,
                        virDomainDiskDefPtr disk);
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
1002
int virDomainDiskDefAssignAddress(virDomainDiskDefPtr def);
1003

1004 1005 1006 1007 1008
int virDomainControllerInsert(virDomainDefPtr def,
                              virDomainControllerDefPtr controller);
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);

1009
int virDomainSaveXML(const char *configDir,
1010 1011 1012
                     virDomainDefPtr def,
                     const char *xml);

1013
int virDomainSaveConfig(const char *configDir,
1014
                        virDomainDefPtr def);
1015
int virDomainSaveStatus(virCapsPtr caps,
1016
                        const char *statusDir,
1017
                        virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
1018

1019 1020 1021 1022
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

1023
int virDomainLoadAllConfigs(virCapsPtr caps,
1024
                            virDomainObjListPtr doms,
1025
                            const char *configDir,
1026
                            const char *autostartDir,
1027
                            int liveStatus,
1028 1029
                            virDomainLoadConfigNotify notify,
                            void *opaque);
1030

1031
int virDomainDeleteConfig(const char *configDir,
1032
                          const char *autostartDir,
1033 1034
                          virDomainObjPtr dom);

1035
char *virDomainConfigFile(const char *dir,
1036 1037
                          const char *name);

1038 1039 1040 1041
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

1042
virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def);
1043 1044
int virDomainVideoDefaultType(virDomainDefPtr def);
int virDomainVideoDefaultRAM(virDomainDefPtr def, int type);
1045

1046 1047 1048 1049
int virDomainObjIsDuplicate(virDomainObjListPtr doms,
                            virDomainDefPtr def,
                            unsigned int check_active);

D
Daniel P. Berrange 已提交
1050 1051
void virDomainObjLock(virDomainObjPtr obj);
void virDomainObjUnlock(virDomainObjPtr obj);
1052

1053 1054 1055 1056 1057 1058 1059 1060 1061 1062
int virDomainObjListNumOfDomains(virDomainObjListPtr doms, int active);

int virDomainObjListGetActiveIDs(virDomainObjListPtr doms,
                                 int *ids,
                                 int maxids);
int virDomainObjListGetInactiveNames(virDomainObjListPtr doms,
                                     char **const names,
                                     int maxnames);


1063 1064 1065 1066
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
VIR_ENUM_DECL(virDomainFeature)
VIR_ENUM_DECL(virDomainLifecycle)
1067
VIR_ENUM_DECL(virDomainDevice)
1068 1069
VIR_ENUM_DECL(virDomainDeviceAddress)
VIR_ENUM_DECL(virDomainDeviceAddressMode)
1070 1071 1072
VIR_ENUM_DECL(virDomainDisk)
VIR_ENUM_DECL(virDomainDiskDevice)
VIR_ENUM_DECL(virDomainDiskBus)
1073
VIR_ENUM_DECL(virDomainDiskCache)
1074
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
1075
VIR_ENUM_DECL(virDomainController)
1076
VIR_ENUM_DECL(virDomainFS)
1077
VIR_ENUM_DECL(virDomainNet)
1078
VIR_ENUM_DECL(virDomainChrTarget)
1079 1080
VIR_ENUM_DECL(virDomainChr)
VIR_ENUM_DECL(virDomainSoundModel)
R
Richard Jones 已提交
1081 1082
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
1083
VIR_ENUM_DECL(virDomainVideo)
1084 1085
VIR_ENUM_DECL(virDomainHostdevMode)
VIR_ENUM_DECL(virDomainHostdevSubsys)
1086 1087 1088
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
1089 1090
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
1091
VIR_ENUM_DECL(virDomainSeclabel)
1092
VIR_ENUM_DECL(virDomainClockOffset)
1093

1094 1095
VIR_ENUM_DECL(virDomainNetdevMacvtap)

1096
VIR_ENUM_DECL(virDomainTimerName)
1097
VIR_ENUM_DECL(virDomainTimerTrack)
1098 1099 1100
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)

1101
#endif /* __DOMAIN_CONF_H */