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

23 24
#ifndef LIBVIRT_DOMAIN_CONF_H
# define LIBVIRT_DOMAIN_CONF_H
25

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

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

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
/* 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 已提交
80
    VIR_DOMAIN_DEVICE_NVRAM,
81
    VIR_DOMAIN_DEVICE_RNG,
82
    VIR_DOMAIN_DEVICE_SHMEM,
83
    VIR_DOMAIN_DEVICE_TPM,
84
    VIR_DOMAIN_DEVICE_PANIC,
85
    VIR_DOMAIN_DEVICE_MEMORY,
J
Ján Tomko 已提交
86
    VIR_DOMAIN_DEVICE_IOMMU,
J
Ján Tomko 已提交
87
    VIR_DOMAIN_DEVICE_VSOCK,
88

89
    VIR_DOMAIN_DEVICE_LAST
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
} virDomainDeviceType;

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 已提交
111
        virDomainNVRAMDefPtr nvram;
112
        virDomainRNGDefPtr rng;
113
        virDomainShmemDefPtr shmem;
114
        virDomainTPMDefPtr tpm;
115
        virDomainPanicDefPtr panic;
116
        virDomainMemoryDefPtr memory;
J
Ján Tomko 已提交
117
        virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
118
        virDomainVsockDefPtr vsock;
119 120 121
    } data;
};

122 123
/* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */
124
typedef enum {
125
    VIR_DOMAIN_VIRT_NONE = 0,
126 127 128 129 130 131 132 133 134 135
    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,
136
    VIR_DOMAIN_VIRT_VBOX,
137
    VIR_DOMAIN_VIRT_PHYP,
D
Dmitry Guryanov 已提交
138
    VIR_DOMAIN_VIRT_PARALLELS,
R
Roman Bogorodskiy 已提交
139
    VIR_DOMAIN_VIRT_BHYVE,
140
    VIR_DOMAIN_VIRT_VZ,
141

142
    VIR_DOMAIN_VIRT_LAST
143
} virDomainVirtType;
144

145 146 147 148 149 150
typedef enum {
    VIR_DOMAIN_OSTYPE_HVM,
    VIR_DOMAIN_OSTYPE_XEN,
    VIR_DOMAIN_OSTYPE_LINUX,
    VIR_DOMAIN_OSTYPE_EXE,
    VIR_DOMAIN_OSTYPE_UML,
151
    VIR_DOMAIN_OSTYPE_XENPVH,
152 153 154

    VIR_DOMAIN_OSTYPE_LAST
} virDomainOSType;
155
VIR_ENUM_DECL(virDomainOS);
156 157


158 159 160 161 162 163
struct _virDomainHostdevOrigStates {
    union {
        struct {
            /* Does the device need to unbind from stub when
             * reattaching to host?
             */
164
            bool unbind_from_stub;
165 166 167 168

            /* Does it need to use remove_slot when reattaching
             * the device to host?
             */
169
            bool remove_slot;
170 171 172 173

            /* Does it need to reprobe driver for the device when
             * reattaching to host?
             */
174
            bool reprobe;
175 176 177 178 179 180
        } pci;

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

181 182 183 184 185 186 187
struct _virDomainLeaseDef {
    char *lockspace;
    char *key;
    char *path;
    unsigned long long offset;
};

188

189
typedef enum {
190 191 192
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

193
    VIR_DOMAIN_HOSTDEV_MODE_LAST
194
} virDomainHostdevMode;
195

196
typedef enum {
197 198
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
H
Han Cheng 已提交
199
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
200
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST,
201
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV,
202 203

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
204
} virDomainHostdevSubsysType;
205

206 207
/* the backend driver used for PCI hostdev devices */
typedef enum {
N
Nitesh Konkar 已提交
208
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automatically, prefer VFIO */
209 210
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM,    /* force legacy kvm style */
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO,   /* force vfio */
211
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN,    /* force legacy xen style, use pciback */
212 213

    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
214
} virDomainHostdevSubsysPCIBackendType;
215

216
VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend);
217

218 219 220 221 222 223 224
typedef enum {
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE,
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI,

    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
} virDomainHostdevSCSIProtocolType;

225
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol);
226

227 228 229 230 231 232 233 234 235 236
struct _virDomainHostdevSubsysUSB {
    bool autoAddress; /* bus/device were filled automatically based
                         on vendor/product */
    unsigned bus;
    unsigned device;

    unsigned vendor;
    unsigned product;
};

237
struct _virDomainHostdevSubsysPCI {
238
    virPCIDeviceAddress addr; /* host address */
239 240 241
    int backend; /* enum virDomainHostdevSubsysPCIBackendType */
};

242
struct _virDomainHostdevSubsysSCSIHost {
243 244 245
    char *adapter;
    unsigned bus;
    unsigned target;
246
    unsigned long long unit;
247 248
};

249
struct _virDomainHostdevSubsysSCSIiSCSI {
250
    virStorageSourcePtr src;
251 252
};

253
struct _virDomainHostdevSubsysSCSI {
254
    int protocol; /* enum virDomainHostdevSCSIProtocolType */
255
    int sgio; /* enum virDomainDeviceSGIO */
256
    int rawio; /* enum virTristateBool */
257 258
    union {
        virDomainHostdevSubsysSCSIHost host;
259
        virDomainHostdevSubsysSCSIiSCSI iscsi;
260
    } u;
261 262
};

263 264
struct _virDomainHostdevSubsysMediatedDev {
    int model;                          /* enum virMediatedDeviceModelType */
265
    int display; /* virTristateSwitch */
266 267 268
    char uuidstr[VIR_UUID_STRING_BUFLEN];   /* mediated device's uuid string */
};

269 270 271 272 273 274 275
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;

276
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIHostProtocol);
277

278 279 280 281 282 283 284 285 286 287 288
typedef enum {
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_DEFAULT,
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO,
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_LAST,
} virDomainHostdevSubsysSCSIVHostModelType;

VIR_ENUM_DECL(virDomainHostdevSubsysSCSIVHostModel);

289 290 291
struct _virDomainHostdevSubsysSCSIVHost {
    int protocol; /* enum virDomainHostdevSubsysSCSIHostProtocolType */
    char *wwpn;
292
    int model; /* enum virDomainHostdevSubsysSCSIVHostModelType */
293 294
};

295
struct _virDomainHostdevSubsys {
296
    int type; /* enum virDomainHostdevSubsysType */
297
    union {
298
        virDomainHostdevSubsysUSB usb;
299
        virDomainHostdevSubsysPCI pci;
300
        virDomainHostdevSubsysSCSI scsi;
301
        virDomainHostdevSubsysSCSIVHost scsi_host;
302
        virDomainHostdevSubsysMediatedDev mdev;
303 304 305
    } u;
};

306

307
typedef enum {
308 309
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
310
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
311 312

    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
313
} virDomainHostdevCapsType;
314 315 316 317 318 319 320 321 322 323

struct _virDomainHostdevCaps {
    int type; /* enum virDOmainHostdevCapsType */
    union {
        struct {
            char *block;
        } storage;
        struct {
            char *chardev;
        } misc;
324
        struct {
325 326
            char *ifname;
            virNetDevIPInfo ip;
327
        } net;
328 329 330 331
    } u;
};


332 333
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
334 335 336 337 338 339 340
    /* If 'parentnet' is non-NULL it means this host dev was
     * not originally present in the XML. It was copied from
     * a network interface for convenience when handling
     * hostdevs internally. This hostdev should never be
     * visible to the user except as part of the interface
     */
    virDomainNetDefPtr parentnet;
341

342
    int mode; /* enum virDomainHostdevMode */
343
    int startupPolicy; /* enum virDomainStartupPolicy */
344
    bool managed;
345
    bool missing;
O
Osier Yang 已提交
346
    bool readonly;
347
    bool shareable;
348
    union {
349
        virDomainHostdevSubsys subsys;
350
        virDomainHostdevCaps caps;
351 352
    } source;
    virDomainHostdevOrigStates origstates;
353
    virDomainDeviceInfoPtr info; /* Guest address */
354 355
};

356

E
Eric Blake 已提交
357 358
/* Types of disk frontend (guest view).  For backends (host view), see
 * virStorageType in util/virstoragefile.h */
359
typedef enum {
360 361 362
    VIR_DOMAIN_DISK_DEVICE_DISK,
    VIR_DOMAIN_DISK_DEVICE_CDROM,
    VIR_DOMAIN_DISK_DEVICE_FLOPPY,
363
    VIR_DOMAIN_DISK_DEVICE_LUN,
364 365

    VIR_DOMAIN_DISK_DEVICE_LAST
366
} virDomainDiskDevice;
367

368
typedef enum {
369 370 371 372 373
    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,
374
    VIR_DOMAIN_DISK_BUS_USB,
375
    VIR_DOMAIN_DISK_BUS_UML,
376
    VIR_DOMAIN_DISK_BUS_SATA,
377
    VIR_DOMAIN_DISK_BUS_SD,
378 379

    VIR_DOMAIN_DISK_BUS_LAST
380
} virDomainDiskBus;
381

382
typedef enum {
383 384 385 386
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
387
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
388
    VIR_DOMAIN_DISK_CACHE_UNSAFE,
389 390

    VIR_DOMAIN_DISK_CACHE_LAST
391
} virDomainDiskCache;
392

393
typedef enum {
394 395
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
396
    VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
397
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
398
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
399 400

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
401
} virDomainDiskErrorPolicy;
402

M
MORITA Kazutaka 已提交
403

404
typedef enum {
405
    VIR_DOMAIN_DISK_TRAY_CLOSED = 0,
406 407 408
    VIR_DOMAIN_DISK_TRAY_OPEN,

    VIR_DOMAIN_DISK_TRAY_LAST
409
} virDomainDiskTray;
410

411
typedef enum {
J
J.B. Joret 已提交
412 413 414 415 416 417
    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
418
} virDomainDiskGeometryTrans;
J
J.B. Joret 已提交
419

420
typedef enum {
421
    VIR_DOMAIN_DISK_IO_DEFAULT = 0,
M
Matthias Dahl 已提交
422 423 424 425
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
426
} virDomainDiskIo;
M
Matthias Dahl 已提交
427

428
typedef enum {
429 430 431 432 433 434
    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
435
} virDomainStartupPolicy;
436

437

438
typedef enum {
439 440 441
    VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
    VIR_DOMAIN_DEVICE_SGIO_FILTERED,
    VIR_DOMAIN_DEVICE_SGIO_UNFILTERED,
O
Osier Yang 已提交
442

443
    VIR_DOMAIN_DEVICE_SGIO_LAST
444
} virDomainDeviceSGIO;
O
Osier Yang 已提交
445

446
typedef enum {
O
Osier Yang 已提交
447
    VIR_DOMAIN_DISK_DISCARD_DEFAULT = 0,
O
Osier Yang 已提交
448 449
    VIR_DOMAIN_DISK_DISCARD_UNMAP,
    VIR_DOMAIN_DISK_DISCARD_IGNORE,
O
Osier Yang 已提交
450 451

    VIR_DOMAIN_DISK_DISCARD_LAST
452
} virDomainDiskDiscard;
O
Osier Yang 已提交
453

454 455 456 457 458 459 460 461 462
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;

463 464 465 466 467 468 469 470 471
typedef enum {
    VIR_DOMAIN_DISK_MODEL_DEFAULT = 0,
    VIR_DOMAIN_DISK_MODEL_VIRTIO,
    VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_DISK_MODEL_LAST
} virDomainDiskModel;

L
Lei Li 已提交
472 473 474 475 476 477 478
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;
479 480 481 482 483 484 485
    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;
486
    char *group_name;
487 488 489 490 491 492
    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 已提交
493 494
};

495

496 497 498 499 500 501 502 503 504
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;

505 506 507 508
typedef enum {
    VIR_DOMAIN_MEMORY_SOURCE_NONE = 0,  /* No memory source defined */
    VIR_DOMAIN_MEMORY_SOURCE_FILE,      /* Memory source is set as file */
    VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS, /* Memory source is set as anonymous */
M
Marc-André Lureau 已提交
509
    VIR_DOMAIN_MEMORY_SOURCE_MEMFD,     /* Memory source is set as memfd */
510 511 512 513 514 515 516 517 518 519 520 521

    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;

522

523 524
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
525
    virStorageSourcePtr src; /* non-NULL.  XXX Allow NULL for empty cdrom? */
526

527 528
    virObjectPtr privateData;

529 530 531 532
    int device; /* enum virDomainDiskDevice */
    int bus; /* enum virDomainDiskBus */
    char *dst;
    int tray_status; /* enum virDomainDiskTray */
J
Ján Tomko 已提交
533
    int removable; /* enum virTristateSwitch */
L
Lei Li 已提交
534

535
    virStorageSourcePtr mirror;
536
    int mirrorState; /* enum virDomainDiskMirrorState */
E
Eric Blake 已提交
537
    int mirrorJob; /* virDomainBlockJobType */
538

J
J.B. Joret 已提交
539 540 541 542
    struct {
        unsigned int cylinders;
        unsigned int heads;
        unsigned int sectors;
543
        int trans; /* enum virDomainDiskGeometryTrans */
J
J.B. Joret 已提交
544 545
    } geometry;

546 547 548
    struct {
        unsigned int logical_block_size;
        unsigned int physical_block_size;
V
Viktor Mihajlovski 已提交
549
    } blockio;
550

L
Lei Li 已提交
551 552
    virDomainBlockIoTuneInfo blkdeviotune;

553 554
    char *driverName;

555
    char *serial;
O
Osier Yang 已提交
556
    char *wwn;
557 558
    char *vendor;
    char *product;
559
    int cachemode; /* enum virDomainDiskCache */
560 561
    int error_policy;  /* enum virDomainDiskErrorPolicy */
    int rerror_policy; /* enum virDomainDiskErrorPolicy */
562
    int iomode; /* enum virDomainDiskIo */
J
Ján Tomko 已提交
563 564 565
    int ioeventfd; /* enum virTristateSwitch */
    int event_idx; /* enum virTristateSwitch */
    int copy_on_read; /* enum virTristateSwitch */
566
    int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
567
    int startupPolicy; /* enum virDomainStartupPolicy */
568
    bool transient;
569
    virDomainDeviceInfo info;
570
    int rawio; /* enum virTristateBool */
571
    int sgio; /* enum virDomainDeviceSGIO */
O
Osier Yang 已提交
572
    int discard; /* enum virDomainDiskDiscard */
573
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
574
    int detect_zeroes; /* enum virDomainDiskDetectZeroes */
575
    char *domain_name; /* backend domain name */
L
Lin Ma 已提交
576
    unsigned int queues;
577
    int model; /* enum virDomainDiskModel */
J
Ján Tomko 已提交
578
    virDomainVirtioOptionsPtr virtio;
579 580 581
};


582
typedef enum {
583 584 585 586
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
587
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
588
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
589
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
J
Ján Tomko 已提交
590
    VIR_DOMAIN_CONTROLLER_TYPE_PCI,
591
    VIR_DOMAIN_CONTROLLER_TYPE_XENBUS,
592 593

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
594
} virDomainControllerType;
595

596

597
typedef enum {
598
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT = -1,
J
Ján Tomko 已提交
599
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
L
Laine Stump 已提交
600
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
J
Ján Tomko 已提交
601
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
602
    VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
603
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE,
604
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT,
605
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT,
606
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT,
607
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS,
608
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS,
J
Ján Tomko 已提交
609 610

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
611
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
612

613
typedef enum {
614
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE = 0,
615 616
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE,
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE,
617
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420,
618
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM,
619
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM,
620
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB,
621
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE,
622
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT,
623
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE,
624
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_PCI_BRIDGE,
625 626 627 628

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

629
typedef enum {
630
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT = -1,
631 632 633 634 635
    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,
636
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
637
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
638
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
639 640
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL,
641

642
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
643
} virDomainControllerModelSCSI;
644

645
typedef enum {
646
    VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT = -1,
M
Marc-André Lureau 已提交
647 648 649 650 651 652 653 654 655
    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 已提交
656
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
657 658
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2,
659
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI,
660
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
M
Marc-André Lureau 已提交
661 662

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
663
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
664

665
typedef enum {
666
    VIR_DOMAIN_CONTROLLER_MODEL_IDE_DEFAULT = -1,
667 668 669 670 671 672 673
    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;

674 675 676 677 678 679 680 681 682
typedef enum {
    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_DEFAULT = -1,
    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO,
    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_LAST
} virDomainControllerModelVirtioSerial;

683 684 685 686 687 688 689
# 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))

690 691 692 693 694
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

695
struct _virDomainPCIControllerOpts {
696 697
    bool pcihole64;
    unsigned long pcihole64size;
698 699 700 701 702 703 704

    /* 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 */
705 706 707 708 709 710 711 712

    /* 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 */
713 714 715 716
    /* chassis & port used by
     * pcie-root-port/pcie-switch-downstream-port, -1 = unspecified */
    int chassis;
    int port;
717
    int busNr; /* used by pci-expander-bus, -1 == unspecified */
718
    int targetIndex; /* used by spapr-pci-host-bridge, -1 == unspecified */
719 720 721 722
    /* numaNode is a *subelement* of target (to match existing
     * item in memory target config) -1 == unspecified
     */
    int numaNode;
723
};
724

725 726 727 728
struct _virDomainUSBControllerOpts {
    int ports;   /* -1 == undef */
};

729 730 731 732
struct _virDomainXenbusControllerOpts {
    int maxGrantFrames;   /* -1 == undef */
};

733 734 735
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
    int type;
736
    int idx;
737
    int model; /* -1 == undef */
738
    unsigned int queues;
739 740
    unsigned int cmd_per_lun;
    unsigned int max_sectors;
741
    int ioeventfd; /* enum virTristateSwitch */
742
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
743 744
    union {
        virDomainVirtioSerialOpts vioserial;
745
        virDomainPCIControllerOpts pciopts;
746
        virDomainUSBControllerOpts usbopts;
747
        virDomainXenbusControllerOpts xenbusopts;
748
    } opts;
749
    virDomainDeviceInfo info;
750
    virDomainVirtioOptionsPtr virtio;
751 752 753
};


G
Giuseppe Scrivano 已提交
754
/* Types of disk backends */
755
typedef enum {
756 757 758 759 760 761
    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 */
762
    VIR_DOMAIN_FS_TYPE_VOLUME, /* Mounts storage pool volume to a guest */
763 764

    VIR_DOMAIN_FS_TYPE_LAST
765
} virDomainFSType;
766

767
/* Filesystem driver type */
768
typedef enum {
769 770 771
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
772
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
773
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
D
Dmitry Guryanov 已提交
774
    VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
775 776

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
777
} virDomainFSDriverType;
778

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

    VIR_DOMAIN_FS_ACCESSMODE_LAST
786
} virDomainFSAccessMode;
787

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

    VIR_DOMAIN_FS_WRPOLICY_LAST
794
} virDomainFSWrpolicy;
795

796 797 798 799 800 801 802 803 804
typedef enum {
    VIR_DOMAIN_FS_MODEL_DEFAULT = 0,
    VIR_DOMAIN_FS_MODEL_VIRTIO,
    VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_FS_MODEL_LAST
} virDomainFSModel;

805 806
struct _virDomainFSDef {
    int type;
807 808
    int fsdriver; /* enum virDomainFSDriverType */
    int accessmode; /* enum virDomainFSAccessMode */
809
    int wrpolicy; /* enum virDomainFSWrpolicy */
810
    int format; /* virStorageFileFormat */
811
    int model; /* virDomainFSModel */
812
    unsigned long long usage; /* in bytes */
813
    virStorageSourcePtr src;
814
    char *dst;
815
    bool readonly;
816
    virDomainDeviceInfo info;
817 818
    unsigned long long space_hard_limit; /* in bytes */
    unsigned long long space_soft_limit; /* in bytes */
819
    bool symlinksResolved;
820
    virDomainVirtioOptionsPtr virtio;
821 822 823
};


824
/* network config types */
825
typedef enum {
826 827
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
M
Michele Paolino 已提交
828
    VIR_DOMAIN_NET_TYPE_VHOSTUSER,
829 830 831 832 833
    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 已提交
834
    VIR_DOMAIN_NET_TYPE_INTERNAL,
835
    VIR_DOMAIN_NET_TYPE_DIRECT,
836
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
837
    VIR_DOMAIN_NET_TYPE_UDP,
838

839
    VIR_DOMAIN_NET_TYPE_LAST
840
} virDomainNetType;
841

842 843 844 845
/* network model types */
typedef enum {
    VIR_DOMAIN_NET_MODEL_UNKNOWN,
    VIR_DOMAIN_NET_MODEL_NETFRONT,
C
Cole Robinson 已提交
846 847 848
    VIR_DOMAIN_NET_MODEL_RTL8139,
    VIR_DOMAIN_NET_MODEL_VIRTIO,
    VIR_DOMAIN_NET_MODEL_E1000,
849 850 851 852

    VIR_DOMAIN_NET_MODEL_LAST
} virDomainNetModelType;

853
/* the backend driver used for virtio interfaces */
854
typedef enum {
855 856 857 858
    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 */

859
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
860
} virDomainNetBackendType;
861

862
/* the TX algorithm used for virtio interfaces */
863
typedef enum {
864 865 866 867
    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,

868
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
869
} virDomainNetVirtioTxModeType;
870

871
/* link interface states */
872
typedef enum {
873 874 875 876 877
        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
878
} virDomainNetInterfaceLinkState;
879

880 881 882 883 884 885 886 887 888 889
/* 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.
 */
struct _virDomainActualNetDef {
    int type; /* enum virDomainNetType */
    union {
        struct {
            char *brname;
890
            int macTableManager; /* enum virNetworkBridgeMACTableManagerType */
891 892 893 894 895
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
        } direct;
896 897 898
        struct {
            virDomainHostdevDef def;
        } hostdev;
899
    } data;
900
    virNetDevVPortProfilePtr virtPortProfile;
901
    virNetDevBandwidthPtr bandwidth;
902
    virNetDevVlan vlan;
903
    int trustGuestRxFilters; /* enum virTristateBool */
904
    unsigned int class_id; /* class ID for bandwidth 'floor' */
905 906
};

907 908
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
909
    virDomainNetType type;
910
    virMacAddr mac;
911
    bool mac_generated; /* true if mac was *just now* auto-generated by libvirt */
912
    int model; /* virDomainNetModelType */
913
    char *modelstr;
914 915
    union {
        struct {
916 917
            virDomainNetBackendType name; /* which driver backend to use */
            virDomainNetVirtioTxModeType txmode;
J
Ján Tomko 已提交
918 919
            virTristateSwitch ioeventfd;
            virTristateSwitch event_idx;
920
            unsigned int queues; /* Multiqueue virtio-net */
921
            unsigned int rx_queue_size;
922
            unsigned int tx_queue_size;
923 924 925 926 927 928 929
            struct {
                virTristateSwitch csum;
                virTristateSwitch gso;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
930
                virTristateSwitch mrg_rxbuf;
931 932 933 934 935 936 937 938
            } host;
            struct {
                virTristateSwitch csum;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
            } guest;
939 940
        } virtio;
    } driver;
941 942 943 944
    struct {
        char *tap;
        char *vhost;
    } backend;
945
    union {
M
Michele Paolino 已提交
946
        virDomainChrSourceDefPtr vhostuser;
947 948 949
        struct {
            char *address;
            int port;
950 951
            char *localaddr;
            int localport;
952 953 954
        } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
        struct {
            char *name;
955 956 957 958 959 960 961 962 963 964
            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;
965 966 967 968
        } network;
        struct {
            char *brname;
        } bridge;
D
Daniel Veillard 已提交
969 970 971
        struct {
            char *name;
        } internal;
972 973
        struct {
            char *linkdev;
974
            int mode; /* enum virMacvtapMode from util/macvtap.h */
975
        } direct;
976 977 978
        struct {
            virDomainHostdevDef def;
        } hostdev;
979
    } data;
980 981
    /* virtPortProfile is used by network/bridge/direct/hostdev */
    virNetDevVPortProfilePtr virtPortProfile;
982 983 984 985
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
986
    char *script;
987
    char *domain_name; /* backend domain name */
988 989
    char *ifname; /* interface name on the host (<target dev='x'/>) */
    virNetDevIPInfo hostIP;
990
    char *ifname_guest_actual;
991 992
    char *ifname_guest;
    virNetDevIPInfo guestIP;
993
    virDomainDeviceInfo info;
994
    char *filter;
995
    virHashTablePtr filterparams;
996
    virNetDevBandwidthPtr bandwidth;
997
    virNetDevVlan vlan;
998
    int trustGuestRxFilters; /* enum virTristateBool */
999
    int linkstate;
1000
    unsigned int mtu;
1001
    virNetDevCoalescePtr coalesce;
1002
    virDomainVirtioOptionsPtr virtio;
1003 1004
};

1005 1006 1007 1008 1009 1010 1011 1012
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;

1013
VIR_ENUM_DECL(virDomainChrDeviceState);
1014

1015
typedef enum {
1016
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1017 1018
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1019
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1020

1021
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1022
} virDomainChrDeviceType;
1023

1024
typedef enum {
1025 1026
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
G
Guannan Ren 已提交
1027
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
M
Michal Privoznik 已提交
1028
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
1029
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
1030
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
1031
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP,
G
Guannan Ren 已提交
1032 1033

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1034
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1035

1036
typedef enum {
1037 1038
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
1039
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
J
Joao Martins 已提交
1040
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN,
1041

1042
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1043
} virDomainChrChannelTargetType;
1044

1045
typedef enum {
1046 1047
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
1048 1049
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
1050
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
1051 1052
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
1053 1054
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
1055

1056
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1057
} virDomainChrConsoleTargetType;
1058

1059 1060 1061 1062 1063
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,
1064
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
1065
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011,
1066 1067
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE,
1068
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A,
1069 1070 1071 1072 1073 1074

    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
} virDomainChrSerialTargetModel;

VIR_ENUM_DECL(virDomainChrSerialTargetModel);

1075
typedef enum {
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
    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,
1086
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1087
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1088
    VIR_DOMAIN_CHR_TYPE_NMDM,
1089

1090
    VIR_DOMAIN_CHR_TYPE_LAST
1091
} virDomainChrType;
1092

1093
typedef enum {
1094
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW = 0,
1095
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1096 1097
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1098

1099
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1100
} virDomainChrTcpProtocol;
1101

1102
typedef enum {
E
Eric Blake 已提交
1103 1104
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1105
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1106

1107
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1108
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1109

1110 1111 1112 1113 1114 1115 1116

struct _virDomainChrSourceReconnectDef {
    virTristateBool enabled;
    unsigned int timeout;
};


1117 1118
/* The host side information for a character device.  */
struct _virDomainChrSourceDef {
1119
    virObject parent;
1120
    int type; /* virDomainChrType */
1121
    virObjectPtr privateData;
1122
    union {
E
Eric Blake 已提交
1123
        /* no <source> for null, vc, stdio */
1124 1125
        struct {
            char *path;
1126
            int append; /* enum virTristateSwitch */
1127
        } file; /* pty, file, pipe, or device */
1128 1129 1130 1131
        struct {
            char *master;
            char *slave;
        } nmdm;
1132 1133 1134
        struct {
            char *host;
            char *service;
1135
            bool listen;
1136
            int protocol;
1137
            bool tlscreds;
1138
            int haveTLS; /* enum virTristateBool */
1139
            bool tlsFromConfig;
1140
            virDomainChrSourceReconnectDef reconnect;
1141 1142 1143 1144 1145 1146 1147 1148 1149
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
1150
            bool listen;
1151
            virDomainChrSourceReconnectDef reconnect;
1152
        } nix;
E
Eric Blake 已提交
1153
        int spicevmc;
1154 1155 1156
        struct {
            char *channel;
        } spiceport;
1157
    } data;
1158 1159
    char *logfile;
    int logappend;
1160 1161 1162

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1163 1164 1165 1166
};

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

1169 1170 1171
    int targetType; /* enum virDomainChrConsoleTargetType ||
                       enum virDomainChrChannelTargetType ||
                       enum virDomainChrSerialTargetType according to deviceType */
1172
    int targetModel; /* enum virDomainChrSerialTargetModel */
1173

1174 1175 1176 1177 1178 1179
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

1180 1181
    virDomainChrDeviceState state;

1182
    virDomainChrSourceDefPtr source;
1183 1184

    virDomainDeviceInfo info;
1185 1186
};

1187
typedef enum {
E
Eric Blake 已提交
1188 1189 1190 1191
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

1192
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1193
} virDomainSmartcardType;
E
Eric Blake 已提交
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205

# 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' */
1206
        virDomainChrSourceDefPtr passthru; /* 'passthrough' */
E
Eric Blake 已提交
1207 1208 1209 1210 1211
    } data;

    virDomainDeviceInfo info;
};

M
Marc-André Lureau 已提交
1212 1213 1214 1215 1216
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

1217
typedef enum {
1218
    VIR_DOMAIN_TPM_MODEL_TIS,
1219
    VIR_DOMAIN_TPM_MODEL_CRB,
1220 1221

    VIR_DOMAIN_TPM_MODEL_LAST
1222
} virDomainTPMModel;
1223

1224
typedef enum {
1225
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
1226
    VIR_DOMAIN_TPM_TYPE_EMULATOR,
1227 1228

    VIR_DOMAIN_TPM_TYPE_LAST
1229
} virDomainTPMBackendType;
1230

1231 1232 1233 1234 1235 1236 1237 1238
typedef enum {
    VIR_DOMAIN_TPM_VERSION_DEFAULT,
    VIR_DOMAIN_TPM_VERSION_1_2,
    VIR_DOMAIN_TPM_VERSION_2_0,

    VIR_DOMAIN_TPM_VERSION_LAST
} virDomainTPMVersion;

1239 1240 1241
# define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"

struct _virDomainTPMDef {
1242
    int type; /* virDomainTPMBackendType */
1243
    virDomainDeviceInfo info;
1244 1245
    int model; /* virDomainTPMModel */
    int version; /* virDomainTPMVersion */
1246 1247 1248 1249
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
1250 1251 1252 1253 1254
        struct {
            virDomainChrSourceDef source;
            char *storagepath;
            char *logfile;
        } emulator;
1255 1256 1257
    } data;
};

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

1264
    VIR_DOMAIN_INPUT_TYPE_LAST
1265
} virDomainInputType;
1266

1267
typedef enum {
1268 1269 1270
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1271
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1272
    VIR_DOMAIN_INPUT_BUS_VIRTIO,
1273 1274

    VIR_DOMAIN_INPUT_BUS_LAST
1275
} virDomainInputBus;
1276

1277 1278 1279 1280 1281 1282 1283 1284 1285
typedef enum {
    VIR_DOMAIN_INPUT_MODEL_DEFAULT = 0,
    VIR_DOMAIN_INPUT_MODEL_VIRTIO,
    VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL,

    VIR_DOMAIN_INPUT_MODEL_LAST
} virDomainInputModel;

1286 1287 1288
struct _virDomainInputDef {
    int type;
    int bus;
1289
    int model; /* virDomainInputModel */
1290 1291 1292
    struct {
        char *evdev;
    } source;
1293
    virDomainDeviceInfo info;
1294
    virDomainVirtioOptionsPtr virtio;
1295 1296
};

1297
typedef enum {
1298 1299
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,
F
Filip Alac 已提交
1300
    VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT,
1301 1302

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1303
} virDomainSoundCodecType;
1304

1305
typedef enum {
1306 1307 1308
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1309
    VIR_DOMAIN_SOUND_MODEL_AC97,
1310
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1311
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1312
    VIR_DOMAIN_SOUND_MODEL_USB,
1313 1314

    VIR_DOMAIN_SOUND_MODEL_LAST
1315
} virDomainSoundModel;
1316

1317 1318 1319 1320 1321
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1322 1323
struct _virDomainSoundDef {
    int model;
1324
    virDomainDeviceInfo info;
1325

1326
    size_t ncodecs;
1327
    virDomainSoundCodecDefPtr *codecs;
1328 1329
};

1330
typedef enum {
R
Richard Jones 已提交
1331 1332
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,
1333
    VIR_DOMAIN_WATCHDOG_MODEL_DIAG288,
R
Richard Jones 已提交
1334 1335

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1336
} virDomainWatchdogModel;
R
Richard Jones 已提交
1337

1338
typedef enum {
R
Richard Jones 已提交
1339 1340 1341 1342
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1343
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1344
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,
1345
    VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI,
R
Richard Jones 已提交
1346 1347

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1348
} virDomainWatchdogAction;
R
Richard Jones 已提交
1349 1350 1351 1352

struct _virDomainWatchdogDef {
    int model;
    int action;
1353
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1354 1355
};

1356

1357
typedef enum {
1358
    VIR_DOMAIN_VIDEO_TYPE_DEFAULT,
1359 1360 1361 1362 1363
    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,
1364
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1365
    VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
M
Marc-André Lureau 已提交
1366
    VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
F
Fabian Freyer 已提交
1367
    VIR_DOMAIN_VIDEO_TYPE_GOP,
1368
    VIR_DOMAIN_VIDEO_TYPE_NONE,
1369 1370

    VIR_DOMAIN_VIDEO_TYPE_LAST
1371
} virDomainVideoType;
1372 1373


1374 1375 1376 1377 1378 1379 1380 1381
typedef enum {
    VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
    VIR_DOMAIN_VIDEO_VGACONF_ON,
    VIR_DOMAIN_VIDEO_VGACONF_OFF,

    VIR_DOMAIN_VIDEO_VGACONF_LAST
} virDomainVideoVGAConf;

1382
VIR_ENUM_DECL(virDomainVideoVGAConf);
1383

1384
struct _virDomainVideoAccelDef {
1385 1386
    int accel2d; /* enum virTristateBool */
    int accel3d; /* enum virTristateBool */
1387 1388 1389
};


1390 1391 1392 1393
struct _virDomainVideoDriverDef {
   virDomainVideoVGAConf vgaconf;
};

1394
struct _virDomainVideoDef {
1395
    int type;   /* enum virDomainVideoType */
1396 1397
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1398
    unsigned int vram64; /* kibibytes (multiples of 1024) */
1399
    unsigned int vgamem; /* kibibytes (multiples of 1024) */
1400
    unsigned int heads;
1401
    bool primary;
1402
    virDomainVideoAccelDefPtr accel;
1403
    virDomainVideoDriverDefPtr driver;
1404
    virDomainDeviceInfo info;
J
Ján Tomko 已提交
1405
    virDomainVirtioOptionsPtr virtio;
1406 1407
};

1408
/* graphics console modes */
1409
typedef enum {
1410 1411
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1412 1413
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1414
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1415
    VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS,
1416

1417
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1418
} virDomainGraphicsType;
1419

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

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

1438 1439
struct _virDomainGraphicsAuthDef {
    char *passwd;
1440
    bool expires; /* Whether there is an expiry time set */
1441
    time_t validTo;  /* seconds since epoch */
1442
    int connected; /* action if connected */
1443 1444
};

1445
typedef enum {
1446 1447 1448 1449 1450 1451
    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 已提交
1452
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1453
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1454 1455

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1456
} virDomainGraphicsSpiceChannelName;
1457

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

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

1478
typedef enum {
1479 1480 1481 1482 1483 1484
    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
1485
} virDomainGraphicsSpiceJpegCompression;
1486

1487
typedef enum {
1488 1489 1490 1491 1492 1493
    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
1494
} virDomainGraphicsSpiceZlibCompression;
1495

1496
typedef enum {
P
Peng Zhou 已提交
1497 1498 1499 1500 1501
    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
1502
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1503

1504
typedef enum {
1505 1506 1507 1508 1509 1510
    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
1511
} virDomainGraphicsSpiceStreamingMode;
1512

1513
typedef enum {
1514 1515 1516
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1517
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1518

1519
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1520
} virDomainGraphicsListenType;
1521

1522
typedef enum {
M
Marc-André Lureau 已提交
1523 1524
    VIR_DOMAIN_HUB_TYPE_USB,

1525
    VIR_DOMAIN_HUB_TYPE_LAST
1526
} virDomainHubType;
M
Marc-André Lureau 已提交
1527

1528
struct _virDomainGraphicsListenDef {
1529
    virDomainGraphicsListenType type;
1530 1531
    char *address;
    char *network;
1532
    char *socket;
1533
    bool fromConfig;    /* true if the @address is config file originated */
1534
    bool autoGenerated;
1535 1536
};

1537
struct _virDomainGraphicsDef {
1538 1539
    virObjectPtr privateData;

M
Michal Privoznik 已提交
1540 1541 1542 1543 1544
    /* 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.
     */
1545
    virDomainGraphicsType type;
1546 1547 1548
    union {
        struct {
            int port;
1549
            bool portReserved;
M
Martin Kletzander 已提交
1550
            int websocket;
1551
            bool websocketGenerated;
1552
            bool autoport;
1553
            char *keymap;
1554
            virDomainGraphicsAuthDef auth;
1555
            int sharePolicy;
1556 1557 1558 1559
        } vnc;
        struct {
            char *display;
            char *xauth;
1560
            bool fullscreen;
1561
            virTristateBool gl;
1562
        } sdl;
1563 1564
        struct {
            int port;
1565 1566 1567
            bool autoport;
            bool replaceUser;
            bool multiUser;
1568 1569 1570
        } rdp;
        struct {
            char *display;
1571
            bool fullscreen;
1572
        } desktop;
1573 1574 1575
        struct {
            int port;
            int tlsPort;
1576 1577
            bool portReserved;
            bool tlsPortReserved;
1578
            virDomainGraphicsSpiceMouseMode mousemode;
1579
            char *keymap;
1580
            virDomainGraphicsAuthDef auth;
1581
            bool autoport;
1582
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1583
            virDomainGraphicsSpiceChannelMode defaultMode;
1584 1585 1586 1587
            int image;
            int jpeg;
            int zlib;
            int playback;
1588
            int streaming;
1589 1590 1591
            virTristateBool copypaste;
            virTristateBool filetransfer;
            virTristateBool gl;
1592
            char *rendernode;
1593
        } spice;
1594 1595 1596
        struct {
            char *rendernode;
        } egl_headless;
1597
    } data;
1598 1599 1600 1601 1602
    /* 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;
1603 1604
};

1605
typedef enum {
1606 1607 1608
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1609
} virDomainRedirdevBus;
1610 1611 1612 1613

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

1614
    virDomainChrSourceDefPtr source;
1615 1616 1617

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

1619
struct _virDomainRedirFilterUSBDevDef {
1620 1621 1622 1623
    int usbClass;
    int vendor;
    int product;
    int version;
1624
    bool allow;
1625 1626 1627 1628
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1629
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1630 1631
};

1632
typedef enum {
1633 1634
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1635
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1636 1637
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL,
1638 1639

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1640
} virDomainMemballoonModel;
1641 1642 1643 1644

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1645
    int period; /* seconds between collections */
1646
    int autodeflate; /* enum virTristateSwitch */
1647
    virDomainVirtioOptionsPtr virtio;
1648 1649
};

L
Li Zhang 已提交
1650 1651 1652
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1653

1654 1655
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1656 1657
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1658 1659 1660 1661

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

1662 1663 1664
struct _virDomainShmemDef {
    char *name;
    unsigned long long size;
1665
    int model; /* enum virDomainShmemModel */
1666 1667
    struct {
        bool enabled;
1668
        virDomainChrSourceDef chr;
1669 1670 1671 1672 1673 1674 1675 1676 1677
    } server;
    struct {
        bool enabled;
        unsigned vectors;
        virTristateSwitch ioeventfd;
    } msi;
    virDomainDeviceInfo info;
};

1678
typedef enum {
1679
    VIR_DOMAIN_SMBIOS_NONE = 0,
1680 1681 1682 1683 1684
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1685
} virDomainSmbiosMode;
1686

1687

1688
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1689

1690
typedef enum {
1691 1692 1693 1694 1695
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1696
    VIR_DOMAIN_BOOT_LAST
1697
} virDomainBootOrder;
1698

1699
typedef enum {
1700 1701 1702
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1703
    VIR_DOMAIN_FEATURE_HAP,
1704
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1705
    VIR_DOMAIN_FEATURE_PRIVNET,
1706
    VIR_DOMAIN_FEATURE_HYPERV,
1707
    VIR_DOMAIN_FEATURE_KVM,
1708
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1709
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1710
    VIR_DOMAIN_FEATURE_PMU,
1711
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1712
    VIR_DOMAIN_FEATURE_GIC,
M
Michal Privoznik 已提交
1713
    VIR_DOMAIN_FEATURE_SMM,
1714
    VIR_DOMAIN_FEATURE_IOAPIC,
1715
    VIR_DOMAIN_FEATURE_HPT,
M
Marc-André Lureau 已提交
1716
    VIR_DOMAIN_FEATURE_VMCOREINFO,
1717
    VIR_DOMAIN_FEATURE_HTM,
1718
    VIR_DOMAIN_FEATURE_NESTED_HV,
1719
    VIR_DOMAIN_FEATURE_MSRS,
1720 1721

    VIR_DOMAIN_FEATURE_LAST
1722
} virDomainFeature;
1723

1724 1725
# define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12

1726
typedef enum {
1727
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1728 1729
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1730 1731 1732 1733 1734 1735
    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,
1736
    VIR_DOMAIN_HYPERV_FREQUENCIES,
1737
    VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
1738
    VIR_DOMAIN_HYPERV_TLBFLUSH,
1739
    VIR_DOMAIN_HYPERV_IPI,
1740
    VIR_DOMAIN_HYPERV_EVMCS,
1741 1742

    VIR_DOMAIN_HYPERV_LAST
1743
} virDomainHyperv;
1744

1745 1746 1747 1748 1749 1750
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763
typedef enum {
    VIR_DOMAIN_MSRS_UNKNOWN = 0,

    VIR_DOMAIN_MSRS_LAST
} virDomainMsrs;

typedef enum {
    VIR_DOMAIN_MSRS_UNKNOWN_IGNORE = 0,
    VIR_DOMAIN_MSRS_UNKNOWN_FAULT,

    VIR_DOMAIN_MSRS_UNKNOWN_LAST
} virDomainMsrsUnknown;

1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 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
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;

1814 1815 1816 1817 1818 1819 1820 1821 1822 1823
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;

1824
VIR_ENUM_DECL(virDomainLockFailure);
1825

M
Michal Privoznik 已提交
1826
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1827
    int useserial; /* enum virTristateBool */
1828 1829 1830
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1831 1832
};

1833
typedef enum {
1834 1835
    VIR_DOMAIN_LOADER_TYPE_NONE = 0,
    VIR_DOMAIN_LOADER_TYPE_ROM,
1836 1837 1838 1839 1840
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

1841
VIR_ENUM_DECL(virDomainLoader);
1842 1843 1844 1845 1846

struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1847
    int secure;     /* enum virTristateBool */
1848
    char *nvram;    /* path to non-volatile RAM */
1849
    char *templt;   /* user override of path to master nvram */
1850 1851 1852 1853
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1854
typedef enum {
1855 1856
    VIR_DOMAIN_IOAPIC_NONE = 0,
    VIR_DOMAIN_IOAPIC_QEMU,
1857 1858 1859 1860 1861 1862 1863
    VIR_DOMAIN_IOAPIC_KVM,

    VIR_DOMAIN_IOAPIC_LAST
} virDomainIOAPIC;

VIR_ENUM_DECL(virDomainIOAPIC);

1864
typedef enum {
1865 1866
    VIR_DOMAIN_HPT_RESIZING_NONE = 0,
    VIR_DOMAIN_HPT_RESIZING_ENABLED,
1867 1868 1869 1870 1871 1872 1873 1874
    VIR_DOMAIN_HPT_RESIZING_DISABLED,
    VIR_DOMAIN_HPT_RESIZING_REQUIRED,

    VIR_DOMAIN_HPT_RESIZING_LAST
} virDomainHPTResizing;

VIR_ENUM_DECL(virDomainHPTResizing);

1875
/* Operating system configuration data & machine / arch */
1876 1877 1878 1879 1880
struct _virDomainOSEnv {
    char *name;
    char *value;
};

1881 1882 1883 1884 1885 1886 1887 1888 1889 1890
typedef enum {
    VIR_DOMAIN_OS_DEF_FIRMWARE_NONE = 0,
    VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS,
    VIR_DOMAIN_OS_DEF_FIRMWARE_EFI,

    VIR_DOMAIN_OS_DEF_FIRMWARE_LAST
} virDomainOsDefFirmware;

VIR_ENUM_DECL(virDomainOsDefFirmware);

1891
struct _virDomainOSDef {
1892
    int type;
1893
    virDomainOsDefFirmware firmware;
1894
    virArch arch;
1895
    char *machine;
1896
    size_t nBootDevs;
1897
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1898
    int bootmenu; /* enum virTristateBool */
1899 1900
    unsigned int bm_timeout;
    bool bm_timeout_set;
1901
    char *init;
1902
    char **initargv;
1903
    virDomainOSEnvPtr *initenv;
1904
    char *initdir;
1905 1906
    char *inituser;
    char *initgroup;
1907 1908 1909
    char *kernel;
    char *initrd;
    char *cmdline;
1910
    char *dtb;
1911
    char *root;
J
Ján Tomko 已提交
1912
    char *slic_table;
1913
    virDomainLoaderDefPtr loader;
1914 1915
    char *bootloader;
    char *bootloaderArgs;
1916
    int smbios_mode;
1917

M
Michal Privoznik 已提交
1918
    virDomainBIOSDef bios;
1919 1920
};

1921
typedef enum {
1922 1923 1924 1925 1926
    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 已提交
1927
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1928
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
1929

1930
    VIR_DOMAIN_TIMER_NAME_LAST
1931
} virDomainTimerNameType;
1932

1933
typedef enum {
1934 1935 1936
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1937

1938
    VIR_DOMAIN_TIMER_TRACK_LAST
1939
} virDomainTimerTrackType;
1940

1941
typedef enum {
1942 1943 1944 1945 1946
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

1947
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
1948
} virDomainTimerTickpolicyType;
1949

1950
typedef enum {
1951 1952 1953 1954
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
1955
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
1956

1957
    VIR_DOMAIN_TIMER_MODE_LAST
1958
} virDomainTimerModeType;
1959

1960
typedef enum {
1961
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
1962 1963
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

1964
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
1965
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
1966

1967
struct _virDomainThreadSchedParam {
1968
    virProcessSchedPolicy policy;
1969 1970 1971
    int priority;
};

1972 1973 1974 1975 1976 1977
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

1978 1979 1980 1981 1982
struct _virDomainTimerDef {
    int name;
    int present;    /* unspecified = -1, no = 0, yes = 1 */
    int tickpolicy; /* none|catchup|merge|discard */

1983 1984 1985 1986
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
1987 1988 1989 1990 1991 1992

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

1993
typedef enum {
1994 1995
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
1996
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
1997
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
1998

1999
    VIR_DOMAIN_CLOCK_OFFSET_LAST
2000
} virDomainClockOffsetType;
2001

2002
typedef enum {
2003 2004 2005
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

2006
    VIR_DOMAIN_CLOCK_BASIS_LAST
2007
} virDomainClockBasis;
2008

2009 2010
struct _virDomainClockDef {
    int offset;
2011

2012
    union {
2013 2014 2015
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
2016
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
2017 2018 2019
        struct {
            long long adjustment;
            int basis;
2020 2021 2022 2023 2024 2025 2026

            /* 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;
2027
        } variable;
2028 2029 2030 2031 2032

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

2034
    size_t ntimers;
2035
    virDomainTimerDefPtr *timers;
2036 2037
};

2038

2039
struct _virBlkioDevice {
2040 2041
    char *path;
    unsigned int weight;
2042 2043 2044 2045
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
2046 2047
};

2048
typedef enum {
2049
    VIR_DOMAIN_RNG_MODEL_VIRTIO,
2050 2051
    VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL,
2052 2053

    VIR_DOMAIN_RNG_MODEL_LAST
2054
} virDomainRNGModel;
2055

2056
typedef enum {
2057 2058 2059 2060 2061
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
    /* VIR_DOMAIN_RNG_BACKEND_POOL, */

    VIR_DOMAIN_RNG_BACKEND_LAST
2062
} virDomainRNGBackend;
2063 2064 2065 2066

struct _virDomainRNGDef {
    int model;
    int backend;
2067 2068
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
2069 2070 2071 2072 2073 2074 2075 2076

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

    virDomainDeviceInfo info;
2077
    virDomainVirtioOptionsPtr virtio;
2078 2079
};

2080 2081 2082
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2083
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2084 2085 2086 2087 2088

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
2089
    virDomainMemoryAccess access;
2090
    virTristateBool discard;
2091

2092 2093 2094
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2095
    char *nvdimmPath;
2096
    unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
2097
    bool nvdimmPmem; /* valid only for NVDIMM */
2098 2099 2100

    /* target */
    int model; /* virDomainMemoryModel */
2101
    int targetNode;
2102
    unsigned long long size; /* kibibytes */
2103
    unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
2104
    bool readonly; /* valid only for NVDIMM */
2105 2106 2107 2108 2109 2110

    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2126 2127 2128 2129 2130
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2131
    VIR_DOMAIN_PANIC_MODEL_S390,
2132 2133 2134 2135

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2136
struct _virDomainPanicDef {
2137
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2138 2139 2140 2141
    virDomainDeviceInfo info;
};


2142
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2143
                              int ndevices);
2144

2145 2146 2147
struct _virDomainResourceDef {
    char *partition;
};
2148

2149
struct _virDomainHugePage {
2150 2151 2152 2153
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2154 2155
# define VIR_DOMAIN_CPUMASK_LEN 1024

2156 2157 2158
struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2159
    int thread_id;
2160
    virBitmapPtr cpumask;
2161 2162

    virDomainThreadSchedParam sched;
2163 2164 2165 2166
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2167

2168
struct _virDomainCputune {
2169
    unsigned long long shares;
2170 2171 2172
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2173
    unsigned long long global_period;
2174
    long long global_quota;
2175 2176
    unsigned long long emulator_period;
    long long emulator_quota;
2177 2178
    unsigned long long iothread_period;
    long long iothread_quota;
2179
    virBitmapPtr emulatorpin;
2180
    virDomainThreadSchedParamPtr emulatorsched;
2181 2182
};

2183

2184 2185 2186 2187 2188 2189
struct _virDomainResctrlMonDef {
    virBitmapPtr vcpus;
    virResctrlMonitorType tag;
    virResctrlMonitorPtr instance;
};

B
Bing Niu 已提交
2190
struct _virDomainResctrlDef {
2191 2192
    virBitmapPtr vcpus;
    virResctrlAllocPtr alloc;
2193 2194 2195

    virDomainResctrlMonDefPtr *monitors;
    size_t nmonitors;
2196 2197 2198
};


2199
struct _virDomainVcpuDef {
2200
    bool online;
2201 2202 2203
    virTristateBool hotpluggable;
    unsigned int order;

2204
    virBitmapPtr cpumask;
2205 2206

    virDomainThreadSchedParam sched;
2207 2208

    virObjectPtr privateData;
2209 2210
};

2211 2212 2213 2214 2215 2216 2217 2218
struct _virDomainBlkiotune {
    unsigned int weight;

    size_t ndevices;
    virBlkioDevicePtr devices;
};

struct _virDomainMemtune {
2219 2220 2221
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2222 2223
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2224 2225 2226 2227

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2228 2229 2230 2231
    /* 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 */

2232 2233 2234
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2235 2236 2237 2238
    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 */
2239 2240 2241 2242

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2243 2244

    virTristateBool discard;
2245 2246 2247 2248 2249 2250 2251 2252
};

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

Q
Qiaowei Ren 已提交
2253 2254 2255 2256 2257
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2258 2259 2260 2261 2262
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

2263 2264 2265 2266 2267 2268 2269 2270
typedef enum {
    VIR_DOMAIN_LAUNCH_SECURITY_NONE,
    VIR_DOMAIN_LAUNCH_SECURITY_SEV,

    VIR_DOMAIN_LAUNCH_SECURITY_LAST,
} virDomainLaunchSecurity;


2271
struct _virDomainSEVDef {
2272 2273 2274 2275 2276 2277 2278 2279 2280
    int sectype; /* enum virDomainLaunchSecurity */
    char *dh_cert;
    char *session;
    unsigned int policy;
    unsigned int cbitpos;
    unsigned int reduced_phys_bits;
};


J
Ján Tomko 已提交
2281 2282 2283 2284 2285 2286 2287 2288
typedef enum {
    VIR_DOMAIN_IOMMU_MODEL_INTEL,

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

struct _virDomainIOMMUDef {
    virDomainIOMMUModel model;
2289
    virTristateSwitch intremap;
2290
    virTristateSwitch caching_mode;
2291
    virTristateSwitch eim;
J
Ján Tomko 已提交
2292
    virTristateSwitch iotlb;
J
Ján Tomko 已提交
2293
};
2294

J
Ján Tomko 已提交
2295 2296 2297
typedef enum {
    VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO,
2298 2299
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL,
J
Ján Tomko 已提交
2300 2301 2302 2303

    VIR_DOMAIN_VSOCK_MODEL_LAST
} virDomainVsockModel;

J
Ján Tomko 已提交
2304
struct _virDomainVsockDef {
2305
    virObjectPtr privateData;
J
Ján Tomko 已提交
2306 2307 2308 2309 2310 2311

    virDomainVsockModel model;
    unsigned int guest_cid;
    virTristateBool auto_cid;

    virDomainDeviceInfo info;
J
Ján Tomko 已提交
2312 2313
};

2314 2315 2316 2317 2318
struct _virDomainVirtioOptions {
    virTristateSwitch iommu;
    virTristateSwitch ats;
};

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

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

2334
    char *name;
2335
    char *title;
2336
    char *description;
2337

2338 2339
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2340

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

2348 2349
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2350

2351
    virDomainCputune cputune;
2352

B
Bing Niu 已提交
2353 2354
    virDomainResctrlDefPtr *resctrls;
    size_t nresctrls;
2355

2356
    virDomainNumaPtr numa;
2357
    virDomainResourceDefPtr resource;
2358
    virDomainIdMapDef idmap;
2359

2360 2361 2362 2363 2364
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2365 2366
    int onLockFailure; /* enum virDomainLockFailureAction */

2367
    virDomainPowerManagement pm;
2368

2369
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2370

2371 2372
    virDomainOSDef os;
    char *emulator;
2373 2374 2375
    /* 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. */
2376
    int features[VIR_DOMAIN_FEATURE_LAST];
2377
    int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
2378
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2379
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2380
    int msrs_features[VIR_DOMAIN_MSRS_LAST];
2381
    unsigned int hyperv_spinlocks;
2382
    virGICVersion gic_version;
2383
    virDomainHPTResizing hpt_resizing;
2384
    unsigned long long hpt_maxpagesize; /* Stored in KiB */
2385
    char *hyperv_vendor_id;
2386
    int apic_eoi;
2387

2388 2389 2390
    bool tseg_specified;
    unsigned long long tseg_size;

2391
    virDomainClockDef clock;
2392

2393
    size_t ngraphics;
2394
    virDomainGraphicsDefPtr *graphics;
2395

2396
    size_t ndisks;
2397 2398
    virDomainDiskDefPtr *disks;

2399
    size_t ncontrollers;
2400 2401
    virDomainControllerDefPtr *controllers;

2402
    size_t nfss;
2403 2404
    virDomainFSDefPtr *fss;

2405
    size_t nnets;
2406 2407
    virDomainNetDefPtr *nets;

2408
    size_t ninputs;
2409 2410
    virDomainInputDefPtr *inputs;

2411
    size_t nsounds;
2412 2413
    virDomainSoundDefPtr *sounds;

2414
    size_t nvideos;
2415 2416
    virDomainVideoDefPtr *videos;

2417
    size_t nhostdevs;
2418 2419
    virDomainHostdevDefPtr *hostdevs;

2420
    size_t nredirdevs;
2421 2422
    virDomainRedirdevDefPtr *redirdevs;

2423
    size_t nsmartcards;
E
Eric Blake 已提交
2424 2425
    virDomainSmartcardDefPtr *smartcards;

2426
    size_t nserials;
2427 2428
    virDomainChrDefPtr *serials;

2429
    size_t nparallels;
2430 2431
    virDomainChrDefPtr *parallels;

2432
    size_t nchannels;
2433 2434
    virDomainChrDefPtr *channels;

2435
    size_t nconsoles;
2436 2437
    virDomainChrDefPtr *consoles;

2438
    size_t nleases;
2439 2440
    virDomainLeaseDefPtr *leases;

2441
    size_t nhubs;
M
Marc-André Lureau 已提交
2442 2443
    virDomainHubDefPtr *hubs;

2444 2445 2446
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2447 2448 2449
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2450 2451 2452
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2453 2454 2455
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2456 2457 2458
    size_t npanics;
    virDomainPanicDefPtr *panics;

2459
    /* Only 1 */
R
Richard Jones 已提交
2460
    virDomainWatchdogDefPtr watchdog;
2461
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2462
    virDomainNVRAMDefPtr nvram;
2463
    virDomainTPMDefPtr tpm;
2464
    virCPUDefPtr cpu;
2465
    virSysinfoDefPtr sysinfo;
2466
    virDomainRedirFilterDefPtr redirfilter;
J
Ján Tomko 已提交
2467
    virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
2468
    virDomainVsockDefPtr vsock;
2469 2470 2471

    void *namespaceData;
    virDomainXMLNamespace ns;
2472

2473 2474
    virDomainKeyWrapDefPtr keywrap;

2475
    /* SEV-specific domain */
2476
    virDomainSEVDefPtr sev;
2477

2478 2479
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2480 2481 2482 2483 2484 2485

    /* 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 */
2486 2487
};

2488

2489
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2490
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2491
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2492
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2493

2494 2495 2496 2497 2498 2499 2500
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

2501
typedef enum {
2502 2503 2504 2505 2506
    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 */
2507
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2508
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2509
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2510
    VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,/* CDROM passthrough */
Y
Yuri Chornoivan 已提交
2511
    VIR_DOMAIN_TAINT_CUSTOM_DTB,       /* Custom device tree blob was specified */
2512
    VIR_DOMAIN_TAINT_CUSTOM_GA_COMMAND, /* Custom guest agent command */
2513 2514

    VIR_DOMAIN_TAINT_LAST
2515
} virDomainTaintFlags;
2516

2517
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2518 2519 2520 2521 2522 2523
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2524
struct _virDomainObj {
2525
    virObjectLockable parent;
2526
    virCond cond;
2527

2528
    pid_t pid;
J
Jiri Denemark 已提交
2529
    virDomainStateReason state;
2530 2531 2532

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2533
    unsigned int updated : 1;
2534
    unsigned int removing : 1;
2535 2536 2537

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

2539
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2540

2541 2542
    bool hasManagedSave;

2543 2544
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2545 2546

    int taint;
2547 2548 2549

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

2552 2553
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2554

2555

2556 2557
/* NB: Any new flag to this list be considered to be set in
 * virt-aa-helper code if the flag prevents parsing. */
2558 2559
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2560
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2561
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2562
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2563
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2564
    VIR_DOMAIN_DEF_FEATURE_USER_ALIAS = (1 << 5),
2565
    VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER = (1 << 6),
2566
    VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT = (1 << 7),
2567 2568 2569
} virDomainDefFeatures;


2570 2571 2572 2573 2574 2575 2576 2577
/* 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);

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

2613 2614 2615 2616 2617 2618 2619
typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def,
                                              virCapsPtr caps,
                                              unsigned int parseFlags,
                                              void *opaque,
                                              void **parseOpaque);
typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque);

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

2627 2628 2629 2630 2631 2632
/* 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);

2633
struct _virDomainDefParserConfig {
2634
    /* driver domain definition callbacks */
2635
    virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
2636
    virDomainDefPostParseDataAlloc domainPostParseDataAlloc;
2637 2638
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2639
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2640
    virDomainDefPostParseDataFree domainPostParseDataFree;
2641

2642 2643
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2644
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2645

2646
    /* private data for the callbacks */
2647 2648
    void *priv;
    virFreeCallback privFree;
2649 2650

    /* data */
2651
    unsigned int features; /* virDomainDefFeatures */
2652
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2653 2654
};

2655
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *);
2656 2657 2658 2659 2660 2661 2662 2663
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
                                                 virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                virDomainObjPtr,
                                                virDomainDefParserConfigPtr);

2664 2665
typedef void *(*virDomainXMLPrivateDataGetParseOpaqueFunc)(virDomainObjPtr vm);

2666 2667 2668 2669 2670
typedef int (*virDomainXMLPrivateDataDiskParseFunc)(xmlXPathContextPtr ctxt,
                                                    virDomainDiskDefPtr disk);
typedef int (*virDomainXMLPrivateDataDiskFormatFunc)(virDomainDiskDefPtr disk,
                                                     virBufferPtr buf);

2671 2672 2673 2674 2675 2676
typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
                                                             virStorageSourcePtr src);
typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
                                                              virBufferPtr buf);


2677 2678 2679
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
2680 2681
    /* note that private data for devices are not copied when using
     * virDomainDefCopy and similar functions */
2682
    virDomainXMLPrivateDataNewFunc    diskNew;
2683 2684
    virDomainXMLPrivateDataDiskParseFunc diskParse;
    virDomainXMLPrivateDataDiskFormatFunc diskFormat;
2685
    virDomainXMLPrivateDataNewFunc    vcpuNew;
2686
    virDomainXMLPrivateDataNewFunc    chrSourceNew;
2687
    virDomainXMLPrivateDataNewFunc    vsockNew;
2688
    virDomainXMLPrivateDataNewFunc    graphicsNew;
2689 2690
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
2691 2692 2693
    /* following function shall return a pointer which will be used as the
     * 'parseOpaque' argument for virDomainDefPostParse */
    virDomainXMLPrivateDataGetParseOpaqueFunc getParseOpaque;
2694 2695
    virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
    virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
2696 2697
};

2698 2699 2700 2701 2702 2703 2704
typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
                                            const virDomainDef *dst);

struct _virDomainABIStability {
    virDomainABIStabilityDomain domain;
};

2705 2706
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
2707
                                            virDomainXMLNamespacePtr xmlns,
2708 2709 2710 2711 2712
                                            virDomainABIStabilityPtr abi,
                                            virSaveCookieCallbacksPtr saveCookie);

virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
2713

2714 2715
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2716
virDomainXMLNamespacePtr
2717
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2718 2719
    ATTRIBUTE_NONNULL(1);

2720 2721 2722 2723 2724
int virDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2725
bool virDomainDefHasUSB(const virDomainDef *def);
2726

2727 2728 2729 2730
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
                                           virDomainDeviceDefPtr dev,
                                           unsigned int flags);

2731 2732
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);

2733
int virDomainDefValidate(virDomainDefPtr def,
2734 2735 2736 2737
                         virCapsPtr caps,
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2738
static inline bool
D
Daniel P. Berrange 已提交
2739
virDomainObjIsActive(virDomainObjPtr dom)
2740 2741 2742 2743
{
    return dom->def->id != -1;
}

2744 2745
int virDomainObjCheckActive(virDomainObjPtr dom);

2746 2747 2748 2749 2750 2751 2752 2753 2754 2755
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;
2756
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2757 2758
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2759

2760
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2761
    ATTRIBUTE_NONNULL(1);
2762

M
Michal Privoznik 已提交
2763 2764
void virDomainObjEndAPI(virDomainObjPtr *vm);

2765
bool virDomainObjTaint(virDomainObjPtr obj,
2766
                       virDomainTaintFlags taint);
2767

2768 2769 2770 2771
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2772

H
Hu Tao 已提交
2773
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2774
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2775
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
J
Ján Tomko 已提交
2776
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
2777
void virDomainInputDefFree(virDomainInputDefPtr def);
2778
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2779
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2780
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2781 2782
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2783
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2784 2785
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
    ATTRIBUTE_RETURN_CHECK;
2786
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
2787
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
2788 2789 2790 2791
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
    ATTRIBUTE_RETURN_CHECK;
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2792 2793 2794
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
                                  virDomainDeviceInfoPtr info);
2795 2796 2797
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2798 2799

virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type);
2800
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2801
bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont);
2802

2803
virDomainFSDefPtr virDomainFSDefNew(void);
2804
void virDomainFSDefFree(virDomainFSDefPtr def);
2805
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
J
Ján Tomko 已提交
2806 2807
virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt);
void virDomainVsockDefFree(virDomainVsockDefPtr vsock);
2808
void virDomainNetDefClear(virDomainNetDefPtr def);
2809
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2810
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2811
void virDomainChrDefFree(virDomainChrDefPtr def);
2812 2813
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
                              virDomainChrSourceDefPtr src);
2814
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
2815
void virDomainSoundDefFree(virDomainSoundDefPtr def);
2816
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2817
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2818
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
C
Cole Robinson 已提交
2819
virDomainVideoDefPtr virDomainVideoDefNew(void);
2820
void virDomainVideoDefFree(virDomainVideoDefPtr def);
2821
void virDomainVideoDefClear(virDomainVideoDefPtr def);
J
John Ferlan 已提交
2822
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
2823
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2824
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2825
void virDomainHubDefFree(virDomainHubDefPtr def);
2826
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2827
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2828
void virDomainShmemDefFree(virDomainShmemDefPtr def);
2829
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2830
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2831
                                             const virDomainDef *def,
2832 2833
                                             virCapsPtr caps,
                                             virDomainXMLOptionPtr xmlopt);
2834
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
C
Cole Robinson 已提交
2835 2836
void virDomainDeviceSetData(virDomainDeviceDefPtr device,
                            void *devicedata);
2837
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2838

2839
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2840 2841
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2842 2843 2844 2845 2846 2847
                                           void *opaque);

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

2848 2849 2850 2851
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

2852 2853
void virDomainDefFree(virDomainDefPtr vm);

2854 2855 2856
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);

2857
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
2858

2859 2860
virDomainGraphicsDefPtr
virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt);
2861
virDomainDefPtr virDomainDefNew(void);
2862

2863
void virDomainObjAssignDef(virDomainObjPtr domain,
2864
                           virDomainDefPtr def,
2865 2866
                           bool live,
                           virDomainDefPtr *oldDef);
2867
int virDomainObjSetDefTransient(virCapsPtr caps,
2868
                                virDomainXMLOptionPtr xmlopt,
2869
                                virDomainObjPtr domain);
2870
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
2871 2872
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
2873
                             virDomainXMLOptionPtr xmlopt,
2874
                             virDomainObjPtr domain);
2875 2876 2877 2878 2879 2880 2881 2882

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

int virDomainObjGetDefs(virDomainObjPtr vm,
                        unsigned int flags,
                        virDomainDefPtr *liveDef,
                        virDomainDefPtr *persDef);
2883 2884 2885
virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                           unsigned int flags,
                                           bool *state);
2886
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
2887

2888 2889 2890
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virCapsPtr caps,
                                 virDomainXMLOptionPtr xmlopt,
2891
                                 void *parseOpaque,
2892 2893 2894 2895
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt);
2896

2897 2898 2899
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
2900 2901 2902 2903
    /* 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. */
2904 2905 2906 2907 2908
    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,
2909
    /* internal flag passed to device info sub-parser to allow using <rom> */
2910
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
2911
    /* internal flag passed to device info sub-parser to allow specifying boot order */
2912 2913
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    /* parse only source half of <disk> */
2914
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 6,
2915
    /* perform RNG schema validation on the passed XML document */
2916
    VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA = 1 << 7,
2917
    /* allow updates in post parse callback that would break ABI otherwise */
2918
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE = 1 << 8,
2919
    /* skip definition validation checks meant to be executed on define time only */
2920
    VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 9,
2921
    /* skip parsing of security labels */
2922
    VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 10,
2923 2924 2925
    /* 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. */
2926
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 11,
2927 2928 2929 2930
    /* 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 */
2931
    VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL = 1 << 12,
2932 2933 2934 2935 2936
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
2937
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
2938
    /* format internal domain status information */
2939
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
2940
    /* format <actual> element */
2941
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
2942
    /* format original states of host PCI device */
2943 2944 2945 2946
    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,
2947 2948
} virDomainDefFormatFlags;

2949 2950 2951 2952 2953 2954 2955 2956 2957
/* 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;

2958
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
2959
                                              const virDomainDef *def,
2960 2961
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
2962
                                              unsigned int flags);
2963 2964 2965 2966
virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr,
                                          const virDomainDef *def,
                                          virDomainXMLOptionPtr xmlopt,
                                          unsigned int flags);
2967 2968
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                        virCapsPtr caps,
2969
                                        virDomainXMLOptionPtr xmlopt,
2970
                                        void *parseOpaque,
L
Laine Stump 已提交
2971
                                        unsigned int flags);
2972 2973
virDomainDefPtr virDomainDefParseFile(const char *filename,
                                      virCapsPtr caps,
2974
                                      virDomainXMLOptionPtr xmlopt,
2975
                                      void *parseOpaque,
L
Laine Stump 已提交
2976
                                      unsigned int flags);
2977
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
2978
                                      xmlNodePtr root,
2979 2980
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
2981
                                      void *parseOpaque,
L
Laine Stump 已提交
2982
                                      unsigned int flags);
2983 2984 2985 2986 2987
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
2988 2989 2990 2991
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
2992

2993
bool virDomainDefCheckABIStability(virDomainDefPtr src,
2994 2995
                                   virDomainDefPtr dst,
                                   virDomainXMLOptionPtr xmlopt);
2996

2997 2998
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
                                        virDomainDefPtr dst,
2999
                                        virDomainXMLOptionPtr xmlopt,
3000 3001
                                        unsigned int flags);

3002
int virDomainDefAddImplicitDevices(virDomainDefPtr def);
3003

3004
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
3005 3006 3007 3008 3009
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);

3010 3011 3012 3013 3014 3015 3016 3017 3018
/* When extending this list, remember that libvirt 1.2.12-5.0.0 had a
 * bug that silently ignored unknown flags.  A new flag to add
 * information is okay as long as clients still work when an older
 * server omits the requested output, but a new flag to suppress
 * information could result in a security hole when older libvirt
 * supplies the sensitive information in spite of the flag. */
# define VIR_DOMAIN_XML_COMMON_FLAGS \
    (VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE | \
     VIR_DOMAIN_XML_MIGRATABLE)
3019 3020
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

3021
char *virDomainDefFormat(virDomainDefPtr def,
3022
                         virCapsPtr caps,
L
Laine Stump 已提交
3023
                         unsigned int flags);
3024 3025
char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
                         virDomainObjPtr obj,
3026
                         virCapsPtr caps,
3027
                         unsigned int flags);
3028
int virDomainDefFormatInternal(virDomainDefPtr def,
3029
                               virCapsPtr caps,
3030
                               unsigned int flags,
3031 3032
                               virBufferPtr buf,
                               virDomainXMLOptionPtr xmlopt);
3033

3034 3035 3036
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
                              int policy,
3037
                              bool attrIndex,
3038 3039
                              unsigned int flags,
                              virDomainXMLOptionPtr xmlopt);
3040

3041 3042
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
3043
                          char *prefix,
3044 3045
                          unsigned int flags);

3046 3047 3048 3049 3050 3051
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

3052
int virDomainDefCompatibleDevice(virDomainDefPtr def,
3053
                                 virDomainDeviceDefPtr dev,
3054
                                 virDomainDeviceDefPtr oldDev,
3055 3056
                                 virDomainDeviceAction action,
                                 bool live);
3057

3058 3059
void virDomainRNGDefFree(virDomainRNGDefPtr def);

3060
int virDomainDiskIndexByAddress(virDomainDefPtr def,
3061
                                virPCIDeviceAddressPtr pci_controller,
3062 3063
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
3064
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
3065
                                           virPCIDeviceAddressPtr pci_controller,
3066 3067 3068
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
3069 3070
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
3071 3072 3073
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
3074
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
3075
int virDomainDiskInsert(virDomainDefPtr def,
3076 3077
                        virDomainDiskDefPtr disk)
    ATTRIBUTE_RETURN_CHECK;
3078 3079
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
3080 3081
int virDomainStorageNetworkParseHost(xmlNodePtr hostnode,
                                     virStorageNetHostDefPtr host);
3082
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
3083 3084
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
3085

3086 3087 3088 3089
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
3090

3091 3092
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
3093
virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname);
3094
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
3095
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
3096
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
3097
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
3098

L
Laine Stump 已提交
3099
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
3100 3101
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
3102 3103 3104
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

3105 3106
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
3107 3108
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
3109
            ATTRIBUTE_NONNULL(1);
3110 3111 3112
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
3113

3114
virDomainNetType virDomainNetGetActualType(const virDomainNetDef *iface);
3115
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
3116
int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
3117
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
3118
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
3119
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
3120
virNetDevVPortProfilePtr
3121
virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface);
3122
virNetDevBandwidthPtr
3123
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
3124
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
3125
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
3126 3127 3128 3129 3130 3131 3132
const char *virDomainNetGetModelString(const virDomainNetDef *net);
int virDomainNetSetModelString(virDomainNetDefPtr et,
                               const char *model);
int virDomainNetStreqModelString(const virDomainNetDef *net,
                                 const char *model);
int virDomainNetStrcaseeqModelString(const virDomainNetDef *net,
                                     const char *model);
3133
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
3134
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
3135 3136 3137
                                const char *address,
                                int family,
                                unsigned int prefix);
3138

3139
int virDomainControllerInsert(virDomainDefPtr def,
3140 3141
                              virDomainControllerDefPtr controller)
    ATTRIBUTE_RETURN_CHECK;
3142 3143
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
3144
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
3145
int virDomainControllerFindByType(virDomainDefPtr def, int type);
3146
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
3147
                                        virPCIDeviceAddressPtr addr);
3148
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
3149
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
3150
const char *virDomainControllerAliasFind(const virDomainDef *def,
3151 3152
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
3153 3154 3155 3156 3157

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
3158 3159
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
    ATTRIBUTE_RETURN_CHECK;
3160 3161
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
3162 3163 3164 3165 3166
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
3167

3168
void
3169
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
3170
                          virDomainChrDeviceType type,
3171 3172 3173
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3174 3175 3176
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
3177 3178 3179
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
3180
int
3181 3182 3183 3184 3185
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
3186 3187 3188 3189
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

3190 3191 3192
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

3193 3194 3195 3196
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

3197
int virDomainSaveXML(const char *configDir,
3198 3199 3200
                     virDomainDefPtr def,
                     const char *xml);

3201
int virDomainSaveConfig(const char *configDir,
3202
                        virCapsPtr caps,
3203
                        virDomainDefPtr def);
3204
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
3205
                        const char *statusDir,
3206 3207
                        virDomainObjPtr obj,
                        virCapsPtr caps) ATTRIBUTE_RETURN_CHECK;
3208

3209 3210 3211 3212
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

3213
int virDomainDeleteConfig(const char *configDir,
3214
                          const char *autostartDir,
3215 3216
                          virDomainObjPtr dom);

3217
char *virDomainConfigFile(const char *dir,
3218 3219
                          const char *name);

3220 3221 3222 3223
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

3224
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
3225
                                                  const char *target);
3226
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
3227
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
3228 3229
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

3230
int virDomainVideoDefaultType(const virDomainDef *def);
3231 3232
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
3233

E
Eric Blake 已提交
3234 3235 3236 3237 3238 3239 3240 3241 3242
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3243 3244 3245 3246 3247 3248 3249 3250 3251
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3252 3253 3254 3255 3256
typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
                                            const char *path,
                                            size_t depth,
                                            void *opaque);

3257 3258 3259 3260 3261 3262 3263
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

3264 3265 3266 3267 3268
int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
                                bool ignoreOpenFailure,
                                virDomainDiskDefPathIterator iter,
                                void *opaque);

J
Jiri Denemark 已提交
3269 3270 3271 3272 3273 3274 3275
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3276 3277 3278
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3279
virSecurityDeviceLabelDefPtr
3280 3281
virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDefPtr def,
                                         const char *model);
3282

3283 3284
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3285

3286 3287 3288 3289 3290 3291 3292 3293 3294 3295
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;

3296 3297 3298 3299 3300 3301 3302 3303
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);
3304 3305 3306
ssize_t virDomainInputDefFind(const virDomainDef *def,
                              const virDomainInputDef *input)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
3307 3308 3309
bool virDomainVsockDefEquals(const virDomainVsockDef *a,
                             const virDomainVsockDef *b)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
3310

3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329
VIR_ENUM_DECL(virDomainTaint);
VIR_ENUM_DECL(virDomainVirt);
VIR_ENUM_DECL(virDomainBoot);
VIR_ENUM_DECL(virDomainFeature);
VIR_ENUM_DECL(virDomainCapabilitiesPolicy);
VIR_ENUM_DECL(virDomainCapsFeature);
VIR_ENUM_DECL(virDomainLifecycle);
VIR_ENUM_DECL(virDomainLifecycleAction);
VIR_ENUM_DECL(virDomainDevice);
VIR_ENUM_DECL(virDomainDiskDevice);
VIR_ENUM_DECL(virDomainDiskGeometryTrans);
VIR_ENUM_DECL(virDomainDiskBus);
VIR_ENUM_DECL(virDomainDiskCache);
VIR_ENUM_DECL(virDomainDiskErrorPolicy);
VIR_ENUM_DECL(virDomainDiskIo);
VIR_ENUM_DECL(virDomainDeviceSGIO);
VIR_ENUM_DECL(virDomainDiskTray);
VIR_ENUM_DECL(virDomainDiskDiscard);
VIR_ENUM_DECL(virDomainDiskDetectZeroes);
3330
VIR_ENUM_DECL(virDomainDiskModel);
3331 3332 3333 3334 3335 3336 3337
VIR_ENUM_DECL(virDomainDiskMirrorState);
VIR_ENUM_DECL(virDomainController);
VIR_ENUM_DECL(virDomainControllerModelPCI);
VIR_ENUM_DECL(virDomainControllerPCIModelName);
VIR_ENUM_DECL(virDomainControllerModelSCSI);
VIR_ENUM_DECL(virDomainControllerModelUSB);
VIR_ENUM_DECL(virDomainControllerModelIDE);
3338
VIR_ENUM_DECL(virDomainControllerModelVirtioSerial);
3339 3340 3341 3342
VIR_ENUM_DECL(virDomainFS);
VIR_ENUM_DECL(virDomainFSDriver);
VIR_ENUM_DECL(virDomainFSAccessMode);
VIR_ENUM_DECL(virDomainFSWrpolicy);
3343
VIR_ENUM_DECL(virDomainFSModel);
3344 3345 3346 3347
VIR_ENUM_DECL(virDomainNet);
VIR_ENUM_DECL(virDomainNetBackend);
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
VIR_ENUM_DECL(virDomainNetInterfaceLinkState);
3348
VIR_ENUM_DECL(virDomainNetModel);
3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372
VIR_ENUM_DECL(virDomainChrDevice);
VIR_ENUM_DECL(virDomainChrChannelTarget);
VIR_ENUM_DECL(virDomainChrConsoleTarget);
VIR_ENUM_DECL(virDomainChrSerialTarget);
VIR_ENUM_DECL(virDomainSmartcard);
VIR_ENUM_DECL(virDomainChr);
VIR_ENUM_DECL(virDomainChrTcpProtocol);
VIR_ENUM_DECL(virDomainChrSpicevmc);
VIR_ENUM_DECL(virDomainSoundCodec);
VIR_ENUM_DECL(virDomainSoundModel);
VIR_ENUM_DECL(virDomainKeyWrapCipherName);
VIR_ENUM_DECL(virDomainMemballoonModel);
VIR_ENUM_DECL(virDomainSmbiosMode);
VIR_ENUM_DECL(virDomainWatchdogModel);
VIR_ENUM_DECL(virDomainWatchdogAction);
VIR_ENUM_DECL(virDomainPanicModel);
VIR_ENUM_DECL(virDomainVideo);
VIR_ENUM_DECL(virDomainHostdevMode);
VIR_ENUM_DECL(virDomainHostdevSubsys);
VIR_ENUM_DECL(virDomainHostdevCaps);
VIR_ENUM_DECL(virDomainHub);
VIR_ENUM_DECL(virDomainRedirdevBus);
VIR_ENUM_DECL(virDomainInput);
VIR_ENUM_DECL(virDomainInputBus);
3373
VIR_ENUM_DECL(virDomainInputModel);
3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386
VIR_ENUM_DECL(virDomainGraphics);
VIR_ENUM_DECL(virDomainGraphicsListen);
VIR_ENUM_DECL(virDomainGraphicsAuthConnected);
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName);
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode);
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression);
VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression);
VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression);
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode);
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode);
VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy);
VIR_ENUM_DECL(virDomainHyperv);
VIR_ENUM_DECL(virDomainKVM);
3387
VIR_ENUM_DECL(virDomainMsrsUnknown);
3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400
VIR_ENUM_DECL(virDomainRNGModel);
VIR_ENUM_DECL(virDomainRNGBackend);
VIR_ENUM_DECL(virDomainTPMModel);
VIR_ENUM_DECL(virDomainTPMBackend);
VIR_ENUM_DECL(virDomainTPMVersion);
VIR_ENUM_DECL(virDomainMemoryModel);
VIR_ENUM_DECL(virDomainMemoryBackingModel);
VIR_ENUM_DECL(virDomainMemorySource);
VIR_ENUM_DECL(virDomainMemoryAllocation);
VIR_ENUM_DECL(virDomainIOMMUModel);
VIR_ENUM_DECL(virDomainVsockModel);
VIR_ENUM_DECL(virDomainShmemModel);
VIR_ENUM_DECL(virDomainLaunchSecurity);
3401
/* from libvirt.h */
3402 3403 3404 3405 3406 3407 3408 3409 3410
VIR_ENUM_DECL(virDomainState);
VIR_ENUM_DECL(virDomainNostateReason);
VIR_ENUM_DECL(virDomainRunningReason);
VIR_ENUM_DECL(virDomainBlockedReason);
VIR_ENUM_DECL(virDomainPausedReason);
VIR_ENUM_DECL(virDomainShutdownReason);
VIR_ENUM_DECL(virDomainShutoffReason);
VIR_ENUM_DECL(virDomainCrashedReason);
VIR_ENUM_DECL(virDomainPMSuspendedReason);
J
Jiri Denemark 已提交
3411 3412 3413 3414

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

3415 3416 3417
VIR_ENUM_DECL(virDomainSeclabel);
VIR_ENUM_DECL(virDomainClockOffset);
VIR_ENUM_DECL(virDomainClockBasis);
3418

3419 3420 3421 3422 3423
VIR_ENUM_DECL(virDomainTimerName);
VIR_ENUM_DECL(virDomainTimerTrack);
VIR_ENUM_DECL(virDomainTimerTickpolicy);
VIR_ENUM_DECL(virDomainTimerMode);
VIR_ENUM_DECL(virDomainCpuPlacementMode);
3424

3425
VIR_ENUM_DECL(virDomainStartupPolicy);
3426

3427 3428
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3429 3430
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3431 3432 3433 3434 3435
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3436 3437 3438 3439
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3440

3441 3442
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3443 3444
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3445 3446
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3447

3448 3449
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);

3450 3451
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3452 3453 3454 3455 3456
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3457 3458 3459 3460 3461 3462 3463
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
3464
                            const char *stateDir,
3465 3466 3467
                            const char *configDir,
                            unsigned int flags);

3468 3469 3470 3471 3472 3473 3474 3475
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3476 3477 3478
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3479 3480
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3481
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3482

3483 3484 3485 3486 3487
virStorageSourcePtr
virDomainStorageSourceParseBase(const char *type,
                                const char *format,
                                const char *index)
    ATTRIBUTE_RETURN_CHECK;
3488

3489 3490 3491
int virDomainStorageSourceParse(xmlNodePtr node,
                                xmlXPathContextPtr ctxt,
                                virStorageSourcePtr src,
3492 3493
                                unsigned int flags,
                                virDomainXMLOptionPtr xmlopt)
3494 3495
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3496 3497 3498 3499 3500 3501 3502 3503
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;

3504 3505
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

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

3508 3509 3510 3511 3512
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3513

3514 3515 3516
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3517 3518 3519 3520 3521
char *
virDomainGenerateMachineName(const char *drivername,
                             int id,
                             const char *name,
                             bool privileged);
3522 3523 3524

bool
virDomainNetTypeSharesHostView(const virDomainNetDef *net);
3525

3526 3527 3528 3529
bool
virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
                                   virDomainLifecycleAction action);

3530
typedef int
3531 3532
(*virDomainNetAllocateActualDeviceImpl)(virNetworkPtr net,
                                        virDomainDefPtr dom,
3533 3534 3535
                                        virDomainNetDefPtr iface);

typedef void
3536 3537
(*virDomainNetNotifyActualDeviceImpl)(virNetworkPtr net,
                                      virDomainDefPtr dom,
3538 3539 3540
                                      virDomainNetDefPtr iface);

typedef int
3541 3542
(*virDomainNetReleaseActualDeviceImpl)(virNetworkPtr net,
                                       virDomainDefPtr dom,
3543 3544
                                       virDomainNetDefPtr iface);

3545 3546 3547 3548 3549 3550 3551 3552 3553
typedef bool
(*virDomainNetBandwidthChangeAllowedImpl)(virDomainNetDefPtr iface,
                                          virNetDevBandwidthPtr newBandwidth);

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


3554 3555 3556
void
virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate,
                          virDomainNetNotifyActualDeviceImpl notify,
3557 3558
                          virDomainNetReleaseActualDeviceImpl release,
                          virDomainNetBandwidthChangeAllowedImpl bandwidthChangeAllowed,
3559
                          virDomainNetBandwidthUpdateImpl bandwidthUpdate);
3560 3561

int
3562 3563
virDomainNetAllocateActualDevice(virConnectPtr conn,
                                 virDomainDefPtr dom,
3564 3565 3566 3567
                                 virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void
3568 3569
virDomainNetNotifyActualDevice(virConnectPtr conn,
                               virDomainDefPtr dom,
3570 3571 3572 3573
                               virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

int
3574 3575
virDomainNetReleaseActualDevice(virConnectPtr conn,
                                virDomainDefPtr dom,
3576 3577 3578
                                virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

3579 3580 3581 3582 3583 3584 3585 3586 3587
bool
virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface,
                              virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

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

3589 3590 3591 3592
int
virDomainNetResolveActualType(virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1);

3593

3594
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
3595

3596 3597 3598
int
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                 virDomainDiskDetectZeroes detect_zeroes);
3599

3600 3601 3602
bool
virDomainDefHasManagedPR(const virDomainDef *def);

3603 3604 3605
bool
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);

3606 3607 3608 3609 3610 3611 3612 3613 3614
bool
virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics);

const char *
virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);

bool
virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);

3615
#endif /* LIBVIRT_DOMAIN_CONF_H */