domain_conf.h 40.6 KB
Newer Older
1 2 3
/*
 * domain_conf.h: domain XML processing
 *
4
 * Copyright (C) 2006-2011 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
# include "sysinfo.h"
43

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

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
/* 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,
64
    VIR_DOMAIN_VIRT_VBOX,
D
Daniel Veillard 已提交
65
    VIR_DOMAIN_VIRT_ONE,
66
    VIR_DOMAIN_VIRT_PHYP,
67 68 69 70

    VIR_DOMAIN_VIRT_LAST,
};

71 72 73
enum virDomainDeviceAddressType {
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
74
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
75
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
76
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
77 78 79 80 81 82 83 84 85 86 87 88 89

    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;
};

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

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

E
Eric Blake 已提交
106 107 108 109 110 111 112
typedef struct _virDomainDeviceCcidAddress virDomainDeviceCcidAddress;
typedef virDomainDeviceCcidAddress *virDomainDeviceCcidAddressPtr;
struct _virDomainDeviceCcidAddress {
    unsigned int controller;
    unsigned int slot;
};

113 114 115
typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
struct _virDomainDeviceInfo {
D
Daniel P. Berrange 已提交
116
    char *alias;
117 118 119
    int type;
    union {
        virDomainDevicePCIAddress pci;
120
        virDomainDeviceDriveAddress drive;
121
        virDomainDeviceVirtioSerialAddress vioserial;
E
Eric Blake 已提交
122
        virDomainDeviceCcidAddress ccid;
123 124 125 126
    } addr;
};


127 128 129 130
/* Two types of disk backends */
enum virDomainDiskType {
    VIR_DOMAIN_DISK_TYPE_BLOCK,
    VIR_DOMAIN_DISK_TYPE_FILE,
131
    VIR_DOMAIN_DISK_TYPE_DIR,
M
MORITA Kazutaka 已提交
132
    VIR_DOMAIN_DISK_TYPE_NETWORK,
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151

    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,
152
    VIR_DOMAIN_DISK_BUS_USB,
153
    VIR_DOMAIN_DISK_BUS_UML,
154
    VIR_DOMAIN_DISK_BUS_SATA,
155 156 157 158

    VIR_DOMAIN_DISK_BUS_LAST
};

159 160 161 162 163 164 165 166 167
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
};

168 169 170 171
enum  virDomainDiskErrorPolicy {
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
172
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
173 174 175 176

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
};

M
MORITA Kazutaka 已提交
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
enum virDomainDiskProtocol {
    VIR_DOMAIN_DISK_PROTOCOL_NBD,
    VIR_DOMAIN_DISK_PROTOCOL_RBD,
    VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG,

    VIR_DOMAIN_DISK_PROTOCOL_LAST
};

typedef struct _virDomainDiskHostDef virDomainDiskHostDef;
typedef virDomainDiskHostDef *virDomainDiskHostDefPtr;
struct _virDomainDiskHostDef {
    char *name;
    char *port;
};

M
Matthias Dahl 已提交
192 193 194 195 196 197 198 199
enum  virDomainDiskIo {
    VIR_DOMAIN_DISK_IO_DEFAULT,
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
};

200 201 202 203 204 205 206 207 208
/* Stores the virtual disk configuration */
typedef struct _virDomainDiskDef virDomainDiskDef;
typedef virDomainDiskDef *virDomainDiskDefPtr;
struct _virDomainDiskDef {
    int type;
    int device;
    int bus;
    char *src;
    char *dst;
M
MORITA Kazutaka 已提交
209 210 211
    int protocol;
    int nhosts;
    virDomainDiskHostDefPtr hosts;
212 213
    char *driverName;
    char *driverType;
214
    char *serial;
215
    int cachemode;
216
    int error_policy;
217
    int bootIndex;
M
Matthias Dahl 已提交
218
    int iomode;
219 220
    unsigned int readonly : 1;
    unsigned int shared : 1;
221
    virDomainDeviceInfo info;
222
    virStorageEncryptionPtr encryption;
223 224 225
};


226 227 228 229 230
enum virDomainControllerType {
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
231
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
232
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
233 234 235 236

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
};

237 238

enum virDomainControllerModel {
239
    VIR_DOMAIN_CONTROLLER_MODEL_AUTO,
240 241 242
    VIR_DOMAIN_CONTROLLER_MODEL_BUSLOGIC,
    VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC,
    VIR_DOMAIN_CONTROLLER_MODEL_LSISAS1068,
243
    VIR_DOMAIN_CONTROLLER_MODEL_VMPVSCSI,
244 245 246 247

    VIR_DOMAIN_CONTROLLER_MODEL_LAST
};

248 249 250 251 252 253 254
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

255 256 257 258 259 260
/* Stores the virtual disk controller configuration */
typedef struct _virDomainControllerDef virDomainControllerDef;
typedef virDomainControllerDef *virDomainControllerDefPtr;
struct _virDomainControllerDef {
    int type;
    int idx;
261
    int model; /* -1 == undef */
262 263 264
    union {
        virDomainVirtioSerialOpts vioserial;
    } opts;
265 266 267 268
    virDomainDeviceInfo info;
};


269 270 271 272 273 274 275 276 277 278
/* 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
};

279 280 281 282 283 284 285 286 287
/* Filesystem mount access mode  */
enum virDomainFSAccessMode {
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
};

288 289 290 291
typedef struct _virDomainFSDef virDomainFSDef;
typedef virDomainFSDef *virDomainFSDefPtr;
struct _virDomainFSDef {
    int type;
292
    int accessmode;
293 294 295
    char *src;
    char *dst;
    unsigned int readonly : 1;
296
    virDomainDeviceInfo info;
297 298 299
};


300 301 302 303 304 305 306 307 308
/* 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 已提交
309
    VIR_DOMAIN_NET_TYPE_INTERNAL,
310
    VIR_DOMAIN_NET_TYPE_DIRECT,
311 312 313 314

    VIR_DOMAIN_NET_TYPE_LAST,
};

315 316 317 318 319 320 321 322
/* the backend driver used for virtio interfaces */
enum virDomainNetBackendType {
    VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT, /* prefer kernel, fall back to user */
    VIR_DOMAIN_NET_BACKEND_TYPE_QEMU,    /* userland */
    VIR_DOMAIN_NET_BACKEND_TYPE_VHOST,   /* kernel */

    VIR_DOMAIN_NET_BACKEND_TYPE_LAST,
};
323

324 325 326 327 328 329 330 331 332
/* the TX algorithm used for virtio interfaces */
enum virDomainNetVirtioTxModeType {
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT, /* default for this version of qemu */
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_IOTHREAD,
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_TIMER,

    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST,
};

333 334 335 336 337 338 339 340 341 342
/* 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,
};


343 344 345 346
/* Stores the virtual network interface configuration */
typedef struct _virDomainNetDef virDomainNetDef;
typedef virDomainNetDef *virDomainNetDefPtr;
struct _virDomainNetDef {
S
Stefan Berger 已提交
347
    enum virDomainNetType type;
348
    unsigned char mac[VIR_MAC_BUFLEN];
349
    char *model;
350 351 352
    union {
        struct {
            enum virDomainNetBackendType name; /* which driver backend to use */
353
            enum virDomainNetVirtioTxModeType txmode;
354 355
        } virtio;
    } driver;
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
    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;
371
            char *script;
372
            char *ipaddr;
373
        } bridge;
D
Daniel Veillard 已提交
374 375 376
        struct {
            char *name;
        } internal;
377 378 379
        struct {
            char *linkdev;
            int mode;
380
            virVirtualPortProfileParams virtPortProfile;
381
        } direct;
382
    } data;
383 384 385 386
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
387
    char *ifname;
388
    int bootIndex;
389
    virDomainDeviceInfo info;
390 391
    char *filter;
    virNWFilterHashTablePtr filterparams;
392 393
};

394
enum virDomainChrDeviceType {
395
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
396 397
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
398
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
399

400 401 402 403 404 405 406 407
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST,
};

enum virDomainChrChannelTargetType {
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,

    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
408 409
};

410 411 412 413
enum virDomainChrConsoleTargetType {
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
414
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
415 416 417 418

    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST,
};

419
enum virDomainChrType {
420 421 422 423 424 425 426 427 428 429
    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,
430
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
431 432 433 434 435 436 437

    VIR_DOMAIN_CHR_TYPE_LAST,
};

enum virDomainChrTcpProtocol {
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW,
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
438 439
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
440 441 442 443

    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST,
};

E
Eric Blake 已提交
444 445 446 447 448 449 450
enum virDomainChrSpicevmcName {
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,

    VIR_DOMAIN_CHR_SPICEVMC_LAST,
};

451 452 453 454 455
/* The host side information for a character device.  */
typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;
struct _virDomainChrSourceDef {
    int type; /* virDomainChrType */
456
    union {
E
Eric Blake 已提交
457
        /* no <source> for null, vc, stdio */
458 459 460 461 462 463
        struct {
            char *path;
        } file; /* pty, file, pipe, or device */
        struct {
            char *host;
            char *service;
464
            bool listen;
465 466 467 468 469 470 471 472 473 474
            int protocol;
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
475
            bool listen;
476
        } nix;
E
Eric Blake 已提交
477
        int spicevmc;
478
    } data;
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
};

/* A complete character device, both host and domain views.  */
typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr;
struct _virDomainChrDef {
    int deviceType;
    int targetType;
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

    virDomainChrSourceDef source;
494 495

    virDomainDeviceInfo info;
496 497
};

E
Eric Blake 已提交
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
enum virDomainSmartcardType {
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

    VIR_DOMAIN_SMARTCARD_TYPE_LAST,
};

# define VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES 3
# define VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE "/etc/pki/nssdb"

typedef struct _virDomainSmartcardDef virDomainSmartcardDef;
typedef virDomainSmartcardDef *virDomainSmartcardDefPtr;
struct _virDomainSmartcardDef {
    int type; /* virDomainSmartcardType */
    union {
        /* no extra data for 'host' */
        struct {
            char *file[VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES];
            char *database;
        } cert; /* 'host-certificates' */
        virDomainChrSourceDef passthru; /* 'passthrough' */
    } data;

    virDomainDeviceInfo info;
};

525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
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;
545
    virDomainDeviceInfo info;
546 547 548 549 550 551
};

enum virDomainSoundModel {
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
552
    VIR_DOMAIN_SOUND_MODEL_AC97,
553
    VIR_DOMAIN_SOUND_MODEL_ICH6,
554 555 556 557 558 559 560 561

    VIR_DOMAIN_SOUND_MODEL_LAST
};

typedef struct _virDomainSoundDef virDomainSoundDef;
typedef virDomainSoundDef *virDomainSoundDefPtr;
struct _virDomainSoundDef {
    int model;
562
    virDomainDeviceInfo info;
563 564
};

R
Richard Jones 已提交
565 566 567 568 569 570 571 572 573 574 575 576
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,
H
Hu Tao 已提交
577
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
578 579 580 581 582 583 584 585 586 587
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
};

typedef struct _virDomainWatchdogDef virDomainWatchdogDef;
typedef virDomainWatchdogDef *virDomainWatchdogDefPtr;
struct _virDomainWatchdogDef {
    int model;
    int action;
588
    virDomainDeviceInfo info;
R
Richard Jones 已提交
589 590
};

591 592 593 594 595 596 597

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,
598
    VIR_DOMAIN_VIDEO_TYPE_QXL,
599 600 601 602 603

    VIR_DOMAIN_VIDEO_TYPE_LAST
};


604 605 606
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
607 608
    unsigned int support3d :1;
    unsigned int support2d :1;
609 610 611
};


612 613 614 615 616 617
typedef struct _virDomainVideoDef virDomainVideoDef;
typedef virDomainVideoDef *virDomainVideoDefPtr;
struct _virDomainVideoDef {
    int type;
    unsigned int vram;
    unsigned int heads;
618
    virDomainVideoAccelDefPtr accel;
619
    virDomainDeviceInfo info;
620 621
};

622 623 624 625
/* 3 possible graphics console modes */
enum virDomainGraphicsType {
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
626 627
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
628
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
629 630 631 632

    VIR_DOMAIN_GRAPHICS_TYPE_LAST,
};

633 634 635 636 637 638 639 640
typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef;
typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr;
struct _virDomainGraphicsAuthDef {
    char *passwd;
    unsigned int expires: 1; /* Whether there is an expiry time set */
    time_t validTo;  /* seconds since epoch */
};

641 642 643 644 645 646 647
enum virDomainGraphicsSpiceChannelName {
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MAIN,
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_DISPLAY,
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_INPUT,
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_CURSOR,
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_PLAYBACK,
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_RECORD,
E
Eric Blake 已提交
648
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
649 650 651 652 653 654 655 656 657 658 659

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
};

enum virDomainGraphicsSpiceChannelMode {
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY,
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE,
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE,

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_LAST
};
660

661 662 663 664 665 666 667
typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;
struct _virDomainGraphicsDef {
    int type;
    union {
        struct {
            int port;
668
            unsigned int autoport :1;
669 670
            char *listenAddr;
            char *keymap;
671
            char *socket;
672
            virDomainGraphicsAuthDef auth;
673 674 675 676
        } vnc;
        struct {
            char *display;
            char *xauth;
677
            int fullscreen;
678
        } sdl;
679 680 681
        struct {
            int port;
            char *listenAddr;
682 683 684
            unsigned int autoport :1;
            unsigned int replaceUser :1;
            unsigned int multiUser :1;
685 686 687
        } rdp;
        struct {
            char *display;
688
            unsigned int fullscreen :1;
689
        } desktop;
690 691 692 693 694
        struct {
            int port;
            int tlsPort;
            char *listenAddr;
            char *keymap;
695
            virDomainGraphicsAuthDef auth;
696
            unsigned int autoport :1;
697
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
698
        } spice;
699 700 701
    } data;
};

702 703 704
enum virDomainHostdevMode {
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
705

706 707 708 709 710 711 712 713 714 715 716 717 718 719
    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 */
720
    unsigned int managed : 1;
721 722 723 724 725 726 727 728 729 730 731
    union {
        struct {
            int type; /* enum virDomainHostdevBusType */
            union {
                struct {
                    unsigned bus;
                    unsigned device;

                    unsigned vendor;
                    unsigned product;
                } usb;
732
                virDomainDevicePCIAddress pci; /* host address */
733
            } u;
734 735 736 737 738
        } subsys;
        struct {
            /* TBD: struct capabilities see:
             * https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
             */
739
            int dummy;
740 741 742
        } caps;
    } source;
    char* target;
743
    int bootIndex;
744
    virDomainDeviceInfo info; /* Guest address */
745
};
746

747 748 749 750

enum {
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
751
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
752 753 754 755 756 757 758 759 760 761 762 763

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
};

typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;
struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
};


764 765 766 767 768 769 770 771 772
enum virDomainSmbiosMode {
    VIR_DOMAIN_SMBIOS_NONE,
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
};

773 774 775
/* Flags for the 'type' field in next struct */
enum virDomainDeviceType {
    VIR_DOMAIN_DEVICE_DISK,
776
    VIR_DOMAIN_DEVICE_FS,
777 778 779
    VIR_DOMAIN_DEVICE_NET,
    VIR_DOMAIN_DEVICE_INPUT,
    VIR_DOMAIN_DEVICE_SOUND,
780
    VIR_DOMAIN_DEVICE_VIDEO,
781
    VIR_DOMAIN_DEVICE_HOSTDEV,
R
Richard Jones 已提交
782
    VIR_DOMAIN_DEVICE_WATCHDOG,
783
    VIR_DOMAIN_DEVICE_CONTROLLER,
784
    VIR_DOMAIN_DEVICE_GRAPHICS,
785 786

    VIR_DOMAIN_DEVICE_LAST,
787 788 789 790 791 792 793 794
};

typedef struct _virDomainDeviceDef virDomainDeviceDef;
typedef virDomainDeviceDef *virDomainDeviceDefPtr;
struct _virDomainDeviceDef {
    int type;
    union {
        virDomainDiskDefPtr disk;
795
        virDomainControllerDefPtr controller;
796
        virDomainFSDefPtr fs;
797 798 799
        virDomainNetDefPtr net;
        virDomainInputDefPtr input;
        virDomainSoundDefPtr sound;
800
        virDomainVideoDefPtr video;
801
        virDomainHostdevDefPtr hostdev;
R
Richard Jones 已提交
802
        virDomainWatchdogDefPtr watchdog;
803
        virDomainGraphicsDefPtr graphics;
804 805 806 807
    } data;
};


808
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
809 810 811 812 813 814 815 816 817 818

enum virDomainBootOrder {
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

    VIR_DOMAIN_BOOT_LAST,
};

819 820 821 822 823 824
enum virDomainBootMenu {
    VIR_DOMAIN_BOOT_MENU_DEFAULT = 0,
    VIR_DOMAIN_BOOT_MENU_ENABLED,
    VIR_DOMAIN_BOOT_MENU_DISABLED,
};

825 826 827 828
enum virDomainFeature {
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
829
    VIR_DOMAIN_FEATURE_HAP,
830 831 832 833 834 835 836 837 838 839 840 841 842

    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
};

843 844 845 846 847 848 849 850 851 852 853
enum virDomainLifecycleCrashAction {
    VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY,
    VIR_DOMAIN_LIFECYCLE_CRASH_RESTART,
    VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME,
    VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE,
    VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY,
    VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART,

    VIR_DOMAIN_LIFECYCLE_CRASH_LAST
};

854 855 856 857 858 859 860 861 862
/* 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];
863
    int bootmenu;
864
    char *init;
865 866 867 868 869 870 871
    char *kernel;
    char *initrd;
    char *cmdline;
    char *root;
    char *loader;
    char *bootloader;
    char *bootloaderArgs;
872
    int smbios_mode;
873 874
};

875 876 877 878 879 880 881
enum virDomainSeclabelType {
    VIR_DOMAIN_SECLABEL_DYNAMIC,
    VIR_DOMAIN_SECLABEL_STATIC,

    VIR_DOMAIN_SECLABEL_LAST,
};

882 883 884 885 886 887 888
/* 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 */
889
    int type;
890 891
};

892 893 894 895 896 897 898 899 900 901
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,
};

902 903 904 905
enum virDomainTimerTrackType {
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
906

907
    VIR_DOMAIN_TIMER_TRACK_LAST,
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923
};

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,
924
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
925 926 927 928

    VIR_DOMAIN_TIMER_MODE_LAST,
};

929 930 931 932 933 934 935 936
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

937 938 939 940 941 942 943
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 */

944 945 946 947
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
948 949 950 951 952 953

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

954 955 956
enum virDomainClockOffsetType {
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
957
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
958
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
959 960 961 962 963 964 965 966

    VIR_DOMAIN_CLOCK_OFFSET_LAST,
};

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

968 969 970 971 972 973 974 975 976
    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;
977 978 979

    int ntimers;
    virDomainTimerDefPtr *timers;
980 981
};

982
# define VIR_DOMAIN_CPUMASK_LEN 1024
983

C
Chris Lalancette 已提交
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031

/* 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 {
    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 virDomainSnapshotHasChildren(virDomainSnapshotObjPtr snap,
                                virDomainSnapshotObjListPtr snapshots);

1032 1033 1034 1035 1036 1037 1038 1039
/* 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;
1040
    char *description;
1041

1042 1043 1044 1045
    struct {
        unsigned int weight;
    } blkio;

1046 1047 1048 1049 1050 1051 1052 1053 1054
    struct {
        unsigned long max_balloon;
        unsigned long cur_balloon;
        unsigned long hugepage_backed;
        unsigned long hard_limit;
        unsigned long soft_limit;
        unsigned long min_guarantee;
        unsigned long swap_hard_limit;
    } mem;
E
Eric Blake 已提交
1055 1056
    unsigned short vcpus;
    unsigned short maxvcpus;
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
    int cpumasklen;
    char *cpumask;

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

    virDomainOSDef os;
    char *emulator;
    int features;

1069
    virDomainClockDef clock;
1070

1071 1072
    int ngraphics;
    virDomainGraphicsDefPtr *graphics;
1073 1074 1075 1076

    int ndisks;
    virDomainDiskDefPtr *disks;

1077 1078 1079
    int ncontrollers;
    virDomainControllerDefPtr *controllers;

1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
    int nfss;
    virDomainFSDefPtr *fss;

    int nnets;
    virDomainNetDefPtr *nets;

    int ninputs;
    virDomainInputDefPtr *inputs;

    int nsounds;
    virDomainSoundDefPtr *sounds;

1092 1093 1094
    int nvideos;
    virDomainVideoDefPtr *videos;

1095 1096 1097
    int nhostdevs;
    virDomainHostdevDefPtr *hostdevs;

E
Eric Blake 已提交
1098 1099 1100
    int nsmartcards;
    virDomainSmartcardDefPtr *smartcards;

1101 1102 1103 1104 1105 1106
    int nserials;
    virDomainChrDefPtr *serials;

    int nparallels;
    virDomainChrDefPtr *parallels;

1107 1108 1109
    int nchannels;
    virDomainChrDefPtr *channels;

1110
    /* Only 1 */
1111
    virDomainChrDefPtr console;
1112
    virSecurityLabelDef seclabel;
R
Richard Jones 已提交
1113
    virDomainWatchdogDefPtr watchdog;
1114
    virDomainMemballoonDefPtr memballoon;
1115
    virCPUDefPtr cpu;
1116
    virSysinfoDefPtr sysinfo;
1117 1118 1119

    void *namespaceData;
    virDomainXMLNamespace ns;
1120 1121 1122 1123 1124 1125
};

/* Guest VM runtime state */
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
1126
    virMutex lock;
1127
    int refs;
1128

1129 1130 1131 1132 1133
    int pid;
    int state;

    unsigned int autostart : 1;
    unsigned int persistent : 1;
1134
    unsigned int updated : 1;
1135 1136 1137

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

C
Chris Lalancette 已提交
1139 1140 1141
    virDomainSnapshotObjList snapshots;
    virDomainSnapshotObjPtr current_snapshot;

1142 1143
    void *privateData;
    void (*privateDataFreeFunc)(void *);
1144 1145
};

1146 1147 1148
typedef struct _virDomainObjList virDomainObjList;
typedef virDomainObjList *virDomainObjListPtr;
struct _virDomainObjList {
1149 1150 1151
    /* uuid string -> virDomainObj  mapping
     * for O(1), lockless lookup-by-uuid */
    virHashTable *objs;
1152
};
1153 1154

static inline int
D
Daniel P. Berrange 已提交
1155
virDomainObjIsActive(virDomainObjPtr dom)
1156 1157 1158 1159
{
    return dom->def->id != -1;
}

1160

1161 1162
int virDomainObjListInit(virDomainObjListPtr objs);
void virDomainObjListDeinit(virDomainObjListPtr objs);
1163

1164
virDomainObjPtr virDomainFindByID(const virDomainObjListPtr doms,
1165
                                  int id);
1166
virDomainObjPtr virDomainFindByUUID(const virDomainObjListPtr doms,
1167
                                    const unsigned char *uuid);
1168
virDomainObjPtr virDomainFindByName(const virDomainObjListPtr doms,
1169 1170 1171 1172 1173 1174
                                    const char *name);


void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
void virDomainDiskDefFree(virDomainDiskDefPtr def);
1175
void virDomainDiskHostDefFree(virDomainDiskHostDefPtr def);
1176
void virDomainControllerDefFree(virDomainControllerDefPtr def);
1177
void virDomainFSDefFree(virDomainFSDefPtr def);
1178
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
1179
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
1180
void virDomainChrDefFree(virDomainChrDefPtr def);
1181
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
1182
void virDomainSoundDefFree(virDomainSoundDefPtr def);
1183
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
R
Richard Jones 已提交
1184
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
1185
void virDomainVideoDefFree(virDomainVideoDefPtr def);
1186
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
1187
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
1188 1189 1190
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                  int type);
int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
1191
int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr);
1192
int virDomainDeviceVirtioSerialAddressIsValid(virDomainDeviceVirtioSerialAddressPtr addr);
1193 1194
int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info);
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
1195
void virDomainDefClearPCIAddresses(virDomainDefPtr def);
D
Daniel P. Berrange 已提交
1196
void virDomainDefClearDeviceAliases(virDomainDefPtr def);
1197

1198 1199 1200 1201 1202 1203 1204 1205
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
                                           virDomainDeviceInfoPtr dev,
                                           void *opaque);

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

1206
void virDomainDefFree(virDomainDefPtr vm);
1207 1208 1209
void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
int virDomainObjUnref(virDomainObjPtr vm);
1210

1211 1212
/* live == true means def describes an active domain (being migrated or
 * restored) as opposed to a new persistent configuration of the domain */
1213
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
1214
                                   virDomainObjListPtr doms,
1215 1216
                                   const virDomainDefPtr def,
                                   bool live);
1217 1218 1219
void virDomainObjAssignDef(virDomainObjPtr domain,
                           const virDomainDefPtr def,
                           bool live);
1220
int virDomainObjSetDefTransient(virCapsPtr caps,
1221 1222
                                virDomainObjPtr domain,
                                bool live);
1223 1224 1225
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
                             virDomainObjPtr domain);
1226
void virDomainRemoveInactive(virDomainObjListPtr doms,
1227 1228
                             virDomainObjPtr dom);

1229
virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
1230
                                              const virDomainDefPtr def,
1231 1232
                                              const char *xmlStr,
                                              int flags);
1233
virDomainDefPtr virDomainDefParseString(virCapsPtr caps,
1234 1235
                                        const char *xmlStr,
                                        int flags);
1236
virDomainDefPtr virDomainDefParseFile(virCapsPtr caps,
1237 1238
                                      const char *filename,
                                      int flags);
1239
virDomainDefPtr virDomainDefParseNode(virCapsPtr caps,
1240
                                      xmlDocPtr doc,
1241 1242
                                      xmlNodePtr root,
                                      int flags);
1243

1244
virDomainObjPtr virDomainObjParseFile(virCapsPtr caps,
1245 1246
                                      const char *filename);

1247
int virDomainDefAddImplicitControllers(virDomainDefPtr def);
1248

1249
char *virDomainDefFormat(virDomainDefPtr def,
1250 1251
                         int flags);

1252
int virDomainCpuSetParse(const char **str,
1253 1254 1255
                         char sep,
                         char *cpuset,
                         int maxcpu);
1256
char *virDomainCpuSetFormat(char *cpuset,
1257 1258
                            int maxcpu);

1259 1260 1261 1262
int virDomainDiskInsert(virDomainDefPtr def,
                        virDomainDiskDefPtr disk);
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
1263
int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def);
1264

1265 1266
void virDomainDiskRemove(virDomainDefPtr def, size_t i);

1267 1268 1269 1270 1271
int virDomainControllerInsert(virDomainDefPtr def,
                              virDomainControllerDefPtr controller);
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);

1272
int virDomainSaveXML(const char *configDir,
1273 1274 1275
                     virDomainDefPtr def,
                     const char *xml);

1276
int virDomainSaveConfig(const char *configDir,
1277
                        virDomainDefPtr def);
1278
int virDomainSaveStatus(virCapsPtr caps,
1279
                        const char *statusDir,
1280
                        virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
1281

1282 1283 1284 1285
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

1286
int virDomainLoadAllConfigs(virCapsPtr caps,
1287
                            virDomainObjListPtr doms,
1288
                            const char *configDir,
1289
                            const char *autostartDir,
1290
                            int liveStatus,
1291 1292
                            virDomainLoadConfigNotify notify,
                            void *opaque);
1293

1294
int virDomainDeleteConfig(const char *configDir,
1295
                          const char *autostartDir,
1296 1297
                          virDomainObjPtr dom);

1298
char *virDomainConfigFile(const char *dir,
1299 1300
                          const char *name);

1301 1302 1303 1304
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

1305
virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def);
1306 1307
int virDomainVideoDefaultType(virDomainDefPtr def);
int virDomainVideoDefaultRAM(virDomainDefPtr def, int type);
1308

1309 1310 1311 1312
int virDomainObjIsDuplicate(virDomainObjListPtr doms,
                            virDomainDefPtr def,
                            unsigned int check_active);

D
Daniel P. Berrange 已提交
1313 1314
void virDomainObjLock(virDomainObjPtr obj);
void virDomainObjUnlock(virDomainObjPtr obj);
1315

1316 1317 1318 1319 1320 1321 1322 1323 1324
int virDomainObjListNumOfDomains(virDomainObjListPtr doms, int active);

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

E
Eric Blake 已提交
1325 1326 1327 1328 1329 1330 1331 1332 1333
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

int virDomainSmartcardDefForeach(virDomainDefPtr def,
                                 bool abortOnError,
                                 virDomainSmartcardDefIterator iter,
                                 void *opaque);

1334 1335 1336 1337 1338 1339 1340 1341 1342
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

int virDomainChrDefForeach(virDomainDefPtr def,
                           bool abortOnError,
                           virDomainChrDefIterator iter,
                           void *opaque);

1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353
typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
                                            const char *path,
                                            size_t depth,
                                            void *opaque);

int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
                                bool allowProbing,
                                bool ignoreOpenFailure,
                                virDomainDiskDefPathIterator iter,
                                void *opaque);

1354 1355 1356
typedef const char* (*virLifecycleToStringFunc)(int type);
typedef int (*virLifecycleFromStringFunc)(const char *type);

1357 1358 1359 1360
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
VIR_ENUM_DECL(virDomainFeature)
VIR_ENUM_DECL(virDomainLifecycle)
1361
VIR_ENUM_DECL(virDomainLifecycleCrash)
1362
VIR_ENUM_DECL(virDomainDevice)
1363 1364
VIR_ENUM_DECL(virDomainDeviceAddress)
VIR_ENUM_DECL(virDomainDeviceAddressMode)
1365 1366 1367
VIR_ENUM_DECL(virDomainDisk)
VIR_ENUM_DECL(virDomainDiskDevice)
VIR_ENUM_DECL(virDomainDiskBus)
1368
VIR_ENUM_DECL(virDomainDiskCache)
1369
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
M
MORITA Kazutaka 已提交
1370
VIR_ENUM_DECL(virDomainDiskProtocol)
M
Matthias Dahl 已提交
1371
VIR_ENUM_DECL(virDomainDiskIo)
1372
VIR_ENUM_DECL(virDomainController)
1373
VIR_ENUM_DECL(virDomainControllerModel)
1374
VIR_ENUM_DECL(virDomainFS)
1375
VIR_ENUM_DECL(virDomainFSAccessMode)
1376
VIR_ENUM_DECL(virDomainNet)
1377
VIR_ENUM_DECL(virDomainNetBackend)
1378
VIR_ENUM_DECL(virDomainNetVirtioTxMode)
1379
VIR_ENUM_DECL(virDomainChrDevice)
1380
VIR_ENUM_DECL(virDomainChrChannelTarget)
1381
VIR_ENUM_DECL(virDomainChrConsoleTarget)
E
Eric Blake 已提交
1382
VIR_ENUM_DECL(virDomainSmartcard)
1383
VIR_ENUM_DECL(virDomainChr)
1384
VIR_ENUM_DECL(virDomainChrTcpProtocol)
E
Eric Blake 已提交
1385
VIR_ENUM_DECL(virDomainChrSpicevmc)
1386
VIR_ENUM_DECL(virDomainSoundModel)
1387
VIR_ENUM_DECL(virDomainMemballoonModel)
1388
VIR_ENUM_DECL(virDomainSysinfo)
1389
VIR_ENUM_DECL(virDomainSmbiosMode)
R
Richard Jones 已提交
1390 1391
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
1392
VIR_ENUM_DECL(virDomainVideo)
1393 1394
VIR_ENUM_DECL(virDomainHostdevMode)
VIR_ENUM_DECL(virDomainHostdevSubsys)
1395 1396 1397
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
1398 1399
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
1400 1401
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
1402
VIR_ENUM_DECL(virDomainSeclabel)
1403
VIR_ENUM_DECL(virDomainClockOffset)
1404

1405 1406
VIR_ENUM_DECL(virDomainNetdevMacvtap)

1407
VIR_ENUM_DECL(virDomainTimerName)
1408
VIR_ENUM_DECL(virDomainTimerTrack)
1409 1410 1411
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)

1412
#endif /* __DOMAIN_CONF_H */