domain_conf.h 123.1 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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#pragma once

#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>

#include "internal.h"
#include "virconftypes.h"
#include "capabilities.h"
#include "virstorageencryption.h"
#include "cpu_conf.h"
#include "virthread.h"
#include "virhash.h"
#include "virsocketaddr.h"
#include "networkcommon_conf.h"
#include "nwfilter_params.h"
#include "numa_conf.h"
#include "virnetdevmacvlan.h"
#include "virsysinfo.h"
#include "virnetdev.h"
#include "virnetdevip.h"
#include "virnetdevvportprofile.h"
#include "virnetdevbandwidth.h"
#include "virnetdevvlan.h"
47
#include "virnetworkportdef.h"
48 49 50 51 52 53 54 55 56 57 58 59
#include "virobject.h"
#include "device_conf.h"
#include "virbitmap.h"
#include "virstoragefile.h"
#include "virseclabel.h"
#include "virprocess.h"
#include "virgic.h"
#include "virperf.h"
#include "virtypedparam.h"
#include "virsavecookie.h"
#include "virresctrl.h"
#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
/* Different types of hypervisor */
123
typedef enum {
124
    VIR_DOMAIN_VIRT_NONE = 0,
125 126 127 128 129 130 131 132 133 134
    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,
135
    VIR_DOMAIN_VIRT_VBOX,
136
    VIR_DOMAIN_VIRT_PHYP,
D
Dmitry Guryanov 已提交
137
    VIR_DOMAIN_VIRT_PARALLELS,
R
Roman Bogorodskiy 已提交
138
    VIR_DOMAIN_VIRT_BHYVE,
139
    VIR_DOMAIN_VIRT_VZ,
140

141
    VIR_DOMAIN_VIRT_LAST
142
} virDomainVirtType;
143

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

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


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

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

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

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

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

187

188
typedef enum {
189 190 191
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

192
    VIR_DOMAIN_HOSTDEV_MODE_LAST
193
} virDomainHostdevMode;
194

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

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
203
} virDomainHostdevSubsysType;
204

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

    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
213
} virDomainHostdevSubsysPCIBackendType;
214

215
VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend);
216

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

    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
} virDomainHostdevSCSIProtocolType;

224
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol);
225

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

    unsigned vendor;
    unsigned product;
};

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

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

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

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

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

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;
493 494
    /* Don't forget to update virDomainBlockIoTuneInfoCopy and
     * virDomainBlockIoTuneInfoEqual. */
L
Lei Li 已提交
495 496
};

497

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

507 508 509 510
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 已提交
511
    VIR_DOMAIN_MEMORY_SOURCE_MEMFD,     /* Memory source is set as memfd */
512 513 514 515 516 517 518 519 520 521 522 523

    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;

524

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

529 530
    virObjectPtr privateData;

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

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

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

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

L
Lei Li 已提交
553 554
    virDomainBlockIoTuneInfo blkdeviotune;

555 556
    char *driverName;

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


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

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
596
} virDomainControllerType;
597

598

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

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
613
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
614

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

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

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

644
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
645
} virDomainControllerModelSCSI;
646

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

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
665
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
666

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

676 677 678 679 680 681 682 683 684
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;

685
#define IS_USB2_CONTROLLER(ctrl) \
686 687 688 689 690 691
    (((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))

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

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

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

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

728 729 730 731
struct _virDomainUSBControllerOpts {
    int ports;   /* -1 == undef */
};

732 733
struct _virDomainXenbusControllerOpts {
    int maxGrantFrames;   /* -1 == undef */
734
    int maxEventChannels; /* -1 == undef */
735 736
};

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


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

    VIR_DOMAIN_FS_TYPE_LAST
769
} virDomainFSType;
770

771
/* Filesystem driver type */
772
typedef enum {
773 774 775
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
776
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
777
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
D
Dmitry Guryanov 已提交
778
    VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
779
    VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS,
780 781

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
782
} virDomainFSDriverType;
783

784
/* Filesystem mount access mode  */
785
typedef enum {
786 787 788 789 790
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
791
} virDomainFSAccessMode;
792

793
/* Filesystem Write policy */
794
typedef enum {
795 796 797 798
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
799
} virDomainFSWrpolicy;
800

801 802 803 804 805 806 807 808 809 810 811 812
/* How to handle exports containing multiple devices. */
typedef enum {
    VIR_DOMAIN_FS_MULTIDEVS_DEFAULT = 0, /* Use QEMU's default setting */
    VIR_DOMAIN_FS_MULTIDEVS_REMAP, /* Remap inodes from host to guest */
    VIR_DOMAIN_FS_MULTIDEVS_FORBID, /* Prohibit more than one device */
    VIR_DOMAIN_FS_MULTIDEVS_WARN, /* Just log a warning if multiple devices */

    VIR_DOMAIN_FS_MULTIDEVS_LAST
} virDomainFSMultidevs;

VIR_ENUM_DECL(virDomainFSMultidevs);

813 814 815 816 817 818 819 820 821
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;

822 823 824 825 826 827 828 829
typedef enum {
    VIR_DOMAIN_FS_CACHE_MODE_DEFAULT = 0,
    VIR_DOMAIN_FS_CACHE_MODE_NONE,
    VIR_DOMAIN_FS_CACHE_MODE_ALWAYS,

    VIR_DOMAIN_FS_CACHE_MODE_LAST
} virDomainFSCacheMode;

830 831
struct _virDomainFSDef {
    int type;
832 833
    int fsdriver; /* enum virDomainFSDriverType */
    int accessmode; /* enum virDomainFSAccessMode */
834
    int wrpolicy; /* enum virDomainFSWrpolicy */
835
    int format; /* virStorageFileFormat */
836
    int model; /* virDomainFSModel */
837
    int multidevs; /* virDomainFSMultidevs */
838
    unsigned long long usage; /* in bytes */
839
    virStorageSourcePtr src;
840
    char *dst;
841
    bool readonly;
842
    virDomainDeviceInfo info;
843 844
    unsigned long long space_hard_limit; /* in bytes */
    unsigned long long space_soft_limit; /* in bytes */
845
    bool symlinksResolved;
846 847 848 849 850 851
    char *binary;
    unsigned long long queue_size;
    virTristateSwitch xattr;
    virDomainFSCacheMode cache;
    virTristateSwitch posix_lock;
    virTristateSwitch flock;
852
    virDomainVirtioOptionsPtr virtio;
853
    virObjectPtr privateData;
854 855 856
};


857
/* network config types */
858
typedef enum {
859 860
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
M
Michele Paolino 已提交
861
    VIR_DOMAIN_NET_TYPE_VHOSTUSER,
862 863 864 865 866
    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 已提交
867
    VIR_DOMAIN_NET_TYPE_INTERNAL,
868
    VIR_DOMAIN_NET_TYPE_DIRECT,
869
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
870
    VIR_DOMAIN_NET_TYPE_UDP,
871

872
    VIR_DOMAIN_NET_TYPE_LAST
873
} virDomainNetType;
874

875 876 877 878
/* network model types */
typedef enum {
    VIR_DOMAIN_NET_MODEL_UNKNOWN,
    VIR_DOMAIN_NET_MODEL_NETFRONT,
C
Cole Robinson 已提交
879 880 881
    VIR_DOMAIN_NET_MODEL_RTL8139,
    VIR_DOMAIN_NET_MODEL_VIRTIO,
    VIR_DOMAIN_NET_MODEL_E1000,
882 883 884 885 886 887 888
    VIR_DOMAIN_NET_MODEL_E1000E,
    VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL,
    VIR_DOMAIN_NET_MODEL_USB_NET,
    VIR_DOMAIN_NET_MODEL_SPAPR_VLAN,
    VIR_DOMAIN_NET_MODEL_LAN9118,
    VIR_DOMAIN_NET_MODEL_SMC91C111,
C
Cole Robinson 已提交
889 890 891 892
    VIR_DOMAIN_NET_MODEL_VLANCE,
    VIR_DOMAIN_NET_MODEL_VMXNET,
    VIR_DOMAIN_NET_MODEL_VMXNET2,
    VIR_DOMAIN_NET_MODEL_VMXNET3,
C
Cole Robinson 已提交
893 894 895 896 897
    VIR_DOMAIN_NET_MODEL_AM79C970A,
    VIR_DOMAIN_NET_MODEL_AM79C973,
    VIR_DOMAIN_NET_MODEL_82540EM,
    VIR_DOMAIN_NET_MODEL_82545EM,
    VIR_DOMAIN_NET_MODEL_82543GC,
898 899 900 901

    VIR_DOMAIN_NET_MODEL_LAST
} virDomainNetModelType;

902
/* the backend driver used for virtio interfaces */
903
typedef enum {
904 905 906 907
    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 */

908
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
909
} virDomainNetBackendType;
910

911
/* the TX algorithm used for virtio interfaces */
912
typedef enum {
913 914 915 916
    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,

917
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
918
} virDomainNetVirtioTxModeType;
919

920 921 922 923 924 925 926 927 928
/* the type of teaming device */
typedef enum {
    VIR_DOMAIN_NET_TEAMING_TYPE_NONE,
    VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT,
    VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT,

    VIR_DOMAIN_NET_TEAMING_TYPE_LAST
} virDomainNetTeamingType;

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

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

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

1075 1076 1077 1078 1079 1080 1081 1082
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;

1083
VIR_ENUM_DECL(virDomainChrDeviceState);
1084

1085
typedef enum {
1086
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1087 1088
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1089
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1090

1091
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1092
} virDomainChrDeviceType;
1093

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

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1104
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1105

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

1112
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1113
} virDomainChrChannelTargetType;
1114

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

1126
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1127
} virDomainChrConsoleTargetType;
1128

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

    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
} virDomainChrSerialTargetModel;

VIR_ENUM_DECL(virDomainChrSerialTargetModel);

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

1160
    VIR_DOMAIN_CHR_TYPE_LAST
1161
} virDomainChrType;
1162

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

1169
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1170
} virDomainChrTcpProtocol;
1171

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

1177
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1178
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1179

1180 1181 1182 1183 1184 1185 1186

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


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

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

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

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

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

1250 1251
    virDomainChrDeviceState state;

1252
    virDomainChrSourceDefPtr source;
1253 1254

    virDomainDeviceInfo info;
1255 1256
};

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

1262
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1263
} virDomainSmartcardType;
E
Eric Blake 已提交
1264

1265 1266
#define VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES 3
#define VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE "/etc/pki/nssdb"
E
Eric Blake 已提交
1267 1268 1269 1270 1271 1272 1273 1274 1275

struct _virDomainSmartcardDef {
    int type; /* virDomainSmartcardType */
    union {
        /* no extra data for 'host' */
        struct {
            char *file[VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES];
            char *database;
        } cert; /* 'host-certificates' */
1276
        virDomainChrSourceDefPtr passthru; /* 'passthrough' */
E
Eric Blake 已提交
1277 1278 1279 1280 1281
    } data;

    virDomainDeviceInfo info;
};

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

1287
typedef enum {
1288
    VIR_DOMAIN_TPM_MODEL_DEFAULT,
1289
    VIR_DOMAIN_TPM_MODEL_TIS,
1290
    VIR_DOMAIN_TPM_MODEL_CRB,
1291
    VIR_DOMAIN_TPM_MODEL_SPAPR,
1292 1293

    VIR_DOMAIN_TPM_MODEL_LAST
1294
} virDomainTPMModel;
1295

1296
typedef enum {
1297
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
1298
    VIR_DOMAIN_TPM_TYPE_EMULATOR,
1299 1300

    VIR_DOMAIN_TPM_TYPE_LAST
1301
} virDomainTPMBackendType;
1302

1303 1304 1305 1306 1307 1308 1309 1310
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;

1311
#define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"
1312 1313

struct _virDomainTPMDef {
1314
    int type; /* virDomainTPMBackendType */
1315
    virDomainDeviceInfo info;
1316 1317
    int model; /* virDomainTPMModel */
    int version; /* virDomainTPMVersion */
1318 1319 1320 1321
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
1322 1323 1324 1325
        struct {
            virDomainChrSourceDef source;
            char *storagepath;
            char *logfile;
1326 1327
            unsigned char secretuuid[VIR_UUID_BUFLEN];
            bool hassecretuuid;
1328
        } emulator;
1329 1330 1331
    } data;
};

1332
typedef enum {
1333 1334
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1335
    VIR_DOMAIN_INPUT_TYPE_KBD,
1336
    VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
1337

1338
    VIR_DOMAIN_INPUT_TYPE_LAST
1339
} virDomainInputType;
1340

1341
typedef enum {
1342 1343 1344
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1345
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1346
    VIR_DOMAIN_INPUT_BUS_VIRTIO,
1347 1348

    VIR_DOMAIN_INPUT_BUS_LAST
1349
} virDomainInputBus;
1350

1351 1352 1353 1354 1355 1356 1357 1358 1359
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;

1360 1361 1362
struct _virDomainInputDef {
    int type;
    int bus;
1363
    int model; /* virDomainInputModel */
1364 1365 1366
    struct {
        char *evdev;
    } source;
1367
    virDomainDeviceInfo info;
1368
    virDomainVirtioOptionsPtr virtio;
1369 1370
};

1371
typedef enum {
1372 1373
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,
F
Filip Alac 已提交
1374
    VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT,
1375 1376

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1377
} virDomainSoundCodecType;
1378

1379
typedef enum {
1380 1381 1382
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1383
    VIR_DOMAIN_SOUND_MODEL_AC97,
1384
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1385
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1386
    VIR_DOMAIN_SOUND_MODEL_USB,
1387 1388

    VIR_DOMAIN_SOUND_MODEL_LAST
1389
} virDomainSoundModel;
1390

1391 1392 1393 1394 1395
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1396 1397
struct _virDomainSoundDef {
    int model;
1398
    virDomainDeviceInfo info;
1399

1400
    size_t ncodecs;
1401
    virDomainSoundCodecDefPtr *codecs;
1402 1403
};

1404
typedef enum {
R
Richard Jones 已提交
1405 1406
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,
1407
    VIR_DOMAIN_WATCHDOG_MODEL_DIAG288,
R
Richard Jones 已提交
1408 1409

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1410
} virDomainWatchdogModel;
R
Richard Jones 已提交
1411

1412
typedef enum {
R
Richard Jones 已提交
1413 1414 1415 1416
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1417
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1418
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,
1419
    VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI,
R
Richard Jones 已提交
1420 1421

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1422
} virDomainWatchdogAction;
R
Richard Jones 已提交
1423 1424 1425 1426

struct _virDomainWatchdogDef {
    int model;
    int action;
1427
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1428 1429
};

1430

1431 1432
/* the backend driver used for virtio interfaces */
typedef enum {
1433
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT = 0,
1434 1435 1436 1437 1438 1439 1440
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU,
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER,

    VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST
} virDomainVideoBackendType;


1441
typedef enum {
1442
    VIR_DOMAIN_VIDEO_TYPE_DEFAULT,
1443 1444 1445 1446 1447
    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,
1448
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1449
    VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
M
Marc-André Lureau 已提交
1450
    VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
F
Fabian Freyer 已提交
1451
    VIR_DOMAIN_VIDEO_TYPE_GOP,
1452
    VIR_DOMAIN_VIDEO_TYPE_NONE,
1453
    VIR_DOMAIN_VIDEO_TYPE_BOCHS,
1454
    VIR_DOMAIN_VIDEO_TYPE_RAMFB,
1455 1456

    VIR_DOMAIN_VIDEO_TYPE_LAST
1457
} virDomainVideoType;
1458 1459


1460 1461 1462 1463 1464 1465 1466 1467
typedef enum {
    VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
    VIR_DOMAIN_VIDEO_VGACONF_ON,
    VIR_DOMAIN_VIDEO_VGACONF_OFF,

    VIR_DOMAIN_VIDEO_VGACONF_LAST
} virDomainVideoVGAConf;

1468
VIR_ENUM_DECL(virDomainVideoVGAConf);
1469

1470
struct _virDomainVideoAccelDef {
1471 1472
    int accel2d; /* enum virTristateBool */
    int accel3d; /* enum virTristateBool */
1473
    char *rendernode;
1474 1475
};

1476 1477 1478 1479
struct _virDomainVideoResolutionDef {
    unsigned int x;
    unsigned int y;
};
1480

1481 1482
struct _virDomainVideoDriverDef {
   virDomainVideoVGAConf vgaconf;
1483
    char *vhost_user_binary;
1484 1485
};

1486
struct _virDomainVideoDef {
1487 1488
    virObjectPtr privateData;

1489
    int type;   /* enum virDomainVideoType */
1490 1491
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1492
    unsigned int vram64; /* kibibytes (multiples of 1024) */
1493
    unsigned int vgamem; /* kibibytes (multiples of 1024) */
1494
    unsigned int heads;
1495
    bool primary;
1496
    virDomainVideoAccelDefPtr accel;
1497
    virDomainVideoResolutionDefPtr res;
1498
    virDomainVideoDriverDefPtr driver;
1499
    virDomainDeviceInfo info;
J
Ján Tomko 已提交
1500
    virDomainVirtioOptionsPtr virtio;
1501
    virDomainVideoBackendType backend;
1502 1503
};

1504
/* graphics console modes */
1505
typedef enum {
1506 1507
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1508 1509
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1510
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1511
    VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS,
1512

1513
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1514
} virDomainGraphicsType;
1515

1516
typedef enum {
1517 1518 1519 1520 1521 1522
    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
1523
} virDomainGraphicsVNCSharePolicy;
1524

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

1534 1535
struct _virDomainGraphicsAuthDef {
    char *passwd;
1536
    bool expires; /* Whether there is an expiry time set */
1537
    time_t validTo;  /* seconds since epoch */
1538
    int connected; /* action if connected */
1539 1540
};

1541
typedef enum {
1542 1543 1544 1545 1546 1547
    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 已提交
1548
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1549
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1550 1551

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1552
} virDomainGraphicsSpiceChannelName;
1553

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

1562
typedef enum {
1563 1564 1565 1566 1567 1568 1569 1570 1571
    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
1572
} virDomainGraphicsSpiceImageCompression;
1573

1574
typedef enum {
1575 1576 1577 1578 1579 1580
    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
1581
} virDomainGraphicsSpiceJpegCompression;
1582

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

1592
typedef enum {
P
Peng Zhou 已提交
1593 1594 1595 1596 1597
    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
1598
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1599

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

1609
typedef enum {
1610 1611 1612
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1613
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1614

1615
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1616
} virDomainGraphicsListenType;
1617

1618
typedef enum {
M
Marc-André Lureau 已提交
1619 1620
    VIR_DOMAIN_HUB_TYPE_USB,

1621
    VIR_DOMAIN_HUB_TYPE_LAST
1622
} virDomainHubType;
M
Marc-André Lureau 已提交
1623

1624
struct _virDomainGraphicsListenDef {
1625
    virDomainGraphicsListenType type;
1626 1627
    char *address;
    char *network;
1628
    char *socket;
1629
    bool fromConfig;    /* true if the @address is config file originated */
1630
    bool autoGenerated;
1631 1632
};

1633
struct _virDomainGraphicsDef {
1634 1635
    virObjectPtr privateData;

M
Michal Privoznik 已提交
1636 1637 1638 1639 1640
    /* 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.
     */
1641
    virDomainGraphicsType type;
1642 1643 1644
    union {
        struct {
            int port;
1645
            bool portReserved;
M
Martin Kletzander 已提交
1646
            int websocket;
1647
            bool websocketGenerated;
1648
            bool autoport;
1649
            char *keymap;
1650
            virDomainGraphicsAuthDef auth;
1651
            int sharePolicy;
1652 1653 1654 1655
        } vnc;
        struct {
            char *display;
            char *xauth;
1656
            bool fullscreen;
1657
            virTristateBool gl;
1658
        } sdl;
1659 1660
        struct {
            int port;
1661 1662 1663
            bool autoport;
            bool replaceUser;
            bool multiUser;
1664 1665 1666
        } rdp;
        struct {
            char *display;
1667
            bool fullscreen;
1668
        } desktop;
1669 1670 1671
        struct {
            int port;
            int tlsPort;
1672 1673
            bool portReserved;
            bool tlsPortReserved;
1674
            virDomainGraphicsSpiceMouseMode mousemode;
1675
            char *keymap;
1676
            virDomainGraphicsAuthDef auth;
1677
            bool autoport;
1678
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1679
            virDomainGraphicsSpiceChannelMode defaultMode;
1680 1681 1682 1683
            int image;
            int jpeg;
            int zlib;
            int playback;
1684
            int streaming;
1685 1686 1687
            virTristateBool copypaste;
            virTristateBool filetransfer;
            virTristateBool gl;
1688
            char *rendernode;
1689
        } spice;
1690 1691 1692
        struct {
            char *rendernode;
        } egl_headless;
1693
    } data;
1694 1695 1696 1697 1698
    /* 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;
1699 1700
};

1701
typedef enum {
1702 1703 1704
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1705
} virDomainRedirdevBus;
1706 1707 1708 1709

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

1710
    virDomainChrSourceDefPtr source;
1711 1712 1713

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

1715
struct _virDomainRedirFilterUSBDevDef {
1716 1717 1718 1719
    int usbClass;
    int vendor;
    int product;
    int version;
1720
    bool allow;
1721 1722 1723 1724
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1725
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1726 1727
};

1728
typedef enum {
1729 1730
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1731
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1732 1733
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL,
1734 1735

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1736
} virDomainMemballoonModel;
1737 1738 1739 1740

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1741
    int period; /* seconds between collections */
1742
    int autodeflate; /* enum virTristateSwitch */
1743
    virDomainVirtioOptionsPtr virtio;
1744 1745
};

L
Li Zhang 已提交
1746 1747 1748
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1749

1750 1751
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1752 1753
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1754 1755 1756 1757

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

1758 1759 1760
struct _virDomainShmemDef {
    char *name;
    unsigned long long size;
1761
    int model; /* enum virDomainShmemModel */
1762 1763
    struct {
        bool enabled;
1764
        virDomainChrSourceDef chr;
1765 1766 1767 1768 1769 1770 1771 1772 1773
    } server;
    struct {
        bool enabled;
        unsigned vectors;
        virTristateSwitch ioeventfd;
    } msi;
    virDomainDeviceInfo info;
};

1774
typedef enum {
1775
    VIR_DOMAIN_SMBIOS_NONE = 0,
1776 1777 1778 1779 1780
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1781
} virDomainSmbiosMode;
1782

1783

1784
#define VIR_DOMAIN_MAX_BOOT_DEVS 4
1785

1786
typedef enum {
1787 1788 1789 1790 1791
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1792
    VIR_DOMAIN_BOOT_LAST
1793
} virDomainBootOrder;
1794

1795
typedef enum {
1796 1797 1798
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1799
    VIR_DOMAIN_FEATURE_HAP,
1800
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1801
    VIR_DOMAIN_FEATURE_PRIVNET,
1802
    VIR_DOMAIN_FEATURE_HYPERV,
1803
    VIR_DOMAIN_FEATURE_KVM,
1804
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1805
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1806
    VIR_DOMAIN_FEATURE_PMU,
1807
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1808
    VIR_DOMAIN_FEATURE_GIC,
M
Michal Privoznik 已提交
1809
    VIR_DOMAIN_FEATURE_SMM,
1810
    VIR_DOMAIN_FEATURE_IOAPIC,
1811
    VIR_DOMAIN_FEATURE_HPT,
M
Marc-André Lureau 已提交
1812
    VIR_DOMAIN_FEATURE_VMCOREINFO,
1813
    VIR_DOMAIN_FEATURE_HTM,
1814
    VIR_DOMAIN_FEATURE_NESTED_HV,
1815
    VIR_DOMAIN_FEATURE_MSRS,
1816
    VIR_DOMAIN_FEATURE_CCF_ASSIST,
1817 1818

    VIR_DOMAIN_FEATURE_LAST
1819
} virDomainFeature;
1820

1821
#define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12
1822

1823
typedef enum {
1824
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1825 1826
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1827 1828 1829 1830 1831 1832
    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,
1833
    VIR_DOMAIN_HYPERV_FREQUENCIES,
1834
    VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
1835
    VIR_DOMAIN_HYPERV_TLBFLUSH,
1836
    VIR_DOMAIN_HYPERV_IPI,
1837
    VIR_DOMAIN_HYPERV_EVMCS,
1838 1839

    VIR_DOMAIN_HYPERV_LAST
1840
} virDomainHyperv;
1841

1842 1843
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,
1844
    VIR_DOMAIN_KVM_DEDICATED,
1845 1846 1847 1848

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861
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;

1862 1863 1864 1865 1866 1867 1868 1869 1870 1871
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 {
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910
    VIR_DOMAIN_PROCES_CAPS_FEATURE_AUDIT_CONTROL = 0,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_AUDIT_WRITE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_BLOCK_SUSPEND,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_CHOWN,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_DAC_OVERRIDE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_DAC_READ_SEARCH,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_FOWNER,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_FSETID,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_IPC_LOCK,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_IPC_OWNER,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_KILL,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_LEASE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_LINUX_IMMUTABLE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_MAC_ADMIN,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_MAC_OVERRIDE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_MKNOD,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_NET_ADMIN,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_NET_BIND_SERVICE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_NET_BROADCAST,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_NET_RAW,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SETGID,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SETFCAP,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SETPCAP,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SETUID,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_ADMIN,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_BOOT,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_CHROOT,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_MODULE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_NICE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_PACCT,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_PTRACE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_RAWIO,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_RESOURCE,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_TIME,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYS_TTY_CONFIG,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_SYSLOG,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_WAKE_ALARM,
    VIR_DOMAIN_PROCES_CAPS_FEATURE_LAST
} virDomainProcessCapsFeature;
1911

1912 1913 1914 1915 1916 1917 1918 1919 1920 1921
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;

1922
VIR_ENUM_DECL(virDomainLockFailure);
1923

M
Michal Privoznik 已提交
1924
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1925
    int useserial; /* enum virTristateBool */
1926 1927 1928
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1929 1930
};

1931
typedef enum {
1932 1933
    VIR_DOMAIN_LOADER_TYPE_NONE = 0,
    VIR_DOMAIN_LOADER_TYPE_ROM,
1934 1935 1936 1937 1938
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

1939
VIR_ENUM_DECL(virDomainLoader);
1940 1941 1942 1943 1944

struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1945
    int secure;     /* enum virTristateBool */
1946
    char *nvram;    /* path to non-volatile RAM */
1947
    char *templt;   /* user override of path to master nvram */
1948 1949 1950 1951
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1952
typedef enum {
1953 1954
    VIR_DOMAIN_IOAPIC_NONE = 0,
    VIR_DOMAIN_IOAPIC_QEMU,
1955 1956 1957 1958 1959 1960 1961
    VIR_DOMAIN_IOAPIC_KVM,

    VIR_DOMAIN_IOAPIC_LAST
} virDomainIOAPIC;

VIR_ENUM_DECL(virDomainIOAPIC);

1962
typedef enum {
1963 1964
    VIR_DOMAIN_HPT_RESIZING_NONE = 0,
    VIR_DOMAIN_HPT_RESIZING_ENABLED,
1965 1966 1967 1968 1969 1970 1971 1972
    VIR_DOMAIN_HPT_RESIZING_DISABLED,
    VIR_DOMAIN_HPT_RESIZING_REQUIRED,

    VIR_DOMAIN_HPT_RESIZING_LAST
} virDomainHPTResizing;

VIR_ENUM_DECL(virDomainHPTResizing);

1973
/* Operating system configuration data & machine / arch */
1974 1975 1976 1977 1978
struct _virDomainOSEnv {
    char *name;
    char *value;
};

1979 1980
typedef enum {
    VIR_DOMAIN_OS_DEF_FIRMWARE_NONE = 0,
1981 1982
    VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS = VIR_DOMAIN_LOADER_TYPE_ROM,
    VIR_DOMAIN_OS_DEF_FIRMWARE_EFI = VIR_DOMAIN_LOADER_TYPE_PFLASH,
1983 1984 1985 1986

    VIR_DOMAIN_OS_DEF_FIRMWARE_LAST
} virDomainOsDefFirmware;

1987 1988
G_STATIC_ASSERT((int)VIR_DOMAIN_OS_DEF_FIRMWARE_LAST == (int)VIR_DOMAIN_LOADER_TYPE_LAST);

1989 1990
VIR_ENUM_DECL(virDomainOsDefFirmware);

1991
struct _virDomainOSDef {
1992
    int type;
1993
    virDomainOsDefFirmware firmware;
1994
    virArch arch;
1995
    char *machine;
1996
    size_t nBootDevs;
1997
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1998
    int bootmenu; /* enum virTristateBool */
1999 2000
    unsigned int bm_timeout;
    bool bm_timeout_set;
2001
    char *init;
2002
    char **initargv;
2003
    virDomainOSEnvPtr *initenv;
2004
    char *initdir;
2005 2006
    char *inituser;
    char *initgroup;
2007 2008 2009
    char *kernel;
    char *initrd;
    char *cmdline;
2010
    char *dtb;
2011
    char *root;
J
Ján Tomko 已提交
2012
    char *slic_table;
2013
    virDomainLoaderDefPtr loader;
2014 2015
    char *bootloader;
    char *bootloaderArgs;
2016
    int smbios_mode;
2017

M
Michal Privoznik 已提交
2018
    virDomainBIOSDef bios;
2019 2020
};

2021
typedef enum {
2022 2023 2024 2025 2026
    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 已提交
2027
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
2028
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
2029
    VIR_DOMAIN_TIMER_NAME_ARMVTIMER,
2030

2031
    VIR_DOMAIN_TIMER_NAME_LAST
2032
} virDomainTimerNameType;
2033

2034
typedef enum {
2035 2036 2037
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
2038

2039
    VIR_DOMAIN_TIMER_TRACK_LAST
2040
} virDomainTimerTrackType;
2041

2042
typedef enum {
2043 2044 2045 2046 2047
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

2048
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
2049
} virDomainTimerTickpolicyType;
2050

2051
typedef enum {
2052 2053 2054 2055
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
2056
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
2057

2058
    VIR_DOMAIN_TIMER_MODE_LAST
2059
} virDomainTimerModeType;
2060

2061
typedef enum {
2062
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
2063 2064
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

2065
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
2066
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
2067

2068
struct _virDomainThreadSchedParam {
2069
    virProcessSchedPolicy policy;
2070 2071 2072
    int priority;
};

2073 2074 2075 2076 2077 2078
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

2079 2080 2081 2082 2083
struct _virDomainTimerDef {
    int name;
    int present;    /* unspecified = -1, no = 0, yes = 1 */
    int tickpolicy; /* none|catchup|merge|discard */

2084 2085 2086
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
L
Leonid Bloch 已提交
2087
    int track;  /* boot|guest|wall */
2088 2089 2090 2091 2092 2093

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

2094
typedef enum {
2095 2096
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
2097
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
2098
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
2099

2100
    VIR_DOMAIN_CLOCK_OFFSET_LAST
2101
} virDomainClockOffsetType;
2102

2103
typedef enum {
2104 2105 2106
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

2107
    VIR_DOMAIN_CLOCK_BASIS_LAST
2108
} virDomainClockBasis;
2109

2110 2111
struct _virDomainClockDef {
    int offset;
2112

2113
    union {
2114 2115 2116
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
2117
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
2118 2119 2120
        struct {
            long long adjustment;
            int basis;
2121 2122 2123 2124 2125 2126 2127

            /* 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;
2128
        } variable;
2129 2130 2131 2132 2133

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

2135
    size_t ntimers;
2136
    virDomainTimerDefPtr *timers;
2137 2138
};

2139

2140
struct _virBlkioDevice {
2141 2142
    char *path;
    unsigned int weight;
2143 2144 2145 2146
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
2147 2148
};

2149
typedef enum {
2150
    VIR_DOMAIN_RNG_MODEL_VIRTIO,
2151 2152
    VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL,
2153 2154

    VIR_DOMAIN_RNG_MODEL_LAST
2155
} virDomainRNGModel;
2156

2157
typedef enum {
2158 2159
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
H
Han Han 已提交
2160
    VIR_DOMAIN_RNG_BACKEND_BUILTIN,
2161 2162

    VIR_DOMAIN_RNG_BACKEND_LAST
2163
} virDomainRNGBackend;
2164 2165 2166 2167

struct _virDomainRNGDef {
    int model;
    int backend;
2168 2169
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
2170 2171 2172 2173 2174 2175 2176 2177

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

    virDomainDeviceInfo info;
2178
    virDomainVirtioOptionsPtr virtio;
2179 2180
};

2181 2182 2183
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2184
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2185 2186 2187 2188 2189

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
2190
    virDomainMemoryAccess access;
2191
    virTristateBool discard;
2192

2193 2194 2195
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2196
    char *nvdimmPath;
2197
    unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
2198
    bool nvdimmPmem; /* valid only for NVDIMM */
2199 2200 2201

    /* target */
    int model; /* virDomainMemoryModel */
2202
    int targetNode;
2203
    unsigned long long size; /* kibibytes */
2204
    unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
2205
    bool readonly; /* valid only for NVDIMM */
2206

2207 2208 2209
    /* required for QEMU NVDIMM ppc64 support */
    unsigned char uuid[VIR_UUID_BUFLEN];

2210 2211 2212 2213 2214
    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2230 2231 2232 2233 2234
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2235
    VIR_DOMAIN_PANIC_MODEL_S390,
2236 2237 2238 2239

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2240
struct _virDomainPanicDef {
2241
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2242 2243 2244 2245
    virDomainDeviceInfo info;
};


2246
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2247
                              int ndevices);
2248

2249 2250 2251
struct _virDomainResourceDef {
    char *partition;
};
2252

2253
struct _virDomainHugePage {
2254 2255 2256 2257
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2258
#define VIR_DOMAIN_CPUMASK_LEN 1024
2259

2260 2261 2262
struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2263
    int thread_id;
2264
    virBitmapPtr cpumask;
2265 2266

    virDomainThreadSchedParam sched;
2267 2268 2269 2270
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2271

2272
struct _virDomainCputune {
2273
    unsigned long long shares;
2274 2275 2276
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2277
    unsigned long long global_period;
2278
    long long global_quota;
2279 2280
    unsigned long long emulator_period;
    long long emulator_quota;
2281 2282
    unsigned long long iothread_period;
    long long iothread_quota;
2283
    virBitmapPtr emulatorpin;
2284
    virDomainThreadSchedParamPtr emulatorsched;
2285 2286
};

2287

2288 2289 2290 2291 2292 2293
struct _virDomainResctrlMonDef {
    virBitmapPtr vcpus;
    virResctrlMonitorType tag;
    virResctrlMonitorPtr instance;
};

B
Bing Niu 已提交
2294
struct _virDomainResctrlDef {
2295 2296
    virBitmapPtr vcpus;
    virResctrlAllocPtr alloc;
2297 2298 2299

    virDomainResctrlMonDefPtr *monitors;
    size_t nmonitors;
2300 2301 2302
};


2303
struct _virDomainVcpuDef {
2304
    bool online;
2305 2306 2307
    virTristateBool hotpluggable;
    unsigned int order;

2308
    virBitmapPtr cpumask;
2309 2310

    virDomainThreadSchedParam sched;
2311 2312

    virObjectPtr privateData;
2313 2314
};

2315 2316 2317 2318 2319 2320 2321 2322
struct _virDomainBlkiotune {
    unsigned int weight;

    size_t ndevices;
    virBlkioDevicePtr devices;
};

struct _virDomainMemtune {
2323 2324 2325
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2326 2327
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2328 2329 2330 2331

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2332 2333 2334 2335
    /* 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 */

2336 2337 2338
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2339 2340 2341 2342
    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 */
2343 2344 2345 2346

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2347 2348

    virTristateBool discard;
2349 2350 2351 2352 2353 2354 2355 2356
};

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

Q
Qiaowei Ren 已提交
2357 2358 2359 2360 2361
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2362 2363 2364 2365 2366
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

2367 2368 2369 2370 2371 2372 2373 2374
typedef enum {
    VIR_DOMAIN_LAUNCH_SECURITY_NONE,
    VIR_DOMAIN_LAUNCH_SECURITY_SEV,

    VIR_DOMAIN_LAUNCH_SECURITY_LAST,
} virDomainLaunchSecurity;


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


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

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

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

J
Ján Tomko 已提交
2400 2401 2402
typedef enum {
    VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO,
2403 2404
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL,
J
Ján Tomko 已提交
2405 2406 2407 2408

    VIR_DOMAIN_VSOCK_MODEL_LAST
} virDomainVsockModel;

J
Ján Tomko 已提交
2409
struct _virDomainVsockDef {
2410
    virObjectPtr privateData;
J
Ján Tomko 已提交
2411 2412 2413 2414 2415 2416

    virDomainVsockModel model;
    unsigned int guest_cid;
    virTristateBool auto_cid;

    virDomainDeviceInfo info;
J
Ján Tomko 已提交
2417 2418
};

2419 2420 2421
struct _virDomainVirtioOptions {
    virTristateSwitch iommu;
    virTristateSwitch ats;
2422
    virTristateSwitch packed;
2423 2424
};

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

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

2440
    char *name;
2441
    char *title;
2442
    char *description;
2443

2444 2445
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2446

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

2454 2455
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2456

2457
    virDomainCputune cputune;
2458

B
Bing Niu 已提交
2459 2460
    virDomainResctrlDefPtr *resctrls;
    size_t nresctrls;
2461

2462
    virDomainNumaPtr numa;
2463
    virDomainResourceDefPtr resource;
2464
    virDomainIdMapDef idmap;
2465

2466 2467 2468 2469 2470
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2471 2472
    int onLockFailure; /* enum virDomainLockFailureAction */

2473
    virDomainPowerManagement pm;
2474

2475
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2476

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

2495 2496 2497
    bool tseg_specified;
    unsigned long long tseg_size;

2498
    virDomainClockDef clock;
2499

2500
    size_t ngraphics;
2501
    virDomainGraphicsDefPtr *graphics;
2502

2503
    size_t ndisks;
2504 2505
    virDomainDiskDefPtr *disks;

2506
    size_t ncontrollers;
2507 2508
    virDomainControllerDefPtr *controllers;

2509
    size_t nfss;
2510 2511
    virDomainFSDefPtr *fss;

2512
    size_t nnets;
2513 2514
    virDomainNetDefPtr *nets;

2515
    size_t ninputs;
2516 2517
    virDomainInputDefPtr *inputs;

2518
    size_t nsounds;
2519 2520
    virDomainSoundDefPtr *sounds;

2521
    size_t nvideos;
2522 2523
    virDomainVideoDefPtr *videos;

2524
    size_t nhostdevs;
2525 2526
    virDomainHostdevDefPtr *hostdevs;

2527
    size_t nredirdevs;
2528 2529
    virDomainRedirdevDefPtr *redirdevs;

2530
    size_t nsmartcards;
E
Eric Blake 已提交
2531 2532
    virDomainSmartcardDefPtr *smartcards;

2533
    size_t nserials;
2534 2535
    virDomainChrDefPtr *serials;

2536
    size_t nparallels;
2537 2538
    virDomainChrDefPtr *parallels;

2539
    size_t nchannels;
2540 2541
    virDomainChrDefPtr *channels;

2542
    size_t nconsoles;
2543 2544
    virDomainChrDefPtr *consoles;

2545
    size_t nleases;
2546 2547
    virDomainLeaseDefPtr *leases;

2548
    size_t nhubs;
M
Marc-André Lureau 已提交
2549 2550
    virDomainHubDefPtr *hubs;

2551 2552 2553
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2554 2555 2556
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2557 2558 2559
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2560 2561 2562
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2563 2564 2565
    size_t npanics;
    virDomainPanicDefPtr *panics;

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

    void *namespaceData;
2578
    virXMLNamespace ns;
2579

2580 2581
    virDomainKeyWrapDefPtr keywrap;

2582
    /* SEV-specific domain */
2583
    virDomainSEVDefPtr sev;
2584

2585 2586
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2587 2588 2589 2590 2591 2592

    /* 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 */
2593 2594
};

2595

2596
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2597
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2598
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2599
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2600

2601 2602 2603 2604 2605 2606 2607
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

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

    VIR_DOMAIN_TAINT_LAST
2623
} virDomainTaintFlags;
2624

2625
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2626 2627 2628 2629 2630 2631
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2632
struct _virDomainObj {
2633
    virObjectLockable parent;
2634
    virCond cond;
2635

2636
    pid_t pid;
J
Jiri Denemark 已提交
2637
    virDomainStateReason state;
2638 2639 2640

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2641
    unsigned int updated : 1;
2642
    unsigned int removing : 1;
2643 2644 2645

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

2647
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2648

2649 2650
    bool hasManagedSave;

2651 2652
    virDomainCheckpointObjListPtr checkpoints;

2653 2654
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2655 2656

    int taint;
2657 2658 2659

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

2662 2663 2664
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainObj, virObjectUnref);


2665 2666
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2667

2668

2669 2670
/* NB: Any new flag to this list be considered to be set in
 * virt-aa-helper code if the flag prevents parsing. */
2671 2672
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2673
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2674
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2675
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2676
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2677
    VIR_DOMAIN_DEF_FEATURE_USER_ALIAS = (1 << 5),
2678
    VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER = (1 << 6),
2679
    VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT = (1 << 7),
2680
    VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING = (1 << 8),
2681 2682 2683
} virDomainDefFeatures;


2684 2685 2686 2687 2688 2689 2690
/* 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,
                                                  void *opaque);

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

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

2729 2730 2731 2732 2733
/* 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,
                                            void *opaque);
2734

2735 2736 2737 2738 2739 2740
/* 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);

2741
struct _virDomainDefParserConfig {
2742
    /* driver domain definition callbacks */
2743
    virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
2744
    virDomainDefPostParseDataAlloc domainPostParseDataAlloc;
2745 2746
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2747
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2748
    virDomainDefPostParseDataFree domainPostParseDataFree;
2749

2750 2751
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2752
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2753

2754
    /* private data for the callbacks */
2755 2756
    void *priv;
    virFreeCallback privFree;
2757 2758

    /* data */
2759
    unsigned int features; /* virDomainDefFeatures */
2760
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2761
    virArch defArch;
2762
    const char *netPrefix;
2763
    const char *defSecModel;
2764 2765
};

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

2775 2776
typedef void *(*virDomainXMLPrivateDataGetParseOpaqueFunc)(virDomainObjPtr vm);

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

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


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

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

struct _virDomainABIStability {
    virDomainABIStabilityDomain domain;
};

2819 2820
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
2821
                                            virXMLNamespacePtr xmlns,
2822 2823 2824 2825 2826
                                            virDomainABIStabilityPtr abi,
                                            virSaveCookieCallbacksPtr saveCookie);

virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
2827

2828 2829 2830 2831 2832 2833 2834
typedef int (*virDomainMomentPostParseCallback)(virDomainMomentDefPtr def);

void virDomainXMLOptionSetMomentPostParse(virDomainXMLOptionPtr xmlopt,
                                          virDomainMomentPostParseCallback cb);
int virDomainXMLOptionRunMomentPostParse(virDomainXMLOptionPtr xmlopt,
                                         virDomainMomentDefPtr def);

2835 2836
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2837
virXMLNamespacePtr
2838
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2839 2840
    ATTRIBUTE_NONNULL(1);

2841 2842 2843 2844
bool
virDomainSCSIDriveAddressIsUsed(const virDomainDef *def,
                                const virDomainDeviceDriveAddress *addr);

2845 2846 2847 2848
int virDomainDefPostParse(virDomainDefPtr def,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2849
bool virDomainDefHasUSB(const virDomainDef *def);
2850

2851 2852 2853 2854
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
                                           virDomainDeviceDefPtr dev,
                                           unsigned int flags);

2855 2856
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);

2857
int virDomainDefValidate(virDomainDefPtr def,
2858 2859 2860
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2861 2862 2863
int
virDomainActualNetDefValidate(const virDomainNetDef *net);

2864
static inline bool
D
Daniel P. Berrange 已提交
2865
virDomainObjIsActive(virDomainObjPtr dom)
2866 2867 2868 2869
{
    return dom->def->id != -1;
}

2870 2871
int virDomainObjCheckActive(virDomainObjPtr dom);

2872 2873 2874 2875 2876 2877 2878 2879 2880
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)
2881
    G_GNUC_WARN_UNUSED_RESULT;
2882
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2883 2884
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2885

2886
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2887
    ATTRIBUTE_NONNULL(1);
2888

M
Michal Privoznik 已提交
2889 2890
void virDomainObjEndAPI(virDomainObjPtr *vm);

2891
bool virDomainObjTaint(virDomainObjPtr obj,
2892
                       virDomainTaintFlags taint);
2893

2894 2895 2896 2897
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2898

H
Hu Tao 已提交
2899
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2900
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2901
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
J
Ján Tomko 已提交
2902
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
2903
void virDomainInputDefFree(virDomainInputDefPtr def);
2904
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2905
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2906
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2907 2908
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2909
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2910
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
2911
    G_GNUC_WARN_UNUSED_RESULT;
2912
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
2913
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
2914
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
2915
    G_GNUC_WARN_UNUSED_RESULT;
2916 2917
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2918 2919
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
2920 2921 2922 2923
                                  const virDomainDeviceDriveAddress *addr);
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2924 2925

virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type);
2926
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2927
bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont);
2928

2929
virDomainFSDefPtr virDomainFSDefNew(virDomainXMLOptionPtr xmlopt);
2930
void virDomainFSDefFree(virDomainFSDefPtr def);
2931
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
J
Ján Tomko 已提交
2932 2933
virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt);
void virDomainVsockDefFree(virDomainVsockDefPtr vsock);
2934
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainVsockDef, virDomainVsockDefFree);
2935
void virDomainNetDefClear(virDomainNetDefPtr def);
2936
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2937
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2938
void virDomainChrDefFree(virDomainChrDefPtr def);
2939 2940
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
                              virDomainChrSourceDefPtr src);
2941
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
J
Jidong Xia 已提交
2942 2943
ssize_t virDomainSoundDefFind(const virDomainDef *def,
                              const virDomainSoundDef *sound);
2944
void virDomainSoundDefFree(virDomainSoundDefPtr def);
J
Jidong Xia 已提交
2945
virDomainSoundDefPtr virDomainSoundDefRemove(virDomainDefPtr def, size_t idx);
2946
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2947
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2948
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
2949
virDomainVideoDefPtr virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt);
2950
void virDomainVideoDefFree(virDomainVideoDefPtr def);
2951
void virDomainVideoDefClear(virDomainVideoDefPtr def);
J
John Ferlan 已提交
2952
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
2953
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2954
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2955
void virDomainHubDefFree(virDomainHubDefPtr def);
2956
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2957
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2958
void virDomainShmemDefFree(virDomainShmemDefPtr def);
2959
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2960
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDeviceDef, virDomainDeviceDefFree);
2961
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2962
                                             const virDomainDef *def,
2963 2964
                                             virDomainXMLOptionPtr xmlopt,
                                             void *parseOpaque);
2965
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
C
Cole Robinson 已提交
2966 2967
void virDomainDeviceSetData(virDomainDeviceDefPtr device,
                            void *devicedata);
2968
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2969

2970
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2971 2972
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2973 2974 2975 2976 2977 2978
                                           void *opaque);

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

2979 2980
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
2981
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
2982

2983
void virDomainDefFree(virDomainDefPtr vm);
2984
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDef, virDomainDefFree);
2985

2986 2987 2988
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);

2989
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
2990

2991 2992
virDomainGraphicsDefPtr
virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt);
2993 2994 2995 2996

virDomainNetDefPtr
virDomainNetDefNew(virDomainXMLOptionPtr xmlopt);

2997
virDomainDefPtr virDomainDefNew(void);
2998

2999
void virDomainObjAssignDef(virDomainObjPtr domain,
3000
                           virDomainDefPtr def,
3001 3002
                           bool live,
                           virDomainDefPtr *oldDef);
3003
int virDomainObjSetDefTransient(virDomainXMLOptionPtr xmlopt,
3004 3005
                                virDomainObjPtr domain,
                                void *parseOpaque);
3006
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
3007
virDomainDefPtr
3008
virDomainObjGetPersistentDef(virDomainXMLOptionPtr xmlopt,
3009 3010
                             virDomainObjPtr domain,
                             void *parseOpaque);
3011 3012 3013 3014 3015 3016 3017 3018

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

int virDomainObjGetDefs(virDomainObjPtr vm,
                        unsigned int flags,
                        virDomainDefPtr *liveDef,
                        virDomainDefPtr *persDef);
3019 3020 3021
virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                           unsigned int flags,
                                           bool *state);
3022
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
3023

3024 3025
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virDomainXMLOptionPtr xmlopt,
3026
                                 void *parseOpaque,
3027 3028
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
3029 3030
                                              virDomainXMLOptionPtr xmlopt,
                                              void *parseOpaque);
3031

3032 3033 3034
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
3035 3036 3037 3038
    /* 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. */
3039 3040 3041 3042 3043
    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,
3044
    /* internal flag passed to device info sub-parser to allow using <rom> */
3045
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
3046
    /* internal flag passed to device info sub-parser to allow specifying boot order */
3047 3048
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    /* parse only source half of <disk> */
3049
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 6,
3050
    /* perform RNG schema validation on the passed XML document */
3051
    VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA = 1 << 7,
3052
    /* allow updates in post parse callback that would break ABI otherwise */
3053
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE = 1 << 8,
3054
    /* skip definition validation checks meant to be executed on define time only */
3055
    VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 9,
3056
    /* skip parsing of security labels */
3057
    VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 10,
3058 3059 3060
    /* 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. */
3061
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 11,
3062 3063 3064 3065
    /* 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 */
3066
    VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL = 1 << 12,
3067 3068 3069 3070 3071
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
3072
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
3073
    /* format internal domain status information */
3074
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
3075
    /* format <actual> element */
3076
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
3077
    /* format original states of host PCI device */
3078 3079 3080 3081
    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,
3082 3083
} virDomainDefFormatFlags;

3084 3085 3086 3087 3088 3089 3090 3091 3092
/* 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;

3093
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
3094
                                              const virDomainDef *def,
3095
                                              virDomainXMLOptionPtr xmlopt,
3096
                                              void *parseOpaque,
L
Laine Stump 已提交
3097
                                              unsigned int flags);
3098 3099 3100
virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr,
                                          virDomainXMLOptionPtr xmlopt,
                                          unsigned int flags);
3101
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
3102
                                        virDomainXMLOptionPtr xmlopt,
3103
                                        void *parseOpaque,
L
Laine Stump 已提交
3104
                                        unsigned int flags);
3105
virDomainDefPtr virDomainDefParseFile(const char *filename,
3106
                                      virDomainXMLOptionPtr xmlopt,
3107
                                      void *parseOpaque,
L
Laine Stump 已提交
3108
                                      unsigned int flags);
3109
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
3110
                                      xmlNodePtr root,
3111
                                      virDomainXMLOptionPtr xmlopt,
3112
                                      void *parseOpaque,
L
Laine Stump 已提交
3113
                                      unsigned int flags);
3114 3115 3116 3117
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3118 3119 3120
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3121

3122
bool virDomainDefCheckABIStability(virDomainDefPtr src,
3123 3124
                                   virDomainDefPtr dst,
                                   virDomainXMLOptionPtr xmlopt);
3125

3126 3127
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
                                        virDomainDefPtr dst,
3128
                                        virDomainXMLOptionPtr xmlopt,
3129 3130
                                        unsigned int flags);

3131 3132
int virDomainDefAddImplicitDevices(virDomainDefPtr def,
                                   virDomainXMLOptionPtr xmlopt);
3133

3134
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
3135 3136 3137 3138 3139
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);

3140 3141 3142 3143 3144 3145
/* 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. */
3146
#define VIR_DOMAIN_XML_COMMON_FLAGS \
3147 3148
    (VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE | \
     VIR_DOMAIN_XML_MIGRATABLE)
3149 3150
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

3151
char *virDomainDefFormat(virDomainDefPtr def,
3152 3153
                         virDomainXMLOptionPtr xmlopt,
                         unsigned int flags)
J
John Ferlan 已提交
3154
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3155 3156 3157
char *virDomainObjFormat(virDomainObjPtr obj,
                         virDomainXMLOptionPtr xmlopt,
                         unsigned int flags)
J
John Ferlan 已提交
3158
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3159
int virDomainDefFormatInternal(virDomainDefPtr def,
3160
                               virDomainXMLOptionPtr xmlopt,
3161
                               virBufferPtr buf,
3162 3163
                               unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3164
    ATTRIBUTE_NONNULL(3);
3165
int virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
3166
                                          virDomainXMLOptionPtr xmlopt,
3167
                                          virBufferPtr buf,
3168 3169 3170
                                          const char *rootname,
                                          unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3171
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3172

3173 3174
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
3175
                              const char *element,
3176
                              int policy,
3177
                              bool attrIndex,
3178
                              unsigned int flags,
3179
                              bool formatsecrets,
3180
                              virDomainXMLOptionPtr xmlopt);
3181

3182 3183 3184 3185 3186 3187
int
virDomainDiskBackingStoreFormat(virBufferPtr buf,
                                virStorageSourcePtr src,
                                virDomainXMLOptionPtr xmlopt,
                                unsigned int flags);

3188 3189
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
3190
                          virDomainXMLOptionPtr xmlopt,
3191 3192
                          unsigned int flags);

3193 3194 3195 3196 3197 3198
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

3199
int virDomainDefCompatibleDevice(virDomainDefPtr def,
3200
                                 virDomainDeviceDefPtr dev,
3201
                                 virDomainDeviceDefPtr oldDev,
3202 3203
                                 virDomainDeviceAction action,
                                 bool live);
3204

3205 3206
void virDomainRNGDefFree(virDomainRNGDefPtr def);

3207
int virDomainDiskIndexByAddress(virDomainDefPtr def,
3208
                                virPCIDeviceAddressPtr pci_controller,
3209 3210
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
3211
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
3212
                                           virPCIDeviceAddressPtr pci_controller,
3213 3214 3215
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
3216 3217
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
3218 3219 3220
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
3221 3222 3223 3224
virDomainDiskDefPtr
virDomainDiskByTarget(virDomainDefPtr def,
                      const char *dst);

3225
int virDomainDiskInsert(virDomainDefPtr def,
3226
                        virDomainDiskDefPtr disk)
3227
    G_GNUC_WARN_UNUSED_RESULT;
3228 3229
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
3230 3231
int virDomainStorageNetworkParseHost(xmlNodePtr hostnode,
                                     virStorageNetHostDefPtr host);
3232
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
3233 3234
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
3235

3236 3237 3238 3239
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
3240

3241 3242
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
3243
virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname);
3244
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
3245
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
3246
int virDomainNetUpdate(virDomainDefPtr def, size_t netidx, virDomainNetDefPtr newnet);
3247 3248
int virDomainNetDHCPInterfaces(virDomainDefPtr def, virDomainInterfacePtr **ifaces);
int virDomainNetARPInterfaces(virDomainDefPtr def, virDomainInterfacePtr **ifaces);
3249
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
3250
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
3251

L
Laine Stump 已提交
3252
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
3253 3254
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
3255 3256 3257
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

3258 3259
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
3260 3261
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
3262
            ATTRIBUTE_NONNULL(1);
3263 3264 3265
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
3266

3267
virDomainNetType virDomainNetGetActualType(const virDomainNetDef *iface);
3268 3269 3270 3271
const char *virDomainNetGetActualBridgeName(const virDomainNetDef *iface);
int virDomainNetGetActualBridgeMACTableManager(const virDomainNetDef *iface);
const char *virDomainNetGetActualDirectDev(const virDomainNetDef *iface);
int virDomainNetGetActualDirectMode(const virDomainNetDef *iface);
3272
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
3273
const virNetDevVPortProfile *
3274
virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface);
3275 3276
const virNetDevBandwidth *
virDomainNetGetActualBandwidth(const virDomainNetDef *iface);
3277
const virNetDevVlan *virDomainNetGetActualVlan(const virDomainNetDef *iface);
3278
bool virDomainNetGetActualTrustGuestRxFilters(const virDomainNetDef *iface);
3279 3280
virTristateBool
virDomainNetGetActualPortOptionsIsolated(const virDomainNetDef *iface);
3281 3282 3283
const char *virDomainNetGetModelString(const virDomainNetDef *net);
int virDomainNetSetModelString(virDomainNetDefPtr et,
                               const char *model);
3284
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
3285
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
3286 3287 3288
                                const char *address,
                                int family,
                                unsigned int prefix);
3289

3290
int virDomainControllerInsert(virDomainDefPtr def,
3291
                              virDomainControllerDefPtr controller)
3292
    G_GNUC_WARN_UNUSED_RESULT;
3293 3294
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
3295
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
3296
int virDomainControllerFindByType(virDomainDefPtr def, int type);
3297
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
3298
                                        virPCIDeviceAddressPtr addr);
3299
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
3300
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
3301
const char *virDomainControllerAliasFind(const virDomainDef *def,
3302 3303
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
3304 3305 3306 3307 3308

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
3309
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
3310
    G_GNUC_WARN_UNUSED_RESULT;
3311 3312
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
3313 3314 3315 3316 3317
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
3318

3319
void
3320
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
3321
                          virDomainChrDeviceType type,
3322 3323 3324
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3325 3326 3327
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
3328 3329 3330
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
3331
int
3332 3333 3334 3335 3336
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
3337 3338 3339 3340
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

3341 3342 3343
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

3344 3345 3346 3347
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

3348 3349 3350 3351 3352
int virDomainDefSave(virDomainDefPtr def,
                     virDomainXMLOptionPtr xmlopt,
                     const char *configDir)
    G_GNUC_WARN_UNUSED_RESULT
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3353
    ATTRIBUTE_NONNULL(3);
3354 3355 3356 3357 3358 3359

int virDomainObjSave(virDomainObjPtr obj,
                     virDomainXMLOptionPtr xmlopt,
                     const char *statusDir)
    G_GNUC_WARN_UNUSED_RESULT
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3360
    ATTRIBUTE_NONNULL(3);
3361

3362 3363 3364 3365
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

3366
int virDomainDeleteConfig(const char *configDir,
3367
                          const char *autostartDir,
3368 3369
                          virDomainObjPtr dom);

3370
char *virDomainConfigFile(const char *dir,
3371 3372
                          const char *name);

3373 3374 3375 3376
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

3377
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
3378
                                                  const char *target);
3379
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
3380
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
3381 3382
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

3383 3384
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
3385

E
Eric Blake 已提交
3386 3387 3388 3389 3390 3391 3392 3393 3394
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3395 3396 3397 3398 3399 3400 3401 3402 3403
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3404 3405 3406 3407 3408 3409 3410
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

J
Jiri Denemark 已提交
3411 3412 3413 3414 3415 3416 3417
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3418 3419 3420
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3421
virSecurityDeviceLabelDefPtr
3422 3423
virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDefPtr def,
                                         const char *model);
3424

3425 3426
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3427

3428
int virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem)
3429
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3430 3431 3432
virDomainMemoryDefPtr virDomainMemoryRemove(virDomainDefPtr def, int idx)
    ATTRIBUTE_NONNULL(1);
int virDomainMemoryFindByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem)
3433
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3434 3435
int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem)
3436
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3437

3438
int virDomainShmemDefInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem)
3439
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3440
bool virDomainShmemDefEquals(virDomainShmemDefPtr src, virDomainShmemDefPtr dst)
3441
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3442
ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem)
3443
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3444 3445
virDomainShmemDefPtr virDomainShmemDefRemove(virDomainDefPtr def, size_t idx)
    ATTRIBUTE_NONNULL(1);
3446 3447
ssize_t virDomainInputDefFind(const virDomainDef *def,
                              const virDomainInputDef *input)
3448
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3449 3450
bool virDomainVsockDefEquals(const virDomainVsockDef *a,
                             const virDomainVsockDef *b)
3451
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3452

3453 3454 3455 3456 3457
VIR_ENUM_DECL(virDomainTaint);
VIR_ENUM_DECL(virDomainVirt);
VIR_ENUM_DECL(virDomainBoot);
VIR_ENUM_DECL(virDomainFeature);
VIR_ENUM_DECL(virDomainCapabilitiesPolicy);
3458
VIR_ENUM_DECL(virDomainProcessCapsFeature);
3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471
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);
3472
VIR_ENUM_DECL(virDomainDiskModel);
3473 3474 3475 3476 3477 3478 3479
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);
3480
VIR_ENUM_DECL(virDomainControllerModelVirtioSerial);
3481 3482 3483 3484
VIR_ENUM_DECL(virDomainFS);
VIR_ENUM_DECL(virDomainFSDriver);
VIR_ENUM_DECL(virDomainFSAccessMode);
VIR_ENUM_DECL(virDomainFSWrpolicy);
3485
VIR_ENUM_DECL(virDomainFSModel);
3486
VIR_ENUM_DECL(virDomainFSCacheMode);
3487 3488 3489
VIR_ENUM_DECL(virDomainNet);
VIR_ENUM_DECL(virDomainNetBackend);
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
3490
VIR_ENUM_DECL(virDomainNetTeaming);
3491
VIR_ENUM_DECL(virDomainNetInterfaceLinkState);
3492
VIR_ENUM_DECL(virDomainNetModel);
3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509
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);
3510
VIR_ENUM_DECL(virDomainVideoBackend);
3511 3512 3513 3514 3515 3516 3517
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);
3518
VIR_ENUM_DECL(virDomainInputModel);
3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531
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);
3532
VIR_ENUM_DECL(virDomainMsrsUnknown);
3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545
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);
3546
/* from libvirt.h */
3547 3548 3549 3550 3551 3552 3553 3554 3555
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 已提交
3556 3557 3558 3559

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

3560 3561 3562
VIR_ENUM_DECL(virDomainSeclabel);
VIR_ENUM_DECL(virDomainClockOffset);
VIR_ENUM_DECL(virDomainClockBasis);
3563

3564 3565 3566 3567 3568
VIR_ENUM_DECL(virDomainTimerName);
VIR_ENUM_DECL(virDomainTimerTrack);
VIR_ENUM_DECL(virDomainTimerTickpolicy);
VIR_ENUM_DECL(virDomainTimerMode);
VIR_ENUM_DECL(virDomainCpuPlacementMode);
3569

3570
VIR_ENUM_DECL(virDomainStartupPolicy);
3571

3572 3573
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3574 3575
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3576 3577 3578 3579 3580
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3581 3582 3583 3584
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3585

3586 3587
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3588 3589
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3590 3591
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3592

3593 3594
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);

3595 3596
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3597 3598 3599 3600 3601
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3602 3603 3604 3605 3606 3607
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virDomainXMLOptionPtr xmlopt,
3608
                            const char *stateDir,
3609 3610 3611
                            const char *configDir,
                            unsigned int flags);

3612 3613 3614 3615 3616 3617 3618 3619
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3620 3621 3622
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3623 3624
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3625
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3626

3627 3628 3629 3630
virStorageSourcePtr
virDomainStorageSourceParseBase(const char *type,
                                const char *format,
                                const char *index)
3631
    G_GNUC_WARN_UNUSED_RESULT;
3632

3633 3634 3635
int virDomainStorageSourceParse(xmlNodePtr node,
                                xmlXPathContextPtr ctxt,
                                virStorageSourcePtr src,
3636 3637
                                unsigned int flags,
                                virDomainXMLOptionPtr xmlopt)
3638 3639
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3640 3641 3642 3643 3644
int
virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
                               virStorageSourcePtr src,
                               unsigned int flags,
                               virDomainXMLOptionPtr xmlopt)
3645
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3646

3647 3648 3649 3650 3651 3652
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
3653
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT;
3654

3655 3656
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

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

3659 3660 3661 3662 3663
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3664

3665 3666 3667
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3668 3669
bool
virDomainNetTypeSharesHostView(const virDomainNetDef *net);
3670

3671 3672 3673 3674
bool
virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
                                   virDomainLifecycleAction action);

3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686
virNetworkPortDefPtr
virDomainNetDefToNetworkPort(virDomainDefPtr dom,
                             virDomainNetDefPtr iface);

int
virDomainNetDefActualFromNetworkPort(virDomainNetDefPtr iface,
                                     virNetworkPortDefPtr port);

virNetworkPortDefPtr
virDomainNetDefActualToNetworkPort(virDomainDefPtr dom,
                                   virDomainNetDefPtr iface);

3687
int
3688 3689
virDomainNetAllocateActualDevice(virConnectPtr conn,
                                 virDomainDefPtr dom,
3690 3691 3692 3693
                                 virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void
3694 3695
virDomainNetNotifyActualDevice(virConnectPtr conn,
                               virDomainDefPtr dom,
3696 3697 3698 3699
                               virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

int
3700 3701
virDomainNetReleaseActualDevice(virConnectPtr conn,
                                virDomainDefPtr dom,
3702 3703 3704
                                virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

3705 3706 3707 3708
int
virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
                            virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3709

3710 3711 3712 3713
int
virDomainNetResolveActualType(virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1);

3714

3715
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
3716

3717 3718 3719
int
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                 virDomainDiskDetectZeroes detect_zeroes);
3720

3721 3722 3723
bool
virDomainDefHasManagedPR(const virDomainDef *def);

3724 3725 3726
bool
virDomainDefHasNVMeDisk(const virDomainDef *def);

3727 3728 3729
bool
virDomainDefHasVFIOHostdev(const virDomainDef *def);

3730 3731 3732
bool
virDomainDefHasMdevHostdev(const virDomainDef *def);

3733 3734 3735 3736 3737 3738
bool
virDomainDefHasOldStyleUEFI(const virDomainDef *def);

bool
virDomainDefHasOldStyleROUEFI(const virDomainDef *def);

3739 3740 3741
bool
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);

3742 3743 3744 3745 3746 3747 3748 3749
bool
virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics);

const char *
virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);

bool
virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);
3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761

bool
virDomainBlockIoTuneInfoHasBasic(const virDomainBlockIoTuneInfo *iotune);

bool
virDomainBlockIoTuneInfoHasMax(const virDomainBlockIoTuneInfo *iotune);

bool
virDomainBlockIoTuneInfoHasMaxLength(const virDomainBlockIoTuneInfo *iotune);

bool
virDomainBlockIoTuneInfoHasAny(const virDomainBlockIoTuneInfo *iotune);
3762 3763 3764 3765

void
virDomainBlockIoTuneInfoCopy(const virDomainBlockIoTuneInfo *src,
                             virDomainBlockIoTuneInfoPtr dst);
3766 3767 3768 3769

bool
virDomainBlockIoTuneInfoEqual(const virDomainBlockIoTuneInfo *a,
                              const virDomainBlockIoTuneInfo *b);
J
Ján Tomko 已提交
3770 3771 3772 3773 3774 3775 3776 3777 3778 3779

bool
virHostdevIsSCSIDevice(const virDomainHostdevDef *hostdev)
    ATTRIBUTE_NONNULL(1);
bool
virHostdevIsMdevDevice(const virDomainHostdevDef *hostdev)
    ATTRIBUTE_NONNULL(1);
bool
virHostdevIsVFIODevice(const virDomainHostdevDef *hostdev)
    ATTRIBUTE_NONNULL(1);