domain_conf.h 120.6 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 47 48 49 50 51 52 53 54 55 56 57 58
#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"
#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"
59

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

88
    VIR_DOMAIN_DEVICE_LAST
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
} 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 已提交
110
        virDomainNVRAMDefPtr nvram;
111
        virDomainRNGDefPtr rng;
112
        virDomainShmemDefPtr shmem;
113
        virDomainTPMDefPtr tpm;
114
        virDomainPanicDefPtr panic;
115
        virDomainMemoryDefPtr memory;
J
Ján Tomko 已提交
116
        virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
117
        virDomainVsockDefPtr vsock;
118 119 120
    } data;
};

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

140
    VIR_DOMAIN_VIRT_LAST
141
} virDomainVirtType;
142

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

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


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

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

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

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

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

186

187
typedef enum {
188 189 190
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

191
    VIR_DOMAIN_HOSTDEV_MODE_LAST
192
} virDomainHostdevMode;
193

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

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
202
} virDomainHostdevSubsysType;
203

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

    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
212
} virDomainHostdevSubsysPCIBackendType;
213

214
VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend);
215

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

    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
} virDomainHostdevSCSIProtocolType;

223
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol);
224

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

    unsigned vendor;
    unsigned product;
};

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

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

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

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

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

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

275
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIHostProtocol);
276

277 278 279 280 281 282 283 284 285 286 287
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);

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

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

305

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

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

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


331 332
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
333 334 335 336 337 338 339
    /* 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;
340

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

355

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

    VIR_DOMAIN_DISK_DEVICE_LAST
365
} virDomainDiskDevice;
366

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

    VIR_DOMAIN_DISK_BUS_LAST
379
} virDomainDiskBus;
380

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

    VIR_DOMAIN_DISK_CACHE_LAST
390
} virDomainDiskCache;
391

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

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
400
} virDomainDiskErrorPolicy;
401

M
MORITA Kazutaka 已提交
402

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

    VIR_DOMAIN_DISK_TRAY_LAST
408
} virDomainDiskTray;
409

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

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

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

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

436

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

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

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

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

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

462 463 464 465 466 467 468 469 470
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 已提交
471 472 473 474 475 476 477
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;
478 479 480 481 482 483 484
    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;
485
    char *group_name;
486 487 488 489 490 491
    unsigned long long total_bytes_sec_max_length;
    unsigned long long read_bytes_sec_max_length;
    unsigned long long write_bytes_sec_max_length;
    unsigned long long total_iops_sec_max_length;
    unsigned long long read_iops_sec_max_length;
    unsigned long long write_iops_sec_max_length;
L
Lei Li 已提交
492 493
};

494

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

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

    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;

521

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

526 527
    virObjectPtr privateData;

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

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

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

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

L
Lei Li 已提交
550 551
    virDomainBlockIoTuneInfo blkdeviotune;

552 553
    char *driverName;

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


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

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
593
} virDomainControllerType;
594

595

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

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

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

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

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

641
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
642
} virDomainControllerModelSCSI;
643

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

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

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

673 674 675 676 677 678 679 680 681
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;

682
#define IS_USB2_CONTROLLER(ctrl) \
683 684 685 686 687 688
    (((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))

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

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

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

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

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

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

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


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

    VIR_DOMAIN_FS_TYPE_LAST
764
} virDomainFSType;
765

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

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
776
} virDomainFSDriverType;
777

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

    VIR_DOMAIN_FS_ACCESSMODE_LAST
785
} virDomainFSAccessMode;
786

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

    VIR_DOMAIN_FS_WRPOLICY_LAST
793
} virDomainFSWrpolicy;
794

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

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


824
/* network config types */
825
typedef enum {
826 827
    VIR_DOMAIN_NET_TYPE_USER,
    VIR_DOMAIN_NET_TYPE_ETHERNET,
M
Michele Paolino 已提交
828
    VIR_DOMAIN_NET_TYPE_VHOSTUSER,
829 830 831 832 833
    VIR_DOMAIN_NET_TYPE_SERVER,
    VIR_DOMAIN_NET_TYPE_CLIENT,
    VIR_DOMAIN_NET_TYPE_MCAST,
    VIR_DOMAIN_NET_TYPE_NETWORK,
    VIR_DOMAIN_NET_TYPE_BRIDGE,
D
Daniel Veillard 已提交
834
    VIR_DOMAIN_NET_TYPE_INTERNAL,
835
    VIR_DOMAIN_NET_TYPE_DIRECT,
836
    VIR_DOMAIN_NET_TYPE_HOSTDEV,
837
    VIR_DOMAIN_NET_TYPE_UDP,
838

839
    VIR_DOMAIN_NET_TYPE_LAST
840
} virDomainNetType;
841

842 843 844 845
/* network model types */
typedef enum {
    VIR_DOMAIN_NET_MODEL_UNKNOWN,
    VIR_DOMAIN_NET_MODEL_NETFRONT,
C
Cole Robinson 已提交
846 847 848
    VIR_DOMAIN_NET_MODEL_RTL8139,
    VIR_DOMAIN_NET_MODEL_VIRTIO,
    VIR_DOMAIN_NET_MODEL_E1000,
849 850 851 852 853 854 855
    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 已提交
856 857 858 859
    VIR_DOMAIN_NET_MODEL_VLANCE,
    VIR_DOMAIN_NET_MODEL_VMXNET,
    VIR_DOMAIN_NET_MODEL_VMXNET2,
    VIR_DOMAIN_NET_MODEL_VMXNET3,
C
Cole Robinson 已提交
860 861 862 863 864
    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,
865 866 867 868

    VIR_DOMAIN_NET_MODEL_LAST
} virDomainNetModelType;

869
/* the backend driver used for virtio interfaces */
870
typedef enum {
871 872 873 874
    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 */

875
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
876
} virDomainNetBackendType;
877

878
/* the TX algorithm used for virtio interfaces */
879
typedef enum {
880 881 882 883
    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,

884
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
885
} virDomainNetVirtioTxModeType;
886

887
/* link interface states */
888
typedef enum {
889 890 891 892 893
        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
894
} virDomainNetInterfaceLinkState;
895

896 897 898 899 900 901 902 903 904 905
/* 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;
906
            int macTableManager; /* enum virNetworkBridgeMACTableManagerType */
907 908 909 910 911
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
        } direct;
912 913 914
        struct {
            virDomainHostdevDef def;
        } hostdev;
915
    } data;
916
    virNetDevVPortProfilePtr virtPortProfile;
917
    virNetDevBandwidthPtr bandwidth;
918
    virNetDevVlan vlan;
919
    int trustGuestRxFilters; /* enum virTristateBool */
920
    unsigned int class_id; /* class ID for bandwidth 'floor' */
921 922
};

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

1027 1028 1029 1030 1031 1032 1033 1034
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;

1035
VIR_ENUM_DECL(virDomainChrDeviceState);
1036

1037
typedef enum {
1038
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1039 1040
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1041
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1042

1043
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1044
} virDomainChrDeviceType;
1045

1046
typedef enum {
1047 1048
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA,
G
Guannan Ren 已提交
1049
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
M
Michal Privoznik 已提交
1050
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
1051
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO,
1052
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM,
1053
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP,
G
Guannan Ren 已提交
1054 1055

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1056
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1057

1058
typedef enum {
1059 1060
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
1061
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
J
Joao Martins 已提交
1062
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN,
1063

1064
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1065
} virDomainChrChannelTargetType;
1066

1067
typedef enum {
1068 1069
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
1070 1071
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
1072
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
1073 1074
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
1075 1076
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
1077

1078
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1079
} virDomainChrConsoleTargetType;
1080

1081 1082 1083 1084 1085
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,
1086
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY,
1087
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011,
1088 1089
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE,
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE,
1090
    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A,
1091 1092 1093 1094 1095 1096

    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
} virDomainChrSerialTargetModel;

VIR_ENUM_DECL(virDomainChrSerialTargetModel);

1097
typedef enum {
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
    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,
1108
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1109
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1110
    VIR_DOMAIN_CHR_TYPE_NMDM,
1111

1112
    VIR_DOMAIN_CHR_TYPE_LAST
1113
} virDomainChrType;
1114

1115
typedef enum {
1116
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW = 0,
1117
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1118 1119
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1120

1121
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1122
} virDomainChrTcpProtocol;
1123

1124
typedef enum {
E
Eric Blake 已提交
1125 1126
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1127
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1128

1129
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1130
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1131

1132 1133 1134 1135 1136 1137 1138

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


1139 1140
/* The host side information for a character device.  */
struct _virDomainChrSourceDef {
1141
    virObject parent;
1142
    int type; /* virDomainChrType */
1143
    virObjectPtr privateData;
1144
    union {
E
Eric Blake 已提交
1145
        /* no <source> for null, vc, stdio */
1146 1147
        struct {
            char *path;
1148
            int append; /* enum virTristateSwitch */
1149
        } file; /* pty, file, pipe, or device */
1150 1151 1152 1153
        struct {
            char *master;
            char *slave;
        } nmdm;
1154 1155 1156
        struct {
            char *host;
            char *service;
1157
            bool listen;
1158
            int protocol;
1159
            bool tlscreds;
1160
            int haveTLS; /* enum virTristateBool */
1161
            bool tlsFromConfig;
1162
            virDomainChrSourceReconnectDef reconnect;
1163 1164 1165 1166 1167 1168 1169 1170 1171
        } tcp;
        struct {
            char *bindHost;
            char *bindService;
            char *connectHost;
            char *connectService;
        } udp;
        struct {
            char *path;
1172
            bool listen;
1173
            virDomainChrSourceReconnectDef reconnect;
1174
        } nix;
E
Eric Blake 已提交
1175
        int spicevmc;
1176 1177 1178
        struct {
            char *channel;
        } spiceport;
1179
    } data;
1180 1181
    char *logfile;
    int logappend;
1182 1183 1184

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1185 1186 1187 1188
};

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

1191 1192 1193
    int targetType; /* enum virDomainChrConsoleTargetType ||
                       enum virDomainChrChannelTargetType ||
                       enum virDomainChrSerialTargetType according to deviceType */
1194
    int targetModel; /* enum virDomainChrSerialTargetModel */
1195

1196 1197 1198 1199 1200 1201
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

1202 1203
    virDomainChrDeviceState state;

1204
    virDomainChrSourceDefPtr source;
1205 1206

    virDomainDeviceInfo info;
1207 1208
};

1209
typedef enum {
E
Eric Blake 已提交
1210 1211 1212 1213
    VIR_DOMAIN_SMARTCARD_TYPE_HOST,
    VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES,
    VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH,

1214
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1215
} virDomainSmartcardType;
E
Eric Blake 已提交
1216

1217 1218
#define VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES 3
#define VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE "/etc/pki/nssdb"
E
Eric Blake 已提交
1219 1220 1221 1222 1223 1224 1225 1226 1227

struct _virDomainSmartcardDef {
    int type; /* virDomainSmartcardType */
    union {
        /* no extra data for 'host' */
        struct {
            char *file[VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES];
            char *database;
        } cert; /* 'host-certificates' */
1228
        virDomainChrSourceDefPtr passthru; /* 'passthrough' */
E
Eric Blake 已提交
1229 1230 1231 1232 1233
    } data;

    virDomainDeviceInfo info;
};

M
Marc-André Lureau 已提交
1234 1235 1236 1237 1238
struct _virDomainHubDef {
    int type;
    virDomainDeviceInfo info;
};

1239
typedef enum {
1240
    VIR_DOMAIN_TPM_MODEL_TIS,
1241
    VIR_DOMAIN_TPM_MODEL_CRB,
1242 1243

    VIR_DOMAIN_TPM_MODEL_LAST
1244
} virDomainTPMModel;
1245

1246
typedef enum {
1247
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
1248
    VIR_DOMAIN_TPM_TYPE_EMULATOR,
1249 1250

    VIR_DOMAIN_TPM_TYPE_LAST
1251
} virDomainTPMBackendType;
1252

1253 1254 1255 1256 1257 1258 1259 1260
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;

1261
#define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"
1262 1263

struct _virDomainTPMDef {
1264
    int type; /* virDomainTPMBackendType */
1265
    virDomainDeviceInfo info;
1266 1267
    int model; /* virDomainTPMModel */
    int version; /* virDomainTPMVersion */
1268 1269 1270 1271
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
1272 1273 1274 1275
        struct {
            virDomainChrSourceDef source;
            char *storagepath;
            char *logfile;
1276 1277
            unsigned char secretuuid[VIR_UUID_BUFLEN];
            bool hassecretuuid;
1278
        } emulator;
1279 1280 1281
    } data;
};

1282
typedef enum {
1283 1284
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1285
    VIR_DOMAIN_INPUT_TYPE_KBD,
1286
    VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
1287

1288
    VIR_DOMAIN_INPUT_TYPE_LAST
1289
} virDomainInputType;
1290

1291
typedef enum {
1292 1293 1294
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1295
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1296
    VIR_DOMAIN_INPUT_BUS_VIRTIO,
1297 1298

    VIR_DOMAIN_INPUT_BUS_LAST
1299
} virDomainInputBus;
1300

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

1310 1311 1312
struct _virDomainInputDef {
    int type;
    int bus;
1313
    int model; /* virDomainInputModel */
1314 1315 1316
    struct {
        char *evdev;
    } source;
1317
    virDomainDeviceInfo info;
1318
    virDomainVirtioOptionsPtr virtio;
1319 1320
};

1321
typedef enum {
1322 1323
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,
F
Filip Alac 已提交
1324
    VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT,
1325 1326

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1327
} virDomainSoundCodecType;
1328

1329
typedef enum {
1330 1331 1332
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1333
    VIR_DOMAIN_SOUND_MODEL_AC97,
1334
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1335
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1336
    VIR_DOMAIN_SOUND_MODEL_USB,
1337 1338

    VIR_DOMAIN_SOUND_MODEL_LAST
1339
} virDomainSoundModel;
1340

1341 1342 1343 1344 1345
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1346 1347
struct _virDomainSoundDef {
    int model;
1348
    virDomainDeviceInfo info;
1349

1350
    size_t ncodecs;
1351
    virDomainSoundCodecDefPtr *codecs;
1352 1353
};

1354
typedef enum {
R
Richard Jones 已提交
1355 1356
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,
1357
    VIR_DOMAIN_WATCHDOG_MODEL_DIAG288,
R
Richard Jones 已提交
1358 1359

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1360
} virDomainWatchdogModel;
R
Richard Jones 已提交
1361

1362
typedef enum {
R
Richard Jones 已提交
1363 1364 1365 1366
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1367
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1368
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,
1369
    VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI,
R
Richard Jones 已提交
1370 1371

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1372
} virDomainWatchdogAction;
R
Richard Jones 已提交
1373 1374 1375 1376

struct _virDomainWatchdogDef {
    int model;
    int action;
1377
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1378 1379
};

1380

1381 1382
/* the backend driver used for virtio interfaces */
typedef enum {
1383
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT = 0,
1384 1385 1386 1387 1388 1389 1390
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU,
    VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER,

    VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST
} virDomainVideoBackendType;


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

    VIR_DOMAIN_VIDEO_TYPE_LAST
1407
} virDomainVideoType;
1408 1409


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

    VIR_DOMAIN_VIDEO_VGACONF_LAST
} virDomainVideoVGAConf;

1418
VIR_ENUM_DECL(virDomainVideoVGAConf);
1419

1420
struct _virDomainVideoAccelDef {
1421 1422
    int accel2d; /* enum virTristateBool */
    int accel3d; /* enum virTristateBool */
1423
    char *rendernode;
1424 1425
};

1426 1427 1428 1429
struct _virDomainVideoResolutionDef {
    unsigned int x;
    unsigned int y;
};
1430

1431 1432
struct _virDomainVideoDriverDef {
   virDomainVideoVGAConf vgaconf;
1433
    char *vhost_user_binary;
1434 1435
};

1436
struct _virDomainVideoDef {
1437 1438
    virObjectPtr privateData;

1439
    int type;   /* enum virDomainVideoType */
1440 1441
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1442
    unsigned int vram64; /* kibibytes (multiples of 1024) */
1443
    unsigned int vgamem; /* kibibytes (multiples of 1024) */
1444
    unsigned int heads;
1445
    bool primary;
1446
    virDomainVideoAccelDefPtr accel;
1447
    virDomainVideoResolutionDefPtr res;
1448
    virDomainVideoDriverDefPtr driver;
1449
    virDomainDeviceInfo info;
J
Ján Tomko 已提交
1450
    virDomainVirtioOptionsPtr virtio;
1451
    virDomainVideoBackendType backend;
1452 1453
};

1454
/* graphics console modes */
1455
typedef enum {
1456 1457
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1458 1459
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1460
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1461
    VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS,
1462

1463
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1464
} virDomainGraphicsType;
1465

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

1475
typedef enum {
1476 1477 1478 1479 1480 1481
    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
1482
} virDomainGraphicsAuthConnectedType;
1483

1484 1485
struct _virDomainGraphicsAuthDef {
    char *passwd;
1486
    bool expires; /* Whether there is an expiry time set */
1487
    time_t validTo;  /* seconds since epoch */
1488
    int connected; /* action if connected */
1489 1490
};

1491
typedef enum {
1492 1493 1494 1495 1496 1497
    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 已提交
1498
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1499
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1500 1501

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1502
} virDomainGraphicsSpiceChannelName;
1503

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

1512
typedef enum {
1513 1514 1515 1516 1517 1518 1519 1520 1521
    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
1522
} virDomainGraphicsSpiceImageCompression;
1523

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

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

1542
typedef enum {
P
Peng Zhou 已提交
1543 1544 1545 1546 1547
    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
1548
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1549

1550
typedef enum {
1551 1552 1553 1554 1555 1556
    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
1557
} virDomainGraphicsSpiceStreamingMode;
1558

1559
typedef enum {
1560 1561 1562
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1563
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1564

1565
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1566
} virDomainGraphicsListenType;
1567

1568
typedef enum {
M
Marc-André Lureau 已提交
1569 1570
    VIR_DOMAIN_HUB_TYPE_USB,

1571
    VIR_DOMAIN_HUB_TYPE_LAST
1572
} virDomainHubType;
M
Marc-André Lureau 已提交
1573

1574
struct _virDomainGraphicsListenDef {
1575
    virDomainGraphicsListenType type;
1576 1577
    char *address;
    char *network;
1578
    char *socket;
1579
    bool fromConfig;    /* true if the @address is config file originated */
1580
    bool autoGenerated;
1581 1582
};

1583
struct _virDomainGraphicsDef {
1584 1585
    virObjectPtr privateData;

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

1651
typedef enum {
1652 1653 1654
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1655
} virDomainRedirdevBus;
1656 1657 1658 1659

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

1660
    virDomainChrSourceDefPtr source;
1661 1662 1663

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

1665
struct _virDomainRedirFilterUSBDevDef {
1666 1667 1668 1669
    int usbClass;
    int vendor;
    int product;
    int version;
1670
    bool allow;
1671 1672 1673 1674
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1675
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1676 1677
};

1678
typedef enum {
1679 1680
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1681
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1682 1683
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL,
1684 1685

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1686
} virDomainMemballoonModel;
1687 1688 1689 1690

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1691
    int period; /* seconds between collections */
1692
    int autodeflate; /* enum virTristateSwitch */
1693
    virDomainVirtioOptionsPtr virtio;
1694 1695
};

L
Li Zhang 已提交
1696 1697 1698
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1699

1700 1701
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1702 1703
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1704 1705 1706 1707

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

1708 1709 1710
struct _virDomainShmemDef {
    char *name;
    unsigned long long size;
1711
    int model; /* enum virDomainShmemModel */
1712 1713
    struct {
        bool enabled;
1714
        virDomainChrSourceDef chr;
1715 1716 1717 1718 1719 1720 1721 1722 1723
    } server;
    struct {
        bool enabled;
        unsigned vectors;
        virTristateSwitch ioeventfd;
    } msi;
    virDomainDeviceInfo info;
};

1724
typedef enum {
1725
    VIR_DOMAIN_SMBIOS_NONE = 0,
1726 1727 1728 1729 1730
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1731
} virDomainSmbiosMode;
1732

1733

1734
#define VIR_DOMAIN_MAX_BOOT_DEVS 4
1735

1736
typedef enum {
1737 1738 1739 1740 1741
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1742
    VIR_DOMAIN_BOOT_LAST
1743
} virDomainBootOrder;
1744

1745
typedef enum {
1746 1747 1748
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1749
    VIR_DOMAIN_FEATURE_HAP,
1750
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1751
    VIR_DOMAIN_FEATURE_PRIVNET,
1752
    VIR_DOMAIN_FEATURE_HYPERV,
1753
    VIR_DOMAIN_FEATURE_KVM,
1754
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1755
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1756
    VIR_DOMAIN_FEATURE_PMU,
1757
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1758
    VIR_DOMAIN_FEATURE_GIC,
M
Michal Privoznik 已提交
1759
    VIR_DOMAIN_FEATURE_SMM,
1760
    VIR_DOMAIN_FEATURE_IOAPIC,
1761
    VIR_DOMAIN_FEATURE_HPT,
M
Marc-André Lureau 已提交
1762
    VIR_DOMAIN_FEATURE_VMCOREINFO,
1763
    VIR_DOMAIN_FEATURE_HTM,
1764
    VIR_DOMAIN_FEATURE_NESTED_HV,
1765
    VIR_DOMAIN_FEATURE_MSRS,
1766
    VIR_DOMAIN_FEATURE_CCF_ASSIST,
1767 1768

    VIR_DOMAIN_FEATURE_LAST
1769
} virDomainFeature;
1770

1771
#define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12
1772

1773
typedef enum {
1774
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1775 1776
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1777 1778 1779 1780 1781 1782
    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,
1783
    VIR_DOMAIN_HYPERV_FREQUENCIES,
1784
    VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
1785
    VIR_DOMAIN_HYPERV_TLBFLUSH,
1786
    VIR_DOMAIN_HYPERV_IPI,
1787
    VIR_DOMAIN_HYPERV_EVMCS,
1788 1789

    VIR_DOMAIN_HYPERV_LAST
1790
} virDomainHyperv;
1791

1792 1793
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,
1794
    VIR_DOMAIN_KVM_DEDICATED,
1795 1796 1797 1798

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811
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;

1812 1813 1814 1815 1816 1817 1818 1819 1820 1821
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 {
1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860
    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;
1861

1862 1863 1864 1865 1866 1867 1868 1869 1870 1871
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;

1872
VIR_ENUM_DECL(virDomainLockFailure);
1873

M
Michal Privoznik 已提交
1874
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1875
    int useserial; /* enum virTristateBool */
1876 1877 1878
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1879 1880
};

1881
typedef enum {
1882 1883
    VIR_DOMAIN_LOADER_TYPE_NONE = 0,
    VIR_DOMAIN_LOADER_TYPE_ROM,
1884 1885 1886 1887 1888
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

1889
VIR_ENUM_DECL(virDomainLoader);
1890 1891 1892 1893 1894

struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1895
    int secure;     /* enum virTristateBool */
1896
    char *nvram;    /* path to non-volatile RAM */
1897
    char *templt;   /* user override of path to master nvram */
1898 1899 1900 1901
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1902
typedef enum {
1903 1904
    VIR_DOMAIN_IOAPIC_NONE = 0,
    VIR_DOMAIN_IOAPIC_QEMU,
1905 1906 1907 1908 1909 1910 1911
    VIR_DOMAIN_IOAPIC_KVM,

    VIR_DOMAIN_IOAPIC_LAST
} virDomainIOAPIC;

VIR_ENUM_DECL(virDomainIOAPIC);

1912
typedef enum {
1913 1914
    VIR_DOMAIN_HPT_RESIZING_NONE = 0,
    VIR_DOMAIN_HPT_RESIZING_ENABLED,
1915 1916 1917 1918 1919 1920 1921 1922
    VIR_DOMAIN_HPT_RESIZING_DISABLED,
    VIR_DOMAIN_HPT_RESIZING_REQUIRED,

    VIR_DOMAIN_HPT_RESIZING_LAST
} virDomainHPTResizing;

VIR_ENUM_DECL(virDomainHPTResizing);

1923
/* Operating system configuration data & machine / arch */
1924 1925 1926 1927 1928
struct _virDomainOSEnv {
    char *name;
    char *value;
};

1929 1930
typedef enum {
    VIR_DOMAIN_OS_DEF_FIRMWARE_NONE = 0,
1931 1932
    VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS = VIR_DOMAIN_LOADER_TYPE_ROM,
    VIR_DOMAIN_OS_DEF_FIRMWARE_EFI = VIR_DOMAIN_LOADER_TYPE_PFLASH,
1933 1934 1935 1936

    VIR_DOMAIN_OS_DEF_FIRMWARE_LAST
} virDomainOsDefFirmware;

1937 1938
G_STATIC_ASSERT((int)VIR_DOMAIN_OS_DEF_FIRMWARE_LAST == (int)VIR_DOMAIN_LOADER_TYPE_LAST);

1939 1940
VIR_ENUM_DECL(virDomainOsDefFirmware);

1941
struct _virDomainOSDef {
1942
    int type;
1943
    virDomainOsDefFirmware firmware;
1944
    virArch arch;
1945
    char *machine;
1946
    size_t nBootDevs;
1947
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1948
    int bootmenu; /* enum virTristateBool */
1949 1950
    unsigned int bm_timeout;
    bool bm_timeout_set;
1951
    char *init;
1952
    char **initargv;
1953
    virDomainOSEnvPtr *initenv;
1954
    char *initdir;
1955 1956
    char *inituser;
    char *initgroup;
1957 1958 1959
    char *kernel;
    char *initrd;
    char *cmdline;
1960
    char *dtb;
1961
    char *root;
J
Ján Tomko 已提交
1962
    char *slic_table;
1963
    virDomainLoaderDefPtr loader;
1964 1965
    char *bootloader;
    char *bootloaderArgs;
1966
    int smbios_mode;
1967

M
Michal Privoznik 已提交
1968
    virDomainBIOSDef bios;
1969 1970
};

1971
typedef enum {
1972 1973 1974 1975 1976
    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 已提交
1977
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1978
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
1979

1980
    VIR_DOMAIN_TIMER_NAME_LAST
1981
} virDomainTimerNameType;
1982

1983
typedef enum {
1984 1985 1986
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1987

1988
    VIR_DOMAIN_TIMER_TRACK_LAST
1989
} virDomainTimerTrackType;
1990

1991
typedef enum {
1992 1993 1994 1995 1996
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

1997
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
1998
} virDomainTimerTickpolicyType;
1999

2000
typedef enum {
2001 2002 2003 2004
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
2005
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
2006

2007
    VIR_DOMAIN_TIMER_MODE_LAST
2008
} virDomainTimerModeType;
2009

2010
typedef enum {
2011
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
2012 2013
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

2014
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
2015
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
2016

2017
struct _virDomainThreadSchedParam {
2018
    virProcessSchedPolicy policy;
2019 2020 2021
    int priority;
};

2022 2023 2024 2025 2026 2027
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

2028 2029 2030 2031 2032
struct _virDomainTimerDef {
    int name;
    int present;    /* unspecified = -1, no = 0, yes = 1 */
    int tickpolicy; /* none|catchup|merge|discard */

2033 2034 2035 2036
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
2037 2038 2039 2040 2041 2042

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

2043
typedef enum {
2044 2045
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
2046
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
2047
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
2048

2049
    VIR_DOMAIN_CLOCK_OFFSET_LAST
2050
} virDomainClockOffsetType;
2051

2052
typedef enum {
2053 2054 2055
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

2056
    VIR_DOMAIN_CLOCK_BASIS_LAST
2057
} virDomainClockBasis;
2058

2059 2060
struct _virDomainClockDef {
    int offset;
2061

2062
    union {
2063 2064 2065
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
2066
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
2067 2068 2069
        struct {
            long long adjustment;
            int basis;
2070 2071 2072 2073 2074 2075 2076

            /* 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;
2077
        } variable;
2078 2079 2080 2081 2082

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

2084
    size_t ntimers;
2085
    virDomainTimerDefPtr *timers;
2086 2087
};

2088

2089
struct _virBlkioDevice {
2090 2091
    char *path;
    unsigned int weight;
2092 2093 2094 2095
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
2096 2097
};

2098
typedef enum {
2099
    VIR_DOMAIN_RNG_MODEL_VIRTIO,
2100 2101
    VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL,
2102 2103

    VIR_DOMAIN_RNG_MODEL_LAST
2104
} virDomainRNGModel;
2105

2106
typedef enum {
2107 2108
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
H
Han Han 已提交
2109
    VIR_DOMAIN_RNG_BACKEND_BUILTIN,
2110 2111

    VIR_DOMAIN_RNG_BACKEND_LAST
2112
} virDomainRNGBackend;
2113 2114 2115 2116

struct _virDomainRNGDef {
    int model;
    int backend;
2117 2118
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
2119 2120 2121 2122 2123 2124 2125 2126

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

    virDomainDeviceInfo info;
2127
    virDomainVirtioOptionsPtr virtio;
2128 2129
};

2130 2131 2132
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2133
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2134 2135 2136 2137 2138

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
2139
    virDomainMemoryAccess access;
2140
    virTristateBool discard;
2141

2142 2143 2144
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2145
    char *nvdimmPath;
2146
    unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
2147
    bool nvdimmPmem; /* valid only for NVDIMM */
2148 2149 2150

    /* target */
    int model; /* virDomainMemoryModel */
2151
    int targetNode;
2152
    unsigned long long size; /* kibibytes */
2153
    unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
2154
    bool readonly; /* valid only for NVDIMM */
2155 2156 2157 2158 2159 2160

    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2176 2177 2178 2179 2180
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2181
    VIR_DOMAIN_PANIC_MODEL_S390,
2182 2183 2184 2185

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2186
struct _virDomainPanicDef {
2187
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2188 2189 2190 2191
    virDomainDeviceInfo info;
};


2192
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2193
                              int ndevices);
2194

2195 2196 2197
struct _virDomainResourceDef {
    char *partition;
};
2198

2199
struct _virDomainHugePage {
2200 2201 2202 2203
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2204
#define VIR_DOMAIN_CPUMASK_LEN 1024
2205

2206 2207 2208
struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2209
    int thread_id;
2210
    virBitmapPtr cpumask;
2211 2212

    virDomainThreadSchedParam sched;
2213 2214 2215 2216
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2217

2218
struct _virDomainCputune {
2219
    unsigned long long shares;
2220 2221 2222
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2223
    unsigned long long global_period;
2224
    long long global_quota;
2225 2226
    unsigned long long emulator_period;
    long long emulator_quota;
2227 2228
    unsigned long long iothread_period;
    long long iothread_quota;
2229
    virBitmapPtr emulatorpin;
2230
    virDomainThreadSchedParamPtr emulatorsched;
2231 2232
};

2233

2234 2235 2236 2237 2238 2239
struct _virDomainResctrlMonDef {
    virBitmapPtr vcpus;
    virResctrlMonitorType tag;
    virResctrlMonitorPtr instance;
};

B
Bing Niu 已提交
2240
struct _virDomainResctrlDef {
2241 2242
    virBitmapPtr vcpus;
    virResctrlAllocPtr alloc;
2243 2244 2245

    virDomainResctrlMonDefPtr *monitors;
    size_t nmonitors;
2246 2247 2248
};


2249
struct _virDomainVcpuDef {
2250
    bool online;
2251 2252 2253
    virTristateBool hotpluggable;
    unsigned int order;

2254
    virBitmapPtr cpumask;
2255 2256

    virDomainThreadSchedParam sched;
2257 2258

    virObjectPtr privateData;
2259 2260
};

2261 2262 2263 2264 2265 2266 2267 2268
struct _virDomainBlkiotune {
    unsigned int weight;

    size_t ndevices;
    virBlkioDevicePtr devices;
};

struct _virDomainMemtune {
2269 2270 2271
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2272 2273
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2274 2275 2276 2277

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2278 2279 2280 2281
    /* 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 */

2282 2283 2284
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2285 2286 2287 2288
    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 */
2289 2290 2291 2292

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2293 2294

    virTristateBool discard;
2295 2296 2297 2298 2299 2300 2301 2302
};

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

Q
Qiaowei Ren 已提交
2303 2304 2305 2306 2307
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2308 2309 2310 2311 2312
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

2313 2314 2315 2316 2317 2318 2319 2320
typedef enum {
    VIR_DOMAIN_LAUNCH_SECURITY_NONE,
    VIR_DOMAIN_LAUNCH_SECURITY_SEV,

    VIR_DOMAIN_LAUNCH_SECURITY_LAST,
} virDomainLaunchSecurity;


2321
struct _virDomainSEVDef {
2322 2323 2324 2325 2326 2327 2328 2329 2330
    int sectype; /* enum virDomainLaunchSecurity */
    char *dh_cert;
    char *session;
    unsigned int policy;
    unsigned int cbitpos;
    unsigned int reduced_phys_bits;
};


J
Ján Tomko 已提交
2331 2332
typedef enum {
    VIR_DOMAIN_IOMMU_MODEL_INTEL,
2333
    VIR_DOMAIN_IOMMU_MODEL_SMMUV3,
J
Ján Tomko 已提交
2334 2335 2336 2337 2338 2339

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

struct _virDomainIOMMUDef {
    virDomainIOMMUModel model;
2340
    virTristateSwitch intremap;
2341
    virTristateSwitch caching_mode;
2342
    virTristateSwitch eim;
J
Ján Tomko 已提交
2343
    virTristateSwitch iotlb;
J
Ján Tomko 已提交
2344
};
2345

J
Ján Tomko 已提交
2346 2347 2348
typedef enum {
    VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO,
2349 2350
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL,
J
Ján Tomko 已提交
2351 2352 2353 2354

    VIR_DOMAIN_VSOCK_MODEL_LAST
} virDomainVsockModel;

J
Ján Tomko 已提交
2355
struct _virDomainVsockDef {
2356
    virObjectPtr privateData;
J
Ján Tomko 已提交
2357 2358 2359 2360 2361 2362

    virDomainVsockModel model;
    unsigned int guest_cid;
    virTristateBool auto_cid;

    virDomainDeviceInfo info;
J
Ján Tomko 已提交
2363 2364
};

2365 2366 2367 2368 2369
struct _virDomainVirtioOptions {
    virTristateSwitch iommu;
    virTristateSwitch ats;
};

2370 2371 2372 2373 2374 2375
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
2376
struct _virDomainDef {
2377
    int virtType; /* enum virDomainVirtType */
2378 2379
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
2380 2381 2382 2383 2384

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

2385
    char *name;
2386
    char *title;
2387
    char *description;
2388

2389 2390
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2391

2392
    virDomainVcpuDefPtr *vcpus;
2393
    size_t maxvcpus;
2394 2395
    /* set if the vcpu definition was specified individually */
    bool individualvcpus;
O
Osier Yang 已提交
2396
    int placement_mode;
H
Hu Tao 已提交
2397
    virBitmapPtr cpumask;
2398

2399 2400
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2401

2402
    virDomainCputune cputune;
2403

B
Bing Niu 已提交
2404 2405
    virDomainResctrlDefPtr *resctrls;
    size_t nresctrls;
2406

2407
    virDomainNumaPtr numa;
2408
    virDomainResourceDefPtr resource;
2409
    virDomainIdMapDef idmap;
2410

2411 2412 2413 2414 2415
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2416 2417
    int onLockFailure; /* enum virDomainLockFailureAction */

2418
    virDomainPowerManagement pm;
2419

2420
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2421

2422 2423
    virDomainOSDef os;
    char *emulator;
2424 2425 2426
    /* 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. */
2427
    int features[VIR_DOMAIN_FEATURE_LAST];
2428
    int caps_features[VIR_DOMAIN_PROCES_CAPS_FEATURE_LAST];
2429
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2430
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2431
    int msrs_features[VIR_DOMAIN_MSRS_LAST];
2432
    unsigned int hyperv_spinlocks;
2433
    int hyperv_stimer_direct;
2434
    virGICVersion gic_version;
2435
    virDomainHPTResizing hpt_resizing;
2436
    unsigned long long hpt_maxpagesize; /* Stored in KiB */
2437
    char *hyperv_vendor_id;
2438
    int apic_eoi;
2439

2440 2441 2442
    bool tseg_specified;
    unsigned long long tseg_size;

2443
    virDomainClockDef clock;
2444

2445
    size_t ngraphics;
2446
    virDomainGraphicsDefPtr *graphics;
2447

2448
    size_t ndisks;
2449 2450
    virDomainDiskDefPtr *disks;

2451
    size_t ncontrollers;
2452 2453
    virDomainControllerDefPtr *controllers;

2454
    size_t nfss;
2455 2456
    virDomainFSDefPtr *fss;

2457
    size_t nnets;
2458 2459
    virDomainNetDefPtr *nets;

2460
    size_t ninputs;
2461 2462
    virDomainInputDefPtr *inputs;

2463
    size_t nsounds;
2464 2465
    virDomainSoundDefPtr *sounds;

2466
    size_t nvideos;
2467 2468
    virDomainVideoDefPtr *videos;

2469
    size_t nhostdevs;
2470 2471
    virDomainHostdevDefPtr *hostdevs;

2472
    size_t nredirdevs;
2473 2474
    virDomainRedirdevDefPtr *redirdevs;

2475
    size_t nsmartcards;
E
Eric Blake 已提交
2476 2477
    virDomainSmartcardDefPtr *smartcards;

2478
    size_t nserials;
2479 2480
    virDomainChrDefPtr *serials;

2481
    size_t nparallels;
2482 2483
    virDomainChrDefPtr *parallels;

2484
    size_t nchannels;
2485 2486
    virDomainChrDefPtr *channels;

2487
    size_t nconsoles;
2488 2489
    virDomainChrDefPtr *consoles;

2490
    size_t nleases;
2491 2492
    virDomainLeaseDefPtr *leases;

2493
    size_t nhubs;
M
Marc-André Lureau 已提交
2494 2495
    virDomainHubDefPtr *hubs;

2496 2497 2498
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2499 2500 2501
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2502 2503 2504
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2505 2506 2507
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2508 2509 2510
    size_t npanics;
    virDomainPanicDefPtr *panics;

2511
    /* Only 1 */
R
Richard Jones 已提交
2512
    virDomainWatchdogDefPtr watchdog;
2513
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2514
    virDomainNVRAMDefPtr nvram;
2515
    virDomainTPMDefPtr tpm;
2516
    virCPUDefPtr cpu;
2517
    virSysinfoDefPtr sysinfo;
2518
    virDomainRedirFilterDefPtr redirfilter;
J
Ján Tomko 已提交
2519
    virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
2520
    virDomainVsockDefPtr vsock;
2521 2522

    void *namespaceData;
2523
    virXMLNamespace ns;
2524

2525 2526
    virDomainKeyWrapDefPtr keywrap;

2527
    /* SEV-specific domain */
2528
    virDomainSEVDefPtr sev;
2529

2530 2531
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2532 2533 2534 2535 2536 2537

    /* 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 */
2538 2539
};

2540

2541
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2542
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2543
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2544
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2545

2546 2547 2548 2549 2550 2551 2552
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

2553
typedef enum {
2554 2555 2556 2557 2558
    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 */
2559
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2560
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2561
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2562
    VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,/* CDROM passthrough */
Y
Yuri Chornoivan 已提交
2563
    VIR_DOMAIN_TAINT_CUSTOM_DTB,       /* Custom device tree blob was specified */
2564
    VIR_DOMAIN_TAINT_CUSTOM_GA_COMMAND, /* Custom guest agent command */
2565
    VIR_DOMAIN_TAINT_CUSTOM_HYPERVISOR_FEATURE, /* custom hypervisor feature control */
2566 2567

    VIR_DOMAIN_TAINT_LAST
2568
} virDomainTaintFlags;
2569

2570
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2571 2572 2573 2574 2575 2576
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2577
struct _virDomainObj {
2578
    virObjectLockable parent;
2579
    virCond cond;
2580

2581
    pid_t pid;
J
Jiri Denemark 已提交
2582
    virDomainStateReason state;
2583 2584 2585

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2586
    unsigned int updated : 1;
2587
    unsigned int removing : 1;
2588 2589 2590

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

2592
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2593

2594 2595
    bool hasManagedSave;

2596 2597
    virDomainCheckpointObjListPtr checkpoints;

2598 2599
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2600 2601

    int taint;
2602 2603 2604

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

2607 2608 2609
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainObj, virObjectUnref);


2610 2611
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2612

2613

2614 2615
/* NB: Any new flag to this list be considered to be set in
 * virt-aa-helper code if the flag prevents parsing. */
2616 2617
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2618
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2619
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2620
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2621
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2622
    VIR_DOMAIN_DEF_FEATURE_USER_ALIAS = (1 << 5),
2623
    VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER = (1 << 6),
2624
    VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT = (1 << 7),
2625
    VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING = (1 << 8),
2626 2627 2628
} virDomainDefFeatures;


2629 2630 2631 2632 2633 2634 2635
/* 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);

2636
/* Called once after everything else has been parsed, for adjusting
2637 2638 2639
 * overall domain defaults.
 * @parseOpaque is opaque data passed by virDomainDefParse* caller,
 * @opaque is opaque data set by driver (usually pointer to driver
2640 2641 2642 2643
 * 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. */
2644
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
2645
                                             unsigned int parseFlags,
2646 2647
                                             void *opaque,
                                             void *parseOpaque);
2648
/* Called once per device, for adjusting per-device settings while
2649 2650 2651 2652
 * 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). */
2653
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
2654
                                                   const virDomainDef *def,
2655
                                                   unsigned int parseFlags,
2656 2657
                                                   void *opaque,
                                                   void *parseOpaque);
2658
/* Drive callback for assigning device addresses, called at the end
2659 2660 2661 2662
 * 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). */
2663 2664
typedef int (*virDomainDefAssignAddressesCallback)(virDomainDef *def,
                                                   unsigned int parseFlags,
2665 2666
                                                   void *opaque,
                                                   void *parseOpaque);
2667

2668 2669 2670 2671 2672 2673
typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def,
                                              unsigned int parseFlags,
                                              void *opaque,
                                              void **parseOpaque);
typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque);

2674 2675 2676 2677 2678
/* 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);
2679

2680 2681 2682 2683 2684 2685
/* 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);

2686
struct _virDomainDefParserConfig {
2687
    /* driver domain definition callbacks */
2688
    virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
2689
    virDomainDefPostParseDataAlloc domainPostParseDataAlloc;
2690 2691
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2692
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2693
    virDomainDefPostParseDataFree domainPostParseDataFree;
2694

2695 2696
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2697
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2698

2699
    /* private data for the callbacks */
2700 2701
    void *priv;
    virFreeCallback privFree;
2702 2703

    /* data */
2704
    unsigned int features; /* virDomainDefFeatures */
2705
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2706
    virArch defArch;
2707
    const char *netPrefix;
2708
    const char *defSecModel;
2709 2710
};

2711
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *);
2712 2713 2714 2715 2716 2717 2718 2719
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
                                                 virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                virDomainObjPtr,
                                                virDomainDefParserConfigPtr);

2720 2721
typedef void *(*virDomainXMLPrivateDataGetParseOpaqueFunc)(virDomainObjPtr vm);

2722 2723 2724 2725 2726
typedef int (*virDomainXMLPrivateDataDiskParseFunc)(xmlXPathContextPtr ctxt,
                                                    virDomainDiskDefPtr disk);
typedef int (*virDomainXMLPrivateDataDiskFormatFunc)(virDomainDiskDefPtr disk,
                                                     virBufferPtr buf);

2727 2728 2729 2730 2731 2732
typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
                                                             virStorageSourcePtr src);
typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
                                                              virBufferPtr buf);


2733 2734 2735
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
2736 2737
    /* note that private data for devices are not copied when using
     * virDomainDefCopy and similar functions */
2738
    virDomainXMLPrivateDataNewFunc    diskNew;
2739 2740
    virDomainXMLPrivateDataDiskParseFunc diskParse;
    virDomainXMLPrivateDataDiskFormatFunc diskFormat;
2741
    virDomainXMLPrivateDataNewFunc    vcpuNew;
2742
    virDomainXMLPrivateDataNewFunc    chrSourceNew;
2743
    virDomainXMLPrivateDataNewFunc    vsockNew;
2744
    virDomainXMLPrivateDataNewFunc    graphicsNew;
2745
    virDomainXMLPrivateDataNewFunc    networkNew;
2746
    virDomainXMLPrivateDataNewFunc    videoNew;
2747
    virDomainXMLPrivateDataNewFunc    fsNew;
2748 2749
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
2750 2751 2752
    /* following function shall return a pointer which will be used as the
     * 'parseOpaque' argument for virDomainDefPostParse */
    virDomainXMLPrivateDataGetParseOpaqueFunc getParseOpaque;
2753 2754
    virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
    virDomainXMLPrivateDataStorageSourceFormatFunc storageFormat;
2755 2756
};

2757 2758 2759 2760 2761 2762 2763
typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
                                            const virDomainDef *dst);

struct _virDomainABIStability {
    virDomainABIStabilityDomain domain;
};

2764 2765
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
2766
                                            virXMLNamespacePtr xmlns,
2767 2768 2769 2770 2771
                                            virDomainABIStabilityPtr abi,
                                            virSaveCookieCallbacksPtr saveCookie);

virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
2772

2773 2774 2775 2776 2777 2778 2779
typedef int (*virDomainMomentPostParseCallback)(virDomainMomentDefPtr def);

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

2780 2781
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2782
virXMLNamespacePtr
2783
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2784 2785
    ATTRIBUTE_NONNULL(1);

2786 2787 2788 2789
bool
virDomainSCSIDriveAddressIsUsed(const virDomainDef *def,
                                const virDomainDeviceDriveAddress *addr);

2790 2791 2792 2793
int virDomainDefPostParse(virDomainDefPtr def,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2794
bool virDomainDefHasUSB(const virDomainDef *def);
2795

2796 2797 2798 2799
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
                                           virDomainDeviceDefPtr dev,
                                           unsigned int flags);

2800 2801
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);

2802
int virDomainDefValidate(virDomainDefPtr def,
2803 2804 2805
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2806 2807 2808
int
virDomainActualNetDefValidate(const virDomainNetDef *net);

2809
static inline bool
D
Daniel P. Berrange 已提交
2810
virDomainObjIsActive(virDomainObjPtr dom)
2811 2812 2813 2814
{
    return dom->def->id != -1;
}

2815 2816
int virDomainObjCheckActive(virDomainObjPtr dom);

2817 2818 2819 2820 2821 2822 2823 2824 2825
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)
2826
    G_GNUC_WARN_UNUSED_RESULT;
2827
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2828 2829
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2830

2831
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2832
    ATTRIBUTE_NONNULL(1);
2833

M
Michal Privoznik 已提交
2834 2835
void virDomainObjEndAPI(virDomainObjPtr *vm);

2836
bool virDomainObjTaint(virDomainObjPtr obj,
2837
                       virDomainTaintFlags taint);
2838

2839 2840 2841 2842
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2843

H
Hu Tao 已提交
2844
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2845
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2846
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
J
Ján Tomko 已提交
2847
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
2848
void virDomainInputDefFree(virDomainInputDefPtr def);
2849
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2850
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2851
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2852 2853
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2854
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2855
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
2856
    G_GNUC_WARN_UNUSED_RESULT;
2857
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
2858
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
2859
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
2860
    G_GNUC_WARN_UNUSED_RESULT;
2861 2862
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2863 2864
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
2865 2866 2867 2868
                                  const virDomainDeviceDriveAddress *addr);
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2869 2870

virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type);
2871
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2872
bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont);
2873

2874
virDomainFSDefPtr virDomainFSDefNew(virDomainXMLOptionPtr xmlopt);
2875
void virDomainFSDefFree(virDomainFSDefPtr def);
2876
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
J
Ján Tomko 已提交
2877 2878
virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt);
void virDomainVsockDefFree(virDomainVsockDefPtr vsock);
2879
void virDomainNetDefClear(virDomainNetDefPtr def);
2880
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2881
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2882
void virDomainChrDefFree(virDomainChrDefPtr def);
2883 2884
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
                              virDomainChrSourceDefPtr src);
2885
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
J
Jidong Xia 已提交
2886 2887
ssize_t virDomainSoundDefFind(const virDomainDef *def,
                              const virDomainSoundDef *sound);
2888
void virDomainSoundDefFree(virDomainSoundDefPtr def);
J
Jidong Xia 已提交
2889
virDomainSoundDefPtr virDomainSoundDefRemove(virDomainDefPtr def, size_t idx);
2890
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2891
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2892
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
2893
virDomainVideoDefPtr virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt);
2894
void virDomainVideoDefFree(virDomainVideoDefPtr def);
2895
void virDomainVideoDefClear(virDomainVideoDefPtr def);
J
John Ferlan 已提交
2896
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
2897
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2898
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2899
void virDomainHubDefFree(virDomainHubDefPtr def);
2900
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2901
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2902
void virDomainShmemDefFree(virDomainShmemDefPtr def);
2903
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2904
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2905
                                             const virDomainDef *def,
2906 2907
                                             virDomainXMLOptionPtr xmlopt,
                                             void *parseOpaque);
2908
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
C
Cole Robinson 已提交
2909 2910
void virDomainDeviceSetData(virDomainDeviceDefPtr device,
                            void *devicedata);
2911
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2912

2913
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2914 2915
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2916 2917 2918 2919 2920 2921
                                           void *opaque);

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

2922 2923
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
2924
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
2925

2926
void virDomainDefFree(virDomainDefPtr vm);
2927
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDef, virDomainDefFree);
2928

2929 2930 2931
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);

2932
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
2933

2934 2935
virDomainGraphicsDefPtr
virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt);
2936 2937 2938 2939

virDomainNetDefPtr
virDomainNetDefNew(virDomainXMLOptionPtr xmlopt);

2940
virDomainDefPtr virDomainDefNew(void);
2941

2942
void virDomainObjAssignDef(virDomainObjPtr domain,
2943
                           virDomainDefPtr def,
2944 2945
                           bool live,
                           virDomainDefPtr *oldDef);
2946
int virDomainObjSetDefTransient(virDomainXMLOptionPtr xmlopt,
2947 2948
                                virDomainObjPtr domain,
                                void *parseOpaque);
2949
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
2950
virDomainDefPtr
2951
virDomainObjGetPersistentDef(virDomainXMLOptionPtr xmlopt,
2952 2953
                             virDomainObjPtr domain,
                             void *parseOpaque);
2954 2955 2956 2957 2958 2959 2960 2961

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

int virDomainObjGetDefs(virDomainObjPtr vm,
                        unsigned int flags,
                        virDomainDefPtr *liveDef,
                        virDomainDefPtr *persDef);
2962 2963 2964
virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                           unsigned int flags,
                                           bool *state);
2965
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
2966

2967 2968
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virDomainXMLOptionPtr xmlopt,
2969
                                 void *parseOpaque,
2970 2971
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
2972 2973
                                              virDomainXMLOptionPtr xmlopt,
                                              void *parseOpaque);
2974

2975 2976 2977
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
2978 2979 2980 2981
    /* 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. */
2982 2983 2984 2985 2986
    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,
2987
    /* internal flag passed to device info sub-parser to allow using <rom> */
2988
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
2989
    /* internal flag passed to device info sub-parser to allow specifying boot order */
2990 2991
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    /* parse only source half of <disk> */
2992
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 6,
2993
    /* perform RNG schema validation on the passed XML document */
2994
    VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA = 1 << 7,
2995
    /* allow updates in post parse callback that would break ABI otherwise */
2996
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE = 1 << 8,
2997
    /* skip definition validation checks meant to be executed on define time only */
2998
    VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 9,
2999
    /* skip parsing of security labels */
3000
    VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 10,
3001 3002 3003
    /* 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. */
3004
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 11,
3005 3006 3007 3008
    /* 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 */
3009
    VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL = 1 << 12,
3010 3011 3012 3013 3014
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
3015
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
3016
    /* format internal domain status information */
3017
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
3018
    /* format <actual> element */
3019
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
3020
    /* format original states of host PCI device */
3021 3022 3023 3024
    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,
3025 3026
} virDomainDefFormatFlags;

3027 3028 3029 3030 3031 3032 3033 3034 3035
/* 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;

3036
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
3037
                                              const virDomainDef *def,
3038
                                              virDomainXMLOptionPtr xmlopt,
3039
                                              void *parseOpaque,
L
Laine Stump 已提交
3040
                                              unsigned int flags);
3041 3042 3043
virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr,
                                          virDomainXMLOptionPtr xmlopt,
                                          unsigned int flags);
3044
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
3045
                                        virDomainXMLOptionPtr xmlopt,
3046
                                        void *parseOpaque,
L
Laine Stump 已提交
3047
                                        unsigned int flags);
3048
virDomainDefPtr virDomainDefParseFile(const char *filename,
3049
                                      virDomainXMLOptionPtr xmlopt,
3050
                                      void *parseOpaque,
L
Laine Stump 已提交
3051
                                      unsigned int flags);
3052
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
3053
                                      xmlNodePtr root,
3054
                                      virDomainXMLOptionPtr xmlopt,
3055
                                      void *parseOpaque,
L
Laine Stump 已提交
3056
                                      unsigned int flags);
3057 3058 3059 3060
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3061 3062 3063
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3064

3065
bool virDomainDefCheckABIStability(virDomainDefPtr src,
3066 3067
                                   virDomainDefPtr dst,
                                   virDomainXMLOptionPtr xmlopt);
3068

3069 3070
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
                                        virDomainDefPtr dst,
3071
                                        virDomainXMLOptionPtr xmlopt,
3072 3073
                                        unsigned int flags);

3074 3075
int virDomainDefAddImplicitDevices(virDomainDefPtr def,
                                   virDomainXMLOptionPtr xmlopt);
3076

3077
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
3078 3079 3080 3081 3082
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);

3083 3084 3085 3086 3087 3088
/* 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. */
3089
#define VIR_DOMAIN_XML_COMMON_FLAGS \
3090 3091
    (VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE | \
     VIR_DOMAIN_XML_MIGRATABLE)
3092 3093
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

3094
char *virDomainDefFormat(virDomainDefPtr def,
3095 3096
                         virDomainXMLOptionPtr xmlopt,
                         unsigned int flags)
J
John Ferlan 已提交
3097
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3098 3099 3100
char *virDomainObjFormat(virDomainObjPtr obj,
                         virDomainXMLOptionPtr xmlopt,
                         unsigned int flags)
J
John Ferlan 已提交
3101
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3102
int virDomainDefFormatInternal(virDomainDefPtr def,
3103
                               virDomainXMLOptionPtr xmlopt,
3104
                               virBufferPtr buf,
3105 3106
                               unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3107
    ATTRIBUTE_NONNULL(3);
3108
int virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
3109
                                          virDomainXMLOptionPtr xmlopt,
3110
                                          virBufferPtr buf,
3111 3112 3113
                                          const char *rootname,
                                          unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3114
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3115

3116 3117
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
3118
                              const char *element,
3119
                              int policy,
3120
                              bool attrIndex,
3121
                              unsigned int flags,
3122
                              bool formatsecrets,
3123
                              virDomainXMLOptionPtr xmlopt);
3124

3125 3126 3127 3128 3129 3130
int
virDomainDiskBackingStoreFormat(virBufferPtr buf,
                                virStorageSourcePtr src,
                                virDomainXMLOptionPtr xmlopt,
                                unsigned int flags);

3131 3132
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
3133
                          virDomainXMLOptionPtr xmlopt,
3134 3135
                          unsigned int flags);

3136 3137 3138 3139 3140 3141
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

3142
int virDomainDefCompatibleDevice(virDomainDefPtr def,
3143
                                 virDomainDeviceDefPtr dev,
3144
                                 virDomainDeviceDefPtr oldDev,
3145 3146
                                 virDomainDeviceAction action,
                                 bool live);
3147

3148 3149
void virDomainRNGDefFree(virDomainRNGDefPtr def);

3150
int virDomainDiskIndexByAddress(virDomainDefPtr def,
3151
                                virPCIDeviceAddressPtr pci_controller,
3152 3153
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
3154
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
3155
                                           virPCIDeviceAddressPtr pci_controller,
3156 3157 3158
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
3159 3160
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
3161 3162 3163
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
3164 3165 3166 3167
virDomainDiskDefPtr
virDomainDiskByTarget(virDomainDefPtr def,
                      const char *dst);

3168
int virDomainDiskInsert(virDomainDefPtr def,
3169
                        virDomainDiskDefPtr disk)
3170
    G_GNUC_WARN_UNUSED_RESULT;
3171 3172
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
3173 3174
int virDomainStorageNetworkParseHost(xmlNodePtr hostnode,
                                     virStorageNetHostDefPtr host);
3175
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
3176 3177
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
3178

3179 3180 3181 3182
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
3183

3184 3185
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
3186
virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname);
3187
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
3188
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
3189
int virDomainNetUpdate(virDomainDefPtr def, size_t netidx, virDomainNetDefPtr newnet);
3190 3191
int virDomainNetDHCPInterfaces(virDomainDefPtr def, virDomainInterfacePtr **ifaces);
int virDomainNetARPInterfaces(virDomainDefPtr def, virDomainInterfacePtr **ifaces);
3192
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
3193
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
3194

L
Laine Stump 已提交
3195
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
3196 3197
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
3198 3199 3200
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

3201 3202
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
3203 3204
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
3205
            ATTRIBUTE_NONNULL(1);
3206 3207 3208
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
3209

3210
virDomainNetType virDomainNetGetActualType(const virDomainNetDef *iface);
3211 3212 3213 3214
const char *virDomainNetGetActualBridgeName(const virDomainNetDef *iface);
int virDomainNetGetActualBridgeMACTableManager(const virDomainNetDef *iface);
const char *virDomainNetGetActualDirectDev(const virDomainNetDef *iface);
int virDomainNetGetActualDirectMode(const virDomainNetDef *iface);
3215
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
3216
const virNetDevVPortProfile *
3217
virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface);
3218 3219
const virNetDevBandwidth *
virDomainNetGetActualBandwidth(const virDomainNetDef *iface);
3220
const virNetDevVlan *virDomainNetGetActualVlan(const virDomainNetDef *iface);
3221
bool virDomainNetGetActualTrustGuestRxFilters(const virDomainNetDef *iface);
3222 3223 3224
const char *virDomainNetGetModelString(const virDomainNetDef *net);
int virDomainNetSetModelString(virDomainNetDefPtr et,
                               const char *model);
3225
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
3226
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
3227 3228 3229
                                const char *address,
                                int family,
                                unsigned int prefix);
3230

3231
int virDomainControllerInsert(virDomainDefPtr def,
3232
                              virDomainControllerDefPtr controller)
3233
    G_GNUC_WARN_UNUSED_RESULT;
3234 3235
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
3236
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
3237
int virDomainControllerFindByType(virDomainDefPtr def, int type);
3238
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
3239
                                        virPCIDeviceAddressPtr addr);
3240
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
3241
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
3242
const char *virDomainControllerAliasFind(const virDomainDef *def,
3243 3244
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
3245 3246 3247 3248 3249

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
3250
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
3251
    G_GNUC_WARN_UNUSED_RESULT;
3252 3253
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
3254 3255 3256 3257 3258
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
3259

3260
void
3261
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
3262
                          virDomainChrDeviceType type,
3263 3264 3265
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3266 3267 3268
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
3269 3270 3271
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
3272
int
3273 3274 3275 3276 3277
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
3278 3279 3280 3281
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

3282 3283 3284
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

3285 3286 3287 3288
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

3289 3290 3291 3292 3293
int virDomainDefSave(virDomainDefPtr def,
                     virDomainXMLOptionPtr xmlopt,
                     const char *configDir)
    G_GNUC_WARN_UNUSED_RESULT
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
J
John Ferlan 已提交
3294
    ATTRIBUTE_NONNULL(3);
3295 3296 3297 3298 3299 3300

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

3303 3304 3305 3306
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

3307
int virDomainDeleteConfig(const char *configDir,
3308
                          const char *autostartDir,
3309 3310
                          virDomainObjPtr dom);

3311
char *virDomainConfigFile(const char *dir,
3312 3313
                          const char *name);

3314 3315 3316 3317
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

3318
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
3319
                                                  const char *target);
3320
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
3321
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
3322 3323
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

3324
int virDomainVideoDefaultType(const virDomainDef *def);
3325 3326
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
3327

E
Eric Blake 已提交
3328 3329 3330 3331 3332 3333 3334 3335 3336
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3337 3338 3339 3340 3341 3342 3343 3344 3345
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3346 3347 3348 3349 3350 3351 3352
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

J
Jiri Denemark 已提交
3353 3354 3355 3356 3357 3358 3359
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3360 3361 3362
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3363
virSecurityDeviceLabelDefPtr
3364 3365
virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDefPtr def,
                                         const char *model);
3366

3367 3368
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3369

3370
int virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem)
3371
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3372 3373 3374
virDomainMemoryDefPtr virDomainMemoryRemove(virDomainDefPtr def, int idx)
    ATTRIBUTE_NONNULL(1);
int virDomainMemoryFindByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem)
3375
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3376 3377
int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem)
3378
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3379

3380
int virDomainShmemDefInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem)
3381
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3382
bool virDomainShmemDefEquals(virDomainShmemDefPtr src, virDomainShmemDefPtr dst)
3383
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3384
ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem)
3385
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3386 3387
virDomainShmemDefPtr virDomainShmemDefRemove(virDomainDefPtr def, size_t idx)
    ATTRIBUTE_NONNULL(1);
3388 3389
ssize_t virDomainInputDefFind(const virDomainDef *def,
                              const virDomainInputDef *input)
3390
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3391 3392
bool virDomainVsockDefEquals(const virDomainVsockDef *a,
                             const virDomainVsockDef *b)
3393
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3394

3395 3396 3397 3398 3399
VIR_ENUM_DECL(virDomainTaint);
VIR_ENUM_DECL(virDomainVirt);
VIR_ENUM_DECL(virDomainBoot);
VIR_ENUM_DECL(virDomainFeature);
VIR_ENUM_DECL(virDomainCapabilitiesPolicy);
3400
VIR_ENUM_DECL(virDomainProcessCapsFeature);
3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413
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);
3414
VIR_ENUM_DECL(virDomainDiskModel);
3415 3416 3417 3418 3419 3420 3421
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);
3422
VIR_ENUM_DECL(virDomainControllerModelVirtioSerial);
3423 3424 3425 3426
VIR_ENUM_DECL(virDomainFS);
VIR_ENUM_DECL(virDomainFSDriver);
VIR_ENUM_DECL(virDomainFSAccessMode);
VIR_ENUM_DECL(virDomainFSWrpolicy);
3427
VIR_ENUM_DECL(virDomainFSModel);
3428 3429 3430 3431
VIR_ENUM_DECL(virDomainNet);
VIR_ENUM_DECL(virDomainNetBackend);
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
VIR_ENUM_DECL(virDomainNetInterfaceLinkState);
3432
VIR_ENUM_DECL(virDomainNetModel);
3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449
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);
3450
VIR_ENUM_DECL(virDomainVideoBackend);
3451 3452 3453 3454 3455 3456 3457
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);
3458
VIR_ENUM_DECL(virDomainInputModel);
3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471
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);
3472
VIR_ENUM_DECL(virDomainMsrsUnknown);
3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485
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);
3486
/* from libvirt.h */
3487 3488 3489 3490 3491 3492 3493 3494 3495
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 已提交
3496 3497 3498 3499

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

3500 3501 3502
VIR_ENUM_DECL(virDomainSeclabel);
VIR_ENUM_DECL(virDomainClockOffset);
VIR_ENUM_DECL(virDomainClockBasis);
3503

3504 3505 3506 3507 3508
VIR_ENUM_DECL(virDomainTimerName);
VIR_ENUM_DECL(virDomainTimerTrack);
VIR_ENUM_DECL(virDomainTimerTickpolicy);
VIR_ENUM_DECL(virDomainTimerMode);
VIR_ENUM_DECL(virDomainCpuPlacementMode);
3509

3510
VIR_ENUM_DECL(virDomainStartupPolicy);
3511

3512 3513
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3514 3515
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3516 3517 3518 3519 3520
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3521 3522 3523 3524
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3525

3526 3527
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3528 3529
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3530 3531
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3532

3533 3534
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);

3535 3536
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3537 3538 3539 3540 3541
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3542 3543 3544 3545 3546 3547
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virDomainXMLOptionPtr xmlopt,
3548
                            const char *stateDir,
3549 3550 3551
                            const char *configDir,
                            unsigned int flags);

3552 3553 3554 3555 3556 3557 3558 3559
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3560 3561 3562
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3563 3564
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3565
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3566

3567 3568 3569 3570
virStorageSourcePtr
virDomainStorageSourceParseBase(const char *type,
                                const char *format,
                                const char *index)
3571
    G_GNUC_WARN_UNUSED_RESULT;
3572

3573 3574 3575
int virDomainStorageSourceParse(xmlNodePtr node,
                                xmlXPathContextPtr ctxt,
                                virStorageSourcePtr src,
3576 3577
                                unsigned int flags,
                                virDomainXMLOptionPtr xmlopt)
3578 3579
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3580 3581 3582 3583 3584
int
virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
                               virStorageSourcePtr src,
                               unsigned int flags,
                               virDomainXMLOptionPtr xmlopt)
3585
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3586

3587 3588 3589 3590 3591 3592
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
3593
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT;
3594

3595 3596
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

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

3599 3600 3601 3602 3603
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3604

3605 3606 3607
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3608 3609 3610 3611 3612
char *
virDomainGenerateMachineName(const char *drivername,
                             int id,
                             const char *name,
                             bool privileged);
3613 3614 3615

bool
virDomainNetTypeSharesHostView(const virDomainNetDef *net);
3616

3617 3618 3619 3620
bool
virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
                                   virDomainLifecycleAction action);

3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637
// Forward decl to avoid pulling in virnetworkportdef.h because
// that pulls in virhostdev.h which pulls in domain_conf.h (evil)
typedef struct _virNetworkPortDef virNetworkPortDef;
typedef virNetworkPortDef *virNetworkPortDefPtr;

virNetworkPortDefPtr
virDomainNetDefToNetworkPort(virDomainDefPtr dom,
                             virDomainNetDefPtr iface);

int
virDomainNetDefActualFromNetworkPort(virDomainNetDefPtr iface,
                                     virNetworkPortDefPtr port);

virNetworkPortDefPtr
virDomainNetDefActualToNetworkPort(virDomainDefPtr dom,
                                   virDomainNetDefPtr iface);

3638
int
3639 3640
virDomainNetAllocateActualDevice(virConnectPtr conn,
                                 virDomainDefPtr dom,
3641 3642 3643 3644
                                 virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void
3645 3646
virDomainNetNotifyActualDevice(virConnectPtr conn,
                               virDomainDefPtr dom,
3647 3648 3649 3650
                               virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

int
3651 3652
virDomainNetReleaseActualDevice(virConnectPtr conn,
                                virDomainDefPtr dom,
3653 3654 3655
                                virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

3656 3657 3658 3659
int
virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
                            virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3660

3661 3662 3663 3664
int
virDomainNetResolveActualType(virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1);

3665

3666
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
3667

3668 3669 3670
int
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                 virDomainDiskDetectZeroes detect_zeroes);
3671

3672 3673 3674
bool
virDomainDefHasManagedPR(const virDomainDef *def);

3675 3676 3677
bool
virDomainDefHasNVMeDisk(const virDomainDef *def);

3678 3679 3680
bool
virDomainDefHasVFIOHostdev(const virDomainDef *def);

3681 3682 3683
bool
virDomainDefHasMdevHostdev(const virDomainDef *def);

3684 3685 3686 3687 3688 3689
bool
virDomainDefHasOldStyleUEFI(const virDomainDef *def);

bool
virDomainDefHasOldStyleROUEFI(const virDomainDef *def);

3690 3691 3692
bool
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);

3693 3694 3695 3696 3697 3698 3699 3700
bool
virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics);

const char *
virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);

bool
virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);