domain_conf.h 100.7 KB
Newer Older
1 2 3
/*
 * domain_conf.h: domain XML processing
 *
4
 * Copyright (C) 2006-2015 Red Hat, Inc.
5
 * Copyright (C) 2006-2008 Daniel P. Berrange
6
 * Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
7 8 9 10 11 12 13 14 15 16 17 18
 *
 * 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
19
 * License along with this library.  If not, see
O
Osier Yang 已提交
20
 * <http://www.gnu.org/licenses/>.
21 22 23 24 25
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __DOMAIN_CONF_H
26
# define __DOMAIN_CONF_H
27

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

32 33
# include "internal.h"
# include "capabilities.h"
34
# include "virstorageencryption.h"
35
# include "cpu_conf.h"
36
# include "virthread.h"
37
# include "virhash.h"
38
# include "virsocketaddr.h"
39
# include "networkcommon_conf.h"
40
# include "nwfilter_params.h"
41
# include "numa_conf.h"
42
# include "virnetdevmacvlan.h"
43
# include "virsysinfo.h"
44 45
# include "virnetdevvportprofile.h"
# include "virnetdevbandwidth.h"
46
# include "virnetdevvlan.h"
47
# include "virobject.h"
48
# include "device_conf.h"
49
# include "virbitmap.h"
50
# include "virstoragefile.h"
51
# include "virseclabel.h"
52
# include "virprocess.h"
53

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
/* 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;

75 76 77
typedef struct _virDomainSoundCodecDef virDomainSoundCodecDef;
typedef virDomainSoundCodecDef *virDomainSoundCodecDefPtr;

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
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;

99 100
typedef struct _virDomainRedirFilterUSBDevDef virDomainRedirFilterUSBDevDef;
typedef virDomainRedirFilterUSBDevDef *virDomainRedirFilterUSBDevDefPtr;
101 102 103 104

typedef struct _virDomainRedirFilterDef virDomainRedirFilterDef;
typedef virDomainRedirFilterDef *virDomainRedirFilterDefPtr;

105 106 107 108 109 110 111 112 113
typedef struct _virDomainSmartcardDef virDomainSmartcardDef;
typedef virDomainSmartcardDef *virDomainSmartcardDefPtr;

typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr;

typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;

L
Li Zhang 已提交
114 115 116
typedef struct _virDomainNVRAMDef virDomainNVRAMDef;
typedef virDomainNVRAMDef *virDomainNVRAMDefPtr;

117 118 119 120 121 122
typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;

typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
typedef virDomainSnapshotObjList *virDomainSnapshotObjListPtr;

123 124 125
typedef struct _virDomainRNGDef virDomainRNGDef;
typedef virDomainRNGDef *virDomainRNGDefPtr;

126 127 128 129 130 131
typedef struct _virDomainIdMapEntry virDomainIdMapEntry;
typedef virDomainIdMapEntry *virDomainIdMapEntryPtr;

typedef struct _virDomainIdMapDef virDomainIdMapDef;
typedef virDomainIdMapDef *virDomainIdMapDefPtr;

H
Hu Tao 已提交
132 133 134
typedef struct _virDomainPanicDef virDomainPanicDef;
typedef virDomainPanicDef *virDomainPanicDefPtr;

135 136 137
typedef struct _virDomainMemoryDef virDomainMemoryDef;
typedef virDomainMemoryDef *virDomainMemoryDefPtr;

M
Michele Paolino 已提交
138 139 140 141 142 143
/* forward declarations virDomainChrSourceDef, required by
 * virDomainNetDef
 */
typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;

144 145 146
typedef struct _virDomainShmemDef virDomainShmemDef;
typedef virDomainShmemDef *virDomainShmemDefPtr;

147 148 149
typedef struct _virDomainTPMDef virDomainTPMDef;
typedef virDomainTPMDef *virDomainTPMDefPtr;

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
/* 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,
L
Li Zhang 已提交
169
    VIR_DOMAIN_DEVICE_NVRAM,
170
    VIR_DOMAIN_DEVICE_RNG,
171
    VIR_DOMAIN_DEVICE_SHMEM,
172
    VIR_DOMAIN_DEVICE_TPM,
173
    VIR_DOMAIN_DEVICE_PANIC,
174
    VIR_DOMAIN_DEVICE_MEMORY,
175

176
    VIR_DOMAIN_DEVICE_LAST
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
} 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;
L
Li Zhang 已提交
200
        virDomainNVRAMDefPtr nvram;
201
        virDomainRNGDefPtr rng;
202
        virDomainShmemDefPtr shmem;
203
        virDomainTPMDefPtr tpm;
204
        virDomainPanicDefPtr panic;
205
        virDomainMemoryDefPtr memory;
206 207 208
    } data;
};

209 210
/* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */
211
typedef enum {
212 213 214 215 216 217 218 219 220 221
    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,
222
    VIR_DOMAIN_VIRT_VBOX,
223
    VIR_DOMAIN_VIRT_PHYP,
D
Dmitry Guryanov 已提交
224
    VIR_DOMAIN_VIRT_PARALLELS,
R
Roman Bogorodskiy 已提交
225
    VIR_DOMAIN_VIRT_BHYVE,
226

227
    VIR_DOMAIN_VIRT_LAST
228
} virDomainVirtType;
229

230 231 232 233 234 235 236 237 238 239 240 241
typedef enum {
    VIR_DOMAIN_OSTYPE_HVM,
    VIR_DOMAIN_OSTYPE_XEN,
    VIR_DOMAIN_OSTYPE_LINUX,
    VIR_DOMAIN_OSTYPE_EXE,
    VIR_DOMAIN_OSTYPE_UML,

    VIR_DOMAIN_OSTYPE_LAST
} virDomainOSType;
VIR_ENUM_DECL(virDomainOS)


242
typedef enum {
243 244
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
245
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
246
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
247
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
248
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB,
249
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
250
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390,
251
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW,
252
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO,
H
Hu Tao 已提交
253
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA,
254
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM,
255 256

    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
257
} virDomainDeviceAddressType;
258

259 260 261 262 263
typedef struct _virDomainDeviceDriveAddress virDomainDeviceDriveAddress;
typedef virDomainDeviceDriveAddress *virDomainDeviceDriveAddressPtr;
struct _virDomainDeviceDriveAddress {
    unsigned int controller;
    unsigned int bus;
264
    unsigned int target;
265 266 267
    unsigned int unit;
};

268 269 270 271 272
typedef struct _virDomainDeviceVirtioSerialAddress virDomainDeviceVirtioSerialAddress;
typedef virDomainDeviceVirtioSerialAddress *virDomainDeviceVirtioSerialAddressPtr;
struct _virDomainDeviceVirtioSerialAddress {
    unsigned int controller;
    unsigned int bus;
273
    unsigned int port;
274 275
};

276 277 278 279 280 281 282 283 284 285 286 287 288
# define VIR_DOMAIN_DEVICE_CCW_MAX_CSSID    254
# define VIR_DOMAIN_DEVICE_CCW_MAX_SSID       3
# define VIR_DOMAIN_DEVICE_CCW_MAX_DEVNO  65535

typedef struct _virDomainDeviceCCWAddress virDomainDeviceCCWAddress;
typedef virDomainDeviceCCWAddress *virDomainDeviceCCWAddressPtr;
struct _virDomainDeviceCCWAddress {
    unsigned int cssid;
    unsigned int ssid;
    unsigned int devno;
    bool         assigned;
};

E
Eric Blake 已提交
289 290 291 292 293 294 295
typedef struct _virDomainDeviceCcidAddress virDomainDeviceCcidAddress;
typedef virDomainDeviceCcidAddress *virDomainDeviceCcidAddressPtr;
struct _virDomainDeviceCcidAddress {
    unsigned int controller;
    unsigned int slot;
};

296 297 298 299
typedef struct _virDomainDeviceUSBAddress virDomainDeviceUSBAddress;
typedef virDomainDeviceUSBAddress *virDomainDeviceUSBAddressPtr;
struct _virDomainDeviceUSBAddress {
    unsigned int bus;
300
    char *port;
301 302
};

303 304 305 306 307 308 309
typedef struct _virDomainDeviceSpaprVioAddress virDomainDeviceSpaprVioAddress;
typedef virDomainDeviceSpaprVioAddress *virDomainDeviceSpaprVioAddressPtr;
struct _virDomainDeviceSpaprVioAddress {
    unsigned long long reg;
    bool has_reg;
};

310
typedef enum {
311 312 313 314
    VIR_DOMAIN_CONTROLLER_MASTER_NONE,
    VIR_DOMAIN_CONTROLLER_MASTER_USB,

    VIR_DOMAIN_CONTROLLER_MASTER_LAST
315
} virDomainControllerMaster;
316 317 318 319 320 321 322

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

H
Hu Tao 已提交
323 324 325 326 327 328 329
typedef struct _virDomainDeviceISAAddress virDomainDeviceISAAddress;
typedef virDomainDeviceISAAddress *virDomainDeviceISAAddressPtr;
struct _virDomainDeviceISAAddress {
    unsigned int iobase;
    unsigned int irq;
};

330 331 332 333 334 335 336
typedef struct _virDomainDeviceDimmAddress virDomainDeviceDimmAddress;
typedef virDomainDeviceDimmAddress *virDomainDeviceDimmAddressPtr;
struct _virDomainDeviceDimmAddress {
    unsigned int slot;
    unsigned long long base;
};

337 338 339
typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
struct _virDomainDeviceInfo {
340 341 342 343
    /* If adding to this struct, ensure that
     * virDomainDeviceInfoIsSet() is updated
     * to consider the new fields
     */
D
Daniel P. Berrange 已提交
344
    char *alias;
345
    int type; /* virDomainDeviceAddressType */
346
    union {
347
        virDevicePCIAddress pci;
348
        virDomainDeviceDriveAddress drive;
349
        virDomainDeviceVirtioSerialAddress vioserial;
E
Eric Blake 已提交
350
        virDomainDeviceCcidAddress ccid;
351
        virDomainDeviceUSBAddress usb;
352
        virDomainDeviceSpaprVioAddress spaprvio;
353
        virDomainDeviceCCWAddress ccw;
H
Hu Tao 已提交
354
        virDomainDeviceISAAddress isa;
355
        virDomainDeviceDimmAddress dimm;
356
    } addr;
357 358 359 360
    int mastertype;
    union {
        virDomainDeviceUSBMaster usb;
    } master;
361 362
    /* rombar and romfile are only used for pci hostdev and network
     * devices. */
J
Ján Tomko 已提交
363
    int rombar;         /* enum virTristateSwitch */
364
    char *romfile;
365 366
    /* bootIndex is only used for disk, network interface, hostdev
     * and redirdev devices */
367
    int bootIndex;
368 369
};

370

371 372 373 374 375 376 377 378
typedef struct _virDomainHostdevOrigStates virDomainHostdevOrigStates;
typedef virDomainHostdevOrigStates *virDomainHostdevOrigStatesPtr;
struct _virDomainHostdevOrigStates {
    union {
        struct {
            /* Does the device need to unbind from stub when
             * reattaching to host?
             */
379
            bool unbind_from_stub;
380 381 382 383

            /* Does it need to use remove_slot when reattaching
             * the device to host?
             */
384
            bool remove_slot;
385 386 387 388

            /* Does it need to reprobe driver for the device when
             * reattaching to host?
             */
389
            bool reprobe;
390 391 392 393 394 395
        } pci;

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

396 397 398 399 400 401 402
struct _virDomainLeaseDef {
    char *lockspace;
    char *key;
    char *path;
    unsigned long long offset;
};

403

404
typedef enum {
405 406 407
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

408
    VIR_DOMAIN_HOSTDEV_MODE_LAST
409
} virDomainHostdevMode;
410

411
typedef enum {
412 413
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
H
Han Cheng 已提交
414
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
415 416

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
417
} virDomainHostdevSubsysType;
418

419 420
/* the backend driver used for PCI hostdev devices */
typedef enum {
421
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automaticaly, prefer VFIO */
422 423
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM,    /* force legacy kvm style */
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO,   /* force vfio */
424
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN,    /* force legacy xen style, use pciback */
425 426

    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
427
} virDomainHostdevSubsysPCIBackendType;
428

429
VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend)
430

431 432 433 434 435 436 437 438 439
typedef enum {
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE,
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI,

    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
} virDomainHostdevSCSIProtocolType;

VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol)

440 441 442 443 444 445 446 447 448 449 450 451
typedef struct _virDomainHostdevSubsysUSB virDomainHostdevSubsysUSB;
typedef virDomainHostdevSubsysUSB *virDomainHostdevSubsysUSBPtr;
struct _virDomainHostdevSubsysUSB {
    bool autoAddress; /* bus/device were filled automatically based
                         on vendor/product */
    unsigned bus;
    unsigned device;

    unsigned vendor;
    unsigned product;
};

452 453 454 455 456 457 458
typedef struct _virDomainHostdevSubsysPCI virDomainHostdevSubsysPCI;
typedef virDomainHostdevSubsysPCI *virDomainHostdevSubsysPCIPtr;
struct _virDomainHostdevSubsysPCI {
    virDevicePCIAddress addr; /* host address */
    int backend; /* enum virDomainHostdevSubsysPCIBackendType */
};

459 460 461
typedef struct _virDomainHostdevSubsysSCSIHost virDomainHostdevSubsysSCSIHost;
typedef virDomainHostdevSubsysSCSIHost *virDomainHostdevSubsysSCSIHostPtr;
struct _virDomainHostdevSubsysSCSIHost {
462 463 464 465
    char *adapter;
    unsigned bus;
    unsigned target;
    unsigned unit;
466 467
};

468 469 470 471 472 473 474 475 476
typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI;
typedef virDomainHostdevSubsysSCSIiSCSI *virDomainHostdevSubsysSCSIiSCSIPtr;
struct _virDomainHostdevSubsysSCSIiSCSI {
    char *path;
    size_t nhosts;
    virStorageNetHostDefPtr hosts;
    virStorageAuthDefPtr auth;
};

477 478 479
typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
typedef virDomainHostdevSubsysSCSI *virDomainHostdevSubsysSCSIPtr;
struct _virDomainHostdevSubsysSCSI {
480
    int protocol; /* enum virDomainHostdevSCSIProtocolType */
481
    int sgio; /* enum virDomainDeviceSGIO */
482
    int rawio; /* enum virTristateBool */
483 484
    union {
        virDomainHostdevSubsysSCSIHost host;
485
        virDomainHostdevSubsysSCSIiSCSI iscsi;
486
    } u;
487 488
};

489 490 491
typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys {
492
    int type; /* enum virDomainHostdevSubsysType */
493
    union {
494
        virDomainHostdevSubsysUSB usb;
495
        virDomainHostdevSubsysPCI pci;
496
        virDomainHostdevSubsysSCSI scsi;
497 498 499
    } u;
};

500

501
typedef enum {
502 503
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
504
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
505 506

    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
507
} virDomainHostdevCapsType;
508

509 510 511 512 513 514 515
typedef struct _virDomainNetIpDef virDomainNetIpDef;
typedef virDomainNetIpDef *virDomainNetIpDefPtr;
struct _virDomainNetIpDef {
    virSocketAddr address;       /* ipv4 or ipv6 address */
    unsigned int prefix; /* number of 1 bits in the net mask */
};

516 517 518 519 520 521 522 523 524 525 526
typedef struct _virDomainHostdevCaps virDomainHostdevCaps;
typedef virDomainHostdevCaps *virDomainHostdevCapsPtr;
struct _virDomainHostdevCaps {
    int type; /* enum virDOmainHostdevCapsType */
    union {
        struct {
            char *block;
        } storage;
        struct {
            char *chardev;
        } misc;
527 528
        struct {
            char *iface;
529 530
            size_t nips;
            virDomainNetIpDefPtr *ips;
531
            size_t nroutes;
532
            virNetworkRouteDefPtr *routes;
533
        } net;
534 535 536 537
    } u;
};


538 539
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
540
    virDomainDeviceDef parent; /* higher level Def containing this */
541
    int mode; /* enum virDomainHostdevMode */
542
    int startupPolicy; /* enum virDomainStartupPolicy */
543
    bool managed;
544
    bool missing;
O
Osier Yang 已提交
545
    bool readonly;
546
    bool shareable;
547
    union {
548
        virDomainHostdevSubsys subsys;
549
        virDomainHostdevCaps caps;
550 551
    } source;
    virDomainHostdevOrigStates origstates;
552
    virDomainDeviceInfoPtr info; /* Guest address */
553 554
};

555

E
Eric Blake 已提交
556 557
/* Types of disk frontend (guest view).  For backends (host view), see
 * virStorageType in util/virstoragefile.h */
558
typedef enum {
559 560 561
    VIR_DOMAIN_DISK_DEVICE_DISK,
    VIR_DOMAIN_DISK_DEVICE_CDROM,
    VIR_DOMAIN_DISK_DEVICE_FLOPPY,
562
    VIR_DOMAIN_DISK_DEVICE_LUN,
563 564

    VIR_DOMAIN_DISK_DEVICE_LAST
565
} virDomainDiskDevice;
566

567
typedef enum {
568 569 570 571 572
    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,
573
    VIR_DOMAIN_DISK_BUS_USB,
574
    VIR_DOMAIN_DISK_BUS_UML,
575
    VIR_DOMAIN_DISK_BUS_SATA,
576
    VIR_DOMAIN_DISK_BUS_SD,
577 578

    VIR_DOMAIN_DISK_BUS_LAST
579
} virDomainDiskBus;
580

581
typedef enum {
582 583 584 585
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
586
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
587
    VIR_DOMAIN_DISK_CACHE_UNSAFE,
588 589

    VIR_DOMAIN_DISK_CACHE_LAST
590
} virDomainDiskCache;
591

592
typedef enum {
593 594
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
595
    VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
596
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
597
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
598 599

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
600
} virDomainDiskErrorPolicy;
601

M
MORITA Kazutaka 已提交
602

603
typedef enum {
604 605 606 607
    VIR_DOMAIN_DISK_TRAY_CLOSED,
    VIR_DOMAIN_DISK_TRAY_OPEN,

    VIR_DOMAIN_DISK_TRAY_LAST
608
} virDomainDiskTray;
609

610
typedef enum {
J
J.B. Joret 已提交
611 612 613 614 615 616
    VIR_DOMAIN_DISK_TRANS_DEFAULT = 0,
    VIR_DOMAIN_DISK_TRANS_NONE,
    VIR_DOMAIN_DISK_TRANS_AUTO,
    VIR_DOMAIN_DISK_TRANS_LBA,

    VIR_DOMAIN_DISK_TRANS_LAST
617
} virDomainDiskGeometryTrans;
J
J.B. Joret 已提交
618

619
typedef enum {
M
Matthias Dahl 已提交
620 621 622 623 624
    VIR_DOMAIN_DISK_IO_DEFAULT,
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
625
} virDomainDiskIo;
M
Matthias Dahl 已提交
626

627
typedef enum {
628 629 630 631 632 633
    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
634
} virDomainStartupPolicy;
635

636

637
typedef enum {
638 639 640
    VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
    VIR_DOMAIN_DEVICE_SGIO_FILTERED,
    VIR_DOMAIN_DEVICE_SGIO_UNFILTERED,
O
Osier Yang 已提交
641

642
    VIR_DOMAIN_DEVICE_SGIO_LAST
643
} virDomainDeviceSGIO;
O
Osier Yang 已提交
644

645
typedef enum {
O
Osier Yang 已提交
646
    VIR_DOMAIN_DISK_DISCARD_DEFAULT = 0,
O
Osier Yang 已提交
647 648
    VIR_DOMAIN_DISK_DISCARD_UNMAP,
    VIR_DOMAIN_DISK_DISCARD_IGNORE,
O
Osier Yang 已提交
649 650

    VIR_DOMAIN_DISK_DISCARD_LAST
651
} virDomainDiskDiscard;
O
Osier Yang 已提交
652

L
Lei Li 已提交
653 654 655 656 657 658 659 660
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;
661 662 663 664 665 666 667
    unsigned long long total_bytes_sec_max;
    unsigned long long read_bytes_sec_max;
    unsigned long long write_bytes_sec_max;
    unsigned long long total_iops_sec_max;
    unsigned long long read_iops_sec_max;
    unsigned long long write_iops_sec_max;
    unsigned long long size_iops_sec;
L
Lei Li 已提交
668 669 670
};
typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;

671

672 673 674 675 676 677 678 679 680 681
typedef enum {
    VIR_DOMAIN_DISK_MIRROR_STATE_NONE = 0, /* No job, or job still not synced */
    VIR_DOMAIN_DISK_MIRROR_STATE_READY, /* Job in second phase */
    VIR_DOMAIN_DISK_MIRROR_STATE_ABORT, /* Job aborted, waiting for event */
    VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT, /* Job pivoted, waiting for event */

    VIR_DOMAIN_DISK_MIRROR_STATE_LAST
} virDomainDiskMirrorState;


682 683
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
684
    virStorageSourcePtr src; /* non-NULL.  XXX Allow NULL for empty cdrom? */
685

686 687
    virObjectPtr privateData;

688 689 690 691
    int device; /* enum virDomainDiskDevice */
    int bus; /* enum virDomainDiskBus */
    char *dst;
    int tray_status; /* enum virDomainDiskTray */
J
Ján Tomko 已提交
692
    int removable; /* enum virTristateSwitch */
L
Lei Li 已提交
693

694 695 696 697
    /* ideally we want a smarter way to interlock block jobs on single qemu disk
     * in the future, but for now we just disallow any concurrent job on a
     * single disk */
    bool blockjob;
698
    virStorageSourcePtr mirror;
699
    int mirrorState; /* enum virDomainDiskMirrorState */
E
Eric Blake 已提交
700
    int mirrorJob; /* virDomainBlockJobType */
701

702 703 704 705 706 707
    /* for some synchronous block jobs, we need to notify the owner */
    virCond blockJobSyncCond;
    int blockJobType;   /* type of the block job from the event */
    int blockJobStatus; /* status of the finished block job */
    bool blockJobSync; /* the block job needs synchronized termination */

J
J.B. Joret 已提交
708 709 710 711
    struct {
        unsigned int cylinders;
        unsigned int heads;
        unsigned int sectors;
712
        int trans; /* enum virDomainDiskGeometryTrans */
J
J.B. Joret 已提交
713 714
    } geometry;

715 716 717
    struct {
        unsigned int logical_block_size;
        unsigned int physical_block_size;
V
Viktor Mihajlovski 已提交
718
    } blockio;
719

L
Lei Li 已提交
720 721
    virDomainBlockIoTuneInfo blkdeviotune;

722
    char *serial;
O
Osier Yang 已提交
723
    char *wwn;
724 725
    char *vendor;
    char *product;
726
    int cachemode; /* enum virDomainDiskCache */
727 728
    int error_policy;  /* enum virDomainDiskErrorPolicy */
    int rerror_policy; /* enum virDomainDiskErrorPolicy */
729
    int iomode; /* enum virDomainDiskIo */
J
Ján Tomko 已提交
730 731 732
    int ioeventfd; /* enum virTristateSwitch */
    int event_idx; /* enum virTristateSwitch */
    int copy_on_read; /* enum virTristateSwitch */
733
    int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
734
    int startupPolicy; /* enum virDomainStartupPolicy */
735
    bool transient;
736
    virDomainDeviceInfo info;
737
    int rawio; /* enum virTristateBool */
738
    int sgio; /* enum virDomainDeviceSGIO */
O
Osier Yang 已提交
739
    int discard; /* enum virDomainDiskDiscard */
740
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
741
    char *domain_name; /* backend domain name */
742 743 744
};


745
typedef enum {
746 747 748 749
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
750
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
751
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
752
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
J
Ján Tomko 已提交
753
    VIR_DOMAIN_CONTROLLER_TYPE_PCI,
754 755

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
756
} virDomainControllerType;
757

758

759
typedef enum {
J
Ján Tomko 已提交
760
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
L
Laine Stump 已提交
761
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
J
Ján Tomko 已提交
762
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
763
    VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
J
Ján Tomko 已提交
764 765

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
766
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
767

768
typedef enum {
769 770 771 772 773
    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,
774
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
775
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
776
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
777

778
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
779
} virDomainControllerModelSCSI;
780

781
typedef enum {
M
Marc-André Lureau 已提交
782 783 784 785 786 787 788 789 790
    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,
G
Gerd Hoffmann 已提交
791
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
792
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
M
Marc-André Lureau 已提交
793 794

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
795
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
796

797 798 799 800 801 802 803
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

804 805 806
typedef struct _virDomainPCIControllerOpts virDomainPCIControllerOpts;
typedef virDomainPCIControllerOpts *virDomainPCIControllerOptsPtr;
struct _virDomainPCIControllerOpts {
807 808 809 810
    bool pcihole64;
    unsigned long pcihole64size;
};

811 812 813
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
    int type;
814
    unsigned int idx;
815
    int model; /* -1 == undef */
816
    unsigned int queues;
817 818
    unsigned int cmd_per_lun;
    unsigned int max_sectors;
819 820
    union {
        virDomainVirtioSerialOpts vioserial;
821
        virDomainPCIControllerOpts pciopts;
822
    } opts;
823 824 825 826
    virDomainDeviceInfo info;
};


G
Giuseppe Scrivano 已提交
827
/* Types of disk backends */
828
typedef enum {
829 830 831 832 833 834
    VIR_DOMAIN_FS_TYPE_MOUNT, /* Mounts (binds) a host dir on a guest dir */
    VIR_DOMAIN_FS_TYPE_BLOCK, /* Mounts a host block dev on a guest dir */
    VIR_DOMAIN_FS_TYPE_FILE,  /* Loopback mounts a host file on a guest dir */
    VIR_DOMAIN_FS_TYPE_TEMPLATE, /* Expands a OS template to a guest dir */
    VIR_DOMAIN_FS_TYPE_RAM,   /* Mount a RAM filesystem on a guest dir */
    VIR_DOMAIN_FS_TYPE_BIND,  /* Binds a guest dir to another guest dir */
835 836

    VIR_DOMAIN_FS_TYPE_LAST
837
} virDomainFSType;
838

839
/* Filesystem driver type */
840
typedef enum {
841 842 843
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
844
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
845
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
D
Dmitry Guryanov 已提交
846
    VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
847 848

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
849
} virDomainFSDriverType;
850

851
/* Filesystem mount access mode  */
852
typedef enum {
853 854 855 856 857
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
858
} virDomainFSAccessMode;
859

860
/* Filesystem Write policy */
861
typedef enum {
862 863 864 865
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
866
} virDomainFSWrpolicy;
867

868 869 870
/* Allow 2 MB ram usage */
# define VIR_DOMAIN_FS_RAM_DEFAULT_USAGE (1024 * 2)

871 872
struct _virDomainFSDef {
    int type;
873 874
    int fsdriver; /* enum virDomainFSDriverType */
    int accessmode; /* enum virDomainFSAccessMode */
875
    int wrpolicy; /* enum virDomainFSWrpolicy */
876
    int format; /* virStorageFileFormat */
877
    unsigned long long usage; /* in bytes */
878 879
    char *src;
    char *dst;
880
    bool readonly;
881
    virDomainDeviceInfo info;
882 883
    unsigned long long space_hard_limit; /* in bytes */
    unsigned long long space_soft_limit; /* in bytes */
884
    bool symlinksResolved;
885 886 887
};


888
/* network config types */
889
typedef enum {
890 891
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
M
Michele Paolino 已提交
892
    VIR_DOMAIN_NET_TYPE_VHOSTUSER,
893 894 895 896 897
    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 已提交
898
    VIR_DOMAIN_NET_TYPE_INTERNAL,
899
    VIR_DOMAIN_NET_TYPE_DIRECT,
900
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
901

902
    VIR_DOMAIN_NET_TYPE_LAST
903
} virDomainNetType;
904

905
/* the backend driver used for virtio interfaces */
906
typedef enum {
907 908 909 910
    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 */

911
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
912
} virDomainNetBackendType;
913

914
/* the TX algorithm used for virtio interfaces */
915
typedef enum {
916 917 918 919
    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,

920
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
921
} virDomainNetVirtioTxModeType;
922

923
/* link interface states */
924
typedef enum {
925 926 927 928 929
        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
930
} virDomainNetInterfaceLinkState;
931

932 933 934 935 936 937 938 939 940 941 942 943
/* 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;
944
            int macTableManager; /* enum virNetworkBridgeMACTableManagerType */
945 946 947 948 949
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
        } direct;
950 951 952
        struct {
            virDomainHostdevDef def;
        } hostdev;
953
    } data;
954
    virNetDevVPortProfilePtr virtPortProfile;
955
    virNetDevBandwidthPtr bandwidth;
956
    virNetDevVlan vlan;
957
    int trustGuestRxFilters; /* enum virTristateBool */
958
    unsigned int class_id; /* class ID for bandwidth 'floor' */
959 960
};

961 962
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
963
    virDomainNetType type;
964
    virMacAddr mac;
965
    char *model;
966 967
    union {
        struct {
968 969
            virDomainNetBackendType name; /* which driver backend to use */
            virDomainNetVirtioTxModeType txmode;
J
Ján Tomko 已提交
970 971
            virTristateSwitch ioeventfd;
            virTristateSwitch event_idx;
972
            unsigned int queues; /* Multiqueue virtio-net */
973 974 975 976 977 978 979
            struct {
                virTristateSwitch csum;
                virTristateSwitch gso;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
980
                virTristateSwitch mrg_rxbuf;
981 982 983 984 985 986 987 988
            } host;
            struct {
                virTristateSwitch csum;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
            } guest;
989 990
        } virtio;
    } driver;
991 992 993 994
    struct {
        char *tap;
        char *vhost;
    } backend;
995 996 997 998
    union {
        struct {
            char *dev;
        } ethernet;
M
Michele Paolino 已提交
999
        virDomainChrSourceDefPtr vhostuser;
1000 1001 1002 1003 1004 1005
        struct {
            char *address;
            int port;
        } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
        struct {
            char *name;
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
            char *portgroup;
            /* 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;
1016 1017 1018 1019
        } network;
        struct {
            char *brname;
        } bridge;
D
Daniel Veillard 已提交
1020 1021 1022
        struct {
            char *name;
        } internal;
1023 1024
        struct {
            char *linkdev;
1025
            int mode; /* enum virMacvtapMode from util/macvtap.h */
1026
        } direct;
1027 1028 1029
        struct {
            virDomainHostdevDef def;
        } hostdev;
1030
    } data;
1031 1032
    /* virtPortProfile is used by network/bridge/direct/hostdev */
    virNetDevVPortProfilePtr virtPortProfile;
1033 1034 1035 1036
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
1037
    char *script;
1038
    char *domain_name; /* backend domain name */
1039
    char *ifname;
1040 1041
    char *ifname_guest;
    char *ifname_guest_actual;
1042
    virDomainDeviceInfo info;
1043 1044
    char *filter;
    virNWFilterHashTablePtr filterparams;
1045
    virNetDevBandwidthPtr bandwidth;
1046
    virNetDevVlan vlan;
1047
    int trustGuestRxFilters; /* enum virTristateBool */
1048
    int linkstate;
1049 1050
    size_t nips;
    virDomainNetIpDefPtr *ips;
1051
    size_t nroutes;
1052
    virNetworkRouteDefPtr *routes;
1053 1054
};

E
Eric Blake 已提交
1055 1056 1057 1058
/* 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"

1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
typedef enum {
    VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT = 0,
    VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED,
    VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED,

    VIR_DOMAIN_CHR_DEVICE_STATE_LAST
} virDomainChrDeviceState;

VIR_ENUM_DECL(virDomainChrDeviceState)

1069
typedef enum {
1070
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1071 1072
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1073
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1074

1075
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1076
} virDomainChrDeviceType;
1077

1078
typedef enum {
G
Guannan Ren 已提交
1079 1080 1081 1082
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1083
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1084

1085
typedef enum {
1086 1087
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
1088 1089
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,

1090
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1091
} virDomainChrChannelTargetType;
1092

1093
typedef enum {
1094 1095
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
1096 1097
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
1098
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
1099 1100
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
1101 1102
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
1103

1104
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1105
} virDomainChrConsoleTargetType;
1106

1107
typedef enum {
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117
    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,
1118
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1119
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1120
    VIR_DOMAIN_CHR_TYPE_NMDM,
1121

1122
    VIR_DOMAIN_CHR_TYPE_LAST
1123
} virDomainChrType;
1124

1125
typedef enum {
1126 1127
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW,
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1128 1129
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1130

1131
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1132
} virDomainChrTcpProtocol;
1133

1134
typedef enum {
E
Eric Blake 已提交
1135 1136
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1137
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1138

1139
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1140
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1141

1142 1143 1144
/* The host side information for a character device.  */
struct _virDomainChrSourceDef {
    int type; /* virDomainChrType */
1145
    union {
E
Eric Blake 已提交
1146
        /* no <source> for null, vc, stdio */
1147 1148 1149
        struct {
            char *path;
        } file; /* pty, file, pipe, or device */
1150 1151 1152 1153
        struct {
            char *master;
            char *slave;
        } nmdm;
1154 1155 1156
        struct {
            char *host;
            char *service;
1157
            bool listen;
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
            int protocol;
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
1168
            bool listen;
1169
        } nix;
E
Eric Blake 已提交
1170
        int spicevmc;
1171 1172 1173
        struct {
            char *channel;
        } spiceport;
1174
    } data;
1175 1176 1177 1178
};

/* A complete character device, both host and domain views.  */
struct _virDomainChrDef {
1179
    int deviceType; /* enum virDomainChrDeviceType */
G
Guannan Ren 已提交
1180 1181

    bool targetTypeAttr;
1182 1183 1184 1185
    int targetType; /* enum virDomainChrConsoleTargetType ||
                       enum virDomainChrChannelTargetType ||
                       enum virDomainChrSerialTargetType according to deviceType */

1186 1187 1188 1189 1190 1191
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

1192 1193
    virDomainChrDeviceState state;

1194
    virDomainChrSourceDef source;
1195 1196

    virDomainDeviceInfo info;
1197 1198 1199

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1200 1201
};

1202
typedef enum {
E
Eric Blake 已提交
1203 1204 1205 1206
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

1207
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1208
} virDomainSmartcardType;
E
Eric Blake 已提交
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226

# 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 已提交
1227 1228 1229 1230 1231
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

1232
typedef enum {
1233 1234 1235
    VIR_DOMAIN_TPM_MODEL_TIS,

    VIR_DOMAIN_TPM_MODEL_LAST
1236
} virDomainTPMModel;
1237

1238
typedef enum {
1239 1240 1241
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,

    VIR_DOMAIN_TPM_TYPE_LAST
1242
} virDomainTPMBackendType;
1243 1244 1245 1246

# define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"

struct _virDomainTPMDef {
1247
    virDomainTPMBackendType type;
1248
    virDomainDeviceInfo info;
1249
    virDomainTPMModel model;
1250 1251 1252 1253 1254 1255 1256
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
    } data;
};

1257
typedef enum {
1258 1259
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1260
    VIR_DOMAIN_INPUT_TYPE_KBD,
1261

1262
    VIR_DOMAIN_INPUT_TYPE_LAST
1263
} virDomainInputType;
1264

1265
typedef enum {
1266 1267 1268
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1269
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1270 1271

    VIR_DOMAIN_INPUT_BUS_LAST
1272
} virDomainInputBus;
1273 1274 1275 1276

struct _virDomainInputDef {
    int type;
    int bus;
1277
    virDomainDeviceInfo info;
1278 1279
};

1280
typedef enum {
1281 1282 1283 1284
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1285
} virDomainSoundCodecType;
1286

1287
typedef enum {
1288 1289 1290
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1291
    VIR_DOMAIN_SOUND_MODEL_AC97,
1292
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1293
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1294
    VIR_DOMAIN_SOUND_MODEL_USB,
1295 1296

    VIR_DOMAIN_SOUND_MODEL_LAST
1297
} virDomainSoundModel;
1298

1299 1300 1301 1302 1303
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1304 1305
struct _virDomainSoundDef {
    int model;
1306
    virDomainDeviceInfo info;
1307

1308
    size_t ncodecs;
1309
    virDomainSoundCodecDefPtr *codecs;
1310 1311
};

1312
typedef enum {
R
Richard Jones 已提交
1313 1314 1315 1316
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1317
} virDomainWatchdogModel;
R
Richard Jones 已提交
1318

1319
typedef enum {
R
Richard Jones 已提交
1320 1321 1322 1323
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1324
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1325 1326 1327
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1328
} virDomainWatchdogAction;
R
Richard Jones 已提交
1329 1330 1331 1332

struct _virDomainWatchdogDef {
    int model;
    int action;
1333
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1334 1335
};

1336

1337
typedef enum {
1338 1339 1340 1341 1342
    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,
1343
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1344
    VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
1345 1346

    VIR_DOMAIN_VIDEO_TYPE_LAST
1347
} virDomainVideoType;
1348 1349


1350 1351 1352
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
1353 1354
    bool support3d;
    bool support2d;
1355 1356 1357
};


1358 1359
struct _virDomainVideoDef {
    int type;
1360 1361
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1362
    unsigned int vgamem; /* kibibytes (multiples of 1024) */
1363
    unsigned int heads;
1364
    bool primary;
1365
    virDomainVideoAccelDefPtr accel;
1366
    virDomainDeviceInfo info;
1367 1368
};

1369
/* graphics console modes */
1370
typedef enum {
1371 1372
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1373 1374
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1375
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1376

1377
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1378
} virDomainGraphicsType;
1379

1380
typedef enum {
1381 1382 1383 1384 1385 1386
    VIR_DOMAIN_GRAPHICS_VNC_SHARE_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_VNC_SHARE_ALLOW_EXCLUSIVE,
    VIR_DOMAIN_GRAPHICS_VNC_SHARE_FORCE_SHARED,
    VIR_DOMAIN_GRAPHICS_VNC_SHARE_IGNORE,

    VIR_DOMAIN_GRAPHICS_VNC_SHARE_LAST
1387
} virDomainGraphicsVNCSharePolicy;
1388

1389
typedef enum {
1390 1391 1392 1393 1394 1395
    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
1396
} virDomainGraphicsAuthConnectedType;
1397

1398 1399 1400 1401
typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef;
typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr;
struct _virDomainGraphicsAuthDef {
    char *passwd;
1402
    bool expires; /* Whether there is an expiry time set */
1403
    time_t validTo;  /* seconds since epoch */
1404
    int connected; /* action if connected */
1405 1406
};

1407
typedef enum {
1408 1409 1410 1411 1412 1413
    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 已提交
1414
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1415
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1416 1417

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1418
} virDomainGraphicsSpiceChannelName;
1419

1420
typedef enum {
1421 1422 1423 1424 1425
    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
1426
} virDomainGraphicsSpiceChannelMode;
1427

1428
typedef enum {
1429 1430 1431 1432 1433 1434 1435 1436 1437
    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
1438
} virDomainGraphicsSpiceImageCompression;
1439

1440
typedef enum {
1441 1442 1443 1444 1445 1446
    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
1447
} virDomainGraphicsSpiceJpegCompression;
1448

1449
typedef enum {
1450 1451 1452 1453 1454 1455
    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
1456
} virDomainGraphicsSpiceZlibCompression;
1457

1458
typedef enum {
P
Peng Zhou 已提交
1459 1460 1461 1462 1463
    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
1464
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1465

1466
typedef enum {
1467 1468 1469 1470 1471 1472
    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
1473
} virDomainGraphicsSpiceStreamingMode;
1474

1475
typedef enum {
1476 1477 1478 1479
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,

1480
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1481
} virDomainGraphicsListenType;
1482

1483
typedef enum {
M
Marc-André Lureau 已提交
1484 1485
    VIR_DOMAIN_HUB_TYPE_USB,

1486
    VIR_DOMAIN_HUB_TYPE_LAST
1487
} virDomainHubType;
M
Marc-André Lureau 已提交
1488

1489 1490 1491 1492 1493 1494
typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef;
typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr;
struct _virDomainGraphicsListenDef {
    int type;   /* enum virDomainGraphicsListenType */
    char *address;
    char *network;
1495
    bool fromConfig;    /* true if the @address is config file originated */
1496 1497
};

1498
struct _virDomainGraphicsDef {
M
Michal Privoznik 已提交
1499 1500 1501 1502 1503
    /* 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.
     */
1504 1505 1506 1507
    int type;
    union {
        struct {
            int port;
1508
            bool portReserved;
M
Martin Kletzander 已提交
1509
            int websocket;
1510
            bool autoport;
1511
            char *keymap;
1512
            char *socket;
1513
            virDomainGraphicsAuthDef auth;
1514
            int sharePolicy;
1515 1516 1517 1518
        } vnc;
        struct {
            char *display;
            char *xauth;
1519
            bool fullscreen;
1520
        } sdl;
1521 1522
        struct {
            int port;
1523 1524 1525
            bool autoport;
            bool replaceUser;
            bool multiUser;
1526 1527 1528
        } rdp;
        struct {
            char *display;
1529
            bool fullscreen;
1530
        } desktop;
1531 1532 1533
        struct {
            int port;
            int tlsPort;
1534 1535
            bool portReserved;
            bool tlsPortReserved;
P
Peng Zhou 已提交
1536
            int mousemode;
1537
            char *keymap;
1538
            virDomainGraphicsAuthDef auth;
1539
            bool autoport;
1540
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1541
            int defaultMode; /* enum virDomainGraphicsSpiceChannelMode */
1542 1543 1544 1545
            int image;
            int jpeg;
            int zlib;
            int playback;
1546
            int streaming;
J
Ján Tomko 已提交
1547 1548
            int copypaste; /* enum virTristateBool */
            int filetransfer; /* enum virTristateBool */
1549
        } spice;
1550
    } data;
1551 1552 1553 1554 1555
    /* 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;
1556 1557
};

1558
typedef enum {
1559 1560 1561
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1562
} virDomainRedirdevBus;
1563 1564 1565 1566 1567 1568 1569 1570 1571 1572

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

    union {
        virDomainChrSourceDef chr;
    } source;

    virDomainDeviceInfo info; /* Guest address */
};
1573

1574
struct _virDomainRedirFilterUSBDevDef {
1575 1576 1577 1578
    int usbClass;
    int vendor;
    int product;
    int version;
1579
    bool allow;
1580 1581 1582 1583
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1584
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1585 1586
};

1587 1588 1589
enum {
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1590
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1591 1592 1593 1594 1595 1596 1597

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
};

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1598
    int period; /* seconds between collections */
1599 1600
};

L
Li Zhang 已提交
1601 1602 1603
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1604

1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619
struct _virDomainShmemDef {
    char *name;
    unsigned long long size;
    struct {
        bool enabled;
        char *path;
    } server;
    struct {
        bool enabled;
        unsigned vectors;
        virTristateSwitch ioeventfd;
    } msi;
    virDomainDeviceInfo info;
};

1620
typedef enum {
1621
    VIR_DOMAIN_SMBIOS_NONE = 0,
1622 1623 1624 1625 1626
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1627
} virDomainSmbiosMode;
1628

1629

1630
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1631

1632
typedef enum {
1633 1634 1635 1636 1637
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1638
    VIR_DOMAIN_BOOT_LAST
1639
} virDomainBootOrder;
1640

1641
typedef enum {
1642 1643 1644
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1645
    VIR_DOMAIN_FEATURE_HAP,
1646
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1647
    VIR_DOMAIN_FEATURE_PRIVNET,
1648
    VIR_DOMAIN_FEATURE_HYPERV,
1649
    VIR_DOMAIN_FEATURE_KVM,
1650
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1651
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1652
    VIR_DOMAIN_FEATURE_PMU,
1653
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1654
    VIR_DOMAIN_FEATURE_GIC,
1655 1656

    VIR_DOMAIN_FEATURE_LAST
1657
} virDomainFeature;
1658

1659
typedef enum {
1660
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1661 1662
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1663 1664

    VIR_DOMAIN_HYPERV_LAST
1665
} virDomainHyperv;
1666

1667 1668 1669 1670 1671 1672
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722
typedef enum {
    VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT = 0,
    VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW,
    VIR_DOMAIN_CAPABILITIES_POLICY_DENY,

    VIR_DOMAIN_CAPABILITIES_POLICY_LAST
} virDomainCapabilitiesPolicy;

/* The capabilities are ordered alphabetically to help check for new ones */
typedef enum {
    VIR_DOMAIN_CAPS_FEATURE_AUDIT_CONTROL = 0,
    VIR_DOMAIN_CAPS_FEATURE_AUDIT_WRITE,
    VIR_DOMAIN_CAPS_FEATURE_BLOCK_SUSPEND,
    VIR_DOMAIN_CAPS_FEATURE_CHOWN,
    VIR_DOMAIN_CAPS_FEATURE_DAC_OVERRIDE,
    VIR_DOMAIN_CAPS_FEATURE_DAC_READ_SEARCH,
    VIR_DOMAIN_CAPS_FEATURE_FOWNER,
    VIR_DOMAIN_CAPS_FEATURE_FSETID,
    VIR_DOMAIN_CAPS_FEATURE_IPC_LOCK,
    VIR_DOMAIN_CAPS_FEATURE_IPC_OWNER,
    VIR_DOMAIN_CAPS_FEATURE_KILL,
    VIR_DOMAIN_CAPS_FEATURE_LEASE,
    VIR_DOMAIN_CAPS_FEATURE_LINUX_IMMUTABLE,
    VIR_DOMAIN_CAPS_FEATURE_MAC_ADMIN,
    VIR_DOMAIN_CAPS_FEATURE_MAC_OVERRIDE,
    VIR_DOMAIN_CAPS_FEATURE_MKNOD,
    VIR_DOMAIN_CAPS_FEATURE_NET_ADMIN,
    VIR_DOMAIN_CAPS_FEATURE_NET_BIND_SERVICE,
    VIR_DOMAIN_CAPS_FEATURE_NET_BROADCAST,
    VIR_DOMAIN_CAPS_FEATURE_NET_RAW,
    VIR_DOMAIN_CAPS_FEATURE_SETGID,
    VIR_DOMAIN_CAPS_FEATURE_SETFCAP,
    VIR_DOMAIN_CAPS_FEATURE_SETPCAP,
    VIR_DOMAIN_CAPS_FEATURE_SETUID,
    VIR_DOMAIN_CAPS_FEATURE_SYS_ADMIN,
    VIR_DOMAIN_CAPS_FEATURE_SYS_BOOT,
    VIR_DOMAIN_CAPS_FEATURE_SYS_CHROOT,
    VIR_DOMAIN_CAPS_FEATURE_SYS_MODULE,
    VIR_DOMAIN_CAPS_FEATURE_SYS_NICE,
    VIR_DOMAIN_CAPS_FEATURE_SYS_PACCT,
    VIR_DOMAIN_CAPS_FEATURE_SYS_PTRACE,
    VIR_DOMAIN_CAPS_FEATURE_SYS_RAWIO,
    VIR_DOMAIN_CAPS_FEATURE_SYS_RESOURCE,
    VIR_DOMAIN_CAPS_FEATURE_SYS_TIME,
    VIR_DOMAIN_CAPS_FEATURE_SYS_TTY_CONFIG,
    VIR_DOMAIN_CAPS_FEATURE_SYSLOG,
    VIR_DOMAIN_CAPS_FEATURE_WAKE_ALARM,
    VIR_DOMAIN_CAPS_FEATURE_LAST
} virDomainCapsFeature;

1723
typedef enum {
1724 1725 1726 1727 1728 1729
    VIR_DOMAIN_LIFECYCLE_DESTROY,
    VIR_DOMAIN_LIFECYCLE_RESTART,
    VIR_DOMAIN_LIFECYCLE_RESTART_RENAME,
    VIR_DOMAIN_LIFECYCLE_PRESERVE,

    VIR_DOMAIN_LIFECYCLE_LAST
1730
} virDomainLifecycleAction;
1731

1732
typedef enum {
1733 1734 1735 1736 1737 1738 1739 1740
    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
1741
} virDomainLifecycleCrashAction;
1742

1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754
typedef enum {
    VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
    VIR_DOMAIN_LOCK_FAILURE_POWEROFF,
    VIR_DOMAIN_LOCK_FAILURE_RESTART,
    VIR_DOMAIN_LOCK_FAILURE_PAUSE,
    VIR_DOMAIN_LOCK_FAILURE_IGNORE,

    VIR_DOMAIN_LOCK_FAILURE_LAST
} virDomainLockFailureAction;

VIR_ENUM_DECL(virDomainLockFailure)

M
Michal Privoznik 已提交
1755 1756 1757
typedef struct _virDomainBIOSDef virDomainBIOSDef;
typedef virDomainBIOSDef *virDomainBIOSDefPtr;
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1758
    int useserial; /* enum virTristateBool */
1759 1760 1761
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1762 1763
};

1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779
typedef enum {
    VIR_DOMAIN_LOADER_TYPE_ROM = 0,
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

VIR_ENUM_DECL(virDomainLoader)

typedef struct _virDomainLoaderDef virDomainLoaderDef;
typedef virDomainLoaderDef *virDomainLoaderDefPtr;
struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
    char *nvram;    /* path to non-volatile RAM */
1780
    char *templt;   /* user override of path to master nvram */
1781 1782 1783 1784
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1785 1786 1787 1788
/* Operating system configuration data & machine / arch */
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
1789
    int type;
1790
    virArch arch;
1791
    char *machine;
1792
    size_t nBootDevs;
1793
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1794
    int bootmenu; /* enum virTristateBool */
1795 1796
    unsigned int bm_timeout;
    bool bm_timeout_set;
1797
    char *init;
1798
    char **initargv;
1799 1800 1801
    char *kernel;
    char *initrd;
    char *cmdline;
1802
    char *dtb;
1803
    char *root;
1804
    virDomainLoaderDefPtr loader;
1805 1806
    char *bootloader;
    char *bootloaderArgs;
1807
    int smbios_mode;
1808

M
Michal Privoznik 已提交
1809
    virDomainBIOSDef bios;
1810 1811
};

1812
typedef enum {
1813 1814 1815 1816 1817
    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 已提交
1818
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1819
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
1820

1821
    VIR_DOMAIN_TIMER_NAME_LAST
1822
} virDomainTimerNameType;
1823

1824
typedef enum {
1825 1826 1827
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1828

1829
    VIR_DOMAIN_TIMER_TRACK_LAST
1830
} virDomainTimerTrackType;
1831

1832
typedef enum {
1833 1834 1835 1836 1837
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

1838
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
1839
} virDomainTimerTickpolicyType;
1840

1841
typedef enum {
1842 1843 1844 1845
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
1846
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
1847

1848
    VIR_DOMAIN_TIMER_MODE_LAST
1849
} virDomainTimerModeType;
1850

1851
typedef enum {
1852
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
1853 1854
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

1855
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
1856
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
1857

1858 1859 1860 1861
typedef struct _virDomainThreadSchedParam virDomainThreadSchedParam;
typedef virDomainThreadSchedParam *virDomainThreadSchedParamPtr;
struct _virDomainThreadSchedParam {
    virBitmapPtr ids;
1862
    virProcessSchedPolicy policy;
1863 1864 1865
    int priority;
};

1866 1867 1868 1869 1870 1871 1872 1873
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

1874 1875 1876 1877 1878 1879 1880
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 */

1881 1882 1883 1884
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
1885 1886 1887 1888 1889 1890

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

1891
typedef enum {
1892 1893
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
1894
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
1895
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
1896

1897
    VIR_DOMAIN_CLOCK_OFFSET_LAST
1898
} virDomainClockOffsetType;
1899

1900
typedef enum {
1901 1902 1903
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

1904
    VIR_DOMAIN_CLOCK_BASIS_LAST
1905
} virDomainClockBasis;
1906

1907 1908 1909 1910
typedef struct _virDomainClockDef virDomainClockDef;
typedef virDomainClockDef *virDomainClockDefPtr;
struct _virDomainClockDef {
    int offset;
1911

1912
    union {
1913 1914 1915
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
1916
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
1917 1918 1919
        struct {
            long long adjustment;
            int basis;
1920 1921 1922 1923 1924 1925 1926

            /* domain start-time adjustment. This is a
             * private/internal read-only value that only exists when
             * a domain is running, and only if the clock
             * offset='variable'
             */
            long long adjustment0;
1927
        } variable;
1928 1929 1930 1931 1932

        /* Timezone name, when
         * offset == VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME */
        char *timezone;
    } data;
1933

1934
    size_t ntimers;
1935
    virDomainTimerDefPtr *timers;
1936 1937
};

1938
# define VIR_DOMAIN_CPUMASK_LEN 1024
1939

1940 1941 1942
typedef struct _virDomainPinDef virDomainPinDef;
typedef virDomainPinDef *virDomainPinDefPtr;
struct _virDomainPinDef {
1943
    int id;
H
Hu Tao 已提交
1944
    virBitmapPtr cpumask;
1945 1946
};

1947
void virDomainPinDefFree(virDomainPinDefPtr def);
1948
void virDomainPinDefArrayFree(virDomainPinDefPtr *def, int npin);
1949

1950 1951
virDomainPinDefPtr *virDomainPinDefCopy(virDomainPinDefPtr *src,
                                        int npin);
1952

1953 1954 1955
virDomainPinDefPtr virDomainPinFind(virDomainPinDefPtr *def,
                                    int npin,
                                    int id);
1956

1957 1958 1959
typedef struct _virBlkioDevice virBlkioDevice;
typedef virBlkioDevice *virBlkioDevicePtr;
struct _virBlkioDevice {
1960 1961
    char *path;
    unsigned int weight;
1962 1963 1964 1965
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
1966 1967
};

1968
typedef enum {
1969 1970 1971
    VIR_DOMAIN_RNG_MODEL_VIRTIO,

    VIR_DOMAIN_RNG_MODEL_LAST
1972
} virDomainRNGModel;
1973

1974
typedef enum {
1975 1976 1977 1978 1979
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
    /* VIR_DOMAIN_RNG_BACKEND_POOL, */

    VIR_DOMAIN_RNG_BACKEND_LAST
1980
} virDomainRNGBackend;
1981 1982 1983 1984

struct _virDomainRNGDef {
    int model;
    int backend;
1985 1986
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
1987 1988 1989 1990 1991 1992 1993 1994 1995 1996

    union {
        char *file; /* file name for 'random' source */
        virDomainChrSourceDefPtr chardev; /* a char backend for
                                             the EGD source */
    } source;

    virDomainDeviceInfo info;
};

1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */

    /* target */
    int model; /* virDomainMemoryModel */
    unsigned int targetNode;
    unsigned long long size; /* kibibytes */

    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


H
Hu Tao 已提交
2034 2035 2036 2037 2038
struct _virDomainPanicDef {
    virDomainDeviceInfo info;
};


2039
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2040
                              int ndevices);
2041

2042 2043 2044 2045 2046
typedef struct _virDomainResourceDef virDomainResourceDef;
typedef virDomainResourceDef *virDomainResourceDefPtr;
struct _virDomainResourceDef {
    char *partition;
};
2047

2048
typedef struct _virDomainHugePage virDomainHugePage;
2049 2050
typedef virDomainHugePage *virDomainHugePagePtr;

2051
struct _virDomainHugePage {
2052 2053 2054 2055
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2056 2057 2058 2059 2060 2061
typedef struct _virDomainIOThreadIDDef virDomainIOThreadIDDef;
typedef virDomainIOThreadIDDef *virDomainIOThreadIDDefPtr;

struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2062
    int thread_id;
2063
    virBitmapPtr cpumask;
2064 2065 2066 2067
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078
typedef struct _virDomainCputune virDomainCputune;
typedef virDomainCputune *virDomainCputunePtr;

struct _virDomainCputune {
    unsigned long shares;
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
    unsigned long long emulator_period;
    long long emulator_quota;
    size_t nvcpupin;
2079 2080
    virDomainPinDefPtr *vcpupin;
    virDomainPinDefPtr emulatorpin;
2081 2082 2083 2084 2085

    size_t nvcpusched;
    virDomainThreadSchedParamPtr vcpusched;
    size_t niothreadsched;
    virDomainThreadSchedParamPtr iothreadsched;
2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101
};

typedef struct _virDomainBlkiotune virDomainBlkiotune;
typedef virDomainBlkiotune *virDomainBlkiotunePtr;

struct _virDomainBlkiotune {
    unsigned int weight;

    size_t ndevices;
    virBlkioDevicePtr devices;
};

typedef struct _virDomainMemtune virDomainMemtune;
typedef virDomainMemtune *virDomainMemtunePtr;

struct _virDomainMemtune {
2102 2103 2104 2105
    unsigned long long max_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetMaxMemory */
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2106 2107 2108 2109

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2110 2111 2112 2113
    /* maximum supported memory for a guest, for hotplugging */
    unsigned long long max_memory; /* in kibibytes */
    unsigned int memory_slots; /* maximum count of RAM memory slots */

2114 2115 2116
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2117 2118 2119 2120
    unsigned long long hard_limit; /* in kibibytes, limit at off_t bytes */
    unsigned long long soft_limit; /* in kibibytes, limit at off_t bytes */
    unsigned long long min_guarantee; /* in kibibytes, limit at off_t bytes */
    unsigned long long swap_hard_limit; /* in kibibytes, limit at off_t bytes */
2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131
};

typedef struct _virDomainPowerManagement virDomainPowerManagement;
typedef virDomainPowerManagement *virDomainPowerManagementPtr;

struct _virDomainPowerManagement {
    /* These options are of type enum virTristateBool */
    int s3;
    int s4;
};

2132 2133 2134 2135 2136 2137
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
2138 2139
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
2140 2141 2142 2143 2144
struct _virDomainDef {
    int virtType;
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
    char *name;
2145
    char *title;
2146
    char *description;
2147

2148 2149
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2150

E
Eric Blake 已提交
2151 2152
    unsigned short vcpus;
    unsigned short maxvcpus;
O
Osier Yang 已提交
2153
    int placement_mode;
H
Hu Tao 已提交
2154
    virBitmapPtr cpumask;
2155

2156
    unsigned int iothreads;
2157 2158
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2159

2160
    virDomainCputune cputune;
2161

2162
    virDomainNumaPtr numa;
2163
    virDomainResourceDefPtr resource;
2164
    virDomainIdMapDef idmap;
2165

2166 2167 2168 2169 2170
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2171 2172
    int onLockFailure; /* enum virDomainLockFailureAction */

2173
    virDomainPowerManagement pm;
2174

2175 2176
    virDomainOSDef os;
    char *emulator;
2177 2178 2179
    /* These three options are of type virTristateSwitch,
     * except VIR_DOMAIN_FEATURE_CAPABILITIES that is of type
     * virDomainCapabilitiesPolicy */
2180
    int features[VIR_DOMAIN_FEATURE_LAST];
2181
    int apic_eoi;
2182
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2183
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2184
    unsigned int hyperv_spinlocks;
M
Michal Privoznik 已提交
2185
    unsigned int gic_version;
2186

J
Ján Tomko 已提交
2187
    /* These options are of type virTristateSwitch: ON = keep, OFF = drop */
2188 2189
    int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];

2190
    virDomainClockDef clock;
2191

2192
    size_t ngraphics;
2193
    virDomainGraphicsDefPtr *graphics;
2194

2195
    size_t ndisks;
2196 2197
    virDomainDiskDefPtr *disks;

2198
    size_t ncontrollers;
2199 2200
    virDomainControllerDefPtr *controllers;

2201
    size_t nfss;
2202 2203
    virDomainFSDefPtr *fss;

2204
    size_t nnets;
2205 2206
    virDomainNetDefPtr *nets;

2207
    size_t ninputs;
2208 2209
    virDomainInputDefPtr *inputs;

2210
    size_t nsounds;
2211 2212
    virDomainSoundDefPtr *sounds;

2213
    size_t nvideos;
2214 2215
    virDomainVideoDefPtr *videos;

2216
    size_t nhostdevs;
2217 2218
    virDomainHostdevDefPtr *hostdevs;

2219
    size_t nredirdevs;
2220 2221
    virDomainRedirdevDefPtr *redirdevs;

2222
    size_t nsmartcards;
E
Eric Blake 已提交
2223 2224
    virDomainSmartcardDefPtr *smartcards;

2225
    size_t nserials;
2226 2227
    virDomainChrDefPtr *serials;

2228
    size_t nparallels;
2229 2230
    virDomainChrDefPtr *parallels;

2231
    size_t nchannels;
2232 2233
    virDomainChrDefPtr *channels;

2234
    size_t nconsoles;
2235 2236
    virDomainChrDefPtr *consoles;

2237
    size_t nleases;
2238 2239
    virDomainLeaseDefPtr *leases;

2240
    size_t nhubs;
M
Marc-André Lureau 已提交
2241 2242
    virDomainHubDefPtr *hubs;

2243 2244 2245
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2246 2247 2248
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2249 2250 2251
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2252 2253 2254
    size_t nmems;
    virDomainMemoryDefPtr *mems;

2255
    /* Only 1 */
R
Richard Jones 已提交
2256
    virDomainWatchdogDefPtr watchdog;
2257
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2258
    virDomainNVRAMDefPtr nvram;
2259
    virDomainTPMDefPtr tpm;
2260
    virCPUDefPtr cpu;
2261
    virSysinfoDefPtr sysinfo;
2262
    virDomainRedirFilterDefPtr redirfilter;
H
Hu Tao 已提交
2263
    virDomainPanicDefPtr panic;
2264 2265 2266

    void *namespaceData;
    virDomainXMLNamespace ns;
2267 2268 2269

    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2270 2271
};

2272 2273 2274 2275
unsigned long long virDomainDefGetMemoryInitial(virDomainDefPtr def);
void virDomainDefSetMemoryInitial(virDomainDefPtr def, unsigned long long size);
unsigned long long virDomainDefGetMemoryActual(virDomainDefPtr def);

2276
typedef enum {
2277 2278 2279 2280 2281
    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 */
2282
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2283
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2284
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2285 2286

    VIR_DOMAIN_TAINT_LAST
2287
} virDomainTaintFlags;
2288

2289
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2290 2291 2292 2293 2294 2295
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2296 2297 2298
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
2299
    virObjectLockable parent;
2300

2301
    pid_t pid;
J
Jiri Denemark 已提交
2302
    virDomainStateReason state;
2303 2304 2305

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2306
    unsigned int updated : 1;
2307
    unsigned int removing : 1;
2308 2309 2310

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

2312
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2313 2314
    virDomainSnapshotObjPtr current_snapshot;

2315 2316
    bool hasManagedSave;

2317 2318
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2319 2320

    int taint;
2321 2322
};

2323 2324
typedef struct _virDomainObjList virDomainObjList;
typedef virDomainObjList *virDomainObjListPtr;
2325

2326 2327
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2328

2329 2330 2331

/* This structure holds various callbacks and data needed
 * while parsing and creating domain XMLs */
2332 2333
typedef struct _virDomainXMLOption virDomainXMLOption;
typedef virDomainXMLOption *virDomainXMLOptionPtr;
2334 2335 2336

typedef void *(*virDomainXMLPrivateDataAllocFunc)(void);
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
2337
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
2338 2339 2340
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *);

2341 2342
/* Called once after everything else has been parsed, for adjusting
 * overall domain defaults.  */
2343 2344 2345
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
                                             virCapsPtr caps,
                                             void *opaque);
2346 2347
/* Called once per device, for adjusting per-device settings while
 * leaving the overall domain otherwise unchanged.  */
2348
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
2349
                                                   const virDomainDef *def,
2350 2351 2352 2353 2354 2355
                                                   virCapsPtr caps,
                                                   void *opaque);

typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
struct _virDomainDefParserConfig {
2356
    /* driver domain definition callbacks */
2357 2358 2359
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;

2360
    /* private data for the callbacks */
2361 2362
    void *priv;
    virFreeCallback privFree;
2363 2364

    /* data */
2365
    bool hasWideSCSIBus;
2366
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2367 2368
};

2369 2370 2371 2372 2373
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
2374
    virDomainXMLPrivateDataNewFunc    diskNew;
2375 2376 2377 2378
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
};

2379 2380 2381
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
                                            virDomainXMLNamespacePtr xmlns);
2382

2383 2384
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2385
virDomainXMLNamespacePtr
2386
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2387 2388
    ATTRIBUTE_NONNULL(1);

2389 2390 2391 2392 2393
int
virDomainDefPostParse(virDomainDefPtr def,
                      virCapsPtr caps,
                      virDomainXMLOptionPtr xmlopt);

2394
static inline bool
D
Daniel P. Berrange 已提交
2395
virDomainObjIsActive(virDomainObjPtr dom)
2396 2397 2398 2399
{
    return dom->def->id != -1;
}

2400
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2401
    ATTRIBUTE_NONNULL(1);
2402

2403
virDomainObjListPtr virDomainObjListNew(void);
2404

2405
virDomainObjPtr virDomainObjListFindByID(virDomainObjListPtr doms,
2406
                                         int id);
2407
virDomainObjPtr virDomainObjListFindByUUID(virDomainObjListPtr doms,
2408
                                           const unsigned char *uuid);
2409 2410
virDomainObjPtr virDomainObjListFindByUUIDRef(virDomainObjListPtr doms,
                                              const unsigned char *uuid);
2411
virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
2412
                                           const char *name);
2413

M
Michal Privoznik 已提交
2414 2415
void virDomainObjEndAPI(virDomainObjPtr *vm);

2416
bool virDomainObjTaint(virDomainObjPtr obj,
2417
                       virDomainTaintFlags taint);
2418

2419 2420

int virDomainDefCheckUnsupportedMemoryHotplug(virDomainDefPtr def);
2421
int virDomainDeviceDefCheckUnsupportedMemoryDevice(virDomainDeviceDefPtr dev);
2422

H
Hu Tao 已提交
2423
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2424
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2425 2426
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
2427
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2428
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2429
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2430 2431 2432 2433 2434 2435 2436 2437 2438 2439
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
const char *virDomainDiskGetSource(virDomainDiskDefPtr def);
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
    ATTRIBUTE_RETURN_CHECK;
const char *virDomainDiskGetDriver(virDomainDiskDefPtr def);
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
    ATTRIBUTE_RETURN_CHECK;
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
H
Han Cheng 已提交
2440 2441 2442
int virDomainDeviceFindControllerModel(virDomainDefPtr def,
                                       virDomainDeviceInfoPtr info,
                                       int controllerType);
2443 2444 2445
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2446
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2447
void virDomainFSDefFree(virDomainFSDefPtr def);
2448
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
2449
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2450
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2451
void virDomainChrDefFree(virDomainChrDefPtr def);
2452
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
2453 2454
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr src,
                              virDomainChrSourceDefPtr dest);
2455
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
2456
void virDomainSoundDefFree(virDomainSoundDefPtr def);
2457
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2458
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2459
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
2460
void virDomainVideoDefFree(virDomainVideoDefPtr def);
2461 2462
virDomainHostdevDefPtr virDomainHostdevDefAlloc(void);
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2463
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2464
void virDomainHubDefFree(virDomainHubDefPtr def);
2465
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2466
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2467
void virDomainShmemDefFree(virDomainShmemDefPtr def);
2468
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2469
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2470
                                             const virDomainDef *def,
2471 2472
                                             virCapsPtr caps,
                                             virDomainXMLOptionPtr xmlopt);
2473 2474
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                  int type);
2475
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
2476 2477
int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst,
                            virDomainDeviceInfoPtr src);
2478
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
2479
void virDomainDefClearPCIAddresses(virDomainDefPtr def);
2480
void virDomainDefClearCCWAddresses(virDomainDefPtr def);
D
Daniel P. Berrange 已提交
2481
void virDomainDefClearDeviceAliases(virDomainDefPtr def);
2482
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2483

2484
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2485 2486
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2487 2488 2489 2490 2491 2492
                                           void *opaque);

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

2493 2494 2495 2496
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

2497 2498
void virDomainDefFree(virDomainDefPtr vm);

M
Michal Novotny 已提交
2499 2500
virDomainChrDefPtr virDomainChrDefNew(void);

2501 2502 2503 2504
virDomainDefPtr virDomainDefNew(void);
virDomainDefPtr virDomainDefNewFull(const char *name,
                                    const unsigned char *uuid,
                                    int id);
2505

2506 2507 2508 2509
enum {
    VIR_DOMAIN_OBJ_LIST_ADD_LIVE = (1 << 0),
    VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1),
};
2510
virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms,
2511
                                    virDomainDefPtr def,
2512
                                    virDomainXMLOptionPtr xmlopt,
2513 2514
                                    unsigned int flags,
                                    virDomainDefPtr *oldDef);
2515
void virDomainObjAssignDef(virDomainObjPtr domain,
2516
                           virDomainDefPtr def,
2517 2518
                           bool live,
                           virDomainDefPtr *oldDef);
2519
int virDomainObjSetDefTransient(virCapsPtr caps,
2520
                                virDomainXMLOptionPtr xmlopt,
2521 2522
                                virDomainObjPtr domain,
                                bool live);
2523 2524
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
2525
                             virDomainXMLOptionPtr xmlopt,
2526
                             virDomainObjPtr domain);
2527 2528 2529

int
virDomainLiveConfigHelperMethod(virCapsPtr caps,
2530
                                virDomainXMLOptionPtr xmlopt,
2531 2532 2533 2534
                                virDomainObjPtr dom,
                                unsigned int *flags,
                                virDomainDefPtr *persistentDef);

2535 2536 2537 2538 2539 2540 2541
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virCapsPtr caps,
                                 virDomainXMLOptionPtr xmlopt,
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt);
2542

2543 2544
void virDomainObjListRemove(virDomainObjListPtr doms,
                            virDomainObjPtr dom);
2545 2546
void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
                                  virDomainObjPtr dom);
2547

2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
    VIR_DOMAIN_DEF_PARSE_INACTIVE        = 1 << 1,
    /* parse <actual> element */
    VIR_DOMAIN_DEF_PARSE_ACTUAL_NET      = 1 << 2,
    /* parse original states of host PCI device */
    VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES = 1 << 3,
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST    = 1 << 6,
    /* parse only source half of <disk> */
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 7,
2561
    VIR_DOMAIN_DEF_PARSE_VALIDATE        = 1 << 8,
2562 2563 2564 2565
    /* don't validate os.type and arch against capabilities. Prevents
     * VMs from disappearing when qemu is removed and libvirtd is restarted
     */
    VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS = 1 << 9,
2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
    VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU      = 1 << 2,
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 3,
    /* format internal domain status information */
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 4,
    /* format <actual> element */
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 5,
    /* format original states of host PCI device */
    VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES = 1 << 6,
    VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM       = 1 << 7,
    VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT      = 1 << 8,
    VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST    = 1 << 9,
} virDomainDefFormatFlags;

2584
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
2585
                                              const virDomainDef *def,
2586 2587
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
2588
                                              unsigned int flags);
2589 2590 2591 2592
virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr,
                                                const virDomainDef *def,
                                                virDomainXMLOptionPtr xmlopt,
                                                unsigned int flags);
2593 2594
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                        virCapsPtr caps,
2595
                                        virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
2596
                                        unsigned int flags);
2597 2598
virDomainDefPtr virDomainDefParseFile(const char *filename,
                                      virCapsPtr caps,
2599
                                      virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
2600
                                      unsigned int flags);
2601
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
2602
                                      xmlNodePtr root,
2603 2604
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
2605
                                      unsigned int flags);
2606 2607 2608 2609 2610
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
2611 2612 2613 2614
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
2615

2616 2617 2618
bool virDomainDefCheckABIStability(virDomainDefPtr src,
                                   virDomainDefPtr dst);

2619
int virDomainDefAddImplicitControllers(virDomainDefPtr def);
2620

2621 2622 2623 2624 2625
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(virDomainDefPtr def,
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);
2626
void virDomainIOThreadSchedDelId(virDomainDefPtr def, unsigned int iothread_id);
2627

2628 2629
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

2630
char *virDomainDefFormat(virDomainDefPtr def,
L
Laine Stump 已提交
2631
                         unsigned int flags);
2632 2633 2634
char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
                         virDomainObjPtr obj,
                         unsigned int flags);
2635 2636 2637
int virDomainDefFormatInternal(virDomainDefPtr def,
                               unsigned int flags,
                               virBufferPtr buf);
2638

2639 2640 2641 2642
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
                              int policy,
                              unsigned int flags);
2643

2644 2645 2646 2647
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
                          unsigned int flags);

2648 2649 2650 2651 2652 2653
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

2654
int virDomainDefCompatibleDevice(virDomainDefPtr def,
2655 2656
                                 virDomainDeviceDefPtr dev,
                                 virDomainDeviceAction action);
2657

2658 2659 2660 2661 2662
int virDomainPinAdd(virDomainPinDefPtr **pindef_list,
                    size_t *npin,
                    unsigned char *cpumap,
                    int maplen,
                    int id);
2663

2664 2665 2666
void virDomainPinDel(virDomainPinDefPtr **pindef_list,
                     size_t *npin,
                     int vcpu);
2667

2668 2669 2670 2671 2672 2673
int virDomainEmulatorPinAdd(virDomainDefPtr def,
                              unsigned char *cpumap,
                              int maplen);

int virDomainEmulatorPinDel(virDomainDefPtr def);

2674 2675
void virDomainRNGDefFree(virDomainRNGDefPtr def);

2676
bool virDomainDiskDefDstDuplicates(virDomainDefPtr def);
2677 2678 2679 2680
int virDomainDiskIndexByAddress(virDomainDefPtr def,
                                virDevicePCIAddressPtr pci_controller,
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
2681 2682 2683
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
2684
int virDomainDiskInsert(virDomainDefPtr def,
2685 2686
                        virDomainDiskDefPtr disk)
    ATTRIBUTE_RETURN_CHECK;
2687 2688
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
2689 2690
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
                                  virDomainDiskDefPtr def);
2691

2692 2693 2694 2695
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
2696
int virDomainDiskSourceParse(xmlNodePtr node,
2697
                             xmlXPathContextPtr ctxt,
2698
                             virStorageSourcePtr src);
2699

2700 2701
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
2702
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
2703
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
2704
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
2705
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
2706

L
Laine Stump 已提交
2707
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
2708 2709
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
2710 2711 2712
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

2713
int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
2714
            ATTRIBUTE_NONNULL(1);
2715
int virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t i, int val)
2716 2717
            ATTRIBUTE_NONNULL(1);
const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
2718
                                              size_t i)
2719 2720
            ATTRIBUTE_NONNULL(1);
int virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
2721
                                      size_t i, const char *address,
2722 2723 2724
                                      int len, bool setType)
            ATTRIBUTE_NONNULL(1);
const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def,
2725
                                              size_t i)
2726 2727
            ATTRIBUTE_NONNULL(1);
int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
2728
                                      size_t i, const char *network, int len)
2729 2730
            ATTRIBUTE_NONNULL(1);

2731
int virDomainNetGetActualType(virDomainNetDefPtr iface);
2732
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
2733
int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
2734
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
2735
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
2736
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
2737
virNetDevVPortProfilePtr
2738
virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface);
2739
virNetDevBandwidthPtr
2740
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
2741
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
2742
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
2743 2744 2745 2746
int virDomainNetAppendIpAddress(virDomainNetDefPtr def,
                                const char *address,
                                int family,
                                unsigned int prefix);
2747

2748
int virDomainControllerInsert(virDomainDefPtr def,
2749 2750
                              virDomainControllerDefPtr controller)
    ATTRIBUTE_RETURN_CHECK;
2751 2752
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
2753
int virDomainControllerFind(virDomainDefPtr def, int type, int idx);
2754
int virDomainControllerFindByType(virDomainDefPtr def, int type);
2755 2756
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
                                        virDevicePCIAddressPtr addr);
2757
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
2758 2759 2760 2761 2762

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
2763 2764
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
    ATTRIBUTE_RETURN_CHECK;
2765 2766
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
2767 2768 2769 2770 2771
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
2772

2773
void
2774
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
2775
                          virDomainChrDeviceType type,
2776 2777 2778
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
2779 2780 2781
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
2782 2783 2784
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
2785
int
2786 2787 2788 2789 2790
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
2791 2792 2793 2794
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

2795 2796 2797 2798 2799 2800
int virDomainRNGInsert(virDomainDefPtr def,
                       virDomainRNGDefPtr rng,
                       bool inplace);
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

2801
int virDomainSaveXML(const char *configDir,
2802 2803 2804
                     virDomainDefPtr def,
                     const char *xml);

2805
int virDomainSaveConfig(const char *configDir,
2806
                        virDomainDefPtr def);
2807
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
2808
                        const char *statusDir,
2809
                        virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
2810

2811 2812 2813 2814
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

2815 2816 2817 2818
int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
                                   const char *configDir,
                                   const char *autostartDir,
                                   int liveStatus,
2819 2820
                                   virCapsPtr caps,
                                   virDomainXMLOptionPtr xmlopt,
2821 2822
                                   virDomainLoadConfigNotify notify,
                                   void *opaque);
2823

2824
int virDomainDeleteConfig(const char *configDir,
2825
                          const char *autostartDir,
2826 2827
                          virDomainObjPtr dom);

2828
char *virDomainConfigFile(const char *dir,
2829 2830
                          const char *name);

2831 2832 2833 2834
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

2835
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
2836
                                                  const char *target);
2837
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
2838
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
2839 2840
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

2841
int virDomainVideoDefaultType(const virDomainDef *def);
2842 2843
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
2844

2845 2846
int virDomainObjListNumOfDomains(virDomainObjListPtr doms,
                                 bool active,
2847
                                 virDomainObjListACLFilter filter,
2848
                                 virConnectPtr conn);
2849 2850 2851

int virDomainObjListGetActiveIDs(virDomainObjListPtr doms,
                                 int *ids,
2852
                                 int maxids,
2853
                                 virDomainObjListACLFilter filter,
2854
                                 virConnectPtr conn);
2855 2856
int virDomainObjListGetInactiveNames(virDomainObjListPtr doms,
                                     char **const names,
2857
                                     int maxnames,
2858
                                     virDomainObjListACLFilter filter,
2859
                                     virConnectPtr conn);
2860

2861 2862 2863 2864 2865 2866 2867
typedef int (*virDomainObjListIterator)(virDomainObjPtr dom,
                                        void *opaque);

int virDomainObjListForEach(virDomainObjListPtr doms,
                            virDomainObjListIterator callback,
                            void *opaque);

E
Eric Blake 已提交
2868 2869 2870 2871 2872 2873 2874 2875 2876
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

2877 2878 2879 2880 2881 2882 2883 2884 2885
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

2886 2887 2888 2889 2890 2891 2892 2893 2894 2895
typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
                                            const char *path,
                                            size_t depth,
                                            void *opaque);

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

J
Jiri Denemark 已提交
2896 2897 2898 2899 2900 2901 2902
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

2903 2904 2905
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

2906 2907 2908
virSecurityDeviceLabelDefPtr
virDomainChrDefGetSecurityLabelDef(virDomainChrDefPtr def, const char *model);

2909 2910
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
2911

2912 2913 2914 2915 2916 2917 2918 2919 2920 2921
int virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
virDomainMemoryDefPtr virDomainMemoryRemove(virDomainDefPtr def, int idx)
    ATTRIBUTE_NONNULL(1);
int virDomainMemoryFindByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

2922
VIR_ENUM_DECL(virDomainTaint)
2923 2924 2925
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
VIR_ENUM_DECL(virDomainFeature)
2926 2927
VIR_ENUM_DECL(virDomainCapabilitiesPolicy)
VIR_ENUM_DECL(virDomainCapsFeature)
2928
VIR_ENUM_DECL(virDomainLifecycle)
2929
VIR_ENUM_DECL(virDomainLifecycleCrash)
2930
VIR_ENUM_DECL(virDomainDevice)
2931
VIR_ENUM_DECL(virDomainDeviceAddress)
2932
VIR_ENUM_DECL(virDomainDiskDevice)
J
J.B. Joret 已提交
2933
VIR_ENUM_DECL(virDomainDiskGeometryTrans)
2934
VIR_ENUM_DECL(virDomainDiskBus)
2935
VIR_ENUM_DECL(virDomainDiskCache)
2936
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
M
Matthias Dahl 已提交
2937
VIR_ENUM_DECL(virDomainDiskIo)
2938
VIR_ENUM_DECL(virDomainDeviceSGIO)
2939
VIR_ENUM_DECL(virDomainDiskTray)
O
Osier Yang 已提交
2940
VIR_ENUM_DECL(virDomainDiskDiscard)
2941
VIR_ENUM_DECL(virDomainDiskMirrorState)
2942
VIR_ENUM_DECL(virDomainController)
J
Ján Tomko 已提交
2943
VIR_ENUM_DECL(virDomainControllerModelPCI)
2944
VIR_ENUM_DECL(virDomainControllerModelSCSI)
M
Marc-André Lureau 已提交
2945
VIR_ENUM_DECL(virDomainControllerModelUSB)
2946
VIR_ENUM_DECL(virDomainFS)
2947
VIR_ENUM_DECL(virDomainFSDriver)
2948
VIR_ENUM_DECL(virDomainFSAccessMode)
2949
VIR_ENUM_DECL(virDomainFSWrpolicy)
2950
VIR_ENUM_DECL(virDomainNet)
2951
VIR_ENUM_DECL(virDomainNetBackend)
2952
VIR_ENUM_DECL(virDomainNetVirtioTxMode)
2953
VIR_ENUM_DECL(virDomainNetInterfaceLinkState)
2954
VIR_ENUM_DECL(virDomainChrDevice)
2955
VIR_ENUM_DECL(virDomainChrChannelTarget)
2956
VIR_ENUM_DECL(virDomainChrConsoleTarget)
G
Guannan Ren 已提交
2957
VIR_ENUM_DECL(virDomainChrSerialTarget)
E
Eric Blake 已提交
2958
VIR_ENUM_DECL(virDomainSmartcard)
2959
VIR_ENUM_DECL(virDomainChr)
2960
VIR_ENUM_DECL(virDomainChrTcpProtocol)
E
Eric Blake 已提交
2961
VIR_ENUM_DECL(virDomainChrSpicevmc)
2962
VIR_ENUM_DECL(virDomainSoundCodec)
2963
VIR_ENUM_DECL(virDomainSoundModel)
2964
VIR_ENUM_DECL(virDomainMemballoonModel)
2965
VIR_ENUM_DECL(virDomainSmbiosMode)
R
Richard Jones 已提交
2966 2967
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
2968
VIR_ENUM_DECL(virDomainVideo)
2969 2970
VIR_ENUM_DECL(virDomainHostdevMode)
VIR_ENUM_DECL(virDomainHostdevSubsys)
2971
VIR_ENUM_DECL(virDomainHostdevCaps)
M
Marc-André Lureau 已提交
2972
VIR_ENUM_DECL(virDomainHub)
2973
VIR_ENUM_DECL(virDomainRedirdevBus)
2974 2975 2976
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
2977
VIR_ENUM_DECL(virDomainGraphicsListen)
2978
VIR_ENUM_DECL(virDomainGraphicsAuthConnected)
2979 2980
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
2981 2982 2983
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
2984
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
P
Peng Zhou 已提交
2985
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
2986
VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy)
2987
VIR_ENUM_DECL(virDomainHyperv)
2988
VIR_ENUM_DECL(virDomainKVM)
2989 2990
VIR_ENUM_DECL(virDomainRNGModel)
VIR_ENUM_DECL(virDomainRNGBackend)
2991 2992
VIR_ENUM_DECL(virDomainTPMModel)
VIR_ENUM_DECL(virDomainTPMBackend)
2993 2994
VIR_ENUM_DECL(virDomainMemoryModel)
VIR_ENUM_DECL(virDomainMemoryBackingModel)
2995 2996
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
J
Jiri Denemark 已提交
2997 2998 2999 3000 3001 3002 3003
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)
3004
VIR_ENUM_DECL(virDomainPMSuspendedReason)
J
Jiri Denemark 已提交
3005 3006 3007 3008

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

3009
VIR_ENUM_DECL(virDomainSeclabel)
3010
VIR_ENUM_DECL(virDomainClockOffset)
3011
VIR_ENUM_DECL(virDomainClockBasis)
3012

3013
VIR_ENUM_DECL(virDomainTimerName)
3014
VIR_ENUM_DECL(virDomainTimerTrack)
3015 3016
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)
O
Osier Yang 已提交
3017
VIR_ENUM_DECL(virDomainCpuPlacementMode)
3018

3019
VIR_ENUM_DECL(virDomainStartupPolicy)
3020

O
Osier Yang 已提交
3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054
# define VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE   \
                (VIR_CONNECT_LIST_DOMAINS_ACTIVE | \
                 VIR_CONNECT_LIST_DOMAINS_INACTIVE)

# define VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT   \
                (VIR_CONNECT_LIST_DOMAINS_PERSISTENT | \
                 VIR_CONNECT_LIST_DOMAINS_TRANSIENT)

# define VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE     \
                (VIR_CONNECT_LIST_DOMAINS_RUNNING | \
                 VIR_CONNECT_LIST_DOMAINS_PAUSED  | \
                 VIR_CONNECT_LIST_DOMAINS_SHUTOFF | \
                 VIR_CONNECT_LIST_DOMAINS_OTHER)

# define VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE   \
                (VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE | \
                 VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE)

# define VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART   \
                (VIR_CONNECT_LIST_DOMAINS_AUTOSTART | \
                 VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)

# define VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT       \
                (VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT | \
                 VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT)

# define VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL                   \
                (VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE      | \
                 VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT  | \
                 VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE       | \
                 VIR_CONNECT_LIST_DOMAINS_FILTERS_MANAGEDSAVE | \
                 VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART   | \
                 VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)

3055 3056 3057 3058 3059 3060
int virDomainObjListCollect(virDomainObjListPtr doms,
                            virConnectPtr conn,
                            virDomainObjPtr **vms,
                            size_t *nvms,
                            virDomainObjListACLFilter filter,
                            unsigned int flags);
3061 3062 3063
int virDomainObjListExport(virDomainObjListPtr doms,
                           virConnectPtr conn,
                           virDomainPtr **domains,
3064
                           virDomainObjListACLFilter filter,
3065
                           unsigned int flags);
3066 3067 3068 3069 3070 3071 3072 3073 3074
int virDomainObjListConvert(virDomainObjListPtr domlist,
                            virConnectPtr conn,
                            virDomainPtr *doms,
                            size_t ndoms,
                            virDomainObjPtr **vms,
                            size_t *nvms,
                            virDomainObjListACLFilter filter,
                            unsigned int flags,
                            bool skip_missing);
O
Osier Yang 已提交
3075

3076 3077 3078 3079 3080
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3081 3082 3083 3084
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3085

3086 3087
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3088 3089
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3090 3091
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3092

3093
bool virDomainDiskSourceIsBlockType(virStorageSourcePtr src)
3094 3095
    ATTRIBUTE_NONNULL(1);

3096 3097
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3098 3099 3100 3101 3102 3103 3104
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              virCapsPtr caps,
                              virDomainXMLOptionPtr xmlopt,
                              unsigned int flags);

3105 3106 3107 3108 3109 3110 3111
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
3112
                            const char *stateDir,
3113 3114 3115
                            const char *configDir,
                            unsigned int flags);

3116 3117 3118 3119 3120 3121 3122 3123
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3124 3125 3126
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3127 3128 3129
int virDomainDefCheckDuplicateDiskWWN(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3130
#endif /* __DOMAIN_CONF_H */