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

23 24
#ifndef LIBVIRT_DOMAIN_CONF_H
# define LIBVIRT_DOMAIN_CONF_H
25

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

30 31
# include "internal.h"
# include "capabilities.h"
32
# include "virstorageencryption.h"
33
# include "cpu_conf.h"
34
# include "virthread.h"
35
# include "virhash.h"
36
# include "virsocketaddr.h"
37
# include "networkcommon_conf.h"
38
# include "nwfilter_params.h"
39
# include "numa_conf.h"
40
# include "virnetdevmacvlan.h"
41
# include "virsysinfo.h"
42
# include "virnetdev.h"
43
# include "virnetdevip.h"
44 45
# include "virnetdevvportprofile.h"
# include "virnetdevbandwidth.h"
46
# include "virnetdevvlan.h"
47
# include "virobject.h"
48
# include "device_conf.h"
49
# include "virbitmap.h"
50
# include "virstoragefile.h"
51
# include "virseclabel.h"
52
# include "virprocess.h"
53
# include "virgic.h"
Q
Qiaowei Ren 已提交
54
# include "virperf.h"
55
# include "virtypedparam.h"
56
# include "virsavecookie.h"
57
# include "virresctrl.h"
58

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
/* 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;

80 81 82
typedef struct _virDomainSoundCodecDef virDomainSoundCodecDef;
typedef virDomainSoundCodecDef *virDomainSoundCodecDefPtr;

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
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;

104 105
typedef struct _virDomainRedirFilterUSBDevDef virDomainRedirFilterUSBDevDef;
typedef virDomainRedirFilterUSBDevDef *virDomainRedirFilterUSBDevDefPtr;
106 107 108 109

typedef struct _virDomainRedirFilterDef virDomainRedirFilterDef;
typedef virDomainRedirFilterDef *virDomainRedirFilterDefPtr;

110 111 112 113 114 115 116 117 118
typedef struct _virDomainSmartcardDef virDomainSmartcardDef;
typedef virDomainSmartcardDef *virDomainSmartcardDefPtr;

typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr;

typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;

L
Li Zhang 已提交
119 120 121
typedef struct _virDomainNVRAMDef virDomainNVRAMDef;
typedef virDomainNVRAMDef *virDomainNVRAMDefPtr;

122 123 124 125 126 127
typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;

typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
typedef virDomainSnapshotObjList *virDomainSnapshotObjListPtr;

128 129 130
typedef struct _virDomainRNGDef virDomainRNGDef;
typedef virDomainRNGDef *virDomainRNGDefPtr;

131 132 133 134 135 136
typedef struct _virDomainIdMapEntry virDomainIdMapEntry;
typedef virDomainIdMapEntry *virDomainIdMapEntryPtr;

typedef struct _virDomainIdMapDef virDomainIdMapDef;
typedef virDomainIdMapDef *virDomainIdMapDefPtr;

H
Hu Tao 已提交
137 138 139
typedef struct _virDomainPanicDef virDomainPanicDef;
typedef virDomainPanicDef *virDomainPanicDefPtr;

140 141 142
typedef struct _virDomainMemoryDef virDomainMemoryDef;
typedef virDomainMemoryDef *virDomainMemoryDefPtr;

M
Michele Paolino 已提交
143 144 145 146 147 148
/* forward declarations virDomainChrSourceDef, required by
 * virDomainNetDef
 */
typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;

149 150 151
typedef struct _virDomainShmemDef virDomainShmemDef;
typedef virDomainShmemDef *virDomainShmemDefPtr;

152 153 154
typedef struct _virDomainTPMDef virDomainTPMDef;
typedef virDomainTPMDef *virDomainTPMDefPtr;

J
Ján Tomko 已提交
155 156 157
typedef struct _virDomainIOMMUDef virDomainIOMMUDef;
typedef virDomainIOMMUDef *virDomainIOMMUDefPtr;

J
Ján Tomko 已提交
158 159 160
typedef struct _virDomainVsockDef virDomainVsockDef;
typedef virDomainVsockDef *virDomainVsockDefPtr;

161 162 163
typedef struct _virDomainVirtioOptions virDomainVirtioOptions;
typedef virDomainVirtioOptions *virDomainVirtioOptionsPtr;

164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
/* 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 已提交
183
    VIR_DOMAIN_DEVICE_NVRAM,
184
    VIR_DOMAIN_DEVICE_RNG,
185
    VIR_DOMAIN_DEVICE_SHMEM,
186
    VIR_DOMAIN_DEVICE_TPM,
187
    VIR_DOMAIN_DEVICE_PANIC,
188
    VIR_DOMAIN_DEVICE_MEMORY,
J
Ján Tomko 已提交
189
    VIR_DOMAIN_DEVICE_IOMMU,
J
Ján Tomko 已提交
190
    VIR_DOMAIN_DEVICE_VSOCK,
191

192
    VIR_DOMAIN_DEVICE_LAST
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
} 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 已提交
216
        virDomainNVRAMDefPtr nvram;
217
        virDomainRNGDefPtr rng;
218
        virDomainShmemDefPtr shmem;
219
        virDomainTPMDefPtr tpm;
220
        virDomainPanicDefPtr panic;
221
        virDomainMemoryDefPtr memory;
J
Ján Tomko 已提交
222
        virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
223
        virDomainVsockDefPtr vsock;
224 225 226
    } data;
};

227 228
/* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */
229
typedef enum {
230
    VIR_DOMAIN_VIRT_NONE = 0,
231 232 233 234 235 236 237 238 239 240
    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,
241
    VIR_DOMAIN_VIRT_VBOX,
242
    VIR_DOMAIN_VIRT_PHYP,
D
Dmitry Guryanov 已提交
243
    VIR_DOMAIN_VIRT_PARALLELS,
R
Roman Bogorodskiy 已提交
244
    VIR_DOMAIN_VIRT_BHYVE,
245
    VIR_DOMAIN_VIRT_VZ,
246

247
    VIR_DOMAIN_VIRT_LAST
248
} virDomainVirtType;
249

250 251 252 253 254 255
typedef enum {
    VIR_DOMAIN_OSTYPE_HVM,
    VIR_DOMAIN_OSTYPE_XEN,
    VIR_DOMAIN_OSTYPE_LINUX,
    VIR_DOMAIN_OSTYPE_EXE,
    VIR_DOMAIN_OSTYPE_UML,
256
    VIR_DOMAIN_OSTYPE_XENPVH,
257 258 259

    VIR_DOMAIN_OSTYPE_LAST
} virDomainOSType;
260
VIR_ENUM_DECL(virDomainOS);
261 262


263 264 265 266 267 268 269 270
typedef struct _virDomainHostdevOrigStates virDomainHostdevOrigStates;
typedef virDomainHostdevOrigStates *virDomainHostdevOrigStatesPtr;
struct _virDomainHostdevOrigStates {
    union {
        struct {
            /* Does the device need to unbind from stub when
             * reattaching to host?
             */
271
            bool unbind_from_stub;
272 273 274 275

            /* Does it need to use remove_slot when reattaching
             * the device to host?
             */
276
            bool remove_slot;
277 278 279 280

            /* Does it need to reprobe driver for the device when
             * reattaching to host?
             */
281
            bool reprobe;
282 283 284 285 286 287
        } pci;

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

288 289 290 291 292 293 294
struct _virDomainLeaseDef {
    char *lockspace;
    char *key;
    char *path;
    unsigned long long offset;
};

295

296
typedef enum {
297 298 299
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

300
    VIR_DOMAIN_HOSTDEV_MODE_LAST
301
} virDomainHostdevMode;
302

303
typedef enum {
304 305
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
H
Han Cheng 已提交
306
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
307
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST,
308
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV,
309 310

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
311
} virDomainHostdevSubsysType;
312

313 314
/* the backend driver used for PCI hostdev devices */
typedef enum {
N
Nitesh Konkar 已提交
315
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automatically, prefer VFIO */
316 317
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM,    /* force legacy kvm style */
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO,   /* force vfio */
318
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN,    /* force legacy xen style, use pciback */
319 320

    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
321
} virDomainHostdevSubsysPCIBackendType;
322

323
VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend);
324

325 326 327 328 329 330 331
typedef enum {
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE,
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI,

    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
} virDomainHostdevSCSIProtocolType;

332
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol);
333

334 335 336 337 338 339 340 341 342 343 344 345
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;
};

346 347 348
typedef struct _virDomainHostdevSubsysPCI virDomainHostdevSubsysPCI;
typedef virDomainHostdevSubsysPCI *virDomainHostdevSubsysPCIPtr;
struct _virDomainHostdevSubsysPCI {
349
    virPCIDeviceAddress addr; /* host address */
350 351 352
    int backend; /* enum virDomainHostdevSubsysPCIBackendType */
};

353 354 355
typedef struct _virDomainHostdevSubsysSCSIHost virDomainHostdevSubsysSCSIHost;
typedef virDomainHostdevSubsysSCSIHost *virDomainHostdevSubsysSCSIHostPtr;
struct _virDomainHostdevSubsysSCSIHost {
356 357 358
    char *adapter;
    unsigned bus;
    unsigned target;
359
    unsigned long long unit;
360 361
};

362 363 364
typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI;
typedef virDomainHostdevSubsysSCSIiSCSI *virDomainHostdevSubsysSCSIiSCSIPtr;
struct _virDomainHostdevSubsysSCSIiSCSI {
365
    virStorageSourcePtr src;
366 367
};

368 369 370
typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
typedef virDomainHostdevSubsysSCSI *virDomainHostdevSubsysSCSIPtr;
struct _virDomainHostdevSubsysSCSI {
371
    int protocol; /* enum virDomainHostdevSCSIProtocolType */
372
    int sgio; /* enum virDomainDeviceSGIO */
373
    int rawio; /* enum virTristateBool */
374 375
    union {
        virDomainHostdevSubsysSCSIHost host;
376
        virDomainHostdevSubsysSCSIiSCSI iscsi;
377
    } u;
378 379
};

380 381 382 383
typedef struct _virDomainHostdevSubsysMediatedDev virDomainHostdevSubsysMediatedDev;
typedef virDomainHostdevSubsysMediatedDev *virDomainHostdevSubsysMediatedDevPtr;
struct _virDomainHostdevSubsysMediatedDev {
    int model;                          /* enum virMediatedDeviceModelType */
384
    int display; /* virTristateSwitch */
385 386 387
    char uuidstr[VIR_UUID_STRING_BUFLEN];   /* mediated device's uuid string */
};

388 389 390 391 392 393 394
typedef enum {
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_NONE,
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST,

    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST,
} virDomainHostdevSubsysSCSIHostProtocolType;

395
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIHostProtocol);
396

397 398 399 400 401 402 403 404 405 406 407
typedef enum {
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_DEFAULT,
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO,
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_LAST,
} virDomainHostdevSubsysSCSIVHostModelType;

VIR_ENUM_DECL(virDomainHostdevSubsysSCSIVHostModel);

408 409 410 411 412
typedef struct _virDomainHostdevSubsysSCSIVHost virDomainHostdevSubsysSCSIVHost;
typedef virDomainHostdevSubsysSCSIVHost *virDomainHostdevSubsysSCSIVHostPtr;
struct _virDomainHostdevSubsysSCSIVHost {
    int protocol; /* enum virDomainHostdevSubsysSCSIHostProtocolType */
    char *wwpn;
413
    int model; /* enum virDomainHostdevSubsysSCSIVHostModelType */
414 415
};

416 417 418
typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys {
419
    int type; /* enum virDomainHostdevSubsysType */
420
    union {
421
        virDomainHostdevSubsysUSB usb;
422
        virDomainHostdevSubsysPCI pci;
423
        virDomainHostdevSubsysSCSI scsi;
424
        virDomainHostdevSubsysSCSIVHost scsi_host;
425
        virDomainHostdevSubsysMediatedDev mdev;
426 427 428
    } u;
};

429

430
typedef enum {
431 432
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
433
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
434 435

    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
436
} virDomainHostdevCapsType;
437 438 439 440 441 442 443 444 445 446 447 448

typedef struct _virDomainHostdevCaps virDomainHostdevCaps;
typedef virDomainHostdevCaps *virDomainHostdevCapsPtr;
struct _virDomainHostdevCaps {
    int type; /* enum virDOmainHostdevCapsType */
    union {
        struct {
            char *block;
        } storage;
        struct {
            char *chardev;
        } misc;
449
        struct {
450 451
            char *ifname;
            virNetDevIPInfo ip;
452
        } net;
453 454 455 456
    } u;
};


457 458
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
459
    virDomainDeviceDef parent; /* higher level Def containing this */
460

461
    int mode; /* enum virDomainHostdevMode */
462
    int startupPolicy; /* enum virDomainStartupPolicy */
463
    bool managed;
464
    bool missing;
O
Osier Yang 已提交
465
    bool readonly;
466
    bool shareable;
467
    union {
468
        virDomainHostdevSubsys subsys;
469
        virDomainHostdevCaps caps;
470 471
    } source;
    virDomainHostdevOrigStates origstates;
472
    virDomainDeviceInfoPtr info; /* Guest address */
473 474
};

475

E
Eric Blake 已提交
476 477
/* Types of disk frontend (guest view).  For backends (host view), see
 * virStorageType in util/virstoragefile.h */
478
typedef enum {
479 480 481
    VIR_DOMAIN_DISK_DEVICE_DISK,
    VIR_DOMAIN_DISK_DEVICE_CDROM,
    VIR_DOMAIN_DISK_DEVICE_FLOPPY,
482
    VIR_DOMAIN_DISK_DEVICE_LUN,
483 484

    VIR_DOMAIN_DISK_DEVICE_LAST
485
} virDomainDiskDevice;
486

487
typedef enum {
488 489 490 491 492
    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,
493
    VIR_DOMAIN_DISK_BUS_USB,
494
    VIR_DOMAIN_DISK_BUS_UML,
495
    VIR_DOMAIN_DISK_BUS_SATA,
496
    VIR_DOMAIN_DISK_BUS_SD,
497 498

    VIR_DOMAIN_DISK_BUS_LAST
499
} virDomainDiskBus;
500

501
typedef enum {
502 503 504 505
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
506
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
507
    VIR_DOMAIN_DISK_CACHE_UNSAFE,
508 509

    VIR_DOMAIN_DISK_CACHE_LAST
510
} virDomainDiskCache;
511

512
typedef enum {
513 514
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
515
    VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
516
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
517
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
518 519

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
520
} virDomainDiskErrorPolicy;
521

M
MORITA Kazutaka 已提交
522

523
typedef enum {
524
    VIR_DOMAIN_DISK_TRAY_CLOSED = 0,
525 526 527
    VIR_DOMAIN_DISK_TRAY_OPEN,

    VIR_DOMAIN_DISK_TRAY_LAST
528
} virDomainDiskTray;
529

530
typedef enum {
J
J.B. Joret 已提交
531 532 533 534 535 536
    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
537
} virDomainDiskGeometryTrans;
J
J.B. Joret 已提交
538

539
typedef enum {
540
    VIR_DOMAIN_DISK_IO_DEFAULT = 0,
M
Matthias Dahl 已提交
541 542 543 544
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
545
} virDomainDiskIo;
M
Matthias Dahl 已提交
546

547
typedef enum {
548 549 550 551 552 553
    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
554
} virDomainStartupPolicy;
555

556

557
typedef enum {
558 559 560
    VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
    VIR_DOMAIN_DEVICE_SGIO_FILTERED,
    VIR_DOMAIN_DEVICE_SGIO_UNFILTERED,
O
Osier Yang 已提交
561

562
    VIR_DOMAIN_DEVICE_SGIO_LAST
563
} virDomainDeviceSGIO;
O
Osier Yang 已提交
564

565
typedef enum {
O
Osier Yang 已提交
566
    VIR_DOMAIN_DISK_DISCARD_DEFAULT = 0,
O
Osier Yang 已提交
567 568
    VIR_DOMAIN_DISK_DISCARD_UNMAP,
    VIR_DOMAIN_DISK_DISCARD_IGNORE,
O
Osier Yang 已提交
569 570

    VIR_DOMAIN_DISK_DISCARD_LAST
571
} virDomainDiskDiscard;
O
Osier Yang 已提交
572

573 574 575 576 577 578 579 580 581
typedef enum {
    VIR_DOMAIN_DISK_DETECT_ZEROES_DEFAULT = 0,
    VIR_DOMAIN_DISK_DETECT_ZEROES_OFF,
    VIR_DOMAIN_DISK_DETECT_ZEROES_ON,
    VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP,

    VIR_DOMAIN_DISK_DETECT_ZEROES_LAST
} virDomainDiskDetectZeroes;

582 583 584 585 586 587 588 589 590
typedef enum {
    VIR_DOMAIN_DISK_MODEL_DEFAULT = 0,
    VIR_DOMAIN_DISK_MODEL_VIRTIO,
    VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_DISK_MODEL_LAST
} virDomainDiskModel;

L
Lei Li 已提交
591 592 593 594 595 596 597 598
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;
599 600 601 602 603 604 605
    unsigned long long total_bytes_sec_max;
    unsigned long long read_bytes_sec_max;
    unsigned long long write_bytes_sec_max;
    unsigned long long total_iops_sec_max;
    unsigned long long read_iops_sec_max;
    unsigned long long write_iops_sec_max;
    unsigned long long size_iops_sec;
606
    char *group_name;
607 608 609 610 611 612
    unsigned long long total_bytes_sec_max_length;
    unsigned long long read_bytes_sec_max_length;
    unsigned long long write_bytes_sec_max_length;
    unsigned long long total_iops_sec_max_length;
    unsigned long long read_iops_sec_max_length;
    unsigned long long write_iops_sec_max_length;
L
Lei Li 已提交
613 614 615
};
typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;

616

617 618 619 620 621 622 623 624 625
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;

626 627 628 629
typedef enum {
    VIR_DOMAIN_MEMORY_SOURCE_NONE = 0,  /* No memory source defined */
    VIR_DOMAIN_MEMORY_SOURCE_FILE,      /* Memory source is set as file */
    VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS, /* Memory source is set as anonymous */
M
Marc-André Lureau 已提交
630
    VIR_DOMAIN_MEMORY_SOURCE_MEMFD,     /* Memory source is set as memfd */
631 632 633 634 635 636 637 638 639 640 641 642

    VIR_DOMAIN_MEMORY_SOURCE_LAST,
} virDomainMemorySource;

typedef enum {
    VIR_DOMAIN_MEMORY_ALLOCATION_NONE = 0,  /* No memory allocation defined */
    VIR_DOMAIN_MEMORY_ALLOCATION_IMMEDIATE, /* Memory allocation is set as immediate */
    VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND,  /* Memory allocation is set as ondemand */

    VIR_DOMAIN_MEMORY_ALLOCATION_LAST,
} virDomainMemoryAllocation;

643

644 645
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
646
    virStorageSourcePtr src; /* non-NULL.  XXX Allow NULL for empty cdrom? */
647

648 649
    virObjectPtr privateData;

650 651 652 653
    int device; /* enum virDomainDiskDevice */
    int bus; /* enum virDomainDiskBus */
    char *dst;
    int tray_status; /* enum virDomainDiskTray */
J
Ján Tomko 已提交
654
    int removable; /* enum virTristateSwitch */
L
Lei Li 已提交
655

656
    virStorageSourcePtr mirror;
657
    int mirrorState; /* enum virDomainDiskMirrorState */
E
Eric Blake 已提交
658
    int mirrorJob; /* virDomainBlockJobType */
659

J
J.B. Joret 已提交
660 661 662 663
    struct {
        unsigned int cylinders;
        unsigned int heads;
        unsigned int sectors;
664
        int trans; /* enum virDomainDiskGeometryTrans */
J
J.B. Joret 已提交
665 666
    } geometry;

667 668 669
    struct {
        unsigned int logical_block_size;
        unsigned int physical_block_size;
V
Viktor Mihajlovski 已提交
670
    } blockio;
671

L
Lei Li 已提交
672 673
    virDomainBlockIoTuneInfo blkdeviotune;

674 675
    char *driverName;

676
    char *serial;
O
Osier Yang 已提交
677
    char *wwn;
678 679
    char *vendor;
    char *product;
680
    int cachemode; /* enum virDomainDiskCache */
681 682
    int error_policy;  /* enum virDomainDiskErrorPolicy */
    int rerror_policy; /* enum virDomainDiskErrorPolicy */
683
    int iomode; /* enum virDomainDiskIo */
J
Ján Tomko 已提交
684 685 686
    int ioeventfd; /* enum virTristateSwitch */
    int event_idx; /* enum virTristateSwitch */
    int copy_on_read; /* enum virTristateSwitch */
687
    int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
688
    int startupPolicy; /* enum virDomainStartupPolicy */
689
    bool transient;
690
    virDomainDeviceInfo info;
691
    int rawio; /* enum virTristateBool */
692
    int sgio; /* enum virDomainDeviceSGIO */
O
Osier Yang 已提交
693
    int discard; /* enum virDomainDiskDiscard */
694
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
695
    int detect_zeroes; /* enum virDomainDiskDetectZeroes */
696
    char *domain_name; /* backend domain name */
L
Lin Ma 已提交
697
    unsigned int queues;
698
    int model; /* enum virDomainDiskModel */
J
Ján Tomko 已提交
699
    virDomainVirtioOptionsPtr virtio;
700 701 702
};


703
typedef enum {
704 705 706 707
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
708
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
709
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
710
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
J
Ján Tomko 已提交
711
    VIR_DOMAIN_CONTROLLER_TYPE_PCI,
712
    VIR_DOMAIN_CONTROLLER_TYPE_XENBUS,
713 714

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
715
} virDomainControllerType;
716

717

718
typedef enum {
719
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT = -1,
J
Ján Tomko 已提交
720
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
L
Laine Stump 已提交
721
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
J
Ján Tomko 已提交
722
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
723
    VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
724
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE,
725
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT,
726
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT,
727
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT,
728
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS,
729
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS,
J
Ján Tomko 已提交
730 731

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
732
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
733

734
typedef enum {
735
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE = 0,
736 737
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE,
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE,
738
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420,
739
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM,
740
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM,
741
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB,
742
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE,
743
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT,
744
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE,
745
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_PCI_BRIDGE,
746 747 748 749

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

750
typedef enum {
751
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT = -1,
752 753 754 755 756
    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,
757
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
758
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
759
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
760 761
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL,
762

763
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
764
} virDomainControllerModelSCSI;
765

766
typedef enum {
767
    VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT = -1,
M
Marc-André Lureau 已提交
768 769 770 771 772 773 774 775 776
    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 已提交
777
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
778 779
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2,
780
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI,
781
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
M
Marc-André Lureau 已提交
782 783

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
784
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
785

786
typedef enum {
787
    VIR_DOMAIN_CONTROLLER_MODEL_IDE_DEFAULT = -1,
788 789 790 791 792 793 794
    VIR_DOMAIN_CONTROLLER_MODEL_IDE_PIIX3,
    VIR_DOMAIN_CONTROLLER_MODEL_IDE_PIIX4,
    VIR_DOMAIN_CONTROLLER_MODEL_IDE_ICH6,

    VIR_DOMAIN_CONTROLLER_MODEL_IDE_LAST
} virDomainControllerModelIDE;

795 796 797 798 799 800 801 802 803
typedef enum {
    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_DEFAULT = -1,
    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO,
    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_LAST
} virDomainControllerModelVirtioSerial;

804 805 806 807 808 809 810
# define IS_USB2_CONTROLLER(ctrl) \
    (((ctrl)->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) && \
     ((ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1 || \
      (ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1 || \
      (ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2 || \
      (ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3))

811 812 813 814 815 816 817
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

818 819 820
typedef struct _virDomainPCIControllerOpts virDomainPCIControllerOpts;
typedef virDomainPCIControllerOpts *virDomainPCIControllerOptsPtr;
struct _virDomainPCIControllerOpts {
821 822
    bool pcihole64;
    unsigned long pcihole64size;
823 824 825 826 827 828 829

    /* the exact controller name is in the "model" subelement, e.g.:
     * <controller type='pci' model='pcie-root-port'>
     *   <model name='ioh3420''/>
     *   ...
     */
    int modelName; /* the exact name of the device in hypervisor */
830 831 832 833 834 835 836 837

    /* the following items are attributes of the "target" subelement
     * of controller type='pci'. They are bits of configuration that
     * are specified on the qemu commandline and are visible to the
     * guest OS, so they must be preserved to ensure ABI
     * compatibility.
     */
    int chassisNr; /* used by pci-bridge, -1 == unspecified */
838 839 840 841
    /* chassis & port used by
     * pcie-root-port/pcie-switch-downstream-port, -1 = unspecified */
    int chassis;
    int port;
842
    int busNr; /* used by pci-expander-bus, -1 == unspecified */
843
    int targetIndex; /* used by spapr-pci-host-bridge, -1 == unspecified */
844 845 846 847
    /* numaNode is a *subelement* of target (to match existing
     * item in memory target config) -1 == unspecified
     */
    int numaNode;
848
};
849

850 851 852 853 854 855
typedef struct _virDomainUSBControllerOpts virDomainUSBControllerOpts;
typedef virDomainUSBControllerOpts *virDomainUSBControllerOptsPtr;
struct _virDomainUSBControllerOpts {
    int ports;   /* -1 == undef */
};

856 857 858 859 860 861
typedef struct _virDomainXenbusControllerOpts virDomainXenbusControllerOpts;
typedef virDomainXenbusControllerOpts *virDomainXenbusControllerOptsPtr;
struct _virDomainXenbusControllerOpts {
    int maxGrantFrames;   /* -1 == undef */
};

862 863 864
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
    int type;
865
    int idx;
866
    int model; /* -1 == undef */
867
    unsigned int queues;
868 869
    unsigned int cmd_per_lun;
    unsigned int max_sectors;
870
    int ioeventfd; /* enum virTristateSwitch */
871
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
872 873
    union {
        virDomainVirtioSerialOpts vioserial;
874
        virDomainPCIControllerOpts pciopts;
875
        virDomainUSBControllerOpts usbopts;
876
        virDomainXenbusControllerOpts xenbusopts;
877
    } opts;
878
    virDomainDeviceInfo info;
879
    virDomainVirtioOptionsPtr virtio;
880 881 882
};


G
Giuseppe Scrivano 已提交
883
/* Types of disk backends */
884
typedef enum {
885 886 887 888 889 890
    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 */
891
    VIR_DOMAIN_FS_TYPE_VOLUME, /* Mounts storage pool volume to a guest */
892 893

    VIR_DOMAIN_FS_TYPE_LAST
894
} virDomainFSType;
895

896
/* Filesystem driver type */
897
typedef enum {
898 899 900
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
901
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
902
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
D
Dmitry Guryanov 已提交
903
    VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
904 905

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
906
} virDomainFSDriverType;
907

908
/* Filesystem mount access mode  */
909
typedef enum {
910 911 912 913 914
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
915
} virDomainFSAccessMode;
916

917
/* Filesystem Write policy */
918
typedef enum {
919 920 921 922
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
923
} virDomainFSWrpolicy;
924

925 926 927 928 929 930 931 932 933
typedef enum {
    VIR_DOMAIN_FS_MODEL_DEFAULT = 0,
    VIR_DOMAIN_FS_MODEL_VIRTIO,
    VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_FS_MODEL_LAST
} virDomainFSModel;

934 935
struct _virDomainFSDef {
    int type;
936 937
    int fsdriver; /* enum virDomainFSDriverType */
    int accessmode; /* enum virDomainFSAccessMode */
938
    int wrpolicy; /* enum virDomainFSWrpolicy */
939
    int format; /* virStorageFileFormat */
940
    int model; /* virDomainFSModel */
941
    unsigned long long usage; /* in bytes */
942
    virStorageSourcePtr src;
943
    char *dst;
944
    bool readonly;
945
    virDomainDeviceInfo info;
946 947
    unsigned long long space_hard_limit; /* in bytes */
    unsigned long long space_soft_limit; /* in bytes */
948
    bool symlinksResolved;
949
    virDomainVirtioOptionsPtr virtio;
950 951 952
};


953
/* network config types */
954
typedef enum {
955 956
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
M
Michele Paolino 已提交
957
    VIR_DOMAIN_NET_TYPE_VHOSTUSER,
958 959 960 961 962
    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 已提交
963
    VIR_DOMAIN_NET_TYPE_INTERNAL,
964
    VIR_DOMAIN_NET_TYPE_DIRECT,
965
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
966
    VIR_DOMAIN_NET_TYPE_UDP,
967

968
    VIR_DOMAIN_NET_TYPE_LAST
969
} virDomainNetType;
970

971
/* the backend driver used for virtio interfaces */
972
typedef enum {
973 974 975 976
    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 */

977
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
978
} virDomainNetBackendType;
979

980
/* the TX algorithm used for virtio interfaces */
981
typedef enum {
982 983 984 985
    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,

986
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
987
} virDomainNetVirtioTxModeType;
988

989
/* link interface states */
990
typedef enum {
991 992 993 994 995
        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
996
} virDomainNetInterfaceLinkState;
997

998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
/* 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;
1010
            int macTableManager; /* enum virNetworkBridgeMACTableManagerType */
1011 1012 1013 1014 1015
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
        } direct;
1016 1017 1018
        struct {
            virDomainHostdevDef def;
        } hostdev;
1019
    } data;
1020
    virNetDevVPortProfilePtr virtPortProfile;
1021
    virNetDevBandwidthPtr bandwidth;
1022
    virNetDevVlan vlan;
1023
    int trustGuestRxFilters; /* enum virTristateBool */
1024
    unsigned int class_id; /* class ID for bandwidth 'floor' */
1025 1026
};

1027 1028
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
1029
    virDomainNetType type;
1030
    virMacAddr mac;
1031
    bool mac_generated; /* true if mac was *just now* auto-generated by libvirt */
1032
    char *model;
1033 1034
    union {
        struct {
1035 1036
            virDomainNetBackendType name; /* which driver backend to use */
            virDomainNetVirtioTxModeType txmode;
J
Ján Tomko 已提交
1037 1038
            virTristateSwitch ioeventfd;
            virTristateSwitch event_idx;
1039
            unsigned int queues; /* Multiqueue virtio-net */
1040
            unsigned int rx_queue_size;
1041
            unsigned int tx_queue_size;
1042 1043 1044 1045 1046 1047 1048
            struct {
                virTristateSwitch csum;
                virTristateSwitch gso;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
1049
                virTristateSwitch mrg_rxbuf;
1050 1051 1052 1053 1054 1055 1056 1057
            } host;
            struct {
                virTristateSwitch csum;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
            } guest;
1058 1059
        } virtio;
    } driver;
1060 1061 1062 1063
    struct {
        char *tap;
        char *vhost;
    } backend;
1064
    union {
M
Michele Paolino 已提交
1065
        virDomainChrSourceDefPtr vhostuser;
1066 1067 1068
        struct {
            char *address;
            int port;
1069 1070
            char *localaddr;
            int localport;
1071 1072 1073
        } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
        struct {
            char *name;
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
            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;
1084 1085 1086 1087
        } network;
        struct {
            char *brname;
        } bridge;
D
Daniel Veillard 已提交
1088 1089 1090
        struct {
            char *name;
        } internal;
1091 1092
        struct {
            char *linkdev;
1093
            int mode; /* enum virMacvtapMode from util/macvtap.h */
1094
        } direct;
1095 1096 1097
        struct {
            virDomainHostdevDef def;
        } hostdev;
1098
    } data;
1099 1100
    /* virtPortProfile is used by network/bridge/direct/hostdev */
    virNetDevVPortProfilePtr virtPortProfile;
1101 1102 1103 1104
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
1105
    char *script;
1106
    char *domain_name; /* backend domain name */
1107 1108
    char *ifname; /* interface name on the host (<target dev='x'/>) */
    virNetDevIPInfo hostIP;
1109
    char *ifname_guest_actual;
1110 1111
    char *ifname_guest;
    virNetDevIPInfo guestIP;
1112
    virDomainDeviceInfo info;
1113
    char *filter;
1114
    virHashTablePtr filterparams;
1115
    virNetDevBandwidthPtr bandwidth;
1116
    virNetDevVlan vlan;
1117
    int trustGuestRxFilters; /* enum virTristateBool */
1118
    int linkstate;
1119
    unsigned int mtu;
1120
    virNetDevCoalescePtr coalesce;
1121
    virDomainVirtioOptionsPtr virtio;
1122 1123
};

1124 1125 1126 1127 1128 1129 1130 1131
typedef enum {
    VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT = 0,
    VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED,
    VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED,

    VIR_DOMAIN_CHR_DEVICE_STATE_LAST
} virDomainChrDeviceState;

1132
VIR_ENUM_DECL(virDomainChrDeviceState);
1133

1134
typedef enum {
1135
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1136 1137
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1138
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1139

1140
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1141
} virDomainChrDeviceType;
1142

1143
typedef enum {
1144 1145
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
G
Guannan Ren 已提交
1146
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
M
Michal Privoznik 已提交
1147
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
1148
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
1149
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
1150
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP,
G
Guannan Ren 已提交
1151 1152

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1153
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1154

1155
typedef enum {
1156 1157
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
1158
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
J
Joao Martins 已提交
1159
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN,
1160

1161
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1162
} virDomainChrChannelTargetType;
1163

1164
typedef enum {
1165 1166
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
1167 1168
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
1169
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
1170 1171
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
1172 1173
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
1174

1175
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1176
} virDomainChrConsoleTargetType;
1177

1178 1179 1180 1181 1182
typedef enum {
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL,
1183
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
1184
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011,
1185 1186
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE,
1187
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A,
1188 1189 1190 1191 1192 1193

    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
} virDomainChrSerialTargetModel;

VIR_ENUM_DECL(virDomainChrSerialTargetModel);

1194
typedef enum {
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
    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,
1205
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1206
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1207
    VIR_DOMAIN_CHR_TYPE_NMDM,
1208

1209
    VIR_DOMAIN_CHR_TYPE_LAST
1210
} virDomainChrType;
1211

1212
typedef enum {
1213
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW = 0,
1214
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1215 1216
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1217

1218
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1219
} virDomainChrTcpProtocol;
1220

1221
typedef enum {
E
Eric Blake 已提交
1222 1223
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1224
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1225

1226
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1227
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1228

1229 1230 1231 1232 1233 1234 1235 1236 1237

struct _virDomainChrSourceReconnectDef {
    virTristateBool enabled;
    unsigned int timeout;
};
typedef struct _virDomainChrSourceReconnectDef virDomainChrSourceReconnectDef;
typedef virDomainChrSourceReconnectDef *virDomainChrSourceReconnectDefPtr;


1238 1239
/* The host side information for a character device.  */
struct _virDomainChrSourceDef {
1240
    virObject parent;
1241
    int type; /* virDomainChrType */
1242
    virObjectPtr privateData;
1243
    union {
E
Eric Blake 已提交
1244
        /* no <source> for null, vc, stdio */
1245 1246
        struct {
            char *path;
1247
            int append; /* enum virTristateSwitch */
1248
        } file; /* pty, file, pipe, or device */
1249 1250 1251 1252
        struct {
            char *master;
            char *slave;
        } nmdm;
1253 1254 1255
        struct {
            char *host;
            char *service;
1256
            bool listen;
1257
            int protocol;
1258
            bool tlscreds;
1259
            int haveTLS; /* enum virTristateBool */
1260
            bool tlsFromConfig;
1261
            virDomainChrSourceReconnectDef reconnect;
1262 1263 1264 1265 1266 1267 1268 1269 1270
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
1271
            bool listen;
1272
            virDomainChrSourceReconnectDef reconnect;
1273
        } nix;
E
Eric Blake 已提交
1274
        int spicevmc;
1275 1276 1277
        struct {
            char *channel;
        } spiceport;
1278
    } data;
1279 1280
    char *logfile;
    int logappend;
1281 1282 1283

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1284 1285 1286 1287
};

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

1290 1291 1292
    int targetType; /* enum virDomainChrConsoleTargetType ||
                       enum virDomainChrChannelTargetType ||
                       enum virDomainChrSerialTargetType according to deviceType */
1293
    int targetModel; /* enum virDomainChrSerialTargetModel */
1294

1295 1296 1297 1298 1299 1300
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

1301 1302
    virDomainChrDeviceState state;

1303
    virDomainChrSourceDefPtr source;
1304 1305

    virDomainDeviceInfo info;
1306 1307
};

1308
typedef enum {
E
Eric Blake 已提交
1309 1310 1311 1312
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

1313
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1314
} virDomainSmartcardType;
E
Eric Blake 已提交
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326

# 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' */
1327
        virDomainChrSourceDefPtr passthru; /* 'passthrough' */
E
Eric Blake 已提交
1328 1329 1330 1331 1332
    } data;

    virDomainDeviceInfo info;
};

M
Marc-André Lureau 已提交
1333 1334 1335 1336 1337
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

1338
typedef enum {
1339
    VIR_DOMAIN_TPM_MODEL_TIS,
1340
    VIR_DOMAIN_TPM_MODEL_CRB,
1341 1342

    VIR_DOMAIN_TPM_MODEL_LAST
1343
} virDomainTPMModel;
1344

1345
typedef enum {
1346
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
1347
    VIR_DOMAIN_TPM_TYPE_EMULATOR,
1348 1349

    VIR_DOMAIN_TPM_TYPE_LAST
1350
} virDomainTPMBackendType;
1351

1352 1353 1354 1355 1356 1357 1358 1359
typedef enum {
    VIR_DOMAIN_TPM_VERSION_DEFAULT,
    VIR_DOMAIN_TPM_VERSION_1_2,
    VIR_DOMAIN_TPM_VERSION_2_0,

    VIR_DOMAIN_TPM_VERSION_LAST
} virDomainTPMVersion;

1360 1361 1362
# define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"

struct _virDomainTPMDef {
1363
    int type; /* virDomainTPMBackendType */
1364
    virDomainDeviceInfo info;
1365 1366
    int model; /* virDomainTPMModel */
    int version; /* virDomainTPMVersion */
1367 1368 1369 1370
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
1371 1372 1373 1374 1375
        struct {
            virDomainChrSourceDef source;
            char *storagepath;
            char *logfile;
        } emulator;
1376 1377 1378
    } data;
};

1379
typedef enum {
1380 1381
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1382
    VIR_DOMAIN_INPUT_TYPE_KBD,
1383
    VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
1384

1385
    VIR_DOMAIN_INPUT_TYPE_LAST
1386
} virDomainInputType;
1387

1388
typedef enum {
1389 1390 1391
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1392
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1393
    VIR_DOMAIN_INPUT_BUS_VIRTIO,
1394 1395

    VIR_DOMAIN_INPUT_BUS_LAST
1396
} virDomainInputBus;
1397

1398 1399 1400 1401 1402 1403 1404 1405 1406
typedef enum {
    VIR_DOMAIN_INPUT_MODEL_DEFAULT = 0,
    VIR_DOMAIN_INPUT_MODEL_VIRTIO,
    VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_INPUT_MODEL_LAST
} virDomainInputModel;

1407 1408 1409
struct _virDomainInputDef {
    int type;
    int bus;
1410
    int model; /* virDomainInputModel */
1411 1412 1413
    struct {
        char *evdev;
    } source;
1414
    virDomainDeviceInfo info;
1415
    virDomainVirtioOptionsPtr virtio;
1416 1417
};

1418
typedef enum {
1419 1420
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,
F
Filip Alac 已提交
1421
    VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT,
1422 1423

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1424
} virDomainSoundCodecType;
1425

1426
typedef enum {
1427 1428 1429
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1430
    VIR_DOMAIN_SOUND_MODEL_AC97,
1431
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1432
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1433
    VIR_DOMAIN_SOUND_MODEL_USB,
1434 1435

    VIR_DOMAIN_SOUND_MODEL_LAST
1436
} virDomainSoundModel;
1437

1438 1439 1440 1441 1442
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1443 1444
struct _virDomainSoundDef {
    int model;
1445
    virDomainDeviceInfo info;
1446

1447
    size_t ncodecs;
1448
    virDomainSoundCodecDefPtr *codecs;
1449 1450
};

1451
typedef enum {
R
Richard Jones 已提交
1452 1453
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,
1454
    VIR_DOMAIN_WATCHDOG_MODEL_DIAG288,
R
Richard Jones 已提交
1455 1456

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1457
} virDomainWatchdogModel;
R
Richard Jones 已提交
1458

1459
typedef enum {
R
Richard Jones 已提交
1460 1461 1462 1463
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1464
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1465
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,
1466
    VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI,
R
Richard Jones 已提交
1467 1468

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1469
} virDomainWatchdogAction;
R
Richard Jones 已提交
1470 1471 1472 1473

struct _virDomainWatchdogDef {
    int model;
    int action;
1474
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1475 1476
};

1477

1478
typedef enum {
1479
    VIR_DOMAIN_VIDEO_TYPE_DEFAULT,
1480 1481 1482 1483 1484
    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,
1485
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1486
    VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
M
Marc-André Lureau 已提交
1487
    VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
F
Fabian Freyer 已提交
1488
    VIR_DOMAIN_VIDEO_TYPE_GOP,
1489
    VIR_DOMAIN_VIDEO_TYPE_NONE,
1490 1491

    VIR_DOMAIN_VIDEO_TYPE_LAST
1492
} virDomainVideoType;
1493 1494


1495 1496 1497 1498 1499 1500 1501 1502
typedef enum {
    VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
    VIR_DOMAIN_VIDEO_VGACONF_ON,
    VIR_DOMAIN_VIDEO_VGACONF_OFF,

    VIR_DOMAIN_VIDEO_VGACONF_LAST
} virDomainVideoVGAConf;

1503
VIR_ENUM_DECL(virDomainVideoVGAConf);
1504

1505 1506 1507
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
1508 1509
    int accel2d; /* enum virTristateBool */
    int accel3d; /* enum virTristateBool */
1510 1511 1512
};


1513 1514 1515 1516 1517 1518
typedef struct _virDomainVideoDriverDef virDomainVideoDriverDef;
typedef virDomainVideoDriverDef *virDomainVideoDriverDefPtr;
struct _virDomainVideoDriverDef {
   virDomainVideoVGAConf vgaconf;
};

1519
struct _virDomainVideoDef {
1520
    int type;   /* enum virDomainVideoType */
1521 1522
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1523
    unsigned int vram64; /* kibibytes (multiples of 1024) */
1524
    unsigned int vgamem; /* kibibytes (multiples of 1024) */
1525
    unsigned int heads;
1526
    bool primary;
1527
    virDomainVideoAccelDefPtr accel;
1528
    virDomainVideoDriverDefPtr driver;
1529
    virDomainDeviceInfo info;
J
Ján Tomko 已提交
1530
    virDomainVirtioOptionsPtr virtio;
1531 1532
};

1533
/* graphics console modes */
1534
typedef enum {
1535 1536
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1537 1538
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1539
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1540
    VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS,
1541

1542
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1543
} virDomainGraphicsType;
1544

1545
typedef enum {
1546 1547 1548 1549 1550 1551
    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
1552
} virDomainGraphicsVNCSharePolicy;
1553

1554
typedef enum {
1555 1556 1557 1558 1559 1560
    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
1561
} virDomainGraphicsAuthConnectedType;
1562

1563 1564 1565 1566
typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef;
typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr;
struct _virDomainGraphicsAuthDef {
    char *passwd;
1567
    bool expires; /* Whether there is an expiry time set */
1568
    time_t validTo;  /* seconds since epoch */
1569
    int connected; /* action if connected */
1570 1571
};

1572
typedef enum {
1573 1574 1575 1576 1577 1578
    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 已提交
1579
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1580
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1581 1582

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1583
} virDomainGraphicsSpiceChannelName;
1584

1585
typedef enum {
1586 1587 1588 1589 1590
    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
1591
} virDomainGraphicsSpiceChannelMode;
1592

1593
typedef enum {
1594 1595 1596 1597 1598 1599 1600 1601 1602
    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
1603
} virDomainGraphicsSpiceImageCompression;
1604

1605
typedef enum {
1606 1607 1608 1609 1610 1611
    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
1612
} virDomainGraphicsSpiceJpegCompression;
1613

1614
typedef enum {
1615 1616 1617 1618 1619 1620
    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
1621
} virDomainGraphicsSpiceZlibCompression;
1622

1623
typedef enum {
P
Peng Zhou 已提交
1624 1625 1626 1627 1628
    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
1629
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1630

1631
typedef enum {
1632 1633 1634 1635 1636 1637
    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
1638
} virDomainGraphicsSpiceStreamingMode;
1639

1640
typedef enum {
1641 1642 1643
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1644
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1645

1646
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1647
} virDomainGraphicsListenType;
1648

1649
typedef enum {
M
Marc-André Lureau 已提交
1650 1651
    VIR_DOMAIN_HUB_TYPE_USB,

1652
    VIR_DOMAIN_HUB_TYPE_LAST
1653
} virDomainHubType;
M
Marc-André Lureau 已提交
1654

1655 1656 1657
typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef;
typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr;
struct _virDomainGraphicsListenDef {
1658
    virDomainGraphicsListenType type;
1659 1660
    char *address;
    char *network;
1661
    char *socket;
1662
    bool fromConfig;    /* true if the @address is config file originated */
1663
    bool autoGenerated;
1664 1665
};

1666
struct _virDomainGraphicsDef {
1667 1668
    virObjectPtr privateData;

M
Michal Privoznik 已提交
1669 1670 1671 1672 1673
    /* 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.
     */
1674
    virDomainGraphicsType type;
1675 1676 1677
    union {
        struct {
            int port;
1678
            bool portReserved;
M
Martin Kletzander 已提交
1679
            int websocket;
1680
            bool websocketGenerated;
1681
            bool autoport;
1682
            char *keymap;
1683
            virDomainGraphicsAuthDef auth;
1684
            int sharePolicy;
1685 1686 1687 1688
        } vnc;
        struct {
            char *display;
            char *xauth;
1689
            bool fullscreen;
1690
            virTristateBool gl;
1691
        } sdl;
1692 1693
        struct {
            int port;
1694 1695 1696
            bool autoport;
            bool replaceUser;
            bool multiUser;
1697 1698 1699
        } rdp;
        struct {
            char *display;
1700
            bool fullscreen;
1701
        } desktop;
1702 1703 1704
        struct {
            int port;
            int tlsPort;
1705 1706
            bool portReserved;
            bool tlsPortReserved;
1707
            virDomainGraphicsSpiceMouseMode mousemode;
1708
            char *keymap;
1709
            virDomainGraphicsAuthDef auth;
1710
            bool autoport;
1711
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1712
            virDomainGraphicsSpiceChannelMode defaultMode;
1713 1714 1715 1716
            int image;
            int jpeg;
            int zlib;
            int playback;
1717
            int streaming;
1718 1719 1720
            virTristateBool copypaste;
            virTristateBool filetransfer;
            virTristateBool gl;
1721
            char *rendernode;
1722
        } spice;
1723 1724 1725
        struct {
            char *rendernode;
        } egl_headless;
1726
    } data;
1727 1728 1729 1730 1731
    /* 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;
1732 1733
};

1734
typedef enum {
1735 1736 1737
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1738
} virDomainRedirdevBus;
1739 1740 1741 1742

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

1743
    virDomainChrSourceDefPtr source;
1744 1745 1746

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

1748
struct _virDomainRedirFilterUSBDevDef {
1749 1750 1751 1752
    int usbClass;
    int vendor;
    int product;
    int version;
1753
    bool allow;
1754 1755 1756 1757
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1758
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1759 1760
};

1761
typedef enum {
1762 1763
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1764
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1765 1766
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL,
1767 1768

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1769
} virDomainMemballoonModel;
1770 1771 1772 1773

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1774
    int period; /* seconds between collections */
1775
    int autodeflate; /* enum virTristateSwitch */
1776
    virDomainVirtioOptionsPtr virtio;
1777 1778
};

L
Li Zhang 已提交
1779 1780 1781
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1782

1783 1784
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1785 1786
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1787 1788 1789 1790

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

1791 1792 1793
struct _virDomainShmemDef {
    char *name;
    unsigned long long size;
1794
    int model; /* enum virDomainShmemModel */
1795 1796
    struct {
        bool enabled;
1797
        virDomainChrSourceDef chr;
1798 1799 1800 1801 1802 1803 1804 1805 1806
    } server;
    struct {
        bool enabled;
        unsigned vectors;
        virTristateSwitch ioeventfd;
    } msi;
    virDomainDeviceInfo info;
};

1807
typedef enum {
1808
    VIR_DOMAIN_SMBIOS_NONE = 0,
1809 1810 1811 1812 1813
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1814
} virDomainSmbiosMode;
1815

1816

1817
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1818

1819
typedef enum {
1820 1821 1822 1823 1824
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1825
    VIR_DOMAIN_BOOT_LAST
1826
} virDomainBootOrder;
1827

1828
typedef enum {
1829 1830 1831
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1832
    VIR_DOMAIN_FEATURE_HAP,
1833
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1834
    VIR_DOMAIN_FEATURE_PRIVNET,
1835
    VIR_DOMAIN_FEATURE_HYPERV,
1836
    VIR_DOMAIN_FEATURE_KVM,
1837
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1838
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1839
    VIR_DOMAIN_FEATURE_PMU,
1840
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1841
    VIR_DOMAIN_FEATURE_GIC,
M
Michal Privoznik 已提交
1842
    VIR_DOMAIN_FEATURE_SMM,
1843
    VIR_DOMAIN_FEATURE_IOAPIC,
1844
    VIR_DOMAIN_FEATURE_HPT,
M
Marc-André Lureau 已提交
1845
    VIR_DOMAIN_FEATURE_VMCOREINFO,
1846
    VIR_DOMAIN_FEATURE_HTM,
1847
    VIR_DOMAIN_FEATURE_NESTED_HV,
1848
    VIR_DOMAIN_FEATURE_MSRS,
1849 1850

    VIR_DOMAIN_FEATURE_LAST
1851
} virDomainFeature;
1852

1853 1854
# define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12

1855
typedef enum {
1856
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1857 1858
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1859 1860 1861 1862 1863 1864
    VIR_DOMAIN_HYPERV_VPINDEX,
    VIR_DOMAIN_HYPERV_RUNTIME,
    VIR_DOMAIN_HYPERV_SYNIC,
    VIR_DOMAIN_HYPERV_STIMER,
    VIR_DOMAIN_HYPERV_RESET,
    VIR_DOMAIN_HYPERV_VENDOR_ID,
1865
    VIR_DOMAIN_HYPERV_FREQUENCIES,
1866
    VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
1867
    VIR_DOMAIN_HYPERV_TLBFLUSH,
1868
    VIR_DOMAIN_HYPERV_IPI,
1869
    VIR_DOMAIN_HYPERV_EVMCS,
1870 1871

    VIR_DOMAIN_HYPERV_LAST
1872
} virDomainHyperv;
1873

1874 1875 1876 1877 1878 1879
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892
typedef enum {
    VIR_DOMAIN_MSRS_UNKNOWN = 0,

    VIR_DOMAIN_MSRS_LAST
} virDomainMsrs;

typedef enum {
    VIR_DOMAIN_MSRS_UNKNOWN_IGNORE = 0,
    VIR_DOMAIN_MSRS_UNKNOWN_FAULT,

    VIR_DOMAIN_MSRS_UNKNOWN_LAST
} virDomainMsrsUnknown;

1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942
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;

1943 1944 1945 1946 1947 1948 1949 1950 1951 1952
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;

1953
VIR_ENUM_DECL(virDomainLockFailure);
1954

M
Michal Privoznik 已提交
1955 1956 1957
typedef struct _virDomainBIOSDef virDomainBIOSDef;
typedef virDomainBIOSDef *virDomainBIOSDefPtr;
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1958
    int useserial; /* enum virTristateBool */
1959 1960 1961
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1962 1963
};

1964
typedef enum {
1965 1966
    VIR_DOMAIN_LOADER_TYPE_NONE = 0,
    VIR_DOMAIN_LOADER_TYPE_ROM,
1967 1968 1969 1970 1971
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

1972
VIR_ENUM_DECL(virDomainLoader);
1973 1974 1975 1976 1977 1978 1979

typedef struct _virDomainLoaderDef virDomainLoaderDef;
typedef virDomainLoaderDef *virDomainLoaderDefPtr;
struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1980
    int secure;     /* enum virTristateBool */
1981
    char *nvram;    /* path to non-volatile RAM */
1982
    char *templt;   /* user override of path to master nvram */
1983 1984 1985 1986
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1987
typedef enum {
1988 1989
    VIR_DOMAIN_IOAPIC_NONE = 0,
    VIR_DOMAIN_IOAPIC_QEMU,
1990 1991 1992 1993 1994 1995 1996
    VIR_DOMAIN_IOAPIC_KVM,

    VIR_DOMAIN_IOAPIC_LAST
} virDomainIOAPIC;

VIR_ENUM_DECL(virDomainIOAPIC);

1997
typedef enum {
1998 1999
    VIR_DOMAIN_HPT_RESIZING_NONE = 0,
    VIR_DOMAIN_HPT_RESIZING_ENABLED,
2000 2001 2002 2003 2004 2005 2006 2007
    VIR_DOMAIN_HPT_RESIZING_DISABLED,
    VIR_DOMAIN_HPT_RESIZING_REQUIRED,

    VIR_DOMAIN_HPT_RESIZING_LAST
} virDomainHPTResizing;

VIR_ENUM_DECL(virDomainHPTResizing);

2008
/* Operating system configuration data & machine / arch */
2009 2010 2011 2012 2013 2014 2015
typedef struct _virDomainOSEnv virDomainOSEnv;
typedef virDomainOSEnv *virDomainOSEnvPtr;
struct _virDomainOSEnv {
    char *name;
    char *value;
};

2016 2017 2018 2019 2020 2021 2022 2023 2024 2025
typedef enum {
    VIR_DOMAIN_OS_DEF_FIRMWARE_NONE = 0,
    VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS,
    VIR_DOMAIN_OS_DEF_FIRMWARE_EFI,

    VIR_DOMAIN_OS_DEF_FIRMWARE_LAST
} virDomainOsDefFirmware;

VIR_ENUM_DECL(virDomainOsDefFirmware);

2026 2027 2028
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
2029
    int type;
2030
    virDomainOsDefFirmware firmware;
2031
    virArch arch;
2032
    char *machine;
2033
    size_t nBootDevs;
2034
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
2035
    int bootmenu; /* enum virTristateBool */
2036 2037
    unsigned int bm_timeout;
    bool bm_timeout_set;
2038
    char *init;
2039
    char **initargv;
2040
    virDomainOSEnvPtr *initenv;
2041
    char *initdir;
2042 2043
    char *inituser;
    char *initgroup;
2044 2045 2046
    char *kernel;
    char *initrd;
    char *cmdline;
2047
    char *dtb;
2048
    char *root;
J
Ján Tomko 已提交
2049
    char *slic_table;
2050
    virDomainLoaderDefPtr loader;
2051 2052
    char *bootloader;
    char *bootloaderArgs;
2053
    int smbios_mode;
2054

M
Michal Privoznik 已提交
2055
    virDomainBIOSDef bios;
2056 2057
};

2058
typedef enum {
2059 2060 2061 2062 2063
    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 已提交
2064
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
2065
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
2066

2067
    VIR_DOMAIN_TIMER_NAME_LAST
2068
} virDomainTimerNameType;
2069

2070
typedef enum {
2071 2072 2073
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
2074

2075
    VIR_DOMAIN_TIMER_TRACK_LAST
2076
} virDomainTimerTrackType;
2077

2078
typedef enum {
2079 2080 2081 2082 2083
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

2084
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
2085
} virDomainTimerTickpolicyType;
2086

2087
typedef enum {
2088 2089 2090 2091
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
2092
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
2093

2094
    VIR_DOMAIN_TIMER_MODE_LAST
2095
} virDomainTimerModeType;
2096

2097
typedef enum {
2098
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
2099 2100
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

2101
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
2102
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
2103

2104 2105 2106
typedef struct _virDomainThreadSchedParam virDomainThreadSchedParam;
typedef virDomainThreadSchedParam *virDomainThreadSchedParamPtr;
struct _virDomainThreadSchedParam {
2107
    virProcessSchedPolicy policy;
2108 2109 2110
    int priority;
};

2111 2112 2113 2114 2115 2116 2117 2118
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

2119 2120 2121 2122 2123 2124 2125
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 */

2126 2127 2128 2129
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
2130 2131 2132 2133 2134 2135

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

2136
typedef enum {
2137 2138
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
2139
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
2140
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
2141

2142
    VIR_DOMAIN_CLOCK_OFFSET_LAST
2143
} virDomainClockOffsetType;
2144

2145
typedef enum {
2146 2147 2148
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

2149
    VIR_DOMAIN_CLOCK_BASIS_LAST
2150
} virDomainClockBasis;
2151

2152 2153 2154 2155
typedef struct _virDomainClockDef virDomainClockDef;
typedef virDomainClockDef *virDomainClockDefPtr;
struct _virDomainClockDef {
    int offset;
2156

2157
    union {
2158 2159 2160
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
2161
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
2162 2163 2164
        struct {
            long long adjustment;
            int basis;
2165 2166 2167 2168 2169 2170 2171

            /* 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;
2172
        } variable;
2173 2174 2175 2176 2177

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

2179
    size_t ntimers;
2180
    virDomainTimerDefPtr *timers;
2181 2182
};

2183

2184 2185 2186
typedef struct _virBlkioDevice virBlkioDevice;
typedef virBlkioDevice *virBlkioDevicePtr;
struct _virBlkioDevice {
2187 2188
    char *path;
    unsigned int weight;
2189 2190 2191 2192
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
2193 2194
};

2195
typedef enum {
2196
    VIR_DOMAIN_RNG_MODEL_VIRTIO,
2197 2198
    VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL,
2199 2200

    VIR_DOMAIN_RNG_MODEL_LAST
2201
} virDomainRNGModel;
2202

2203
typedef enum {
2204 2205 2206 2207 2208
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
    /* VIR_DOMAIN_RNG_BACKEND_POOL, */

    VIR_DOMAIN_RNG_BACKEND_LAST
2209
} virDomainRNGBackend;
2210 2211 2212 2213

struct _virDomainRNGDef {
    int model;
    int backend;
2214 2215
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
2216 2217 2218 2219 2220 2221 2222 2223

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

    virDomainDeviceInfo info;
2224
    virDomainVirtioOptionsPtr virtio;
2225 2226
};

2227 2228 2229
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2230
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2231 2232 2233 2234 2235

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
2236
    virDomainMemoryAccess access;
2237
    virTristateBool discard;
2238

2239 2240 2241
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2242
    char *nvdimmPath;
2243
    unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
2244
    bool nvdimmPmem; /* valid only for NVDIMM */
2245 2246 2247

    /* target */
    int model; /* virDomainMemoryModel */
2248
    int targetNode;
2249
    unsigned long long size; /* kibibytes */
2250
    unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
2251
    bool readonly; /* valid only for NVDIMM */
2252 2253 2254 2255 2256 2257

    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2273 2274 2275 2276 2277
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2278
    VIR_DOMAIN_PANIC_MODEL_S390,
2279 2280 2281 2282

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2283
struct _virDomainPanicDef {
2284
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2285 2286 2287 2288
    virDomainDeviceInfo info;
};


2289
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2290
                              int ndevices);
2291

2292 2293 2294 2295 2296
typedef struct _virDomainResourceDef virDomainResourceDef;
typedef virDomainResourceDef *virDomainResourceDefPtr;
struct _virDomainResourceDef {
    char *partition;
};
2297

2298
typedef struct _virDomainHugePage virDomainHugePage;
2299 2300
typedef virDomainHugePage *virDomainHugePagePtr;

2301
struct _virDomainHugePage {
2302 2303 2304 2305
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2306 2307
# define VIR_DOMAIN_CPUMASK_LEN 1024

2308 2309 2310 2311 2312 2313
typedef struct _virDomainIOThreadIDDef virDomainIOThreadIDDef;
typedef virDomainIOThreadIDDef *virDomainIOThreadIDDefPtr;

struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2314
    int thread_id;
2315
    virBitmapPtr cpumask;
2316 2317

    virDomainThreadSchedParam sched;
2318 2319 2320 2321
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2322

2323 2324 2325 2326
typedef struct _virDomainCputune virDomainCputune;
typedef virDomainCputune *virDomainCputunePtr;

struct _virDomainCputune {
2327
    unsigned long long shares;
2328 2329 2330
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2331
    unsigned long long global_period;
2332
    long long global_quota;
2333 2334
    unsigned long long emulator_period;
    long long emulator_quota;
2335 2336
    unsigned long long iothread_period;
    long long iothread_quota;
2337
    virBitmapPtr emulatorpin;
2338 2339
};

2340

2341 2342 2343 2344 2345 2346 2347 2348
typedef struct _virDomainResctrlMonDef virDomainResctrlMonDef;
typedef virDomainResctrlMonDef *virDomainResctrlMonDefPtr;
struct _virDomainResctrlMonDef {
    virBitmapPtr vcpus;
    virResctrlMonitorType tag;
    virResctrlMonitorPtr instance;
};

B
Bing Niu 已提交
2349 2350
typedef struct _virDomainResctrlDef virDomainResctrlDef;
typedef virDomainResctrlDef *virDomainResctrlDefPtr;
2351

B
Bing Niu 已提交
2352
struct _virDomainResctrlDef {
2353 2354
    virBitmapPtr vcpus;
    virResctrlAllocPtr alloc;
2355 2356 2357

    virDomainResctrlMonDefPtr *monitors;
    size_t nmonitors;
2358 2359 2360
};


2361 2362
typedef struct _virDomainVcpuDef virDomainVcpuDef;
typedef virDomainVcpuDef *virDomainVcpuDefPtr;
2363

2364
struct _virDomainVcpuDef {
2365
    bool online;
2366 2367 2368
    virTristateBool hotpluggable;
    unsigned int order;

2369
    virBitmapPtr cpumask;
2370 2371

    virDomainThreadSchedParam sched;
2372 2373

    virObjectPtr privateData;
2374 2375
};

2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389
typedef struct _virDomainBlkiotune virDomainBlkiotune;
typedef virDomainBlkiotune *virDomainBlkiotunePtr;

struct _virDomainBlkiotune {
    unsigned int weight;

    size_t ndevices;
    virBlkioDevicePtr devices;
};

typedef struct _virDomainMemtune virDomainMemtune;
typedef virDomainMemtune *virDomainMemtunePtr;

struct _virDomainMemtune {
2390 2391 2392
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2393 2394
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2395 2396 2397 2398

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2399 2400 2401 2402
    /* maximum supported memory for a guest, for hotplugging */
    unsigned long long max_memory; /* in kibibytes */
    unsigned int memory_slots; /* maximum count of RAM memory slots */

2403 2404 2405
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2406 2407 2408 2409
    unsigned long long hard_limit; /* in kibibytes, limit at off_t bytes */
    unsigned long long soft_limit; /* in kibibytes, limit at off_t bytes */
    unsigned long long min_guarantee; /* in kibibytes, limit at off_t bytes */
    unsigned long long swap_hard_limit; /* in kibibytes, limit at off_t bytes */
2410 2411 2412 2413

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2414 2415

    virTristateBool discard;
2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426
};

typedef struct _virDomainPowerManagement virDomainPowerManagement;
typedef virDomainPowerManagement *virDomainPowerManagementPtr;

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

Q
Qiaowei Ren 已提交
2427 2428 2429 2430 2431 2432 2433
typedef struct _virDomainPerfDef virDomainPerfDef;
typedef virDomainPerfDef *virDomainPerfDefPtr;
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2434 2435 2436 2437 2438 2439 2440
typedef struct _virDomainKeyWrapDef virDomainKeyWrapDef;
typedef virDomainKeyWrapDef *virDomainKeyWrapDefPtr;
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

2441 2442 2443 2444 2445 2446 2447
typedef enum {
    VIR_DOMAIN_LAUNCH_SECURITY_NONE,
    VIR_DOMAIN_LAUNCH_SECURITY_SEV,

    VIR_DOMAIN_LAUNCH_SECURITY_LAST,
} virDomainLaunchSecurity;

2448 2449
typedef struct _virDomainSEVDef virDomainSEVDef;
typedef virDomainSEVDef *virDomainSEVDefPtr;
2450

2451
struct _virDomainSEVDef {
2452 2453 2454 2455 2456 2457 2458 2459 2460
    int sectype; /* enum virDomainLaunchSecurity */
    char *dh_cert;
    char *session;
    unsigned int policy;
    unsigned int cbitpos;
    unsigned int reduced_phys_bits;
};


J
Ján Tomko 已提交
2461 2462 2463 2464 2465 2466 2467 2468
typedef enum {
    VIR_DOMAIN_IOMMU_MODEL_INTEL,

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

struct _virDomainIOMMUDef {
    virDomainIOMMUModel model;
2469
    virTristateSwitch intremap;
2470
    virTristateSwitch caching_mode;
2471
    virTristateSwitch eim;
J
Ján Tomko 已提交
2472
    virTristateSwitch iotlb;
J
Ján Tomko 已提交
2473
};
2474

J
Ján Tomko 已提交
2475 2476 2477
typedef enum {
    VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO,
2478 2479
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL,
J
Ján Tomko 已提交
2480 2481 2482 2483

    VIR_DOMAIN_VSOCK_MODEL_LAST
} virDomainVsockModel;

J
Ján Tomko 已提交
2484
struct _virDomainVsockDef {
2485
    virObjectPtr privateData;
J
Ján Tomko 已提交
2486 2487 2488 2489 2490 2491

    virDomainVsockModel model;
    unsigned int guest_cid;
    virTristateBool auto_cid;

    virDomainDeviceInfo info;
J
Ján Tomko 已提交
2492 2493
};

2494 2495 2496 2497 2498
struct _virDomainVirtioOptions {
    virTristateSwitch iommu;
    virTristateSwitch ats;
};

2499 2500 2501 2502 2503 2504
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
2505 2506
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
2507
struct _virDomainDef {
2508
    int virtType; /* enum virDomainVirtType */
2509 2510
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
2511 2512 2513 2514 2515

    unsigned char genid[VIR_UUID_BUFLEN];
    bool genidRequested;
    bool genidGenerated;

2516
    char *name;
2517
    char *title;
2518
    char *description;
2519

2520 2521
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2522

2523
    virDomainVcpuDefPtr *vcpus;
2524
    size_t maxvcpus;
2525 2526
    /* set if the vcpu definition was specified individually */
    bool individualvcpus;
O
Osier Yang 已提交
2527
    int placement_mode;
H
Hu Tao 已提交
2528
    virBitmapPtr cpumask;
2529

2530 2531
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2532

2533
    virDomainCputune cputune;
2534

B
Bing Niu 已提交
2535 2536
    virDomainResctrlDefPtr *resctrls;
    size_t nresctrls;
2537

2538
    virDomainNumaPtr numa;
2539
    virDomainResourceDefPtr resource;
2540
    virDomainIdMapDef idmap;
2541

2542 2543 2544 2545 2546
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2547 2548
    int onLockFailure; /* enum virDomainLockFailureAction */

2549
    virDomainPowerManagement pm;
2550

2551
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2552

2553 2554
    virDomainOSDef os;
    char *emulator;
2555 2556 2557
    /* Most {caps_,hyperv_,kvm_,}feature options utilize a virTristateSwitch
     * to handle support. A few assign specific data values to the option.
     * See virDomainDefFeaturesCheckABIStability() for details. */
2558
    int features[VIR_DOMAIN_FEATURE_LAST];
2559
    int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
2560
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2561
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2562
    int msrs_features[VIR_DOMAIN_MSRS_LAST];
2563
    unsigned int hyperv_spinlocks;
2564
    virGICVersion gic_version;
2565
    virDomainHPTResizing hpt_resizing;
2566
    unsigned long long hpt_maxpagesize; /* Stored in KiB */
2567
    char *hyperv_vendor_id;
2568
    int apic_eoi;
2569

2570 2571 2572
    bool tseg_specified;
    unsigned long long tseg_size;

2573
    virDomainClockDef clock;
2574

2575
    size_t ngraphics;
2576
    virDomainGraphicsDefPtr *graphics;
2577

2578
    size_t ndisks;
2579 2580
    virDomainDiskDefPtr *disks;

2581
    size_t ncontrollers;
2582 2583
    virDomainControllerDefPtr *controllers;

2584
    size_t nfss;
2585 2586
    virDomainFSDefPtr *fss;

2587
    size_t nnets;
2588 2589
    virDomainNetDefPtr *nets;

2590
    size_t ninputs;
2591 2592
    virDomainInputDefPtr *inputs;

2593
    size_t nsounds;
2594 2595
    virDomainSoundDefPtr *sounds;

2596
    size_t nvideos;
2597 2598
    virDomainVideoDefPtr *videos;

2599
    size_t nhostdevs;
2600 2601
    virDomainHostdevDefPtr *hostdevs;

2602
    size_t nredirdevs;
2603 2604
    virDomainRedirdevDefPtr *redirdevs;

2605
    size_t nsmartcards;
E
Eric Blake 已提交
2606 2607
    virDomainSmartcardDefPtr *smartcards;

2608
    size_t nserials;
2609 2610
    virDomainChrDefPtr *serials;

2611
    size_t nparallels;
2612 2613
    virDomainChrDefPtr *parallels;

2614
    size_t nchannels;
2615 2616
    virDomainChrDefPtr *channels;

2617
    size_t nconsoles;
2618 2619
    virDomainChrDefPtr *consoles;

2620
    size_t nleases;
2621 2622
    virDomainLeaseDefPtr *leases;

2623
    size_t nhubs;
M
Marc-André Lureau 已提交
2624 2625
    virDomainHubDefPtr *hubs;

2626 2627 2628
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2629 2630 2631
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2632 2633 2634
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2635 2636 2637
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2638 2639 2640
    size_t npanics;
    virDomainPanicDefPtr *panics;

2641
    /* Only 1 */
R
Richard Jones 已提交
2642
    virDomainWatchdogDefPtr watchdog;
2643
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2644
    virDomainNVRAMDefPtr nvram;
2645
    virDomainTPMDefPtr tpm;
2646
    virCPUDefPtr cpu;
2647
    virSysinfoDefPtr sysinfo;
2648
    virDomainRedirFilterDefPtr redirfilter;
J
Ján Tomko 已提交
2649
    virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
2650
    virDomainVsockDefPtr vsock;
2651 2652 2653

    void *namespaceData;
    virDomainXMLNamespace ns;
2654

2655 2656
    virDomainKeyWrapDefPtr keywrap;

2657
    /* SEV-specific domain */
2658
    virDomainSEVDefPtr sev;
2659

2660 2661
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2662 2663 2664 2665 2666 2667

    /* internal fields */
    bool postParseFailed; /* set to true if one of the custom post parse
                             callbacks failed for a non-critical reason
                             (was not able to fill in some data) and thus
                             should be re-run before starting */
2668 2669
};

2670

2671
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2672
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2673
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2674
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2675

2676 2677 2678 2679 2680 2681 2682
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

2683
typedef enum {
2684 2685 2686 2687 2688
    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 */
2689
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2690
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2691
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2692
    VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,/* CDROM passthrough */
Y
Yuri Chornoivan 已提交
2693
    VIR_DOMAIN_TAINT_CUSTOM_DTB,       /* Custom device tree blob was specified */
2694
    VIR_DOMAIN_TAINT_CUSTOM_GA_COMMAND, /* Custom guest agent command */
2695 2696

    VIR_DOMAIN_TAINT_LAST
2697
} virDomainTaintFlags;
2698

2699
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2700 2701 2702 2703 2704 2705
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2706 2707 2708
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
2709
    virObjectLockable parent;
2710
    virCond cond;
2711

2712
    pid_t pid;
J
Jiri Denemark 已提交
2713
    virDomainStateReason state;
2714 2715 2716

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2717
    unsigned int updated : 1;
2718
    unsigned int removing : 1;
2719 2720 2721

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

2723
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2724 2725
    virDomainSnapshotObjPtr current_snapshot;

2726 2727
    bool hasManagedSave;

2728 2729
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2730 2731

    int taint;
2732 2733 2734

    unsigned long long original_memlock; /* Original RLIMIT_MEMLOCK, zero if no
                                          * restore will be required later */
2735 2736
};

2737 2738
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2739

2740

2741 2742
/* NB: Any new flag to this list be considered to be set in
 * virt-aa-helper code if the flag prevents parsing. */
2743 2744
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2745
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2746
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2747
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2748
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2749
    VIR_DOMAIN_DEF_FEATURE_USER_ALIAS = (1 << 5),
2750
    VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER = (1 << 6),
2751
    VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT = (1 << 7),
2752 2753 2754
} virDomainDefFeatures;


2755 2756
/* This structure holds various callbacks and data needed
 * while parsing and creating domain XMLs */
2757 2758
typedef struct _virDomainXMLOption virDomainXMLOption;
typedef virDomainXMLOption *virDomainXMLOptionPtr;
2759

2760 2761 2762 2763 2764 2765 2766 2767 2768

/* Called after everything else has been parsed, for adjusting basics.
 * This has similar semantics to virDomainDefPostParseCallback, but no
 * parseOpaque is used. This callback is run prior to
 * virDomainDefPostParseCallback. */
typedef int (*virDomainDefPostParseBasicCallback)(virDomainDefPtr def,
                                                  virCapsPtr caps,
                                                  void *opaque);

2769
/* Called once after everything else has been parsed, for adjusting
2770 2771 2772
 * overall domain defaults.
 * @parseOpaque is opaque data passed by virDomainDefParse* caller,
 * @opaque is opaque data set by driver (usually pointer to driver
2773 2774 2775 2776
 * private data). Non-fatal failures should be reported by returning 1. In
 * cases when that is allowed, such failure is translated to a success return
 * value and the failure is noted in def->postParseFailed. Drivers should then
 * re-run the post parse callback when attempting to use such definition. */
2777 2778
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
                                             virCapsPtr caps,
2779
                                             unsigned int parseFlags,
2780 2781
                                             void *opaque,
                                             void *parseOpaque);
2782
/* Called once per device, for adjusting per-device settings while
2783 2784 2785 2786
 * leaving the overall domain otherwise unchanged.
 * @parseOpaque is opaque data passed by virDomainDefParse* caller,
 * @opaque is opaque data set by driver (usually pointer to driver
 * private data). */
2787
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
2788
                                                   const virDomainDef *def,
2789
                                                   virCapsPtr caps,
2790
                                                   unsigned int parseFlags,
2791 2792
                                                   void *opaque,
                                                   void *parseOpaque);
2793
/* Drive callback for assigning device addresses, called at the end
2794 2795 2796 2797
 * of parsing, after all defaults and implicit devices have been added.
 * @parseOpaque is opaque data passed by virDomainDefParse* caller,
 * @opaque is opaque data set by driver (usually pointer to driver
 * private data). */
2798 2799 2800
typedef int (*virDomainDefAssignAddressesCallback)(virDomainDef *def,
                                                   virCapsPtr caps,
                                                   unsigned int parseFlags,
2801 2802
                                                   void *opaque,
                                                   void *parseOpaque);
2803

2804 2805 2806 2807 2808 2809 2810
typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def,
                                              virCapsPtr caps,
                                              unsigned int parseFlags,
                                              void *opaque,
                                              void **parseOpaque);
typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque);

2811 2812 2813 2814 2815 2816
/* Called in appropriate places where the domain conf parser can return failure
 * for configurations that were previously accepted. This shall not modify the
 * config. */
typedef int (*virDomainDefValidateCallback)(const virDomainDef *def,
                                            virCapsPtr caps,
                                            void *opaque);
2817

2818 2819 2820 2821 2822 2823
/* Called once per device, for adjusting per-device settings while
 * leaving the overall domain otherwise unchanged.  */
typedef int (*virDomainDeviceDefValidateCallback)(const virDomainDeviceDef *dev,
                                                  const virDomainDef *def,
                                                  void *opaque);

2824 2825 2826
typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
struct _virDomainDefParserConfig {
2827
    /* driver domain definition callbacks */
2828
    virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
2829
    virDomainDefPostParseDataAlloc domainPostParseDataAlloc;
2830 2831
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2832
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2833
    virDomainDefPostParseDataFree domainPostParseDataFree;
2834

2835 2836
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2837
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2838

2839
    /* private data for the callbacks */
2840 2841
    void *priv;
    virFreeCallback privFree;
2842 2843

    /* data */
2844
    unsigned int features; /* virDomainDefFeatures */
2845
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2846 2847
};

2848
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *);
2849 2850 2851 2852 2853 2854 2855 2856
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
                                                 virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                virDomainObjPtr,
                                                virDomainDefParserConfigPtr);

2857 2858
typedef void *(*virDomainXMLPrivateDataGetParseOpaqueFunc)(virDomainObjPtr vm);

2859 2860 2861 2862 2863
typedef int (*virDomainXMLPrivateDataDiskParseFunc)(xmlXPathContextPtr ctxt,
                                                    virDomainDiskDefPtr disk);
typedef int (*virDomainXMLPrivateDataDiskFormatFunc)(virDomainDiskDefPtr disk,
                                                     virBufferPtr buf);

2864 2865 2866 2867 2868 2869
typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
                                                             virStorageSourcePtr src);
typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
                                                              virBufferPtr buf);


2870 2871 2872 2873 2874
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
2875 2876
    /* note that private data for devices are not copied when using
     * virDomainDefCopy and similar functions */
2877
    virDomainXMLPrivateDataNewFunc    diskNew;
2878 2879
    virDomainXMLPrivateDataDiskParseFunc diskParse;
    virDomainXMLPrivateDataDiskFormatFunc diskFormat;
2880
    virDomainXMLPrivateDataNewFunc    vcpuNew;
2881
    virDomainXMLPrivateDataNewFunc    chrSourceNew;
2882
    virDomainXMLPrivateDataNewFunc    vsockNew;
2883
    virDomainXMLPrivateDataNewFunc    graphicsNew;
2884 2885
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
2886 2887 2888
    /* following function shall return a pointer which will be used as the
     * 'parseOpaque' argument for virDomainDefPostParse */
    virDomainXMLPrivateDataGetParseOpaqueFunc getParseOpaque;
2889 2890
    virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
    virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
2891 2892
};

2893 2894 2895 2896 2897 2898 2899 2900 2901
typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
                                            const virDomainDef *dst);

typedef struct _virDomainABIStability virDomainABIStability;
typedef virDomainABIStability *virDomainABIStabilityPtr;
struct _virDomainABIStability {
    virDomainABIStabilityDomain domain;
};

2902 2903
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
2904
                                            virDomainXMLNamespacePtr xmlns,
2905 2906 2907 2908 2909
                                            virDomainABIStabilityPtr abi,
                                            virSaveCookieCallbacksPtr saveCookie);

virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
2910

2911 2912
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2913
virDomainXMLNamespacePtr
2914
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2915 2916
    ATTRIBUTE_NONNULL(1);

2917 2918 2919 2920 2921
int virDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2922
bool virDomainDefHasUSB(const virDomainDef *def);
2923

2924 2925 2926 2927
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
                                           virDomainDeviceDefPtr dev,
                                           unsigned int flags);

2928 2929
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);

2930
int virDomainDefValidate(virDomainDefPtr def,
2931 2932 2933 2934
                         virCapsPtr caps,
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2935
static inline bool
D
Daniel P. Berrange 已提交
2936
virDomainObjIsActive(virDomainObjPtr dom)
2937 2938 2939 2940
{
    return dom->def->id != -1;
}

2941 2942
int virDomainObjCheckActive(virDomainObjPtr dom);

2943 2944 2945 2946 2947 2948 2949 2950 2951 2952
int virDomainDefSetVcpusMax(virDomainDefPtr def,
                            unsigned int vcpus,
                            virDomainXMLOptionPtr xmlopt);
bool virDomainDefHasVcpusOffline(const virDomainDef *def);
unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
unsigned int virDomainDefGetVcpus(const virDomainDef *def);
virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def);
virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
    ATTRIBUTE_RETURN_CHECK;
2953
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2954 2955
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2956

2957
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2958
    ATTRIBUTE_NONNULL(1);
2959

M
Michal Privoznik 已提交
2960 2961
void virDomainObjEndAPI(virDomainObjPtr *vm);

2962
bool virDomainObjTaint(virDomainObjPtr obj,
2963
                       virDomainTaintFlags taint);
2964

2965 2966 2967 2968
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2969

H
Hu Tao 已提交
2970
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2971
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2972
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
J
Ján Tomko 已提交
2973
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
2974
void virDomainInputDefFree(virDomainInputDefPtr def);
2975
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2976
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2977
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2978 2979
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2980
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2981 2982
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
    ATTRIBUTE_RETURN_CHECK;
2983
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
2984
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
2985 2986 2987 2988
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
    ATTRIBUTE_RETURN_CHECK;
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2989 2990 2991
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
                                  virDomainDeviceInfoPtr info);
2992 2993 2994
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2995 2996

virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type);
2997
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2998
bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont);
2999

3000
virDomainFSDefPtr virDomainFSDefNew(void);
3001
void virDomainFSDefFree(virDomainFSDefPtr def);
3002
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
J
Ján Tomko 已提交
3003 3004
virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt);
void virDomainVsockDefFree(virDomainVsockDefPtr vsock);
3005
void virDomainNetDefClear(virDomainNetDefPtr def);
3006
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
3007
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
3008
void virDomainChrDefFree(virDomainChrDefPtr def);
3009 3010
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
                              virDomainChrSourceDefPtr src);
3011
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
3012
void virDomainSoundDefFree(virDomainSoundDefPtr def);
3013
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
3014
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
3015
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
C
Cole Robinson 已提交
3016
virDomainVideoDefPtr virDomainVideoDefNew(void);
3017
void virDomainVideoDefFree(virDomainVideoDefPtr def);
3018
void virDomainVideoDefClear(virDomainVideoDefPtr def);
J
John Ferlan 已提交
3019
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
3020
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
3021
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
3022
void virDomainHubDefFree(virDomainHubDefPtr def);
3023
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
3024
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
3025
void virDomainShmemDefFree(virDomainShmemDefPtr def);
3026
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
3027
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
3028
                                             const virDomainDef *def,
3029 3030
                                             virCapsPtr caps,
                                             virDomainXMLOptionPtr xmlopt);
3031
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
C
Cole Robinson 已提交
3032 3033
void virDomainDeviceSetData(virDomainDeviceDefPtr device,
                            void *devicedata);
3034
void virDomainTPMDefFree(virDomainTPMDefPtr def);
3035

3036
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
3037 3038
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
3039 3040 3041 3042 3043 3044
                                           void *opaque);

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

3045 3046 3047 3048
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

3049 3050
void virDomainDefFree(virDomainDefPtr vm);

3051 3052 3053
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);

3054
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
3055

3056 3057
virDomainGraphicsDefPtr
virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt);
3058
virDomainDefPtr virDomainDefNew(void);
3059

3060
void virDomainObjAssignDef(virDomainObjPtr domain,
3061
                           virDomainDefPtr def,
3062 3063
                           bool live,
                           virDomainDefPtr *oldDef);
3064
int virDomainObjSetDefTransient(virCapsPtr caps,
3065
                                virDomainXMLOptionPtr xmlopt,
3066
                                virDomainObjPtr domain);
3067
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
3068 3069
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
3070
                             virDomainXMLOptionPtr xmlopt,
3071
                             virDomainObjPtr domain);
3072 3073 3074 3075 3076 3077 3078 3079

int virDomainObjUpdateModificationImpact(virDomainObjPtr vm,
                                         unsigned int *flags);

int virDomainObjGetDefs(virDomainObjPtr vm,
                        unsigned int flags,
                        virDomainDefPtr *liveDef,
                        virDomainDefPtr *persDef);
3080 3081 3082
virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                           unsigned int flags,
                                           bool *state);
3083
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
3084

3085 3086 3087
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virCapsPtr caps,
                                 virDomainXMLOptionPtr xmlopt,
3088
                                 void *parseOpaque,
3089 3090 3091 3092
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt);
3093

3094 3095 3096
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
3097 3098 3099 3100
    /* Parse only parts of the XML that would be present in an inactive libvirt
     * XML. Note that the flag does not imply that ABI incompatible
     * transformations can be used, since it's used to strip runtime info when
     * restoring save images/migration. */
3101 3102 3103 3104 3105
    VIR_DOMAIN_DEF_PARSE_INACTIVE        = 1 << 1,
    /* parse <actual> element */
    VIR_DOMAIN_DEF_PARSE_ACTUAL_NET      = 1 << 2,
    /* parse original states of host PCI device */
    VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES = 1 << 3,
3106
    /* internal flag passed to device info sub-parser to allow using <rom> */
3107
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
3108
    /* internal flag passed to device info sub-parser to allow specifying boot order */
3109 3110
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    /* parse only source half of <disk> */
3111
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 6,
3112
    /* perform RNG schema validation on the passed XML document */
3113
    VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA = 1 << 7,
3114
    /* allow updates in post parse callback that would break ABI otherwise */
3115
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE = 1 << 8,
3116
    /* skip definition validation checks meant to be executed on define time only */
3117
    VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 9,
3118
    /* skip parsing of security labels */
3119
    VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 10,
3120 3121 3122
    /* Allows updates in post parse callback for incoming persistent migration
     * that would break ABI otherwise.  This should be used only if it's safe
     * to do such change. */
3123
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 11,
3124 3125 3126 3127
    /* Allows to ignore certain failures in the post parse callbacks, which
     * may happen due to missing packages and can be fixed by re-running the
     * post parse callbacks before starting. Failure of the post parse callback
     * is recorded as def->postParseFail */
3128
    VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL = 1 << 12,
3129 3130 3131 3132 3133
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
3134
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
3135
    /* format internal domain status information */
3136
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
3137
    /* format <actual> element */
3138
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
3139
    /* format original states of host PCI device */
3140 3141 3142 3143
    VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES = 1 << 5,
    VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM       = 1 << 6,
    VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT      = 1 << 7,
    VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST    = 1 << 8,
3144 3145
} virDomainDefFormatFlags;

3146 3147 3148 3149 3150 3151 3152 3153 3154
/* Use these flags to skip specific domain ABI consistency checks done
 * in virDomainDefCheckABIStabilityFlags.
 */
typedef enum {
    /* Set when domain lock must be released and there exists the possibility
     * that some external action could alter the value, such as cur_balloon. */
    VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE = 1 << 0,
} virDomainDefABICheckFlags;

3155
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
3156
                                              const virDomainDef *def,
3157 3158
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
3159
                                              unsigned int flags);
3160 3161 3162 3163
virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr,
                                          const virDomainDef *def,
                                          virDomainXMLOptionPtr xmlopt,
                                          unsigned int flags);
3164 3165
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                        virCapsPtr caps,
3166
                                        virDomainXMLOptionPtr xmlopt,
3167
                                        void *parseOpaque,
L
Laine Stump 已提交
3168
                                        unsigned int flags);
3169 3170
virDomainDefPtr virDomainDefParseFile(const char *filename,
                                      virCapsPtr caps,
3171
                                      virDomainXMLOptionPtr xmlopt,
3172
                                      void *parseOpaque,
L
Laine Stump 已提交
3173
                                      unsigned int flags);
3174
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
3175
                                      xmlNodePtr root,
3176 3177
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
3178
                                      void *parseOpaque,
L
Laine Stump 已提交
3179
                                      unsigned int flags);
3180 3181 3182 3183 3184
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3185 3186 3187 3188
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3189

3190
bool virDomainDefCheckABIStability(virDomainDefPtr src,
3191 3192
                                   virDomainDefPtr dst,
                                   virDomainXMLOptionPtr xmlopt);
3193

3194 3195
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
                                        virDomainDefPtr dst,
3196
                                        virDomainXMLOptionPtr xmlopt,
3197 3198
                                        unsigned int flags);

3199
int virDomainDefAddImplicitDevices(virDomainDefPtr def);
3200

3201
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
3202 3203 3204 3205 3206
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);

3207 3208 3209 3210 3211 3212 3213 3214 3215
/* When extending this list, remember that libvirt 1.2.12-5.0.0 had a
 * bug that silently ignored unknown flags.  A new flag to add
 * information is okay as long as clients still work when an older
 * server omits the requested output, but a new flag to suppress
 * information could result in a security hole when older libvirt
 * supplies the sensitive information in spite of the flag. */
# define VIR_DOMAIN_XML_COMMON_FLAGS \
    (VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE | \
     VIR_DOMAIN_XML_MIGRATABLE)
3216 3217
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

3218
char *virDomainDefFormat(virDomainDefPtr def,
3219
                         virCapsPtr caps,
L
Laine Stump 已提交
3220
                         unsigned int flags);
3221 3222
char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
                         virDomainObjPtr obj,
3223
                         virCapsPtr caps,
3224
                         unsigned int flags);
3225
int virDomainDefFormatInternal(virDomainDefPtr def,
3226
                               virCapsPtr caps,
3227
                               unsigned int flags,
3228 3229
                               virBufferPtr buf,
                               virDomainXMLOptionPtr xmlopt);
3230

3231 3232 3233
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
                              int policy,
3234 3235
                              unsigned int flags,
                              virDomainXMLOptionPtr xmlopt);
3236

3237 3238
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
3239
                          char *prefix,
3240 3241
                          unsigned int flags);

3242 3243 3244 3245 3246 3247
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

3248
int virDomainDefCompatibleDevice(virDomainDefPtr def,
3249
                                 virDomainDeviceDefPtr dev,
3250
                                 virDomainDeviceDefPtr oldDev,
3251 3252
                                 virDomainDeviceAction action,
                                 bool live);
3253

3254 3255
void virDomainRNGDefFree(virDomainRNGDefPtr def);

3256
int virDomainDiskIndexByAddress(virDomainDefPtr def,
3257
                                virPCIDeviceAddressPtr pci_controller,
3258 3259
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
3260
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
3261
                                           virPCIDeviceAddressPtr pci_controller,
3262 3263 3264
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
3265 3266
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
3267 3268 3269
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
3270
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
3271
int virDomainDiskInsert(virDomainDefPtr def,
3272 3273
                        virDomainDiskDefPtr disk)
    ATTRIBUTE_RETURN_CHECK;
3274 3275
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
3276 3277
int virDomainStorageNetworkParseHost(xmlNodePtr hostnode,
                                     virStorageNetHostDefPtr host);
3278
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
3279 3280
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
3281

3282 3283 3284 3285
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
3286
int virDomainDiskSourceParse(xmlNodePtr node,
3287
                             xmlXPathContextPtr ctxt,
3288
                             virStorageSourcePtr src,
3289 3290
                             unsigned int flags,
                             virDomainXMLOptionPtr xmlopt);
3291

3292 3293
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
3294
virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname);
3295
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
3296
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
3297
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
3298
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
3299

L
Laine Stump 已提交
3300
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
3301 3302
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
3303 3304 3305
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

3306 3307
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
3308 3309
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
3310
            ATTRIBUTE_NONNULL(1);
3311 3312 3313
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
3314

3315
virDomainNetType virDomainNetGetActualType(const virDomainNetDef *iface);
3316
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
3317
int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
3318
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
3319
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
3320
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
3321
virNetDevVPortProfilePtr
3322
virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface);
3323
virNetDevBandwidthPtr
3324
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
3325
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
3326
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
3327
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
3328
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
3329 3330 3331
                                const char *address,
                                int family,
                                unsigned int prefix);
3332

3333
int virDomainControllerInsert(virDomainDefPtr def,
3334 3335
                              virDomainControllerDefPtr controller)
    ATTRIBUTE_RETURN_CHECK;
3336 3337
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
3338
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
3339
int virDomainControllerFindByType(virDomainDefPtr def, int type);
3340
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
3341
                                        virPCIDeviceAddressPtr addr);
3342
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
3343
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
3344
const char *virDomainControllerAliasFind(const virDomainDef *def,
3345 3346
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
3347 3348 3349 3350 3351

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
3352 3353
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
    ATTRIBUTE_RETURN_CHECK;
3354 3355
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
3356 3357 3358 3359 3360
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
3361

3362
void
3363
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
3364
                          virDomainChrDeviceType type,
3365 3366 3367
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3368 3369 3370
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
3371 3372 3373
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
3374
int
3375 3376 3377 3378 3379
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
3380 3381 3382 3383
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

3384 3385 3386
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

3387 3388 3389 3390
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

3391
int virDomainSaveXML(const char *configDir,
3392 3393 3394
                     virDomainDefPtr def,
                     const char *xml);

3395
int virDomainSaveConfig(const char *configDir,
3396
                        virCapsPtr caps,
3397
                        virDomainDefPtr def);
3398
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
3399
                        const char *statusDir,
3400 3401
                        virDomainObjPtr obj,
                        virCapsPtr caps) ATTRIBUTE_RETURN_CHECK;
3402

3403 3404 3405 3406
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

3407
int virDomainDeleteConfig(const char *configDir,
3408
                          const char *autostartDir,
3409 3410
                          virDomainObjPtr dom);

3411
char *virDomainConfigFile(const char *dir,
3412 3413
                          const char *name);

3414 3415 3416 3417
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

3418
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
3419
                                                  const char *target);
3420
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
3421
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
3422 3423
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

3424
int virDomainVideoDefaultType(const virDomainDef *def);
3425 3426
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
3427

E
Eric Blake 已提交
3428 3429 3430 3431 3432 3433 3434 3435 3436
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3437 3438 3439 3440 3441 3442 3443 3444 3445
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3446 3447 3448 3449 3450
typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
                                            const char *path,
                                            size_t depth,
                                            void *opaque);

3451 3452 3453 3454 3455 3456 3457
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

3458 3459 3460 3461 3462
int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
                                bool ignoreOpenFailure,
                                virDomainDiskDefPathIterator iter,
                                void *opaque);

J
Jiri Denemark 已提交
3463 3464 3465 3466 3467 3468 3469
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3470 3471 3472
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3473
virSecurityDeviceLabelDefPtr
3474 3475
virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDefPtr def,
                                         const char *model);
3476

3477 3478
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3479

3480 3481 3482 3483 3484 3485 3486 3487 3488 3489
int virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
virDomainMemoryDefPtr virDomainMemoryRemove(virDomainDefPtr def, int idx)
    ATTRIBUTE_NONNULL(1);
int virDomainMemoryFindByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

3490 3491 3492 3493 3494 3495 3496 3497
int virDomainShmemDefInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
bool virDomainShmemDefEquals(virDomainShmemDefPtr src, virDomainShmemDefPtr dst)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
virDomainShmemDefPtr virDomainShmemDefRemove(virDomainDefPtr def, size_t idx)
    ATTRIBUTE_NONNULL(1);
3498 3499 3500
ssize_t virDomainInputDefFind(const virDomainDef *def,
                              const virDomainInputDef *input)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
3501 3502 3503
bool virDomainVsockDefEquals(const virDomainVsockDef *a,
                             const virDomainVsockDef *b)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
3504

3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523
VIR_ENUM_DECL(virDomainTaint);
VIR_ENUM_DECL(virDomainVirt);
VIR_ENUM_DECL(virDomainBoot);
VIR_ENUM_DECL(virDomainFeature);
VIR_ENUM_DECL(virDomainCapabilitiesPolicy);
VIR_ENUM_DECL(virDomainCapsFeature);
VIR_ENUM_DECL(virDomainLifecycle);
VIR_ENUM_DECL(virDomainLifecycleAction);
VIR_ENUM_DECL(virDomainDevice);
VIR_ENUM_DECL(virDomainDiskDevice);
VIR_ENUM_DECL(virDomainDiskGeometryTrans);
VIR_ENUM_DECL(virDomainDiskBus);
VIR_ENUM_DECL(virDomainDiskCache);
VIR_ENUM_DECL(virDomainDiskErrorPolicy);
VIR_ENUM_DECL(virDomainDiskIo);
VIR_ENUM_DECL(virDomainDeviceSGIO);
VIR_ENUM_DECL(virDomainDiskTray);
VIR_ENUM_DECL(virDomainDiskDiscard);
VIR_ENUM_DECL(virDomainDiskDetectZeroes);
3524
VIR_ENUM_DECL(virDomainDiskModel);
3525 3526 3527 3528 3529 3530 3531
VIR_ENUM_DECL(virDomainDiskMirrorState);
VIR_ENUM_DECL(virDomainController);
VIR_ENUM_DECL(virDomainControllerModelPCI);
VIR_ENUM_DECL(virDomainControllerPCIModelName);
VIR_ENUM_DECL(virDomainControllerModelSCSI);
VIR_ENUM_DECL(virDomainControllerModelUSB);
VIR_ENUM_DECL(virDomainControllerModelIDE);
3532
VIR_ENUM_DECL(virDomainControllerModelVirtioSerial);
3533 3534 3535 3536
VIR_ENUM_DECL(virDomainFS);
VIR_ENUM_DECL(virDomainFSDriver);
VIR_ENUM_DECL(virDomainFSAccessMode);
VIR_ENUM_DECL(virDomainFSWrpolicy);
3537
VIR_ENUM_DECL(virDomainFSModel);
3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565
VIR_ENUM_DECL(virDomainNet);
VIR_ENUM_DECL(virDomainNetBackend);
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
VIR_ENUM_DECL(virDomainNetInterfaceLinkState);
VIR_ENUM_DECL(virDomainChrDevice);
VIR_ENUM_DECL(virDomainChrChannelTarget);
VIR_ENUM_DECL(virDomainChrConsoleTarget);
VIR_ENUM_DECL(virDomainChrSerialTarget);
VIR_ENUM_DECL(virDomainSmartcard);
VIR_ENUM_DECL(virDomainChr);
VIR_ENUM_DECL(virDomainChrTcpProtocol);
VIR_ENUM_DECL(virDomainChrSpicevmc);
VIR_ENUM_DECL(virDomainSoundCodec);
VIR_ENUM_DECL(virDomainSoundModel);
VIR_ENUM_DECL(virDomainKeyWrapCipherName);
VIR_ENUM_DECL(virDomainMemballoonModel);
VIR_ENUM_DECL(virDomainSmbiosMode);
VIR_ENUM_DECL(virDomainWatchdogModel);
VIR_ENUM_DECL(virDomainWatchdogAction);
VIR_ENUM_DECL(virDomainPanicModel);
VIR_ENUM_DECL(virDomainVideo);
VIR_ENUM_DECL(virDomainHostdevMode);
VIR_ENUM_DECL(virDomainHostdevSubsys);
VIR_ENUM_DECL(virDomainHostdevCaps);
VIR_ENUM_DECL(virDomainHub);
VIR_ENUM_DECL(virDomainRedirdevBus);
VIR_ENUM_DECL(virDomainInput);
VIR_ENUM_DECL(virDomainInputBus);
3566
VIR_ENUM_DECL(virDomainInputModel);
3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579
VIR_ENUM_DECL(virDomainGraphics);
VIR_ENUM_DECL(virDomainGraphicsListen);
VIR_ENUM_DECL(virDomainGraphicsAuthConnected);
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName);
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode);
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression);
VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression);
VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression);
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode);
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode);
VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy);
VIR_ENUM_DECL(virDomainHyperv);
VIR_ENUM_DECL(virDomainKVM);
3580
VIR_ENUM_DECL(virDomainMsrsUnknown);
3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593
VIR_ENUM_DECL(virDomainRNGModel);
VIR_ENUM_DECL(virDomainRNGBackend);
VIR_ENUM_DECL(virDomainTPMModel);
VIR_ENUM_DECL(virDomainTPMBackend);
VIR_ENUM_DECL(virDomainTPMVersion);
VIR_ENUM_DECL(virDomainMemoryModel);
VIR_ENUM_DECL(virDomainMemoryBackingModel);
VIR_ENUM_DECL(virDomainMemorySource);
VIR_ENUM_DECL(virDomainMemoryAllocation);
VIR_ENUM_DECL(virDomainIOMMUModel);
VIR_ENUM_DECL(virDomainVsockModel);
VIR_ENUM_DECL(virDomainShmemModel);
VIR_ENUM_DECL(virDomainLaunchSecurity);
3594
/* from libvirt.h */
3595 3596 3597 3598 3599 3600 3601 3602 3603
VIR_ENUM_DECL(virDomainState);
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);
VIR_ENUM_DECL(virDomainPMSuspendedReason);
J
Jiri Denemark 已提交
3604 3605 3606 3607

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

3608 3609 3610
VIR_ENUM_DECL(virDomainSeclabel);
VIR_ENUM_DECL(virDomainClockOffset);
VIR_ENUM_DECL(virDomainClockBasis);
3611

3612 3613 3614 3615 3616
VIR_ENUM_DECL(virDomainTimerName);
VIR_ENUM_DECL(virDomainTimerTrack);
VIR_ENUM_DECL(virDomainTimerTickpolicy);
VIR_ENUM_DECL(virDomainTimerMode);
VIR_ENUM_DECL(virDomainCpuPlacementMode);
3617

3618
VIR_ENUM_DECL(virDomainStartupPolicy);
3619

3620 3621
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3622 3623
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3624 3625 3626 3627 3628
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3629 3630 3631 3632
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3633

3634 3635
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3636 3637
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3638 3639
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3640

3641 3642
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);

3643 3644
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3645 3646 3647 3648 3649
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3650 3651 3652 3653 3654 3655 3656
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
3657
                            const char *stateDir,
3658 3659 3660
                            const char *configDir,
                            unsigned int flags);

3661 3662 3663 3664 3665 3666 3667 3668
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3669 3670 3671
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3672 3673
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3674
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3675

3676 3677 3678 3679 3680 3681 3682
int virDomainStorageSourceFormat(virBufferPtr attrBuf,
                                 virBufferPtr childBuf,
                                 virStorageSourcePtr src,
                                 unsigned int flags,
                                 bool skipSeclabels)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3683 3684 3685 3686 3687 3688
int virDomainStorageSourceParse(xmlNodePtr node,
                                xmlXPathContextPtr ctxt,
                                virStorageSourcePtr src,
                                unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3689 3690 3691 3692 3693 3694 3695 3696
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;

3697 3698
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

3699
char *virDomainDefGetShortName(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
M
Martin Kletzander 已提交
3700

3701 3702 3703 3704 3705
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3706

3707 3708 3709
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3710 3711 3712 3713 3714
char *
virDomainGenerateMachineName(const char *drivername,
                             int id,
                             const char *name,
                             bool privileged);
3715 3716 3717

bool
virDomainNetTypeSharesHostView(const virDomainNetDef *net);
3718

3719 3720 3721 3722
bool
virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
                                   virDomainLifecycleAction action);

3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734
typedef int
(*virDomainNetAllocateActualDeviceImpl)(virDomainDefPtr dom,
                                        virDomainNetDefPtr iface);

typedef void
(*virDomainNetNotifyActualDeviceImpl)(virDomainDefPtr dom,
                                      virDomainNetDefPtr iface);

typedef int
(*virDomainNetReleaseActualDeviceImpl)(virDomainDefPtr dom,
                                       virDomainNetDefPtr iface);

3735 3736 3737 3738 3739 3740 3741 3742 3743
typedef bool
(*virDomainNetBandwidthChangeAllowedImpl)(virDomainNetDefPtr iface,
                                          virNetDevBandwidthPtr newBandwidth);

typedef int
(*virDomainNetBandwidthUpdateImpl)(virDomainNetDefPtr iface,
                                   virNetDevBandwidthPtr newBandwidth);


3744 3745 3746
void
virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate,
                          virDomainNetNotifyActualDeviceImpl notify,
3747 3748
                          virDomainNetReleaseActualDeviceImpl release,
                          virDomainNetBandwidthChangeAllowedImpl bandwidthChangeAllowed,
3749
                          virDomainNetBandwidthUpdateImpl bandwidthUpdate);
3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765

int
virDomainNetAllocateActualDevice(virDomainDefPtr dom,
                                 virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void
virDomainNetNotifyActualDevice(virDomainDefPtr dom,
                               virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

int
virDomainNetReleaseActualDevice(virDomainDefPtr dom,
                                virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

3766 3767 3768 3769 3770 3771 3772 3773 3774
bool
virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface,
                              virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

int
virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
                            virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3775

3776 3777 3778 3779
int
virDomainNetResolveActualType(virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1);

3780

3781
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
3782

3783 3784 3785
int
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                 virDomainDiskDetectZeroes detect_zeroes);
3786

3787 3788 3789
bool
virDomainDefHasManagedPR(const virDomainDef *def);

3790 3791 3792
bool
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);

3793 3794 3795 3796 3797 3798 3799 3800 3801
bool
virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics);

const char *
virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);

bool
virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);

3802
#endif /* LIBVIRT_DOMAIN_CONF_H */