domain_conf.h 58.3 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 49 50 51 52 53 54 55 56 57 58

/* 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,
59
    VIR_DOMAIN_VIRT_VBOX,
D
Daniel Veillard 已提交
60
    VIR_DOMAIN_VIRT_ONE,
61
    VIR_DOMAIN_VIRT_PHYP,
62 63 64 65

    VIR_DOMAIN_VIRT_LAST,
};

66 67 68
enum virDomainDeviceAddressType {
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
69
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
70
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
71
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
72
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB,
73 74 75 76

    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
};

77 78 79 80 81 82 83 84
enum virDomainDeviceAddressPciMulti {
    VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_DEFAULT = 0,
    VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_ON,
    VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_OFF,

    VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_LAST
};

85 86 87 88 89 90 91
typedef struct _virDomainDevicePCIAddress virDomainDevicePCIAddress;
typedef virDomainDevicePCIAddress *virDomainDevicePCIAddressPtr;
struct _virDomainDevicePCIAddress {
    unsigned int domain;
    unsigned int bus;
    unsigned int slot;
    unsigned int function;
92
    int          multi;  /* enum virDomainDeviceAddressPciMulti */
93 94
};

95 96 97 98 99 100 101 102
typedef struct _virDomainDeviceDriveAddress virDomainDeviceDriveAddress;
typedef virDomainDeviceDriveAddress *virDomainDeviceDriveAddressPtr;
struct _virDomainDeviceDriveAddress {
    unsigned int controller;
    unsigned int bus;
    unsigned int unit;
};

103 104 105 106 107
typedef struct _virDomainDeviceVirtioSerialAddress virDomainDeviceVirtioSerialAddress;
typedef virDomainDeviceVirtioSerialAddress *virDomainDeviceVirtioSerialAddressPtr;
struct _virDomainDeviceVirtioSerialAddress {
    unsigned int controller;
    unsigned int bus;
108
    unsigned int port;
109 110
};

E
Eric Blake 已提交
111 112 113 114 115 116 117
typedef struct _virDomainDeviceCcidAddress virDomainDeviceCcidAddress;
typedef virDomainDeviceCcidAddress *virDomainDeviceCcidAddressPtr;
struct _virDomainDeviceCcidAddress {
    unsigned int controller;
    unsigned int slot;
};

118 119 120 121
typedef struct _virDomainDeviceUSBAddress virDomainDeviceUSBAddress;
typedef virDomainDeviceUSBAddress *virDomainDeviceUSBAddressPtr;
struct _virDomainDeviceUSBAddress {
    unsigned int bus;
122
    char *port;
123 124
};

125 126 127 128 129 130 131 132 133 134 135 136 137
enum virDomainControllerMaster {
    VIR_DOMAIN_CONTROLLER_MASTER_NONE,
    VIR_DOMAIN_CONTROLLER_MASTER_USB,

    VIR_DOMAIN_CONTROLLER_MASTER_LAST
};

typedef struct _virDomainDeviceUSBMaster virDomainDeviceUSBMaster;
typedef virDomainDeviceUSBMaster *virDomainDeviceUSBMasterPtr;
struct _virDomainDeviceUSBMaster {
    unsigned int startport;
};

138 139 140
typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
struct _virDomainDeviceInfo {
141 142 143 144
    /* If adding to this struct, ensure that
     * virDomainDeviceInfoIsSet() is updated
     * to consider the new fields
     */
D
Daniel P. Berrange 已提交
145
    char *alias;
146 147 148
    int type;
    union {
        virDomainDevicePCIAddress pci;
149
        virDomainDeviceDriveAddress drive;
150
        virDomainDeviceVirtioSerialAddress vioserial;
E
Eric Blake 已提交
151
        virDomainDeviceCcidAddress ccid;
152
        virDomainDeviceUSBAddress usb;
153
    } addr;
154 155 156 157
    int mastertype;
    union {
        virDomainDeviceUSBMaster usb;
    } master;
158 159
};

160 161 162 163 164 165 166 167 168
typedef struct _virDomainLeaseDef virDomainLeaseDef;
typedef virDomainLeaseDef *virDomainLeaseDefPtr;
struct _virDomainLeaseDef {
    char *lockspace;
    char *key;
    char *path;
    unsigned long long offset;
};

169

170 171 172 173
/* Two types of disk backends */
enum virDomainDiskType {
    VIR_DOMAIN_DISK_TYPE_BLOCK,
    VIR_DOMAIN_DISK_TYPE_FILE,
174
    VIR_DOMAIN_DISK_TYPE_DIR,
M
MORITA Kazutaka 已提交
175
    VIR_DOMAIN_DISK_TYPE_NETWORK,
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194

    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,
195
    VIR_DOMAIN_DISK_BUS_USB,
196
    VIR_DOMAIN_DISK_BUS_UML,
197
    VIR_DOMAIN_DISK_BUS_SATA,
198 199 200 201

    VIR_DOMAIN_DISK_BUS_LAST
};

202 203 204 205 206
enum  virDomainDiskCache {
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
207
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
208 209 210 211

    VIR_DOMAIN_DISK_CACHE_LAST
};

212 213 214 215
enum  virDomainDiskErrorPolicy {
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
216
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
217 218 219 220

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
};

M
MORITA Kazutaka 已提交
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
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 已提交
236 237 238 239 240 241 242 243
enum  virDomainDiskIo {
    VIR_DOMAIN_DISK_IO_DEFAULT,
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
};

244 245 246 247 248 249 250 251
enum virDomainIoEventFd {
    VIR_DOMAIN_IO_EVENT_FD_DEFAULT = 0,
    VIR_DOMAIN_IO_EVENT_FD_ON,
    VIR_DOMAIN_IO_EVENT_FD_OFF,

    VIR_DOMAIN_IO_EVENT_FD_LAST
};

252 253 254 255 256 257 258 259
enum virDomainVirtioEventIdx {
    VIR_DOMAIN_VIRTIO_EVENT_IDX_DEFAULT = 0,
    VIR_DOMAIN_VIRTIO_EVENT_IDX_ON,
    VIR_DOMAIN_VIRTIO_EVENT_IDX_OFF,

    VIR_DOMAIN_VIRTIO_EVENT_IDX_LAST
};

260 261 262 263 264 265 266 267 268
enum virDomainDiskSnapshot {
    VIR_DOMAIN_DISK_SNAPSHOT_DEFAULT = 0,
    VIR_DOMAIN_DISK_SNAPSHOT_NO,
    VIR_DOMAIN_DISK_SNAPSHOT_INTERNAL,
    VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL,

    VIR_DOMAIN_DISK_SNAPSHOT_LAST
};

269 270 271 272 273
enum virDomainSnapshotState {
    /* Inherit the VIR_DOMAIN_* states from virDomainState.  */
    VIR_DOMAIN_DISK_SNAPSHOT = VIR_DOMAIN_LAST,
};

274 275 276 277 278 279 280 281 282
/* 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 已提交
283 284 285
    int protocol;
    int nhosts;
    virDomainDiskHostDefPtr hosts;
286 287
    char *driverName;
    char *driverType;
288
    char *serial;
289
    int cachemode;
290
    int error_policy;
291
    int bootIndex;
M
Matthias Dahl 已提交
292
    int iomode;
293
    int ioeventfd;
294
    int event_idx;
295
    int snapshot; /* enum virDomainDiskSnapshot */
296 297
    unsigned int readonly : 1;
    unsigned int shared : 1;
298
    unsigned int transient : 1;
299
    virDomainDeviceInfo info;
300
    virStorageEncryptionPtr encryption;
301 302 303
};


304 305 306 307 308
enum virDomainControllerType {
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
309
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
310
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
311
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
312 313 314 315

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
};

316

317 318 319 320 321 322
enum virDomainControllerModelSCSI {
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO,
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC,
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC,
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068,
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI,
323

324
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
325 326
};

M
Marc-André Lureau 已提交
327 328 329 330 331 332 333 334 335 336 337 338 339 340
enum virDomainControllerModelUSB {
    VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX4_UHCI,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_EHCI,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI,

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
};

341 342 343 344 345 346 347
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

348 349 350 351 352 353
/* Stores the virtual disk controller configuration */
typedef struct _virDomainControllerDef virDomainControllerDef;
typedef virDomainControllerDef *virDomainControllerDefPtr;
struct _virDomainControllerDef {
    int type;
    int idx;
354
    int model; /* -1 == undef */
355 356 357
    union {
        virDomainVirtioSerialOpts vioserial;
    } opts;
358 359 360 361
    virDomainDeviceInfo info;
};


362 363 364 365 366 367 368 369 370 371
/* 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
};

372 373 374 375 376 377 378 379 380
/* 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
};

381 382 383 384
typedef struct _virDomainFSDef virDomainFSDef;
typedef virDomainFSDef *virDomainFSDefPtr;
struct _virDomainFSDef {
    int type;
385
    int accessmode;
386 387 388
    char *src;
    char *dst;
    unsigned int readonly : 1;
389
    virDomainDeviceInfo info;
390 391 392
};


393 394 395 396 397 398 399 400 401
/* 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 已提交
402
    VIR_DOMAIN_NET_TYPE_INTERNAL,
403
    VIR_DOMAIN_NET_TYPE_DIRECT,
404 405 406 407

    VIR_DOMAIN_NET_TYPE_LAST,
};

408 409 410 411 412 413 414 415
/* 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,
};
416

417 418 419 420 421 422 423 424 425
/* 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,
};

426 427 428 429 430 431 432 433 434
/* link interface states */
enum virDomainNetInterfaceLinkState {
        VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT = 0, /* Default link state (up) */
        VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP,          /* Link is up. ("cable" connected) */
        VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN ,       /* Link is down. ("cable" disconnected) */

        VIR_DOMAIN_NET_INTERFACE_LINK_STATE_LAST
};

435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
/* Config that was actually used to bring up interface, after
 * resolving network reference. This is private data, only used within
 * libvirt, but still must maintain backward compatibility, because
 * different versions of libvirt may read the same data file.
 */
typedef struct _virDomainActualNetDef virDomainActualNetDef;
typedef virDomainActualNetDef *virDomainActualNetDefPtr;
struct _virDomainActualNetDef {
    int type; /* enum virDomainNetType */
    union {
        struct {
            char *brname;
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
            virVirtualPortProfileParamsPtr virtPortProfile;
        } direct;
    } data;
454
    virBandwidthPtr bandwidth;
455 456
};

457 458 459 460
/* Stores the virtual network interface configuration */
typedef struct _virDomainNetDef virDomainNetDef;
typedef virDomainNetDef *virDomainNetDefPtr;
struct _virDomainNetDef {
S
Stefan Berger 已提交
461
    enum virDomainNetType type;
462
    unsigned char mac[VIR_MAC_BUFLEN];
463
    char *model;
464 465 466
    union {
        struct {
            enum virDomainNetBackendType name; /* which driver backend to use */
467
            enum virDomainNetVirtioTxModeType txmode;
468
            enum virDomainIoEventFd ioeventfd;
469
            enum virDomainVirtioEventIdx event_idx;
470 471
        } virtio;
    } driver;
472 473 474 475 476 477 478 479 480 481 482 483
    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;
484 485 486 487 488 489 490 491 492 493 494
            char *portgroup;
            virVirtualPortProfileParamsPtr virtPortProfile;
            /* actual has info about the currently used physical
             * device (if the network is of type
             * bridge/private/vepa/passthrough). This is saved in the
             * domain state, but never written to persistent config,
             * since it needs to be re-allocated whenever the domain
             * is restarted. It is also never shown to the user, and
             * the user cannot specify it in XML documents.
             */
            virDomainActualNetDefPtr actual;
495 496 497
        } network;
        struct {
            char *brname;
498
            char *script;
499
            char *ipaddr;
500
        } bridge;
D
Daniel Veillard 已提交
501 502 503
        struct {
            char *name;
        } internal;
504 505
        struct {
            char *linkdev;
506
            int mode; /* enum virMacvtapMode from util/macvtap.h */
507
            virVirtualPortProfileParamsPtr virtPortProfile;
508
        } direct;
509
    } data;
510 511 512 513
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
514
    char *ifname;
515
    int bootIndex;
516
    virDomainDeviceInfo info;
517 518
    char *filter;
    virNWFilterHashTablePtr filterparams;
519
    virBandwidthPtr bandwidth;
520
    int linkstate;
521 522
};

E
Eric Blake 已提交
523 524 525 526
/* Used for prefix of ifname of any network name generated dynamically
 * by libvirt, and cannot be used for a persistent network name.  */
# define VIR_NET_GENERATED_PREFIX "vnet"

527
enum virDomainChrDeviceType {
528
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
529 530
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
531
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
532

533 534 535 536 537 538 539 540
    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,
541 542
};

543 544 545 546
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 已提交
547
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
548 549 550 551

    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST,
};

552
enum virDomainChrType {
553 554 555 556 557 558 559 560 561 562
    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,
563
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
564 565 566 567 568 569 570

    VIR_DOMAIN_CHR_TYPE_LAST,
};

enum virDomainChrTcpProtocol {
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW,
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
571 572
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
573 574 575 576

    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST,
};

E
Eric Blake 已提交
577 578 579
enum virDomainChrSpicevmcName {
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
580
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
581 582 583 584

    VIR_DOMAIN_CHR_SPICEVMC_LAST,
};

585 586 587 588 589
/* The host side information for a character device.  */
typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;
struct _virDomainChrSourceDef {
    int type; /* virDomainChrType */
590
    union {
E
Eric Blake 已提交
591
        /* no <source> for null, vc, stdio */
592 593 594 595 596 597
        struct {
            char *path;
        } file; /* pty, file, pipe, or device */
        struct {
            char *host;
            char *service;
598
            bool listen;
599 600 601 602 603 604 605 606 607 608
            int protocol;
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
609
            bool listen;
610
        } nix;
E
Eric Blake 已提交
611
        int spicevmc;
612
    } data;
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
};

/* 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;
628 629

    virDomainDeviceInfo info;
630 631
};

E
Eric Blake 已提交
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658
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;
};

M
Marc-André Lureau 已提交
659 660 661 662 663 664 665
typedef struct _virDomainHubDef virDomainHubDef;
typedef virDomainHubDef *virDomainHubDefPtr;
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685
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;
686
    virDomainDeviceInfo info;
687 688 689 690 691 692
};

enum virDomainSoundModel {
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
693
    VIR_DOMAIN_SOUND_MODEL_AC97,
694
    VIR_DOMAIN_SOUND_MODEL_ICH6,
695 696 697 698 699 700 701 702

    VIR_DOMAIN_SOUND_MODEL_LAST
};

typedef struct _virDomainSoundDef virDomainSoundDef;
typedef virDomainSoundDef *virDomainSoundDefPtr;
struct _virDomainSoundDef {
    int model;
703
    virDomainDeviceInfo info;
704 705
};

R
Richard Jones 已提交
706 707 708 709 710 711 712 713 714 715 716 717
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 已提交
718
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
719 720 721 722 723 724 725 726 727 728
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
};

typedef struct _virDomainWatchdogDef virDomainWatchdogDef;
typedef virDomainWatchdogDef *virDomainWatchdogDefPtr;
struct _virDomainWatchdogDef {
    int model;
    int action;
729
    virDomainDeviceInfo info;
R
Richard Jones 已提交
730 731
};

732 733 734 735 736 737 738

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,
739
    VIR_DOMAIN_VIDEO_TYPE_QXL,
740 741 742 743 744

    VIR_DOMAIN_VIDEO_TYPE_LAST
};


745 746 747
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
748 749
    unsigned int support3d :1;
    unsigned int support2d :1;
750 751 752
};


753 754 755 756 757 758
typedef struct _virDomainVideoDef virDomainVideoDef;
typedef virDomainVideoDef *virDomainVideoDefPtr;
struct _virDomainVideoDef {
    int type;
    unsigned int vram;
    unsigned int heads;
759
    virDomainVideoAccelDefPtr accel;
760
    virDomainDeviceInfo info;
761 762
};

763 764 765 766
/* 3 possible graphics console modes */
enum virDomainGraphicsType {
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
767 768
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
769
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
770 771 772 773

    VIR_DOMAIN_GRAPHICS_TYPE_LAST,
};

774 775 776 777 778 779 780 781 782
enum virDomainGraphicsAuthConnectedType {
    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_FAIL,
    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_DISCONNECT,
    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_KEEP,

    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_LAST
};

783 784 785 786 787 788
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 */
789
    int connected; /* action if connected */
790 791
};

792 793 794 795 796 797 798
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 已提交
799
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
800 801 802 803 804 805 806 807 808 809 810

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

812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
enum virDomainGraphicsSpiceImageCompression {
    VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_GLZ,
    VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ,
    VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_QUIC,
    VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_GLZ,
    VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LZ,
    VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_OFF,

    VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST
};

enum virDomainGraphicsSpiceJpegCompression {
    VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_AUTO,
    VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_NEVER,
    VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_ALWAYS,

    VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST
};

enum virDomainGraphicsSpiceZlibCompression {
    VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_AUTO,
    VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_NEVER,
    VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_ALWAYS,

    VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST
};

enum virDomainGraphicsSpicePlaybackCompression {
    VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_ON,
    VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_OFF,

    VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST
};

850 851 852 853 854 855 856 857 858
enum virDomainGraphicsSpiceStreamingMode {
    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_FILTER,
    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_ALL,
    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_OFF,

    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST
};

859 860 861 862 863 864 865 866
enum virDomainGraphicsSpiceClipboardCopypaste {
    VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_YES,
    VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_NO,

    VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_LAST
};

867 868 869 870 871 872 873 874
enum virDomainGraphicsListenType {
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,

    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST,
};

M
Marc-André Lureau 已提交
875 876 877 878 879 880
enum virDomainHubType {
    VIR_DOMAIN_HUB_TYPE_USB,

    VIR_DOMAIN_HUB_TYPE_LAST,
};

881 882 883 884 885 886 887 888
typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef;
typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr;
struct _virDomainGraphicsListenDef {
    int type;   /* enum virDomainGraphicsListenType */
    char *address;
    char *network;
};

889 890 891 892 893 894 895
typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;
struct _virDomainGraphicsDef {
    int type;
    union {
        struct {
            int port;
896
            unsigned int autoport :1;
897
            char *keymap;
898
            char *socket;
899
            virDomainGraphicsAuthDef auth;
900 901 902 903
        } vnc;
        struct {
            char *display;
            char *xauth;
904
            int fullscreen;
905
        } sdl;
906 907
        struct {
            int port;
908 909 910
            unsigned int autoport :1;
            unsigned int replaceUser :1;
            unsigned int multiUser :1;
911 912 913
        } rdp;
        struct {
            char *display;
914
            unsigned int fullscreen :1;
915
        } desktop;
916 917 918 919
        struct {
            int port;
            int tlsPort;
            char *keymap;
920
            virDomainGraphicsAuthDef auth;
921
            unsigned int autoport :1;
922
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
923 924 925 926
            int image;
            int jpeg;
            int zlib;
            int playback;
927
            int streaming;
928
            int copypaste;
929
        } spice;
930
    } data;
931 932 933 934 935
    /* nListens, listens, and *port are only useful if type is vnc,
     * rdp, or spice. They've been extracted from the union only to
     * simplify parsing code.*/
    size_t nListens;
    virDomainGraphicsListenDefPtr listens;
936 937
};

938 939 940
enum virDomainHostdevMode {
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
941

942 943 944 945 946 947 948 949 950 951 952 953 954 955
    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 */
956
    unsigned int managed : 1;
957 958 959 960 961 962 963 964 965 966 967
    union {
        struct {
            int type; /* enum virDomainHostdevBusType */
            union {
                struct {
                    unsigned bus;
                    unsigned device;

                    unsigned vendor;
                    unsigned product;
                } usb;
968
                virDomainDevicePCIAddress pci; /* host address */
969
            } u;
970 971 972 973 974
        } subsys;
        struct {
            /* TBD: struct capabilities see:
             * https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
             */
975
            int dummy;
976 977
        } caps;
    } source;
978
    int bootIndex;
979
    virDomainDeviceInfo info; /* Guest address */
980
};
981

982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
enum virDomainRedirdevBus {
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
};

typedef struct _virDomainRedirdevDef virDomainRedirdevDef;
typedef virDomainRedirdevDef *virDomainRedirdevDefPtr;
struct _virDomainRedirdevDef {
    int bus; /* enum virDomainRedirdevBus */

    union {
        virDomainChrSourceDef chr;
    } source;

    virDomainDeviceInfo info; /* Guest address */
};
999 1000 1001 1002

enum {
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1003
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
};

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


1016 1017 1018 1019 1020 1021 1022 1023 1024
enum virDomainSmbiosMode {
    VIR_DOMAIN_SMBIOS_NONE,
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
};

1025 1026 1027
/* Flags for the 'type' field in next struct */
enum virDomainDeviceType {
    VIR_DOMAIN_DEVICE_DISK,
1028
    VIR_DOMAIN_DEVICE_LEASE,
1029
    VIR_DOMAIN_DEVICE_FS,
1030 1031 1032
    VIR_DOMAIN_DEVICE_NET,
    VIR_DOMAIN_DEVICE_INPUT,
    VIR_DOMAIN_DEVICE_SOUND,
1033
    VIR_DOMAIN_DEVICE_VIDEO,
1034
    VIR_DOMAIN_DEVICE_HOSTDEV,
R
Richard Jones 已提交
1035
    VIR_DOMAIN_DEVICE_WATCHDOG,
1036
    VIR_DOMAIN_DEVICE_CONTROLLER,
1037
    VIR_DOMAIN_DEVICE_GRAPHICS,
M
Marc-André Lureau 已提交
1038
    VIR_DOMAIN_DEVICE_HUB,
1039
    VIR_DOMAIN_DEVICE_REDIRDEV,
1040 1041

    VIR_DOMAIN_DEVICE_LAST,
1042 1043 1044 1045 1046 1047 1048 1049
};

typedef struct _virDomainDeviceDef virDomainDeviceDef;
typedef virDomainDeviceDef *virDomainDeviceDefPtr;
struct _virDomainDeviceDef {
    int type;
    union {
        virDomainDiskDefPtr disk;
1050
        virDomainControllerDefPtr controller;
1051
        virDomainLeaseDefPtr lease;
1052
        virDomainFSDefPtr fs;
1053 1054 1055
        virDomainNetDefPtr net;
        virDomainInputDefPtr input;
        virDomainSoundDefPtr sound;
1056
        virDomainVideoDefPtr video;
1057
        virDomainHostdevDefPtr hostdev;
R
Richard Jones 已提交
1058
        virDomainWatchdogDefPtr watchdog;
1059
        virDomainGraphicsDefPtr graphics;
M
Marc-André Lureau 已提交
1060
        virDomainHubDefPtr hub;
1061
        virDomainRedirdevDefPtr redirdev;
1062 1063 1064 1065
    } data;
};


1066
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076

enum virDomainBootOrder {
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

    VIR_DOMAIN_BOOT_LAST,
};

1077 1078 1079 1080 1081 1082
enum virDomainBootMenu {
    VIR_DOMAIN_BOOT_MENU_DEFAULT = 0,
    VIR_DOMAIN_BOOT_MENU_ENABLED,
    VIR_DOMAIN_BOOT_MENU_DISABLED,
};

1083 1084 1085 1086
enum virDomainFeature {
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1087
    VIR_DOMAIN_FEATURE_HAP,
1088
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101

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

1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
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
};

M
Michal Privoznik 已提交
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124
enum virDomainBIOSUseserial {
    VIR_DOMAIN_BIOS_USESERIAL_DEFAULT = 0,
    VIR_DOMAIN_BIOS_USESERIAL_YES,
    VIR_DOMAIN_BIOS_USESERIAL_NO
};

typedef struct _virDomainBIOSDef virDomainBIOSDef;
typedef virDomainBIOSDef *virDomainBIOSDefPtr;
struct _virDomainBIOSDef {
    int useserial;
};

1125 1126 1127 1128 1129 1130 1131 1132 1133
/* 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];
1134
    int bootmenu;
1135
    char *init;
1136 1137 1138 1139 1140 1141 1142
    char *kernel;
    char *initrd;
    char *cmdline;
    char *root;
    char *loader;
    char *bootloader;
    char *bootloaderArgs;
1143
    int smbios_mode;
M
Michal Privoznik 已提交
1144
    virDomainBIOSDef bios;
1145 1146
};

1147 1148 1149 1150 1151 1152 1153
enum virDomainSeclabelType {
    VIR_DOMAIN_SECLABEL_DYNAMIC,
    VIR_DOMAIN_SECLABEL_STATIC,

    VIR_DOMAIN_SECLABEL_LAST,
};

1154 1155 1156 1157 1158 1159 1160
/* 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 */
1161
    char *baselabel;    /* base name of label string */
1162
    int type;           /* virDomainSeclabelType */
1163
    bool norelabel;
1164 1165
};

1166 1167 1168 1169 1170 1171 1172 1173 1174 1175
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,
};

1176 1177 1178 1179
enum virDomainTimerTrackType {
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1180

1181
    VIR_DOMAIN_TIMER_TRACK_LAST,
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
};

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,
1198
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
1199 1200 1201 1202

    VIR_DOMAIN_TIMER_MODE_LAST,
};

1203 1204 1205 1206 1207 1208 1209 1210
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

1211 1212 1213 1214 1215 1216 1217
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 */

1218 1219 1220 1221
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
1222 1223 1224 1225 1226 1227

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

1228 1229 1230
enum virDomainClockOffsetType {
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
1231
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
1232
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
1233 1234 1235 1236 1237 1238 1239 1240

    VIR_DOMAIN_CLOCK_OFFSET_LAST,
};

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

1242 1243 1244 1245 1246 1247 1248 1249 1250
    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;
1251 1252 1253

    int ntimers;
    virDomainTimerDefPtr *timers;
1254 1255
};

1256
# define VIR_DOMAIN_CPUMASK_LEN 1024
1257

E
Eric Blake 已提交
1258 1259 1260
typedef struct _virDomainVcpuPinDef virDomainVcpuPinDef;
typedef virDomainVcpuPinDef *virDomainVcpuPinDefPtr;
struct _virDomainVcpuPinDef {
1261 1262 1263 1264
    int vcpuid;
    char *cpumask;
};

E
Eric Blake 已提交
1265
int virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def,
1266 1267 1268
                                int nvcpupin,
                                int vcpu);

E
Eric Blake 已提交
1269
virDomainVcpuPinDefPtr virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
1270 1271 1272
                                                  int nvcpupin,
                                                  int vcpu);

1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291
enum virDomainNumatuneMemMode {
    VIR_DOMAIN_NUMATUNE_MEM_STRICT,
    VIR_DOMAIN_NUMATUNE_MEM_PREFERRED,
    VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE,

    VIR_DOMAIN_NUMATUNE_MEM_LAST
};

typedef struct _virDomainNumatuneDef virDomainNumatuneDef;
typedef virDomainNumatuneDef *virDomainNumatuneDefPtr;
struct _virDomainNumatuneDef {
    struct {
        char *nodemask;
        int mode;
    } memory;

    /* Future NUMA tuning related stuff should go here. */
};

1292 1293 1294 1295 1296 1297
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
1298 1299 1300 1301 1302 1303 1304
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
struct _virDomainDef {
    int virtType;
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
    char *name;
1305
    char *description;
1306

1307 1308 1309 1310
    struct {
        unsigned int weight;
    } blkio;

1311 1312 1313 1314 1315 1316 1317 1318 1319
    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 已提交
1320 1321
    unsigned short vcpus;
    unsigned short maxvcpus;
1322 1323 1324
    int cpumasklen;
    char *cpumask;

1325 1326
    struct {
        unsigned long shares;
1327 1328
        unsigned long long period;
        long long quota;
1329
        int nvcpupin;
E
Eric Blake 已提交
1330
        virDomainVcpuPinDefPtr *vcpupin;
1331 1332
    } cputune;

1333 1334
    virDomainNumatuneDef numatune;

1335 1336 1337 1338 1339 1340 1341 1342 1343
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

    virDomainOSDef os;
    char *emulator;
    int features;

1344
    virDomainClockDef clock;
1345

1346 1347
    int ngraphics;
    virDomainGraphicsDefPtr *graphics;
1348 1349 1350 1351

    int ndisks;
    virDomainDiskDefPtr *disks;

1352 1353 1354
    int ncontrollers;
    virDomainControllerDefPtr *controllers;

1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366
    int nfss;
    virDomainFSDefPtr *fss;

    int nnets;
    virDomainNetDefPtr *nets;

    int ninputs;
    virDomainInputDefPtr *inputs;

    int nsounds;
    virDomainSoundDefPtr *sounds;

1367 1368 1369
    int nvideos;
    virDomainVideoDefPtr *videos;

1370 1371 1372
    int nhostdevs;
    virDomainHostdevDefPtr *hostdevs;

1373 1374 1375
    int nredirdevs;
    virDomainRedirdevDefPtr *redirdevs;

E
Eric Blake 已提交
1376 1377 1378
    int nsmartcards;
    virDomainSmartcardDefPtr *smartcards;

1379 1380 1381 1382 1383 1384
    int nserials;
    virDomainChrDefPtr *serials;

    int nparallels;
    virDomainChrDefPtr *parallels;

1385 1386 1387
    int nchannels;
    virDomainChrDefPtr *channels;

1388
    size_t nleases;
1389 1390
    virDomainLeaseDefPtr *leases;

M
Marc-André Lureau 已提交
1391 1392 1393
    int nhubs;
    virDomainHubDefPtr *hubs;

1394
    /* Only 1 */
1395
    virDomainChrDefPtr console;
1396
    virSecurityLabelDef seclabel;
R
Richard Jones 已提交
1397
    virDomainWatchdogDefPtr watchdog;
1398
    virDomainMemballoonDefPtr memballoon;
1399
    virCPUDefPtr cpu;
1400
    virSysinfoDefPtr sysinfo;
1401 1402 1403

    void *namespaceData;
    virDomainXMLNamespace ns;
1404 1405
};

1406 1407 1408 1409 1410 1411
enum virDomainTaintFlags {
    VIR_DOMAIN_TAINT_CUSTOM_ARGV,      /* Custom ARGV passthrough from XML */
    VIR_DOMAIN_TAINT_CUSTOM_MONITOR,   /* Custom monitor commands issued */
    VIR_DOMAIN_TAINT_HIGH_PRIVILEGES,  /* Running with undesirably high privileges */
    VIR_DOMAIN_TAINT_SHELL_SCRIPTS,    /* Network configuration using opaque shell scripts */
    VIR_DOMAIN_TAINT_DISK_PROBING,     /* Relying on potentially unsafe disk format probing */
1412
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
1413 1414 1415 1416

    VIR_DOMAIN_TAINT_LAST
};

1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430
/* Items related to snapshot state */

/* Stores disk-snapshot information */
typedef struct _virDomainSnapshotDiskDef virDomainSnapshotDiskDef;
typedef virDomainSnapshotDiskDef *virDomainSnapshotDiskDefPtr;
struct _virDomainSnapshotDiskDef {
    char *name; /* name matching the <target dev='...' of the domain */
    int index; /* index within snapshot->dom->disks that matches name */
    int snapshot; /* enum virDomainDiskSnapshot */
    char *file; /* new source file when snapshot is external */
    char *driverType; /* file format type of new file */
};

/* Stores the complete snapshot metadata */
1431 1432 1433
typedef struct _virDomainSnapshotDef virDomainSnapshotDef;
typedef virDomainSnapshotDef *virDomainSnapshotDefPtr;
struct _virDomainSnapshotDef {
1434
    /* Public XML.  */
1435 1436 1437 1438
    char *name;
    char *description;
    char *parent;
    long long creationTime; /* in seconds */
1439
    int state; /* enum virDomainSnapshotState */
1440 1441 1442 1443

    size_t ndisks; /* should not exceed dom->ndisks */
    virDomainSnapshotDiskDef *disks;

1444
    virDomainDefPtr dom;
1445

1446 1447
    /* Internal use.  */
    bool current; /* At most one snapshot in the list should have this set */
1448 1449 1450 1451 1452 1453
};

typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;
struct _virDomainSnapshotObj {
    virDomainSnapshotDefPtr def;
1454 1455 1456

    /* Internal use only */
    int mark; /* Used in identifying descendents. */
1457 1458 1459 1460 1461 1462 1463 1464 1465 1466
};

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

1467 1468
typedef enum {
    VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE = 1 << 0,
1469 1470
    VIR_DOMAIN_SNAPSHOT_PARSE_DISKS    = 1 << 1,
    VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL = 1 << 2,
1471 1472
} virDomainSnapshotParseFlags;

1473
virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
1474 1475
                                                        virCapsPtr caps,
                                                        unsigned int expectedVirtTypes,
1476
                                                        unsigned int flags);
1477 1478 1479
void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
char *virDomainSnapshotDefFormat(char *domain_uuid,
                                 virDomainSnapshotDefPtr def,
1480
                                 unsigned int flags,
1481
                                 int internal);
1482 1483 1484
int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
                                int default_snapshot,
                                bool require_match);
1485 1486 1487 1488 1489
virDomainSnapshotObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr snapshots,
                                                   const virDomainSnapshotDefPtr def);

int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr objs);
int virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots,
1490 1491 1492 1493
                                     char **const names, int maxnames,
                                     unsigned int flags);
int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr snapshots,
                                unsigned int flags);
1494 1495 1496 1497 1498 1499
virDomainSnapshotObjPtr virDomainSnapshotFindByName(const virDomainSnapshotObjListPtr snapshots,
                                                    const char *name);
void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
                                    virDomainSnapshotObjPtr snapshot);
int virDomainSnapshotHasChildren(virDomainSnapshotObjPtr snap,
                                virDomainSnapshotObjListPtr snapshots);
1500 1501 1502 1503
int virDomainSnapshotForEachChild(virDomainSnapshotObjListPtr snapshots,
                                  virDomainSnapshotObjPtr snapshot,
                                  virHashIterator iter,
                                  void *data);
1504 1505 1506 1507
int virDomainSnapshotForEachDescendant(virDomainSnapshotObjListPtr snapshots,
                                       virDomainSnapshotObjPtr snapshot,
                                       virHashIterator iter,
                                       void *data);
1508

1509
/* Guest VM runtime state */
J
Jiri Denemark 已提交
1510 1511 1512 1513 1514 1515
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

1516 1517 1518
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
1519
    virMutex lock;
1520
    int refs;
1521

1522
    int pid;
J
Jiri Denemark 已提交
1523
    virDomainStateReason state;
1524 1525 1526

    unsigned int autostart : 1;
    unsigned int persistent : 1;
1527
    unsigned int updated : 1;
1528 1529 1530

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

C
Chris Lalancette 已提交
1532 1533 1534
    virDomainSnapshotObjList snapshots;
    virDomainSnapshotObjPtr current_snapshot;

1535 1536
    void *privateData;
    void (*privateDataFreeFunc)(void *);
1537 1538

    int taint;
1539 1540
};

1541 1542 1543
typedef struct _virDomainObjList virDomainObjList;
typedef virDomainObjList *virDomainObjListPtr;
struct _virDomainObjList {
1544 1545 1546
    /* uuid string -> virDomainObj  mapping
     * for O(1), lockless lookup-by-uuid */
    virHashTable *objs;
1547
};
1548

1549
static inline bool
D
Daniel P. Berrange 已提交
1550
virDomainObjIsActive(virDomainObjPtr dom)
1551 1552 1553 1554
{
    return dom->def->id != -1;
}

1555

1556 1557
int virDomainObjListInit(virDomainObjListPtr objs);
void virDomainObjListDeinit(virDomainObjListPtr objs);
1558

1559
virDomainObjPtr virDomainFindByID(const virDomainObjListPtr doms,
1560
                                  int id);
1561
virDomainObjPtr virDomainFindByUUID(const virDomainObjListPtr doms,
1562
                                    const unsigned char *uuid);
1563
virDomainObjPtr virDomainFindByName(const virDomainObjListPtr doms,
1564 1565
                                    const char *name);

1566 1567
bool virDomainObjTaint(virDomainObjPtr obj,
                       enum virDomainTaintFlags taint);
1568 1569 1570 1571

void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
void virDomainDiskDefFree(virDomainDiskDefPtr def);
1572
void virDomainDiskHostDefFree(virDomainDiskHostDefPtr def);
1573
void virDomainControllerDefFree(virDomainControllerDefPtr def);
1574
void virDomainFSDefFree(virDomainFSDefPtr def);
1575
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
1576
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
1577
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
1578
void virDomainChrDefFree(virDomainChrDefPtr def);
1579
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
1580
void virDomainSoundDefFree(virDomainSoundDefPtr def);
1581
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
R
Richard Jones 已提交
1582
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
1583
void virDomainVideoDefFree(virDomainVideoDefPtr def);
1584
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
1585
void virDomainHubDefFree(virDomainHubDefPtr def);
1586
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
1587
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
1588 1589 1590
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                  int type);
int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
1591
int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr);
1592
int virDomainDeviceVirtioSerialAddressIsValid(virDomainDeviceVirtioSerialAddressPtr addr);
1593
int virDomainDeviceUSBAddressIsValid(virDomainDeviceUSBAddressPtr addr);
1594
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
1595
void virDomainDefClearPCIAddresses(virDomainDefPtr def);
D
Daniel P. Berrange 已提交
1596
void virDomainDefClearDeviceAliases(virDomainDefPtr def);
1597

1598 1599 1600 1601 1602 1603 1604 1605
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
                                           virDomainDeviceInfoPtr dev,
                                           void *opaque);

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

1606
void virDomainDefFree(virDomainDefPtr vm);
1607 1608
void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
1609
int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK;
1610

M
Michal Novotny 已提交
1611 1612
virDomainChrDefPtr virDomainChrDefNew(void);

1613 1614
/* live == true means def describes an active domain (being migrated or
 * restored) as opposed to a new persistent configuration of the domain */
1615
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
1616
                                   virDomainObjListPtr doms,
1617 1618
                                   const virDomainDefPtr def,
                                   bool live);
1619 1620 1621
void virDomainObjAssignDef(virDomainObjPtr domain,
                           const virDomainDefPtr def,
                           bool live);
1622
int virDomainObjSetDefTransient(virCapsPtr caps,
1623 1624
                                virDomainObjPtr domain,
                                bool live);
1625 1626 1627
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
                             virDomainObjPtr domain);
1628 1629 1630
virDomainDefPtr
virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom);

1631
void virDomainRemoveInactive(virDomainObjListPtr doms,
1632 1633
                             virDomainObjPtr dom);

1634
virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
1635
                                              const virDomainDefPtr def,
1636
                                              const char *xmlStr,
L
Laine Stump 已提交
1637
                                              unsigned int flags);
1638
virDomainDefPtr virDomainDefParseString(virCapsPtr caps,
1639
                                        const char *xmlStr,
M
Matthias Bolte 已提交
1640
                                        unsigned int expectedVirtTypes,
L
Laine Stump 已提交
1641
                                        unsigned int flags);
1642
virDomainDefPtr virDomainDefParseFile(virCapsPtr caps,
1643
                                      const char *filename,
M
Matthias Bolte 已提交
1644
                                      unsigned int expectedVirtTypes,
L
Laine Stump 已提交
1645
                                      unsigned int flags);
1646
virDomainDefPtr virDomainDefParseNode(virCapsPtr caps,
1647
                                      xmlDocPtr doc,
1648
                                      xmlNodePtr root,
M
Matthias Bolte 已提交
1649
                                      unsigned int expectedVirtTypes,
L
Laine Stump 已提交
1650
                                      unsigned int flags);
1651

1652 1653 1654
bool virDomainDefCheckABIStability(virDomainDefPtr src,
                                   virDomainDefPtr dst);

1655
int virDomainDefAddImplicitControllers(virDomainDefPtr def);
1656

1657
char *virDomainDefFormat(virDomainDefPtr def,
L
Laine Stump 已提交
1658
                         unsigned int flags);
1659

1660
int virDomainCpuSetParse(const char **str,
1661 1662 1663
                         char sep,
                         char *cpuset,
                         int maxcpu);
1664
char *virDomainCpuSetFormat(char *cpuset,
1665 1666
                            int maxcpu);

E
Eric Blake 已提交
1667
int virDomainVcpuPinAdd(virDomainDefPtr def,
1668 1669 1670 1671
                        unsigned char *cpumap,
                        int maplen,
                        int vcpu);

E
Eric Blake 已提交
1672
int virDomainVcpuPinDel(virDomainDefPtr def, int vcpu);
1673

1674 1675 1676
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
1677 1678 1679 1680
int virDomainDiskInsert(virDomainDefPtr def,
                        virDomainDiskDefPtr disk);
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
1681
int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def);
1682

1683
void virDomainDiskRemove(virDomainDefPtr def, size_t i);
1684
int virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
1685

1686 1687 1688 1689
int virDomainNetIndexByMac(virDomainDefPtr def, const unsigned char *mac);
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
int virDomainNetRemoveByMac(virDomainDefPtr def, const unsigned char *mac);

1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707
int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t ii)
            ATTRIBUTE_NONNULL(1);
int virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t ii, int val)
            ATTRIBUTE_NONNULL(1);
const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
                                              size_t ii)
            ATTRIBUTE_NONNULL(1);
int virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
                                      size_t ii, const char *address,
                                      int len, bool setType)
            ATTRIBUTE_NONNULL(1);
const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def,
                                              size_t ii)
            ATTRIBUTE_NONNULL(1);
int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
                                      size_t ii, const char *network, int len)
            ATTRIBUTE_NONNULL(1);

1708 1709 1710 1711 1712 1713
int virDomainNetGetActualType(virDomainNetDefPtr iface);
char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
virVirtualPortProfileParamsPtr
virDomainNetGetActualDirectVirtPortProfile(virDomainNetDefPtr iface);
1714 1715
virBandwidthPtr
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
1716

1717 1718 1719 1720 1721
int virDomainControllerInsert(virDomainDefPtr def,
                              virDomainControllerDefPtr controller);
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);

1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def);
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
void virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
int virDomainLeaseRemove(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);

1734
int virDomainSaveXML(const char *configDir,
1735 1736 1737
                     virDomainDefPtr def,
                     const char *xml);

1738
int virDomainSaveConfig(const char *configDir,
1739
                        virDomainDefPtr def);
1740
int virDomainSaveStatus(virCapsPtr caps,
1741
                        const char *statusDir,
1742
                        virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
1743

1744 1745 1746 1747
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

1748
int virDomainLoadAllConfigs(virCapsPtr caps,
1749
                            virDomainObjListPtr doms,
1750
                            const char *configDir,
1751
                            const char *autostartDir,
1752
                            int liveStatus,
M
Matthias Bolte 已提交
1753
                            unsigned int expectedVirtTypes,
1754 1755
                            virDomainLoadConfigNotify notify,
                            void *opaque);
1756

1757
int virDomainDeleteConfig(const char *configDir,
1758
                          const char *autostartDir,
1759 1760
                          virDomainObjPtr dom);

1761
char *virDomainConfigFile(const char *dir,
1762 1763
                          const char *name);

1764 1765 1766 1767
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

1768
virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def);
1769 1770
int virDomainVideoDefaultType(virDomainDefPtr def);
int virDomainVideoDefaultRAM(virDomainDefPtr def, int type);
1771

1772 1773 1774 1775
int virDomainObjIsDuplicate(virDomainObjListPtr doms,
                            virDomainDefPtr def,
                            unsigned int check_active);

D
Daniel P. Berrange 已提交
1776 1777
void virDomainObjLock(virDomainObjPtr obj);
void virDomainObjUnlock(virDomainObjPtr obj);
1778

1779 1780 1781 1782 1783 1784 1785 1786 1787
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 已提交
1788 1789 1790 1791 1792 1793 1794 1795 1796
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

1797 1798 1799 1800 1801 1802 1803 1804 1805
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816
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);

J
Jiri Denemark 已提交
1817 1818 1819 1820 1821 1822 1823
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

1824 1825 1826
typedef const char* (*virLifecycleToStringFunc)(int type);
typedef int (*virLifecycleFromStringFunc)(const char *type);

1827 1828
VIR_ENUM_DECL(virDomainTaint)

1829 1830 1831 1832
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
VIR_ENUM_DECL(virDomainFeature)
VIR_ENUM_DECL(virDomainLifecycle)
1833
VIR_ENUM_DECL(virDomainLifecycleCrash)
1834
VIR_ENUM_DECL(virDomainDevice)
1835
VIR_ENUM_DECL(virDomainDeviceAddress)
1836
VIR_ENUM_DECL(virDomainDeviceAddressPciMulti)
1837 1838 1839
VIR_ENUM_DECL(virDomainDisk)
VIR_ENUM_DECL(virDomainDiskDevice)
VIR_ENUM_DECL(virDomainDiskBus)
1840
VIR_ENUM_DECL(virDomainDiskCache)
1841
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
M
MORITA Kazutaka 已提交
1842
VIR_ENUM_DECL(virDomainDiskProtocol)
M
Matthias Dahl 已提交
1843
VIR_ENUM_DECL(virDomainDiskIo)
1844
VIR_ENUM_DECL(virDomainDiskSnapshot)
1845
VIR_ENUM_DECL(virDomainIoEventFd)
1846
VIR_ENUM_DECL(virDomainVirtioEventIdx)
1847
VIR_ENUM_DECL(virDomainController)
1848
VIR_ENUM_DECL(virDomainControllerModelSCSI)
M
Marc-André Lureau 已提交
1849
VIR_ENUM_DECL(virDomainControllerModelUSB)
1850
VIR_ENUM_DECL(virDomainFS)
1851
VIR_ENUM_DECL(virDomainFSAccessMode)
1852
VIR_ENUM_DECL(virDomainNet)
1853
VIR_ENUM_DECL(virDomainNetBackend)
1854
VIR_ENUM_DECL(virDomainNetVirtioTxMode)
1855
VIR_ENUM_DECL(virDomainNetInterfaceLinkState)
1856
VIR_ENUM_DECL(virDomainChrDevice)
1857
VIR_ENUM_DECL(virDomainChrChannelTarget)
1858
VIR_ENUM_DECL(virDomainChrConsoleTarget)
E
Eric Blake 已提交
1859
VIR_ENUM_DECL(virDomainSmartcard)
1860
VIR_ENUM_DECL(virDomainChr)
1861
VIR_ENUM_DECL(virDomainChrTcpProtocol)
E
Eric Blake 已提交
1862
VIR_ENUM_DECL(virDomainChrSpicevmc)
1863
VIR_ENUM_DECL(virDomainSoundModel)
1864
VIR_ENUM_DECL(virDomainMemballoonModel)
1865
VIR_ENUM_DECL(virDomainSmbiosMode)
R
Richard Jones 已提交
1866 1867
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
1868
VIR_ENUM_DECL(virDomainVideo)
1869 1870
VIR_ENUM_DECL(virDomainHostdevMode)
VIR_ENUM_DECL(virDomainHostdevSubsys)
M
Marc-André Lureau 已提交
1871
VIR_ENUM_DECL(virDomainHub)
1872
VIR_ENUM_DECL(virDomainRedirdevBus)
1873 1874 1875
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
1876
VIR_ENUM_DECL(virDomainGraphicsListen)
1877
VIR_ENUM_DECL(virDomainGraphicsAuthConnected)
1878 1879
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
1880 1881 1882 1883
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression)
1884
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
1885
VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste)
1886
VIR_ENUM_DECL(virDomainNumatuneMemMode)
1887
VIR_ENUM_DECL(virDomainSnapshotState)
1888 1889
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
J
Jiri Denemark 已提交
1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900
VIR_ENUM_DECL(virDomainNostateReason)
VIR_ENUM_DECL(virDomainRunningReason)
VIR_ENUM_DECL(virDomainBlockedReason)
VIR_ENUM_DECL(virDomainPausedReason)
VIR_ENUM_DECL(virDomainShutdownReason)
VIR_ENUM_DECL(virDomainShutoffReason)
VIR_ENUM_DECL(virDomainCrashedReason)

const char *virDomainStateReasonToString(virDomainState state, int reason);
int virDomainStateReasonFromString(virDomainState state, const char *reason);

1901
VIR_ENUM_DECL(virDomainSeclabel)
1902
VIR_ENUM_DECL(virDomainClockOffset)
1903

1904
VIR_ENUM_DECL(virDomainTimerName)
1905
VIR_ENUM_DECL(virDomainTimerTrack)
1906 1907 1908
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)

1909
#endif /* __DOMAIN_CONF_H */