domain_conf.h 117.9 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 25
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __DOMAIN_CONF_H
26
# define __DOMAIN_CONF_H
27

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

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

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

82 83 84
typedef struct _virDomainSoundCodecDef virDomainSoundCodecDef;
typedef virDomainSoundCodecDef *virDomainSoundCodecDefPtr;

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

106 107
typedef struct _virDomainRedirFilterUSBDevDef virDomainRedirFilterUSBDevDef;
typedef virDomainRedirFilterUSBDevDef *virDomainRedirFilterUSBDevDefPtr;
108 109 110 111

typedef struct _virDomainRedirFilterDef virDomainRedirFilterDef;
typedef virDomainRedirFilterDef *virDomainRedirFilterDefPtr;

112 113 114 115 116 117 118 119 120
typedef struct _virDomainSmartcardDef virDomainSmartcardDef;
typedef virDomainSmartcardDef *virDomainSmartcardDefPtr;

typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr;

typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;

L
Li Zhang 已提交
121 122 123
typedef struct _virDomainNVRAMDef virDomainNVRAMDef;
typedef virDomainNVRAMDef *virDomainNVRAMDefPtr;

124 125 126 127 128 129
typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;

typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
typedef virDomainSnapshotObjList *virDomainSnapshotObjListPtr;

130 131 132
typedef struct _virDomainRNGDef virDomainRNGDef;
typedef virDomainRNGDef *virDomainRNGDefPtr;

133 134 135 136 137 138
typedef struct _virDomainIdMapEntry virDomainIdMapEntry;
typedef virDomainIdMapEntry *virDomainIdMapEntryPtr;

typedef struct _virDomainIdMapDef virDomainIdMapDef;
typedef virDomainIdMapDef *virDomainIdMapDefPtr;

H
Hu Tao 已提交
139 140 141
typedef struct _virDomainPanicDef virDomainPanicDef;
typedef virDomainPanicDef *virDomainPanicDefPtr;

142 143 144
typedef struct _virDomainMemoryDef virDomainMemoryDef;
typedef virDomainMemoryDef *virDomainMemoryDefPtr;

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

151 152 153
typedef struct _virDomainShmemDef virDomainShmemDef;
typedef virDomainShmemDef *virDomainShmemDefPtr;

154 155 156
typedef struct _virDomainTPMDef virDomainTPMDef;
typedef virDomainTPMDef *virDomainTPMDefPtr;

J
Ján Tomko 已提交
157 158 159
typedef struct _virDomainIOMMUDef virDomainIOMMUDef;
typedef virDomainIOMMUDef *virDomainIOMMUDefPtr;

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

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

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

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

244
    VIR_DOMAIN_VIRT_LAST
245
} virDomainVirtType;
246

247 248 249 250 251 252 253 254 255 256 257 258
typedef enum {
    VIR_DOMAIN_OSTYPE_HVM,
    VIR_DOMAIN_OSTYPE_XEN,
    VIR_DOMAIN_OSTYPE_LINUX,
    VIR_DOMAIN_OSTYPE_EXE,
    VIR_DOMAIN_OSTYPE_UML,

    VIR_DOMAIN_OSTYPE_LAST
} virDomainOSType;
VIR_ENUM_DECL(virDomainOS)


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

            /* Does it need to use remove_slot when reattaching
             * the device to host?
             */
272
            bool remove_slot;
273 274 275 276

            /* Does it need to reprobe driver for the device when
             * reattaching to host?
             */
277
            bool reprobe;
278 279 280 281 282 283
        } pci;

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

284 285 286 287 288 289 290
struct _virDomainLeaseDef {
    char *lockspace;
    char *key;
    char *path;
    unsigned long long offset;
};

291

292
typedef enum {
293 294 295
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

296
    VIR_DOMAIN_HOSTDEV_MODE_LAST
297
} virDomainHostdevMode;
298

299
typedef enum {
300 301
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
H
Han Cheng 已提交
302
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
303
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST,
304
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV,
305 306

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
307
} virDomainHostdevSubsysType;
308

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

    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
317
} virDomainHostdevSubsysPCIBackendType;
318

319
VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend)
320

321 322 323 324 325 326 327 328 329
typedef enum {
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE,
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI,

    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
} virDomainHostdevSCSIProtocolType;

VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol)

330 331 332 333 334 335 336 337 338 339 340 341
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;
};

342 343 344
typedef struct _virDomainHostdevSubsysPCI virDomainHostdevSubsysPCI;
typedef virDomainHostdevSubsysPCI *virDomainHostdevSubsysPCIPtr;
struct _virDomainHostdevSubsysPCI {
345
    virPCIDeviceAddress addr; /* host address */
346 347 348
    int backend; /* enum virDomainHostdevSubsysPCIBackendType */
};

349 350 351
typedef struct _virDomainHostdevSubsysSCSIHost virDomainHostdevSubsysSCSIHost;
typedef virDomainHostdevSubsysSCSIHost *virDomainHostdevSubsysSCSIHostPtr;
struct _virDomainHostdevSubsysSCSIHost {
352 353 354
    char *adapter;
    unsigned bus;
    unsigned target;
355
    unsigned long long unit;
356 357
};

358 359 360
typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI;
typedef virDomainHostdevSubsysSCSIiSCSI *virDomainHostdevSubsysSCSIiSCSIPtr;
struct _virDomainHostdevSubsysSCSIiSCSI {
361
    virStorageSourcePtr src;
362 363
};

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

376 377 378 379 380 381 382
typedef struct _virDomainHostdevSubsysMediatedDev virDomainHostdevSubsysMediatedDev;
typedef virDomainHostdevSubsysMediatedDev *virDomainHostdevSubsysMediatedDevPtr;
struct _virDomainHostdevSubsysMediatedDev {
    int model;                          /* enum virMediatedDeviceModelType */
    char uuidstr[VIR_UUID_STRING_BUFLEN];   /* mediated device's uuid string */
};

383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
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;

VIR_ENUM_DECL(virDomainHostdevSubsysSCSIHostProtocol)

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

399 400 401
typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys {
402
    int type; /* enum virDomainHostdevSubsysType */
403
    union {
404
        virDomainHostdevSubsysUSB usb;
405
        virDomainHostdevSubsysPCI pci;
406
        virDomainHostdevSubsysSCSI scsi;
407
        virDomainHostdevSubsysSCSIVHost scsi_host;
408
        virDomainHostdevSubsysMediatedDev mdev;
409 410 411
    } u;
};

412

413
typedef enum {
414 415
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
416
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
417 418

    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
419
} virDomainHostdevCapsType;
420 421 422 423 424 425 426 427 428 429 430 431

typedef struct _virDomainHostdevCaps virDomainHostdevCaps;
typedef virDomainHostdevCaps *virDomainHostdevCapsPtr;
struct _virDomainHostdevCaps {
    int type; /* enum virDOmainHostdevCapsType */
    union {
        struct {
            char *block;
        } storage;
        struct {
            char *chardev;
        } misc;
432
        struct {
433 434
            char *ifname;
            virNetDevIPInfo ip;
435
        } net;
436 437 438 439
    } u;
};


440 441
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
442
    virDomainDeviceDef parent; /* higher level Def containing this */
443

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

458

E
Eric Blake 已提交
459 460
/* Types of disk frontend (guest view).  For backends (host view), see
 * virStorageType in util/virstoragefile.h */
461
typedef enum {
462 463 464
    VIR_DOMAIN_DISK_DEVICE_DISK,
    VIR_DOMAIN_DISK_DEVICE_CDROM,
    VIR_DOMAIN_DISK_DEVICE_FLOPPY,
465
    VIR_DOMAIN_DISK_DEVICE_LUN,
466 467

    VIR_DOMAIN_DISK_DEVICE_LAST
468
} virDomainDiskDevice;
469

470
typedef enum {
471 472 473 474 475
    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,
476
    VIR_DOMAIN_DISK_BUS_USB,
477
    VIR_DOMAIN_DISK_BUS_UML,
478
    VIR_DOMAIN_DISK_BUS_SATA,
479
    VIR_DOMAIN_DISK_BUS_SD,
480 481

    VIR_DOMAIN_DISK_BUS_LAST
482
} virDomainDiskBus;
483

484
typedef enum {
485 486 487 488
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
489
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
490
    VIR_DOMAIN_DISK_CACHE_UNSAFE,
491 492

    VIR_DOMAIN_DISK_CACHE_LAST
493
} virDomainDiskCache;
494

495
typedef enum {
496 497
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
498
    VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
499
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
500
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
501 502

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
503
} virDomainDiskErrorPolicy;
504

M
MORITA Kazutaka 已提交
505

506
typedef enum {
507
    VIR_DOMAIN_DISK_TRAY_CLOSED = 0,
508 509 510
    VIR_DOMAIN_DISK_TRAY_OPEN,

    VIR_DOMAIN_DISK_TRAY_LAST
511
} virDomainDiskTray;
512

513
typedef enum {
J
J.B. Joret 已提交
514 515 516 517 518 519
    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
520
} virDomainDiskGeometryTrans;
J
J.B. Joret 已提交
521

522
typedef enum {
523
    VIR_DOMAIN_DISK_IO_DEFAULT = 0,
M
Matthias Dahl 已提交
524 525 526 527
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
528
} virDomainDiskIo;
M
Matthias Dahl 已提交
529

530
typedef enum {
531 532 533 534 535 536
    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
537
} virDomainStartupPolicy;
538

539

540
typedef enum {
541 542 543
    VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
    VIR_DOMAIN_DEVICE_SGIO_FILTERED,
    VIR_DOMAIN_DEVICE_SGIO_UNFILTERED,
O
Osier Yang 已提交
544

545
    VIR_DOMAIN_DEVICE_SGIO_LAST
546
} virDomainDeviceSGIO;
O
Osier Yang 已提交
547

548
typedef enum {
O
Osier Yang 已提交
549
    VIR_DOMAIN_DISK_DISCARD_DEFAULT = 0,
O
Osier Yang 已提交
550 551
    VIR_DOMAIN_DISK_DISCARD_UNMAP,
    VIR_DOMAIN_DISK_DISCARD_IGNORE,
O
Osier Yang 已提交
552 553

    VIR_DOMAIN_DISK_DISCARD_LAST
554
} virDomainDiskDiscard;
O
Osier Yang 已提交
555

556 557 558 559 560 561 562 563 564
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 已提交
565 566 567 568 569 570 571 572
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;
573 574 575 576 577 578 579
    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;
580
    char *group_name;
581 582 583 584 585 586
    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 已提交
587 588 589
};
typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;

590

591 592 593 594 595 596 597 598 599
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;

600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
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 */

    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;

616

617 618
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
619
    virStorageSourcePtr src; /* non-NULL.  XXX Allow NULL for empty cdrom? */
620

621 622
    virObjectPtr privateData;

623 624 625 626
    int device; /* enum virDomainDiskDevice */
    int bus; /* enum virDomainDiskBus */
    char *dst;
    int tray_status; /* enum virDomainDiskTray */
J
Ján Tomko 已提交
627
    int removable; /* enum virTristateSwitch */
L
Lei Li 已提交
628

629
    virStorageSourcePtr mirror;
630
    int mirrorState; /* enum virDomainDiskMirrorState */
E
Eric Blake 已提交
631
    int mirrorJob; /* virDomainBlockJobType */
632

J
J.B. Joret 已提交
633 634 635 636
    struct {
        unsigned int cylinders;
        unsigned int heads;
        unsigned int sectors;
637
        int trans; /* enum virDomainDiskGeometryTrans */
J
J.B. Joret 已提交
638 639
    } geometry;

640 641 642
    struct {
        unsigned int logical_block_size;
        unsigned int physical_block_size;
V
Viktor Mihajlovski 已提交
643
    } blockio;
644

L
Lei Li 已提交
645 646
    virDomainBlockIoTuneInfo blkdeviotune;

647 648
    char *driverName;

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


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

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
686
} virDomainControllerType;
687

688

689
typedef enum {
690
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT = -1,
J
Ján Tomko 已提交
691
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
L
Laine Stump 已提交
692
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
J
Ján Tomko 已提交
693
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
694
    VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
695
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE,
696
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT,
697
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT,
698
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT,
699
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS,
700
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS,
J
Ján Tomko 已提交
701 702

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
703
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
704

705
typedef enum {
706
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE = 0,
707 708
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE,
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE,
709
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420,
710
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM,
711
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM,
712
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB,
713
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE,
714
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT,
715
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE,
716
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_PCI_BRIDGE,
717 718 719 720

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

721
typedef enum {
722
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT = -1,
723 724 725 726 727
    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,
728
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
729
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
730
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
731

732
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
733
} virDomainControllerModelSCSI;
734

735
typedef enum {
736
    VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT = -1,
M
Marc-André Lureau 已提交
737 738 739 740 741 742 743 744 745
    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 已提交
746
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
747 748
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2,
749
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI,
750
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
M
Marc-André Lureau 已提交
751 752

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
753
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
754

755
typedef enum {
756
    VIR_DOMAIN_CONTROLLER_MODEL_IDE_DEFAULT = -1,
757 758 759 760 761 762 763
    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;

764 765 766 767 768 769 770
# 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))

771 772 773 774 775 776 777
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

778 779 780
typedef struct _virDomainPCIControllerOpts virDomainPCIControllerOpts;
typedef virDomainPCIControllerOpts *virDomainPCIControllerOptsPtr;
struct _virDomainPCIControllerOpts {
781 782
    bool pcihole64;
    unsigned long pcihole64size;
783 784 785 786 787 788 789

    /* 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 */
790 791 792 793 794 795 796 797

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

810 811 812 813 814 815
typedef struct _virDomainUSBControllerOpts virDomainUSBControllerOpts;
typedef virDomainUSBControllerOpts *virDomainUSBControllerOptsPtr;
struct _virDomainUSBControllerOpts {
    int ports;   /* -1 == undef */
};

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


G
Giuseppe Scrivano 已提交
836
/* Types of disk backends */
837
typedef enum {
838 839 840 841 842 843
    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 */
844
    VIR_DOMAIN_FS_TYPE_VOLUME, /* Mounts storage pool volume to a guest */
845 846

    VIR_DOMAIN_FS_TYPE_LAST
847
} virDomainFSType;
848

849
/* Filesystem driver type */
850
typedef enum {
851 852 853
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
854
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
855
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
D
Dmitry Guryanov 已提交
856
    VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
857 858

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
859
} virDomainFSDriverType;
860

861
/* Filesystem mount access mode  */
862
typedef enum {
863 864 865 866 867
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
868
} virDomainFSAccessMode;
869

870
/* Filesystem Write policy */
871
typedef enum {
872 873 874 875
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
876
} virDomainFSWrpolicy;
877

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


896
/* network config types */
897
typedef enum {
898 899
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
M
Michele Paolino 已提交
900
    VIR_DOMAIN_NET_TYPE_VHOSTUSER,
901 902 903 904 905
    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 已提交
906
    VIR_DOMAIN_NET_TYPE_INTERNAL,
907
    VIR_DOMAIN_NET_TYPE_DIRECT,
908
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
909
    VIR_DOMAIN_NET_TYPE_UDP,
910

911
    VIR_DOMAIN_NET_TYPE_LAST
912
} virDomainNetType;
913

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

920
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
921
} virDomainNetBackendType;
922

923
/* the TX algorithm used for virtio interfaces */
924
typedef enum {
925 926 927 928
    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,

929
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
930
} virDomainNetVirtioTxModeType;
931

932
/* link interface states */
933
typedef enum {
934 935 936 937 938
        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
939
} virDomainNetInterfaceLinkState;
940

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

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

1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
typedef enum {
    VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT = 0,
    VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED,
    VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED,

    VIR_DOMAIN_CHR_DEVICE_STATE_LAST
} virDomainChrDeviceState;

VIR_ENUM_DECL(virDomainChrDeviceState)

1077
typedef enum {
1078
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1079 1080
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1081
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1082

1083
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1084
} virDomainChrDeviceType;
1085

1086
typedef enum {
1087 1088
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
G
Guannan Ren 已提交
1089
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
M
Michal Privoznik 已提交
1090
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
1091
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
1092
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
1093
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP,
G
Guannan Ren 已提交
1094 1095

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1096
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1097

1098
typedef enum {
1099 1100
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
1101
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
J
Joao Martins 已提交
1102
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN,
1103

1104
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1105
} virDomainChrChannelTargetType;
1106

1107
typedef enum {
1108 1109
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
1110 1111
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
1112
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
1113 1114
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
1115 1116
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
1117

1118
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1119
} virDomainChrConsoleTargetType;
1120

1121 1122 1123 1124 1125
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,
1126
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
1127
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011,
1128 1129
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE,
1130 1131 1132 1133 1134 1135

    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
} virDomainChrSerialTargetModel;

VIR_ENUM_DECL(virDomainChrSerialTargetModel);

1136
typedef enum {
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
    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,
1147
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1148
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1149
    VIR_DOMAIN_CHR_TYPE_NMDM,
1150

1151
    VIR_DOMAIN_CHR_TYPE_LAST
1152
} virDomainChrType;
1153

1154
typedef enum {
1155
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW = 0,
1156
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1157 1158
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1159

1160
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1161
} virDomainChrTcpProtocol;
1162

1163
typedef enum {
E
Eric Blake 已提交
1164 1165
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1166
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1167

1168
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1169
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1170

1171 1172 1173 1174 1175 1176 1177 1178 1179

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


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

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1226 1227 1228 1229
};

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

1232 1233 1234
    int targetType; /* enum virDomainChrConsoleTargetType ||
                       enum virDomainChrChannelTargetType ||
                       enum virDomainChrSerialTargetType according to deviceType */
1235
    int targetModel; /* enum virDomainChrSerialTargetModel */
1236

1237 1238 1239 1240 1241 1242
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

1243 1244
    virDomainChrDeviceState state;

1245
    virDomainChrSourceDefPtr source;
1246 1247

    virDomainDeviceInfo info;
1248 1249
};

1250
typedef enum {
E
Eric Blake 已提交
1251 1252 1253 1254
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

1255
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1256
} virDomainSmartcardType;
E
Eric Blake 已提交
1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268

# 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' */
1269
        virDomainChrSourceDefPtr passthru; /* 'passthrough' */
E
Eric Blake 已提交
1270 1271 1272 1273 1274
    } data;

    virDomainDeviceInfo info;
};

M
Marc-André Lureau 已提交
1275 1276 1277 1278 1279
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

1280
typedef enum {
1281
    VIR_DOMAIN_TPM_MODEL_TIS,
1282
    VIR_DOMAIN_TPM_MODEL_CRB,
1283 1284

    VIR_DOMAIN_TPM_MODEL_LAST
1285
} virDomainTPMModel;
1286

1287
typedef enum {
1288 1289 1290
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,

    VIR_DOMAIN_TPM_TYPE_LAST
1291
} virDomainTPMBackendType;
1292 1293 1294 1295

# define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"

struct _virDomainTPMDef {
1296
    virDomainTPMBackendType type;
1297
    virDomainDeviceInfo info;
1298
    virDomainTPMModel model;
1299 1300 1301 1302 1303 1304 1305
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
    } data;
};

1306
typedef enum {
1307 1308
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1309
    VIR_DOMAIN_INPUT_TYPE_KBD,
1310
    VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
1311

1312
    VIR_DOMAIN_INPUT_TYPE_LAST
1313
} virDomainInputType;
1314

1315
typedef enum {
1316 1317 1318
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1319
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1320
    VIR_DOMAIN_INPUT_BUS_VIRTIO,
1321 1322

    VIR_DOMAIN_INPUT_BUS_LAST
1323
} virDomainInputBus;
1324 1325 1326 1327

struct _virDomainInputDef {
    int type;
    int bus;
1328 1329 1330
    struct {
        char *evdev;
    } source;
1331
    virDomainDeviceInfo info;
1332
    virDomainVirtioOptionsPtr virtio;
1333 1334
};

1335
typedef enum {
1336 1337 1338 1339
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1340
} virDomainSoundCodecType;
1341

1342
typedef enum {
1343 1344 1345
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1346
    VIR_DOMAIN_SOUND_MODEL_AC97,
1347
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1348
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1349
    VIR_DOMAIN_SOUND_MODEL_USB,
1350 1351

    VIR_DOMAIN_SOUND_MODEL_LAST
1352
} virDomainSoundModel;
1353

1354 1355 1356 1357 1358
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1359 1360
struct _virDomainSoundDef {
    int model;
1361
    virDomainDeviceInfo info;
1362

1363
    size_t ncodecs;
1364
    virDomainSoundCodecDefPtr *codecs;
1365 1366
};

1367
typedef enum {
R
Richard Jones 已提交
1368 1369
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,
1370
    VIR_DOMAIN_WATCHDOG_MODEL_DIAG288,
R
Richard Jones 已提交
1371 1372

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1373
} virDomainWatchdogModel;
R
Richard Jones 已提交
1374

1375
typedef enum {
R
Richard Jones 已提交
1376 1377 1378 1379
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1380
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1381
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,
1382
    VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI,
R
Richard Jones 已提交
1383 1384

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1385
} virDomainWatchdogAction;
R
Richard Jones 已提交
1386 1387 1388 1389

struct _virDomainWatchdogDef {
    int model;
    int action;
1390
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1391 1392
};

1393

1394
typedef enum {
1395
    VIR_DOMAIN_VIDEO_TYPE_DEFAULT,
1396 1397 1398 1399 1400
    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,
1401
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1402
    VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
M
Marc-André Lureau 已提交
1403
    VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
F
Fabian Freyer 已提交
1404
    VIR_DOMAIN_VIDEO_TYPE_GOP,
1405 1406

    VIR_DOMAIN_VIDEO_TYPE_LAST
1407
} virDomainVideoType;
1408 1409


1410 1411 1412 1413 1414 1415 1416 1417 1418 1419
typedef enum {
    VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
    VIR_DOMAIN_VIDEO_VGACONF_ON,
    VIR_DOMAIN_VIDEO_VGACONF_OFF,

    VIR_DOMAIN_VIDEO_VGACONF_LAST
} virDomainVideoVGAConf;

VIR_ENUM_DECL(virDomainVideoVGAConf)

1420 1421 1422
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
1423 1424
    int accel2d; /* enum virTristateBool */
    int accel3d; /* enum virTristateBool */
1425 1426 1427
};


1428 1429 1430 1431 1432 1433
typedef struct _virDomainVideoDriverDef virDomainVideoDriverDef;
typedef virDomainVideoDriverDef *virDomainVideoDriverDefPtr;
struct _virDomainVideoDriverDef {
   virDomainVideoVGAConf vgaconf;
};

1434 1435
struct _virDomainVideoDef {
    int type;
1436 1437
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1438
    unsigned int vram64; /* kibibytes (multiples of 1024) */
1439
    unsigned int vgamem; /* kibibytes (multiples of 1024) */
1440
    unsigned int heads;
1441
    bool primary;
1442
    virDomainVideoAccelDefPtr accel;
1443
    virDomainVideoDriverDefPtr driver;
1444
    virDomainDeviceInfo info;
J
Ján Tomko 已提交
1445
    virDomainVirtioOptionsPtr virtio;
1446 1447
};

1448
/* graphics console modes */
1449
typedef enum {
1450 1451
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1452 1453
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1454
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1455

1456
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1457
} virDomainGraphicsType;
1458

1459
typedef enum {
1460 1461 1462 1463 1464 1465
    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
1466
} virDomainGraphicsVNCSharePolicy;
1467

1468
typedef enum {
1469 1470 1471 1472 1473 1474
    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
1475
} virDomainGraphicsAuthConnectedType;
1476

1477 1478 1479 1480
typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef;
typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr;
struct _virDomainGraphicsAuthDef {
    char *passwd;
1481
    bool expires; /* Whether there is an expiry time set */
1482
    time_t validTo;  /* seconds since epoch */
1483
    int connected; /* action if connected */
1484 1485
};

1486
typedef enum {
1487 1488 1489 1490 1491 1492
    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 已提交
1493
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1494
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1495 1496

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1497
} virDomainGraphicsSpiceChannelName;
1498

1499
typedef enum {
1500 1501 1502 1503 1504
    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
1505
} virDomainGraphicsSpiceChannelMode;
1506

1507
typedef enum {
1508 1509 1510 1511 1512 1513 1514 1515 1516
    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
1517
} virDomainGraphicsSpiceImageCompression;
1518

1519
typedef enum {
1520 1521 1522 1523 1524 1525
    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
1526
} virDomainGraphicsSpiceJpegCompression;
1527

1528
typedef enum {
1529 1530 1531 1532 1533 1534
    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
1535
} virDomainGraphicsSpiceZlibCompression;
1536

1537
typedef enum {
P
Peng Zhou 已提交
1538 1539 1540 1541 1542
    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
1543
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1544

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

1554
typedef enum {
1555 1556 1557
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1558
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1559

1560
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1561
} virDomainGraphicsListenType;
1562

1563
typedef enum {
M
Marc-André Lureau 已提交
1564 1565
    VIR_DOMAIN_HUB_TYPE_USB,

1566
    VIR_DOMAIN_HUB_TYPE_LAST
1567
} virDomainHubType;
M
Marc-André Lureau 已提交
1568

1569 1570 1571
typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef;
typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr;
struct _virDomainGraphicsListenDef {
1572
    virDomainGraphicsListenType type;
1573 1574
    char *address;
    char *network;
1575
    char *socket;
1576
    bool fromConfig;    /* true if the @address is config file originated */
1577
    bool autoGenerated;
1578 1579
};

1580
struct _virDomainGraphicsDef {
M
Michal Privoznik 已提交
1581 1582 1583 1584 1585
    /* 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.
     */
1586
    virDomainGraphicsType type;
1587 1588 1589
    union {
        struct {
            int port;
1590
            bool portReserved;
M
Martin Kletzander 已提交
1591
            int websocket;
1592
            bool websocketGenerated;
1593
            bool autoport;
1594
            char *keymap;
1595
            virDomainGraphicsAuthDef auth;
1596
            int sharePolicy;
1597 1598 1599 1600
        } vnc;
        struct {
            char *display;
            char *xauth;
1601
            bool fullscreen;
1602
            virTristateBool gl;
1603
        } sdl;
1604 1605
        struct {
            int port;
1606 1607 1608
            bool autoport;
            bool replaceUser;
            bool multiUser;
1609 1610 1611
        } rdp;
        struct {
            char *display;
1612
            bool fullscreen;
1613
        } desktop;
1614 1615 1616
        struct {
            int port;
            int tlsPort;
1617 1618
            bool portReserved;
            bool tlsPortReserved;
1619
            virDomainGraphicsSpiceMouseMode mousemode;
1620
            char *keymap;
1621
            virDomainGraphicsAuthDef auth;
1622
            bool autoport;
1623
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1624
            virDomainGraphicsSpiceChannelMode defaultMode;
1625 1626 1627 1628
            int image;
            int jpeg;
            int zlib;
            int playback;
1629
            int streaming;
1630 1631 1632
            virTristateBool copypaste;
            virTristateBool filetransfer;
            virTristateBool gl;
1633
            char *rendernode;
1634
        } spice;
1635
    } data;
1636 1637 1638 1639 1640
    /* 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;
1641 1642
};

1643
typedef enum {
1644 1645 1646
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1647
} virDomainRedirdevBus;
1648 1649 1650 1651

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

1652
    virDomainChrSourceDefPtr source;
1653 1654 1655

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

1657
struct _virDomainRedirFilterUSBDevDef {
1658 1659 1660 1661
    int usbClass;
    int vendor;
    int product;
    int version;
1662
    bool allow;
1663 1664 1665 1666
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1667
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1668 1669
};

1670
typedef enum {
1671 1672
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1673
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1674 1675

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1676
} virDomainMemballoonModel;
1677 1678 1679 1680

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1681
    int period; /* seconds between collections */
1682
    int autodeflate; /* enum virTristateSwitch */
1683
    virDomainVirtioOptionsPtr virtio;
1684 1685
};

L
Li Zhang 已提交
1686 1687 1688
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1689

1690 1691
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1692 1693
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1694 1695 1696 1697

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

1698 1699 1700
struct _virDomainShmemDef {
    char *name;
    unsigned long long size;
1701
    int model; /* enum virDomainShmemModel */
1702 1703
    struct {
        bool enabled;
1704
        virDomainChrSourceDef chr;
1705 1706 1707 1708 1709 1710 1711 1712 1713
    } server;
    struct {
        bool enabled;
        unsigned vectors;
        virTristateSwitch ioeventfd;
    } msi;
    virDomainDeviceInfo info;
};

1714
typedef enum {
1715
    VIR_DOMAIN_SMBIOS_NONE = 0,
1716 1717 1718 1719 1720
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1721
} virDomainSmbiosMode;
1722

1723

1724
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1725

1726
typedef enum {
1727 1728 1729 1730 1731
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1732
    VIR_DOMAIN_BOOT_LAST
1733
} virDomainBootOrder;
1734

1735
typedef enum {
1736 1737 1738
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1739
    VIR_DOMAIN_FEATURE_HAP,
1740
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1741
    VIR_DOMAIN_FEATURE_PRIVNET,
1742
    VIR_DOMAIN_FEATURE_HYPERV,
1743
    VIR_DOMAIN_FEATURE_KVM,
1744
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1745
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1746
    VIR_DOMAIN_FEATURE_PMU,
1747
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1748
    VIR_DOMAIN_FEATURE_GIC,
M
Michal Privoznik 已提交
1749
    VIR_DOMAIN_FEATURE_SMM,
1750
    VIR_DOMAIN_FEATURE_IOAPIC,
1751
    VIR_DOMAIN_FEATURE_HPT,
M
Marc-André Lureau 已提交
1752
    VIR_DOMAIN_FEATURE_VMCOREINFO,
1753 1754

    VIR_DOMAIN_FEATURE_LAST
1755
} virDomainFeature;
1756

1757 1758
# define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12

1759
typedef enum {
1760
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1761 1762
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1763 1764 1765 1766 1767 1768
    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,
1769 1770

    VIR_DOMAIN_HYPERV_LAST
1771
} virDomainHyperv;
1772

1773 1774 1775 1776 1777 1778
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828
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;

1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840
typedef enum {
    VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
    VIR_DOMAIN_LOCK_FAILURE_POWEROFF,
    VIR_DOMAIN_LOCK_FAILURE_RESTART,
    VIR_DOMAIN_LOCK_FAILURE_PAUSE,
    VIR_DOMAIN_LOCK_FAILURE_IGNORE,

    VIR_DOMAIN_LOCK_FAILURE_LAST
} virDomainLockFailureAction;

VIR_ENUM_DECL(virDomainLockFailure)

M
Michal Privoznik 已提交
1841 1842 1843
typedef struct _virDomainBIOSDef virDomainBIOSDef;
typedef virDomainBIOSDef *virDomainBIOSDefPtr;
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1844
    int useserial; /* enum virTristateBool */
1845 1846 1847
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1848 1849
};

1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864
typedef enum {
    VIR_DOMAIN_LOADER_TYPE_ROM = 0,
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

VIR_ENUM_DECL(virDomainLoader)

typedef struct _virDomainLoaderDef virDomainLoaderDef;
typedef virDomainLoaderDef *virDomainLoaderDefPtr;
struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1865
    int secure;     /* enum virTristateBool */
1866
    char *nvram;    /* path to non-volatile RAM */
1867
    char *templt;   /* user override of path to master nvram */
1868 1869 1870 1871
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1872
typedef enum {
1873 1874
    VIR_DOMAIN_IOAPIC_NONE = 0,
    VIR_DOMAIN_IOAPIC_QEMU,
1875 1876 1877 1878 1879 1880 1881
    VIR_DOMAIN_IOAPIC_KVM,

    VIR_DOMAIN_IOAPIC_LAST
} virDomainIOAPIC;

VIR_ENUM_DECL(virDomainIOAPIC);

1882
typedef enum {
1883 1884
    VIR_DOMAIN_HPT_RESIZING_NONE = 0,
    VIR_DOMAIN_HPT_RESIZING_ENABLED,
1885 1886 1887 1888 1889 1890 1891 1892
    VIR_DOMAIN_HPT_RESIZING_DISABLED,
    VIR_DOMAIN_HPT_RESIZING_REQUIRED,

    VIR_DOMAIN_HPT_RESIZING_LAST
} virDomainHPTResizing;

VIR_ENUM_DECL(virDomainHPTResizing);

1893
/* Operating system configuration data & machine / arch */
1894 1895 1896 1897 1898 1899 1900
typedef struct _virDomainOSEnv virDomainOSEnv;
typedef virDomainOSEnv *virDomainOSEnvPtr;
struct _virDomainOSEnv {
    char *name;
    char *value;
};

1901 1902 1903
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
1904
    int type;
1905
    virArch arch;
1906
    char *machine;
1907
    size_t nBootDevs;
1908
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1909
    int bootmenu; /* enum virTristateBool */
1910 1911
    unsigned int bm_timeout;
    bool bm_timeout_set;
1912
    char *init;
1913
    char **initargv;
1914
    virDomainOSEnvPtr *initenv;
1915
    char *initdir;
1916 1917
    char *inituser;
    char *initgroup;
1918 1919 1920
    char *kernel;
    char *initrd;
    char *cmdline;
1921
    char *dtb;
1922
    char *root;
J
Ján Tomko 已提交
1923
    char *slic_table;
1924
    virDomainLoaderDefPtr loader;
1925 1926
    char *bootloader;
    char *bootloaderArgs;
1927
    int smbios_mode;
1928

M
Michal Privoznik 已提交
1929
    virDomainBIOSDef bios;
1930 1931
};

1932
typedef enum {
1933 1934 1935 1936 1937
    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 已提交
1938
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1939
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
1940

1941
    VIR_DOMAIN_TIMER_NAME_LAST
1942
} virDomainTimerNameType;
1943

1944
typedef enum {
1945 1946 1947
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1948

1949
    VIR_DOMAIN_TIMER_TRACK_LAST
1950
} virDomainTimerTrackType;
1951

1952
typedef enum {
1953 1954 1955 1956 1957
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

1958
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
1959
} virDomainTimerTickpolicyType;
1960

1961
typedef enum {
1962 1963 1964 1965
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
1966
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
1967

1968
    VIR_DOMAIN_TIMER_MODE_LAST
1969
} virDomainTimerModeType;
1970

1971
typedef enum {
1972
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
1973 1974
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

1975
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
1976
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
1977

1978 1979 1980
typedef struct _virDomainThreadSchedParam virDomainThreadSchedParam;
typedef virDomainThreadSchedParam *virDomainThreadSchedParamPtr;
struct _virDomainThreadSchedParam {
1981
    virProcessSchedPolicy policy;
1982 1983 1984
    int priority;
};

1985 1986 1987 1988 1989 1990 1991 1992
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

1993 1994 1995 1996 1997 1998 1999
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 */

2000 2001 2002 2003
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
2004 2005 2006 2007 2008 2009

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

2010
typedef enum {
2011 2012
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
2013
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
2014
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
2015

2016
    VIR_DOMAIN_CLOCK_OFFSET_LAST
2017
} virDomainClockOffsetType;
2018

2019
typedef enum {
2020 2021 2022
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

2023
    VIR_DOMAIN_CLOCK_BASIS_LAST
2024
} virDomainClockBasis;
2025

2026 2027 2028 2029
typedef struct _virDomainClockDef virDomainClockDef;
typedef virDomainClockDef *virDomainClockDefPtr;
struct _virDomainClockDef {
    int offset;
2030

2031
    union {
2032 2033 2034
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
2035
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
2036 2037 2038
        struct {
            long long adjustment;
            int basis;
2039 2040 2041 2042 2043 2044 2045

            /* 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;
2046
        } variable;
2047 2048 2049 2050 2051

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

2053
    size_t ntimers;
2054
    virDomainTimerDefPtr *timers;
2055 2056
};

2057

2058 2059 2060
typedef struct _virBlkioDevice virBlkioDevice;
typedef virBlkioDevice *virBlkioDevicePtr;
struct _virBlkioDevice {
2061 2062
    char *path;
    unsigned int weight;
2063 2064 2065 2066
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
2067 2068
};

2069
typedef enum {
2070 2071 2072
    VIR_DOMAIN_RNG_MODEL_VIRTIO,

    VIR_DOMAIN_RNG_MODEL_LAST
2073
} virDomainRNGModel;
2074

2075
typedef enum {
2076 2077 2078 2079 2080
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
    /* VIR_DOMAIN_RNG_BACKEND_POOL, */

    VIR_DOMAIN_RNG_BACKEND_LAST
2081
} virDomainRNGBackend;
2082 2083 2084 2085

struct _virDomainRNGDef {
    int model;
    int backend;
2086 2087
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
2088 2089 2090 2091 2092 2093 2094 2095

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

    virDomainDeviceInfo info;
2096
    virDomainVirtioOptionsPtr virtio;
2097 2098
};

2099 2100 2101
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2102
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2103 2104 2105 2106 2107

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
2108
    virDomainMemoryAccess access;
2109
    virTristateBool discard;
2110

2111 2112 2113
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2114
    char *nvdimmPath;
2115 2116 2117

    /* target */
    int model; /* virDomainMemoryModel */
2118
    int targetNode;
2119
    unsigned long long size; /* kibibytes */
2120
    unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
2121 2122 2123 2124 2125 2126

    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2142 2143 2144 2145 2146
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2147
    VIR_DOMAIN_PANIC_MODEL_S390,
2148 2149 2150 2151

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2152
struct _virDomainPanicDef {
2153
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2154 2155 2156 2157
    virDomainDeviceInfo info;
};


2158
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2159
                              int ndevices);
2160

2161 2162 2163 2164 2165
typedef struct _virDomainResourceDef virDomainResourceDef;
typedef virDomainResourceDef *virDomainResourceDefPtr;
struct _virDomainResourceDef {
    char *partition;
};
2166

2167
typedef struct _virDomainHugePage virDomainHugePage;
2168 2169
typedef virDomainHugePage *virDomainHugePagePtr;

2170
struct _virDomainHugePage {
2171 2172 2173 2174
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2175 2176
# define VIR_DOMAIN_CPUMASK_LEN 1024

2177 2178 2179 2180 2181 2182
typedef struct _virDomainIOThreadIDDef virDomainIOThreadIDDef;
typedef virDomainIOThreadIDDef *virDomainIOThreadIDDefPtr;

struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2183
    int thread_id;
2184
    virBitmapPtr cpumask;
2185 2186

    virDomainThreadSchedParam sched;
2187 2188 2189 2190
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2191

2192 2193 2194 2195
typedef struct _virDomainCputune virDomainCputune;
typedef virDomainCputune *virDomainCputunePtr;

struct _virDomainCputune {
2196
    unsigned long long shares;
2197 2198 2199
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2200
    unsigned long long global_period;
2201
    long long global_quota;
2202 2203
    unsigned long long emulator_period;
    long long emulator_quota;
2204 2205
    unsigned long long iothread_period;
    long long iothread_quota;
2206
    virBitmapPtr emulatorpin;
2207 2208
};

2209

2210 2211 2212 2213 2214 2215 2216 2217 2218
typedef struct _virDomainCachetuneDef virDomainCachetuneDef;
typedef virDomainCachetuneDef *virDomainCachetuneDefPtr;

struct _virDomainCachetuneDef {
    virBitmapPtr vcpus;
    virResctrlAllocPtr alloc;
};


2219 2220
typedef struct _virDomainVcpuDef virDomainVcpuDef;
typedef virDomainVcpuDef *virDomainVcpuDefPtr;
2221

2222
struct _virDomainVcpuDef {
2223
    bool online;
2224 2225 2226
    virTristateBool hotpluggable;
    unsigned int order;

2227
    virBitmapPtr cpumask;
2228 2229

    virDomainThreadSchedParam sched;
2230 2231

    virObjectPtr privateData;
2232 2233
};

2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247
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 {
2248 2249 2250
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2251 2252
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2253 2254 2255 2256

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2257 2258 2259 2260
    /* 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 */

2261 2262 2263
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2264 2265 2266 2267
    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 */
2268 2269 2270 2271

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2272 2273

    virTristateBool discard;
2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284
};

typedef struct _virDomainPowerManagement virDomainPowerManagement;
typedef virDomainPowerManagement *virDomainPowerManagementPtr;

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

Q
Qiaowei Ren 已提交
2285 2286 2287 2288 2289 2290 2291
typedef struct _virDomainPerfDef virDomainPerfDef;
typedef virDomainPerfDef *virDomainPerfDefPtr;
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2292 2293 2294 2295 2296 2297 2298
typedef struct _virDomainKeyWrapDef virDomainKeyWrapDef;
typedef virDomainKeyWrapDef *virDomainKeyWrapDefPtr;
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

J
Ján Tomko 已提交
2299 2300 2301 2302 2303 2304 2305 2306
typedef enum {
    VIR_DOMAIN_IOMMU_MODEL_INTEL,

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

struct _virDomainIOMMUDef {
    virDomainIOMMUModel model;
2307
    virTristateSwitch intremap;
2308
    virTristateSwitch caching_mode;
2309
    virTristateSwitch eim;
J
Ján Tomko 已提交
2310
    virTristateSwitch iotlb;
J
Ján Tomko 已提交
2311
};
2312 2313 2314 2315 2316 2317

struct _virDomainVirtioOptions {
    virTristateSwitch iommu;
    virTristateSwitch ats;
};

2318 2319 2320 2321 2322 2323
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
2324 2325
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
2326
struct _virDomainDef {
2327
    virDomainVirtType virtType;
2328 2329 2330
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
    char *name;
2331
    char *title;
2332
    char *description;
2333

2334 2335
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2336

2337
    virDomainVcpuDefPtr *vcpus;
2338
    size_t maxvcpus;
2339 2340
    /* set if the vcpu definition was specified individually */
    bool individualvcpus;
O
Osier Yang 已提交
2341
    int placement_mode;
H
Hu Tao 已提交
2342
    virBitmapPtr cpumask;
2343

2344 2345
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2346

2347
    virDomainCputune cputune;
2348

2349 2350 2351
    virDomainCachetuneDefPtr *cachetunes;
    size_t ncachetunes;

2352
    virDomainNumaPtr numa;
2353
    virDomainResourceDefPtr resource;
2354
    virDomainIdMapDef idmap;
2355

2356 2357 2358 2359 2360
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2361 2362
    int onLockFailure; /* enum virDomainLockFailureAction */

2363
    virDomainPowerManagement pm;
2364

2365
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2366

2367 2368
    virDomainOSDef os;
    char *emulator;
2369 2370 2371
    /* 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. */
2372
    int features[VIR_DOMAIN_FEATURE_LAST];
2373
    int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
2374
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2375
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2376
    unsigned int hyperv_spinlocks;
2377
    virGICVersion gic_version;
2378
    char *hyperv_vendor_id;
2379
    int apic_eoi;
2380

2381
    virDomainClockDef clock;
2382

2383
    size_t ngraphics;
2384
    virDomainGraphicsDefPtr *graphics;
2385

2386
    size_t ndisks;
2387 2388
    virDomainDiskDefPtr *disks;

2389
    size_t ncontrollers;
2390 2391
    virDomainControllerDefPtr *controllers;

2392
    size_t nfss;
2393 2394
    virDomainFSDefPtr *fss;

2395
    size_t nnets;
2396 2397
    virDomainNetDefPtr *nets;

2398
    size_t ninputs;
2399 2400
    virDomainInputDefPtr *inputs;

2401
    size_t nsounds;
2402 2403
    virDomainSoundDefPtr *sounds;

2404
    size_t nvideos;
2405 2406
    virDomainVideoDefPtr *videos;

2407
    size_t nhostdevs;
2408 2409
    virDomainHostdevDefPtr *hostdevs;

2410
    size_t nredirdevs;
2411 2412
    virDomainRedirdevDefPtr *redirdevs;

2413
    size_t nsmartcards;
E
Eric Blake 已提交
2414 2415
    virDomainSmartcardDefPtr *smartcards;

2416
    size_t nserials;
2417 2418
    virDomainChrDefPtr *serials;

2419
    size_t nparallels;
2420 2421
    virDomainChrDefPtr *parallels;

2422
    size_t nchannels;
2423 2424
    virDomainChrDefPtr *channels;

2425
    size_t nconsoles;
2426 2427
    virDomainChrDefPtr *consoles;

2428
    size_t nleases;
2429 2430
    virDomainLeaseDefPtr *leases;

2431
    size_t nhubs;
M
Marc-André Lureau 已提交
2432 2433
    virDomainHubDefPtr *hubs;

2434 2435 2436
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2437 2438 2439
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2440 2441 2442
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2443 2444 2445
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2446 2447 2448
    size_t npanics;
    virDomainPanicDefPtr *panics;

2449
    /* Only 1 */
R
Richard Jones 已提交
2450
    virDomainWatchdogDefPtr watchdog;
2451
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2452
    virDomainNVRAMDefPtr nvram;
2453
    virDomainTPMDefPtr tpm;
2454
    virCPUDefPtr cpu;
2455
    virSysinfoDefPtr sysinfo;
2456
    virDomainRedirFilterDefPtr redirfilter;
J
Ján Tomko 已提交
2457
    virDomainIOMMUDefPtr iommu;
2458 2459 2460

    void *namespaceData;
    virDomainXMLNamespace ns;
2461

2462 2463
    virDomainKeyWrapDefPtr keywrap;

2464 2465
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2466 2467 2468 2469 2470 2471

    /* 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 */
2472 2473
};

2474

2475
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2476
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2477
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2478
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2479

2480 2481 2482 2483 2484 2485 2486
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

2487
typedef enum {
2488 2489 2490 2491 2492
    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 */
2493
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2494
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2495
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2496
    VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,/* CDROM passthrough */
Y
Yuri Chornoivan 已提交
2497
    VIR_DOMAIN_TAINT_CUSTOM_DTB,       /* Custom device tree blob was specified */
2498
    VIR_DOMAIN_TAINT_CUSTOM_GA_COMMAND, /* Custom guest agent command */
2499 2500

    VIR_DOMAIN_TAINT_LAST
2501
} virDomainTaintFlags;
2502

2503
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2504 2505 2506 2507 2508 2509
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2510 2511 2512
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
2513
    virObjectLockable parent;
2514
    virCond cond;
2515

2516
    pid_t pid;
J
Jiri Denemark 已提交
2517
    virDomainStateReason state;
2518 2519 2520

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2521
    unsigned int updated : 1;
2522
    unsigned int removing : 1;
2523 2524 2525

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

2527
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2528 2529
    virDomainSnapshotObjPtr current_snapshot;

2530 2531
    bool hasManagedSave;

2532 2533
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2534 2535

    int taint;
2536 2537 2538

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

2541 2542
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2543

2544

2545 2546
/* NB: Any new flag to this list be considered to be set in
 * virt-aa-helper code if the flag prevents parsing. */
2547 2548
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2549
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2550
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2551
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2552
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2553
    VIR_DOMAIN_DEF_FEATURE_USER_ALIAS = (1 << 5),
2554 2555 2556
} virDomainDefFeatures;


2557 2558
/* This structure holds various callbacks and data needed
 * while parsing and creating domain XMLs */
2559 2560
typedef struct _virDomainXMLOption virDomainXMLOption;
typedef virDomainXMLOption *virDomainXMLOptionPtr;
2561

2562 2563 2564 2565 2566 2567 2568 2569 2570

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

2571
/* Called once after everything else has been parsed, for adjusting
2572 2573 2574
 * overall domain defaults.
 * @parseOpaque is opaque data passed by virDomainDefParse* caller,
 * @opaque is opaque data set by driver (usually pointer to driver
2575 2576 2577 2578
 * 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. */
2579 2580
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
                                             virCapsPtr caps,
2581
                                             unsigned int parseFlags,
2582 2583
                                             void *opaque,
                                             void *parseOpaque);
2584
/* Called once per device, for adjusting per-device settings while
2585 2586 2587 2588
 * 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). */
2589
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
2590
                                                   const virDomainDef *def,
2591
                                                   virCapsPtr caps,
2592
                                                   unsigned int parseFlags,
2593 2594
                                                   void *opaque,
                                                   void *parseOpaque);
2595
/* Drive callback for assigning device addresses, called at the end
2596 2597 2598 2599
 * 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). */
2600 2601 2602
typedef int (*virDomainDefAssignAddressesCallback)(virDomainDef *def,
                                                   virCapsPtr caps,
                                                   unsigned int parseFlags,
2603 2604
                                                   void *opaque,
                                                   void *parseOpaque);
2605

2606 2607 2608 2609 2610 2611 2612
typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def,
                                              virCapsPtr caps,
                                              unsigned int parseFlags,
                                              void *opaque,
                                              void **parseOpaque);
typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque);

2613 2614 2615 2616 2617 2618
/* 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);
2619

2620 2621 2622 2623 2624 2625
/* 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);

2626 2627 2628
typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
struct _virDomainDefParserConfig {
2629
    /* driver domain definition callbacks */
2630
    virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
2631
    virDomainDefPostParseDataAlloc domainPostParseDataAlloc;
2632 2633
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2634
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2635
    virDomainDefPostParseDataFree domainPostParseDataFree;
2636

2637 2638
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2639
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2640

2641
    /* private data for the callbacks */
2642 2643
    void *priv;
    virFreeCallback privFree;
2644 2645

    /* data */
2646
    unsigned int features; /* virDomainDefFeatures */
2647
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2648 2649
};

2650
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *);
2651 2652 2653 2654 2655 2656 2657 2658
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
                                                 virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                virDomainObjPtr,
                                                virDomainDefParserConfigPtr);

2659 2660 2661 2662 2663 2664
typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
                                                             virStorageSourcePtr src);
typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
                                                              virBufferPtr buf);


2665 2666 2667 2668 2669
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
2670 2671
    /* note that private data for devices are not copied when using
     * virDomainDefCopy and similar functions */
2672
    virDomainXMLPrivateDataNewFunc    diskNew;
2673
    virDomainXMLPrivateDataNewFunc    vcpuNew;
2674
    virDomainXMLPrivateDataNewFunc    chrSourceNew;
2675 2676
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
2677 2678
    virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
    virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
2679 2680
};

2681 2682 2683 2684 2685 2686 2687 2688 2689
typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
                                            const virDomainDef *dst);

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

2690 2691
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
2692
                                            virDomainXMLNamespacePtr xmlns,
2693 2694 2695 2696 2697
                                            virDomainABIStabilityPtr abi,
                                            virSaveCookieCallbacksPtr saveCookie);

virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
2698

2699 2700
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2701
virDomainXMLNamespacePtr
2702
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2703 2704
    ATTRIBUTE_NONNULL(1);

2705 2706 2707 2708 2709
int virDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2710
bool virDomainDefHasUSB(const virDomainDef *def);
2711

2712 2713 2714 2715
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
                                           virDomainDeviceDefPtr dev,
                                           unsigned int flags);

2716 2717
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);

2718
int virDomainDefValidate(virDomainDefPtr def,
2719 2720 2721 2722
                         virCapsPtr caps,
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2723
static inline bool
D
Daniel P. Berrange 已提交
2724
virDomainObjIsActive(virDomainObjPtr dom)
2725 2726 2727 2728
{
    return dom->def->id != -1;
}

2729 2730
int virDomainObjCheckActive(virDomainObjPtr dom);

2731 2732 2733 2734 2735 2736 2737 2738 2739 2740
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;
2741
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2742 2743
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2744

2745
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2746
    ATTRIBUTE_NONNULL(1);
2747

M
Michal Privoznik 已提交
2748 2749
void virDomainObjEndAPI(virDomainObjPtr *vm);

2750
bool virDomainObjTaint(virDomainObjPtr obj,
2751
                       virDomainTaintFlags taint);
2752

2753 2754 2755 2756
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2757

H
Hu Tao 已提交
2758
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2759
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2760
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
J
Ján Tomko 已提交
2761
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
2762
void virDomainInputDefFree(virDomainInputDefPtr def);
2763
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2764
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2765
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2766 2767
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2768
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2769 2770
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
    ATTRIBUTE_RETURN_CHECK;
2771
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
2772
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
2773 2774 2775 2776
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
    ATTRIBUTE_RETURN_CHECK;
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2777 2778 2779
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
                                  virDomainDeviceInfoPtr info);
2780 2781 2782
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2783 2784

virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type);
2785
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2786
bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont);
2787

2788
virDomainFSDefPtr virDomainFSDefNew(void);
2789
void virDomainFSDefFree(virDomainFSDefPtr def);
2790
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
2791
void virDomainNetDefClear(virDomainNetDefPtr def);
2792
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2793
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2794
void virDomainChrDefFree(virDomainChrDefPtr def);
2795
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
2796 2797
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr src,
                              virDomainChrSourceDefPtr dest);
2798
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
2799
void virDomainSoundDefFree(virDomainSoundDefPtr def);
2800
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2801
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2802
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
C
Cole Robinson 已提交
2803
virDomainVideoDefPtr virDomainVideoDefNew(void);
2804
void virDomainVideoDefFree(virDomainVideoDefPtr def);
J
John Ferlan 已提交
2805
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
2806
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2807
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2808
void virDomainHubDefFree(virDomainHubDefPtr def);
2809
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2810
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2811
void virDomainShmemDefFree(virDomainShmemDefPtr def);
2812
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2813
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2814
                                             const virDomainDef *def,
2815 2816
                                             virCapsPtr caps,
                                             virDomainXMLOptionPtr xmlopt);
2817 2818
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                  int type);
2819
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
2820
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2821

2822
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2823 2824
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2825 2826 2827 2828 2829 2830
                                           void *opaque);

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

2831 2832 2833 2834
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

2835 2836
void virDomainDefFree(virDomainDefPtr vm);

2837 2838 2839
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);

2840
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
2841

2842 2843 2844 2845
virDomainDefPtr virDomainDefNew(void);
virDomainDefPtr virDomainDefNewFull(const char *name,
                                    const unsigned char *uuid,
                                    int id);
2846

2847
void virDomainObjAssignDef(virDomainObjPtr domain,
2848
                           virDomainDefPtr def,
2849 2850
                           bool live,
                           virDomainDefPtr *oldDef);
2851
int virDomainObjSetDefTransient(virCapsPtr caps,
2852
                                virDomainXMLOptionPtr xmlopt,
2853
                                virDomainObjPtr domain);
2854
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
2855 2856
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
2857
                             virDomainXMLOptionPtr xmlopt,
2858
                             virDomainObjPtr domain);
2859 2860 2861 2862 2863 2864 2865 2866

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

int virDomainObjGetDefs(virDomainObjPtr vm,
                        unsigned int flags,
                        virDomainDefPtr *liveDef,
                        virDomainDefPtr *persDef);
2867 2868 2869
virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                           unsigned int flags,
                                           bool *state);
2870
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
2871

2872 2873 2874
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virCapsPtr caps,
                                 virDomainXMLOptionPtr xmlopt,
2875
                                 void *parseOpaque,
2876 2877 2878 2879
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt);
2880

2881 2882 2883
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
2884 2885 2886 2887
    /* 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. */
2888 2889 2890 2891 2892
    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,
2893
    /* internal flag passed to device info sub-parser to allow using <rom> */
2894
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
2895
    /* internal flag passed to device info sub-parser to allow specifying boot order */
2896 2897
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    /* parse only source half of <disk> */
2898
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 6,
2899
    /* perform RNG schema validation on the passed XML document */
2900
    VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA = 1 << 7,
2901
    /* don't validate os.type and arch against capabilities. Prevents
2902
     * VMs from disappearing when qemu is removed and libvirtd is restarted */
2903
    VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS = 1 << 8,
2904 2905
    /* allow updates in post parse callback that would break ABI otherwise */
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE = 1 << 9,
2906 2907
    /* skip definition validation checks meant to be executed on define time only */
    VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 10,
2908 2909
    /* skip parsing of security labels */
    VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 11,
2910 2911 2912 2913
    /* 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. */
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 12,
2914 2915 2916 2917 2918
    /* 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 */
    VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL = 1 << 13,
2919 2920 2921 2922 2923
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
2924
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
2925
    /* format internal domain status information */
2926
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
2927
    /* format <actual> element */
2928
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
2929
    /* format original states of host PCI device */
2930 2931 2932 2933
    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,
2934 2935
} virDomainDefFormatFlags;

2936 2937 2938 2939 2940 2941 2942 2943 2944
/* 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;

2945
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
2946
                                              const virDomainDef *def,
2947 2948
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
2949
                                              unsigned int flags);
2950 2951 2952 2953
virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr,
                                          const virDomainDef *def,
                                          virDomainXMLOptionPtr xmlopt,
                                          unsigned int flags);
2954 2955
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                        virCapsPtr caps,
2956
                                        virDomainXMLOptionPtr xmlopt,
2957
                                        void *parseOpaque,
L
Laine Stump 已提交
2958
                                        unsigned int flags);
2959 2960
virDomainDefPtr virDomainDefParseFile(const char *filename,
                                      virCapsPtr caps,
2961
                                      virDomainXMLOptionPtr xmlopt,
2962
                                      void *parseOpaque,
L
Laine Stump 已提交
2963
                                      unsigned int flags);
2964
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
2965
                                      xmlNodePtr root,
2966 2967
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
2968
                                      void *parseOpaque,
L
Laine Stump 已提交
2969
                                      unsigned int flags);
2970 2971 2972 2973 2974
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
2975 2976 2977 2978
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
2979

2980
bool virDomainDefCheckABIStability(virDomainDefPtr src,
2981 2982
                                   virDomainDefPtr dst,
                                   virDomainXMLOptionPtr xmlopt);
2983

2984 2985
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
                                        virDomainDefPtr dst,
2986
                                        virDomainXMLOptionPtr xmlopt,
2987 2988
                                        unsigned int flags);

2989
int virDomainDefAddImplicitDevices(virDomainDefPtr def);
2990

2991
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
2992 2993 2994 2995 2996
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);

2997 2998
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

2999
char *virDomainDefFormat(virDomainDefPtr def,
3000
                         virCapsPtr caps,
L
Laine Stump 已提交
3001
                         unsigned int flags);
3002 3003
char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
                         virDomainObjPtr obj,
3004
                         virCapsPtr caps,
3005
                         unsigned int flags);
3006
int virDomainDefFormatInternal(virDomainDefPtr def,
3007
                               virCapsPtr caps,
3008
                               unsigned int flags,
3009 3010
                               virBufferPtr buf,
                               virDomainXMLOptionPtr xmlopt);
3011

3012 3013 3014
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
                              int policy,
3015 3016
                              unsigned int flags,
                              virDomainXMLOptionPtr xmlopt);
3017

3018 3019
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
3020
                          char *prefix,
3021 3022
                          unsigned int flags);

3023 3024 3025 3026 3027 3028
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

3029
int virDomainDefCompatibleDevice(virDomainDefPtr def,
3030 3031
                                 virDomainDeviceDefPtr dev,
                                 virDomainDeviceDefPtr oldDev);
3032

3033 3034
void virDomainRNGDefFree(virDomainRNGDefPtr def);

3035
int virDomainDiskIndexByAddress(virDomainDefPtr def,
3036
                                virPCIDeviceAddressPtr pci_controller,
3037 3038
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
3039
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
3040
                                           virPCIDeviceAddressPtr pci_controller,
3041 3042 3043
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
3044 3045
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
3046 3047 3048
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
3049
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
3050
int virDomainDiskInsert(virDomainDefPtr def,
3051 3052
                        virDomainDiskDefPtr disk)
    ATTRIBUTE_RETURN_CHECK;
3053 3054
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
3055
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
3056 3057
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
3058

3059 3060 3061 3062
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
3063
int virDomainDiskSourceParse(xmlNodePtr node,
3064
                             xmlXPathContextPtr ctxt,
3065
                             virStorageSourcePtr src,
3066 3067
                             unsigned int flags,
                             virDomainXMLOptionPtr xmlopt);
3068

3069 3070
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
3071
virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname);
3072
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
3073
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
3074
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
3075
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
3076

L
Laine Stump 已提交
3077
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
3078 3079
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
3080 3081 3082
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

3083 3084
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
3085 3086
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
3087
            ATTRIBUTE_NONNULL(1);
3088 3089 3090
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
3091

3092
virDomainNetType virDomainNetGetActualType(const virDomainNetDef *iface);
3093
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
3094
int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
3095
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
3096
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
3097
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
3098
virNetDevVPortProfilePtr
3099
virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface);
3100
virNetDevBandwidthPtr
3101
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
3102
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
3103
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
3104
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
3105 3106 3107
                                const char *address,
                                int family,
                                unsigned int prefix);
3108

3109
int virDomainControllerInsert(virDomainDefPtr def,
3110 3111
                              virDomainControllerDefPtr controller)
    ATTRIBUTE_RETURN_CHECK;
3112 3113
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
3114
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
3115
int virDomainControllerFindByType(virDomainDefPtr def, int type);
3116
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
3117
                                        virPCIDeviceAddressPtr addr);
3118
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
3119
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
3120
const char *virDomainControllerAliasFind(const virDomainDef *def,
3121 3122
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
3123 3124 3125 3126 3127

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
3128 3129
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
    ATTRIBUTE_RETURN_CHECK;
3130 3131
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
3132 3133 3134 3135 3136
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
3137

3138
void
3139
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
3140
                          virDomainChrDeviceType type,
3141 3142 3143
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3144 3145 3146
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
3147 3148 3149
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
3150
int
3151 3152 3153 3154 3155
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
3156 3157 3158 3159
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

3160 3161 3162
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

3163 3164 3165 3166
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

3167
int virDomainSaveXML(const char *configDir,
3168 3169 3170
                     virDomainDefPtr def,
                     const char *xml);

3171
int virDomainSaveConfig(const char *configDir,
3172
                        virCapsPtr caps,
3173
                        virDomainDefPtr def);
3174
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
3175
                        const char *statusDir,
3176 3177
                        virDomainObjPtr obj,
                        virCapsPtr caps) ATTRIBUTE_RETURN_CHECK;
3178

3179 3180 3181 3182
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

3183
int virDomainDeleteConfig(const char *configDir,
3184
                          const char *autostartDir,
3185 3186
                          virDomainObjPtr dom);

3187
char *virDomainConfigFile(const char *dir,
3188 3189
                          const char *name);

3190 3191 3192 3193
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

3194
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
3195
                                                  const char *target);
3196
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
3197
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
3198 3199
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

3200
int virDomainVideoDefaultType(const virDomainDef *def);
3201 3202
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
3203

E
Eric Blake 已提交
3204 3205 3206 3207 3208 3209 3210 3211 3212
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3213 3214 3215 3216 3217 3218 3219 3220 3221
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3222 3223 3224 3225 3226
typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
                                            const char *path,
                                            size_t depth,
                                            void *opaque);

3227 3228 3229 3230 3231 3232 3233
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

3234 3235 3236 3237 3238
int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
                                bool ignoreOpenFailure,
                                virDomainDiskDefPathIterator iter,
                                void *opaque);

J
Jiri Denemark 已提交
3239 3240 3241 3242 3243 3244 3245
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3246 3247 3248
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3249
virSecurityDeviceLabelDefPtr
3250 3251
virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDefPtr def,
                                         const char *model);
3252

3253 3254
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3255

3256 3257 3258 3259 3260 3261 3262 3263 3264 3265
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;

3266 3267 3268 3269 3270 3271 3272 3273
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);
3274 3275 3276
ssize_t virDomainInputDefFind(const virDomainDef *def,
                              const virDomainInputDef *input)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
3277

3278
VIR_ENUM_DECL(virDomainTaint)
3279 3280 3281
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
VIR_ENUM_DECL(virDomainFeature)
3282 3283
VIR_ENUM_DECL(virDomainCapabilitiesPolicy)
VIR_ENUM_DECL(virDomainCapsFeature)
3284
VIR_ENUM_DECL(virDomainLifecycle)
3285
VIR_ENUM_DECL(virDomainLifecycleAction)
3286
VIR_ENUM_DECL(virDomainDevice)
3287
VIR_ENUM_DECL(virDomainDeviceAddress)
3288
VIR_ENUM_DECL(virDomainDiskDevice)
J
J.B. Joret 已提交
3289
VIR_ENUM_DECL(virDomainDiskGeometryTrans)
3290
VIR_ENUM_DECL(virDomainDiskBus)
3291
VIR_ENUM_DECL(virDomainDiskCache)
3292
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
M
Matthias Dahl 已提交
3293
VIR_ENUM_DECL(virDomainDiskIo)
3294
VIR_ENUM_DECL(virDomainDeviceSGIO)
3295
VIR_ENUM_DECL(virDomainDiskTray)
O
Osier Yang 已提交
3296
VIR_ENUM_DECL(virDomainDiskDiscard)
3297
VIR_ENUM_DECL(virDomainDiskDetectZeroes)
3298
VIR_ENUM_DECL(virDomainDiskMirrorState)
3299
VIR_ENUM_DECL(virDomainController)
J
Ján Tomko 已提交
3300
VIR_ENUM_DECL(virDomainControllerModelPCI)
3301
VIR_ENUM_DECL(virDomainControllerPCIModelName)
3302
VIR_ENUM_DECL(virDomainControllerModelSCSI)
M
Marc-André Lureau 已提交
3303
VIR_ENUM_DECL(virDomainControllerModelUSB)
3304
VIR_ENUM_DECL(virDomainControllerModelIDE)
3305
VIR_ENUM_DECL(virDomainFS)
3306
VIR_ENUM_DECL(virDomainFSDriver)
3307
VIR_ENUM_DECL(virDomainFSAccessMode)
3308
VIR_ENUM_DECL(virDomainFSWrpolicy)
3309
VIR_ENUM_DECL(virDomainNet)
3310
VIR_ENUM_DECL(virDomainNetBackend)
3311
VIR_ENUM_DECL(virDomainNetVirtioTxMode)
3312
VIR_ENUM_DECL(virDomainNetInterfaceLinkState)
3313
VIR_ENUM_DECL(virDomainChrDevice)
3314
VIR_ENUM_DECL(virDomainChrChannelTarget)
3315
VIR_ENUM_DECL(virDomainChrConsoleTarget)
G
Guannan Ren 已提交
3316
VIR_ENUM_DECL(virDomainChrSerialTarget)
E
Eric Blake 已提交
3317
VIR_ENUM_DECL(virDomainSmartcard)
3318
VIR_ENUM_DECL(virDomainChr)
3319
VIR_ENUM_DECL(virDomainChrTcpProtocol)
E
Eric Blake 已提交
3320
VIR_ENUM_DECL(virDomainChrSpicevmc)
3321
VIR_ENUM_DECL(virDomainSoundCodec)
3322
VIR_ENUM_DECL(virDomainSoundModel)
3323
VIR_ENUM_DECL(virDomainKeyWrapCipherName)
3324
VIR_ENUM_DECL(virDomainMemballoonModel)
3325
VIR_ENUM_DECL(virDomainSmbiosMode)
R
Richard Jones 已提交
3326 3327
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
3328
VIR_ENUM_DECL(virDomainPanicModel)
3329
VIR_ENUM_DECL(virDomainVideo)
3330 3331
VIR_ENUM_DECL(virDomainHostdevMode)
VIR_ENUM_DECL(virDomainHostdevSubsys)
3332
VIR_ENUM_DECL(virDomainHostdevCaps)
M
Marc-André Lureau 已提交
3333
VIR_ENUM_DECL(virDomainHub)
3334
VIR_ENUM_DECL(virDomainRedirdevBus)
3335 3336 3337
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
3338
VIR_ENUM_DECL(virDomainGraphicsListen)
3339
VIR_ENUM_DECL(virDomainGraphicsAuthConnected)
3340 3341
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
3342 3343 3344
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
3345
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
P
Peng Zhou 已提交
3346
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
3347
VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy)
3348
VIR_ENUM_DECL(virDomainHyperv)
3349
VIR_ENUM_DECL(virDomainKVM)
3350 3351
VIR_ENUM_DECL(virDomainRNGModel)
VIR_ENUM_DECL(virDomainRNGBackend)
3352 3353
VIR_ENUM_DECL(virDomainTPMModel)
VIR_ENUM_DECL(virDomainTPMBackend)
3354 3355
VIR_ENUM_DECL(virDomainMemoryModel)
VIR_ENUM_DECL(virDomainMemoryBackingModel)
3356 3357
VIR_ENUM_DECL(virDomainMemorySource)
VIR_ENUM_DECL(virDomainMemoryAllocation)
J
Ján Tomko 已提交
3358
VIR_ENUM_DECL(virDomainIOMMUModel)
3359
VIR_ENUM_DECL(virDomainShmemModel)
3360 3361
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
J
Jiri Denemark 已提交
3362 3363 3364 3365 3366 3367 3368
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)
3369
VIR_ENUM_DECL(virDomainPMSuspendedReason)
J
Jiri Denemark 已提交
3370 3371 3372 3373

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

3374
VIR_ENUM_DECL(virDomainSeclabel)
3375
VIR_ENUM_DECL(virDomainClockOffset)
3376
VIR_ENUM_DECL(virDomainClockBasis)
3377

3378
VIR_ENUM_DECL(virDomainTimerName)
3379
VIR_ENUM_DECL(virDomainTimerTrack)
3380 3381
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)
O
Osier Yang 已提交
3382
VIR_ENUM_DECL(virDomainCpuPlacementMode)
3383

3384
VIR_ENUM_DECL(virDomainStartupPolicy)
3385

3386 3387
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3388 3389
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3390 3391 3392 3393 3394
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3395 3396 3397 3398
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3399

3400 3401
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3402 3403
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3404 3405
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3406

3407 3408
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);

3409 3410
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3411 3412 3413 3414 3415
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3416 3417 3418 3419 3420 3421 3422
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
3423
                            const char *stateDir,
3424 3425 3426
                            const char *configDir,
                            unsigned int flags);

3427 3428 3429 3430 3431 3432 3433 3434
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3435 3436 3437
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3438 3439
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3440
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3441

3442 3443 3444 3445 3446 3447 3448
int virDomainStorageSourceFormat(virBufferPtr attrBuf,
                                 virBufferPtr childBuf,
                                 virStorageSourcePtr src,
                                 unsigned int flags,
                                 bool skipSeclabels)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3449 3450 3451 3452 3453 3454 3455 3456
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;

3457 3458
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

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

3461 3462 3463 3464 3465
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3466

3467 3468 3469
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3470 3471 3472 3473 3474
char *
virDomainGenerateMachineName(const char *drivername,
                             int id,
                             const char *name,
                             bool privileged);
3475 3476 3477

bool
virDomainNetTypeSharesHostView(const virDomainNetDef *net);
3478

3479 3480 3481 3482
bool
virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
                                   virDomainLifecycleAction action);

3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494
typedef int
(*virDomainNetAllocateActualDeviceImpl)(virDomainDefPtr dom,
                                        virDomainNetDefPtr iface);

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

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

3495 3496 3497 3498 3499 3500 3501 3502 3503
typedef bool
(*virDomainNetBandwidthChangeAllowedImpl)(virDomainNetDefPtr iface,
                                          virNetDevBandwidthPtr newBandwidth);

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


3504 3505 3506
void
virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate,
                          virDomainNetNotifyActualDeviceImpl notify,
3507 3508
                          virDomainNetReleaseActualDeviceImpl release,
                          virDomainNetBandwidthChangeAllowedImpl bandwidthChangeAllowed,
3509
                          virDomainNetBandwidthUpdateImpl bandwidthUpdate);
3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525

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

3526 3527 3528 3529 3530 3531 3532 3533 3534
bool
virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface,
                              virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

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

3536 3537 3538 3539
int
virDomainNetResolveActualType(virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1);

3540

3541
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
3542

3543 3544 3545
int
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                 virDomainDiskDetectZeroes detect_zeroes);
3546

3547
#endif /* __DOMAIN_CONF_H */