domain_conf.h 124.4 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
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,
H
Han Han 已提交
424
    VIR_DOMAIN_DISK_IO_URING,
M
Matthias Dahl 已提交
425 426

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

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

438

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

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

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

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

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

464 465 466 467 468 469 470 471 472
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 已提交
473 474 475 476 477 478 479
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;
480 481 482 483 484 485 486
    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;
487
    char *group_name;
488 489 490 491 492 493
    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;
494 495
    /* Don't forget to update virDomainBlockIoTuneInfoCopy and
     * virDomainBlockIoTuneInfoEqual. */
L
Lei Li 已提交
496 497
};

498

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

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

    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;

525

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

530 531
    virObjectPtr privateData;

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

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

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

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

L
Lei Li 已提交
554 555
    virDomainBlockIoTuneInfo blkdeviotune;

556 557
    char *driverName;

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

    bool diskElementAuth;
    bool diskElementEnc;
585 586 587
};


588
typedef enum {
589 590 591 592
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
593
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
594
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
595
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
J
Ján Tomko 已提交
596
    VIR_DOMAIN_CONTROLLER_TYPE_PCI,
597
    VIR_DOMAIN_CONTROLLER_TYPE_XENBUS,
598 599

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
600
} virDomainControllerType;
601

602

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

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
617
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
618

619
typedef enum {
620
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE = 0,
621 622
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE,
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE,
623
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420,
624
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM,
625
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM,
626
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB,
627
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE,
628
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT,
629
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE,
630
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_PCI_BRIDGE,
631 632 633 634

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

635
typedef enum {
636
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT = -1,
637 638 639 640 641
    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,
642
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
643
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
644
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
645 646
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL,
647

648
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
649
} virDomainControllerModelSCSI;
650

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

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
669
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
670

671
typedef enum {
672
    VIR_DOMAIN_CONTROLLER_MODEL_IDE_DEFAULT = -1,
673 674 675 676 677 678 679
    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;

680 681 682 683 684 685 686 687 688
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;

689
#define IS_USB2_CONTROLLER(ctrl) \
690 691 692 693 694 695
    (((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))

696 697 698 699 700
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

701
struct _virDomainPCIControllerOpts {
702 703
    bool pcihole64;
    unsigned long pcihole64size;
704 705 706 707 708 709 710

    /* 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 */
711 712 713 714 715 716 717 718

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

732 733 734 735
struct _virDomainUSBControllerOpts {
    int ports;   /* -1 == undef */
};

736 737
struct _virDomainXenbusControllerOpts {
    int maxGrantFrames;   /* -1 == undef */
738
    int maxEventChannels; /* -1 == undef */
739 740
};

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


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

    VIR_DOMAIN_FS_TYPE_LAST
773
} virDomainFSType;
774

775
/* Filesystem driver type */
776
typedef enum {
777 778 779
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
780
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
781
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
D
Dmitry Guryanov 已提交
782
    VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
783
    VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS,
784 785

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
786
} virDomainFSDriverType;
787

788
/* Filesystem mount access mode  */
789
typedef enum {
790 791 792 793 794
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
795
} virDomainFSAccessMode;
796

797
/* Filesystem Write policy */
798
typedef enum {
799 800 801 802
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
803
} virDomainFSWrpolicy;
804

805 806 807 808 809 810 811 812 813 814 815 816
/* 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);

817 818 819 820 821 822 823 824 825
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;

826 827 828 829 830 831 832 833
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;

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


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

876
    VIR_DOMAIN_NET_TYPE_LAST
877
} virDomainNetType;
878

879 880 881 882
/* network model types */
typedef enum {
    VIR_DOMAIN_NET_MODEL_UNKNOWN,
    VIR_DOMAIN_NET_MODEL_NETFRONT,
C
Cole Robinson 已提交
883 884 885
    VIR_DOMAIN_NET_MODEL_RTL8139,
    VIR_DOMAIN_NET_MODEL_VIRTIO,
    VIR_DOMAIN_NET_MODEL_E1000,
886 887 888 889 890 891 892
    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 已提交
893 894 895 896
    VIR_DOMAIN_NET_MODEL_VLANCE,
    VIR_DOMAIN_NET_MODEL_VMXNET,
    VIR_DOMAIN_NET_MODEL_VMXNET2,
    VIR_DOMAIN_NET_MODEL_VMXNET3,
C
Cole Robinson 已提交
897 898 899 900 901
    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,
902 903 904 905

    VIR_DOMAIN_NET_MODEL_LAST
} virDomainNetModelType;

906
/* the backend driver used for virtio interfaces */
907
typedef enum {
908 909 910 911
    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 */

912
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
913
} virDomainNetBackendType;
914

915
/* the TX algorithm used for virtio interfaces */
916
typedef enum {
917 918 919 920
    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,

921
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
922
} virDomainNetVirtioTxModeType;
923

924 925 926 927 928 929 930 931 932
/* 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;

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

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

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

1079 1080 1081 1082 1083 1084 1085 1086
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;

1087
VIR_ENUM_DECL(virDomainChrDeviceState);
1088

1089
typedef enum {
1090
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1091 1092
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1093
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1094

1095
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1096
} virDomainChrDeviceType;
1097

1098
typedef enum {
1099 1100
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
G
Guannan Ren 已提交
1101
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
M
Michal Privoznik 已提交
1102
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
1103
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
1104
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
1105
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP,
G
Guannan Ren 已提交
1106 1107

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1108
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1109

1110
typedef enum {
1111 1112
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
1113
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
J
Joao Martins 已提交
1114
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN,
1115

1116
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1117
} virDomainChrChannelTargetType;
1118

1119
typedef enum {
1120 1121
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
1122 1123
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
1124
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
1125 1126
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
1127 1128
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
1129

1130
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1131
} virDomainChrConsoleTargetType;
1132

1133 1134 1135 1136 1137
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,
1138
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
1139
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011,
1140 1141
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE,
1142
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A,
1143 1144 1145 1146 1147 1148

    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
} virDomainChrSerialTargetModel;

VIR_ENUM_DECL(virDomainChrSerialTargetModel);

1149
typedef enum {
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
    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,
1160
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1161
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1162
    VIR_DOMAIN_CHR_TYPE_NMDM,
1163

1164
    VIR_DOMAIN_CHR_TYPE_LAST
1165
} virDomainChrType;
1166

1167
typedef enum {
1168
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW = 0,
1169
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1170 1171
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1172

1173
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1174
} virDomainChrTcpProtocol;
1175

1176
typedef enum {
E
Eric Blake 已提交
1177 1178
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1179
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1180

1181
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1182
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1183

1184 1185 1186 1187 1188 1189 1190

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


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

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1237 1238 1239 1240
};

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

1243 1244 1245
    int targetType; /* enum virDomainChrConsoleTargetType ||
                       enum virDomainChrChannelTargetType ||
                       enum virDomainChrSerialTargetType according to deviceType */
1246
    int targetModel; /* enum virDomainChrSerialTargetModel */
1247

1248 1249 1250 1251 1252 1253
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

1254 1255
    virDomainChrDeviceState state;

1256
    virDomainChrSourceDefPtr source;
1257 1258

    virDomainDeviceInfo info;
1259 1260
};

1261
typedef enum {
E
Eric Blake 已提交
1262 1263 1264 1265
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

1266
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1267
} virDomainSmartcardType;
E
Eric Blake 已提交
1268

1269 1270
#define VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES 3
#define VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE "/etc/pki/nssdb"
E
Eric Blake 已提交
1271 1272 1273 1274 1275 1276 1277 1278 1279

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

    virDomainDeviceInfo info;
};

M
Marc-André Lureau 已提交
1286 1287 1288 1289 1290
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

1291
typedef enum {
1292
    VIR_DOMAIN_TPM_MODEL_DEFAULT,
1293
    VIR_DOMAIN_TPM_MODEL_TIS,
1294
    VIR_DOMAIN_TPM_MODEL_CRB,
1295
    VIR_DOMAIN_TPM_MODEL_SPAPR,
1296 1297

    VIR_DOMAIN_TPM_MODEL_LAST
1298
} virDomainTPMModel;
1299

1300
typedef enum {
1301
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
1302
    VIR_DOMAIN_TPM_TYPE_EMULATOR,
1303 1304

    VIR_DOMAIN_TPM_TYPE_LAST
1305
} virDomainTPMBackendType;
1306

1307 1308 1309 1310 1311 1312 1313 1314
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;

1315
#define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"
1316 1317

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

1336
typedef enum {
1337 1338
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1339
    VIR_DOMAIN_INPUT_TYPE_KBD,
1340
    VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
1341

1342
    VIR_DOMAIN_INPUT_TYPE_LAST
1343
} virDomainInputType;
1344

1345
typedef enum {
1346 1347 1348
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1349
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1350
    VIR_DOMAIN_INPUT_BUS_VIRTIO,
1351 1352

    VIR_DOMAIN_INPUT_BUS_LAST
1353
} virDomainInputBus;
1354

1355 1356 1357 1358 1359 1360 1361 1362 1363
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;

1364 1365 1366
struct _virDomainInputDef {
    int type;
    int bus;
1367
    int model; /* virDomainInputModel */
1368 1369 1370
    struct {
        char *evdev;
    } source;
1371
    virDomainDeviceInfo info;
1372
    virDomainVirtioOptionsPtr virtio;
1373 1374
};

1375
typedef enum {
1376 1377
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,
F
Filip Alac 已提交
1378
    VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT,
1379 1380

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1381
} virDomainSoundCodecType;
1382

1383
typedef enum {
1384 1385 1386
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1387
    VIR_DOMAIN_SOUND_MODEL_AC97,
1388
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1389
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1390
    VIR_DOMAIN_SOUND_MODEL_USB,
1391 1392

    VIR_DOMAIN_SOUND_MODEL_LAST
1393
} virDomainSoundModel;
1394

1395 1396 1397 1398 1399
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1400 1401
struct _virDomainSoundDef {
    int model;
1402
    virDomainDeviceInfo info;
1403

1404
    size_t ncodecs;
1405
    virDomainSoundCodecDefPtr *codecs;
1406 1407
};

1408
typedef enum {
R
Richard Jones 已提交
1409 1410
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,
1411
    VIR_DOMAIN_WATCHDOG_MODEL_DIAG288,
R
Richard Jones 已提交
1412 1413

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1414
} virDomainWatchdogModel;
R
Richard Jones 已提交
1415

1416
typedef enum {
R
Richard Jones 已提交
1417 1418 1419 1420
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1421
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1422
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,
1423
    VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI,
R
Richard Jones 已提交
1424 1425

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1426
} virDomainWatchdogAction;
R
Richard Jones 已提交
1427 1428 1429 1430

struct _virDomainWatchdogDef {
    int model;
    int action;
1431
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1432 1433
};

1434

1435 1436
/* the backend driver used for virtio interfaces */
typedef enum {
1437
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT = 0,
1438 1439 1440 1441 1442 1443 1444
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU,
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER,

    VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST
} virDomainVideoBackendType;


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

    VIR_DOMAIN_VIDEO_TYPE_LAST
1461
} virDomainVideoType;
1462 1463


1464 1465 1466 1467 1468 1469 1470 1471
typedef enum {
    VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
    VIR_DOMAIN_VIDEO_VGACONF_ON,
    VIR_DOMAIN_VIDEO_VGACONF_OFF,

    VIR_DOMAIN_VIDEO_VGACONF_LAST
} virDomainVideoVGAConf;

1472
VIR_ENUM_DECL(virDomainVideoVGAConf);
1473

1474
struct _virDomainVideoAccelDef {
1475 1476
    int accel2d; /* enum virTristateBool */
    int accel3d; /* enum virTristateBool */
1477
    char *rendernode;
1478 1479
};

1480 1481 1482 1483
struct _virDomainVideoResolutionDef {
    unsigned int x;
    unsigned int y;
};
1484

1485 1486
struct _virDomainVideoDriverDef {
   virDomainVideoVGAConf vgaconf;
1487
    char *vhost_user_binary;
1488 1489
};

1490
struct _virDomainVideoDef {
1491 1492
    virObjectPtr privateData;

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

1508
/* graphics console modes */
1509
typedef enum {
1510 1511
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1512 1513
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1514
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1515
    VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS,
1516

1517
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1518
} virDomainGraphicsType;
1519

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

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

1538 1539
struct _virDomainGraphicsAuthDef {
    char *passwd;
1540
    bool expires; /* Whether there is an expiry time set */
1541
    time_t validTo;  /* seconds since epoch */
1542
    int connected; /* action if connected */
1543 1544
};

1545
typedef enum {
1546 1547 1548 1549 1550 1551
    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 已提交
1552
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1553
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1554 1555

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1556
} virDomainGraphicsSpiceChannelName;
1557

1558
typedef enum {
1559 1560 1561 1562 1563
    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
1564
} virDomainGraphicsSpiceChannelMode;
1565

1566
typedef enum {
1567 1568 1569 1570 1571 1572 1573 1574 1575
    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
1576
} virDomainGraphicsSpiceImageCompression;
1577

1578
typedef enum {
1579 1580 1581 1582 1583 1584
    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
1585
} virDomainGraphicsSpiceJpegCompression;
1586

1587
typedef enum {
1588 1589 1590 1591 1592 1593
    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
1594
} virDomainGraphicsSpiceZlibCompression;
1595

1596
typedef enum {
P
Peng Zhou 已提交
1597 1598 1599 1600 1601
    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
1602
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1603

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

1613
typedef enum {
1614 1615 1616
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1617
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1618

1619
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1620
} virDomainGraphicsListenType;
1621

1622
typedef enum {
M
Marc-André Lureau 已提交
1623 1624
    VIR_DOMAIN_HUB_TYPE_USB,

1625
    VIR_DOMAIN_HUB_TYPE_LAST
1626
} virDomainHubType;
M
Marc-André Lureau 已提交
1627

1628
struct _virDomainGraphicsListenDef {
1629
    virDomainGraphicsListenType type;
1630 1631
    char *address;
    char *network;
1632
    char *socket;
1633
    bool fromConfig;    /* true if the @address is config file originated */
1634
    bool autoGenerated;
1635 1636
};

1637
struct _virDomainGraphicsDef {
1638 1639
    virObjectPtr privateData;

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

1705
typedef enum {
1706 1707 1708
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1709
} virDomainRedirdevBus;
1710 1711 1712 1713

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

1714
    virDomainChrSourceDefPtr source;
1715 1716 1717

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

1719
struct _virDomainRedirFilterUSBDevDef {
1720 1721 1722 1723
    int usbClass;
    int vendor;
    int product;
    int version;
1724
    bool allow;
1725 1726 1727 1728
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1729
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1730 1731
};

1732
typedef enum {
1733 1734
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1735
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1736 1737
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL,
1738 1739

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1740
} virDomainMemballoonModel;
1741 1742 1743 1744

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1745
    int period; /* seconds between collections */
1746
    int autodeflate; /* enum virTristateSwitch */
1747
    virDomainVirtioOptionsPtr virtio;
1748 1749
};

L
Li Zhang 已提交
1750 1751 1752
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1753

1754 1755
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1756 1757
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1758 1759 1760 1761

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

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

1778
typedef enum {
1779
    VIR_DOMAIN_SMBIOS_NONE = 0,
1780 1781 1782 1783 1784
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1785
} virDomainSmbiosMode;
1786

1787

1788
#define VIR_DOMAIN_MAX_BOOT_DEVS 4
1789

1790
typedef enum {
1791 1792 1793 1794 1795
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1796
    VIR_DOMAIN_BOOT_LAST
1797
} virDomainBootOrder;
1798

1799
typedef enum {
1800 1801 1802
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1803
    VIR_DOMAIN_FEATURE_HAP,
1804
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1805
    VIR_DOMAIN_FEATURE_PRIVNET,
1806
    VIR_DOMAIN_FEATURE_HYPERV,
1807
    VIR_DOMAIN_FEATURE_KVM,
1808
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1809
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1810
    VIR_DOMAIN_FEATURE_PMU,
1811
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1812
    VIR_DOMAIN_FEATURE_GIC,
M
Michal Privoznik 已提交
1813
    VIR_DOMAIN_FEATURE_SMM,
1814
    VIR_DOMAIN_FEATURE_IOAPIC,
1815
    VIR_DOMAIN_FEATURE_HPT,
M
Marc-André Lureau 已提交
1816
    VIR_DOMAIN_FEATURE_VMCOREINFO,
1817
    VIR_DOMAIN_FEATURE_HTM,
1818
    VIR_DOMAIN_FEATURE_NESTED_HV,
1819
    VIR_DOMAIN_FEATURE_MSRS,
1820
    VIR_DOMAIN_FEATURE_CCF_ASSIST,
1821
    VIR_DOMAIN_FEATURE_XEN,
1822
    VIR_DOMAIN_FEATURE_CFPC,
1823
    VIR_DOMAIN_FEATURE_SBBC,
1824
    VIR_DOMAIN_FEATURE_IBS,
1825 1826

    VIR_DOMAIN_FEATURE_LAST
1827
} virDomainFeature;
1828

1829
#define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12
1830

1831
typedef enum {
1832
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1833 1834
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1835 1836 1837 1838 1839 1840
    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,
1841
    VIR_DOMAIN_HYPERV_FREQUENCIES,
1842
    VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
1843
    VIR_DOMAIN_HYPERV_TLBFLUSH,
1844
    VIR_DOMAIN_HYPERV_IPI,
1845
    VIR_DOMAIN_HYPERV_EVMCS,
1846 1847

    VIR_DOMAIN_HYPERV_LAST
1848
} virDomainHyperv;
1849

1850 1851
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,
1852
    VIR_DOMAIN_KVM_DEDICATED,
1853 1854 1855 1856

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869
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;

1870 1871
typedef enum {
    VIR_DOMAIN_XEN_E820_HOST = 0,
1872
    VIR_DOMAIN_XEN_PASSTHROUGH,
1873 1874 1875 1876

    VIR_DOMAIN_XEN_LAST
} virDomainXen;

1877 1878 1879 1880 1881 1882 1883 1884
typedef enum {
    VIR_DOMAIN_XEN_PASSTHROUGH_MODE_DEFAULT = 0,
    VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SYNC_PT,
    VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SHARE_PT,

    VIR_DOMAIN_XEN_PASSTHROUGH_MODE_LAST
} virDomainXenPassthroughMode;

1885 1886 1887 1888 1889 1890 1891 1892 1893 1894
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 {
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933
    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;
1934

1935 1936 1937 1938 1939 1940 1941 1942 1943 1944
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;

1945
VIR_ENUM_DECL(virDomainLockFailure);
1946

M
Michal Privoznik 已提交
1947
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1948
    int useserial; /* enum virTristateBool */
1949 1950 1951
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1952 1953
};

1954
typedef enum {
1955 1956
    VIR_DOMAIN_LOADER_TYPE_NONE = 0,
    VIR_DOMAIN_LOADER_TYPE_ROM,
1957 1958 1959 1960 1961
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

1962
VIR_ENUM_DECL(virDomainLoader);
1963 1964 1965 1966 1967

struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1968
    int secure;     /* enum virTristateBool */
1969
    char *nvram;    /* path to non-volatile RAM */
1970
    char *templt;   /* user override of path to master nvram */
1971 1972 1973 1974
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1975
typedef enum {
1976 1977
    VIR_DOMAIN_IOAPIC_NONE = 0,
    VIR_DOMAIN_IOAPIC_QEMU,
1978 1979 1980 1981 1982 1983 1984
    VIR_DOMAIN_IOAPIC_KVM,

    VIR_DOMAIN_IOAPIC_LAST
} virDomainIOAPIC;

VIR_ENUM_DECL(virDomainIOAPIC);

1985
typedef enum {
1986 1987
    VIR_DOMAIN_HPT_RESIZING_NONE = 0,
    VIR_DOMAIN_HPT_RESIZING_ENABLED,
1988 1989 1990 1991 1992 1993 1994 1995
    VIR_DOMAIN_HPT_RESIZING_DISABLED,
    VIR_DOMAIN_HPT_RESIZING_REQUIRED,

    VIR_DOMAIN_HPT_RESIZING_LAST
} virDomainHPTResizing;

VIR_ENUM_DECL(virDomainHPTResizing);

1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006
typedef enum {
    VIR_DOMAIN_CFPC_NONE = 0,
    VIR_DOMAIN_CFPC_BROKEN,
    VIR_DOMAIN_CFPC_WORKAROUND,
    VIR_DOMAIN_CFPC_FIXED,

    VIR_DOMAIN_CFPC_LAST
} virDomainCFPC;

VIR_ENUM_DECL(virDomainCFPC);

2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017
typedef enum {
    VIR_DOMAIN_SBBC_NONE = 0,
    VIR_DOMAIN_SBBC_BROKEN,
    VIR_DOMAIN_SBBC_WORKAROUND,
    VIR_DOMAIN_SBBC_FIXED,

    VIR_DOMAIN_SBBC_LAST
} virDomainSBBC;

VIR_ENUM_DECL(virDomainSBBC);

2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030
typedef enum {
    VIR_DOMAIN_IBS_NONE = 0,
    VIR_DOMAIN_IBS_BROKEN,
    VIR_DOMAIN_IBS_WORKAROUND,
    VIR_DOMAIN_IBS_FIXEDIBS,
    VIR_DOMAIN_IBS_FIXEDCCD,
    VIR_DOMAIN_IBS_FIXEDNA,

    VIR_DOMAIN_IBS_LAST
} virDomainIBS;

VIR_ENUM_DECL(virDomainIBS);

2031
/* Operating system configuration data & machine / arch */
2032 2033 2034 2035 2036
struct _virDomainOSEnv {
    char *name;
    char *value;
};

2037 2038
typedef enum {
    VIR_DOMAIN_OS_DEF_FIRMWARE_NONE = 0,
2039 2040
    VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS = VIR_DOMAIN_LOADER_TYPE_ROM,
    VIR_DOMAIN_OS_DEF_FIRMWARE_EFI = VIR_DOMAIN_LOADER_TYPE_PFLASH,
2041 2042 2043 2044

    VIR_DOMAIN_OS_DEF_FIRMWARE_LAST
} virDomainOsDefFirmware;

2045 2046
G_STATIC_ASSERT((int)VIR_DOMAIN_OS_DEF_FIRMWARE_LAST == (int)VIR_DOMAIN_LOADER_TYPE_LAST);

2047 2048
VIR_ENUM_DECL(virDomainOsDefFirmware);

2049
struct _virDomainOSDef {
2050
    int type;
2051
    virDomainOsDefFirmware firmware;
2052
    virArch arch;
2053
    char *machine;
2054
    size_t nBootDevs;
2055
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
2056
    int bootmenu; /* enum virTristateBool */
2057 2058
    unsigned int bm_timeout;
    bool bm_timeout_set;
2059
    char *init;
2060
    char **initargv;
2061
    virDomainOSEnvPtr *initenv;
2062
    char *initdir;
2063 2064
    char *inituser;
    char *initgroup;
2065 2066 2067
    char *kernel;
    char *initrd;
    char *cmdline;
2068
    char *dtb;
2069
    char *root;
J
Ján Tomko 已提交
2070
    char *slic_table;
2071
    virDomainLoaderDefPtr loader;
2072 2073
    char *bootloader;
    char *bootloaderArgs;
2074
    int smbios_mode;
2075

M
Michal Privoznik 已提交
2076
    virDomainBIOSDef bios;
2077 2078
};

2079
typedef enum {
2080 2081 2082 2083 2084
    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 已提交
2085
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
2086
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
2087
    VIR_DOMAIN_TIMER_NAME_ARMVTIMER,
2088

2089
    VIR_DOMAIN_TIMER_NAME_LAST
2090
} virDomainTimerNameType;
2091

2092
typedef enum {
2093 2094 2095
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
2096

2097
    VIR_DOMAIN_TIMER_TRACK_LAST
2098
} virDomainTimerTrackType;
2099

2100
typedef enum {
2101 2102 2103 2104 2105
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

2106
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
2107
} virDomainTimerTickpolicyType;
2108

2109
typedef enum {
2110 2111 2112 2113
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
2114
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
2115

2116
    VIR_DOMAIN_TIMER_MODE_LAST
2117
} virDomainTimerModeType;
2118

2119
typedef enum {
2120
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
2121 2122
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

2123
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
2124
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
2125

2126
struct _virDomainThreadSchedParam {
2127
    virProcessSchedPolicy policy;
2128 2129 2130
    int priority;
};

2131 2132 2133 2134 2135 2136
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

2137 2138 2139 2140 2141
struct _virDomainTimerDef {
    int name;
    int present;    /* unspecified = -1, no = 0, yes = 1 */
    int tickpolicy; /* none|catchup|merge|discard */

2142 2143 2144
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
L
Leonid Bloch 已提交
2145
    int track;  /* boot|guest|wall */
2146 2147 2148 2149 2150 2151

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

2152
typedef enum {
2153 2154
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
2155
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
2156
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
2157

2158
    VIR_DOMAIN_CLOCK_OFFSET_LAST
2159
} virDomainClockOffsetType;
2160

2161
typedef enum {
2162 2163 2164
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

2165
    VIR_DOMAIN_CLOCK_BASIS_LAST
2166
} virDomainClockBasis;
2167

2168 2169
struct _virDomainClockDef {
    int offset;
2170

2171
    union {
2172 2173 2174
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
2175
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
2176 2177 2178
        struct {
            long long adjustment;
            int basis;
2179 2180 2181 2182 2183 2184 2185

            /* 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;
2186
        } variable;
2187 2188 2189 2190 2191

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

2193
    size_t ntimers;
2194
    virDomainTimerDefPtr *timers;
2195 2196
};

2197

2198
struct _virBlkioDevice {
2199 2200
    char *path;
    unsigned int weight;
2201 2202 2203 2204
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
2205 2206
};

2207
typedef enum {
2208
    VIR_DOMAIN_RNG_MODEL_VIRTIO,
2209 2210
    VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL,
2211 2212

    VIR_DOMAIN_RNG_MODEL_LAST
2213
} virDomainRNGModel;
2214

2215
typedef enum {
2216 2217
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
H
Han Han 已提交
2218
    VIR_DOMAIN_RNG_BACKEND_BUILTIN,
2219 2220

    VIR_DOMAIN_RNG_BACKEND_LAST
2221
} virDomainRNGBackend;
2222 2223 2224 2225

struct _virDomainRNGDef {
    int model;
    int backend;
2226 2227
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
2228 2229 2230 2231 2232 2233 2234 2235

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

    virDomainDeviceInfo info;
2236
    virDomainVirtioOptionsPtr virtio;
2237 2238
};

2239 2240 2241
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2242
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2243 2244 2245 2246 2247

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
2248
    virDomainMemoryAccess access;
2249
    virTristateBool discard;
2250

2251 2252 2253
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2254
    char *nvdimmPath;
2255
    unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
2256
    bool nvdimmPmem; /* valid only for NVDIMM */
2257 2258 2259

    /* target */
    int model; /* virDomainMemoryModel */
2260
    int targetNode;
2261
    unsigned long long size; /* kibibytes */
2262
    unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
2263
    bool readonly; /* valid only for NVDIMM */
2264

2265 2266 2267
    /* required for QEMU NVDIMM ppc64 support */
    unsigned char uuid[VIR_UUID_BUFLEN];

2268 2269 2270 2271 2272
    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2288 2289 2290 2291 2292
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2293
    VIR_DOMAIN_PANIC_MODEL_S390,
2294 2295 2296 2297

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2298
struct _virDomainPanicDef {
2299
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2300 2301 2302 2303
    virDomainDeviceInfo info;
};


2304
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2305
                              int ndevices);
2306

2307 2308 2309
struct _virDomainResourceDef {
    char *partition;
};
2310

2311
struct _virDomainHugePage {
2312 2313 2314 2315
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2316
#define VIR_DOMAIN_CPUMASK_LEN 1024
2317

2318 2319 2320
struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2321
    int thread_id;
2322
    virBitmapPtr cpumask;
2323 2324

    virDomainThreadSchedParam sched;
2325 2326 2327 2328
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2329

2330
struct _virDomainCputune {
2331
    unsigned long long shares;
2332 2333 2334
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2335
    unsigned long long global_period;
2336
    long long global_quota;
2337 2338
    unsigned long long emulator_period;
    long long emulator_quota;
2339 2340
    unsigned long long iothread_period;
    long long iothread_quota;
2341
    virBitmapPtr emulatorpin;
2342
    virDomainThreadSchedParamPtr emulatorsched;
2343 2344
};

2345

2346 2347 2348 2349 2350 2351
struct _virDomainResctrlMonDef {
    virBitmapPtr vcpus;
    virResctrlMonitorType tag;
    virResctrlMonitorPtr instance;
};

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

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


2361
struct _virDomainVcpuDef {
2362
    bool online;
2363 2364 2365
    virTristateBool hotpluggable;
    unsigned int order;

2366
    virBitmapPtr cpumask;
2367 2368

    virDomainThreadSchedParam sched;
2369 2370

    virObjectPtr privateData;
2371 2372
};

2373 2374 2375 2376 2377 2378 2379 2380
struct _virDomainBlkiotune {
    unsigned int weight;

    size_t ndevices;
    virBlkioDevicePtr devices;
};

struct _virDomainMemtune {
2381 2382 2383
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2384 2385
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2386 2387 2388 2389

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2390 2391 2392 2393
    /* 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 */

2394 2395 2396
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2397 2398 2399 2400
    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 */
2401 2402 2403 2404

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2405 2406

    virTristateBool discard;
2407 2408 2409 2410 2411 2412 2413 2414
};

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

Q
Qiaowei Ren 已提交
2415 2416 2417 2418 2419
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2420 2421 2422 2423 2424
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

2425 2426 2427 2428 2429 2430 2431 2432
typedef enum {
    VIR_DOMAIN_LAUNCH_SECURITY_NONE,
    VIR_DOMAIN_LAUNCH_SECURITY_SEV,

    VIR_DOMAIN_LAUNCH_SECURITY_LAST,
} virDomainLaunchSecurity;


2433
struct _virDomainSEVDef {
2434 2435 2436 2437 2438 2439 2440 2441 2442
    int sectype; /* enum virDomainLaunchSecurity */
    char *dh_cert;
    char *session;
    unsigned int policy;
    unsigned int cbitpos;
    unsigned int reduced_phys_bits;
};


J
Ján Tomko 已提交
2443 2444
typedef enum {
    VIR_DOMAIN_IOMMU_MODEL_INTEL,
2445
    VIR_DOMAIN_IOMMU_MODEL_SMMUV3,
J
Ján Tomko 已提交
2446 2447 2448 2449 2450 2451

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

struct _virDomainIOMMUDef {
    virDomainIOMMUModel model;
2452
    virTristateSwitch intremap;
2453
    virTristateSwitch caching_mode;
2454
    virTristateSwitch eim;
J
Ján Tomko 已提交
2455
    virTristateSwitch iotlb;
J
Ján Tomko 已提交
2456
};
2457

J
Ján Tomko 已提交
2458 2459 2460
typedef enum {
    VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO,
2461 2462
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL,
J
Ján Tomko 已提交
2463 2464 2465 2466

    VIR_DOMAIN_VSOCK_MODEL_LAST
} virDomainVsockModel;

J
Ján Tomko 已提交
2467
struct _virDomainVsockDef {
2468
    virObjectPtr privateData;
J
Ján Tomko 已提交
2469 2470 2471 2472 2473 2474

    virDomainVsockModel model;
    unsigned int guest_cid;
    virTristateBool auto_cid;

    virDomainDeviceInfo info;
J
Ján Tomko 已提交
2475 2476
};

2477 2478 2479
struct _virDomainVirtioOptions {
    virTristateSwitch iommu;
    virTristateSwitch ats;
2480
    virTristateSwitch packed;
2481 2482
};

2483 2484 2485 2486 2487 2488
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
2489
struct _virDomainDef {
2490
    int virtType; /* enum virDomainVirtType */
2491 2492
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
2493 2494 2495 2496 2497

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

2498
    char *name;
2499
    char *title;
2500
    char *description;
2501

2502 2503
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2504

2505
    virDomainVcpuDefPtr *vcpus;
2506
    size_t maxvcpus;
2507 2508
    /* set if the vcpu definition was specified individually */
    bool individualvcpus;
O
Osier Yang 已提交
2509
    int placement_mode;
H
Hu Tao 已提交
2510
    virBitmapPtr cpumask;
2511

2512 2513
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2514

2515
    virDomainCputune cputune;
2516

B
Bing Niu 已提交
2517 2518
    virDomainResctrlDefPtr *resctrls;
    size_t nresctrls;
2519

2520
    virDomainNumaPtr numa;
2521
    virDomainResourceDefPtr resource;
2522
    virDomainIdMapDef idmap;
2523

2524 2525 2526 2527 2528
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2529 2530
    int onLockFailure; /* enum virDomainLockFailureAction */

2531
    virDomainPowerManagement pm;
2532

2533
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2534

2535 2536
    virDomainOSDef os;
    char *emulator;
2537 2538 2539
    /* 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. */
2540
    int features[VIR_DOMAIN_FEATURE_LAST];
2541
    int caps_features[VIR_DOMAIN_PROCES_CAPS_FEATURE_LAST];
2542
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2543
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2544
    int msrs_features[VIR_DOMAIN_MSRS_LAST];
2545
    int xen_features[VIR_DOMAIN_XEN_LAST];
2546
    int xen_passthrough_mode;
2547
    unsigned int hyperv_spinlocks;
2548
    int hyperv_stimer_direct;
2549
    virGICVersion gic_version;
2550
    virDomainHPTResizing hpt_resizing;
2551
    unsigned long long hpt_maxpagesize; /* Stored in KiB */
2552
    char *hyperv_vendor_id;
2553
    int apic_eoi;
2554

2555 2556 2557
    bool tseg_specified;
    unsigned long long tseg_size;

2558
    virDomainClockDef clock;
2559

2560
    size_t ngraphics;
2561
    virDomainGraphicsDefPtr *graphics;
2562

2563
    size_t ndisks;
2564 2565
    virDomainDiskDefPtr *disks;

2566
    size_t ncontrollers;
2567 2568
    virDomainControllerDefPtr *controllers;

2569
    size_t nfss;
2570 2571
    virDomainFSDefPtr *fss;

2572
    size_t nnets;
2573 2574
    virDomainNetDefPtr *nets;

2575
    size_t ninputs;
2576 2577
    virDomainInputDefPtr *inputs;

2578
    size_t nsounds;
2579 2580
    virDomainSoundDefPtr *sounds;

2581
    size_t nvideos;
2582 2583
    virDomainVideoDefPtr *videos;

2584
    size_t nhostdevs;
2585 2586
    virDomainHostdevDefPtr *hostdevs;

2587
    size_t nredirdevs;
2588 2589
    virDomainRedirdevDefPtr *redirdevs;

2590
    size_t nsmartcards;
E
Eric Blake 已提交
2591 2592
    virDomainSmartcardDefPtr *smartcards;

2593
    size_t nserials;
2594 2595
    virDomainChrDefPtr *serials;

2596
    size_t nparallels;
2597 2598
    virDomainChrDefPtr *parallels;

2599
    size_t nchannels;
2600 2601
    virDomainChrDefPtr *channels;

2602
    size_t nconsoles;
2603 2604
    virDomainChrDefPtr *consoles;

2605
    size_t nleases;
2606 2607
    virDomainLeaseDefPtr *leases;

2608
    size_t nhubs;
M
Marc-André Lureau 已提交
2609 2610
    virDomainHubDefPtr *hubs;

2611 2612 2613
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2614 2615 2616
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2617 2618 2619
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2620 2621 2622
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2623 2624 2625
    size_t npanics;
    virDomainPanicDefPtr *panics;

2626
    /* Only 1 */
R
Richard Jones 已提交
2627
    virDomainWatchdogDefPtr watchdog;
2628
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2629
    virDomainNVRAMDefPtr nvram;
2630
    virDomainTPMDefPtr tpm;
2631
    virCPUDefPtr cpu;
2632
    virSysinfoDefPtr sysinfo;
2633
    virDomainRedirFilterDefPtr redirfilter;
J
Ján Tomko 已提交
2634
    virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
2635
    virDomainVsockDefPtr vsock;
2636 2637

    void *namespaceData;
2638
    virXMLNamespace ns;
2639

2640 2641
    virDomainKeyWrapDefPtr keywrap;

2642
    /* SEV-specific domain */
2643
    virDomainSEVDefPtr sev;
2644

2645 2646
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2647 2648 2649 2650 2651 2652

    /* 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 */
2653 2654
};

2655

2656
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2657
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2658
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2659
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2660

2661 2662 2663 2664 2665 2666 2667
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

2668
typedef enum {
2669 2670 2671 2672 2673
    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 */
2674
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2675
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2676
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2677
    VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,/* CDROM passthrough */
Y
Yuri Chornoivan 已提交
2678
    VIR_DOMAIN_TAINT_CUSTOM_DTB,       /* Custom device tree blob was specified */
2679
    VIR_DOMAIN_TAINT_CUSTOM_GA_COMMAND, /* Custom guest agent command */
2680
    VIR_DOMAIN_TAINT_CUSTOM_HYPERVISOR_FEATURE, /* custom hypervisor feature control */
2681 2682

    VIR_DOMAIN_TAINT_LAST
2683
} virDomainTaintFlags;
2684

2685
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2686 2687 2688 2689 2690 2691
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2692
struct _virDomainObj {
2693
    virObjectLockable parent;
2694
    virCond cond;
2695

2696
    pid_t pid;
J
Jiri Denemark 已提交
2697
    virDomainStateReason state;
2698 2699 2700

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2701
    unsigned int updated : 1;
2702
    unsigned int removing : 1;
2703 2704 2705

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

2707
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2708

2709 2710
    bool hasManagedSave;

2711 2712
    virDomainCheckpointObjListPtr checkpoints;

2713 2714
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2715 2716

    int taint;
2717 2718 2719

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

2722 2723 2724
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainObj, virObjectUnref);


2725 2726
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2727

2728

2729 2730
/* NB: Any new flag to this list be considered to be set in
 * virt-aa-helper code if the flag prevents parsing. */
2731 2732
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2733
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2734
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2735
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2736
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2737
    VIR_DOMAIN_DEF_FEATURE_USER_ALIAS = (1 << 5),
2738
    VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER = (1 << 6),
2739
    VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT = (1 << 7),
2740
    VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING = (1 << 8),
2741 2742 2743
} virDomainDefFeatures;


2744 2745 2746 2747 2748 2749 2750
/* 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);

2751
/* Called once after everything else has been parsed, for adjusting
2752 2753 2754
 * overall domain defaults.
 * @parseOpaque is opaque data passed by virDomainDefParse* caller,
 * @opaque is opaque data set by driver (usually pointer to driver
2755 2756 2757 2758
 * 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. */
2759
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
2760
                                             unsigned int parseFlags,
2761 2762
                                             void *opaque,
                                             void *parseOpaque);
2763
/* Called once per device, for adjusting per-device settings while
2764 2765 2766 2767
 * 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). */
2768
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
2769
                                                   const virDomainDef *def,
2770
                                                   unsigned int parseFlags,
2771 2772
                                                   void *opaque,
                                                   void *parseOpaque);
2773
/* Drive callback for assigning device addresses, called at the end
2774 2775 2776 2777
 * 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). */
2778 2779
typedef int (*virDomainDefAssignAddressesCallback)(virDomainDef *def,
                                                   unsigned int parseFlags,
2780 2781
                                                   void *opaque,
                                                   void *parseOpaque);
2782

2783 2784 2785 2786 2787 2788
typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def,
                                              unsigned int parseFlags,
                                              void *opaque,
                                              void **parseOpaque);
typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque);

2789 2790 2791 2792 2793
/* 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);
2794

2795 2796 2797 2798 2799 2800
/* 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);

2801
struct _virDomainDefParserConfig {
2802
    /* driver domain definition callbacks */
2803
    virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
2804
    virDomainDefPostParseDataAlloc domainPostParseDataAlloc;
2805 2806
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2807
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2808
    virDomainDefPostParseDataFree domainPostParseDataFree;
2809

2810 2811
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2812
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2813

2814
    /* private data for the callbacks */
2815 2816
    void *priv;
    virFreeCallback privFree;
2817 2818

    /* data */
2819
    unsigned int features; /* virDomainDefFeatures */
2820
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2821
    virArch defArch;
2822
    const char *netPrefix;
2823
    const char *defSecModel;
2824 2825
};

2826
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *);
2827 2828 2829 2830 2831 2832 2833 2834
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
                                                 virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                virDomainObjPtr,
                                                virDomainDefParserConfigPtr);

2835 2836
typedef void *(*virDomainXMLPrivateDataGetParseOpaqueFunc)(virDomainObjPtr vm);

2837 2838 2839 2840 2841
typedef int (*virDomainXMLPrivateDataDiskParseFunc)(xmlXPathContextPtr ctxt,
                                                    virDomainDiskDefPtr disk);
typedef int (*virDomainXMLPrivateDataDiskFormatFunc)(virDomainDiskDefPtr disk,
                                                     virBufferPtr buf);

2842 2843 2844 2845 2846 2847
typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
                                                             virStorageSourcePtr src);
typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
                                                              virBufferPtr buf);


2848 2849 2850
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
2851 2852
    /* note that private data for devices are not copied when using
     * virDomainDefCopy and similar functions */
2853
    virDomainXMLPrivateDataNewFunc    diskNew;
2854 2855
    virDomainXMLPrivateDataDiskParseFunc diskParse;
    virDomainXMLPrivateDataDiskFormatFunc diskFormat;
2856
    virDomainXMLPrivateDataNewFunc    vcpuNew;
2857
    virDomainXMLPrivateDataNewFunc    chrSourceNew;
2858
    virDomainXMLPrivateDataNewFunc    vsockNew;
2859
    virDomainXMLPrivateDataNewFunc    graphicsNew;
2860
    virDomainXMLPrivateDataNewFunc    networkNew;
2861
    virDomainXMLPrivateDataNewFunc    videoNew;
2862
    virDomainXMLPrivateDataNewFunc    fsNew;
2863 2864
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
2865 2866 2867
    /* following function shall return a pointer which will be used as the
     * 'parseOpaque' argument for virDomainDefPostParse */
    virDomainXMLPrivateDataGetParseOpaqueFunc getParseOpaque;
2868 2869
    virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
    virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
2870 2871
};

2872 2873 2874 2875 2876 2877 2878
typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
                                            const virDomainDef *dst);

struct _virDomainABIStability {
    virDomainABIStabilityDomain domain;
};

2879 2880
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
2881
                                            virXMLNamespacePtr xmlns,
2882 2883 2884 2885 2886
                                            virDomainABIStabilityPtr abi,
                                            virSaveCookieCallbacksPtr saveCookie);

virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
2887

2888 2889 2890 2891 2892 2893 2894
typedef int (*virDomainMomentPostParseCallback)(virDomainMomentDefPtr def);

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

2895 2896
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2897
virXMLNamespacePtr
2898
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2899 2900
    ATTRIBUTE_NONNULL(1);

2901 2902 2903 2904
bool
virDomainSCSIDriveAddressIsUsed(const virDomainDef *def,
                                const virDomainDeviceDriveAddress *addr);

2905 2906 2907 2908
int virDomainDefPostParse(virDomainDefPtr def,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2909
bool virDomainDefHasUSB(const virDomainDef *def);
2910

2911 2912 2913 2914
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
                                           virDomainDeviceDefPtr dev,
                                           unsigned int flags);

2915 2916
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);

2917
int virDomainDefValidate(virDomainDefPtr def,
2918 2919 2920
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2921 2922 2923
int
virDomainActualNetDefValidate(const virDomainNetDef *net);

2924
static inline bool
D
Daniel P. Berrange 已提交
2925
virDomainObjIsActive(virDomainObjPtr dom)
2926 2927 2928 2929
{
    return dom->def->id != -1;
}

2930 2931
int virDomainObjCheckActive(virDomainObjPtr dom);

2932 2933 2934 2935 2936 2937 2938 2939 2940
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)
2941
    G_GNUC_WARN_UNUSED_RESULT;
2942
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2943 2944
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2945

2946
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2947
    ATTRIBUTE_NONNULL(1);
2948

M
Michal Privoznik 已提交
2949 2950
void virDomainObjEndAPI(virDomainObjPtr *vm);

2951
bool virDomainObjTaint(virDomainObjPtr obj,
2952
                       virDomainTaintFlags taint);
2953

2954 2955 2956 2957
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2958

H
Hu Tao 已提交
2959
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2960
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2961
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
J
Ján Tomko 已提交
2962
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
2963
void virDomainInputDefFree(virDomainInputDefPtr def);
2964
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2965
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2966
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2967 2968
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2969
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2970
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
2971
    G_GNUC_WARN_UNUSED_RESULT;
2972
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
2973
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
2974
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
2975
    G_GNUC_WARN_UNUSED_RESULT;
2976 2977
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2978 2979
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
2980 2981 2982 2983
                                  const virDomainDeviceDriveAddress *addr);
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2984 2985

virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type);
2986
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2987
bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont);
2988

2989
virDomainFSDefPtr virDomainFSDefNew(virDomainXMLOptionPtr xmlopt);
2990
void virDomainFSDefFree(virDomainFSDefPtr def);
2991
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
J
Ján Tomko 已提交
2992 2993
virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt);
void virDomainVsockDefFree(virDomainVsockDefPtr vsock);
2994
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainVsockDef, virDomainVsockDefFree);
2995
void virDomainNetDefClear(virDomainNetDefPtr def);
2996
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2997
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2998
void virDomainChrDefFree(virDomainChrDefPtr def);
2999 3000
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
                              virDomainChrSourceDefPtr src);
3001
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
J
Jidong Xia 已提交
3002 3003
ssize_t virDomainSoundDefFind(const virDomainDef *def,
                              const virDomainSoundDef *sound);
3004
void virDomainSoundDefFree(virDomainSoundDefPtr def);
J
Jidong Xia 已提交
3005
virDomainSoundDefPtr virDomainSoundDefRemove(virDomainDefPtr def, size_t idx);
3006
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
3007
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
3008
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
3009
virDomainVideoDefPtr virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt);
3010
void virDomainVideoDefFree(virDomainVideoDefPtr def);
3011
void virDomainVideoDefClear(virDomainVideoDefPtr def);
J
John Ferlan 已提交
3012
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
3013
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
3014
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
3015
void virDomainHubDefFree(virDomainHubDefPtr def);
3016
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
3017
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
3018
void virDomainShmemDefFree(virDomainShmemDefPtr def);
3019
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
3020
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDeviceDef, virDomainDeviceDefFree);
3021
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
3022
                                             const virDomainDef *def,
3023 3024
                                             virDomainXMLOptionPtr xmlopt,
                                             void *parseOpaque);
3025
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
C
Cole Robinson 已提交
3026 3027
void virDomainDeviceSetData(virDomainDeviceDefPtr device,
                            void *devicedata);
3028
void virDomainTPMDefFree(virDomainTPMDefPtr def);
3029

3030
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
3031 3032
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
3033 3034 3035 3036 3037 3038
                                           void *opaque);

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

3039 3040
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
3041
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3042

3043
void virDomainDefFree(virDomainDefPtr vm);
3044
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDef, virDomainDefFree);
3045

3046 3047 3048
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);

3049
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
3050

3051 3052
virDomainGraphicsDefPtr
virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt);
3053 3054 3055 3056

virDomainNetDefPtr
virDomainNetDefNew(virDomainXMLOptionPtr xmlopt);

3057
virDomainDefPtr virDomainDefNew(void);
3058

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

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

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

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

3092 3093 3094
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
3095 3096 3097 3098
    /* 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. */
3099 3100 3101 3102 3103
    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,
3104
    /* internal flag passed to device info sub-parser to allow using <rom> */
3105
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
3106
    /* internal flag passed to device info sub-parser to allow specifying boot order */
3107 3108
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    /* parse only source half of <disk> */
3109
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 6,
3110
    /* perform RNG schema validation on the passed XML document */
3111
    VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA = 1 << 7,
3112
    /* allow updates in post parse callback that would break ABI otherwise */
3113
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE = 1 << 8,
3114
    /* skip definition validation checks meant to be executed on define time only */
3115
    VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 9,
3116
    /* skip parsing of security labels */
3117
    VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 10,
3118 3119 3120
    /* 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. */
3121
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 11,
3122 3123 3124 3125
    /* 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 */
3126
    VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL = 1 << 12,
3127 3128 3129 3130 3131
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
3132
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
3133
    /* format internal domain status information */
3134
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
3135
    /* format <actual> element */
3136
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
3137
    /* format original states of host PCI device */
3138 3139 3140 3141
    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,
3142 3143
} virDomainDefFormatFlags;

3144 3145 3146 3147 3148 3149 3150 3151 3152
/* 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;

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

3182
bool virDomainDefCheckABIStability(virDomainDefPtr src,
3183 3184
                                   virDomainDefPtr dst,
                                   virDomainXMLOptionPtr xmlopt);
3185

3186 3187
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
                                        virDomainDefPtr dst,
3188
                                        virDomainXMLOptionPtr xmlopt,
3189 3190
                                        unsigned int flags);

3191 3192
int virDomainDefAddImplicitDevices(virDomainDefPtr def,
                                   virDomainXMLOptionPtr xmlopt);
3193

3194
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
3195 3196 3197 3198 3199
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);

3200 3201 3202 3203 3204 3205
/* 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. */
3206
#define VIR_DOMAIN_XML_COMMON_FLAGS \
3207 3208
    (VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE | \
     VIR_DOMAIN_XML_MIGRATABLE)
3209 3210
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

3211
char *virDomainDefFormat(virDomainDefPtr def,
3212 3213
                         virDomainXMLOptionPtr xmlopt,
                         unsigned int flags)
J
John Ferlan 已提交
3214
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3215 3216 3217
char *virDomainObjFormat(virDomainObjPtr obj,
                         virDomainXMLOptionPtr xmlopt,
                         unsigned int flags)
J
John Ferlan 已提交
3218
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3219
int virDomainDefFormatInternal(virDomainDefPtr def,
3220
                               virDomainXMLOptionPtr xmlopt,
3221
                               virBufferPtr buf,
3222 3223
                               unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3224
    ATTRIBUTE_NONNULL(3);
3225
int virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
3226
                                          virDomainXMLOptionPtr xmlopt,
3227
                                          virBufferPtr buf,
3228 3229 3230
                                          const char *rootname,
                                          unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3231
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3232

3233 3234
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
3235
                              const char *element,
3236
                              int policy,
3237
                              bool attrIndex,
3238
                              unsigned int flags,
3239 3240
                              bool skipAuth,
                              bool skipEnc,
3241
                              virDomainXMLOptionPtr xmlopt);
3242

3243 3244 3245 3246 3247 3248
int
virDomainDiskBackingStoreFormat(virBufferPtr buf,
                                virStorageSourcePtr src,
                                virDomainXMLOptionPtr xmlopt,
                                unsigned int flags);

3249 3250
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
3251
                          virDomainXMLOptionPtr xmlopt,
3252 3253
                          unsigned int flags);

3254 3255 3256 3257 3258 3259
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

3260
int virDomainDefCompatibleDevice(virDomainDefPtr def,
3261
                                 virDomainDeviceDefPtr dev,
3262
                                 virDomainDeviceDefPtr oldDev,
3263 3264
                                 virDomainDeviceAction action,
                                 bool live);
3265

3266 3267
void virDomainRNGDefFree(virDomainRNGDefPtr def);

3268
int virDomainDiskIndexByAddress(virDomainDefPtr def,
3269
                                virPCIDeviceAddressPtr pci_controller,
3270 3271
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
3272
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
3273
                                           virPCIDeviceAddressPtr pci_controller,
3274 3275 3276
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
3277 3278
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
3279 3280 3281
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
3282 3283 3284 3285
virDomainDiskDefPtr
virDomainDiskByTarget(virDomainDefPtr def,
                      const char *dst);

3286
int virDomainDiskInsert(virDomainDefPtr def,
3287
                        virDomainDiskDefPtr disk)
3288
    G_GNUC_WARN_UNUSED_RESULT;
3289 3290
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
3291 3292
int virDomainStorageNetworkParseHost(xmlNodePtr hostnode,
                                     virStorageNetHostDefPtr host);
3293
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
3294 3295
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
3296

3297 3298 3299 3300
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
3301

3302 3303
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
3304
virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname);
3305
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
3306
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
3307
int virDomainNetUpdate(virDomainDefPtr def, size_t netidx, virDomainNetDefPtr newnet);
3308 3309
int virDomainNetDHCPInterfaces(virDomainDefPtr def, virDomainInterfacePtr **ifaces);
int virDomainNetARPInterfaces(virDomainDefPtr def, virDomainInterfacePtr **ifaces);
3310
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
3311
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
3312

L
Laine Stump 已提交
3313
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
3314 3315
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
3316 3317 3318
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

3319 3320
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
3321 3322
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
3323
            ATTRIBUTE_NONNULL(1);
3324 3325 3326
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
3327

3328
virDomainNetType virDomainNetGetActualType(const virDomainNetDef *iface);
3329 3330 3331 3332
const char *virDomainNetGetActualBridgeName(const virDomainNetDef *iface);
int virDomainNetGetActualBridgeMACTableManager(const virDomainNetDef *iface);
const char *virDomainNetGetActualDirectDev(const virDomainNetDef *iface);
int virDomainNetGetActualDirectMode(const virDomainNetDef *iface);
3333
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
3334
const virNetDevVPortProfile *
3335
virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface);
3336 3337
const virNetDevBandwidth *
virDomainNetGetActualBandwidth(const virDomainNetDef *iface);
3338
const virNetDevVlan *virDomainNetGetActualVlan(const virDomainNetDef *iface);
3339
bool virDomainNetGetActualTrustGuestRxFilters(const virDomainNetDef *iface);
3340 3341
virTristateBool
virDomainNetGetActualPortOptionsIsolated(const virDomainNetDef *iface);
3342 3343 3344
const char *virDomainNetGetModelString(const virDomainNetDef *net);
int virDomainNetSetModelString(virDomainNetDefPtr et,
                               const char *model);
3345
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
3346
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
3347 3348 3349
                                const char *address,
                                int family,
                                unsigned int prefix);
3350

3351
int virDomainControllerInsert(virDomainDefPtr def,
3352
                              virDomainControllerDefPtr controller)
3353
    G_GNUC_WARN_UNUSED_RESULT;
3354 3355
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
3356
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
3357
int virDomainControllerFindByType(virDomainDefPtr def, int type);
3358
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
3359
                                        virPCIDeviceAddressPtr addr);
3360
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
3361
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
3362
const char *virDomainControllerAliasFind(const virDomainDef *def,
3363 3364
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
3365 3366 3367 3368 3369

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
3370
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
3371
    G_GNUC_WARN_UNUSED_RESULT;
3372 3373
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
3374 3375 3376 3377 3378
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
3379

3380
void
3381
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
3382
                          virDomainChrDeviceType type,
3383 3384 3385
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3386 3387 3388
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
3389 3390 3391
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
3392
int
3393 3394 3395 3396 3397
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
3398 3399 3400 3401
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

3402 3403 3404
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

3405 3406 3407 3408
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

3409 3410 3411 3412 3413
int virDomainDefSave(virDomainDefPtr def,
                     virDomainXMLOptionPtr xmlopt,
                     const char *configDir)
    G_GNUC_WARN_UNUSED_RESULT
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3414
    ATTRIBUTE_NONNULL(3);
3415 3416 3417 3418 3419 3420

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

3423 3424 3425 3426
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

3427
int virDomainDeleteConfig(const char *configDir,
3428
                          const char *autostartDir,
3429 3430
                          virDomainObjPtr dom);

3431
char *virDomainConfigFile(const char *dir,
3432 3433
                          const char *name);

3434 3435 3436 3437
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

3438
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
3439
                                                  const char *target);
3440
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
3441
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
3442 3443
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

3444 3445
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
3446

E
Eric Blake 已提交
3447 3448 3449 3450 3451 3452 3453 3454 3455
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3456 3457 3458 3459 3460 3461 3462 3463 3464
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3465 3466 3467 3468 3469 3470 3471
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

J
Jiri Denemark 已提交
3472 3473 3474 3475 3476 3477 3478
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3479 3480 3481
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3482
virSecurityDeviceLabelDefPtr
3483 3484
virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDefPtr def,
                                         const char *model);
3485

3486 3487
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3488

3489
int virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem)
3490
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3491 3492 3493
virDomainMemoryDefPtr virDomainMemoryRemove(virDomainDefPtr def, int idx)
    ATTRIBUTE_NONNULL(1);
int virDomainMemoryFindByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem)
3494
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3495 3496
int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem)
3497
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3498

3499
int virDomainShmemDefInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem)
3500
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3501
bool virDomainShmemDefEquals(virDomainShmemDefPtr src, virDomainShmemDefPtr dst)
3502
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3503
ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem)
3504
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3505 3506
virDomainShmemDefPtr virDomainShmemDefRemove(virDomainDefPtr def, size_t idx)
    ATTRIBUTE_NONNULL(1);
3507 3508
ssize_t virDomainInputDefFind(const virDomainDef *def,
                              const virDomainInputDef *input)
3509
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3510 3511
bool virDomainVsockDefEquals(const virDomainVsockDef *a,
                             const virDomainVsockDef *b)
3512
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3513

3514 3515 3516 3517 3518
VIR_ENUM_DECL(virDomainTaint);
VIR_ENUM_DECL(virDomainVirt);
VIR_ENUM_DECL(virDomainBoot);
VIR_ENUM_DECL(virDomainFeature);
VIR_ENUM_DECL(virDomainCapabilitiesPolicy);
3519
VIR_ENUM_DECL(virDomainProcessCapsFeature);
3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532
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);
3533
VIR_ENUM_DECL(virDomainDiskModel);
3534 3535 3536 3537 3538 3539 3540
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);
3541
VIR_ENUM_DECL(virDomainControllerModelVirtioSerial);
3542 3543 3544 3545
VIR_ENUM_DECL(virDomainFS);
VIR_ENUM_DECL(virDomainFSDriver);
VIR_ENUM_DECL(virDomainFSAccessMode);
VIR_ENUM_DECL(virDomainFSWrpolicy);
3546
VIR_ENUM_DECL(virDomainFSModel);
3547
VIR_ENUM_DECL(virDomainFSCacheMode);
3548 3549 3550
VIR_ENUM_DECL(virDomainNet);
VIR_ENUM_DECL(virDomainNetBackend);
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
3551
VIR_ENUM_DECL(virDomainNetTeaming);
3552
VIR_ENUM_DECL(virDomainNetInterfaceLinkState);
3553
VIR_ENUM_DECL(virDomainNetModel);
3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570
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);
3571
VIR_ENUM_DECL(virDomainVideoBackend);
3572 3573 3574 3575 3576 3577 3578
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);
3579
VIR_ENUM_DECL(virDomainInputModel);
3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592
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);
3593
VIR_ENUM_DECL(virDomainXen);
3594
VIR_ENUM_DECL(virDomainXenPassthroughMode);
3595
VIR_ENUM_DECL(virDomainMsrsUnknown);
3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608
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);
3609
/* from libvirt.h */
3610 3611 3612 3613 3614 3615 3616 3617 3618
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 已提交
3619 3620 3621 3622

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

3623 3624 3625
VIR_ENUM_DECL(virDomainSeclabel);
VIR_ENUM_DECL(virDomainClockOffset);
VIR_ENUM_DECL(virDomainClockBasis);
3626

3627 3628 3629 3630 3631
VIR_ENUM_DECL(virDomainTimerName);
VIR_ENUM_DECL(virDomainTimerTrack);
VIR_ENUM_DECL(virDomainTimerTickpolicy);
VIR_ENUM_DECL(virDomainTimerMode);
VIR_ENUM_DECL(virDomainCpuPlacementMode);
3632

3633
VIR_ENUM_DECL(virDomainStartupPolicy);
3634

3635 3636
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3637 3638
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3639 3640 3641 3642 3643
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3644 3645 3646 3647
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3648

3649 3650
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3651 3652
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3653 3654
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3655

3656 3657
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);

3658 3659
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3660 3661 3662 3663 3664
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3665 3666 3667 3668 3669 3670
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virDomainXMLOptionPtr xmlopt,
3671
                            const char *stateDir,
3672 3673 3674
                            const char *configDir,
                            unsigned int flags);

3675 3676 3677 3678 3679 3680 3681 3682
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3683 3684 3685
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3686 3687
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3688
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3689

3690 3691 3692 3693
virStorageSourcePtr
virDomainStorageSourceParseBase(const char *type,
                                const char *format,
                                const char *index)
3694
    G_GNUC_WARN_UNUSED_RESULT;
3695

3696 3697 3698
int virDomainStorageSourceParse(xmlNodePtr node,
                                xmlXPathContextPtr ctxt,
                                virStorageSourcePtr src,
3699 3700
                                unsigned int flags,
                                virDomainXMLOptionPtr xmlopt)
3701 3702
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3703 3704 3705 3706 3707
int
virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
                               virStorageSourcePtr src,
                               unsigned int flags,
                               virDomainXMLOptionPtr xmlopt)
3708
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3709

3710 3711 3712 3713 3714 3715
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
3716
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT;
3717

3718 3719
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

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

3722 3723 3724 3725 3726
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3727

3728 3729 3730
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3731 3732
bool
virDomainNetTypeSharesHostView(const virDomainNetDef *net);
3733

3734 3735 3736 3737
bool
virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
                                   virDomainLifecycleAction action);

3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749
virNetworkPortDefPtr
virDomainNetDefToNetworkPort(virDomainDefPtr dom,
                             virDomainNetDefPtr iface);

int
virDomainNetDefActualFromNetworkPort(virDomainNetDefPtr iface,
                                     virNetworkPortDefPtr port);

virNetworkPortDefPtr
virDomainNetDefActualToNetworkPort(virDomainDefPtr dom,
                                   virDomainNetDefPtr iface);

3750
int
3751 3752
virDomainNetAllocateActualDevice(virConnectPtr conn,
                                 virDomainDefPtr dom,
3753 3754 3755 3756
                                 virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void
3757 3758
virDomainNetNotifyActualDevice(virConnectPtr conn,
                               virDomainDefPtr dom,
3759 3760 3761 3762
                               virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

int
3763 3764
virDomainNetReleaseActualDevice(virConnectPtr conn,
                                virDomainDefPtr dom,
3765 3766 3767
                                virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

3768 3769 3770 3771
int
virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
                            virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3772

3773 3774 3775 3776
int
virDomainNetResolveActualType(virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1);

3777

3778
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
3779

3780 3781 3782
int
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                 virDomainDiskDetectZeroes detect_zeroes);
3783

3784 3785 3786
bool
virDomainDefHasManagedPR(const virDomainDef *def);

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

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

3793 3794 3795
bool
virDomainDefHasMdevHostdev(const virDomainDef *def);

3796 3797 3798 3799 3800 3801
bool
virDomainDefHasOldStyleUEFI(const virDomainDef *def);

bool
virDomainDefHasOldStyleROUEFI(const virDomainDef *def);

3802 3803 3804
bool
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);

3805 3806 3807 3808 3809 3810 3811 3812
bool
virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics);

const char *
virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);

bool
virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);
3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824

bool
virDomainBlockIoTuneInfoHasBasic(const virDomainBlockIoTuneInfo *iotune);

bool
virDomainBlockIoTuneInfoHasMax(const virDomainBlockIoTuneInfo *iotune);

bool
virDomainBlockIoTuneInfoHasMaxLength(const virDomainBlockIoTuneInfo *iotune);

bool
virDomainBlockIoTuneInfoHasAny(const virDomainBlockIoTuneInfo *iotune);
3825 3826 3827 3828

void
virDomainBlockIoTuneInfoCopy(const virDomainBlockIoTuneInfo *src,
                             virDomainBlockIoTuneInfoPtr dst);
3829 3830 3831 3832

bool
virDomainBlockIoTuneInfoEqual(const virDomainBlockIoTuneInfo *a,
                              const virDomainBlockIoTuneInfo *b);
J
Ján Tomko 已提交
3833 3834 3835 3836 3837 3838 3839 3840 3841 3842

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