domain_conf.h 120.0 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 265 266
    char uuidstr[VIR_UUID_STRING_BUFLEN];   /* mediated device's uuid string */
};

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

274
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIHostProtocol);
275

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

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

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

304

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

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

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


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

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

354

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

    VIR_DOMAIN_DISK_DEVICE_LAST
364
} virDomainDiskDevice;
365

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

    VIR_DOMAIN_DISK_BUS_LAST
378
} virDomainDiskBus;
379

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

    VIR_DOMAIN_DISK_CACHE_LAST
389
} virDomainDiskCache;
390

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

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
399
} virDomainDiskErrorPolicy;
400

M
MORITA Kazutaka 已提交
401

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

    VIR_DOMAIN_DISK_TRAY_LAST
407
} virDomainDiskTray;
408

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

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

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

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

435

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

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

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

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

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

461 462 463 464 465 466 467 468 469
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 已提交
470 471 472 473 474 475 476
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;
477 478 479 480 481 482 483
    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;
484
    char *group_name;
485 486 487 488 489 490
    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 已提交
491 492
};

493

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

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

    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;

520

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

525 526
    virObjectPtr privateData;

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

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

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

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

L
Lei Li 已提交
549 550
    virDomainBlockIoTuneInfo blkdeviotune;

551 552
    char *driverName;

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


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

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
592
} virDomainControllerType;
593

594

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

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

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

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

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

640
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
641
} virDomainControllerModelSCSI;
642

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

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

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

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

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

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

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

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

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

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

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

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


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

    VIR_DOMAIN_FS_TYPE_LAST
763
} virDomainFSType;
764

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

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
775
} virDomainFSDriverType;
776

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

    VIR_DOMAIN_FS_ACCESSMODE_LAST
784
} virDomainFSAccessMode;
785

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

    VIR_DOMAIN_FS_WRPOLICY_LAST
792
} virDomainFSWrpolicy;
793

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

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


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

837
    VIR_DOMAIN_NET_TYPE_LAST
838
} virDomainNetType;
839

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

    VIR_DOMAIN_NET_MODEL_LAST
} virDomainNetModelType;

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

873
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
874
} virDomainNetBackendType;
875

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

882
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
883
} virDomainNetVirtioTxModeType;
884

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

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

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

1025 1026 1027 1028 1029 1030 1031 1032
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;

1033
VIR_ENUM_DECL(virDomainChrDeviceState);
1034

1035
typedef enum {
1036
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1037 1038
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1039
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1040

1041
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1042
} virDomainChrDeviceType;
1043

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

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1054
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1055

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

1062
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1063
} virDomainChrChannelTargetType;
1064

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

1076
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1077
} virDomainChrConsoleTargetType;
1078

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

    VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST
} virDomainChrSerialTargetModel;

VIR_ENUM_DECL(virDomainChrSerialTargetModel);

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

1110
    VIR_DOMAIN_CHR_TYPE_LAST
1111
} virDomainChrType;
1112

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

1119
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1120
} virDomainChrTcpProtocol;
1121

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

1127
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1128
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1129

1130 1131 1132 1133 1134 1135 1136

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


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

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1183 1184 1185 1186
};

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

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

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

1200 1201
    virDomainChrDeviceState state;

1202
    virDomainChrSourceDefPtr source;
1203 1204

    virDomainDeviceInfo info;
1205 1206
};

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

1212
    VIR_DOMAIN_SMARTCARD_TYPE_LAST
1213
} virDomainSmartcardType;
E
Eric Blake 已提交
1214

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

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

    virDomainDeviceInfo info;
};

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

1237
typedef enum {
1238
    VIR_DOMAIN_TPM_MODEL_TIS,
1239
    VIR_DOMAIN_TPM_MODEL_CRB,
1240 1241

    VIR_DOMAIN_TPM_MODEL_LAST
1242
} virDomainTPMModel;
1243

1244
typedef enum {
1245
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
1246
    VIR_DOMAIN_TPM_TYPE_EMULATOR,
1247 1248

    VIR_DOMAIN_TPM_TYPE_LAST
1249
} virDomainTPMBackendType;
1250

1251 1252 1253 1254 1255 1256 1257 1258
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;

1259
#define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"
1260 1261

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

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

1286
    VIR_DOMAIN_INPUT_TYPE_LAST
1287
} virDomainInputType;
1288

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

    VIR_DOMAIN_INPUT_BUS_LAST
1297
} virDomainInputBus;
1298

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

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

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

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1325
} virDomainSoundCodecType;
1326

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

    VIR_DOMAIN_SOUND_MODEL_LAST
1337
} virDomainSoundModel;
1338

1339 1340 1341 1342 1343
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1344 1345
struct _virDomainSoundDef {
    int model;
1346
    virDomainDeviceInfo info;
1347

1348
    size_t ncodecs;
1349
    virDomainSoundCodecDefPtr *codecs;
1350 1351
};

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

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1358
} virDomainWatchdogModel;
R
Richard Jones 已提交
1359

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

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1370
} virDomainWatchdogAction;
R
Richard Jones 已提交
1371 1372 1373 1374

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

1378

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

    VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST
} virDomainVideoBackendType;


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

    VIR_DOMAIN_VIDEO_TYPE_LAST
1405
} virDomainVideoType;
1406 1407


1408 1409 1410 1411 1412 1413 1414 1415
typedef enum {
    VIR_DOMAIN_VIDEO_VGACONF_IO = 0,
    VIR_DOMAIN_VIDEO_VGACONF_ON,
    VIR_DOMAIN_VIDEO_VGACONF_OFF,

    VIR_DOMAIN_VIDEO_VGACONF_LAST
} virDomainVideoVGAConf;

1416
VIR_ENUM_DECL(virDomainVideoVGAConf);
1417

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


1425 1426
struct _virDomainVideoDriverDef {
   virDomainVideoVGAConf vgaconf;
1427
    char *vhost_user_binary;
1428 1429
};

1430
struct _virDomainVideoDef {
1431 1432
    virObjectPtr privateData;

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

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

1456
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1457
} virDomainGraphicsType;
1458

1459
typedef enum {
1460 1461 1462 1463 1464 1465
    VIR_DOMAIN_GRAPHICS_VNC_SHARE_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_VNC_SHARE_ALLOW_EXCLUSIVE,
    VIR_DOMAIN_GRAPHICS_VNC_SHARE_FORCE_SHARED,
    VIR_DOMAIN_GRAPHICS_VNC_SHARE_IGNORE,

    VIR_DOMAIN_GRAPHICS_VNC_SHARE_LAST
1466
} virDomainGraphicsVNCSharePolicy;
1467

1468
typedef enum {
1469 1470 1471 1472 1473 1474
    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_DEFAULT = 0,
    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_FAIL,
    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_DISCONNECT,
    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_KEEP,

    VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_LAST
1475
} virDomainGraphicsAuthConnectedType;
1476

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

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

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1495
} virDomainGraphicsSpiceChannelName;
1496

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

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

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

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

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

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

1552
typedef enum {
1553 1554 1555
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1556
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1557

1558
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1559
} virDomainGraphicsListenType;
1560

1561
typedef enum {
M
Marc-André Lureau 已提交
1562 1563
    VIR_DOMAIN_HUB_TYPE_USB,

1564
    VIR_DOMAIN_HUB_TYPE_LAST
1565
} virDomainHubType;
M
Marc-André Lureau 已提交
1566

1567
struct _virDomainGraphicsListenDef {
1568
    virDomainGraphicsListenType type;
1569 1570
    char *address;
    char *network;
1571
    char *socket;
1572
    bool fromConfig;    /* true if the @address is config file originated */
1573
    bool autoGenerated;
1574 1575
};

1576
struct _virDomainGraphicsDef {
1577 1578
    virObjectPtr privateData;

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

1644
typedef enum {
1645 1646 1647
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1648
} virDomainRedirdevBus;
1649 1650 1651 1652

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

1653
    virDomainChrSourceDefPtr source;
1654 1655 1656

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

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

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

1671
typedef enum {
1672 1673
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1674
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1675 1676
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL,
1677 1678

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1679
} virDomainMemballoonModel;
1680 1681 1682 1683

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1684
    int period; /* seconds between collections */
1685
    int autodeflate; /* enum virTristateSwitch */
1686
    virDomainVirtioOptionsPtr virtio;
1687 1688
};

L
Li Zhang 已提交
1689 1690 1691
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1692

1693 1694
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1695 1696
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1697 1698 1699 1700

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

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

1717
typedef enum {
1718
    VIR_DOMAIN_SMBIOS_NONE = 0,
1719 1720 1721 1722 1723
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1724
} virDomainSmbiosMode;
1725

1726

1727
#define VIR_DOMAIN_MAX_BOOT_DEVS 4
1728

1729
typedef enum {
1730 1731 1732 1733 1734
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1735
    VIR_DOMAIN_BOOT_LAST
1736
} virDomainBootOrder;
1737

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

    VIR_DOMAIN_FEATURE_LAST
1762
} virDomainFeature;
1763

1764
#define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12
1765

1766
typedef enum {
1767
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1768 1769
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1770 1771 1772 1773 1774 1775
    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,
1776
    VIR_DOMAIN_HYPERV_FREQUENCIES,
1777
    VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
1778
    VIR_DOMAIN_HYPERV_TLBFLUSH,
1779
    VIR_DOMAIN_HYPERV_IPI,
1780
    VIR_DOMAIN_HYPERV_EVMCS,
1781 1782

    VIR_DOMAIN_HYPERV_LAST
1783
} virDomainHyperv;
1784

1785 1786
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,
1787
    VIR_DOMAIN_KVM_DEDICATED,
1788 1789 1790 1791

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804
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;

1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 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
typedef enum {
    VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT = 0,
    VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW,
    VIR_DOMAIN_CAPABILITIES_POLICY_DENY,

    VIR_DOMAIN_CAPABILITIES_POLICY_LAST
} virDomainCapabilitiesPolicy;

/* The capabilities are ordered alphabetically to help check for new ones */
typedef enum {
    VIR_DOMAIN_CAPS_FEATURE_AUDIT_CONTROL = 0,
    VIR_DOMAIN_CAPS_FEATURE_AUDIT_WRITE,
    VIR_DOMAIN_CAPS_FEATURE_BLOCK_SUSPEND,
    VIR_DOMAIN_CAPS_FEATURE_CHOWN,
    VIR_DOMAIN_CAPS_FEATURE_DAC_OVERRIDE,
    VIR_DOMAIN_CAPS_FEATURE_DAC_READ_SEARCH,
    VIR_DOMAIN_CAPS_FEATURE_FOWNER,
    VIR_DOMAIN_CAPS_FEATURE_FSETID,
    VIR_DOMAIN_CAPS_FEATURE_IPC_LOCK,
    VIR_DOMAIN_CAPS_FEATURE_IPC_OWNER,
    VIR_DOMAIN_CAPS_FEATURE_KILL,
    VIR_DOMAIN_CAPS_FEATURE_LEASE,
    VIR_DOMAIN_CAPS_FEATURE_LINUX_IMMUTABLE,
    VIR_DOMAIN_CAPS_FEATURE_MAC_ADMIN,
    VIR_DOMAIN_CAPS_FEATURE_MAC_OVERRIDE,
    VIR_DOMAIN_CAPS_FEATURE_MKNOD,
    VIR_DOMAIN_CAPS_FEATURE_NET_ADMIN,
    VIR_DOMAIN_CAPS_FEATURE_NET_BIND_SERVICE,
    VIR_DOMAIN_CAPS_FEATURE_NET_BROADCAST,
    VIR_DOMAIN_CAPS_FEATURE_NET_RAW,
    VIR_DOMAIN_CAPS_FEATURE_SETGID,
    VIR_DOMAIN_CAPS_FEATURE_SETFCAP,
    VIR_DOMAIN_CAPS_FEATURE_SETPCAP,
    VIR_DOMAIN_CAPS_FEATURE_SETUID,
    VIR_DOMAIN_CAPS_FEATURE_SYS_ADMIN,
    VIR_DOMAIN_CAPS_FEATURE_SYS_BOOT,
    VIR_DOMAIN_CAPS_FEATURE_SYS_CHROOT,
    VIR_DOMAIN_CAPS_FEATURE_SYS_MODULE,
    VIR_DOMAIN_CAPS_FEATURE_SYS_NICE,
    VIR_DOMAIN_CAPS_FEATURE_SYS_PACCT,
    VIR_DOMAIN_CAPS_FEATURE_SYS_PTRACE,
    VIR_DOMAIN_CAPS_FEATURE_SYS_RAWIO,
    VIR_DOMAIN_CAPS_FEATURE_SYS_RESOURCE,
    VIR_DOMAIN_CAPS_FEATURE_SYS_TIME,
    VIR_DOMAIN_CAPS_FEATURE_SYS_TTY_CONFIG,
    VIR_DOMAIN_CAPS_FEATURE_SYSLOG,
    VIR_DOMAIN_CAPS_FEATURE_WAKE_ALARM,
    VIR_DOMAIN_CAPS_FEATURE_LAST
} virDomainCapsFeature;

1855 1856 1857 1858 1859 1860 1861 1862 1863 1864
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;

1865
VIR_ENUM_DECL(virDomainLockFailure);
1866

M
Michal Privoznik 已提交
1867
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1868
    int useserial; /* enum virTristateBool */
1869 1870 1871
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1872 1873
};

1874
typedef enum {
1875 1876
    VIR_DOMAIN_LOADER_TYPE_NONE = 0,
    VIR_DOMAIN_LOADER_TYPE_ROM,
1877 1878 1879 1880 1881
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

1882
VIR_ENUM_DECL(virDomainLoader);
1883 1884 1885 1886 1887

struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1888
    int secure;     /* enum virTristateBool */
1889
    char *nvram;    /* path to non-volatile RAM */
1890
    char *templt;   /* user override of path to master nvram */
1891 1892 1893 1894
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1895
typedef enum {
1896 1897
    VIR_DOMAIN_IOAPIC_NONE = 0,
    VIR_DOMAIN_IOAPIC_QEMU,
1898 1899 1900 1901 1902 1903 1904
    VIR_DOMAIN_IOAPIC_KVM,

    VIR_DOMAIN_IOAPIC_LAST
} virDomainIOAPIC;

VIR_ENUM_DECL(virDomainIOAPIC);

1905
typedef enum {
1906 1907
    VIR_DOMAIN_HPT_RESIZING_NONE = 0,
    VIR_DOMAIN_HPT_RESIZING_ENABLED,
1908 1909 1910 1911 1912 1913 1914 1915
    VIR_DOMAIN_HPT_RESIZING_DISABLED,
    VIR_DOMAIN_HPT_RESIZING_REQUIRED,

    VIR_DOMAIN_HPT_RESIZING_LAST
} virDomainHPTResizing;

VIR_ENUM_DECL(virDomainHPTResizing);

1916
/* Operating system configuration data & machine / arch */
1917 1918 1919 1920 1921
struct _virDomainOSEnv {
    char *name;
    char *value;
};

1922 1923 1924 1925 1926 1927 1928 1929 1930 1931
typedef enum {
    VIR_DOMAIN_OS_DEF_FIRMWARE_NONE = 0,
    VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS,
    VIR_DOMAIN_OS_DEF_FIRMWARE_EFI,

    VIR_DOMAIN_OS_DEF_FIRMWARE_LAST
} virDomainOsDefFirmware;

VIR_ENUM_DECL(virDomainOsDefFirmware);

1932
struct _virDomainOSDef {
1933
    int type;
1934
    virDomainOsDefFirmware firmware;
1935
    virArch arch;
1936
    char *machine;
1937
    size_t nBootDevs;
1938
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1939
    int bootmenu; /* enum virTristateBool */
1940 1941
    unsigned int bm_timeout;
    bool bm_timeout_set;
1942
    char *init;
1943
    char **initargv;
1944
    virDomainOSEnvPtr *initenv;
1945
    char *initdir;
1946 1947
    char *inituser;
    char *initgroup;
1948 1949 1950
    char *kernel;
    char *initrd;
    char *cmdline;
1951
    char *dtb;
1952
    char *root;
J
Ján Tomko 已提交
1953
    char *slic_table;
1954
    virDomainLoaderDefPtr loader;
1955 1956
    char *bootloader;
    char *bootloaderArgs;
1957
    int smbios_mode;
1958

M
Michal Privoznik 已提交
1959
    virDomainBIOSDef bios;
1960 1961
};

1962
typedef enum {
1963 1964 1965 1966 1967
    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 已提交
1968
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1969
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
1970

1971
    VIR_DOMAIN_TIMER_NAME_LAST
1972
} virDomainTimerNameType;
1973

1974
typedef enum {
1975 1976 1977
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1978

1979
    VIR_DOMAIN_TIMER_TRACK_LAST
1980
} virDomainTimerTrackType;
1981

1982
typedef enum {
1983 1984 1985 1986 1987
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

1988
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
1989
} virDomainTimerTickpolicyType;
1990

1991
typedef enum {
1992 1993 1994 1995
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
1996
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
1997

1998
    VIR_DOMAIN_TIMER_MODE_LAST
1999
} virDomainTimerModeType;
2000

2001
typedef enum {
2002
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
2003 2004
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

2005
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
2006
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
2007

2008
struct _virDomainThreadSchedParam {
2009
    virProcessSchedPolicy policy;
2010 2011 2012
    int priority;
};

2013 2014 2015 2016 2017 2018
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

2019 2020 2021 2022 2023
struct _virDomainTimerDef {
    int name;
    int present;    /* unspecified = -1, no = 0, yes = 1 */
    int tickpolicy; /* none|catchup|merge|discard */

2024 2025 2026 2027
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
2028 2029 2030 2031 2032 2033

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

2034
typedef enum {
2035 2036
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
2037
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
2038
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
2039

2040
    VIR_DOMAIN_CLOCK_OFFSET_LAST
2041
} virDomainClockOffsetType;
2042

2043
typedef enum {
2044 2045 2046
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

2047
    VIR_DOMAIN_CLOCK_BASIS_LAST
2048
} virDomainClockBasis;
2049

2050 2051
struct _virDomainClockDef {
    int offset;
2052

2053
    union {
2054 2055 2056
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
2057
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
2058 2059 2060
        struct {
            long long adjustment;
            int basis;
2061 2062 2063 2064 2065 2066 2067

            /* 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;
2068
        } variable;
2069 2070 2071 2072 2073

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

2075
    size_t ntimers;
2076
    virDomainTimerDefPtr *timers;
2077 2078
};

2079

2080
struct _virBlkioDevice {
2081 2082
    char *path;
    unsigned int weight;
2083 2084 2085 2086
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
2087 2088
};

2089
typedef enum {
2090
    VIR_DOMAIN_RNG_MODEL_VIRTIO,
2091 2092
    VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL,
2093 2094

    VIR_DOMAIN_RNG_MODEL_LAST
2095
} virDomainRNGModel;
2096

2097
typedef enum {
2098 2099 2100 2101
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,

    VIR_DOMAIN_RNG_BACKEND_LAST
2102
} virDomainRNGBackend;
2103 2104 2105 2106

struct _virDomainRNGDef {
    int model;
    int backend;
2107 2108
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
2109 2110 2111 2112 2113 2114 2115 2116

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

    virDomainDeviceInfo info;
2117
    virDomainVirtioOptionsPtr virtio;
2118 2119
};

2120 2121 2122
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2123
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2124 2125 2126 2127 2128

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
2129
    virDomainMemoryAccess access;
2130
    virTristateBool discard;
2131

2132 2133 2134
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2135
    char *nvdimmPath;
2136
    unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
2137
    bool nvdimmPmem; /* valid only for NVDIMM */
2138 2139 2140

    /* target */
    int model; /* virDomainMemoryModel */
2141
    int targetNode;
2142
    unsigned long long size; /* kibibytes */
2143
    unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
2144
    bool readonly; /* valid only for NVDIMM */
2145 2146 2147 2148 2149 2150

    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2166 2167 2168 2169 2170
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2171
    VIR_DOMAIN_PANIC_MODEL_S390,
2172 2173 2174 2175

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2176
struct _virDomainPanicDef {
2177
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2178 2179 2180 2181
    virDomainDeviceInfo info;
};


2182
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2183
                              int ndevices);
2184

2185 2186 2187
struct _virDomainResourceDef {
    char *partition;
};
2188

2189
struct _virDomainHugePage {
2190 2191 2192 2193
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2194
#define VIR_DOMAIN_CPUMASK_LEN 1024
2195

2196 2197 2198
struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2199
    int thread_id;
2200
    virBitmapPtr cpumask;
2201 2202

    virDomainThreadSchedParam sched;
2203 2204 2205 2206
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2207

2208
struct _virDomainCputune {
2209
    unsigned long long shares;
2210 2211 2212
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2213
    unsigned long long global_period;
2214
    long long global_quota;
2215 2216
    unsigned long long emulator_period;
    long long emulator_quota;
2217 2218
    unsigned long long iothread_period;
    long long iothread_quota;
2219
    virBitmapPtr emulatorpin;
2220
    virDomainThreadSchedParamPtr emulatorsched;
2221 2222
};

2223

2224 2225 2226 2227 2228 2229
struct _virDomainResctrlMonDef {
    virBitmapPtr vcpus;
    virResctrlMonitorType tag;
    virResctrlMonitorPtr instance;
};

B
Bing Niu 已提交
2230
struct _virDomainResctrlDef {
2231 2232
    virBitmapPtr vcpus;
    virResctrlAllocPtr alloc;
2233 2234 2235

    virDomainResctrlMonDefPtr *monitors;
    size_t nmonitors;
2236 2237 2238
};


2239
struct _virDomainVcpuDef {
2240
    bool online;
2241 2242 2243
    virTristateBool hotpluggable;
    unsigned int order;

2244
    virBitmapPtr cpumask;
2245 2246

    virDomainThreadSchedParam sched;
2247 2248

    virObjectPtr privateData;
2249 2250
};

2251 2252 2253 2254 2255 2256 2257 2258
struct _virDomainBlkiotune {
    unsigned int weight;

    size_t ndevices;
    virBlkioDevicePtr devices;
};

struct _virDomainMemtune {
2259 2260 2261
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2262 2263
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2264 2265 2266 2267

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2268 2269 2270 2271
    /* 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 */

2272 2273 2274
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2275 2276 2277 2278
    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 */
2279 2280 2281 2282

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2283 2284

    virTristateBool discard;
2285 2286 2287 2288 2289 2290 2291 2292
};

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

Q
Qiaowei Ren 已提交
2293 2294 2295 2296 2297
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2298 2299 2300 2301 2302
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

2303 2304 2305 2306 2307 2308 2309 2310
typedef enum {
    VIR_DOMAIN_LAUNCH_SECURITY_NONE,
    VIR_DOMAIN_LAUNCH_SECURITY_SEV,

    VIR_DOMAIN_LAUNCH_SECURITY_LAST,
} virDomainLaunchSecurity;


2311
struct _virDomainSEVDef {
2312 2313 2314 2315 2316 2317 2318 2319 2320
    int sectype; /* enum virDomainLaunchSecurity */
    char *dh_cert;
    char *session;
    unsigned int policy;
    unsigned int cbitpos;
    unsigned int reduced_phys_bits;
};


J
Ján Tomko 已提交
2321 2322
typedef enum {
    VIR_DOMAIN_IOMMU_MODEL_INTEL,
2323
    VIR_DOMAIN_IOMMU_MODEL_SMMUV3,
J
Ján Tomko 已提交
2324 2325 2326 2327 2328 2329

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

struct _virDomainIOMMUDef {
    virDomainIOMMUModel model;
2330
    virTristateSwitch intremap;
2331
    virTristateSwitch caching_mode;
2332
    virTristateSwitch eim;
J
Ján Tomko 已提交
2333
    virTristateSwitch iotlb;
J
Ján Tomko 已提交
2334
};
2335

J
Ján Tomko 已提交
2336 2337 2338
typedef enum {
    VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO,
2339 2340
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL,
    VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL,
J
Ján Tomko 已提交
2341 2342 2343 2344

    VIR_DOMAIN_VSOCK_MODEL_LAST
} virDomainVsockModel;

J
Ján Tomko 已提交
2345
struct _virDomainVsockDef {
2346
    virObjectPtr privateData;
J
Ján Tomko 已提交
2347 2348 2349 2350 2351 2352

    virDomainVsockModel model;
    unsigned int guest_cid;
    virTristateBool auto_cid;

    virDomainDeviceInfo info;
J
Ján Tomko 已提交
2353 2354
};

2355 2356 2357 2358 2359
struct _virDomainVirtioOptions {
    virTristateSwitch iommu;
    virTristateSwitch ats;
};

2360 2361 2362 2363 2364 2365
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
2366
struct _virDomainDef {
2367
    int virtType; /* enum virDomainVirtType */
2368 2369
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
2370 2371 2372 2373 2374

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

2375
    char *name;
2376
    char *title;
2377
    char *description;
2378

2379 2380
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2381

2382
    virDomainVcpuDefPtr *vcpus;
2383
    size_t maxvcpus;
2384 2385
    /* set if the vcpu definition was specified individually */
    bool individualvcpus;
O
Osier Yang 已提交
2386
    int placement_mode;
H
Hu Tao 已提交
2387
    virBitmapPtr cpumask;
2388

2389 2390
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2391

2392
    virDomainCputune cputune;
2393

B
Bing Niu 已提交
2394 2395
    virDomainResctrlDefPtr *resctrls;
    size_t nresctrls;
2396

2397
    virDomainNumaPtr numa;
2398
    virDomainResourceDefPtr resource;
2399
    virDomainIdMapDef idmap;
2400

2401 2402 2403 2404 2405
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2406 2407
    int onLockFailure; /* enum virDomainLockFailureAction */

2408
    virDomainPowerManagement pm;
2409

2410
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2411

2412 2413
    virDomainOSDef os;
    char *emulator;
2414 2415 2416
    /* 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. */
2417
    int features[VIR_DOMAIN_FEATURE_LAST];
2418
    int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];
2419
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2420
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2421
    int msrs_features[VIR_DOMAIN_MSRS_LAST];
2422
    unsigned int hyperv_spinlocks;
2423
    int hyperv_stimer_direct;
2424
    virGICVersion gic_version;
2425
    virDomainHPTResizing hpt_resizing;
2426
    unsigned long long hpt_maxpagesize; /* Stored in KiB */
2427
    char *hyperv_vendor_id;
2428
    int apic_eoi;
2429

2430 2431 2432
    bool tseg_specified;
    unsigned long long tseg_size;

2433
    virDomainClockDef clock;
2434

2435
    size_t ngraphics;
2436
    virDomainGraphicsDefPtr *graphics;
2437

2438
    size_t ndisks;
2439 2440
    virDomainDiskDefPtr *disks;

2441
    size_t ncontrollers;
2442 2443
    virDomainControllerDefPtr *controllers;

2444
    size_t nfss;
2445 2446
    virDomainFSDefPtr *fss;

2447
    size_t nnets;
2448 2449
    virDomainNetDefPtr *nets;

2450
    size_t ninputs;
2451 2452
    virDomainInputDefPtr *inputs;

2453
    size_t nsounds;
2454 2455
    virDomainSoundDefPtr *sounds;

2456
    size_t nvideos;
2457 2458
    virDomainVideoDefPtr *videos;

2459
    size_t nhostdevs;
2460 2461
    virDomainHostdevDefPtr *hostdevs;

2462
    size_t nredirdevs;
2463 2464
    virDomainRedirdevDefPtr *redirdevs;

2465
    size_t nsmartcards;
E
Eric Blake 已提交
2466 2467
    virDomainSmartcardDefPtr *smartcards;

2468
    size_t nserials;
2469 2470
    virDomainChrDefPtr *serials;

2471
    size_t nparallels;
2472 2473
    virDomainChrDefPtr *parallels;

2474
    size_t nchannels;
2475 2476
    virDomainChrDefPtr *channels;

2477
    size_t nconsoles;
2478 2479
    virDomainChrDefPtr *consoles;

2480
    size_t nleases;
2481 2482
    virDomainLeaseDefPtr *leases;

2483
    size_t nhubs;
M
Marc-André Lureau 已提交
2484 2485
    virDomainHubDefPtr *hubs;

2486 2487 2488
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2489 2490 2491
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2492 2493 2494
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2495 2496 2497
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2498 2499 2500
    size_t npanics;
    virDomainPanicDefPtr *panics;

2501
    /* Only 1 */
R
Richard Jones 已提交
2502
    virDomainWatchdogDefPtr watchdog;
2503
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2504
    virDomainNVRAMDefPtr nvram;
2505
    virDomainTPMDefPtr tpm;
2506
    virCPUDefPtr cpu;
2507
    virSysinfoDefPtr sysinfo;
2508
    virDomainRedirFilterDefPtr redirfilter;
J
Ján Tomko 已提交
2509
    virDomainIOMMUDefPtr iommu;
J
Ján Tomko 已提交
2510
    virDomainVsockDefPtr vsock;
2511 2512

    void *namespaceData;
2513
    virXMLNamespace ns;
2514

2515 2516
    virDomainKeyWrapDefPtr keywrap;

2517
    /* SEV-specific domain */
2518
    virDomainSEVDefPtr sev;
2519

2520 2521
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2522 2523 2524 2525 2526 2527

    /* 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 */
2528 2529
};

2530

2531
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2532
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2533
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2534
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2535

2536 2537 2538 2539 2540 2541 2542
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

2543
typedef enum {
2544 2545 2546 2547 2548
    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 */
2549
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2550
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2551
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2552
    VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,/* CDROM passthrough */
Y
Yuri Chornoivan 已提交
2553
    VIR_DOMAIN_TAINT_CUSTOM_DTB,       /* Custom device tree blob was specified */
2554
    VIR_DOMAIN_TAINT_CUSTOM_GA_COMMAND, /* Custom guest agent command */
2555
    VIR_DOMAIN_TAINT_CUSTOM_HYPERVISOR_FEATURE, /* custom hypervisor feature control */
2556 2557

    VIR_DOMAIN_TAINT_LAST
2558
} virDomainTaintFlags;
2559

2560
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2561 2562 2563 2564 2565 2566
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2567
struct _virDomainObj {
2568
    virObjectLockable parent;
2569
    virCond cond;
2570

2571
    pid_t pid;
J
Jiri Denemark 已提交
2572
    virDomainStateReason state;
2573 2574 2575

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2576
    unsigned int updated : 1;
2577
    unsigned int removing : 1;
2578 2579 2580

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

2582
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2583

2584 2585
    bool hasManagedSave;

2586 2587
    virDomainCheckpointObjListPtr checkpoints;

2588 2589
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2590 2591

    int taint;
2592 2593 2594

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

2597 2598 2599
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainObj, virObjectUnref);


2600 2601
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2602

2603

2604 2605
/* NB: Any new flag to this list be considered to be set in
 * virt-aa-helper code if the flag prevents parsing. */
2606 2607
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2608
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2609
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2610
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2611
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2612
    VIR_DOMAIN_DEF_FEATURE_USER_ALIAS = (1 << 5),
2613
    VIR_DOMAIN_DEF_FEATURE_NO_BOOT_ORDER = (1 << 6),
2614
    VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT = (1 << 7),
2615
    VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING = (1 << 8),
2616 2617 2618
} virDomainDefFeatures;


2619 2620 2621 2622 2623 2624 2625 2626
/* Called after everything else has been parsed, for adjusting basics.
 * This has similar semantics to virDomainDefPostParseCallback, but no
 * parseOpaque is used. This callback is run prior to
 * virDomainDefPostParseCallback. */
typedef int (*virDomainDefPostParseBasicCallback)(virDomainDefPtr def,
                                                  virCapsPtr caps,
                                                  void *opaque);

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

2662 2663 2664 2665 2666 2667 2668
typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def,
                                              virCapsPtr caps,
                                              unsigned int parseFlags,
                                              void *opaque,
                                              void **parseOpaque);
typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque);

2669 2670 2671 2672 2673 2674
/* Called in appropriate places where the domain conf parser can return failure
 * for configurations that were previously accepted. This shall not modify the
 * config. */
typedef int (*virDomainDefValidateCallback)(const virDomainDef *def,
                                            virCapsPtr caps,
                                            void *opaque);
2675

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

2682
struct _virDomainDefParserConfig {
2683
    /* driver domain definition callbacks */
2684
    virDomainDefPostParseBasicCallback domainPostParseBasicCallback;
2685
    virDomainDefPostParseDataAlloc domainPostParseDataAlloc;
2686 2687
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2688
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2689
    virDomainDefPostParseDataFree domainPostParseDataFree;
2690

2691 2692
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2693
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2694

2695
    /* private data for the callbacks */
2696 2697
    void *priv;
    virFreeCallback privFree;
2698 2699

    /* data */
2700
    unsigned int features; /* virDomainDefFeatures */
2701
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2702 2703
};

2704
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *);
2705 2706 2707 2708 2709 2710 2711 2712
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
                                                 virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                virDomainObjPtr,
                                                virDomainDefParserConfigPtr);

2713 2714
typedef void *(*virDomainXMLPrivateDataGetParseOpaqueFunc)(virDomainObjPtr vm);

2715 2716 2717 2718 2719
typedef int (*virDomainXMLPrivateDataDiskParseFunc)(xmlXPathContextPtr ctxt,
                                                    virDomainDiskDefPtr disk);
typedef int (*virDomainXMLPrivateDataDiskFormatFunc)(virDomainDiskDefPtr disk,
                                                     virBufferPtr buf);

2720 2721 2722 2723 2724 2725
typedef int (*virDomainXMLPrivateDataStorageSourceParseFunc)(xmlXPathContextPtr ctxt,
                                                             virStorageSourcePtr src);
typedef int (*virDomainXMLPrivateDataStorageSourceFormatFunc)(virStorageSourcePtr src,
                                                              virBufferPtr buf);


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

2749 2750 2751 2752 2753 2754 2755
typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src,
                                            const virDomainDef *dst);

struct _virDomainABIStability {
    virDomainABIStabilityDomain domain;
};

2756 2757
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
2758
                                            virXMLNamespacePtr xmlns,
2759 2760 2761 2762 2763
                                            virDomainABIStabilityPtr abi,
                                            virSaveCookieCallbacksPtr saveCookie);

virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt);
2764

2765 2766 2767 2768 2769 2770 2771
typedef int (*virDomainMomentPostParseCallback)(virDomainMomentDefPtr def);

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

2772 2773
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2774
virXMLNamespacePtr
2775
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2776 2777
    ATTRIBUTE_NONNULL(1);

2778 2779 2780 2781
bool
virDomainSCSIDriveAddressIsUsed(const virDomainDef *def,
                                const virDomainDeviceDriveAddress *addr);

2782 2783 2784 2785 2786
int virDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2787
bool virDomainDefHasUSB(const virDomainDef *def);
2788

2789 2790 2791 2792
int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
                                           virDomainDeviceDefPtr dev,
                                           unsigned int flags);

2793 2794
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);

2795
int virDomainDefValidate(virDomainDefPtr def,
2796 2797 2798 2799
                         virCapsPtr caps,
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2800
static inline bool
D
Daniel P. Berrange 已提交
2801
virDomainObjIsActive(virDomainObjPtr dom)
2802 2803 2804 2805
{
    return dom->def->id != -1;
}

2806 2807
int virDomainObjCheckActive(virDomainObjPtr dom);

2808 2809 2810 2811 2812 2813 2814 2815 2816
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)
2817
    G_GNUC_WARN_UNUSED_RESULT;
2818
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2819 2820
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2821

2822
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2823
    ATTRIBUTE_NONNULL(1);
2824

M
Michal Privoznik 已提交
2825 2826
void virDomainObjEndAPI(virDomainObjPtr *vm);

2827
bool virDomainObjTaint(virDomainObjPtr obj,
2828
                       virDomainTaintFlags taint);
2829

2830 2831 2832 2833
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2834

H
Hu Tao 已提交
2835
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2836
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2837
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
J
Ján Tomko 已提交
2838
const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
2839
void virDomainInputDefFree(virDomainInputDefPtr def);
2840
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2841
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2842
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2843 2844
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2845
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2846
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
2847
    G_GNUC_WARN_UNUSED_RESULT;
2848
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
2849
const char *virDomainDiskGetDriver(const virDomainDiskDef *def);
2850
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
2851
    G_GNUC_WARN_UNUSED_RESULT;
2852 2853
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2854 2855 2856
virDomainControllerDefPtr
virDomainDeviceFindSCSIController(const virDomainDef *def,
                                  virDomainDeviceInfoPtr info);
2857 2858 2859
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2860 2861

virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type);
2862
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2863
bool virDomainControllerIsPSeriesPHB(const virDomainControllerDef *cont);
2864

2865
virDomainFSDefPtr virDomainFSDefNew(void);
2866
void virDomainFSDefFree(virDomainFSDefPtr def);
2867
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
J
Ján Tomko 已提交
2868 2869
virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt);
void virDomainVsockDefFree(virDomainVsockDefPtr vsock);
2870
void virDomainNetDefClear(virDomainNetDefPtr def);
2871
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2872
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2873
void virDomainChrDefFree(virDomainChrDefPtr def);
2874 2875
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
                              virDomainChrSourceDefPtr src);
2876
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
2877
void virDomainSoundDefFree(virDomainSoundDefPtr def);
2878
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2879
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2880
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
2881
virDomainVideoDefPtr virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt);
2882
void virDomainVideoDefFree(virDomainVideoDefPtr def);
2883
void virDomainVideoDefClear(virDomainVideoDefPtr def);
J
John Ferlan 已提交
2884
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
2885
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2886
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2887
void virDomainHubDefFree(virDomainHubDefPtr def);
2888
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2889
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2890
void virDomainShmemDefFree(virDomainShmemDefPtr def);
2891
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2892
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2893
                                             const virDomainDef *def,
2894
                                             virCapsPtr caps,
2895 2896
                                             virDomainXMLOptionPtr xmlopt,
                                             void *parseOpaque);
2897
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
C
Cole Robinson 已提交
2898 2899
void virDomainDeviceSetData(virDomainDeviceDefPtr device,
                            void *devicedata);
2900
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2901

2902
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2903 2904
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2905 2906 2907 2908 2909 2910
                                           void *opaque);

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

2911 2912
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
2913
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
2914

2915
void virDomainDefFree(virDomainDefPtr vm);
2916
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainDef, virDomainDefFree);
2917

2918 2919 2920
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);

2921
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
2922

2923 2924
virDomainGraphicsDefPtr
virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt);
2925 2926 2927 2928

virDomainNetDefPtr
virDomainNetDefNew(virDomainXMLOptionPtr xmlopt);

2929
virDomainDefPtr virDomainDefNew(void);
2930

2931
void virDomainObjAssignDef(virDomainObjPtr domain,
2932
                           virDomainDefPtr def,
2933 2934
                           bool live,
                           virDomainDefPtr *oldDef);
2935
int virDomainObjSetDefTransient(virCapsPtr caps,
2936
                                virDomainXMLOptionPtr xmlopt,
2937 2938
                                virDomainObjPtr domain,
                                void *parseOpaque);
2939
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
2940 2941
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
2942
                             virDomainXMLOptionPtr xmlopt,
2943 2944
                             virDomainObjPtr domain,
                             void *parseOpaque);
2945 2946 2947 2948 2949 2950 2951 2952

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

int virDomainObjGetDefs(virDomainObjPtr vm,
                        unsigned int flags,
                        virDomainDefPtr *liveDef,
                        virDomainDefPtr *persDef);
2953 2954 2955
virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                           unsigned int flags,
                                           bool *state);
2956
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
2957

2958 2959 2960
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virCapsPtr caps,
                                 virDomainXMLOptionPtr xmlopt,
2961
                                 void *parseOpaque,
2962 2963 2964
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                              virCapsPtr caps,
2965 2966
                                              virDomainXMLOptionPtr xmlopt,
                                              void *parseOpaque);
2967

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

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
3008
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 2,
3009
    /* format internal domain status information */
3010
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 3,
3011
    /* format <actual> element */
3012
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 4,
3013
    /* format original states of host PCI device */
3014 3015 3016 3017
    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,
3018 3019
} virDomainDefFormatFlags;

3020 3021 3022 3023 3024 3025 3026 3027 3028
/* 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;

3029
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
3030
                                              const virDomainDef *def,
3031 3032
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt,
3033
                                              void *parseOpaque,
L
Laine Stump 已提交
3034
                                              unsigned int flags);
3035 3036 3037 3038
virDomainDiskDefPtr virDomainDiskDefParse(const char *xmlStr,
                                          const virDomainDef *def,
                                          virDomainXMLOptionPtr xmlopt,
                                          unsigned int flags);
3039 3040
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                        virCapsPtr caps,
3041
                                        virDomainXMLOptionPtr xmlopt,
3042
                                        void *parseOpaque,
L
Laine Stump 已提交
3043
                                        unsigned int flags);
3044 3045
virDomainDefPtr virDomainDefParseFile(const char *filename,
                                      virCapsPtr caps,
3046
                                      virDomainXMLOptionPtr xmlopt,
3047
                                      void *parseOpaque,
L
Laine Stump 已提交
3048
                                      unsigned int flags);
3049
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
3050
                                      xmlNodePtr root,
3051 3052
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
3053
                                      void *parseOpaque,
L
Laine Stump 已提交
3054
                                      unsigned int flags);
3055 3056 3057 3058 3059
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
3060 3061 3062 3063
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virCapsPtr caps,
                                      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
                         virCapsPtr caps,
L
Laine Stump 已提交
3096
                         unsigned int flags);
3097 3098
char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
                         virDomainObjPtr obj,
3099
                         virCapsPtr caps,
3100
                         unsigned int flags);
3101
int virDomainDefFormatInternal(virDomainDefPtr def,
3102
                               virCapsPtr caps,
3103
                               unsigned int flags,
3104 3105
                               virBufferPtr buf,
                               virDomainXMLOptionPtr xmlopt);
3106 3107 3108 3109 3110 3111
int virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
                                          virCapsPtr caps,
                                          unsigned int flags,
                                          virBufferPtr buf,
                                          virDomainXMLOptionPtr xmlopt,
                                          const char *rootname);
3112

3113 3114
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
3115
                              const char *element,
3116
                              int policy,
3117
                              bool attrIndex,
3118 3119
                              unsigned int flags,
                              virDomainXMLOptionPtr xmlopt);
3120

3121 3122 3123 3124 3125 3126
int
virDomainDiskBackingStoreFormat(virBufferPtr buf,
                                virStorageSourcePtr src,
                                virDomainXMLOptionPtr xmlopt,
                                unsigned int flags);

3127 3128
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
3129
                          char *prefix,
3130 3131
                          unsigned int flags);

3132 3133 3134 3135 3136 3137
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

3138
int virDomainDefCompatibleDevice(virDomainDefPtr def,
3139
                                 virDomainDeviceDefPtr dev,
3140
                                 virDomainDeviceDefPtr oldDev,
3141 3142
                                 virDomainDeviceAction action,
                                 bool live);
3143

3144 3145
void virDomainRNGDefFree(virDomainRNGDefPtr def);

3146
int virDomainDiskIndexByAddress(virDomainDefPtr def,
3147
                                virPCIDeviceAddressPtr pci_controller,
3148 3149
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
3150
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
3151
                                           virPCIDeviceAddressPtr pci_controller,
3152 3153 3154
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
3155 3156
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
3157 3158 3159
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
3160
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
3161
int virDomainDiskInsert(virDomainDefPtr def,
3162
                        virDomainDiskDefPtr disk)
3163
    G_GNUC_WARN_UNUSED_RESULT;
3164 3165
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
3166 3167
int virDomainStorageNetworkParseHost(xmlNodePtr hostnode,
                                     virStorageNetHostDefPtr host);
3168
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
3169 3170
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
3171

3172 3173 3174 3175
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
3176

3177 3178
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
3179
virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname);
3180
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
3181
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
3182
int virDomainNetUpdate(virDomainDefPtr def, size_t netidx, virDomainNetDefPtr newnet);
3183
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
3184
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
3185

L
Laine Stump 已提交
3186
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
3187 3188
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
3189 3190 3191
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

3192 3193
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
3194 3195
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
3196
            ATTRIBUTE_NONNULL(1);
3197 3198 3199
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
3200

3201
virDomainNetType virDomainNetGetActualType(const virDomainNetDef *iface);
3202
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
3203
int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
3204
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
3205
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
3206
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
3207
virNetDevVPortProfilePtr
3208
virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface);
3209
virNetDevBandwidthPtr
3210
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
3211
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
3212
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
3213 3214 3215
const char *virDomainNetGetModelString(const virDomainNetDef *net);
int virDomainNetSetModelString(virDomainNetDefPtr et,
                               const char *model);
3216
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
3217
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
3218 3219 3220
                                const char *address,
                                int family,
                                unsigned int prefix);
3221

3222
int virDomainControllerInsert(virDomainDefPtr def,
3223
                              virDomainControllerDefPtr controller)
3224
    G_GNUC_WARN_UNUSED_RESULT;
3225 3226
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
3227
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
3228
int virDomainControllerFindByType(virDomainDefPtr def, int type);
3229
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
3230
                                        virPCIDeviceAddressPtr addr);
3231
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
3232
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
3233
const char *virDomainControllerAliasFind(const virDomainDef *def,
3234 3235
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
3236 3237 3238 3239 3240

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
3241
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
3242
    G_GNUC_WARN_UNUSED_RESULT;
3243 3244
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
3245 3246 3247 3248 3249
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
3250

3251
void
3252
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
3253
                          virDomainChrDeviceType type,
3254 3255 3256
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
3257 3258 3259
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
3260 3261 3262
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
3263
int
3264 3265 3266 3267 3268
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
3269 3270 3271 3272
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

3273 3274 3275
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

3276 3277 3278 3279
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

3280
int virDomainSaveXML(const char *configDir,
3281 3282 3283
                     virDomainDefPtr def,
                     const char *xml);

3284
int virDomainSaveConfig(const char *configDir,
3285
                        virCapsPtr caps,
3286
                        virDomainDefPtr def);
3287
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
3288
                        const char *statusDir,
3289
                        virDomainObjPtr obj,
3290
                        virCapsPtr caps) G_GNUC_WARN_UNUSED_RESULT;
3291

3292 3293 3294 3295
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

3296
int virDomainDeleteConfig(const char *configDir,
3297
                          const char *autostartDir,
3298 3299
                          virDomainObjPtr dom);

3300
char *virDomainConfigFile(const char *dir,
3301 3302
                          const char *name);

3303 3304 3305 3306
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

3307
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
3308
                                                  const char *target);
3309
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
3310
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
3311 3312
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

3313
int virDomainVideoDefaultType(const virDomainDef *def);
3314 3315
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
3316

E
Eric Blake 已提交
3317 3318 3319 3320 3321 3322 3323 3324 3325
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3326 3327 3328 3329 3330 3331 3332 3333 3334
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3335 3336 3337 3338 3339 3340 3341
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

J
Jiri Denemark 已提交
3342 3343 3344 3345 3346 3347 3348
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3349 3350 3351
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3352
virSecurityDeviceLabelDefPtr
3353 3354
virDomainChrSourceDefGetSecurityLabelDef(virDomainChrSourceDefPtr def,
                                         const char *model);
3355

3356 3357
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3358

3359
int virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem)
3360
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3361 3362 3363
virDomainMemoryDefPtr virDomainMemoryRemove(virDomainDefPtr def, int idx)
    ATTRIBUTE_NONNULL(1);
int virDomainMemoryFindByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem)
3364
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3365 3366
int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem)
3367
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3368

3369
int virDomainShmemDefInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem)
3370
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3371
bool virDomainShmemDefEquals(virDomainShmemDefPtr src, virDomainShmemDefPtr dst)
3372
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3373
ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem)
3374
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3375 3376
virDomainShmemDefPtr virDomainShmemDefRemove(virDomainDefPtr def, size_t idx)
    ATTRIBUTE_NONNULL(1);
3377 3378
ssize_t virDomainInputDefFind(const virDomainDef *def,
                              const virDomainInputDef *input)
3379
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3380 3381
bool virDomainVsockDefEquals(const virDomainVsockDef *a,
                             const virDomainVsockDef *b)
3382
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3383

3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402
VIR_ENUM_DECL(virDomainTaint);
VIR_ENUM_DECL(virDomainVirt);
VIR_ENUM_DECL(virDomainBoot);
VIR_ENUM_DECL(virDomainFeature);
VIR_ENUM_DECL(virDomainCapabilitiesPolicy);
VIR_ENUM_DECL(virDomainCapsFeature);
VIR_ENUM_DECL(virDomainLifecycle);
VIR_ENUM_DECL(virDomainLifecycleAction);
VIR_ENUM_DECL(virDomainDevice);
VIR_ENUM_DECL(virDomainDiskDevice);
VIR_ENUM_DECL(virDomainDiskGeometryTrans);
VIR_ENUM_DECL(virDomainDiskBus);
VIR_ENUM_DECL(virDomainDiskCache);
VIR_ENUM_DECL(virDomainDiskErrorPolicy);
VIR_ENUM_DECL(virDomainDiskIo);
VIR_ENUM_DECL(virDomainDeviceSGIO);
VIR_ENUM_DECL(virDomainDiskTray);
VIR_ENUM_DECL(virDomainDiskDiscard);
VIR_ENUM_DECL(virDomainDiskDetectZeroes);
3403
VIR_ENUM_DECL(virDomainDiskModel);
3404 3405 3406 3407 3408 3409 3410
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);
3411
VIR_ENUM_DECL(virDomainControllerModelVirtioSerial);
3412 3413 3414 3415
VIR_ENUM_DECL(virDomainFS);
VIR_ENUM_DECL(virDomainFSDriver);
VIR_ENUM_DECL(virDomainFSAccessMode);
VIR_ENUM_DECL(virDomainFSWrpolicy);
3416
VIR_ENUM_DECL(virDomainFSModel);
3417 3418 3419 3420
VIR_ENUM_DECL(virDomainNet);
VIR_ENUM_DECL(virDomainNetBackend);
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
VIR_ENUM_DECL(virDomainNetInterfaceLinkState);
3421
VIR_ENUM_DECL(virDomainNetModel);
3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438
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);
3439
VIR_ENUM_DECL(virDomainVideoBackend);
3440 3441 3442 3443 3444 3445 3446
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);
3447
VIR_ENUM_DECL(virDomainInputModel);
3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460
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);
3461
VIR_ENUM_DECL(virDomainMsrsUnknown);
3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474
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);
3475
/* from libvirt.h */
3476 3477 3478 3479 3480 3481 3482 3483 3484
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 已提交
3485 3486 3487 3488

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

3489 3490 3491
VIR_ENUM_DECL(virDomainSeclabel);
VIR_ENUM_DECL(virDomainClockOffset);
VIR_ENUM_DECL(virDomainClockBasis);
3492

3493 3494 3495 3496 3497
VIR_ENUM_DECL(virDomainTimerName);
VIR_ENUM_DECL(virDomainTimerTrack);
VIR_ENUM_DECL(virDomainTimerTickpolicy);
VIR_ENUM_DECL(virDomainTimerMode);
VIR_ENUM_DECL(virDomainCpuPlacementMode);
3498

3499
VIR_ENUM_DECL(virDomainStartupPolicy);
3500

3501 3502
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3503 3504
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3505 3506 3507 3508 3509
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3510 3511 3512 3513
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3514

3515 3516
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3517 3518
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3519 3520
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3521

3522 3523
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);

3524 3525
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3526 3527 3528 3529 3530
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3531 3532 3533 3534 3535 3536 3537
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
3538
                            const char *stateDir,
3539 3540 3541
                            const char *configDir,
                            unsigned int flags);

3542 3543 3544 3545 3546 3547 3548 3549
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3550 3551 3552
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3553 3554
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3555
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3556

3557 3558 3559 3560
virStorageSourcePtr
virDomainStorageSourceParseBase(const char *type,
                                const char *format,
                                const char *index)
3561
    G_GNUC_WARN_UNUSED_RESULT;
3562

3563 3564 3565
int virDomainStorageSourceParse(xmlNodePtr node,
                                xmlXPathContextPtr ctxt,
                                virStorageSourcePtr src,
3566 3567
                                unsigned int flags,
                                virDomainXMLOptionPtr xmlopt)
3568 3569
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

3570 3571 3572 3573 3574
int
virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
                               virStorageSourcePtr src,
                               unsigned int flags,
                               virDomainXMLOptionPtr xmlopt)
3575
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
3576

3577 3578 3579 3580 3581 3582
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
3583
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) G_GNUC_WARN_UNUSED_RESULT;
3584

3585 3586
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

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

3589 3590 3591 3592 3593
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3594

3595 3596 3597
int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3598 3599 3600 3601 3602
char *
virDomainGenerateMachineName(const char *drivername,
                             int id,
                             const char *name,
                             bool privileged);
3603 3604 3605

bool
virDomainNetTypeSharesHostView(const virDomainNetDef *net);
3606

3607 3608 3609 3610
bool
virDomainDefLifecycleActionAllowed(virDomainLifecycle type,
                                   virDomainLifecycleAction action);

3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627
// 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);

3628
int
3629 3630
virDomainNetAllocateActualDevice(virConnectPtr conn,
                                 virDomainDefPtr dom,
3631 3632 3633 3634
                                 virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void
3635 3636
virDomainNetNotifyActualDevice(virConnectPtr conn,
                               virDomainDefPtr dom,
3637 3638 3639 3640
                               virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

int
3641 3642
virDomainNetReleaseActualDevice(virConnectPtr conn,
                                virDomainDefPtr dom,
3643 3644 3645
                                virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

3646 3647 3648 3649
int
virDomainNetBandwidthUpdate(virDomainNetDefPtr iface,
                            virNetDevBandwidthPtr newBandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3650

3651 3652 3653 3654
int
virDomainNetResolveActualType(virDomainNetDefPtr iface)
    ATTRIBUTE_NONNULL(1);

3655

3656
int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
3657

3658 3659 3660
int
virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                 virDomainDiskDetectZeroes detect_zeroes);
3661

3662 3663 3664
bool
virDomainDefHasManagedPR(const virDomainDef *def);

3665 3666 3667
bool
virDomainDefHasVFIOHostdev(const virDomainDef *def);

3668 3669 3670
bool
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);

3671 3672 3673 3674 3675 3676 3677 3678
bool
virDomainGraphicsSupportsRenderNode(const virDomainGraphicsDef *graphics);

const char *
virDomainGraphicsGetRenderNode(const virDomainGraphicsDef *graphics);

bool
virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics);