domain_conf.h 123.3 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

typedef struct _virDomainHostdevSubsysSCSIVHost virDomainHostdevSubsysSCSIVHost;
typedef virDomainHostdevSubsysSCSIVHost *virDomainHostdevSubsysSCSIVHostPtr;
struct _virDomainHostdevSubsysSCSIVHost {
    int protocol; /* enum virDomainHostdevSubsysSCSIHostProtocolType */
    char *wwpn;
};

404 405 406
typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys {
407
    int type; /* enum virDomainHostdevSubsysType */
408
    union {
409
        virDomainHostdevSubsysUSB usb;
410
        virDomainHostdevSubsysPCI pci;
411
        virDomainHostdevSubsysSCSI scsi;
412
        virDomainHostdevSubsysSCSIVHost scsi_host;
413
        virDomainHostdevSubsysMediatedDev mdev;
414 415 416
    } u;
};

417

418
typedef enum {
419 420
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
421
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
422 423

    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
424
} virDomainHostdevCapsType;
425 426 427 428 429 430 431 432 433 434 435 436

typedef struct _virDomainHostdevCaps virDomainHostdevCaps;
typedef virDomainHostdevCaps *virDomainHostdevCapsPtr;
struct _virDomainHostdevCaps {
    int type; /* enum virDOmainHostdevCapsType */
    union {
        struct {
            char *block;
        } storage;
        struct {
            char *chardev;
        } misc;
437
        struct {
438 439
            char *ifname;
            virNetDevIPInfo ip;
440
        } net;
441 442 443 444
    } u;
};


445 446
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
447
    virDomainDeviceDef parent; /* higher level Def containing this */
448

449
    int mode; /* enum virDomainHostdevMode */
450
    int startupPolicy; /* enum virDomainStartupPolicy */
451
    bool managed;
452
    bool missing;
O
Osier Yang 已提交
453
    bool readonly;
454
    bool shareable;
455
    union {
456
        virDomainHostdevSubsys subsys;
457
        virDomainHostdevCaps caps;
458 459
    } source;
    virDomainHostdevOrigStates origstates;
460
    virDomainDeviceInfoPtr info; /* Guest address */
461 462
};

463

E
Eric Blake 已提交
464 465
/* Types of disk frontend (guest view).  For backends (host view), see
 * virStorageType in util/virstoragefile.h */
466
typedef enum {
467 468 469
    VIR_DOMAIN_DISK_DEVICE_DISK,
    VIR_DOMAIN_DISK_DEVICE_CDROM,
    VIR_DOMAIN_DISK_DEVICE_FLOPPY,
470
    VIR_DOMAIN_DISK_DEVICE_LUN,
471 472

    VIR_DOMAIN_DISK_DEVICE_LAST
473
} virDomainDiskDevice;
474

475
typedef enum {
476 477 478 479 480
    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,
481
    VIR_DOMAIN_DISK_BUS_USB,
482
    VIR_DOMAIN_DISK_BUS_UML,
483
    VIR_DOMAIN_DISK_BUS_SATA,
484
    VIR_DOMAIN_DISK_BUS_SD,
485 486

    VIR_DOMAIN_DISK_BUS_LAST
487
} virDomainDiskBus;
488

489
typedef enum {
490 491 492 493
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
494
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
495
    VIR_DOMAIN_DISK_CACHE_UNSAFE,
496 497

    VIR_DOMAIN_DISK_CACHE_LAST
498
} virDomainDiskCache;
499

500
typedef enum {
501 502
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
503
    VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
504
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
505
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
506 507

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
508
} virDomainDiskErrorPolicy;
509

M
MORITA Kazutaka 已提交
510

511
typedef enum {
512
    VIR_DOMAIN_DISK_TRAY_CLOSED = 0,
513 514 515
    VIR_DOMAIN_DISK_TRAY_OPEN,

    VIR_DOMAIN_DISK_TRAY_LAST
516
} virDomainDiskTray;
517

518
typedef enum {
J
J.B. Joret 已提交
519 520 521 522 523 524
    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
525
} virDomainDiskGeometryTrans;
J
J.B. Joret 已提交
526

527
typedef enum {
528
    VIR_DOMAIN_DISK_IO_DEFAULT = 0,
M
Matthias Dahl 已提交
529 530 531 532
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
533
} virDomainDiskIo;
M
Matthias Dahl 已提交
534

535
typedef enum {
536 537 538 539 540 541
    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
542
} virDomainStartupPolicy;
543

544

545
typedef enum {
546 547 548
    VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
    VIR_DOMAIN_DEVICE_SGIO_FILTERED,
    VIR_DOMAIN_DEVICE_SGIO_UNFILTERED,
O
Osier Yang 已提交
549

550
    VIR_DOMAIN_DEVICE_SGIO_LAST
551
} virDomainDeviceSGIO;
O
Osier Yang 已提交
552

553
typedef enum {
O
Osier Yang 已提交
554
    VIR_DOMAIN_DISK_DISCARD_DEFAULT = 0,
O
Osier Yang 已提交
555 556
    VIR_DOMAIN_DISK_DISCARD_UNMAP,
    VIR_DOMAIN_DISK_DISCARD_IGNORE,
O
Osier Yang 已提交
557 558

    VIR_DOMAIN_DISK_DISCARD_LAST
559
} virDomainDiskDiscard;
O
Osier Yang 已提交
560

561 562 563 564 565 566 567 568 569
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;

L
Lei Li 已提交
570 571 572 573 574 575 576 577
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;
578 579 580 581 582 583 584
    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;
585
    char *group_name;
586 587 588 589 590 591
    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 已提交
592 593 594
};
typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;

595

596 597 598 599 600 601 602 603 604
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;

605 606 607 608
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 已提交
609
    VIR_DOMAIN_MEMORY_SOURCE_MEMFD,     /* Memory source is set as memfd */
610 611 612 613 614 615 616 617 618 619 620 621

    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;

622

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

627 628
    virObjectPtr privateData;

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

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

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

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

L
Lei Li 已提交
651 652
    virDomainBlockIoTuneInfo blkdeviotune;

653 654
    char *driverName;

655
    char *serial;
O
Osier Yang 已提交
656
    char *wwn;
657 658
    char *vendor;
    char *product;
659
    int cachemode; /* enum virDomainDiskCache */
660 661
    int error_policy;  /* enum virDomainDiskErrorPolicy */
    int rerror_policy; /* enum virDomainDiskErrorPolicy */
662
    int iomode; /* enum virDomainDiskIo */
J
Ján Tomko 已提交
663 664 665
    int ioeventfd; /* enum virTristateSwitch */
    int event_idx; /* enum virTristateSwitch */
    int copy_on_read; /* enum virTristateSwitch */
666
    int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
667
    int startupPolicy; /* enum virDomainStartupPolicy */
668
    bool transient;
669
    virDomainDeviceInfo info;
670
    int rawio; /* enum virTristateBool */
671
    int sgio; /* enum virDomainDeviceSGIO */
O
Osier Yang 已提交
672
    int discard; /* enum virDomainDiskDiscard */
673
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
674
    int detect_zeroes; /* enum virDomainDiskDetectZeroes */
675
    char *domain_name; /* backend domain name */
L
Lin Ma 已提交
676
    unsigned int queues;
J
Ján Tomko 已提交
677
    virDomainVirtioOptionsPtr virtio;
678 679 680
};


681
typedef enum {
682 683 684 685
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
686
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
687
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
688
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
J
Ján Tomko 已提交
689
    VIR_DOMAIN_CONTROLLER_TYPE_PCI,
690 691

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
692
} virDomainControllerType;
693

694

695
typedef enum {
696
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT = -1,
J
Ján Tomko 已提交
697
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
L
Laine Stump 已提交
698
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
J
Ján Tomko 已提交
699
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
700
    VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
701
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE,
702
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT,
703
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT,
704
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT,
705
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS,
706
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS,
J
Ján Tomko 已提交
707 708

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
709
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
710

711
typedef enum {
712
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE = 0,
713 714
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE,
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE,
715
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420,
716
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM,
717
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM,
718
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB,
719
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE,
720
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT,
721
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE,
722
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_PCI_BRIDGE,
723 724 725 726

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

727
typedef enum {
728
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT = -1,
729 730 731 732 733
    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,
734
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
735
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
736
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
737

738
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
739
} virDomainControllerModelSCSI;
740

741
typedef enum {
742
    VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT = -1,
M
Marc-André Lureau 已提交
743 744 745 746 747 748 749 750 751
    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 已提交
752
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
753 754
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2,
755
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI,
756
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
M
Marc-André Lureau 已提交
757 758

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
759
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
760

761
typedef enum {
762
    VIR_DOMAIN_CONTROLLER_MODEL_IDE_DEFAULT = -1,
763 764 765 766 767 768 769
    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;

770 771 772 773 774 775 776
# 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))

777 778 779 780 781 782 783
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

784 785 786
typedef struct _virDomainPCIControllerOpts virDomainPCIControllerOpts;
typedef virDomainPCIControllerOpts *virDomainPCIControllerOptsPtr;
struct _virDomainPCIControllerOpts {
787 788
    bool pcihole64;
    unsigned long pcihole64size;
789 790 791 792 793 794 795

    /* 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 */
796 797 798 799 800 801 802 803

    /* 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 */
804 805 806 807
    /* chassis & port used by
     * pcie-root-port/pcie-switch-downstream-port, -1 = unspecified */
    int chassis;
    int port;
808
    int busNr; /* used by pci-expander-bus, -1 == unspecified */
809
    int targetIndex; /* used by spapr-pci-host-bridge, -1 == unspecified */
810 811 812 813
    /* numaNode is a *subelement* of target (to match existing
     * item in memory target config) -1 == unspecified
     */
    int numaNode;
814
};
815

816 817 818 819 820 821
typedef struct _virDomainUSBControllerOpts virDomainUSBControllerOpts;
typedef virDomainUSBControllerOpts *virDomainUSBControllerOptsPtr;
struct _virDomainUSBControllerOpts {
    int ports;   /* -1 == undef */
};

822 823 824
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
    int type;
825
    int idx;
826
    int model; /* -1 == undef */
827
    unsigned int queues;
828 829
    unsigned int cmd_per_lun;
    unsigned int max_sectors;
830
    int ioeventfd; /* enum virTristateSwitch */
831
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
832 833
    union {
        virDomainVirtioSerialOpts vioserial;
834
        virDomainPCIControllerOpts pciopts;
835
        virDomainUSBControllerOpts usbopts;
836
    } opts;
837
    virDomainDeviceInfo info;
838
    virDomainVirtioOptionsPtr virtio;
839 840 841
};


G
Giuseppe Scrivano 已提交
842
/* Types of disk backends */
843
typedef enum {
844 845 846 847 848 849
    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 */
850
    VIR_DOMAIN_FS_TYPE_VOLUME, /* Mounts storage pool volume to a guest */
851 852

    VIR_DOMAIN_FS_TYPE_LAST
853
} virDomainFSType;
854

855
/* Filesystem driver type */
856
typedef enum {
857 858 859
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
860
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
861
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
D
Dmitry Guryanov 已提交
862
    VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
863 864

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
865
} virDomainFSDriverType;
866

867
/* Filesystem mount access mode  */
868
typedef enum {
869 870 871 872 873
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
874
} virDomainFSAccessMode;
875

876
/* Filesystem Write policy */
877
typedef enum {
878 879 880 881
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
882
} virDomainFSWrpolicy;
883

884 885
struct _virDomainFSDef {
    int type;
886 887
    int fsdriver; /* enum virDomainFSDriverType */
    int accessmode; /* enum virDomainFSAccessMode */
888
    int wrpolicy; /* enum virDomainFSWrpolicy */
889
    int format; /* virStorageFileFormat */
890
    unsigned long long usage; /* in bytes */
891
    virStorageSourcePtr src;
892
    char *dst;
893
    bool readonly;
894
    virDomainDeviceInfo info;
895 896
    unsigned long long space_hard_limit; /* in bytes */
    unsigned long long space_soft_limit; /* in bytes */
897
    bool symlinksResolved;
898
    virDomainVirtioOptionsPtr virtio;
899 900 901
};


902
/* network config types */
903
typedef enum {
904 905
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
M
Michele Paolino 已提交
906
    VIR_DOMAIN_NET_TYPE_VHOSTUSER,
907 908 909 910 911
    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 已提交
912
    VIR_DOMAIN_NET_TYPE_INTERNAL,
913
    VIR_DOMAIN_NET_TYPE_DIRECT,
914
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
915
    VIR_DOMAIN_NET_TYPE_UDP,
916

917
    VIR_DOMAIN_NET_TYPE_LAST
918
} virDomainNetType;
919

920
/* the backend driver used for virtio interfaces */
921
typedef enum {
922 923 924 925
    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 */

926
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
927
} virDomainNetBackendType;
928

929
/* the TX algorithm used for virtio interfaces */
930
typedef enum {
931 932 933 934
    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,

935
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
936
} virDomainNetVirtioTxModeType;
937

938
/* link interface states */
939
typedef enum {
940 941 942 943 944
        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
945
} virDomainNetInterfaceLinkState;
946

947 948 949 950 951 952 953 954 955 956 957 958
/* 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;
959
            int macTableManager; /* enum virNetworkBridgeMACTableManagerType */
960 961 962 963 964
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
        } direct;
965 966 967
        struct {
            virDomainHostdevDef def;
        } hostdev;
968
    } data;
969
    virNetDevVPortProfilePtr virtPortProfile;
970
    virNetDevBandwidthPtr bandwidth;
971
    virNetDevVlan vlan;
972
    int trustGuestRxFilters; /* enum virTristateBool */
973
    unsigned int class_id; /* class ID for bandwidth 'floor' */
974 975
};

976 977
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
978
    virDomainNetType type;
979
    virMacAddr mac;
980
    bool mac_generated; /* true if mac was *just now* auto-generated by libvirt */
981
    char *model;
982 983
    union {
        struct {
984 985
            virDomainNetBackendType name; /* which driver backend to use */
            virDomainNetVirtioTxModeType txmode;
J
Ján Tomko 已提交
986 987
            virTristateSwitch ioeventfd;
            virTristateSwitch event_idx;
988
            unsigned int queues; /* Multiqueue virtio-net */
989
            unsigned int rx_queue_size;
990
            unsigned int tx_queue_size;
991 992 993 994 995 996 997
            struct {
                virTristateSwitch csum;
                virTristateSwitch gso;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
998
                virTristateSwitch mrg_rxbuf;
999 1000 1001 1002 1003 1004 1005 1006
            } host;
            struct {
                virTristateSwitch csum;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
            } guest;
1007 1008
        } virtio;
    } driver;
1009 1010 1011 1012
    struct {
        char *tap;
        char *vhost;
    } backend;
1013
    union {
M
Michele Paolino 已提交
1014
        virDomainChrSourceDefPtr vhostuser;
1015 1016 1017
        struct {
            char *address;
            int port;
1018 1019
            char *localaddr;
            int localport;
1020 1021 1022
        } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
        struct {
            char *name;
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032
            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;
1033 1034 1035 1036
        } network;
        struct {
            char *brname;
        } bridge;
D
Daniel Veillard 已提交
1037 1038 1039
        struct {
            char *name;
        } internal;
1040 1041
        struct {
            char *linkdev;
1042
            int mode; /* enum virMacvtapMode from util/macvtap.h */
1043
        } direct;
1044 1045 1046
        struct {
            virDomainHostdevDef def;
        } hostdev;
1047
    } data;
1048 1049
    /* virtPortProfile is used by network/bridge/direct/hostdev */
    virNetDevVPortProfilePtr virtPortProfile;
1050 1051 1052 1053
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
1054
    char *script;
1055
    char *domain_name; /* backend domain name */
1056 1057
    char *ifname; /* interface name on the host (<target dev='x'/>) */
    virNetDevIPInfo hostIP;
1058
    char *ifname_guest_actual;
1059 1060
    char *ifname_guest;
    virNetDevIPInfo guestIP;
1061
    virDomainDeviceInfo info;
1062
    char *filter;
1063
    virHashTablePtr filterparams;
1064
    virNetDevBandwidthPtr bandwidth;
1065
    virNetDevVlan vlan;
1066
    int trustGuestRxFilters; /* enum virTristateBool */
1067
    int linkstate;
1068
    unsigned int mtu;
1069
    virNetDevCoalescePtr coalesce;
1070
    virDomainVirtioOptionsPtr virtio;
1071 1072
};

1073 1074 1075 1076 1077 1078 1079 1080
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;

1081
VIR_ENUM_DECL(virDomainChrDeviceState);
1082

1083
typedef enum {
1084
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1085 1086
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1087
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1088

1089
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1090
} virDomainChrDeviceType;
1091

1092
typedef enum {
1093 1094
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
G
Guannan Ren 已提交
1095
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
M
Michal Privoznik 已提交
1096
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
1097
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
1098
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
1099
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP,
G
Guannan Ren 已提交
1100 1101

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1102
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1103

1104
typedef enum {
1105 1106
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
1107
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
J
Joao Martins 已提交
1108
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN,
1109

1110
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1111
} virDomainChrChannelTargetType;
1112

1113
typedef enum {
1114 1115
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
1116 1117
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
1118
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
1119 1120
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
1121 1122
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
1123

1124
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1125
} virDomainChrConsoleTargetType;
1126

1127 1128 1129 1130 1131
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,
1132
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
1133
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011,
1134 1135
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE,
1136
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A,
1137 1138 1139 1140 1141 1142

    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
} virDomainChrSerialTargetModel;

VIR_ENUM_DECL(virDomainChrSerialTargetModel);

1143
typedef enum {
1144 1145 1146 1147 1148 1149 1150 1151 1152 1153
    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,
1154
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1155
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1156
    VIR_DOMAIN_CHR_TYPE_NMDM,
1157

1158
    VIR_DOMAIN_CHR_TYPE_LAST
1159
} virDomainChrType;
1160

1161
typedef enum {
1162
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW = 0,
1163
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1164 1165
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1166

1167
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1168
} virDomainChrTcpProtocol;
1169

1170
typedef enum {
E
Eric Blake 已提交
1171 1172
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1173
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1174

1175
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1176
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1177

1178 1179 1180 1181 1182 1183 1184 1185 1186

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


1187 1188
/* The host side information for a character device.  */
struct _virDomainChrSourceDef {
1189
    virObject parent;
1190
    int type; /* virDomainChrType */
1191
    virObjectPtr privateData;
1192
    union {
E
Eric Blake 已提交
1193
        /* no <source> for null, vc, stdio */
1194 1195
        struct {
            char *path;
1196
            int append; /* enum virTristateSwitch */
1197
        } file; /* pty, file, pipe, or device */
1198 1199 1200 1201
        struct {
            char *master;
            char *slave;
        } nmdm;
1202 1203 1204
        struct {
            char *host;
            char *service;
1205
            bool listen;
1206
            int protocol;
1207
            bool tlscreds;
1208
            int haveTLS; /* enum virTristateBool */
1209
            bool tlsFromConfig;
1210
            virDomainChrSourceReconnectDef reconnect;
1211 1212 1213 1214 1215 1216 1217 1218 1219
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
1220
            bool listen;
1221
            virDomainChrSourceReconnectDef reconnect;
1222
        } nix;
E
Eric Blake 已提交
1223
        int spicevmc;
1224 1225 1226
        struct {
            char *channel;
        } spiceport;
1227
    } data;
1228 1229
    char *logfile;
    int logappend;
1230 1231 1232

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1233 1234 1235 1236
};

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

1239 1240 1241
    int targetType; /* enum virDomainChrConsoleTargetType ||
                       enum virDomainChrChannelTargetType ||
                       enum virDomainChrSerialTargetType according to deviceType */
1242
    int targetModel; /* enum virDomainChrSerialTargetModel */
1243

1244 1245 1246 1247 1248 1249
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

1250 1251
    virDomainChrDeviceState state;

1252
    virDomainChrSourceDefPtr source;
1253 1254

    virDomainDeviceInfo info;
1255 1256
};

1257
typedef enum {
E
Eric Blake 已提交
1258 1259 1260 1261
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

1262
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1263
} virDomainSmartcardType;
E
Eric Blake 已提交
1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275

# 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' */
1276
        virDomainChrSourceDefPtr passthru; /* 'passthrough' */
E
Eric Blake 已提交
1277 1278 1279 1280 1281
    } data;

    virDomainDeviceInfo info;
};

M
Marc-André Lureau 已提交
1282 1283 1284 1285 1286
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

1287
typedef enum {
1288
    VIR_DOMAIN_TPM_MODEL_TIS,
1289
    VIR_DOMAIN_TPM_MODEL_CRB,
1290 1291

    VIR_DOMAIN_TPM_MODEL_LAST
1292
} virDomainTPMModel;
1293

1294
typedef enum {
1295
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
1296
    VIR_DOMAIN_TPM_TYPE_EMULATOR,
1297 1298

    VIR_DOMAIN_TPM_TYPE_LAST
1299
} virDomainTPMBackendType;
1300

1301 1302 1303 1304 1305 1306 1307 1308
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;

1309 1310 1311
# define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"

struct _virDomainTPMDef {
1312
    int type; /* virDomainTPMBackendType */
1313
    virDomainDeviceInfo info;
1314 1315
    int model; /* virDomainTPMModel */
    int version; /* virDomainTPMVersion */
1316 1317 1318 1319
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
1320 1321 1322 1323 1324
        struct {
            virDomainChrSourceDef source;
            char *storagepath;
            char *logfile;
        } emulator;
1325 1326 1327
    } data;
};

1328
typedef enum {
1329 1330
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1331
    VIR_DOMAIN_INPUT_TYPE_KBD,
1332
    VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
1333

1334
    VIR_DOMAIN_INPUT_TYPE_LAST
1335
} virDomainInputType;
1336

1337
typedef enum {
1338 1339 1340
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1341
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1342
    VIR_DOMAIN_INPUT_BUS_VIRTIO,
1343 1344

    VIR_DOMAIN_INPUT_BUS_LAST
1345
} virDomainInputBus;
1346 1347 1348 1349

struct _virDomainInputDef {
    int type;
    int bus;
1350 1351 1352
    struct {
        char *evdev;
    } source;
1353
    virDomainDeviceInfo info;
1354
    virDomainVirtioOptionsPtr virtio;
1355 1356
};

1357
typedef enum {
1358 1359
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,
F
Filip Alac 已提交
1360
    VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT,
1361 1362

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1363
} virDomainSoundCodecType;
1364

1365
typedef enum {
1366 1367 1368
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1369
    VIR_DOMAIN_SOUND_MODEL_AC97,
1370
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1371
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1372
    VIR_DOMAIN_SOUND_MODEL_USB,
1373 1374

    VIR_DOMAIN_SOUND_MODEL_LAST
1375
} virDomainSoundModel;
1376

1377 1378 1379 1380 1381
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1382 1383
struct _virDomainSoundDef {
    int model;
1384
    virDomainDeviceInfo info;
1385

1386
    size_t ncodecs;
1387
    virDomainSoundCodecDefPtr *codecs;
1388 1389
};

1390
typedef enum {
R
Richard Jones 已提交
1391 1392
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,
1393
    VIR_DOMAIN_WATCHDOG_MODEL_DIAG288,
R
Richard Jones 已提交
1394 1395

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1396
} virDomainWatchdogModel;
R
Richard Jones 已提交
1397

1398
typedef enum {
R
Richard Jones 已提交
1399 1400 1401 1402
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1403
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1404
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,
1405
    VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI,
R
Richard Jones 已提交
1406 1407

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1408
} virDomainWatchdogAction;
R
Richard Jones 已提交
1409 1410 1411 1412

struct _virDomainWatchdogDef {
    int model;
    int action;
1413
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1414 1415
};

1416

1417
typedef enum {
1418
    VIR_DOMAIN_VIDEO_TYPE_DEFAULT,
1419 1420 1421 1422 1423
    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,
1424
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1425
    VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
M
Marc-André Lureau 已提交
1426
    VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
F
Fabian Freyer 已提交
1427
    VIR_DOMAIN_VIDEO_TYPE_GOP,
1428
    VIR_DOMAIN_VIDEO_TYPE_NONE,
1429 1430

    VIR_DOMAIN_VIDEO_TYPE_LAST
1431
} virDomainVideoType;
1432 1433


1434 1435 1436 1437 1438 1439 1440 1441
typedef enum {
    VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
    VIR_DOMAIN_VIDEO_VGACONF_ON,
    VIR_DOMAIN_VIDEO_VGACONF_OFF,

    VIR_DOMAIN_VIDEO_VGACONF_LAST
} virDomainVideoVGAConf;

1442
VIR_ENUM_DECL(virDomainVideoVGAConf);
1443

1444 1445 1446
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
1447 1448
    int accel2d; /* enum virTristateBool */
    int accel3d; /* enum virTristateBool */
1449 1450 1451
};


1452 1453 1454 1455 1456 1457
typedef struct _virDomainVideoDriverDef virDomainVideoDriverDef;
typedef virDomainVideoDriverDef *virDomainVideoDriverDefPtr;
struct _virDomainVideoDriverDef {
   virDomainVideoVGAConf vgaconf;
};

1458
struct _virDomainVideoDef {
1459
    int type;   /* enum virDomainVideoType */
1460 1461
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1462
    unsigned int vram64; /* kibibytes (multiples of 1024) */
1463
    unsigned int vgamem; /* kibibytes (multiples of 1024) */
1464
    unsigned int heads;
1465
    bool primary;
1466
    virDomainVideoAccelDefPtr accel;
1467
    virDomainVideoDriverDefPtr driver;
1468
    virDomainDeviceInfo info;
J
Ján Tomko 已提交
1469
    virDomainVirtioOptionsPtr virtio;
1470 1471
};

1472
/* graphics console modes */
1473
typedef enum {
1474 1475
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1476 1477
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1478
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1479
    VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS,
1480

1481
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1482
} virDomainGraphicsType;
1483

1484
typedef enum {
1485 1486 1487 1488 1489 1490
    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
1491
} virDomainGraphicsVNCSharePolicy;
1492

1493
typedef enum {
1494 1495 1496 1497 1498 1499
    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
1500
} virDomainGraphicsAuthConnectedType;
1501

1502 1503 1504 1505
typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef;
typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr;
struct _virDomainGraphicsAuthDef {
    char *passwd;
1506
    bool expires; /* Whether there is an expiry time set */
1507
    time_t validTo;  /* seconds since epoch */
1508
    int connected; /* action if connected */
1509 1510
};

1511
typedef enum {
1512 1513 1514 1515 1516 1517
    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 已提交
1518
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1519
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1520 1521

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1522
} virDomainGraphicsSpiceChannelName;
1523

1524
typedef enum {
1525 1526 1527 1528 1529
    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
1530
} virDomainGraphicsSpiceChannelMode;
1531

1532
typedef enum {
1533 1534 1535 1536 1537 1538 1539 1540 1541
    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
1542
} virDomainGraphicsSpiceImageCompression;
1543

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

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

1562
typedef enum {
P
Peng Zhou 已提交
1563 1564 1565 1566 1567
    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
1568
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1569

1570
typedef enum {
1571 1572 1573 1574 1575 1576
    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
1577
} virDomainGraphicsSpiceStreamingMode;
1578

1579
typedef enum {
1580 1581 1582
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1583
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1584

1585
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1586
} virDomainGraphicsListenType;
1587

1588
typedef enum {
M
Marc-André Lureau 已提交
1589 1590
    VIR_DOMAIN_HUB_TYPE_USB,

1591
    VIR_DOMAIN_HUB_TYPE_LAST
1592
} virDomainHubType;
M
Marc-André Lureau 已提交
1593

1594 1595 1596
typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef;
typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr;
struct _virDomainGraphicsListenDef {
1597
    virDomainGraphicsListenType type;
1598 1599
    char *address;
    char *network;
1600
    char *socket;
1601
    bool fromConfig;    /* true if the @address is config file originated */
1602
    bool autoGenerated;
1603 1604
};

1605
struct _virDomainGraphicsDef {
1606 1607
    virObjectPtr privateData;

M
Michal Privoznik 已提交
1608 1609 1610 1611 1612
    /* 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.
     */
1613
    virDomainGraphicsType type;
1614 1615 1616
    union {
        struct {
            int port;
1617
            bool portReserved;
M
Martin Kletzander 已提交
1618
            int websocket;
1619
            bool websocketGenerated;
1620
            bool autoport;
1621
            char *keymap;
1622
            virDomainGraphicsAuthDef auth;
1623
            int sharePolicy;
1624 1625 1626 1627
        } vnc;
        struct {
            char *display;
            char *xauth;
1628
            bool fullscreen;
1629
            virTristateBool gl;
1630
        } sdl;
1631 1632
        struct {
            int port;
1633 1634 1635
            bool autoport;
            bool replaceUser;
            bool multiUser;
1636 1637 1638
        } rdp;
        struct {
            char *display;
1639
            bool fullscreen;
1640
        } desktop;
1641 1642 1643
        struct {
            int port;
            int tlsPort;
1644 1645
            bool portReserved;
            bool tlsPortReserved;
1646
            virDomainGraphicsSpiceMouseMode mousemode;
1647
            char *keymap;
1648
            virDomainGraphicsAuthDef auth;
1649
            bool autoport;
1650
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1651
            virDomainGraphicsSpiceChannelMode defaultMode;
1652 1653 1654 1655
            int image;
            int jpeg;
            int zlib;
            int playback;
1656
            int streaming;
1657 1658 1659
            virTristateBool copypaste;
            virTristateBool filetransfer;
            virTristateBool gl;
1660
            char *rendernode;
1661
        } spice;
1662 1663 1664
        struct {
            char *rendernode;
        } egl_headless;
1665
    } data;
1666 1667 1668 1669 1670
    /* 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;
1671 1672
};

1673
typedef enum {
1674 1675 1676
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1677
} virDomainRedirdevBus;
1678 1679 1680 1681

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

1682
    virDomainChrSourceDefPtr source;
1683 1684 1685

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

1687
struct _virDomainRedirFilterUSBDevDef {
1688 1689 1690 1691
    int usbClass;
    int vendor;
    int product;
    int version;
1692
    bool allow;
1693 1694 1695 1696
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1697
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1698 1699
};

1700
typedef enum {
1701 1702
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1703
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1704 1705

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1706
} virDomainMemballoonModel;
1707 1708 1709 1710

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1711
    int period; /* seconds between collections */
1712
    int autodeflate; /* enum virTristateSwitch */
1713
    virDomainVirtioOptionsPtr virtio;
1714 1715
};

L
Li Zhang 已提交
1716 1717 1718
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1719

1720 1721
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1722 1723
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1724 1725 1726 1727

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

1728 1729 1730
struct _virDomainShmemDef {
    char *name;
    unsigned long long size;
1731
    int model; /* enum virDomainShmemModel */
1732 1733
    struct {
        bool enabled;
1734
        virDomainChrSourceDef chr;
1735 1736 1737 1738 1739 1740 1741 1742 1743
    } server;
    struct {
        bool enabled;
        unsigned vectors;
        virTristateSwitch ioeventfd;
    } msi;
    virDomainDeviceInfo info;
};

1744
typedef enum {
1745
    VIR_DOMAIN_SMBIOS_NONE = 0,
1746 1747 1748 1749 1750
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1751
} virDomainSmbiosMode;
1752

1753

1754
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1755

1756
typedef enum {
1757 1758 1759 1760 1761
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1762
    VIR_DOMAIN_BOOT_LAST
1763
} virDomainBootOrder;
1764

1765
typedef enum {
1766 1767 1768
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1769
    VIR_DOMAIN_FEATURE_HAP,
1770
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1771
    VIR_DOMAIN_FEATURE_PRIVNET,
1772
    VIR_DOMAIN_FEATURE_HYPERV,
1773
    VIR_DOMAIN_FEATURE_KVM,
1774
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1775
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1776
    VIR_DOMAIN_FEATURE_PMU,
1777
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1778
    VIR_DOMAIN_FEATURE_GIC,
M
Michal Privoznik 已提交
1779
    VIR_DOMAIN_FEATURE_SMM,
1780
    VIR_DOMAIN_FEATURE_IOAPIC,
1781
    VIR_DOMAIN_FEATURE_HPT,
M
Marc-André Lureau 已提交
1782
    VIR_DOMAIN_FEATURE_VMCOREINFO,
1783
    VIR_DOMAIN_FEATURE_HTM,
1784
    VIR_DOMAIN_FEATURE_NESTED_HV,
1785
    VIR_DOMAIN_FEATURE_MSRS,
1786 1787

    VIR_DOMAIN_FEATURE_LAST
1788
} virDomainFeature;
1789

1790 1791
# define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12

1792
typedef enum {
1793
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1794 1795
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1796 1797 1798 1799 1800 1801
    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,
1802
    VIR_DOMAIN_HYPERV_FREQUENCIES,
1803
    VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
1804
    VIR_DOMAIN_HYPERV_TLBFLUSH,
1805
    VIR_DOMAIN_HYPERV_IPI,
1806
    VIR_DOMAIN_HYPERV_EVMCS,
1807 1808

    VIR_DOMAIN_HYPERV_LAST
1809
} virDomainHyperv;
1810

1811 1812 1813 1814 1815 1816
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829
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;

1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879
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;

1880 1881 1882 1883 1884 1885 1886 1887 1888 1889
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;

1890
VIR_ENUM_DECL(virDomainLockFailure);
1891

M
Michal Privoznik 已提交
1892 1893 1894
typedef struct _virDomainBIOSDef virDomainBIOSDef;
typedef virDomainBIOSDef *virDomainBIOSDefPtr;
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1895
    int useserial; /* enum virTristateBool */
1896 1897 1898
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1899 1900
};

1901 1902 1903 1904 1905 1906 1907
typedef enum {
    VIR_DOMAIN_LOADER_TYPE_ROM = 0,
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

1908
VIR_ENUM_DECL(virDomainLoader);
1909 1910 1911 1912 1913 1914 1915

typedef struct _virDomainLoaderDef virDomainLoaderDef;
typedef virDomainLoaderDef *virDomainLoaderDefPtr;
struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1916
    int secure;     /* enum virTristateBool */
1917
    char *nvram;    /* path to non-volatile RAM */
1918
    char *templt;   /* user override of path to master nvram */
1919 1920 1921 1922
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1923
typedef enum {
1924 1925
    VIR_DOMAIN_IOAPIC_NONE = 0,
    VIR_DOMAIN_IOAPIC_QEMU,
1926 1927 1928 1929 1930 1931 1932
    VIR_DOMAIN_IOAPIC_KVM,

    VIR_DOMAIN_IOAPIC_LAST
} virDomainIOAPIC;

VIR_ENUM_DECL(virDomainIOAPIC);

1933
typedef enum {
1934 1935
    VIR_DOMAIN_HPT_RESIZING_NONE = 0,
    VIR_DOMAIN_HPT_RESIZING_ENABLED,
1936 1937 1938 1939 1940 1941 1942 1943
    VIR_DOMAIN_HPT_RESIZING_DISABLED,
    VIR_DOMAIN_HPT_RESIZING_REQUIRED,

    VIR_DOMAIN_HPT_RESIZING_LAST
} virDomainHPTResizing;

VIR_ENUM_DECL(virDomainHPTResizing);

1944
/* Operating system configuration data & machine / arch */
1945 1946 1947 1948 1949 1950 1951
typedef struct _virDomainOSEnv virDomainOSEnv;
typedef virDomainOSEnv *virDomainOSEnvPtr;
struct _virDomainOSEnv {
    char *name;
    char *value;
};

1952 1953 1954
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
1955
    int type;
1956
    virArch arch;
1957
    char *machine;
1958
    size_t nBootDevs;
1959
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1960
    int bootmenu; /* enum virTristateBool */
1961 1962
    unsigned int bm_timeout;
    bool bm_timeout_set;
1963
    char *init;
1964
    char **initargv;
1965
    virDomainOSEnvPtr *initenv;
1966
    char *initdir;
1967 1968
    char *inituser;
    char *initgroup;
1969 1970 1971
    char *kernel;
    char *initrd;
    char *cmdline;
1972
    char *dtb;
1973
    char *root;
J
Ján Tomko 已提交
1974
    char *slic_table;
1975
    virDomainLoaderDefPtr loader;
1976 1977
    char *bootloader;
    char *bootloaderArgs;
1978
    int smbios_mode;
1979

M
Michal Privoznik 已提交
1980
    virDomainBIOSDef bios;
1981 1982
};

1983
typedef enum {
1984 1985 1986 1987 1988
    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 已提交
1989
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1990
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
1991

1992
    VIR_DOMAIN_TIMER_NAME_LAST
1993
} virDomainTimerNameType;
1994

1995
typedef enum {
1996 1997 1998
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1999

2000
    VIR_DOMAIN_TIMER_TRACK_LAST
2001
} virDomainTimerTrackType;
2002

2003
typedef enum {
2004 2005 2006 2007 2008
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

2009
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
2010
} virDomainTimerTickpolicyType;
2011

2012
typedef enum {
2013 2014 2015 2016
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
2017
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
2018

2019
    VIR_DOMAIN_TIMER_MODE_LAST
2020
} virDomainTimerModeType;
2021

2022
typedef enum {
2023
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
2024 2025
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

2026
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
2027
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
2028

2029 2030 2031
typedef struct _virDomainThreadSchedParam virDomainThreadSchedParam;
typedef virDomainThreadSchedParam *virDomainThreadSchedParamPtr;
struct _virDomainThreadSchedParam {
2032
    virProcessSchedPolicy policy;
2033 2034 2035
    int priority;
};

2036 2037 2038 2039 2040 2041 2042 2043
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

2044 2045 2046 2047 2048 2049 2050
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 */

2051 2052 2053 2054
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
2055 2056 2057 2058 2059 2060

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

2061
typedef enum {
2062 2063
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
2064
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
2065
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
2066

2067
    VIR_DOMAIN_CLOCK_OFFSET_LAST
2068
} virDomainClockOffsetType;
2069

2070
typedef enum {
2071 2072 2073
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

2074
    VIR_DOMAIN_CLOCK_BASIS_LAST
2075
} virDomainClockBasis;
2076

2077 2078 2079 2080
typedef struct _virDomainClockDef virDomainClockDef;
typedef virDomainClockDef *virDomainClockDefPtr;
struct _virDomainClockDef {
    int offset;
2081

2082
    union {
2083 2084 2085
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
2086
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
2087 2088 2089
        struct {
            long long adjustment;
            int basis;
2090 2091 2092 2093 2094 2095 2096

            /* 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;
2097
        } variable;
2098 2099 2100 2101 2102

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

2104
    size_t ntimers;
2105
    virDomainTimerDefPtr *timers;
2106 2107
};

2108

2109 2110 2111
typedef struct _virBlkioDevice virBlkioDevice;
typedef virBlkioDevice *virBlkioDevicePtr;
struct _virBlkioDevice {
2112 2113
    char *path;
    unsigned int weight;
2114 2115 2116 2117
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
2118 2119
};

2120
typedef enum {
2121 2122 2123
    VIR_DOMAIN_RNG_MODEL_VIRTIO,

    VIR_DOMAIN_RNG_MODEL_LAST
2124
} virDomainRNGModel;
2125

2126
typedef enum {
2127 2128 2129 2130 2131
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
    /* VIR_DOMAIN_RNG_BACKEND_POOL, */

    VIR_DOMAIN_RNG_BACKEND_LAST
2132
} virDomainRNGBackend;
2133 2134 2135 2136

struct _virDomainRNGDef {
    int model;
    int backend;
2137 2138
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
2139 2140 2141 2142 2143 2144 2145 2146

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

    virDomainDeviceInfo info;
2147
    virDomainVirtioOptionsPtr virtio;
2148 2149
};

2150 2151 2152
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2153
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2154 2155 2156 2157 2158

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
2159
    virDomainMemoryAccess access;
2160
    virTristateBool discard;
2161

2162 2163 2164
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2165
    char *nvdimmPath;
2166
    unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
2167
    bool nvdimmPmem; /* valid only for NVDIMM */
2168 2169 2170

    /* target */
    int model; /* virDomainMemoryModel */
2171
    int targetNode;
2172
    unsigned long long size; /* kibibytes */
2173
    unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
2174
    bool readonly; /* valid only for NVDIMM */
2175 2176 2177 2178 2179 2180

    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2196 2197 2198 2199 2200
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2201
    VIR_DOMAIN_PANIC_MODEL_S390,
2202 2203 2204 2205

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2206
struct _virDomainPanicDef {
2207
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2208 2209 2210 2211
    virDomainDeviceInfo info;
};


2212
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2213
                              int ndevices);
2214

2215 2216 2217 2218 2219
typedef struct _virDomainResourceDef virDomainResourceDef;
typedef virDomainResourceDef *virDomainResourceDefPtr;
struct _virDomainResourceDef {
    char *partition;
};
2220

2221
typedef struct _virDomainHugePage virDomainHugePage;
2222 2223
typedef virDomainHugePage *virDomainHugePagePtr;

2224
struct _virDomainHugePage {
2225 2226 2227 2228
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2229 2230
# define VIR_DOMAIN_CPUMASK_LEN 1024

2231 2232 2233 2234 2235 2236
typedef struct _virDomainIOThreadIDDef virDomainIOThreadIDDef;
typedef virDomainIOThreadIDDef *virDomainIOThreadIDDefPtr;

struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2237
    int thread_id;
2238
    virBitmapPtr cpumask;
2239 2240

    virDomainThreadSchedParam sched;
2241 2242 2243 2244
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2245

2246 2247 2248 2249
typedef struct _virDomainCputune virDomainCputune;
typedef virDomainCputune *virDomainCputunePtr;

struct _virDomainCputune {
2250
    unsigned long long shares;
2251 2252 2253
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2254
    unsigned long long global_period;
2255
    long long global_quota;
2256 2257
    unsigned long long emulator_period;
    long long emulator_quota;
2258 2259
    unsigned long long iothread_period;
    long long iothread_quota;
2260
    virBitmapPtr emulatorpin;
2261 2262
};

2263

2264 2265 2266 2267 2268 2269 2270 2271
typedef struct _virDomainResctrlMonDef virDomainResctrlMonDef;
typedef virDomainResctrlMonDef *virDomainResctrlMonDefPtr;
struct _virDomainResctrlMonDef {
    virBitmapPtr vcpus;
    virResctrlMonitorType tag;
    virResctrlMonitorPtr instance;
};

B
Bing Niu 已提交
2272 2273
typedef struct _virDomainResctrlDef virDomainResctrlDef;
typedef virDomainResctrlDef *virDomainResctrlDefPtr;
2274

B
Bing Niu 已提交
2275
struct _virDomainResctrlDef {
2276 2277
    virBitmapPtr vcpus;
    virResctrlAllocPtr alloc;
2278 2279 2280

    virDomainResctrlMonDefPtr *monitors;
    size_t nmonitors;
2281 2282 2283
};


2284 2285
typedef struct _virDomainVcpuDef virDomainVcpuDef;
typedef virDomainVcpuDef *virDomainVcpuDefPtr;
2286

2287
struct _virDomainVcpuDef {
2288
    bool online;
2289 2290 2291
    virTristateBool hotpluggable;
    unsigned int order;

2292
    virBitmapPtr cpumask;
2293 2294

    virDomainThreadSchedParam sched;
2295 2296

    virObjectPtr privateData;
2297 2298
};

2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312
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 {
2313 2314 2315
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2316 2317
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2318 2319 2320 2321

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2322 2323 2324 2325
    /* 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 */

2326 2327 2328
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2329 2330 2331 2332
    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 */
2333 2334 2335 2336

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2337 2338

    virTristateBool discard;
2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349
};

typedef struct _virDomainPowerManagement virDomainPowerManagement;
typedef virDomainPowerManagement *virDomainPowerManagementPtr;

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

Q
Qiaowei Ren 已提交
2350 2351 2352 2353 2354 2355 2356
typedef struct _virDomainPerfDef virDomainPerfDef;
typedef virDomainPerfDef *virDomainPerfDefPtr;
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2357 2358 2359 2360 2361 2362 2363
typedef struct _virDomainKeyWrapDef virDomainKeyWrapDef;
typedef virDomainKeyWrapDef *virDomainKeyWrapDefPtr;
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

2364 2365 2366 2367 2368 2369 2370
typedef enum {
    VIR_DOMAIN_LAUNCH_SECURITY_NONE,
    VIR_DOMAIN_LAUNCH_SECURITY_SEV,

    VIR_DOMAIN_LAUNCH_SECURITY_LAST,
} virDomainLaunchSecurity;

2371 2372
typedef struct _virDomainSEVDef virDomainSEVDef;
typedef virDomainSEVDef *virDomainSEVDefPtr;
2373

2374
struct _virDomainSEVDef {
2375 2376 2377 2378 2379 2380 2381 2382 2383
    int sectype; /* enum virDomainLaunchSecurity */
    char *dh_cert;
    char *session;
    unsigned int policy;
    unsigned int cbitpos;
    unsigned int reduced_phys_bits;
};


J
Ján Tomko 已提交
2384 2385 2386 2387 2388 2389 2390 2391
typedef enum {
    VIR_DOMAIN_IOMMU_MODEL_INTEL,

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

struct _virDomainIOMMUDef {
    virDomainIOMMUModel model;
2392
    virTristateSwitch intremap;
2393
    virTristateSwitch caching_mode;
2394
    virTristateSwitch eim;
J
Ján Tomko 已提交
2395
    virTristateSwitch iotlb;
J
Ján Tomko 已提交
2396
};
2397

J
Ján Tomko 已提交
2398 2399 2400 2401 2402 2403 2404
typedef enum {
    VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO,

    VIR_DOMAIN_VSOCK_MODEL_LAST
} virDomainVsockModel;

J
Ján Tomko 已提交
2405
struct _virDomainVsockDef {
2406
    virObjectPtr privateData;
J
Ján Tomko 已提交
2407 2408 2409 2410 2411 2412

    virDomainVsockModel model;
    unsigned int guest_cid;
    virTristateBool auto_cid;

    virDomainDeviceInfo info;
J
Ján Tomko 已提交
2413 2414
};

2415 2416 2417 2418 2419
struct _virDomainVirtioOptions {
    virTristateSwitch iommu;
    virTristateSwitch ats;
};

2420 2421 2422 2423 2424 2425
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
2426 2427
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
2428
struct _virDomainDef {
2429
    int virtType; /* enum virDomainVirtType */
2430 2431
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
2432 2433 2434 2435 2436

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

2437
    char *name;
2438
    char *title;
2439
    char *description;
2440

2441 2442
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2443

2444
    virDomainVcpuDefPtr *vcpus;
2445
    size_t maxvcpus;
2446 2447
    /* set if the vcpu definition was specified individually */
    bool individualvcpus;
O
Osier Yang 已提交
2448
    int placement_mode;
H
Hu Tao 已提交
2449
    virBitmapPtr cpumask;
2450

2451 2452
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2453

2454
    virDomainCputune cputune;
2455

B
Bing Niu 已提交
2456 2457
    virDomainResctrlDefPtr *resctrls;
    size_t nresctrls;
2458

2459
    virDomainNumaPtr numa;
2460
    virDomainResourceDefPtr resource;
2461
    virDomainIdMapDef idmap;
2462

2463 2464 2465 2466 2467
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2468 2469
    int onLockFailure; /* enum virDomainLockFailureAction */

2470
    virDomainPowerManagement pm;
2471

2472
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2473

2474 2475
    virDomainOSDef os;
    char *emulator;
2476 2477 2478
    /* 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. */
2479
    int features[VIR_DOMAIN_FEATURE_LAST];
2480
    int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
2481
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2482
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2483
    int msrs_features[VIR_DOMAIN_MSRS_LAST];
2484
    unsigned int hyperv_spinlocks;
2485
    virGICVersion gic_version;
2486
    virDomainHPTResizing hpt_resizing;
2487
    unsigned long long hpt_maxpagesize; /* Stored in KiB */
2488
    char *hyperv_vendor_id;
2489
    int apic_eoi;
2490

2491 2492 2493
    bool tseg_specified;
    unsigned long long tseg_size;

2494
    virDomainClockDef clock;
2495

2496
    size_t ngraphics;
2497
    virDomainGraphicsDefPtr *graphics;
2498

2499
    size_t ndisks;
2500 2501
    virDomainDiskDefPtr *disks;

2502
    size_t ncontrollers;
2503 2504
    virDomainControllerDefPtr *controllers;

2505
    size_t nfss;
2506 2507
    virDomainFSDefPtr *fss;

2508
    size_t nnets;
2509 2510
    virDomainNetDefPtr *nets;

2511
    size_t ninputs;
2512 2513
    virDomainInputDefPtr *inputs;

2514
    size_t nsounds;
2515 2516
    virDomainSoundDefPtr *sounds;

2517
    size_t nvideos;
2518 2519
    virDomainVideoDefPtr *videos;

2520
    size_t nhostdevs;
2521 2522
    virDomainHostdevDefPtr *hostdevs;

2523
    size_t nredirdevs;
2524 2525
    virDomainRedirdevDefPtr *redirdevs;

2526
    size_t nsmartcards;
E
Eric Blake 已提交
2527 2528
    virDomainSmartcardDefPtr *smartcards;

2529
    size_t nserials;
2530 2531
    virDomainChrDefPtr *serials;

2532
    size_t nparallels;
2533 2534
    virDomainChrDefPtr *parallels;

2535
    size_t nchannels;
2536 2537
    virDomainChrDefPtr *channels;

2538
    size_t nconsoles;
2539 2540
    virDomainChrDefPtr *consoles;

2541
    size_t nleases;
2542 2543
    virDomainLeaseDefPtr *leases;

2544
    size_t nhubs;
M
Marc-André Lureau 已提交
2545 2546
    virDomainHubDefPtr *hubs;

2547 2548 2549
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2550 2551 2552
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2553 2554 2555
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2556 2557 2558
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2559 2560 2561
    size_t npanics;
    virDomainPanicDefPtr *panics;

2562
    /* Only 1 */
R
Richard Jones 已提交
2563
    virDomainWatchdogDefPtr watchdog;
2564
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2565
    virDomainNVRAMDefPtr nvram;
2566
    virDomainTPMDefPtr tpm;
2567
    virCPUDefPtr cpu;
2568
    virSysinfoDefPtr sysinfo;
2569
    virDomainRedirFilterDefPtr redirfilter;
J
Ján Tomko 已提交
2570
    virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
2571
    virDomainVsockDefPtr vsock;
2572 2573 2574

    void *namespaceData;
    virDomainXMLNamespace ns;
2575

2576 2577
    virDomainKeyWrapDefPtr keywrap;

2578
    /* SEV-specific domain */
2579
    virDomainSEVDefPtr sev;
2580

2581 2582
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2583 2584 2585 2586 2587 2588

    /* 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 */
2589 2590
};

2591

2592
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2593
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2594
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2595
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2596

2597 2598 2599 2600 2601 2602 2603
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

2604
typedef enum {
2605 2606 2607 2608 2609
    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 */
2610
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2611
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2612
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2613
    VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,/* CDROM passthrough */
Y
Yuri Chornoivan 已提交
2614
    VIR_DOMAIN_TAINT_CUSTOM_DTB,       /* Custom device tree blob was specified */
2615
    VIR_DOMAIN_TAINT_CUSTOM_GA_COMMAND, /* Custom guest agent command */
2616 2617

    VIR_DOMAIN_TAINT_LAST
2618
} virDomainTaintFlags;
2619

2620
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2621 2622 2623 2624 2625 2626
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2627 2628 2629
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
2630
    virObjectLockable parent;
2631
    virCond cond;
2632

2633
    pid_t pid;
J
Jiri Denemark 已提交
2634
    virDomainStateReason state;
2635 2636 2637

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2638
    unsigned int updated : 1;
2639
    unsigned int removing : 1;
2640 2641 2642

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

2644
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2645 2646
    virDomainSnapshotObjPtr current_snapshot;

2647 2648
    bool hasManagedSave;

2649 2650
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2651 2652

    int taint;
2653 2654 2655

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

2658 2659
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2660

2661

2662 2663
/* NB: Any new flag to this list be considered to be set in
 * virt-aa-helper code if the flag prevents parsing. */
2664 2665
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2666
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2667
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2668
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2669
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2670
    VIR_DOMAIN_DEF_FEATURE_USER_ALIAS = (1 << 5),
2671
    VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER = (1 << 6),
2672 2673 2674
} virDomainDefFeatures;


2675 2676
/* This structure holds various callbacks and data needed
 * while parsing and creating domain XMLs */
2677 2678
typedef struct _virDomainXMLOption virDomainXMLOption;
typedef virDomainXMLOption *virDomainXMLOptionPtr;
2679

2680 2681 2682 2683 2684 2685 2686 2687 2688

/* 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);

2689
/* Called once after everything else has been parsed, for adjusting
2690 2691 2692
 * overall domain defaults.
 * @parseOpaque is opaque data passed by virDomainDefParse* caller,
 * @opaque is opaque data set by driver (usually pointer to driver
2693 2694 2695 2696
 * 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. */
2697 2698
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
                                             virCapsPtr caps,
2699
                                             unsigned int parseFlags,
2700 2701
                                             void *opaque,
                                             void *parseOpaque);
2702
/* Called once per device, for adjusting per-device settings while
2703 2704 2705 2706
 * 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). */
2707
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
2708
                                                   const virDomainDef *def,
2709
                                                   virCapsPtr caps,
2710
                                                   unsigned int parseFlags,
2711 2712
                                                   void *opaque,
                                                   void *parseOpaque);
2713
/* Drive callback for assigning device addresses, called at the end
2714 2715 2716 2717
 * 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). */
2718 2719 2720
typedef int (*virDomainDefAssignAddressesCallback)(virDomainDef *def,
                                                   virCapsPtr caps,
                                                   unsigned int parseFlags,
2721 2722
                                                   void *opaque,
                                                   void *parseOpaque);
2723

2724 2725 2726 2727 2728 2729 2730
typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def,
                                              virCapsPtr caps,
                                              unsigned int parseFlags,
                                              void *opaque,
                                              void **parseOpaque);
typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque);

2731 2732 2733 2734 2735 2736
/* 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);
2737

2738 2739 2740 2741 2742 2743
/* 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);

2744 2745 2746
typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
struct _virDomainDefParserConfig {
2747
    /* driver domain definition callbacks */
2748
    virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
2749
    virDomainDefPostParseDataAlloc domainPostParseDataAlloc;
2750 2751
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2752
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2753
    virDomainDefPostParseDataFree domainPostParseDataFree;
2754

2755 2756
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2757
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2758

2759
    /* private data for the callbacks */
2760 2761
    void *priv;
    virFreeCallback privFree;
2762 2763

    /* data */
2764
    unsigned int features; /* virDomainDefFeatures */
2765
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2766 2767
};

2768
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *);
2769 2770 2771 2772 2773 2774 2775 2776
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
                                                 virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                virDomainObjPtr,
                                                virDomainDefParserConfigPtr);

2777 2778
typedef void *(*virDomainXMLPrivateDataGetParseOpaqueFunc)(virDomainObjPtr vm);

2779 2780 2781 2782 2783
typedef int (*virDomainXMLPrivateDataDiskParseFunc)(xmlXPathContextPtr ctxt,
                                                    virDomainDiskDefPtr disk);
typedef int (*virDomainXMLPrivateDataDiskFormatFunc)(virDomainDiskDefPtr disk,
                                                     virBufferPtr buf);

2784 2785 2786 2787 2788 2789
typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
                                                             virStorageSourcePtr src);
typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
                                                              virBufferPtr buf);


2790 2791 2792 2793 2794
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
2795 2796
    /* note that private data for devices are not copied when using
     * virDomainDefCopy and similar functions */
2797
    virDomainXMLPrivateDataNewFunc    diskNew;
2798 2799
    virDomainXMLPrivateDataDiskParseFunc diskParse;
    virDomainXMLPrivateDataDiskFormatFunc diskFormat;
2800
    virDomainXMLPrivateDataNewFunc    vcpuNew;
2801
    virDomainXMLPrivateDataNewFunc    chrSourceNew;
2802
    virDomainXMLPrivateDataNewFunc    vsockNew;
2803
    virDomainXMLPrivateDataNewFunc    graphicsNew;
2804 2805
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
2806 2807 2808
    /* following function shall return a pointer which will be used as the
     * 'parseOpaque' argument for virDomainDefPostParse */
    virDomainXMLPrivateDataGetParseOpaqueFunc getParseOpaque;
2809 2810
    virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
    virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
2811 2812
};

2813 2814 2815 2816 2817 2818 2819 2820 2821
typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
                                            const virDomainDef *dst);

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

2822 2823
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
2824
                                            virDomainXMLNamespacePtr xmlns,
2825 2826 2827 2828 2829
                                            virDomainABIStabilityPtr abi,
                                            virSaveCookieCallbacksPtr saveCookie);

virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
2830

2831 2832
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2833
virDomainXMLNamespacePtr
2834
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2835 2836
    ATTRIBUTE_NONNULL(1);

2837 2838 2839 2840 2841
int virDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2842
bool virDomainDefHasUSB(const virDomainDef *def);
2843

2844 2845 2846 2847
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
                                           virDomainDeviceDefPtr dev,
                                           unsigned int flags);

2848 2849
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);

2850
int virDomainDefValidate(virDomainDefPtr def,
2851 2852 2853 2854
                         virCapsPtr caps,
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2855
static inline bool
D
Daniel P. Berrange 已提交
2856
virDomainObjIsActive(virDomainObjPtr dom)
2857 2858 2859 2860
{
    return dom->def->id != -1;
}

2861 2862
int virDomainObjCheckActive(virDomainObjPtr dom);

2863 2864 2865 2866 2867 2868 2869 2870 2871 2872
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;
2873
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2874 2875
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2876

2877
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2878
    ATTRIBUTE_NONNULL(1);
2879

M
Michal Privoznik 已提交
2880 2881
void virDomainObjEndAPI(virDomainObjPtr *vm);

2882
bool virDomainObjTaint(virDomainObjPtr obj,
2883
                       virDomainTaintFlags taint);
2884

2885 2886 2887 2888
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2889

H
Hu Tao 已提交
2890
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2891
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2892
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
J
Ján Tomko 已提交
2893
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
2894
void virDomainInputDefFree(virDomainInputDefPtr def);
2895
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2896
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2897
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2898 2899
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2900
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2901 2902
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
    ATTRIBUTE_RETURN_CHECK;
2903
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
2904
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
2905 2906 2907 2908
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
    ATTRIBUTE_RETURN_CHECK;
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2909 2910 2911
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
                                  virDomainDeviceInfoPtr info);
2912 2913 2914
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2915 2916

virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type);
2917
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2918
bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont);
2919

2920
virDomainFSDefPtr virDomainFSDefNew(void);
2921
void virDomainFSDefFree(virDomainFSDefPtr def);
2922
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
J
Ján Tomko 已提交
2923 2924
virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt);
void virDomainVsockDefFree(virDomainVsockDefPtr vsock);
2925
void virDomainNetDefClear(virDomainNetDefPtr def);
2926
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2927
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2928
void virDomainChrDefFree(virDomainChrDefPtr def);
2929 2930
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
                              virDomainChrSourceDefPtr src);
2931
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
2932
void virDomainSoundDefFree(virDomainSoundDefPtr def);
2933
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2934
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2935
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
C
Cole Robinson 已提交
2936
virDomainVideoDefPtr virDomainVideoDefNew(void);
2937
void virDomainVideoDefFree(virDomainVideoDefPtr def);
2938
void virDomainVideoDefClear(virDomainVideoDefPtr def);
J
John Ferlan 已提交
2939
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
2940
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2941
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2942
void virDomainHubDefFree(virDomainHubDefPtr def);
2943
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2944
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2945
void virDomainShmemDefFree(virDomainShmemDefPtr def);
2946
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2947
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2948
                                             const virDomainDef *def,
2949 2950
                                             virCapsPtr caps,
                                             virDomainXMLOptionPtr xmlopt);
2951
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
C
Cole Robinson 已提交
2952 2953
void virDomainDeviceSetData(virDomainDeviceDefPtr device,
                            void *devicedata);
2954
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2955

2956
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2957 2958
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2959 2960 2961 2962 2963 2964
                                           void *opaque);

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

2965 2966 2967 2968
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

2969 2970
void virDomainDefFree(virDomainDefPtr vm);

2971 2972 2973
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);

2974
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
2975

2976 2977
virDomainGraphicsDefPtr
virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt);
2978
virDomainDefPtr virDomainDefNew(void);
2979

2980
void virDomainObjAssignDef(virDomainObjPtr domain,
2981
                           virDomainDefPtr def,
2982 2983
                           bool live,
                           virDomainDefPtr *oldDef);
2984
int virDomainObjSetDefTransient(virCapsPtr caps,
2985
                                virDomainXMLOptionPtr xmlopt,
2986
                                virDomainObjPtr domain);
2987
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
2988 2989
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
2990
                             virDomainXMLOptionPtr xmlopt,
2991
                             virDomainObjPtr domain);
2992 2993 2994 2995 2996 2997 2998 2999

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

int virDomainObjGetDefs(virDomainObjPtr vm,
                        unsigned int flags,
                        virDomainDefPtr *liveDef,
                        virDomainDefPtr *persDef);
3000 3001 3002
virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                           unsigned int flags,
                                           bool *state);
3003
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
3004

3005 3006 3007
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virCapsPtr caps,
                                 virDomainXMLOptionPtr xmlopt,
3008
                                 void *parseOpaque,
3009 3010 3011 3012
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt);
3013

3014 3015 3016
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
3017 3018 3019 3020
    /* 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. */
3021 3022 3023 3024 3025
    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,
3026
    /* internal flag passed to device info sub-parser to allow using <rom> */
3027
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
3028
    /* internal flag passed to device info sub-parser to allow specifying boot order */
3029 3030
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    /* parse only source half of <disk> */
3031
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 6,
3032
    /* perform RNG schema validation on the passed XML document */
3033
    VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA = 1 << 7,
3034
    /* allow updates in post parse callback that would break ABI otherwise */
3035
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE = 1 << 8,
3036
    /* skip definition validation checks meant to be executed on define time only */
3037
    VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 9,
3038
    /* skip parsing of security labels */
3039
    VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 10,
3040 3041 3042
    /* 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. */
3043
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 11,
3044 3045 3046 3047
    /* 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 */
3048
    VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL = 1 << 12,
3049 3050 3051 3052 3053
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
3054
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
3055
    /* format internal domain status information */
3056
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
3057
    /* format <actual> element */
3058
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
3059
    /* format original states of host PCI device */
3060 3061 3062 3063
    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,
3064 3065
} virDomainDefFormatFlags;

3066 3067 3068 3069 3070 3071 3072 3073 3074
/* 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;

3075
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
3076
                                              const virDomainDef *def,
3077 3078
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
3079
                                              unsigned int flags);
3080 3081 3082 3083
virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr,
                                          const virDomainDef *def,
                                          virDomainXMLOptionPtr xmlopt,
                                          unsigned int flags);
3084 3085
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                        virCapsPtr caps,
3086
                                        virDomainXMLOptionPtr xmlopt,
3087
                                        void *parseOpaque,
L
Laine Stump 已提交
3088
                                        unsigned int flags);
3089 3090
virDomainDefPtr virDomainDefParseFile(const char *filename,
                                      virCapsPtr caps,
3091
                                      virDomainXMLOptionPtr xmlopt,
3092
                                      void *parseOpaque,
L
Laine Stump 已提交
3093
                                      unsigned int flags);
3094
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
3095
                                      xmlNodePtr root,
3096 3097
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
3098
                                      void *parseOpaque,
L
Laine Stump 已提交
3099
                                      unsigned int flags);
3100 3101 3102 3103 3104
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3105 3106 3107 3108
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3109

3110
bool virDomainDefCheckABIStability(virDomainDefPtr src,
3111 3112
                                   virDomainDefPtr dst,
                                   virDomainXMLOptionPtr xmlopt);
3113

3114 3115
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
                                        virDomainDefPtr dst,
3116
                                        virDomainXMLOptionPtr xmlopt,
3117 3118
                                        unsigned int flags);

3119
int virDomainDefAddImplicitDevices(virDomainDefPtr def);
3120

3121
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
3122 3123 3124 3125 3126
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);

3127 3128 3129 3130 3131 3132 3133 3134 3135
/* 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)
3136 3137
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

3138
char *virDomainDefFormat(virDomainDefPtr def,
3139
                         virCapsPtr caps,
L
Laine Stump 已提交
3140
                         unsigned int flags);
3141 3142
char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
                         virDomainObjPtr obj,
3143
                         virCapsPtr caps,
3144
                         unsigned int flags);
3145
int virDomainDefFormatInternal(virDomainDefPtr def,
3146
                               virCapsPtr caps,
3147
                               unsigned int flags,
3148 3149
                               virBufferPtr buf,
                               virDomainXMLOptionPtr xmlopt);
3150

3151 3152 3153
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
                              int policy,
3154 3155
                              unsigned int flags,
                              virDomainXMLOptionPtr xmlopt);
3156

3157 3158
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
3159
                          char *prefix,
3160 3161
                          unsigned int flags);

3162 3163 3164 3165 3166 3167
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

3168
int virDomainDefCompatibleDevice(virDomainDefPtr def,
3169
                                 virDomainDeviceDefPtr dev,
3170
                                 virDomainDeviceDefPtr oldDev,
3171 3172
                                 virDomainDeviceAction action,
                                 bool live);
3173

3174 3175
void virDomainRNGDefFree(virDomainRNGDefPtr def);

3176
int virDomainDiskIndexByAddress(virDomainDefPtr def,
3177
                                virPCIDeviceAddressPtr pci_controller,
3178 3179
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
3180
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
3181
                                           virPCIDeviceAddressPtr pci_controller,
3182 3183 3184
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
3185 3186
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
3187 3188 3189
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
3190
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
3191
int virDomainDiskInsert(virDomainDefPtr def,
3192 3193
                        virDomainDiskDefPtr disk)
    ATTRIBUTE_RETURN_CHECK;
3194 3195
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
3196
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
3197 3198
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
3199

3200 3201 3202 3203
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
3204
int virDomainDiskSourceParse(xmlNodePtr node,
3205
                             xmlXPathContextPtr ctxt,
3206
                             virStorageSourcePtr src,
3207 3208
                             unsigned int flags,
                             virDomainXMLOptionPtr xmlopt);
3209

3210 3211
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
3212
virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname);
3213
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
3214
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
3215
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
3216
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
3217

L
Laine Stump 已提交
3218
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
3219 3220
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
3221 3222 3223
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

3224 3225
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
3226 3227
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
3228
            ATTRIBUTE_NONNULL(1);
3229 3230 3231
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
3232

3233
virDomainNetType virDomainNetGetActualType(const virDomainNetDef *iface);
3234
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
3235
int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
3236
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
3237
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
3238
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
3239
virNetDevVPortProfilePtr
3240
virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface);
3241
virNetDevBandwidthPtr
3242
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
3243
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
3244
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
3245
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
3246
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
3247 3248 3249
                                const char *address,
                                int family,
                                unsigned int prefix);
3250

3251
int virDomainControllerInsert(virDomainDefPtr def,
3252 3253
                              virDomainControllerDefPtr controller)
    ATTRIBUTE_RETURN_CHECK;
3254 3255
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
3256
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
3257
int virDomainControllerFindByType(virDomainDefPtr def, int type);
3258
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
3259
                                        virPCIDeviceAddressPtr addr);
3260
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
3261
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
3262
const char *virDomainControllerAliasFind(const virDomainDef *def,
3263 3264
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
3265 3266 3267 3268 3269

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
3270 3271
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
    ATTRIBUTE_RETURN_CHECK;
3272 3273
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
3274 3275 3276 3277 3278
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
3279

3280
void
3281
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
3282
                          virDomainChrDeviceType type,
3283 3284 3285
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3286 3287 3288
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
3289 3290 3291
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
3292
int
3293 3294 3295 3296 3297
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
3298 3299 3300 3301
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

3302 3303 3304
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

3305 3306 3307 3308
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

3309
int virDomainSaveXML(const char *configDir,
3310 3311 3312
                     virDomainDefPtr def,
                     const char *xml);

3313
int virDomainSaveConfig(const char *configDir,
3314
                        virCapsPtr caps,
3315
                        virDomainDefPtr def);
3316
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
3317
                        const char *statusDir,
3318 3319
                        virDomainObjPtr obj,
                        virCapsPtr caps) ATTRIBUTE_RETURN_CHECK;
3320

3321 3322 3323 3324
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

3325
int virDomainDeleteConfig(const char *configDir,
3326
                          const char *autostartDir,
3327 3328
                          virDomainObjPtr dom);

3329
char *virDomainConfigFile(const char *dir,
3330 3331
                          const char *name);

3332 3333 3334 3335
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

3336
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
3337
                                                  const char *target);
3338
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
3339
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
3340 3341
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

3342
int virDomainVideoDefaultType(const virDomainDef *def);
3343 3344
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
3345

E
Eric Blake 已提交
3346 3347 3348 3349 3350 3351 3352 3353 3354
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3355 3356 3357 3358 3359 3360 3361 3362 3363
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3364 3365 3366 3367 3368
typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
                                            const char *path,
                                            size_t depth,
                                            void *opaque);

3369 3370 3371 3372 3373 3374 3375
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

3376 3377 3378 3379 3380
int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
                                bool ignoreOpenFailure,
                                virDomainDiskDefPathIterator iter,
                                void *opaque);

J
Jiri Denemark 已提交
3381 3382 3383 3384 3385 3386 3387
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3388 3389 3390
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3391
virSecurityDeviceLabelDefPtr
3392 3393
virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDefPtr def,
                                         const char *model);
3394

3395 3396
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3397

3398 3399 3400 3401 3402 3403 3404 3405 3406 3407
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;

3408 3409 3410 3411 3412 3413 3414 3415
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);
3416 3417 3418
ssize_t virDomainInputDefFind(const virDomainDef *def,
                              const virDomainInputDef *input)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
3419 3420 3421
bool virDomainVsockDefEquals(const virDomainVsockDef *a,
                             const virDomainVsockDef *b)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
3422

3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493
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);
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);
VIR_ENUM_DECL(virDomainFS);
VIR_ENUM_DECL(virDomainFSDriver);
VIR_ENUM_DECL(virDomainFSAccessMode);
VIR_ENUM_DECL(virDomainFSWrpolicy);
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);
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);
3494
VIR_ENUM_DECL(virDomainMsrsUnknown);
3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507
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);
3508
/* from libvirt.h */
3509 3510 3511 3512 3513 3514 3515 3516 3517
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 已提交
3518 3519 3520 3521

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

3522 3523 3524
VIR_ENUM_DECL(virDomainSeclabel);
VIR_ENUM_DECL(virDomainClockOffset);
VIR_ENUM_DECL(virDomainClockBasis);
3525

3526 3527 3528 3529 3530
VIR_ENUM_DECL(virDomainTimerName);
VIR_ENUM_DECL(virDomainTimerTrack);
VIR_ENUM_DECL(virDomainTimerTickpolicy);
VIR_ENUM_DECL(virDomainTimerMode);
VIR_ENUM_DECL(virDomainCpuPlacementMode);
3531

3532
VIR_ENUM_DECL(virDomainStartupPolicy);
3533

3534 3535
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3536 3537
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3538 3539 3540 3541 3542
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3543 3544 3545 3546
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3547

3548 3549
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3550 3551
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3552 3553
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3554

3555 3556
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);

3557 3558
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3559 3560 3561 3562 3563
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3564 3565 3566 3567 3568 3569 3570
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
3571
                            const char *stateDir,
3572 3573 3574
                            const char *configDir,
                            unsigned int flags);

3575 3576 3577 3578 3579 3580 3581 3582
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3583 3584 3585
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3586 3587
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3588
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3589

3590 3591 3592 3593 3594 3595 3596
int virDomainStorageSourceFormat(virBufferPtr attrBuf,
                                 virBufferPtr childBuf,
                                 virStorageSourcePtr src,
                                 unsigned int flags,
                                 bool skipSeclabels)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3597 3598 3599 3600 3601 3602
int virDomainStorageSourceParse(xmlNodePtr node,
                                xmlXPathContextPtr ctxt,
                                virStorageSourcePtr src,
                                unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3603 3604 3605 3606 3607 3608 3609 3610
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;

3611 3612
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

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

3615 3616 3617 3618 3619
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3620

3621 3622 3623
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3624 3625 3626 3627 3628
char *
virDomainGenerateMachineName(const char *drivername,
                             int id,
                             const char *name,
                             bool privileged);
3629 3630 3631

bool
virDomainNetTypeSharesHostView(const virDomainNetDef *net);
3632

3633 3634 3635 3636
bool
virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
                                   virDomainLifecycleAction action);

3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648
typedef int
(*virDomainNetAllocateActualDeviceImpl)(virDomainDefPtr dom,
                                        virDomainNetDefPtr iface);

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

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

3649 3650 3651 3652 3653 3654 3655 3656 3657
typedef bool
(*virDomainNetBandwidthChangeAllowedImpl)(virDomainNetDefPtr iface,
                                          virNetDevBandwidthPtr newBandwidth);

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


3658 3659 3660
void
virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate,
                          virDomainNetNotifyActualDeviceImpl notify,
3661 3662
                          virDomainNetReleaseActualDeviceImpl release,
                          virDomainNetBandwidthChangeAllowedImpl bandwidthChangeAllowed,
3663
                          virDomainNetBandwidthUpdateImpl bandwidthUpdate);
3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679

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

3680 3681 3682 3683 3684 3685 3686 3687 3688
bool
virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface,
                              virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

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

3690 3691 3692 3693
int
virDomainNetResolveActualType(virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1);

3694

3695
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
3696

3697 3698 3699
int
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                 virDomainDiskDetectZeroes detect_zeroes);
3700

3701 3702 3703
bool
virDomainDefHasManagedPR(const virDomainDef *def);

3704 3705 3706
bool
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);

3707 3708 3709 3710 3711 3712 3713 3714 3715
bool
virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics);

const char *
virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);

bool
virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);

3716
#endif /* LIBVIRT_DOMAIN_CONF_H */