domain_conf.h 68.5 KB
Newer Older
1 2 3
/*
 * domain_conf.h: domain XML processing
 *
E
Eric Blake 已提交
4
 * Copyright (C) 2006-2012 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
# include "internal.h"
# include "capabilities.h"
# include "storage_encryption_conf.h"
# include "cpu_conf.h"
# include "util.h"
# include "threads.h"
37
# include "virhash.h"
38
# include "virsocketaddr.h"
39 40
# include "nwfilter_params.h"
# include "nwfilter_conf.h"
41
# include "virnetdevmacvlan.h"
42
# include "sysinfo.h"
43
# include "virnetdevvportprofile.h"
A
Ansis Atteka 已提交
44
# include "virnetdevopenvswitch.h"
45
# include "virnetdevbandwidth.h"
46

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/* forward declarations of all device types, required by
 * virDomainDeviceDef
 */
typedef struct _virDomainDiskDef virDomainDiskDef;
typedef virDomainDiskDef *virDomainDiskDefPtr;

typedef struct _virDomainControllerDef virDomainControllerDef;
typedef virDomainControllerDef *virDomainControllerDefPtr;

typedef struct _virDomainLeaseDef virDomainLeaseDef;
typedef virDomainLeaseDef *virDomainLeaseDefPtr;

typedef struct _virDomainFSDef virDomainFSDef;
typedef virDomainFSDef *virDomainFSDefPtr;

typedef struct _virDomainNetDef virDomainNetDef;
typedef virDomainNetDef *virDomainNetDefPtr;

typedef struct _virDomainInputDef virDomainInputDef;
typedef virDomainInputDef *virDomainInputDefPtr;

68 69 70
typedef struct _virDomainSoundCodecDef virDomainSoundCodecDef;
typedef virDomainSoundCodecDef *virDomainSoundCodecDefPtr;

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
typedef struct _virDomainSoundDef virDomainSoundDef;
typedef virDomainSoundDef *virDomainSoundDefPtr;

typedef struct _virDomainVideoDef virDomainVideoDef;
typedef virDomainVideoDef *virDomainVideoDefPtr;

typedef struct _virDomainHostdevDef virDomainHostdevDef;
typedef virDomainHostdevDef *virDomainHostdevDefPtr;

typedef struct _virDomainWatchdogDef virDomainWatchdogDef;
typedef virDomainWatchdogDef *virDomainWatchdogDefPtr;

typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;

typedef struct _virDomainHubDef virDomainHubDef;
typedef virDomainHubDef *virDomainHubDefPtr;

typedef struct _virDomainRedirdevDef virDomainRedirdevDef;
typedef virDomainRedirdevDef *virDomainRedirdevDefPtr;

typedef struct _virDomainSmartcardDef virDomainSmartcardDef;
typedef virDomainSmartcardDef *virDomainSmartcardDefPtr;

typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr;

typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;

/* Flags for the 'type' field in virDomainDeviceDef */
typedef enum {
    VIR_DOMAIN_DEVICE_NONE = 0,
    VIR_DOMAIN_DEVICE_DISK,
    VIR_DOMAIN_DEVICE_LEASE,
    VIR_DOMAIN_DEVICE_FS,
    VIR_DOMAIN_DEVICE_NET,
    VIR_DOMAIN_DEVICE_INPUT,
    VIR_DOMAIN_DEVICE_SOUND,
    VIR_DOMAIN_DEVICE_VIDEO,
    VIR_DOMAIN_DEVICE_HOSTDEV,
    VIR_DOMAIN_DEVICE_WATCHDOG,
    VIR_DOMAIN_DEVICE_CONTROLLER,
    VIR_DOMAIN_DEVICE_GRAPHICS,
    VIR_DOMAIN_DEVICE_HUB,
    VIR_DOMAIN_DEVICE_REDIRDEV,
    VIR_DOMAIN_DEVICE_SMARTCARD,
    VIR_DOMAIN_DEVICE_CHR,
    VIR_DOMAIN_DEVICE_MEMBALLOON,

    VIR_DOMAIN_DEVICE_LAST,
} virDomainDeviceType;

typedef struct _virDomainDeviceDef virDomainDeviceDef;
typedef virDomainDeviceDef *virDomainDeviceDefPtr;
struct _virDomainDeviceDef {
    int type; /* enum virDomainDeviceType */
    union {
        virDomainDiskDefPtr disk;
        virDomainControllerDefPtr controller;
        virDomainLeaseDefPtr lease;
        virDomainFSDefPtr fs;
        virDomainNetDefPtr net;
        virDomainInputDefPtr input;
        virDomainSoundDefPtr sound;
        virDomainVideoDefPtr video;
        virDomainHostdevDefPtr hostdev;
        virDomainWatchdogDefPtr watchdog;
        virDomainGraphicsDefPtr graphics;
        virDomainHubDefPtr hub;
        virDomainRedirdevDefPtr redirdev;
        virDomainSmartcardDefPtr smartcard;
        virDomainChrDefPtr chr;
        virDomainMemballoonDefPtr memballoon;
    } data;
};

148 149 150 151 152 153 154 155 156 157 158 159 160
/* 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_TEST,
    VIR_DOMAIN_VIRT_VMWARE,
    VIR_DOMAIN_VIRT_HYPERV,
161
    VIR_DOMAIN_VIRT_VBOX,
162
    VIR_DOMAIN_VIRT_PHYP,
163 164 165 166

    VIR_DOMAIN_VIRT_LAST,
};

167 168 169
enum virDomainDeviceAddressType {
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
170
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
171
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
172
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
173
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB,
174
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
175 176 177 178

    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
};

179 180 181 182 183 184 185 186
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
};

187 188 189 190 191 192 193 194
enum virDomainPciRombarMode {
    VIR_DOMAIN_PCI_ROMBAR_DEFAULT = 0,
    VIR_DOMAIN_PCI_ROMBAR_ON,
    VIR_DOMAIN_PCI_ROMBAR_OFF,

    VIR_DOMAIN_PCI_ROMBAR_LAST
};

195 196 197 198 199 200 201
typedef struct _virDomainDevicePCIAddress virDomainDevicePCIAddress;
typedef virDomainDevicePCIAddress *virDomainDevicePCIAddressPtr;
struct _virDomainDevicePCIAddress {
    unsigned int domain;
    unsigned int bus;
    unsigned int slot;
    unsigned int function;
202
    int          multi;  /* enum virDomainDeviceAddressPciMulti */
203 204
};

205 206 207 208 209
typedef struct _virDomainDeviceDriveAddress virDomainDeviceDriveAddress;
typedef virDomainDeviceDriveAddress *virDomainDeviceDriveAddressPtr;
struct _virDomainDeviceDriveAddress {
    unsigned int controller;
    unsigned int bus;
210
    unsigned int target;
211 212 213
    unsigned int unit;
};

214 215 216 217 218
typedef struct _virDomainDeviceVirtioSerialAddress virDomainDeviceVirtioSerialAddress;
typedef virDomainDeviceVirtioSerialAddress *virDomainDeviceVirtioSerialAddressPtr;
struct _virDomainDeviceVirtioSerialAddress {
    unsigned int controller;
    unsigned int bus;
219
    unsigned int port;
220 221
};

E
Eric Blake 已提交
222 223 224 225 226 227 228
typedef struct _virDomainDeviceCcidAddress virDomainDeviceCcidAddress;
typedef virDomainDeviceCcidAddress *virDomainDeviceCcidAddressPtr;
struct _virDomainDeviceCcidAddress {
    unsigned int controller;
    unsigned int slot;
};

229 230 231 232
typedef struct _virDomainDeviceUSBAddress virDomainDeviceUSBAddress;
typedef virDomainDeviceUSBAddress *virDomainDeviceUSBAddressPtr;
struct _virDomainDeviceUSBAddress {
    unsigned int bus;
233
    char *port;
234 235
};

236 237 238 239 240 241 242
typedef struct _virDomainDeviceSpaprVioAddress virDomainDeviceSpaprVioAddress;
typedef virDomainDeviceSpaprVioAddress *virDomainDeviceSpaprVioAddressPtr;
struct _virDomainDeviceSpaprVioAddress {
    unsigned long long reg;
    bool has_reg;
};

243 244 245 246 247 248 249 250 251 252 253 254 255
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;
};

256 257 258
typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
struct _virDomainDeviceInfo {
259 260 261 262
    /* If adding to this struct, ensure that
     * virDomainDeviceInfoIsSet() is updated
     * to consider the new fields
     */
D
Daniel P. Berrange 已提交
263
    char *alias;
264 265 266
    int type;
    union {
        virDomainDevicePCIAddress pci;
267
        virDomainDeviceDriveAddress drive;
268
        virDomainDeviceVirtioSerialAddress vioserial;
E
Eric Blake 已提交
269
        virDomainDeviceCcidAddress ccid;
270
        virDomainDeviceUSBAddress usb;
271
        virDomainDeviceSpaprVioAddress spaprvio;
272
    } addr;
273 274 275 276
    int mastertype;
    union {
        virDomainDeviceUSBMaster usb;
    } master;
277 278
    /* rombar and romfile are only used for pci hostdev and network
     * devices. */
279
    int rombar;         /* enum virDomainPciRombarMode */
280
    char *romfile;
281 282
    /* bootIndex is only user for disk, network interface, and
     * hostdev devices. */
283
    int bootIndex;
284 285
};

E
Eric Blake 已提交
286
enum virDomainSeclabelType {
287 288
    VIR_DOMAIN_SECLABEL_DEFAULT,
    VIR_DOMAIN_SECLABEL_NONE,
E
Eric Blake 已提交
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
    VIR_DOMAIN_SECLABEL_DYNAMIC,
    VIR_DOMAIN_SECLABEL_STATIC,

    VIR_DOMAIN_SECLABEL_LAST,
};

/* 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 */
    char *baselabel;    /* base name of label string */
    int type;           /* virDomainSeclabelType */
    bool norelabel;
};

307 308 309 310 311 312 313 314 315 316

/* Security configuration for domain */
typedef struct _virSecurityDeviceLabelDef virSecurityDeviceLabelDef;
typedef virSecurityDeviceLabelDef *virSecurityDeviceLabelDefPtr;
struct _virSecurityDeviceLabelDef {
    char *label;        /* image label string */
    bool norelabel;
};


317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
typedef struct _virDomainHostdevOrigStates virDomainHostdevOrigStates;
typedef virDomainHostdevOrigStates *virDomainHostdevOrigStatesPtr;
struct _virDomainHostdevOrigStates {
    union {
        struct {
            /* Does the device need to unbind from stub when
             * reattaching to host?
             */
            unsigned int unbind_from_stub : 1;

            /* Does it need to use remove_slot when reattaching
             * the device to host?
             */
            unsigned int remove_slot : 1;

            /* Does it need to reprobe driver for the device when
             * reattaching to host?
             */
            unsigned int reprobe :1;
        } pci;

        /* Perhaps 'usb' in future */
    } states;
};

342 343 344 345 346 347 348
struct _virDomainLeaseDef {
    char *lockspace;
    char *key;
    char *path;
    unsigned long long offset;
};

349

350 351 352 353 354 355 356 357 358 359 360 361 362 363
enum virDomainHostdevMode {
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

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

364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380

typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys {
    int type; /* enum virDomainHostdevBusType */
    union {
        struct {
            unsigned bus;
            unsigned device;

            unsigned vendor;
            unsigned product;
        } usb;
        virDomainDevicePCIAddress pci; /* host address */
    } u;
};

381 382
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
383
    virDomainDeviceDef parent; /* higher level Def containing this */
384 385 386
    int mode; /* enum virDomainHostdevMode */
    unsigned int managed : 1;
    union {
387
        virDomainHostdevSubsys subsys;
388 389 390 391 392 393 394 395
        struct {
            /* TBD: struct capabilities see:
             * https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
             */
            int dummy;
        } caps;
    } source;
    virDomainHostdevOrigStates origstates;
396
    virDomainDeviceInfoPtr info; /* Guest address */
397 398
};

399 400 401 402
/* Two types of disk backends */
enum virDomainDiskType {
    VIR_DOMAIN_DISK_TYPE_BLOCK,
    VIR_DOMAIN_DISK_TYPE_FILE,
403
    VIR_DOMAIN_DISK_TYPE_DIR,
M
MORITA Kazutaka 已提交
404
    VIR_DOMAIN_DISK_TYPE_NETWORK,
405 406 407 408 409 410 411 412 413

    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,
414
    VIR_DOMAIN_DISK_DEVICE_LUN,
415 416 417 418 419 420 421 422 423 424

    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,
425
    VIR_DOMAIN_DISK_BUS_USB,
426
    VIR_DOMAIN_DISK_BUS_UML,
427
    VIR_DOMAIN_DISK_BUS_SATA,
428 429 430 431

    VIR_DOMAIN_DISK_BUS_LAST
};

432 433 434 435 436
enum  virDomainDiskCache {
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
437
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
438
    VIR_DOMAIN_DISK_CACHE_UNSAFE,
439 440 441 442

    VIR_DOMAIN_DISK_CACHE_LAST
};

443 444 445
enum  virDomainDiskErrorPolicy {
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
446
    VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
447
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
448
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
449 450 451 452

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
};

M
MORITA Kazutaka 已提交
453 454 455 456 457 458 459 460
enum virDomainDiskProtocol {
    VIR_DOMAIN_DISK_PROTOCOL_NBD,
    VIR_DOMAIN_DISK_PROTOCOL_RBD,
    VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG,

    VIR_DOMAIN_DISK_PROTOCOL_LAST
};

461 462 463 464 465 466 467
enum virDomainDiskTray {
    VIR_DOMAIN_DISK_TRAY_CLOSED,
    VIR_DOMAIN_DISK_TRAY_OPEN,

    VIR_DOMAIN_DISK_TRAY_LAST
};

M
MORITA Kazutaka 已提交
468 469 470 471 472 473 474
typedef struct _virDomainDiskHostDef virDomainDiskHostDef;
typedef virDomainDiskHostDef *virDomainDiskHostDefPtr;
struct _virDomainDiskHostDef {
    char *name;
    char *port;
};

M
Matthias Dahl 已提交
475 476 477 478 479 480 481 482
enum  virDomainDiskIo {
    VIR_DOMAIN_DISK_IO_DEFAULT,
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
};

483 484 485 486 487 488 489 490
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
};

491 492 493 494 495 496 497 498
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
};

O
Osier Yang 已提交
499 500 501 502 503 504 505 506
enum virDomainDiskCopyOnRead {
    VIR_DOMAIN_DISK_COPY_ON_READ_DEFAULT = 0,
    VIR_DOMAIN_DISK_COPY_ON_READ_ON,
    VIR_DOMAIN_DISK_COPY_ON_READ_OFF,

    VIR_DOMAIN_DISK_COPY_ON_READ_LAST
};

507 508 509 510 511 512 513 514 515
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
};

516 517 518
enum virDomainSnapshotState {
    /* Inherit the VIR_DOMAIN_* states from virDomainState.  */
    VIR_DOMAIN_DISK_SNAPSHOT = VIR_DOMAIN_LAST,
E
Eric Blake 已提交
519
    VIR_DOMAIN_SNAPSHOT_STATE_LAST
520 521
};

522 523 524 525 526 527 528 529 530
enum virDomainStartupPolicy {
    VIR_DOMAIN_STARTUP_POLICY_DEFAULT = 0,
    VIR_DOMAIN_STARTUP_POLICY_MANDATORY,
    VIR_DOMAIN_STARTUP_POLICY_REQUISITE,
    VIR_DOMAIN_STARTUP_POLICY_OPTIONAL,

    VIR_DOMAIN_STARTUP_POLICY_LAST
};

531 532 533 534 535 536 537 538
enum virDomainDiskSecretType {
    VIR_DOMAIN_DISK_SECRET_TYPE_NONE,
    VIR_DOMAIN_DISK_SECRET_TYPE_UUID,
    VIR_DOMAIN_DISK_SECRET_TYPE_USAGE,

    VIR_DOMAIN_DISK_SECRET_TYPE_LAST
};

L
Lei Li 已提交
539 540 541 542 543 544 545 546 547 548 549
typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo;
struct _virDomainBlockIoTuneInfo {
    unsigned long long total_bytes_sec;
    unsigned long long read_bytes_sec;
    unsigned long long write_bytes_sec;
    unsigned long long total_iops_sec;
    unsigned long long read_iops_sec;
    unsigned long long write_iops_sec;
};
typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;

550 551 552 553 554 555
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
    int type;
    int device;
    int bus;
    char *src;
556
    virSecurityDeviceLabelDefPtr seclabel;
557
    char *dst;
558
    int tray_status;
M
MORITA Kazutaka 已提交
559 560 561
    int protocol;
    int nhosts;
    virDomainDiskHostDefPtr hosts;
562 563 564 565 566 567 568 569
    struct {
        char *username;
        int secretType; /* enum virDomainDiskSecretType */
        union {
            unsigned char uuid[VIR_UUID_BUFLEN];
            char *usage;
        } secret;
    } auth;
570 571
    char *driverName;
    char *driverType;
L
Lei Li 已提交
572

573 574 575 576
    char *mirror;
    char *mirrorFormat;
    bool mirroring;

L
Lei Li 已提交
577 578
    virDomainBlockIoTuneInfo blkdeviotune;

579
    char *serial;
580
    int cachemode;
581 582
    int error_policy;  /* enum virDomainDiskErrorPolicy */
    int rerror_policy; /* enum virDomainDiskErrorPolicy */
M
Matthias Dahl 已提交
583
    int iomode;
584
    int ioeventfd;
585
    int event_idx;
O
Osier Yang 已提交
586
    int copy_on_read;
587
    int snapshot; /* enum virDomainDiskSnapshot */
588
    int startupPolicy; /* enum virDomainStartupPolicy */
589 590
    unsigned int readonly : 1;
    unsigned int shared : 1;
591
    unsigned int transient : 1;
592
    virDomainDeviceInfo info;
593
    virStorageEncryptionPtr encryption;
594 595
    bool rawio_specified;
    int rawio; /* no = 0, yes = 1 */
596 597 598
};


599 600 601 602 603
enum virDomainControllerType {
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
604
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
605
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
606
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
607 608 609 610

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
};

611

612 613 614 615 616 617
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,
618
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
619
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
620

621
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
622 623
};

M
Marc-André Lureau 已提交
624 625 626 627 628 629 630 631 632 633 634 635 636 637
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
};

638 639 640 641 642 643 644
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

645 646 647 648
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
    int type;
    int idx;
649
    int model; /* -1 == undef */
650 651 652
    union {
        virDomainVirtioSerialOpts vioserial;
    } opts;
653 654 655 656
    virDomainDeviceInfo info;
};


657 658 659 660 661 662 663 664 665 666
/* 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
};

667 668 669 670 671 672 673 674 675
/* Filesystem driver type */
enum virDomainFSDriverType {
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
};

676 677 678 679 680 681 682 683 684
/* 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
};

685 686 687 688 689 690 691 692
/* Filesystem Write policy */
enum virDomainFSWrpolicy {
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
};

693 694
struct _virDomainFSDef {
    int type;
695
    int fsdriver;
696
    int accessmode;
697
    int wrpolicy; /* enum virDomainFSWrpolicy */
698 699 700
    char *src;
    char *dst;
    unsigned int readonly : 1;
701
    virDomainDeviceInfo info;
702 703 704
};


705 706 707 708 709 710 711 712 713
/* 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 已提交
714
    VIR_DOMAIN_NET_TYPE_INTERNAL,
715
    VIR_DOMAIN_NET_TYPE_DIRECT,
716
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
717 718 719 720

    VIR_DOMAIN_NET_TYPE_LAST,
};

721 722 723 724 725 726 727 728
/* 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,
};
729

730 731 732 733 734 735 736 737 738
/* 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,
};

739 740 741 742 743 744 745 746 747
/* 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
};

748 749 750 751 752 753 754 755 756 757 758 759
/* 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;
A
Ansis Atteka 已提交
760
            virNetDevVPortProfilePtr virtPortProfile;
761 762 763 764
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
765
            virNetDevVPortProfilePtr virtPortProfile;
766
        } direct;
767 768 769 770
        struct {
            virDomainHostdevDef def;
            virNetDevVPortProfilePtr virtPortProfile;
        } hostdev;
771
    } data;
772
    virNetDevBandwidthPtr bandwidth;
773 774
};

775 776
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
S
Stefan Berger 已提交
777
    enum virDomainNetType type;
778
    unsigned char mac[VIR_MAC_BUFLEN];
779
    char *model;
780 781 782
    union {
        struct {
            enum virDomainNetBackendType name; /* which driver backend to use */
783
            enum virDomainNetVirtioTxModeType txmode;
784
            enum virDomainIoEventFd ioeventfd;
785
            enum virDomainVirtioEventIdx event_idx;
786 787
        } virtio;
    } driver;
788 789 790 791 792 793 794 795 796 797 798
    union {
        struct {
            char *dev;
            char *ipaddr;
        } ethernet;
        struct {
            char *address;
            int port;
        } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
        struct {
            char *name;
799
            char *portgroup;
800
            virNetDevVPortProfilePtr virtPortProfile;
801 802 803 804 805 806 807 808 809
            /* 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;
810 811 812
        } network;
        struct {
            char *brname;
813
            char *ipaddr;
A
Ansis Atteka 已提交
814
            virNetDevVPortProfilePtr virtPortProfile;
815
        } bridge;
D
Daniel Veillard 已提交
816 817 818
        struct {
            char *name;
        } internal;
819 820
        struct {
            char *linkdev;
821
            int mode; /* enum virMacvtapMode from util/macvtap.h */
822
            virNetDevVPortProfilePtr virtPortProfile;
823
        } direct;
824 825 826 827
        struct {
            virDomainHostdevDef def;
            virNetDevVPortProfilePtr virtPortProfile;
        } hostdev;
828
    } data;
829 830 831 832
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
833
    char *script;
834
    char *ifname;
835
    virDomainDeviceInfo info;
836 837
    char *filter;
    virNWFilterHashTablePtr filterparams;
838
    virNetDevBandwidthPtr bandwidth;
839
    int linkstate;
840 841
};

E
Eric Blake 已提交
842 843 844 845
/* 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"

846
enum virDomainChrDeviceType {
847
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
848 849
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
850
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
851

852 853 854 855 856 857 858 859
    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,
860 861
};

862 863 864 865
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 已提交
866
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
867 868
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
869 870 871 872

    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST,
};

873
enum virDomainChrType {
874 875 876 877 878 879 880 881 882 883
    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,
884
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
885 886 887 888 889 890 891

    VIR_DOMAIN_CHR_TYPE_LAST,
};

enum virDomainChrTcpProtocol {
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW,
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
892 893
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
894 895 896 897

    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST,
};

E
Eric Blake 已提交
898 899 900
enum virDomainChrSpicevmcName {
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
901
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
902 903 904 905

    VIR_DOMAIN_CHR_SPICEVMC_LAST,
};

906 907 908 909 910
/* The host side information for a character device.  */
typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;
struct _virDomainChrSourceDef {
    int type; /* virDomainChrType */
911
    union {
E
Eric Blake 已提交
912
        /* no <source> for null, vc, stdio */
913 914 915 916 917 918
        struct {
            char *path;
        } file; /* pty, file, pipe, or device */
        struct {
            char *host;
            char *service;
919
            bool listen;
920 921 922 923 924 925 926 927 928 929
            int protocol;
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
930
            bool listen;
931
        } nix;
E
Eric Blake 已提交
932
        int spicevmc;
933
    } data;
934 935 936 937 938 939 940 941 942 943 944 945 946
};

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

    virDomainChrSourceDef source;
947 948

    virDomainDeviceInfo info;
949 950
};

E
Eric Blake 已提交
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975
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"

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 已提交
976 977 978 979 980
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
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
};

struct _virDomainInputDef {
    int type;
    int bus;
999
    virDomainDeviceInfo info;
1000 1001
};

1002 1003 1004 1005 1006 1007 1008
enum virDomainSoundCodecType {
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
};

1009 1010 1011 1012
enum virDomainSoundModel {
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1013
    VIR_DOMAIN_SOUND_MODEL_AC97,
1014
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1015 1016 1017 1018

    VIR_DOMAIN_SOUND_MODEL_LAST
};

1019 1020 1021 1022 1023
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1024 1025
struct _virDomainSoundDef {
    int model;
1026
    virDomainDeviceInfo info;
1027 1028 1029

    int ncodecs;
    virDomainSoundCodecDefPtr *codecs;
1030 1031
};

R
Richard Jones 已提交
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
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 已提交
1044
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1045 1046 1047 1048 1049 1050 1051 1052
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
};

struct _virDomainWatchdogDef {
    int model;
    int action;
1053
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1054 1055
};

1056 1057 1058 1059 1060 1061 1062

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,
1063
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1064 1065 1066 1067 1068

    VIR_DOMAIN_VIDEO_TYPE_LAST
};


1069 1070 1071
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
1072 1073
    unsigned int support3d :1;
    unsigned int support2d :1;
1074 1075 1076
};


1077 1078 1079 1080
struct _virDomainVideoDef {
    int type;
    unsigned int vram;
    unsigned int heads;
1081
    virDomainVideoAccelDefPtr accel;
1082
    virDomainDeviceInfo info;
1083 1084
};

1085 1086 1087 1088
/* 3 possible graphics console modes */
enum virDomainGraphicsType {
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1089 1090
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1091
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1092 1093 1094 1095

    VIR_DOMAIN_GRAPHICS_TYPE_LAST,
};

1096 1097 1098 1099 1100 1101 1102 1103 1104
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
};

1105 1106 1107 1108 1109 1110
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 */
1111
    int connected; /* action if connected */
1112 1113
};

1114 1115 1116 1117 1118 1119 1120
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 已提交
1121
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1122
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133

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

1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172
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
};

P
Peng Zhou 已提交
1173 1174 1175 1176 1177 1178 1179 1180
enum virDomainGraphicsSpiceMouseMode {
    VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER,
    VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT,

    VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST
};

1181 1182 1183 1184 1185 1186 1187 1188 1189
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
};

1190 1191 1192 1193 1194 1195 1196 1197
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
};

1198 1199 1200 1201 1202 1203 1204 1205
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 已提交
1206 1207 1208 1209 1210 1211
enum virDomainHubType {
    VIR_DOMAIN_HUB_TYPE_USB,

    VIR_DOMAIN_HUB_TYPE_LAST,
};

1212 1213 1214 1215 1216 1217 1218 1219
typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef;
typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr;
struct _virDomainGraphicsListenDef {
    int type;   /* enum virDomainGraphicsListenType */
    char *address;
    char *network;
};

1220
struct _virDomainGraphicsDef {
M
Michal Privoznik 已提交
1221 1222 1223 1224 1225
    /* Port value discipline:
     * Value -1 is legacy syntax indicating that it should be auto-allocated.
     * Value 0 means port wasn't specified in XML at all.
     * Positive value is actual port number given in XML.
     */
1226 1227 1228 1229
    int type;
    union {
        struct {
            int port;
1230
            unsigned int autoport :1;
1231
            char *keymap;
1232
            char *socket;
1233
            virDomainGraphicsAuthDef auth;
1234 1235 1236 1237
        } vnc;
        struct {
            char *display;
            char *xauth;
1238
            int fullscreen;
1239
        } sdl;
1240 1241
        struct {
            int port;
1242 1243 1244
            unsigned int autoport :1;
            unsigned int replaceUser :1;
            unsigned int multiUser :1;
1245 1246 1247
        } rdp;
        struct {
            char *display;
1248
            unsigned int fullscreen :1;
1249
        } desktop;
1250 1251 1252
        struct {
            int port;
            int tlsPort;
P
Peng Zhou 已提交
1253
            int mousemode;
1254
            char *keymap;
1255
            virDomainGraphicsAuthDef auth;
1256
            unsigned int autoport :1;
1257
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1258
            int defaultMode; /* enum virDomainGraphicsSpiceChannelMode */
1259 1260 1261 1262
            int image;
            int jpeg;
            int zlib;
            int playback;
1263
            int streaming;
1264
            int copypaste;
1265
        } spice;
1266
    } data;
1267 1268 1269 1270 1271
    /* 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;
1272 1273
};

1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288
enum virDomainRedirdevBus {
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
};

struct _virDomainRedirdevDef {
    int bus; /* enum virDomainRedirdevBus */

    union {
        virDomainChrSourceDef chr;
    } source;

    virDomainDeviceInfo info; /* Guest address */
};
1289 1290 1291 1292

enum {
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1293
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
};

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
};


1304 1305 1306 1307 1308 1309 1310 1311 1312
enum virDomainSmbiosMode {
    VIR_DOMAIN_SMBIOS_NONE,
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
};

1313

1314
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324

enum virDomainBootOrder {
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

    VIR_DOMAIN_BOOT_LAST,
};

1325 1326 1327 1328 1329 1330
enum virDomainBootMenu {
    VIR_DOMAIN_BOOT_MENU_DEFAULT = 0,
    VIR_DOMAIN_BOOT_MENU_ENABLED,
    VIR_DOMAIN_BOOT_MENU_DISABLED,
};

1331 1332 1333 1334
enum virDomainFeature {
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1335
    VIR_DOMAIN_FEATURE_HAP,
1336
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1337
    VIR_DOMAIN_FEATURE_PRIVNET,
1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350

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

1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361
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 已提交
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373
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;
};

1374 1375 1376 1377 1378 1379 1380 1381 1382
/* 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];
1383
    int bootmenu;
1384
    char *init;
1385
    char **initargv;
1386 1387 1388 1389 1390 1391 1392
    char *kernel;
    char *initrd;
    char *cmdline;
    char *root;
    char *loader;
    char *bootloader;
    char *bootloaderArgs;
1393
    int smbios_mode;
M
Michal Privoznik 已提交
1394
    virDomainBIOSDef bios;
1395 1396
};

1397 1398 1399 1400 1401 1402
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,
P
Paolo Bonzini 已提交
1403
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1404 1405 1406 1407

    VIR_DOMAIN_TIMER_NAME_LAST,
};

1408 1409 1410 1411
enum virDomainTimerTrackType {
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1412

1413
    VIR_DOMAIN_TIMER_TRACK_LAST,
1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429
};

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,
1430
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
1431 1432 1433 1434

    VIR_DOMAIN_TIMER_MODE_LAST,
};

O
Osier Yang 已提交
1435
enum virDomainCpuPlacementMode {
1436
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
1437 1438 1439 1440 1441
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST,
};

1442 1443 1444 1445 1446 1447 1448 1449
enum virDomainNumatuneMemPlacementMode {
    VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_DEFAULT = 0,
    VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC,
    VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO,

    VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_LAST,
};

1450 1451 1452 1453 1454 1455 1456 1457
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

1458 1459 1460 1461 1462 1463 1464
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 */

1465 1466 1467 1468
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
1469 1470 1471 1472 1473 1474

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

1475 1476 1477
enum virDomainClockOffsetType {
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
1478
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
1479
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
1480 1481 1482 1483

    VIR_DOMAIN_CLOCK_OFFSET_LAST,
};

1484 1485 1486 1487 1488 1489 1490
enum virDomainClockBasis {
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

    VIR_DOMAIN_CLOCK_BASIS_LAST,
};

1491 1492 1493 1494
typedef struct _virDomainClockDef virDomainClockDef;
typedef virDomainClockDef *virDomainClockDefPtr;
struct _virDomainClockDef {
    int offset;
1495

1496
    union {
1497 1498 1499
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
1500
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
1501 1502 1503 1504
        struct {
            long long adjustment;
            int basis;
        } variable;
1505 1506 1507 1508 1509

        /* Timezone name, when
         * offset == VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME */
        char *timezone;
    } data;
1510 1511 1512

    int ntimers;
    virDomainTimerDefPtr *timers;
1513 1514
};

1515
# define VIR_DOMAIN_CPUMASK_LEN 1024
1516

E
Eric Blake 已提交
1517 1518 1519
typedef struct _virDomainVcpuPinDef virDomainVcpuPinDef;
typedef virDomainVcpuPinDef *virDomainVcpuPinDefPtr;
struct _virDomainVcpuPinDef {
1520 1521 1522 1523
    int vcpuid;
    char *cpumask;
};

E
Eric Blake 已提交
1524
int virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def,
1525 1526 1527
                                int nvcpupin,
                                int vcpu);

E
Eric Blake 已提交
1528
virDomainVcpuPinDefPtr virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
1529 1530 1531
                                                  int nvcpupin,
                                                  int vcpu);

1532 1533 1534 1535 1536 1537
typedef struct _virDomainNumatuneDef virDomainNumatuneDef;
typedef virDomainNumatuneDef *virDomainNumatuneDefPtr;
struct _virDomainNumatuneDef {
    struct {
        char *nodemask;
        int mode;
1538
        int placement_mode; /* enum virDomainNumatuneMemPlacementMode */
1539 1540 1541 1542 1543
    } memory;

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

1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554
typedef struct _virBlkioDeviceWeight virBlkioDeviceWeight;
typedef virBlkioDeviceWeight *virBlkioDeviceWeightPtr;
struct _virBlkioDeviceWeight {
    char *path;
    unsigned int weight;
};

void virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights,
                                    int ndevices);


1555 1556 1557 1558 1559 1560
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
1561 1562 1563 1564 1565 1566 1567
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
struct _virDomainDef {
    int virtType;
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
    char *name;
1568
    char *title;
1569
    char *description;
1570

1571 1572
    struct {
        unsigned int weight;
1573 1574 1575

        size_t ndevices;
        virBlkioDeviceWeightPtr devices;
1576 1577
    } blkio;

1578
    struct {
1579 1580 1581 1582 1583 1584 1585
        unsigned long long max_balloon; /* in kibibytes */
        unsigned long long cur_balloon; /* in kibibytes */
        bool hugepage_backed;
        unsigned long long hard_limit; /* in kibibytes */
        unsigned long long soft_limit; /* in kibibytes */
        unsigned long long min_guarantee; /* in kibibytes */
        unsigned long long swap_hard_limit; /* in kibibytes */
1586
    } mem;
E
Eric Blake 已提交
1587 1588
    unsigned short vcpus;
    unsigned short maxvcpus;
O
Osier Yang 已提交
1589
    int placement_mode;
1590 1591 1592
    int cpumasklen;
    char *cpumask;

1593 1594
    struct {
        unsigned long shares;
1595 1596
        unsigned long long period;
        long long quota;
1597
        int nvcpupin;
E
Eric Blake 已提交
1598
        virDomainVcpuPinDefPtr *vcpupin;
1599 1600
    } cputune;

1601 1602
    virDomainNumatuneDef numatune;

1603 1604 1605 1606 1607 1608 1609 1610 1611
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

    virDomainOSDef os;
    char *emulator;
    int features;

1612
    virDomainClockDef clock;
1613

1614 1615
    int ngraphics;
    virDomainGraphicsDefPtr *graphics;
1616 1617 1618 1619

    int ndisks;
    virDomainDiskDefPtr *disks;

1620 1621 1622
    int ncontrollers;
    virDomainControllerDefPtr *controllers;

1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634
    int nfss;
    virDomainFSDefPtr *fss;

    int nnets;
    virDomainNetDefPtr *nets;

    int ninputs;
    virDomainInputDefPtr *inputs;

    int nsounds;
    virDomainSoundDefPtr *sounds;

1635 1636 1637
    int nvideos;
    virDomainVideoDefPtr *videos;

1638 1639 1640
    int nhostdevs;
    virDomainHostdevDefPtr *hostdevs;

1641 1642 1643
    int nredirdevs;
    virDomainRedirdevDefPtr *redirdevs;

E
Eric Blake 已提交
1644 1645 1646
    int nsmartcards;
    virDomainSmartcardDefPtr *smartcards;

1647 1648 1649 1650 1651 1652
    int nserials;
    virDomainChrDefPtr *serials;

    int nparallels;
    virDomainChrDefPtr *parallels;

1653 1654 1655
    int nchannels;
    virDomainChrDefPtr *channels;

1656 1657 1658
    int nconsoles;
    virDomainChrDefPtr *consoles;

1659
    size_t nleases;
1660 1661
    virDomainLeaseDefPtr *leases;

M
Marc-André Lureau 已提交
1662 1663 1664
    int nhubs;
    virDomainHubDefPtr *hubs;

1665
    /* Only 1 */
1666
    virSecurityLabelDef seclabel;
R
Richard Jones 已提交
1667
    virDomainWatchdogDefPtr watchdog;
1668
    virDomainMemballoonDefPtr memballoon;
1669
    virCPUDefPtr cpu;
1670
    virSysinfoDefPtr sysinfo;
1671 1672 1673

    void *namespaceData;
    virDomainXMLNamespace ns;
1674 1675 1676

    /* Application-specific custom metadata */
    xmlNodePtr metadata;
1677 1678
};

1679 1680 1681 1682 1683 1684
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 */
1685
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
1686
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
1687 1688 1689 1690

    VIR_DOMAIN_TAINT_LAST
};

1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704
/* 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 */
1705 1706 1707
typedef struct _virDomainSnapshotDef virDomainSnapshotDef;
typedef virDomainSnapshotDef *virDomainSnapshotDefPtr;
struct _virDomainSnapshotDef {
1708
    /* Public XML.  */
1709 1710 1711 1712
    char *name;
    char *description;
    char *parent;
    long long creationTime; /* in seconds */
1713
    int state; /* enum virDomainSnapshotState */
1714 1715 1716 1717

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

1718
    virDomainDefPtr dom;
1719

1720 1721
    /* Internal use.  */
    bool current; /* At most one snapshot in the list should have this set */
1722 1723 1724 1725 1726 1727
};

typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;
struct _virDomainSnapshotObj {
    virDomainSnapshotDefPtr def;
1728

1729 1730 1731 1732
    virDomainSnapshotObjPtr parent; /* NULL if root */
    virDomainSnapshotObjPtr sibling; /* NULL if last child of parent */
    size_t nchildren;
    virDomainSnapshotObjPtr first_child; /* NULL if no children */
1733 1734 1735 1736 1737 1738 1739 1740
};

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

    size_t nroots;
    virDomainSnapshotObjPtr first_root;
1744 1745
};

1746 1747
typedef enum {
    VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE = 1 << 0,
1748 1749
    VIR_DOMAIN_SNAPSHOT_PARSE_DISKS    = 1 << 1,
    VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL = 1 << 2,
1750 1751
} virDomainSnapshotParseFlags;

1752
virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
1753 1754
                                                        virCapsPtr caps,
                                                        unsigned int expectedVirtTypes,
1755
                                                        unsigned int flags);
1756
void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
1757
char *virDomainSnapshotDefFormat(const char *domain_uuid,
1758
                                 virDomainSnapshotDefPtr def,
1759
                                 unsigned int flags,
1760
                                 int internal);
1761 1762 1763
int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot,
                                int default_snapshot,
                                bool require_match);
1764 1765 1766 1767 1768
virDomainSnapshotObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr snapshots,
                                                   const virDomainSnapshotDefPtr def);

int virDomainSnapshotObjListInit(virDomainSnapshotObjListPtr objs);
int virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots,
1769 1770 1771 1772
                                     char **const names, int maxnames,
                                     unsigned int flags);
int virDomainSnapshotObjListNum(virDomainSnapshotObjListPtr snapshots,
                                unsigned int flags);
1773 1774 1775 1776 1777
int virDomainSnapshotObjListGetNamesFrom(virDomainSnapshotObjPtr snapshot,
                                         char **const names, int maxnames,
                                         unsigned int flags);
int virDomainSnapshotObjListNumFrom(virDomainSnapshotObjPtr snapshot,
                                    unsigned int flags);
1778 1779 1780 1781
virDomainSnapshotObjPtr virDomainSnapshotFindByName(const virDomainSnapshotObjListPtr snapshots,
                                                    const char *name);
void virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr snapshots,
                                    virDomainSnapshotObjPtr snapshot);
E
Eric Blake 已提交
1782
int virDomainSnapshotForEachChild(virDomainSnapshotObjPtr snapshot,
1783 1784
                                  virHashIterator iter,
                                  void *data);
E
Eric Blake 已提交
1785
int virDomainSnapshotForEachDescendant(virDomainSnapshotObjPtr snapshot,
1786 1787
                                       virHashIterator iter,
                                       void *data);
1788 1789 1790
int virDomainSnapshotUpdateRelations(virDomainSnapshotObjListPtr snapshots);
void virDomainSnapshotDropParent(virDomainSnapshotObjListPtr snapshots,
                                 virDomainSnapshotObjPtr snapshot);
1791

1792
/* Guest VM runtime state */
J
Jiri Denemark 已提交
1793 1794 1795 1796 1797 1798
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

1799 1800 1801
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
1802
    virMutex lock;
1803
    int refs;
1804

1805
    pid_t pid;
J
Jiri Denemark 已提交
1806
    virDomainStateReason state;
1807 1808 1809

    unsigned int autostart : 1;
    unsigned int persistent : 1;
1810
    unsigned int updated : 1;
1811 1812 1813

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

C
Chris Lalancette 已提交
1815 1816 1817
    virDomainSnapshotObjList snapshots;
    virDomainSnapshotObjPtr current_snapshot;

1818 1819
    void *privateData;
    void (*privateDataFreeFunc)(void *);
1820 1821

    int taint;
1822 1823
};

1824 1825 1826
typedef struct _virDomainObjList virDomainObjList;
typedef virDomainObjList *virDomainObjListPtr;
struct _virDomainObjList {
1827 1828 1829
    /* uuid string -> virDomainObj  mapping
     * for O(1), lockless lookup-by-uuid */
    virHashTable *objs;
1830
};
1831

1832
static inline bool
D
Daniel P. Berrange 已提交
1833
virDomainObjIsActive(virDomainObjPtr dom)
1834 1835 1836 1837
{
    return dom->def->id != -1;
}

1838

1839 1840
int virDomainObjListInit(virDomainObjListPtr objs);
void virDomainObjListDeinit(virDomainObjListPtr objs);
1841

1842
virDomainObjPtr virDomainFindByID(const virDomainObjListPtr doms,
1843
                                  int id);
1844
virDomainObjPtr virDomainFindByUUID(const virDomainObjListPtr doms,
1845
                                    const unsigned char *uuid);
1846
virDomainObjPtr virDomainFindByName(const virDomainObjListPtr doms,
1847 1848
                                    const char *name);

1849 1850
bool virDomainObjTaint(virDomainObjPtr obj,
                       enum virDomainTaintFlags taint);
1851 1852 1853 1854

void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
void virDomainDiskDefFree(virDomainDiskDefPtr def);
1855
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
1856
void virDomainDiskHostDefFree(virDomainDiskHostDefPtr def);
1857 1858 1859
int virDomainDiskFindControllerModel(virDomainDefPtr def,
                                     virDomainDiskDefPtr disk,
                                     int controllerType);
1860
void virDomainControllerDefFree(virDomainControllerDefPtr def);
1861
void virDomainFSDefFree(virDomainFSDefPtr def);
1862
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
1863
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
1864
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
1865
void virDomainChrDefFree(virDomainChrDefPtr def);
1866
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
1867 1868
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr src,
                              virDomainChrSourceDefPtr dest);
1869
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
1870
void virDomainSoundDefFree(virDomainSoundDefPtr def);
1871
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
R
Richard Jones 已提交
1872
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
1873
void virDomainVideoDefFree(virDomainVideoDefPtr def);
1874 1875
virDomainHostdevDefPtr virDomainHostdevDefAlloc(void);
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
1876
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
1877
void virDomainHubDefFree(virDomainHubDefPtr def);
1878
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
1879
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
1880 1881 1882
virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps,
                                             const virDomainDefPtr def,
                                             virDomainDeviceDefPtr src);
1883 1884 1885 1886
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                  int type);
int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr);
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
1887
void virDomainDefClearPCIAddresses(virDomainDefPtr def);
D
Daniel P. Berrange 已提交
1888
void virDomainDefClearDeviceAliases(virDomainDefPtr def);
1889

1890
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
1891 1892
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
1893 1894 1895 1896 1897 1898
                                           void *opaque);

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

1899
void virDomainDefFree(virDomainDefPtr vm);
1900 1901
void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
1902
int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK;
1903

M
Michal Novotny 已提交
1904 1905
virDomainChrDefPtr virDomainChrDefNew(void);

1906 1907
/* live == true means def describes an active domain (being migrated or
 * restored) as opposed to a new persistent configuration of the domain */
1908
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
1909
                                   virDomainObjListPtr doms,
1910 1911
                                   const virDomainDefPtr def,
                                   bool live);
1912 1913 1914
void virDomainObjAssignDef(virDomainObjPtr domain,
                           const virDomainDefPtr def,
                           bool live);
1915
int virDomainObjSetDefTransient(virCapsPtr caps,
1916 1917
                                virDomainObjPtr domain,
                                bool live);
1918 1919 1920
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
                             virDomainObjPtr domain);
1921 1922 1923 1924 1925 1926 1927

int
virDomainLiveConfigHelperMethod(virCapsPtr caps,
                                virDomainObjPtr dom,
                                unsigned int *flags,
                                virDomainDefPtr *persistentDef);

1928 1929 1930
virDomainDefPtr
virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom);

1931
void virDomainRemoveInactive(virDomainObjListPtr doms,
1932 1933
                             virDomainObjPtr dom);

1934
virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
1935
                                              const virDomainDefPtr def,
1936
                                              const char *xmlStr,
L
Laine Stump 已提交
1937
                                              unsigned int flags);
1938
virDomainDefPtr virDomainDefParseString(virCapsPtr caps,
1939
                                        const char *xmlStr,
M
Matthias Bolte 已提交
1940
                                        unsigned int expectedVirtTypes,
L
Laine Stump 已提交
1941
                                        unsigned int flags);
1942
virDomainDefPtr virDomainDefParseFile(virCapsPtr caps,
1943
                                      const char *filename,
M
Matthias Bolte 已提交
1944
                                      unsigned int expectedVirtTypes,
L
Laine Stump 已提交
1945
                                      unsigned int flags);
1946
virDomainDefPtr virDomainDefParseNode(virCapsPtr caps,
1947
                                      xmlDocPtr doc,
1948
                                      xmlNodePtr root,
M
Matthias Bolte 已提交
1949
                                      unsigned int expectedVirtTypes,
L
Laine Stump 已提交
1950
                                      unsigned int flags);
1951

1952 1953 1954
bool virDomainDefCheckABIStability(virDomainDefPtr src,
                                   virDomainDefPtr dst);

1955
int virDomainDefAddImplicitControllers(virDomainDefPtr def);
1956

1957
char *virDomainDefFormat(virDomainDefPtr def,
L
Laine Stump 已提交
1958
                         unsigned int flags);
1959 1960 1961
int virDomainDefFormatInternal(virDomainDefPtr def,
                               unsigned int flags,
                               virBufferPtr buf);
1962

1963
int virDomainCpuSetParse(const char *str,
1964 1965 1966
                         char sep,
                         char *cpuset,
                         int maxcpu);
1967
char *virDomainCpuSetFormat(char *cpuset,
1968 1969
                            int maxcpu);

E
Eric Blake 已提交
1970
int virDomainVcpuPinAdd(virDomainDefPtr def,
1971 1972 1973 1974
                        unsigned char *cpumap,
                        int maplen,
                        int vcpu);

E
Eric Blake 已提交
1975
int virDomainVcpuPinDel(virDomainDefPtr def, int vcpu);
1976

1977 1978 1979
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
1980 1981 1982 1983
int virDomainDiskInsert(virDomainDefPtr def,
                        virDomainDiskDefPtr disk);
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
1984
int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def);
1985

1986 1987 1988 1989
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
1990

1991 1992
int virDomainNetIndexByMac(virDomainDefPtr def, const unsigned char *mac);
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
1993 1994 1995 1996
virDomainNetDefPtr
virDomainNetRemove(virDomainDefPtr def, size_t i);
virDomainNetDefPtr
virDomainNetRemoveByMac(virDomainDefPtr def, const unsigned char *mac);
1997

L
Laine Stump 已提交
1998
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
1999 2000
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
2001 2002 2003
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021
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);

2022
int virDomainNetGetActualType(virDomainNetDefPtr iface);
2023 2024
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
2025
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
2026
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
2027
virNetDevVPortProfilePtr
2028
virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface);
2029
virNetDevBandwidthPtr
2030
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
2031

2032 2033 2034 2035 2036
int virDomainControllerInsert(virDomainDefPtr def,
                              virDomainControllerDefPtr controller);
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);

2037 2038 2039 2040 2041 2042 2043 2044

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def);
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
2045 2046 2047 2048 2049
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
2050

2051
int virDomainSaveXML(const char *configDir,
2052 2053 2054
                     virDomainDefPtr def,
                     const char *xml);

2055
int virDomainSaveConfig(const char *configDir,
2056
                        virDomainDefPtr def);
2057
int virDomainSaveStatus(virCapsPtr caps,
2058
                        const char *statusDir,
2059
                        virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
2060

2061 2062 2063 2064
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

2065
int virDomainLoadAllConfigs(virCapsPtr caps,
2066
                            virDomainObjListPtr doms,
2067
                            const char *configDir,
2068
                            const char *autostartDir,
2069
                            int liveStatus,
M
Matthias Bolte 已提交
2070
                            unsigned int expectedVirtTypes,
2071 2072
                            virDomainLoadConfigNotify notify,
                            void *opaque);
2073

2074
int virDomainDeleteConfig(const char *configDir,
2075
                          const char *autostartDir,
2076 2077
                          virDomainObjPtr dom);

2078
char *virDomainConfigFile(const char *dir,
2079 2080
                          const char *name);

2081 2082 2083 2084
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

2085
virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def);
2086 2087
int virDomainVideoDefaultType(virDomainDefPtr def);
int virDomainVideoDefaultRAM(virDomainDefPtr def, int type);
2088

2089 2090 2091 2092
int virDomainObjIsDuplicate(virDomainObjListPtr doms,
                            virDomainDefPtr def,
                            unsigned int check_active);

D
Daniel P. Berrange 已提交
2093 2094
void virDomainObjLock(virDomainObjPtr obj);
void virDomainObjUnlock(virDomainObjPtr obj);
2095

2096 2097 2098 2099 2100 2101 2102 2103 2104
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 已提交
2105 2106 2107 2108 2109 2110 2111 2112 2113
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

2114 2115 2116 2117 2118 2119 2120 2121 2122
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

2123 2124 2125 2126 2127 2128 2129 2130
typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
                                            const char *path,
                                            size_t depth,
                                            void *opaque);

int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
                                bool allowProbing,
                                bool ignoreOpenFailure,
2131
                                uid_t uid, gid_t gid,
2132 2133 2134
                                virDomainDiskDefPathIterator iter,
                                void *opaque);

J
Jiri Denemark 已提交
2135 2136 2137 2138 2139 2140 2141
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

2142 2143 2144
typedef const char* (*virLifecycleToStringFunc)(int type);
typedef int (*virLifecycleFromStringFunc)(const char *type);

2145 2146
VIR_ENUM_DECL(virDomainTaint)

2147 2148 2149 2150
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
VIR_ENUM_DECL(virDomainFeature)
VIR_ENUM_DECL(virDomainLifecycle)
2151
VIR_ENUM_DECL(virDomainLifecycleCrash)
2152
VIR_ENUM_DECL(virDomainDevice)
2153
VIR_ENUM_DECL(virDomainDeviceAddress)
2154
VIR_ENUM_DECL(virDomainDeviceAddressPciMulti)
2155 2156 2157
VIR_ENUM_DECL(virDomainDisk)
VIR_ENUM_DECL(virDomainDiskDevice)
VIR_ENUM_DECL(virDomainDiskBus)
2158
VIR_ENUM_DECL(virDomainDiskCache)
2159
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
M
MORITA Kazutaka 已提交
2160
VIR_ENUM_DECL(virDomainDiskProtocol)
M
Matthias Dahl 已提交
2161
VIR_ENUM_DECL(virDomainDiskIo)
2162
VIR_ENUM_DECL(virDomainDiskSecretType)
2163
VIR_ENUM_DECL(virDomainDiskSnapshot)
2164
VIR_ENUM_DECL(virDomainDiskTray)
2165
VIR_ENUM_DECL(virDomainIoEventFd)
2166
VIR_ENUM_DECL(virDomainVirtioEventIdx)
O
Osier Yang 已提交
2167
VIR_ENUM_DECL(virDomainDiskCopyOnRead)
2168
VIR_ENUM_DECL(virDomainController)
2169
VIR_ENUM_DECL(virDomainControllerModelSCSI)
M
Marc-André Lureau 已提交
2170
VIR_ENUM_DECL(virDomainControllerModelUSB)
2171
VIR_ENUM_DECL(virDomainFS)
2172
VIR_ENUM_DECL(virDomainFSDriverType)
2173
VIR_ENUM_DECL(virDomainFSAccessMode)
2174
VIR_ENUM_DECL(virDomainFSWrpolicy)
2175
VIR_ENUM_DECL(virDomainNet)
2176
VIR_ENUM_DECL(virDomainNetBackend)
2177
VIR_ENUM_DECL(virDomainNetVirtioTxMode)
2178
VIR_ENUM_DECL(virDomainNetInterfaceLinkState)
2179
VIR_ENUM_DECL(virDomainChrDevice)
2180
VIR_ENUM_DECL(virDomainChrChannelTarget)
2181
VIR_ENUM_DECL(virDomainChrConsoleTarget)
E
Eric Blake 已提交
2182
VIR_ENUM_DECL(virDomainSmartcard)
2183
VIR_ENUM_DECL(virDomainChr)
2184
VIR_ENUM_DECL(virDomainChrTcpProtocol)
E
Eric Blake 已提交
2185
VIR_ENUM_DECL(virDomainChrSpicevmc)
2186
VIR_ENUM_DECL(virDomainSoundCodec)
2187
VIR_ENUM_DECL(virDomainSoundModel)
2188
VIR_ENUM_DECL(virDomainMemballoonModel)
2189
VIR_ENUM_DECL(virDomainSmbiosMode)
R
Richard Jones 已提交
2190 2191
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
2192
VIR_ENUM_DECL(virDomainVideo)
2193 2194
VIR_ENUM_DECL(virDomainHostdevMode)
VIR_ENUM_DECL(virDomainHostdevSubsys)
2195
VIR_ENUM_DECL(virDomainPciRombarMode)
M
Marc-André Lureau 已提交
2196
VIR_ENUM_DECL(virDomainHub)
2197
VIR_ENUM_DECL(virDomainRedirdevBus)
2198 2199 2200
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
2201
VIR_ENUM_DECL(virDomainGraphicsListen)
2202
VIR_ENUM_DECL(virDomainGraphicsAuthConnected)
2203 2204
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
2205 2206 2207 2208
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression)
2209
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
2210
VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste)
P
Peng Zhou 已提交
2211
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
2212
VIR_ENUM_DECL(virDomainNumatuneMemMode)
2213
VIR_ENUM_DECL(virDomainNumatuneMemPlacementMode)
2214
VIR_ENUM_DECL(virDomainSnapshotState)
2215 2216
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
J
Jiri Denemark 已提交
2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227
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);

2228
VIR_ENUM_DECL(virDomainSeclabel)
2229
VIR_ENUM_DECL(virDomainClockOffset)
2230
VIR_ENUM_DECL(virDomainClockBasis)
2231

2232
VIR_ENUM_DECL(virDomainTimerName)
2233
VIR_ENUM_DECL(virDomainTimerTrack)
2234 2235
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)
O
Osier Yang 已提交
2236
VIR_ENUM_DECL(virDomainCpuPlacementMode)
2237

2238
VIR_ENUM_DECL(virDomainStartupPolicy)
2239 2240 2241

virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def,
                                    const char *device);
2242
#endif /* __DOMAIN_CONF_H */