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

#ifndef __DOMAIN_CONF_H
25
# define __DOMAIN_CONF_H
26

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

31 32
# include "internal.h"
# include "capabilities.h"
33
# include "virstorageencryption.h"
34
# include "cpu_conf.h"
35
# include "virthread.h"
36
# include "virhash.h"
37
# include "virsocketaddr.h"
38
# include "nwfilter_params.h"
39
# include "numatune_conf.h"
40
# include "virnetdevmacvlan.h"
41
# include "virsysinfo.h"
42
# include "virnetdevvportprofile.h"
A
Ansis Atteka 已提交
43
# include "virnetdevopenvswitch.h"
44
# include "virnetdevbandwidth.h"
45
# include "virnetdevvlan.h"
46
# include "virobject.h"
47
# include "device_conf.h"
48
# include "virbitmap.h"
49
# include "virstoragefile.h"
50
# include "virseclabel.h"
51

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

73 74 75
typedef struct _virDomainSoundCodecDef virDomainSoundCodecDef;
typedef virDomainSoundCodecDef *virDomainSoundCodecDefPtr;

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

97 98
typedef struct _virDomainRedirFilterUSBDevDef virDomainRedirFilterUSBDevDef;
typedef virDomainRedirFilterUSBDevDef *virDomainRedirFilterUSBDevDefPtr;
99 100 101 102

typedef struct _virDomainRedirFilterDef virDomainRedirFilterDef;
typedef virDomainRedirFilterDef *virDomainRedirFilterDefPtr;

103 104 105 106 107 108 109 110 111
typedef struct _virDomainSmartcardDef virDomainSmartcardDef;
typedef virDomainSmartcardDef *virDomainSmartcardDefPtr;

typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr;

typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;

L
Li Zhang 已提交
112 113 114
typedef struct _virDomainNVRAMDef virDomainNVRAMDef;
typedef virDomainNVRAMDef *virDomainNVRAMDefPtr;

115 116 117 118 119 120
typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;

typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
typedef virDomainSnapshotObjList *virDomainSnapshotObjListPtr;

121 122 123
typedef struct _virDomainRNGDef virDomainRNGDef;
typedef virDomainRNGDef *virDomainRNGDefPtr;

124 125 126 127 128 129
typedef struct _virDomainIdMapEntry virDomainIdMapEntry;
typedef virDomainIdMapEntry *virDomainIdMapEntryPtr;

typedef struct _virDomainIdMapDef virDomainIdMapDef;
typedef virDomainIdMapDef *virDomainIdMapDefPtr;

H
Hu Tao 已提交
130 131 132
typedef struct _virDomainPanicDef virDomainPanicDef;
typedef virDomainPanicDef *virDomainPanicDefPtr;

M
Michele Paolino 已提交
133 134 135 136 137 138
/* forward declarations virDomainChrSourceDef, required by
 * virDomainNetDef
 */
typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;

139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
/* 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 已提交
158
    VIR_DOMAIN_DEVICE_NVRAM,
159
    VIR_DOMAIN_DEVICE_RNG,
160

161
    VIR_DOMAIN_DEVICE_LAST
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
} 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 已提交
185
        virDomainNVRAMDefPtr nvram;
186
        virDomainRNGDefPtr rng;
187 188 189
    } data;
};

190 191
/* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */
192
typedef enum {
193 194 195 196 197 198 199 200 201 202
    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,
203
    VIR_DOMAIN_VIRT_VBOX,
204
    VIR_DOMAIN_VIRT_PHYP,
D
Dmitry Guryanov 已提交
205
    VIR_DOMAIN_VIRT_PARALLELS,
R
Roman Bogorodskiy 已提交
206
    VIR_DOMAIN_VIRT_BHYVE,
207

208
    VIR_DOMAIN_VIRT_LAST
209
} virDomainVirtType;
210

211
typedef enum {
212 213
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
214
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
215
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
216
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
217
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB,
218
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
219
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390,
220
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW,
221
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO,
H
Hu Tao 已提交
222
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA,
223 224

    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
225
} virDomainDeviceAddressType;
226

227 228 229 230 231
typedef struct _virDomainDeviceDriveAddress virDomainDeviceDriveAddress;
typedef virDomainDeviceDriveAddress *virDomainDeviceDriveAddressPtr;
struct _virDomainDeviceDriveAddress {
    unsigned int controller;
    unsigned int bus;
232
    unsigned int target;
233 234 235
    unsigned int unit;
};

236 237 238 239 240
typedef struct _virDomainDeviceVirtioSerialAddress virDomainDeviceVirtioSerialAddress;
typedef virDomainDeviceVirtioSerialAddress *virDomainDeviceVirtioSerialAddressPtr;
struct _virDomainDeviceVirtioSerialAddress {
    unsigned int controller;
    unsigned int bus;
241
    unsigned int port;
242 243
};

244 245 246 247 248 249 250 251 252 253 254 255 256
# 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 已提交
257 258 259 260 261 262 263
typedef struct _virDomainDeviceCcidAddress virDomainDeviceCcidAddress;
typedef virDomainDeviceCcidAddress *virDomainDeviceCcidAddressPtr;
struct _virDomainDeviceCcidAddress {
    unsigned int controller;
    unsigned int slot;
};

264 265 266 267
typedef struct _virDomainDeviceUSBAddress virDomainDeviceUSBAddress;
typedef virDomainDeviceUSBAddress *virDomainDeviceUSBAddressPtr;
struct _virDomainDeviceUSBAddress {
    unsigned int bus;
268
    char *port;
269 270
};

271 272 273 274 275 276 277
typedef struct _virDomainDeviceSpaprVioAddress virDomainDeviceSpaprVioAddress;
typedef virDomainDeviceSpaprVioAddress *virDomainDeviceSpaprVioAddressPtr;
struct _virDomainDeviceSpaprVioAddress {
    unsigned long long reg;
    bool has_reg;
};

278
typedef enum {
279 280 281 282
    VIR_DOMAIN_CONTROLLER_MASTER_NONE,
    VIR_DOMAIN_CONTROLLER_MASTER_USB,

    VIR_DOMAIN_CONTROLLER_MASTER_LAST
283
} virDomainControllerMaster;
284 285 286 287 288 289 290

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

H
Hu Tao 已提交
291 292 293 294 295 296 297
typedef struct _virDomainDeviceISAAddress virDomainDeviceISAAddress;
typedef virDomainDeviceISAAddress *virDomainDeviceISAAddressPtr;
struct _virDomainDeviceISAAddress {
    unsigned int iobase;
    unsigned int irq;
};

298 299 300
typedef struct _virDomainDeviceInfo virDomainDeviceInfo;
typedef virDomainDeviceInfo *virDomainDeviceInfoPtr;
struct _virDomainDeviceInfo {
301 302 303 304
    /* If adding to this struct, ensure that
     * virDomainDeviceInfoIsSet() is updated
     * to consider the new fields
     */
D
Daniel P. Berrange 已提交
305
    char *alias;
306 307
    int type;
    union {
308
        virDevicePCIAddress pci;
309
        virDomainDeviceDriveAddress drive;
310
        virDomainDeviceVirtioSerialAddress vioserial;
E
Eric Blake 已提交
311
        virDomainDeviceCcidAddress ccid;
312
        virDomainDeviceUSBAddress usb;
313
        virDomainDeviceSpaprVioAddress spaprvio;
314
        virDomainDeviceCCWAddress ccw;
H
Hu Tao 已提交
315
        virDomainDeviceISAAddress isa;
316
    } addr;
317 318 319 320
    int mastertype;
    union {
        virDomainDeviceUSBMaster usb;
    } master;
321 322
    /* rombar and romfile are only used for pci hostdev and network
     * devices. */
J
Ján Tomko 已提交
323
    int rombar;         /* enum virTristateSwitch */
324
    char *romfile;
325 326
    /* bootIndex is only used for disk, network interface, hostdev
     * and redirdev devices */
327
    int bootIndex;
328 329
};

330

331 332 333 334 335 336 337 338
typedef struct _virDomainHostdevOrigStates virDomainHostdevOrigStates;
typedef virDomainHostdevOrigStates *virDomainHostdevOrigStatesPtr;
struct _virDomainHostdevOrigStates {
    union {
        struct {
            /* Does the device need to unbind from stub when
             * reattaching to host?
             */
339
            bool unbind_from_stub;
340 341 342 343

            /* Does it need to use remove_slot when reattaching
             * the device to host?
             */
344
            bool remove_slot;
345 346 347 348

            /* Does it need to reprobe driver for the device when
             * reattaching to host?
             */
349
            bool reprobe;
350 351 352 353 354 355
        } pci;

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

356 357 358 359 360 361 362
struct _virDomainLeaseDef {
    char *lockspace;
    char *key;
    char *path;
    unsigned long long offset;
};

363

364
typedef enum {
365 366 367
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

368
    VIR_DOMAIN_HOSTDEV_MODE_LAST
369
} virDomainHostdevMode;
370

371
typedef enum {
372 373
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
H
Han Cheng 已提交
374
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
375 376

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
377
} virDomainHostdevSubsysType;
378

379 380
/* the backend driver used for PCI hostdev devices */
typedef enum {
381
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automaticaly, prefer VFIO */
382 383
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM,    /* force legacy kvm style */
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO,   /* force vfio */
384
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN,    /* force legacy xen style, use pciback */
385 386

    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
387
} virDomainHostdevSubsysPCIBackendType;
388

389
VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend)
390

391 392 393 394 395 396 397 398 399
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)

400 401 402 403 404 405 406 407 408 409 410 411
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;
};

412 413 414 415 416 417 418
typedef struct _virDomainHostdevSubsysPCI virDomainHostdevSubsysPCI;
typedef virDomainHostdevSubsysPCI *virDomainHostdevSubsysPCIPtr;
struct _virDomainHostdevSubsysPCI {
    virDevicePCIAddress addr; /* host address */
    int backend; /* enum virDomainHostdevSubsysPCIBackendType */
};

419 420 421
typedef struct _virDomainHostdevSubsysSCSIHost virDomainHostdevSubsysSCSIHost;
typedef virDomainHostdevSubsysSCSIHost *virDomainHostdevSubsysSCSIHostPtr;
struct _virDomainHostdevSubsysSCSIHost {
422 423 424 425
    char *adapter;
    unsigned bus;
    unsigned target;
    unsigned unit;
426 427
};

428 429 430 431 432 433 434 435 436
typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI;
typedef virDomainHostdevSubsysSCSIiSCSI *virDomainHostdevSubsysSCSIiSCSIPtr;
struct _virDomainHostdevSubsysSCSIiSCSI {
    char *path;
    size_t nhosts;
    virStorageNetHostDefPtr hosts;
    virStorageAuthDefPtr auth;
};

437 438 439
typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
typedef virDomainHostdevSubsysSCSI *virDomainHostdevSubsysSCSIPtr;
struct _virDomainHostdevSubsysSCSI {
440
    int protocol; /* enum virDomainHostdevSCSIProtocolType */
441
    int sgio; /* enum virDomainDeviceSGIO */
442 443
    union {
        virDomainHostdevSubsysSCSIHost host;
444
        virDomainHostdevSubsysSCSIiSCSI iscsi;
445
    } u;
446 447
};

448 449 450
typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys {
451
    int type; /* enum virDomainHostdevSubsysType */
452
    union {
453
        virDomainHostdevSubsysUSB usb;
454
        virDomainHostdevSubsysPCI pci;
455
        virDomainHostdevSubsysSCSI scsi;
456 457 458
    } u;
};

459

460
typedef enum {
461 462
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
463
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
464 465

    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
466
} virDomainHostdevCapsType;
467 468 469 470 471 472 473 474 475 476 477 478

typedef struct _virDomainHostdevCaps virDomainHostdevCaps;
typedef virDomainHostdevCaps *virDomainHostdevCapsPtr;
struct _virDomainHostdevCaps {
    int type; /* enum virDOmainHostdevCapsType */
    union {
        struct {
            char *block;
        } storage;
        struct {
            char *chardev;
        } misc;
479 480 481
        struct {
            char *iface;
        } net;
482 483 484 485
    } u;
};


486 487
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
488
    virDomainDeviceDef parent; /* higher level Def containing this */
489
    int mode; /* enum virDomainHostdevMode */
490
    int startupPolicy; /* enum virDomainStartupPolicy */
491
    bool managed;
492
    bool missing;
O
Osier Yang 已提交
493
    bool readonly;
494
    bool shareable;
495
    union {
496
        virDomainHostdevSubsys subsys;
497
        virDomainHostdevCaps caps;
498 499
    } source;
    virDomainHostdevOrigStates origstates;
500
    virDomainDeviceInfoPtr info; /* Guest address */
501 502
};

503

E
Eric Blake 已提交
504 505
/* Types of disk frontend (guest view).  For backends (host view), see
 * virStorageType in util/virstoragefile.h */
506
typedef enum {
507 508 509
    VIR_DOMAIN_DISK_DEVICE_DISK,
    VIR_DOMAIN_DISK_DEVICE_CDROM,
    VIR_DOMAIN_DISK_DEVICE_FLOPPY,
510
    VIR_DOMAIN_DISK_DEVICE_LUN,
511 512

    VIR_DOMAIN_DISK_DEVICE_LAST
513
} virDomainDiskDevice;
514

515
typedef enum {
516 517 518 519 520
    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,
521
    VIR_DOMAIN_DISK_BUS_USB,
522
    VIR_DOMAIN_DISK_BUS_UML,
523
    VIR_DOMAIN_DISK_BUS_SATA,
524
    VIR_DOMAIN_DISK_BUS_SD,
525 526

    VIR_DOMAIN_DISK_BUS_LAST
527
} virDomainDiskBus;
528

529
typedef enum {
530 531 532 533
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
534
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
535
    VIR_DOMAIN_DISK_CACHE_UNSAFE,
536 537

    VIR_DOMAIN_DISK_CACHE_LAST
538
} virDomainDiskCache;
539

540
typedef enum {
541 542
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
543
    VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
544
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
545
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
546 547

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
548
} virDomainDiskErrorPolicy;
549

M
MORITA Kazutaka 已提交
550

551
typedef enum {
552 553 554 555
    VIR_DOMAIN_DISK_TRAY_CLOSED,
    VIR_DOMAIN_DISK_TRAY_OPEN,

    VIR_DOMAIN_DISK_TRAY_LAST
556
} virDomainDiskTray;
557

558
typedef enum {
J
J.B. Joret 已提交
559 560 561 562 563 564
    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
565
} virDomainDiskGeometryTrans;
J
J.B. Joret 已提交
566

567
typedef enum {
M
Matthias Dahl 已提交
568 569 570 571 572
    VIR_DOMAIN_DISK_IO_DEFAULT,
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
573
} virDomainDiskIo;
M
Matthias Dahl 已提交
574

575
typedef enum {
576 577 578 579 580 581
    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
582
} virDomainStartupPolicy;
583

584

585
typedef enum {
586 587 588
    VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
    VIR_DOMAIN_DEVICE_SGIO_FILTERED,
    VIR_DOMAIN_DEVICE_SGIO_UNFILTERED,
O
Osier Yang 已提交
589

590
    VIR_DOMAIN_DEVICE_SGIO_LAST
591
} virDomainDeviceSGIO;
O
Osier Yang 已提交
592

593
typedef enum {
O
Osier Yang 已提交
594
    VIR_DOMAIN_DISK_DISCARD_DEFAULT = 0,
O
Osier Yang 已提交
595 596
    VIR_DOMAIN_DISK_DISCARD_UNMAP,
    VIR_DOMAIN_DISK_DISCARD_IGNORE,
O
Osier Yang 已提交
597 598

    VIR_DOMAIN_DISK_DISCARD_LAST
599
} virDomainDiskDiscard;
O
Osier Yang 已提交
600

L
Lei Li 已提交
601 602 603 604 605 606 607 608 609 610 611
typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo;
struct _virDomainBlockIoTuneInfo {
    unsigned long long total_bytes_sec;
    unsigned long long read_bytes_sec;
    unsigned long long write_bytes_sec;
    unsigned long long total_iops_sec;
    unsigned long long read_iops_sec;
    unsigned long long write_iops_sec;
};
typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;

612

613 614 615 616 617 618 619 620 621 622
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;


623 624
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
625
    virStorageSourcePtr src; /* non-NULL.  XXX Allow NULL for empty cdrom? */
626 627 628 629 630

    int device; /* enum virDomainDiskDevice */
    int bus; /* enum virDomainDiskBus */
    char *dst;
    int tray_status; /* enum virDomainDiskTray */
J
Ján Tomko 已提交
631
    int removable; /* enum virTristateSwitch */
L
Lei Li 已提交
632

633
    virStorageSourcePtr mirror;
634
    int mirrorState; /* enum virDomainDiskMirrorState */
E
Eric Blake 已提交
635
    int mirrorJob; /* virDomainBlockJobType */
636

J
J.B. Joret 已提交
637 638 639 640
    struct {
        unsigned int cylinders;
        unsigned int heads;
        unsigned int sectors;
641
        int trans; /* enum virDomainDiskGeometryTrans */
J
J.B. Joret 已提交
642 643
    } geometry;

644 645 646
    struct {
        unsigned int logical_block_size;
        unsigned int physical_block_size;
V
Viktor Mihajlovski 已提交
647
    } blockio;
648

L
Lei Li 已提交
649 650
    virDomainBlockIoTuneInfo blkdeviotune;

651
    char *serial;
O
Osier Yang 已提交
652
    char *wwn;
653 654
    char *vendor;
    char *product;
655
    int cachemode; /* enum virDomainDiskCache */
656 657
    int error_policy;  /* enum virDomainDiskErrorPolicy */
    int rerror_policy; /* enum virDomainDiskErrorPolicy */
658
    int iomode; /* enum virDomainDiskIo */
J
Ján Tomko 已提交
659 660 661
    int ioeventfd; /* enum virTristateSwitch */
    int event_idx; /* enum virTristateSwitch */
    int copy_on_read; /* enum virTristateSwitch */
662
    int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
663
    int startupPolicy; /* enum virDomainStartupPolicy */
664
    bool transient;
665
    virDomainDeviceInfo info;
666 667
    bool rawio_specified;
    int rawio; /* no = 0, yes = 1 */
668
    int sgio; /* enum virDomainDeviceSGIO */
O
Osier Yang 已提交
669
    int discard; /* enum virDomainDiskDiscard */
670 671 672
};


673
typedef enum {
674 675 676 677
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
678
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
679
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
680
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
J
Ján Tomko 已提交
681
    VIR_DOMAIN_CONTROLLER_TYPE_PCI,
682 683

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
684
} virDomainControllerType;
685

686

687
typedef enum {
J
Ján Tomko 已提交
688
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
L
Laine Stump 已提交
689
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
J
Ján Tomko 已提交
690
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
691
    VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
J
Ján Tomko 已提交
692 693

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
694
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
695

696
typedef enum {
697 698 699 700 701
    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,
702
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
703
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
704
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
705

706
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
707
} virDomainControllerModelSCSI;
708

709
typedef enum {
M
Marc-André Lureau 已提交
710 711 712 713 714 715 716 717 718
    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 已提交
719
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
720
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
M
Marc-André Lureau 已提交
721 722

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
723
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
724

725 726 727 728 729 730 731
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

732 733 734
typedef struct _virDomainPCIControllerOpts virDomainPCIControllerOpts;
typedef virDomainPCIControllerOpts *virDomainPCIControllerOptsPtr;
struct _virDomainPCIControllerOpts {
735 736 737 738
    bool pcihole64;
    unsigned long pcihole64size;
};

739 740 741
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
    int type;
742
    unsigned int idx;
743
    int model; /* -1 == undef */
744
    unsigned int queues;
745 746
    unsigned int cmd_per_lun;
    unsigned int max_sectors;
747 748
    union {
        virDomainVirtioSerialOpts vioserial;
749
        virDomainPCIControllerOpts pciopts;
750
    } opts;
751 752 753 754
    virDomainDeviceInfo info;
};


G
Giuseppe Scrivano 已提交
755
/* Types of disk backends */
756
typedef enum {
757 758 759 760 761 762
    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 */
763 764

    VIR_DOMAIN_FS_TYPE_LAST
765
} virDomainFSType;
766

767
/* Filesystem driver type */
768
typedef enum {
769 770 771
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
772
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
773
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
774 775

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
776
} virDomainFSDriverType;
777

778
/* Filesystem mount access mode  */
779
typedef enum {
780 781 782 783 784
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
785
} virDomainFSAccessMode;
786

787
/* Filesystem Write policy */
788
typedef enum {
789 790 791 792
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
793
} virDomainFSWrpolicy;
794

795 796 797
/* Allow 2 MB ram usage */
# define VIR_DOMAIN_FS_RAM_DEFAULT_USAGE (1024 * 2)

798 799
struct _virDomainFSDef {
    int type;
800 801
    int fsdriver; /* enum virDomainFSDriverType */
    int accessmode; /* enum virDomainFSAccessMode */
802
    int wrpolicy; /* enum virDomainFSWrpolicy */
803
    int format; /* virStorageFileFormat */
804
    unsigned long long usage; /* in bytes */
805 806
    char *src;
    char *dst;
807
    bool readonly;
808
    virDomainDeviceInfo info;
809 810
    unsigned long long space_hard_limit; /* in bytes */
    unsigned long long space_soft_limit; /* in bytes */
811 812 813
};


814
/* network config types */
815
typedef enum {
816 817
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
M
Michele Paolino 已提交
818
    VIR_DOMAIN_NET_TYPE_VHOSTUSER,
819 820 821 822 823
    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 已提交
824
    VIR_DOMAIN_NET_TYPE_INTERNAL,
825
    VIR_DOMAIN_NET_TYPE_DIRECT,
826
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
827

828
    VIR_DOMAIN_NET_TYPE_LAST
829
} virDomainNetType;
830

831
/* the backend driver used for virtio interfaces */
832
typedef enum {
833 834 835 836
    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 */

837
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
838
} virDomainNetBackendType;
839

840
/* the TX algorithm used for virtio interfaces */
841
typedef enum {
842 843 844 845
    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,

846
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
847
} virDomainNetVirtioTxModeType;
848

849
/* link interface states */
850
typedef enum {
851 852 853 854 855
        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
856
} virDomainNetInterfaceLinkState;
857

858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874
/* Config that was actually used to bring up interface, after
 * resolving network reference. This is private data, only used within
 * libvirt, but still must maintain backward compatibility, because
 * different versions of libvirt may read the same data file.
 */
typedef struct _virDomainActualNetDef virDomainActualNetDef;
typedef virDomainActualNetDef *virDomainActualNetDefPtr;
struct _virDomainActualNetDef {
    int type; /* enum virDomainNetType */
    union {
        struct {
            char *brname;
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
        } direct;
875 876 877
        struct {
            virDomainHostdevDef def;
        } hostdev;
878
    } data;
879
    virNetDevVPortProfilePtr virtPortProfile;
880
    virNetDevBandwidthPtr bandwidth;
881
    virNetDevVlan vlan;
882
    unsigned int class_id; /* class ID for bandwidth 'floor' */
883 884
};

885 886
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
887
    virDomainNetType type;
888
    virMacAddr mac;
889
    char *model;
890 891
    union {
        struct {
892 893
            virDomainNetBackendType name; /* which driver backend to use */
            virDomainNetVirtioTxModeType txmode;
J
Ján Tomko 已提交
894 895
            virTristateSwitch ioeventfd;
            virTristateSwitch event_idx;
896
            unsigned int queues; /* Multiqueue virtio-net */
897 898
        } virtio;
    } driver;
899 900 901 902 903
    union {
        struct {
            char *dev;
            char *ipaddr;
        } ethernet;
M
Michele Paolino 已提交
904
        virDomainChrSourceDefPtr vhostuser;
905 906 907 908 909 910
        struct {
            char *address;
            int port;
        } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
        struct {
            char *name;
911 912 913 914 915 916 917 918 919 920
            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;
921 922 923
        } network;
        struct {
            char *brname;
924
            char *ipaddr;
925
        } bridge;
D
Daniel Veillard 已提交
926 927 928
        struct {
            char *name;
        } internal;
929 930
        struct {
            char *linkdev;
931
            int mode; /* enum virMacvtapMode from util/macvtap.h */
932
        } direct;
933 934 935
        struct {
            virDomainHostdevDef def;
        } hostdev;
936
    } data;
937 938
    /* virtPortProfile is used by network/bridge/direct/hostdev */
    virNetDevVPortProfilePtr virtPortProfile;
939 940 941 942
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
943
    char *script;
944
    char *ifname;
945 946
    char *ifname_guest;
    char *ifname_guest_actual;
947
    virDomainDeviceInfo info;
948 949
    char *filter;
    virNWFilterHashTablePtr filterparams;
950
    virNetDevBandwidthPtr bandwidth;
951
    virNetDevVlan vlan;
952
    int linkstate;
953 954
};

E
Eric Blake 已提交
955 956 957 958
/* 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"

959
typedef enum {
960
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
961 962
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
963
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
964

965
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
966
} virDomainChrDeviceType;
967

968
typedef enum {
G
Guannan Ren 已提交
969 970 971 972
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
973
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
974

975
typedef enum {
976 977
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
978 979
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,

980
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
981
} virDomainChrChannelTargetType;
982

983
typedef enum {
984 985
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
986 987
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
988
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
989 990
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
991 992
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
993

994
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
995
} virDomainChrConsoleTargetType;
996

997
typedef enum {
998 999 1000 1001 1002 1003 1004 1005 1006 1007
    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,
1008
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1009
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1010
    VIR_DOMAIN_CHR_TYPE_NMDM,
1011

1012
    VIR_DOMAIN_CHR_TYPE_LAST
1013
} virDomainChrType;
1014

1015
typedef enum {
1016 1017
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW,
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1018 1019
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1020

1021
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1022
} virDomainChrTcpProtocol;
1023

1024
typedef enum {
E
Eric Blake 已提交
1025 1026
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1027
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1028

1029
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1030
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1031

1032 1033 1034
/* The host side information for a character device.  */
struct _virDomainChrSourceDef {
    int type; /* virDomainChrType */
1035
    union {
E
Eric Blake 已提交
1036
        /* no <source> for null, vc, stdio */
1037 1038 1039
        struct {
            char *path;
        } file; /* pty, file, pipe, or device */
1040 1041 1042 1043
        struct {
            char *master;
            char *slave;
        } nmdm;
1044 1045 1046
        struct {
            char *host;
            char *service;
1047
            bool listen;
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
            int protocol;
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
1058
            bool listen;
1059
        } nix;
E
Eric Blake 已提交
1060
        int spicevmc;
1061 1062 1063
        struct {
            char *channel;
        } spiceport;
1064
    } data;
1065 1066 1067 1068 1069
};

/* A complete character device, both host and domain views.  */
struct _virDomainChrDef {
    int deviceType;
G
Guannan Ren 已提交
1070 1071

    bool targetTypeAttr;
1072 1073 1074 1075 1076 1077 1078 1079
    int targetType;
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

    virDomainChrSourceDef source;
1080 1081

    virDomainDeviceInfo info;
1082 1083 1084

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1085 1086
};

1087
typedef enum {
E
Eric Blake 已提交
1088 1089 1090 1091
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

1092
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1093
} virDomainSmartcardType;
E
Eric Blake 已提交
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111

# 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 已提交
1112 1113 1114 1115 1116
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

1117
typedef enum {
1118 1119 1120
    VIR_DOMAIN_TPM_MODEL_TIS,

    VIR_DOMAIN_TPM_MODEL_LAST
1121
} virDomainTPMModel;
1122

1123
typedef enum {
1124 1125 1126
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,

    VIR_DOMAIN_TPM_TYPE_LAST
1127
} virDomainTPMBackendType;
1128 1129 1130 1131 1132 1133

# define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"

typedef struct _virDomainTPMDef virDomainTPMDef;
typedef virDomainTPMDef *virDomainTPMDefPtr;
struct _virDomainTPMDef {
1134
    virDomainTPMBackendType type;
1135
    virDomainDeviceInfo info;
1136
    virDomainTPMModel model;
1137 1138 1139 1140 1141 1142 1143
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
    } data;
};

1144
typedef enum {
1145 1146
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1147
    VIR_DOMAIN_INPUT_TYPE_KBD,
1148

1149
    VIR_DOMAIN_INPUT_TYPE_LAST
1150
} virDomainInputType;
1151

1152
typedef enum {
1153 1154 1155 1156 1157
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,

    VIR_DOMAIN_INPUT_BUS_LAST
1158
} virDomainInputBus;
1159 1160 1161 1162

struct _virDomainInputDef {
    int type;
    int bus;
1163
    virDomainDeviceInfo info;
1164 1165
};

1166
typedef enum {
1167 1168 1169 1170
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1171
} virDomainSoundCodecType;
1172

1173
typedef enum {
1174 1175 1176
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1177
    VIR_DOMAIN_SOUND_MODEL_AC97,
1178
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1179
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1180
    VIR_DOMAIN_SOUND_MODEL_USB,
1181 1182

    VIR_DOMAIN_SOUND_MODEL_LAST
1183
} virDomainSoundModel;
1184

1185 1186 1187 1188 1189
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1190 1191
struct _virDomainSoundDef {
    int model;
1192
    virDomainDeviceInfo info;
1193

1194
    size_t ncodecs;
1195
    virDomainSoundCodecDefPtr *codecs;
1196 1197
};

1198
typedef enum {
R
Richard Jones 已提交
1199 1200 1201 1202
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1203
} virDomainWatchdogModel;
R
Richard Jones 已提交
1204

1205
typedef enum {
R
Richard Jones 已提交
1206 1207 1208 1209
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1210
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1211 1212 1213
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1214
} virDomainWatchdogAction;
R
Richard Jones 已提交
1215 1216 1217 1218

struct _virDomainWatchdogDef {
    int model;
    int action;
1219
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1220 1221
};

1222

1223
typedef enum {
1224 1225 1226 1227 1228
    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,
1229
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1230 1231

    VIR_DOMAIN_VIDEO_TYPE_LAST
1232
} virDomainVideoType;
1233 1234


1235 1236 1237
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
1238 1239
    bool support3d;
    bool support2d;
1240 1241 1242
};


1243 1244
struct _virDomainVideoDef {
    int type;
1245 1246
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1247
    unsigned int heads;
1248
    bool primary;
1249
    virDomainVideoAccelDefPtr accel;
1250
    virDomainDeviceInfo info;
1251 1252
};

1253
/* graphics console modes */
1254
typedef enum {
1255 1256
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1257 1258
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1259
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1260

1261
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1262
} virDomainGraphicsType;
1263

1264
typedef enum {
1265 1266 1267 1268 1269 1270
    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
1271
} virDomainGraphicsVNCSharePolicy;
1272

1273
typedef enum {
1274 1275 1276 1277 1278 1279
    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
1280
} virDomainGraphicsAuthConnectedType;
1281

1282 1283 1284 1285
typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef;
typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr;
struct _virDomainGraphicsAuthDef {
    char *passwd;
1286
    bool expires; /* Whether there is an expiry time set */
1287
    time_t validTo;  /* seconds since epoch */
1288
    int connected; /* action if connected */
1289 1290
};

1291
typedef enum {
1292 1293 1294 1295 1296 1297
    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 已提交
1298
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1299
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1300 1301

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1302
} virDomainGraphicsSpiceChannelName;
1303

1304
typedef enum {
1305 1306 1307 1308 1309
    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
1310
} virDomainGraphicsSpiceChannelMode;
1311

1312
typedef enum {
1313 1314 1315 1316 1317 1318 1319 1320 1321
    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
1322
} virDomainGraphicsSpiceImageCompression;
1323

1324
typedef enum {
1325 1326 1327 1328 1329 1330
    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
1331
} virDomainGraphicsSpiceJpegCompression;
1332

1333
typedef enum {
1334 1335 1336 1337 1338 1339
    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
1340
} virDomainGraphicsSpiceZlibCompression;
1341

1342
typedef enum {
P
Peng Zhou 已提交
1343 1344 1345 1346 1347
    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
1348
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1349

1350
typedef enum {
1351 1352 1353 1354 1355 1356
    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
1357
} virDomainGraphicsSpiceStreamingMode;
1358

1359
typedef enum {
1360 1361 1362 1363
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,

1364
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1365
} virDomainGraphicsListenType;
1366

1367
typedef enum {
M
Marc-André Lureau 已提交
1368 1369
    VIR_DOMAIN_HUB_TYPE_USB,

1370
    VIR_DOMAIN_HUB_TYPE_LAST
1371
} virDomainHubType;
M
Marc-André Lureau 已提交
1372

1373 1374 1375 1376 1377 1378
typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef;
typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr;
struct _virDomainGraphicsListenDef {
    int type;   /* enum virDomainGraphicsListenType */
    char *address;
    char *network;
1379
    bool fromConfig;    /* true if the @address is config file originated */
1380 1381
};

1382
struct _virDomainGraphicsDef {
M
Michal Privoznik 已提交
1383 1384 1385 1386 1387
    /* 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.
     */
1388 1389 1390 1391
    int type;
    union {
        struct {
            int port;
1392
            bool portReserved;
M
Martin Kletzander 已提交
1393
            int websocket;
1394
            bool autoport;
1395
            char *keymap;
1396
            char *socket;
1397
            virDomainGraphicsAuthDef auth;
1398
            int sharePolicy;
1399 1400 1401 1402
        } vnc;
        struct {
            char *display;
            char *xauth;
1403
            bool fullscreen;
1404
        } sdl;
1405 1406
        struct {
            int port;
1407 1408 1409
            bool autoport;
            bool replaceUser;
            bool multiUser;
1410 1411 1412
        } rdp;
        struct {
            char *display;
1413
            bool fullscreen;
1414
        } desktop;
1415 1416 1417
        struct {
            int port;
            int tlsPort;
1418 1419
            bool portReserved;
            bool tlsPortReserved;
P
Peng Zhou 已提交
1420
            int mousemode;
1421
            char *keymap;
1422
            virDomainGraphicsAuthDef auth;
1423
            bool autoport;
1424
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1425
            int defaultMode; /* enum virDomainGraphicsSpiceChannelMode */
1426 1427 1428 1429
            int image;
            int jpeg;
            int zlib;
            int playback;
1430
            int streaming;
J
Ján Tomko 已提交
1431 1432
            int copypaste; /* enum virTristateBool */
            int filetransfer; /* enum virTristateBool */
1433
        } spice;
1434
    } data;
1435 1436 1437 1438 1439
    /* 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;
1440 1441
};

1442
typedef enum {
1443 1444 1445
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1446
} virDomainRedirdevBus;
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456

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

    union {
        virDomainChrSourceDef chr;
    } source;

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

1458
struct _virDomainRedirFilterUSBDevDef {
1459 1460 1461 1462
    int usbClass;
    int vendor;
    int product;
    int version;
1463
    bool allow;
1464 1465 1466 1467
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1468
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1469 1470
};

1471 1472 1473
enum {
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1474
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1475 1476 1477 1478 1479 1480 1481

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
};

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1482
    unsigned int period; /* seconds between collections */
1483 1484
};

L
Li Zhang 已提交
1485 1486 1487
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1488

1489
typedef enum {
1490
    VIR_DOMAIN_SMBIOS_NONE = 0,
1491 1492 1493 1494 1495
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1496
} virDomainSmbiosMode;
1497

1498

1499
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1500

1501
typedef enum {
1502 1503 1504 1505 1506
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1507
    VIR_DOMAIN_BOOT_LAST
1508
} virDomainBootOrder;
1509

1510
typedef enum {
1511 1512 1513
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1514
    VIR_DOMAIN_FEATURE_HAP,
1515
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1516
    VIR_DOMAIN_FEATURE_PRIVNET,
1517
    VIR_DOMAIN_FEATURE_HYPERV,
1518
    VIR_DOMAIN_FEATURE_KVM,
1519
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1520
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1521 1522

    VIR_DOMAIN_FEATURE_LAST
1523
} virDomainFeature;
1524

1525
typedef enum {
1526
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1527 1528
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1529 1530

    VIR_DOMAIN_HYPERV_LAST
1531
} virDomainHyperv;
1532

1533 1534 1535 1536 1537 1538
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588
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;

1589
typedef enum {
1590 1591 1592 1593 1594 1595
    VIR_DOMAIN_LIFECYCLE_DESTROY,
    VIR_DOMAIN_LIFECYCLE_RESTART,
    VIR_DOMAIN_LIFECYCLE_RESTART_RENAME,
    VIR_DOMAIN_LIFECYCLE_PRESERVE,

    VIR_DOMAIN_LIFECYCLE_LAST
1596
} virDomainLifecycleAction;
1597

1598
typedef enum {
1599 1600 1601 1602 1603 1604 1605 1606
    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
1607
} virDomainLifecycleCrashAction;
1608

1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620
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 已提交
1621 1622 1623
typedef struct _virDomainBIOSDef virDomainBIOSDef;
typedef virDomainBIOSDef *virDomainBIOSDefPtr;
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1624
    int useserial; /* enum virTristateBool */
1625 1626 1627
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1628 1629
};

1630 1631 1632 1633 1634
/* Operating system configuration data & machine / arch */
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
    char *type;
1635
    virArch arch;
1636
    char *machine;
1637
    size_t nBootDevs;
1638
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1639
    int bootmenu; /* enum virTristateBool */
1640 1641
    unsigned int bm_timeout;
    bool bm_timeout_set;
1642
    char *init;
1643
    char **initargv;
1644 1645 1646
    char *kernel;
    char *initrd;
    char *cmdline;
1647
    char *dtb;
1648 1649 1650 1651
    char *root;
    char *loader;
    char *bootloader;
    char *bootloaderArgs;
1652
    int smbios_mode;
1653

M
Michal Privoznik 已提交
1654
    virDomainBIOSDef bios;
1655 1656
};

1657
typedef enum {
1658 1659 1660 1661 1662
    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 已提交
1663
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1664
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
1665

1666
    VIR_DOMAIN_TIMER_NAME_LAST
1667
} virDomainTimerNameType;
1668

1669
typedef enum {
1670 1671 1672
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1673

1674
    VIR_DOMAIN_TIMER_TRACK_LAST
1675
} virDomainTimerTrackType;
1676

1677
typedef enum {
1678 1679 1680 1681 1682
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

1683
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
1684
} virDomainTimerTickpolicyType;
1685

1686
typedef enum {
1687 1688 1689 1690
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
1691
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
1692

1693
    VIR_DOMAIN_TIMER_MODE_LAST
1694
} virDomainTimerModeType;
1695

1696
typedef enum {
1697
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
1698 1699
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

1700
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
1701
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
1702

1703 1704 1705 1706 1707 1708 1709 1710
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

1711 1712 1713 1714 1715 1716 1717
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 */

1718 1719 1720 1721
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
1722 1723 1724 1725 1726 1727

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

1728
typedef enum {
1729 1730
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
1731
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
1732
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
1733

1734
    VIR_DOMAIN_CLOCK_OFFSET_LAST
1735
} virDomainClockOffsetType;
1736

1737
typedef enum {
1738 1739 1740
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

1741
    VIR_DOMAIN_CLOCK_BASIS_LAST
1742
} virDomainClockBasis;
1743

1744 1745 1746 1747
typedef struct _virDomainClockDef virDomainClockDef;
typedef virDomainClockDef *virDomainClockDefPtr;
struct _virDomainClockDef {
    int offset;
1748

1749
    union {
1750 1751 1752
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
1753
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
1754 1755 1756
        struct {
            long long adjustment;
            int basis;
1757 1758 1759 1760 1761 1762 1763

            /* 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;
1764
        } variable;
1765 1766 1767 1768 1769

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

1771
    size_t ntimers;
1772
    virDomainTimerDefPtr *timers;
1773 1774
};

1775
# define VIR_DOMAIN_CPUMASK_LEN 1024
1776

E
Eric Blake 已提交
1777 1778 1779
typedef struct _virDomainVcpuPinDef virDomainVcpuPinDef;
typedef virDomainVcpuPinDef *virDomainVcpuPinDefPtr;
struct _virDomainVcpuPinDef {
1780
    int vcpuid;
H
Hu Tao 已提交
1781
    virBitmapPtr cpumask;
1782 1783
};

H
Hu Tao 已提交
1784 1785
void virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr def);
void virDomainVcpuPinDefArrayFree(virDomainVcpuPinDefPtr *def, int nvcpupin);
1786 1787 1788 1789

virDomainVcpuPinDefPtr *virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src,
                                                int nvcpupin);

E
Eric Blake 已提交
1790
int virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def,
1791 1792 1793
                                int nvcpupin,
                                int vcpu);

E
Eric Blake 已提交
1794
virDomainVcpuPinDefPtr virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
1795 1796 1797
                                                  int nvcpupin,
                                                  int vcpu);

1798 1799 1800
typedef struct _virBlkioDevice virBlkioDevice;
typedef virBlkioDevice *virBlkioDevicePtr;
struct _virBlkioDevice {
1801 1802
    char *path;
    unsigned int weight;
1803 1804 1805 1806
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
1807 1808
};

1809
typedef enum {
1810 1811 1812
    VIR_DOMAIN_RNG_MODEL_VIRTIO,

    VIR_DOMAIN_RNG_MODEL_LAST
1813
} virDomainRNGModel;
1814

1815
typedef enum {
1816 1817 1818 1819 1820
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
    /* VIR_DOMAIN_RNG_BACKEND_POOL, */

    VIR_DOMAIN_RNG_BACKEND_LAST
1821
} virDomainRNGBackend;
1822 1823 1824 1825

struct _virDomainRNGDef {
    int model;
    int backend;
1826 1827
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
1828 1829 1830 1831 1832 1833 1834 1835 1836 1837

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

    virDomainDeviceInfo info;
};

1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852
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 已提交
1853 1854 1855 1856 1857
struct _virDomainPanicDef {
    virDomainDeviceInfo info;
};


1858
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
1859
                              int ndevices);
1860

1861 1862 1863 1864 1865
typedef struct _virDomainResourceDef virDomainResourceDef;
typedef virDomainResourceDef *virDomainResourceDefPtr;
struct _virDomainResourceDef {
    char *partition;
};
1866

1867 1868 1869 1870 1871 1872 1873 1874
typedef struct _virDomaiHugePage virDomainHugePage;
typedef virDomainHugePage *virDomainHugePagePtr;

struct _virDomaiHugePage {
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

1875 1876 1877 1878 1879 1880
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
1881 1882
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
1883 1884 1885 1886 1887
struct _virDomainDef {
    int virtType;
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
    char *name;
1888
    char *title;
1889
    char *description;
1890

1891 1892
    struct {
        unsigned int weight;
1893 1894

        size_t ndevices;
1895
        virBlkioDevicePtr devices;
1896 1897
    } blkio;

1898
    struct {
1899 1900
        unsigned long long max_balloon; /* in kibibytes */
        unsigned long long cur_balloon; /* in kibibytes */
1901 1902 1903 1904

        virDomainHugePagePtr hugepages;
        size_t nhugepages;

1905
        bool nosharepages;
1906
        bool locked;
J
Ján Tomko 已提交
1907
        int dump_core; /* enum virTristateSwitch */
1908 1909 1910 1911
        unsigned long long hard_limit; /* in kibibytes */
        unsigned long long soft_limit; /* in kibibytes */
        unsigned long long min_guarantee; /* in kibibytes */
        unsigned long long swap_hard_limit; /* in kibibytes */
1912
    } mem;
E
Eric Blake 已提交
1913 1914
    unsigned short vcpus;
    unsigned short maxvcpus;
O
Osier Yang 已提交
1915
    int placement_mode;
H
Hu Tao 已提交
1916
    virBitmapPtr cpumask;
1917

1918 1919
    struct {
        unsigned long shares;
1920
        bool sharesSpecified;
1921 1922
        unsigned long long period;
        long long quota;
1923 1924
        unsigned long long emulator_period;
        long long emulator_quota;
1925
        size_t nvcpupin;
E
Eric Blake 已提交
1926
        virDomainVcpuPinDefPtr *vcpupin;
T
Tang Chen 已提交
1927
        virDomainVcpuPinDefPtr emulatorpin;
1928 1929
    } cputune;

1930
    virDomainNumatunePtr numatune;
1931
    virDomainResourceDefPtr resource;
1932
    virDomainIdMapDef idmap;
1933

1934 1935 1936 1937 1938
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

1939 1940
    int onLockFailure; /* enum virDomainLockFailureAction */

1941
    struct {
J
Ján Tomko 已提交
1942
        /* These options are of type enum virTristateBool */
1943 1944 1945 1946
        int s3;
        int s4;
    } pm;

1947 1948
    virDomainOSDef os;
    char *emulator;
1949 1950 1951
    /* These three options are of type virTristateSwitch,
     * except VIR_DOMAIN_FEATURE_CAPABILITIES that is of type
     * virDomainCapabilitiesPolicy */
1952
    int features[VIR_DOMAIN_FEATURE_LAST];
1953
    int apic_eoi;
1954
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
1955
    int kvm_features[VIR_DOMAIN_KVM_LAST];
1956
    unsigned int hyperv_spinlocks;
1957

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

1961
    virDomainClockDef clock;
1962

1963
    size_t ngraphics;
1964
    virDomainGraphicsDefPtr *graphics;
1965

1966
    size_t ndisks;
1967 1968
    virDomainDiskDefPtr *disks;

1969
    size_t ncontrollers;
1970 1971
    virDomainControllerDefPtr *controllers;

1972
    size_t nfss;
1973 1974
    virDomainFSDefPtr *fss;

1975
    size_t nnets;
1976 1977
    virDomainNetDefPtr *nets;

1978
    size_t ninputs;
1979 1980
    virDomainInputDefPtr *inputs;

1981
    size_t nsounds;
1982 1983
    virDomainSoundDefPtr *sounds;

1984
    size_t nvideos;
1985 1986
    virDomainVideoDefPtr *videos;

1987
    size_t nhostdevs;
1988 1989
    virDomainHostdevDefPtr *hostdevs;

1990
    size_t nredirdevs;
1991 1992
    virDomainRedirdevDefPtr *redirdevs;

1993
    size_t nsmartcards;
E
Eric Blake 已提交
1994 1995
    virDomainSmartcardDefPtr *smartcards;

1996
    size_t nserials;
1997 1998
    virDomainChrDefPtr *serials;

1999
    size_t nparallels;
2000 2001
    virDomainChrDefPtr *parallels;

2002
    size_t nchannels;
2003 2004
    virDomainChrDefPtr *channels;

2005
    size_t nconsoles;
2006 2007
    virDomainChrDefPtr *consoles;

2008
    size_t nleases;
2009 2010
    virDomainLeaseDefPtr *leases;

2011
    size_t nhubs;
M
Marc-André Lureau 已提交
2012 2013
    virDomainHubDefPtr *hubs;

2014 2015 2016
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2017 2018 2019
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2020
    /* Only 1 */
R
Richard Jones 已提交
2021
    virDomainWatchdogDefPtr watchdog;
2022
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2023
    virDomainNVRAMDefPtr nvram;
2024
    virDomainTPMDefPtr tpm;
2025
    virCPUDefPtr cpu;
2026
    virSysinfoDefPtr sysinfo;
2027
    virDomainRedirFilterDefPtr redirfilter;
H
Hu Tao 已提交
2028
    virDomainPanicDefPtr panic;
2029 2030 2031

    void *namespaceData;
    virDomainXMLNamespace ns;
2032 2033 2034

    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2035 2036
};

2037
typedef enum {
2038 2039 2040 2041 2042
    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 */
2043
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2044
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2045
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2046 2047

    VIR_DOMAIN_TAINT_LAST
2048
} virDomainTaintFlags;
2049

2050
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2051 2052 2053 2054 2055 2056
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2057 2058 2059
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
2060
    virObjectLockable parent;
2061

2062
    pid_t pid;
J
Jiri Denemark 已提交
2063
    virDomainStateReason state;
2064 2065 2066

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2067
    unsigned int updated : 1;
2068 2069 2070

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

2072
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2073 2074
    virDomainSnapshotObjPtr current_snapshot;

2075 2076
    bool hasManagedSave;

2077 2078
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2079 2080

    int taint;
2081 2082
};

2083 2084
typedef struct _virDomainObjList virDomainObjList;
typedef virDomainObjList *virDomainObjListPtr;
2085

2086 2087 2088
typedef bool (*virDomainObjListFilter)(virConnectPtr conn,
                                       virDomainDefPtr def);

2089 2090 2091

/* This structure holds various callbacks and data needed
 * while parsing and creating domain XMLs */
2092 2093
typedef struct _virDomainXMLOption virDomainXMLOption;
typedef virDomainXMLOption *virDomainXMLOptionPtr;
2094 2095 2096 2097 2098 2099

typedef void *(*virDomainXMLPrivateDataAllocFunc)(void);
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *);

2100 2101
/* Called once after everything else has been parsed, for adjusting
 * overall domain defaults.  */
2102 2103 2104
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
                                             virCapsPtr caps,
                                             void *opaque);
2105 2106
/* Called once per device, for adjusting per-device settings while
 * leaving the overall domain otherwise unchanged.  */
2107
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
2108
                                                   const virDomainDef *def,
2109 2110 2111 2112 2113 2114
                                                   virCapsPtr caps,
                                                   void *opaque);

typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
struct _virDomainDefParserConfig {
2115
    /* driver domain definition callbacks */
2116 2117 2118
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;

2119
    /* private data for the callbacks */
2120 2121
    void *priv;
    virFreeCallback privFree;
2122 2123

    /* data */
2124
    bool hasWideSCSIBus;
2125
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2126 2127
};

2128 2129 2130 2131 2132 2133 2134 2135 2136
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
};

2137 2138 2139
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
                                            virDomainXMLNamespacePtr xmlns);
2140

2141 2142
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2143
virDomainXMLNamespacePtr
2144
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2145 2146
    ATTRIBUTE_NONNULL(1);

2147 2148 2149 2150 2151
int
virDomainDefPostParse(virDomainDefPtr def,
                      virCapsPtr caps,
                      virDomainXMLOptionPtr xmlopt);

2152
static inline bool
D
Daniel P. Berrange 已提交
2153
virDomainObjIsActive(virDomainObjPtr dom)
2154 2155 2156 2157
{
    return dom->def->id != -1;
}

2158
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2159
    ATTRIBUTE_NONNULL(1);
2160

2161
virDomainObjListPtr virDomainObjListNew(void);
2162

2163
virDomainObjPtr virDomainObjListFindByID(virDomainObjListPtr doms,
2164
                                         int id);
2165
virDomainObjPtr virDomainObjListFindByUUID(virDomainObjListPtr doms,
2166
                                           const unsigned char *uuid);
2167
virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
2168
                                           const char *name);
2169

2170
bool virDomainObjTaint(virDomainObjPtr obj,
2171
                       virDomainTaintFlags taint);
2172

H
Hu Tao 已提交
2173
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2174
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2175 2176
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
2177
virDomainDiskDefPtr virDomainDiskDefNew(void);
2178
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2179
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189
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 已提交
2190 2191 2192
int virDomainDeviceFindControllerModel(virDomainDefPtr def,
                                       virDomainDeviceInfoPtr info,
                                       int controllerType);
2193 2194 2195
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2196
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2197
void virDomainFSDefFree(virDomainFSDefPtr def);
2198
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
2199
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2200
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2201
void virDomainChrDefFree(virDomainChrDefPtr def);
2202
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
2203 2204
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr src,
                              virDomainChrSourceDefPtr dest);
2205
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
2206
void virDomainSoundDefFree(virDomainSoundDefPtr def);
2207
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2208
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2209
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
2210
void virDomainVideoDefFree(virDomainVideoDefPtr def);
2211 2212
virDomainHostdevDefPtr virDomainHostdevDefAlloc(void);
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2213
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2214
void virDomainHubDefFree(virDomainHubDefPtr def);
2215
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2216
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2217
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2218
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2219
                                             const virDomainDef *def,
2220 2221
                                             virCapsPtr caps,
                                             virDomainXMLOptionPtr xmlopt);
2222 2223
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                  int type);
2224
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
2225 2226
int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst,
                            virDomainDeviceInfoPtr src);
2227
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
2228
void virDomainDefClearPCIAddresses(virDomainDefPtr def);
2229
void virDomainDefClearCCWAddresses(virDomainDefPtr def);
D
Daniel P. Berrange 已提交
2230
void virDomainDefClearDeviceAliases(virDomainDefPtr def);
2231
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2232

2233
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2234 2235
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2236 2237 2238 2239 2240 2241
                                           void *opaque);

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

2242 2243
void virDomainDefFree(virDomainDefPtr vm);

M
Michal Novotny 已提交
2244 2245
virDomainChrDefPtr virDomainChrDefNew(void);

2246 2247 2248 2249
virDomainDefPtr virDomainDefNew(const char *name,
                                const unsigned char *uuid,
                                int id);

2250 2251 2252 2253
enum {
    VIR_DOMAIN_OBJ_LIST_ADD_LIVE = (1 << 0),
    VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1),
};
2254
virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms,
2255
                                    virDomainDefPtr def,
2256
                                    virDomainXMLOptionPtr xmlopt,
2257 2258
                                    unsigned int flags,
                                    virDomainDefPtr *oldDef);
2259
void virDomainObjAssignDef(virDomainObjPtr domain,
2260
                           virDomainDefPtr def,
2261 2262
                           bool live,
                           virDomainDefPtr *oldDef);
2263
int virDomainObjSetDefTransient(virCapsPtr caps,
2264
                                virDomainXMLOptionPtr xmlopt,
2265 2266
                                virDomainObjPtr domain,
                                bool live);
2267 2268
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
2269
                             virDomainXMLOptionPtr xmlopt,
2270
                             virDomainObjPtr domain);
2271 2272 2273

int
virDomainLiveConfigHelperMethod(virCapsPtr caps,
2274
                                virDomainXMLOptionPtr xmlopt,
2275 2276 2277 2278
                                virDomainObjPtr dom,
                                unsigned int *flags,
                                virDomainDefPtr *persistentDef);

2279 2280 2281 2282 2283 2284 2285
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virCapsPtr caps,
                                 virDomainXMLOptionPtr xmlopt,
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt);
2286

2287 2288
void virDomainObjListRemove(virDomainObjListPtr doms,
                            virDomainObjPtr dom);
2289 2290
void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
                                  virDomainObjPtr dom);
2291

2292
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
2293
                                              const virDomainDef *def,
2294 2295
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
2296
                                              unsigned int flags);
2297 2298
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                        virCapsPtr caps,
2299
                                        virDomainXMLOptionPtr xmlopt,
M
Matthias Bolte 已提交
2300
                                        unsigned int expectedVirtTypes,
L
Laine Stump 已提交
2301
                                        unsigned int flags);
2302 2303
virDomainDefPtr virDomainDefParseFile(const char *filename,
                                      virCapsPtr caps,
2304
                                      virDomainXMLOptionPtr xmlopt,
M
Matthias Bolte 已提交
2305
                                      unsigned int expectedVirtTypes,
L
Laine Stump 已提交
2306
                                      unsigned int flags);
2307
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
2308
                                      xmlNodePtr root,
2309 2310
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
M
Matthias Bolte 已提交
2311
                                      unsigned int expectedVirtTypes,
L
Laine Stump 已提交
2312
                                      unsigned int flags);
2313

2314 2315 2316
bool virDomainDefCheckABIStability(virDomainDefPtr src,
                                   virDomainDefPtr dst);

2317
int virDomainDefAddImplicitControllers(virDomainDefPtr def);
2318

2319
char *virDomainDefFormat(virDomainDefPtr def,
L
Laine Stump 已提交
2320
                         unsigned int flags);
2321 2322 2323
int virDomainDefFormatInternal(virDomainDefPtr def,
                               unsigned int flags,
                               virBufferPtr buf);
2324

2325 2326 2327 2328
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
                              int policy,
                              unsigned int flags);
2329

2330 2331 2332 2333
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
                          unsigned int flags);

2334 2335 2336 2337 2338 2339
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

2340
int virDomainDefCompatibleDevice(virDomainDefPtr def,
2341 2342
                                 virDomainDeviceDefPtr dev,
                                 virDomainDeviceAction action);
2343

2344
int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list,
2345
                        size_t *nvcpupin,
2346 2347 2348 2349
                        unsigned char *cpumap,
                        int maplen,
                        int vcpu);

2350
void virDomainVcpuPinDel(virDomainDefPtr def, int vcpu);
2351

2352 2353 2354 2355 2356 2357
int virDomainEmulatorPinAdd(virDomainDefPtr def,
                              unsigned char *cpumap,
                              int maplen);

int virDomainEmulatorPinDel(virDomainDefPtr def);

2358 2359
void virDomainRNGDefFree(virDomainRNGDefPtr def);

2360 2361 2362
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
2363
int virDomainDiskInsert(virDomainDefPtr def,
2364 2365
                        virDomainDiskDefPtr disk)
    ATTRIBUTE_RETURN_CHECK;
2366 2367
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
2368 2369
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
                                  virDomainDiskDefPtr def);
2370

2371 2372 2373 2374
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
2375 2376
int virDomainDiskSourceParse(xmlNodePtr node,
                             virStorageSourcePtr src);
2377

E
Eric Blake 已提交
2378
bool virDomainHasDiskMirror(virDomainObjPtr vm);
2379

2380 2381
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
2382
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
2383
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
2384
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
2385

L
Laine Stump 已提交
2386
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
2387 2388
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
2389 2390 2391
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

2392
int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
2393
            ATTRIBUTE_NONNULL(1);
2394
int virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t i, int val)
2395 2396
            ATTRIBUTE_NONNULL(1);
const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
2397
                                              size_t i)
2398 2399
            ATTRIBUTE_NONNULL(1);
int virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
2400
                                      size_t i, const char *address,
2401 2402 2403
                                      int len, bool setType)
            ATTRIBUTE_NONNULL(1);
const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def,
2404
                                              size_t i)
2405 2406
            ATTRIBUTE_NONNULL(1);
int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
2407
                                      size_t i, const char *network, int len)
2408 2409
            ATTRIBUTE_NONNULL(1);

2410
int virDomainNetGetActualType(virDomainNetDefPtr iface);
2411 2412
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
2413
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
2414
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
2415
virNetDevVPortProfilePtr
2416
virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface);
2417
virNetDevBandwidthPtr
2418
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
2419
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
2420

2421
int virDomainControllerInsert(virDomainDefPtr def,
2422 2423
                              virDomainControllerDefPtr controller)
    ATTRIBUTE_RETURN_CHECK;
2424 2425
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
2426 2427
int virDomainControllerFind(virDomainDefPtr def, int type, int idx);
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
2428 2429 2430 2431 2432

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
2433 2434
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
    ATTRIBUTE_RETURN_CHECK;
2435 2436
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
2437 2438 2439 2440 2441
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
2442

2443
void
2444
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
2445
                          virDomainChrDeviceType type,
2446 2447 2448
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
2449 2450 2451
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
2452 2453 2454
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
2455 2456 2457 2458 2459 2460 2461
int
virDomainChrInsert(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

2462
int virDomainSaveXML(const char *configDir,
2463 2464 2465
                     virDomainDefPtr def,
                     const char *xml);

2466
int virDomainSaveConfig(const char *configDir,
2467
                        virDomainDefPtr def);
2468
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
2469
                        const char *statusDir,
2470
                        virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK;
2471

2472 2473 2474 2475
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

2476 2477 2478 2479
int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
                                   const char *configDir,
                                   const char *autostartDir,
                                   int liveStatus,
2480 2481
                                   virCapsPtr caps,
                                   virDomainXMLOptionPtr xmlopt,
2482 2483 2484
                                   unsigned int expectedVirtTypes,
                                   virDomainLoadConfigNotify notify,
                                   void *opaque);
2485

2486
int virDomainDeleteConfig(const char *configDir,
2487
                          const char *autostartDir,
2488 2489
                          virDomainObjPtr dom);

2490
char *virDomainConfigFile(const char *dir,
2491 2492
                          const char *name);

2493 2494 2495 2496
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

2497
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
2498
                                                  const char *target);
2499
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
2500
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
2501 2502
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

2503 2504
int virDomainVideoDefaultType(const virDomainDef *def);
int virDomainVideoDefaultRAM(const virDomainDef *def, int type);
2505

2506 2507 2508 2509
int virDomainObjListNumOfDomains(virDomainObjListPtr doms,
                                 bool active,
                                 virDomainObjListFilter filter,
                                 virConnectPtr conn);
2510 2511 2512

int virDomainObjListGetActiveIDs(virDomainObjListPtr doms,
                                 int *ids,
2513 2514 2515
                                 int maxids,
                                 virDomainObjListFilter filter,
                                 virConnectPtr conn);
2516 2517
int virDomainObjListGetInactiveNames(virDomainObjListPtr doms,
                                     char **const names,
2518 2519 2520
                                     int maxnames,
                                     virDomainObjListFilter filter,
                                     virConnectPtr conn);
2521

2522 2523 2524 2525 2526 2527 2528
typedef int (*virDomainObjListIterator)(virDomainObjPtr dom,
                                        void *opaque);

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

E
Eric Blake 已提交
2529 2530 2531 2532 2533 2534 2535 2536 2537
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

2538 2539 2540 2541 2542 2543 2544 2545 2546
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

2547 2548 2549 2550 2551 2552 2553 2554 2555 2556
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 已提交
2557 2558 2559 2560 2561 2562 2563
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

2564 2565 2566
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

2567 2568 2569
virSecurityDeviceLabelDefPtr
virDomainChrDefGetSecurityLabelDef(virDomainChrDefPtr def, const char *model);

2570 2571
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
2572

2573
VIR_ENUM_DECL(virDomainTaint)
2574 2575 2576
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
VIR_ENUM_DECL(virDomainFeature)
2577 2578
VIR_ENUM_DECL(virDomainCapabilitiesPolicy)
VIR_ENUM_DECL(virDomainCapsFeature)
2579
VIR_ENUM_DECL(virDomainLifecycle)
2580
VIR_ENUM_DECL(virDomainLifecycleCrash)
2581
VIR_ENUM_DECL(virDomainDevice)
2582
VIR_ENUM_DECL(virDomainDeviceAddress)
2583
VIR_ENUM_DECL(virDomainDiskDevice)
J
J.B. Joret 已提交
2584
VIR_ENUM_DECL(virDomainDiskGeometryTrans)
2585
VIR_ENUM_DECL(virDomainDiskBus)
2586
VIR_ENUM_DECL(virDomainDiskCache)
2587
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
M
Matthias Dahl 已提交
2588
VIR_ENUM_DECL(virDomainDiskIo)
2589
VIR_ENUM_DECL(virDomainDeviceSGIO)
2590
VIR_ENUM_DECL(virDomainDiskTray)
O
Osier Yang 已提交
2591
VIR_ENUM_DECL(virDomainDiskDiscard)
2592
VIR_ENUM_DECL(virDomainDiskMirrorState)
2593
VIR_ENUM_DECL(virDomainController)
J
Ján Tomko 已提交
2594
VIR_ENUM_DECL(virDomainControllerModelPCI)
2595
VIR_ENUM_DECL(virDomainControllerModelSCSI)
M
Marc-André Lureau 已提交
2596
VIR_ENUM_DECL(virDomainControllerModelUSB)
2597
VIR_ENUM_DECL(virDomainFS)
2598
VIR_ENUM_DECL(virDomainFSDriver)
2599
VIR_ENUM_DECL(virDomainFSAccessMode)
2600
VIR_ENUM_DECL(virDomainFSWrpolicy)
2601
VIR_ENUM_DECL(virDomainNet)
2602
VIR_ENUM_DECL(virDomainNetBackend)
2603
VIR_ENUM_DECL(virDomainNetVirtioTxMode)
2604
VIR_ENUM_DECL(virDomainNetInterfaceLinkState)
2605
VIR_ENUM_DECL(virDomainChrDevice)
2606
VIR_ENUM_DECL(virDomainChrChannelTarget)
2607
VIR_ENUM_DECL(virDomainChrConsoleTarget)
G
Guannan Ren 已提交
2608
VIR_ENUM_DECL(virDomainChrSerialTarget)
E
Eric Blake 已提交
2609
VIR_ENUM_DECL(virDomainSmartcard)
2610
VIR_ENUM_DECL(virDomainChr)
2611
VIR_ENUM_DECL(virDomainChrTcpProtocol)
E
Eric Blake 已提交
2612
VIR_ENUM_DECL(virDomainChrSpicevmc)
2613
VIR_ENUM_DECL(virDomainSoundCodec)
2614
VIR_ENUM_DECL(virDomainSoundModel)
2615
VIR_ENUM_DECL(virDomainMemballoonModel)
2616
VIR_ENUM_DECL(virDomainSmbiosMode)
R
Richard Jones 已提交
2617 2618
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
2619
VIR_ENUM_DECL(virDomainVideo)
2620 2621
VIR_ENUM_DECL(virDomainHostdevMode)
VIR_ENUM_DECL(virDomainHostdevSubsys)
2622
VIR_ENUM_DECL(virDomainHostdevCaps)
M
Marc-André Lureau 已提交
2623
VIR_ENUM_DECL(virDomainHub)
2624
VIR_ENUM_DECL(virDomainRedirdevBus)
2625 2626 2627
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
2628
VIR_ENUM_DECL(virDomainGraphicsListen)
2629
VIR_ENUM_DECL(virDomainGraphicsAuthConnected)
2630 2631
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
2632 2633 2634
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
2635
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
P
Peng Zhou 已提交
2636
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
2637
VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy)
2638
VIR_ENUM_DECL(virDomainHyperv)
2639
VIR_ENUM_DECL(virDomainKVM)
2640 2641
VIR_ENUM_DECL(virDomainRNGModel)
VIR_ENUM_DECL(virDomainRNGBackend)
2642 2643
VIR_ENUM_DECL(virDomainTPMModel)
VIR_ENUM_DECL(virDomainTPMBackend)
2644 2645
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
J
Jiri Denemark 已提交
2646 2647 2648 2649 2650 2651 2652
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)
2653
VIR_ENUM_DECL(virDomainPMSuspendedReason)
J
Jiri Denemark 已提交
2654 2655 2656 2657

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

2658
VIR_ENUM_DECL(virDomainSeclabel)
2659
VIR_ENUM_DECL(virDomainClockOffset)
2660
VIR_ENUM_DECL(virDomainClockBasis)
2661

2662
VIR_ENUM_DECL(virDomainTimerName)
2663
VIR_ENUM_DECL(virDomainTimerTrack)
2664 2665
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)
O
Osier Yang 已提交
2666
VIR_ENUM_DECL(virDomainCpuPlacementMode)
2667

2668
VIR_ENUM_DECL(virDomainStartupPolicy)
2669

O
Osier Yang 已提交
2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703
# 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)

2704 2705 2706
int virDomainObjListExport(virDomainObjListPtr doms,
                           virConnectPtr conn,
                           virDomainPtr **domains,
2707
                           virDomainObjListFilter filter,
2708
                           unsigned int flags);
O
Osier Yang 已提交
2709

2710 2711 2712 2713 2714
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
2715 2716 2717 2718
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
2719

2720 2721
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

2722 2723
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
2724 2725
                           virDomainDeviceDefPtr dev,
                           bool reportError);
2726

2727
bool virDomainDiskSourceIsBlockType(virStorageSourcePtr src)
2728 2729
    ATTRIBUTE_NONNULL(1);

2730 2731
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

2732 2733 2734 2735 2736 2737 2738
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              virCapsPtr caps,
                              virDomainXMLOptionPtr xmlopt,
                              unsigned int flags);

2739 2740 2741 2742 2743 2744 2745
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
2746
                            const char *stateDir,
2747 2748 2749
                            const char *configDir,
                            unsigned int flags);

2750 2751 2752
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

2753
#endif /* __DOMAIN_CONF_H */