domain_conf.h 106.6 KB
Newer Older
1 2 3
/*
 * domain_conf.h: domain XML processing
 *
4
 * Copyright (C) 2006-2016 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
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __DOMAIN_CONF_H
26
# define __DOMAIN_CONF_H
27

28 29 30
# include <libxml/parser.h>
# include <libxml/tree.h>
# include <libxml/xpath.h>
31

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

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
/* forward declarations of all device types, required by
 * virDomainDeviceDef
 */
typedef struct _virDomainDiskDef virDomainDiskDef;
typedef virDomainDiskDef *virDomainDiskDefPtr;

typedef struct _virDomainControllerDef virDomainControllerDef;
typedef virDomainControllerDef *virDomainControllerDefPtr;

typedef struct _virDomainLeaseDef virDomainLeaseDef;
typedef virDomainLeaseDef *virDomainLeaseDefPtr;

typedef struct _virDomainFSDef virDomainFSDef;
typedef virDomainFSDef *virDomainFSDefPtr;

typedef struct _virDomainNetDef virDomainNetDef;
typedef virDomainNetDef *virDomainNetDefPtr;

typedef struct _virDomainInputDef virDomainInputDef;
typedef virDomainInputDef *virDomainInputDefPtr;

79 80 81
typedef struct _virDomainSoundCodecDef virDomainSoundCodecDef;
typedef virDomainSoundCodecDef *virDomainSoundCodecDefPtr;

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
typedef struct _virDomainSoundDef virDomainSoundDef;
typedef virDomainSoundDef *virDomainSoundDefPtr;

typedef struct _virDomainVideoDef virDomainVideoDef;
typedef virDomainVideoDef *virDomainVideoDefPtr;

typedef struct _virDomainHostdevDef virDomainHostdevDef;
typedef virDomainHostdevDef *virDomainHostdevDefPtr;

typedef struct _virDomainWatchdogDef virDomainWatchdogDef;
typedef virDomainWatchdogDef *virDomainWatchdogDefPtr;

typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;

typedef struct _virDomainHubDef virDomainHubDef;
typedef virDomainHubDef *virDomainHubDefPtr;

typedef struct _virDomainRedirdevDef virDomainRedirdevDef;
typedef virDomainRedirdevDef *virDomainRedirdevDefPtr;

103 104
typedef struct _virDomainRedirFilterUSBDevDef virDomainRedirFilterUSBDevDef;
typedef virDomainRedirFilterUSBDevDef *virDomainRedirFilterUSBDevDefPtr;
105 106 107 108

typedef struct _virDomainRedirFilterDef virDomainRedirFilterDef;
typedef virDomainRedirFilterDef *virDomainRedirFilterDefPtr;

109 110 111 112 113 114 115 116 117
typedef struct _virDomainSmartcardDef virDomainSmartcardDef;
typedef virDomainSmartcardDef *virDomainSmartcardDefPtr;

typedef struct _virDomainChrDef virDomainChrDef;
typedef virDomainChrDef *virDomainChrDefPtr;

typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;

L
Li Zhang 已提交
118 119 120
typedef struct _virDomainNVRAMDef virDomainNVRAMDef;
typedef virDomainNVRAMDef *virDomainNVRAMDefPtr;

121 122 123 124 125 126
typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;

typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
typedef virDomainSnapshotObjList *virDomainSnapshotObjListPtr;

127 128 129
typedef struct _virDomainRNGDef virDomainRNGDef;
typedef virDomainRNGDef *virDomainRNGDefPtr;

130 131 132 133 134 135
typedef struct _virDomainIdMapEntry virDomainIdMapEntry;
typedef virDomainIdMapEntry *virDomainIdMapEntryPtr;

typedef struct _virDomainIdMapDef virDomainIdMapDef;
typedef virDomainIdMapDef *virDomainIdMapDefPtr;

H
Hu Tao 已提交
136 137 138
typedef struct _virDomainPanicDef virDomainPanicDef;
typedef virDomainPanicDef *virDomainPanicDefPtr;

139 140 141
typedef struct _virDomainMemoryDef virDomainMemoryDef;
typedef virDomainMemoryDef *virDomainMemoryDefPtr;

M
Michele Paolino 已提交
142 143 144 145 146 147
/* forward declarations virDomainChrSourceDef, required by
 * virDomainNetDef
 */
typedef struct _virDomainChrSourceDef virDomainChrSourceDef;
typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;

148 149 150
typedef struct _virDomainShmemDef virDomainShmemDef;
typedef virDomainShmemDef *virDomainShmemDefPtr;

151 152 153
typedef struct _virDomainTPMDef virDomainTPMDef;
typedef virDomainTPMDef *virDomainTPMDefPtr;

J
Ján Tomko 已提交
154 155 156
typedef struct _virDomainIOMMUDef virDomainIOMMUDef;
typedef virDomainIOMMUDef *virDomainIOMMUDefPtr;

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
/* 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 已提交
176
    VIR_DOMAIN_DEVICE_NVRAM,
177
    VIR_DOMAIN_DEVICE_RNG,
178
    VIR_DOMAIN_DEVICE_SHMEM,
179
    VIR_DOMAIN_DEVICE_TPM,
180
    VIR_DOMAIN_DEVICE_PANIC,
181
    VIR_DOMAIN_DEVICE_MEMORY,
J
Ján Tomko 已提交
182
    VIR_DOMAIN_DEVICE_IOMMU,
183

184
    VIR_DOMAIN_DEVICE_LAST
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
} virDomainDeviceType;

typedef struct _virDomainDeviceDef virDomainDeviceDef;
typedef virDomainDeviceDef *virDomainDeviceDefPtr;
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 已提交
208
        virDomainNVRAMDefPtr nvram;
209
        virDomainRNGDefPtr rng;
210
        virDomainShmemDefPtr shmem;
211
        virDomainTPMDefPtr tpm;
212
        virDomainPanicDefPtr panic;
213
        virDomainMemoryDefPtr memory;
J
Ján Tomko 已提交
214
        virDomainIOMMUDefPtr iommu;
215 216 217
    } data;
};

218 219
/* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */
220
typedef enum {
221
    VIR_DOMAIN_VIRT_NONE = 0,
222 223 224 225 226 227 228 229 230 231
    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,
232
    VIR_DOMAIN_VIRT_VBOX,
233
    VIR_DOMAIN_VIRT_PHYP,
D
Dmitry Guryanov 已提交
234
    VIR_DOMAIN_VIRT_PARALLELS,
R
Roman Bogorodskiy 已提交
235
    VIR_DOMAIN_VIRT_BHYVE,
236
    VIR_DOMAIN_VIRT_VZ,
237

238
    VIR_DOMAIN_VIRT_LAST
239
} virDomainVirtType;
240

241 242 243 244 245 246 247 248 249 250 251 252
typedef enum {
    VIR_DOMAIN_OSTYPE_HVM,
    VIR_DOMAIN_OSTYPE_XEN,
    VIR_DOMAIN_OSTYPE_LINUX,
    VIR_DOMAIN_OSTYPE_EXE,
    VIR_DOMAIN_OSTYPE_UML,

    VIR_DOMAIN_OSTYPE_LAST
} virDomainOSType;
VIR_ENUM_DECL(virDomainOS)


253 254 255 256 257 258 259 260
typedef struct _virDomainHostdevOrigStates virDomainHostdevOrigStates;
typedef virDomainHostdevOrigStates *virDomainHostdevOrigStatesPtr;
struct _virDomainHostdevOrigStates {
    union {
        struct {
            /* Does the device need to unbind from stub when
             * reattaching to host?
             */
261
            bool unbind_from_stub;
262 263 264 265

            /* Does it need to use remove_slot when reattaching
             * the device to host?
             */
266
            bool remove_slot;
267 268 269 270

            /* Does it need to reprobe driver for the device when
             * reattaching to host?
             */
271
            bool reprobe;
272 273 274 275 276 277
        } pci;

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

278 279 280 281 282 283 284
struct _virDomainLeaseDef {
    char *lockspace;
    char *key;
    char *path;
    unsigned long long offset;
};

285

286
typedef enum {
287 288 289
    VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
    VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,

290
    VIR_DOMAIN_HOSTDEV_MODE_LAST
291
} virDomainHostdevMode;
292

293
typedef enum {
294 295
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
H
Han Cheng 已提交
296
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
297
    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST,
298 299

    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
300
} virDomainHostdevSubsysType;
301

302 303
/* the backend driver used for PCI hostdev devices */
typedef enum {
N
Nitesh Konkar 已提交
304
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automatically, prefer VFIO */
305 306
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM,    /* force legacy kvm style */
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO,   /* force vfio */
307
    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN,    /* force legacy xen style, use pciback */
308 309

    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
310
} virDomainHostdevSubsysPCIBackendType;
311

312
VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend)
313

314 315 316 317 318 319 320 321 322
typedef enum {
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE,
    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI,

    VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
} virDomainHostdevSCSIProtocolType;

VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol)

323 324 325 326 327 328 329 330 331 332 333 334
typedef struct _virDomainHostdevSubsysUSB virDomainHostdevSubsysUSB;
typedef virDomainHostdevSubsysUSB *virDomainHostdevSubsysUSBPtr;
struct _virDomainHostdevSubsysUSB {
    bool autoAddress; /* bus/device were filled automatically based
                         on vendor/product */
    unsigned bus;
    unsigned device;

    unsigned vendor;
    unsigned product;
};

335 336 337
typedef struct _virDomainHostdevSubsysPCI virDomainHostdevSubsysPCI;
typedef virDomainHostdevSubsysPCI *virDomainHostdevSubsysPCIPtr;
struct _virDomainHostdevSubsysPCI {
338
    virPCIDeviceAddress addr; /* host address */
339 340 341
    int backend; /* enum virDomainHostdevSubsysPCIBackendType */
};

342 343 344
typedef struct _virDomainHostdevSubsysSCSIHost virDomainHostdevSubsysSCSIHost;
typedef virDomainHostdevSubsysSCSIHost *virDomainHostdevSubsysSCSIHostPtr;
struct _virDomainHostdevSubsysSCSIHost {
345 346 347
    char *adapter;
    unsigned bus;
    unsigned target;
348
    unsigned long long unit;
349 350
};

351 352 353 354 355 356 357 358 359
typedef struct _virDomainHostdevSubsysSCSIiSCSI virDomainHostdevSubsysSCSIiSCSI;
typedef virDomainHostdevSubsysSCSIiSCSI *virDomainHostdevSubsysSCSIiSCSIPtr;
struct _virDomainHostdevSubsysSCSIiSCSI {
    char *path;
    size_t nhosts;
    virStorageNetHostDefPtr hosts;
    virStorageAuthDefPtr auth;
};

360 361 362
typedef struct _virDomainHostdevSubsysSCSI virDomainHostdevSubsysSCSI;
typedef virDomainHostdevSubsysSCSI *virDomainHostdevSubsysSCSIPtr;
struct _virDomainHostdevSubsysSCSI {
363
    int protocol; /* enum virDomainHostdevSCSIProtocolType */
364
    int sgio; /* enum virDomainDeviceSGIO */
365
    int rawio; /* enum virTristateBool */
366 367
    union {
        virDomainHostdevSubsysSCSIHost host;
368
        virDomainHostdevSubsysSCSIiSCSI iscsi;
369
    } u;
370 371
};

372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
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;

VIR_ENUM_DECL(virDomainHostdevSubsysSCSIHostProtocol)

typedef struct _virDomainHostdevSubsysSCSIVHost virDomainHostdevSubsysSCSIVHost;
typedef virDomainHostdevSubsysSCSIVHost *virDomainHostdevSubsysSCSIVHostPtr;
struct _virDomainHostdevSubsysSCSIVHost {
    int protocol; /* enum virDomainHostdevSubsysSCSIHostProtocolType */
    char *wwpn;
};

388 389 390
typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys {
391
    int type; /* enum virDomainHostdevSubsysType */
392
    union {
393
        virDomainHostdevSubsysUSB usb;
394
        virDomainHostdevSubsysPCI pci;
395
        virDomainHostdevSubsysSCSI scsi;
396
        virDomainHostdevSubsysSCSIVHost scsi_host;
397 398 399
    } u;
};

400

401
typedef enum {
402 403
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE,
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC,
404
    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET,
405 406

    VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST
407
} virDomainHostdevCapsType;
408 409 410 411 412 413 414 415 416 417 418 419

typedef struct _virDomainHostdevCaps virDomainHostdevCaps;
typedef virDomainHostdevCaps *virDomainHostdevCapsPtr;
struct _virDomainHostdevCaps {
    int type; /* enum virDOmainHostdevCapsType */
    union {
        struct {
            char *block;
        } storage;
        struct {
            char *chardev;
        } misc;
420
        struct {
421 422
            char *ifname;
            virNetDevIPInfo ip;
423
        } net;
424 425 426 427
    } u;
};


428 429
/* basic device for direct passthrough */
struct _virDomainHostdevDef {
430
    virDomainDeviceDef parent; /* higher level Def containing this */
431 432
    virObjectPtr privateData;

433
    int mode; /* enum virDomainHostdevMode */
434
    int startupPolicy; /* enum virDomainStartupPolicy */
435
    bool managed;
436
    bool missing;
O
Osier Yang 已提交
437
    bool readonly;
438
    bool shareable;
439
    union {
440
        virDomainHostdevSubsys subsys;
441
        virDomainHostdevCaps caps;
442 443
    } source;
    virDomainHostdevOrigStates origstates;
444
    virDomainDeviceInfoPtr info; /* Guest address */
445 446
};

447

E
Eric Blake 已提交
448 449
/* Types of disk frontend (guest view).  For backends (host view), see
 * virStorageType in util/virstoragefile.h */
450
typedef enum {
451 452 453
    VIR_DOMAIN_DISK_DEVICE_DISK,
    VIR_DOMAIN_DISK_DEVICE_CDROM,
    VIR_DOMAIN_DISK_DEVICE_FLOPPY,
454
    VIR_DOMAIN_DISK_DEVICE_LUN,
455 456

    VIR_DOMAIN_DISK_DEVICE_LAST
457
} virDomainDiskDevice;
458

459
typedef enum {
460 461 462 463 464
    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,
465
    VIR_DOMAIN_DISK_BUS_USB,
466
    VIR_DOMAIN_DISK_BUS_UML,
467
    VIR_DOMAIN_DISK_BUS_SATA,
468
    VIR_DOMAIN_DISK_BUS_SD,
469 470

    VIR_DOMAIN_DISK_BUS_LAST
471
} virDomainDiskBus;
472

473
typedef enum {
474 475 476 477
    VIR_DOMAIN_DISK_CACHE_DEFAULT,
    VIR_DOMAIN_DISK_CACHE_DISABLE,
    VIR_DOMAIN_DISK_CACHE_WRITETHRU,
    VIR_DOMAIN_DISK_CACHE_WRITEBACK,
478
    VIR_DOMAIN_DISK_CACHE_DIRECTSYNC,
479
    VIR_DOMAIN_DISK_CACHE_UNSAFE,
480 481

    VIR_DOMAIN_DISK_CACHE_LAST
482
} virDomainDiskCache;
483

484
typedef enum {
485 486
    VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT,
    VIR_DOMAIN_DISK_ERROR_POLICY_STOP,
487
    VIR_DOMAIN_DISK_ERROR_POLICY_REPORT,
488
    VIR_DOMAIN_DISK_ERROR_POLICY_IGNORE,
489
    VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE,
490 491

    VIR_DOMAIN_DISK_ERROR_POLICY_LAST
492
} virDomainDiskErrorPolicy;
493

M
MORITA Kazutaka 已提交
494

495
typedef enum {
496
    VIR_DOMAIN_DISK_TRAY_CLOSED = 0,
497 498 499
    VIR_DOMAIN_DISK_TRAY_OPEN,

    VIR_DOMAIN_DISK_TRAY_LAST
500
} virDomainDiskTray;
501

502
typedef enum {
J
J.B. Joret 已提交
503 504 505 506 507 508
    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
509
} virDomainDiskGeometryTrans;
J
J.B. Joret 已提交
510

511
typedef enum {
512
    VIR_DOMAIN_DISK_IO_DEFAULT = 0,
M
Matthias Dahl 已提交
513 514 515 516
    VIR_DOMAIN_DISK_IO_NATIVE,
    VIR_DOMAIN_DISK_IO_THREADS,

    VIR_DOMAIN_DISK_IO_LAST
517
} virDomainDiskIo;
M
Matthias Dahl 已提交
518

519
typedef enum {
520 521 522 523 524 525
    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
526
} virDomainStartupPolicy;
527

528

529
typedef enum {
530 531 532
    VIR_DOMAIN_DEVICE_SGIO_DEFAULT = 0,
    VIR_DOMAIN_DEVICE_SGIO_FILTERED,
    VIR_DOMAIN_DEVICE_SGIO_UNFILTERED,
O
Osier Yang 已提交
533

534
    VIR_DOMAIN_DEVICE_SGIO_LAST
535
} virDomainDeviceSGIO;
O
Osier Yang 已提交
536

537
typedef enum {
O
Osier Yang 已提交
538
    VIR_DOMAIN_DISK_DISCARD_DEFAULT = 0,
O
Osier Yang 已提交
539 540
    VIR_DOMAIN_DISK_DISCARD_UNMAP,
    VIR_DOMAIN_DISK_DISCARD_IGNORE,
O
Osier Yang 已提交
541 542

    VIR_DOMAIN_DISK_DISCARD_LAST
543
} virDomainDiskDiscard;
O
Osier Yang 已提交
544

545 546 547 548 549 550 551 552 553
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;

L
Lei Li 已提交
554 555 556 557 558 559 560 561
typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo;
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;
562 563 564 565 566 567 568
    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;
569
    char *group_name;
570 571 572 573 574 575
    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 已提交
576 577 578
};
typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr;

579

580 581 582 583 584 585 586 587 588
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;

589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
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 */

    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;

605

606 607
/* Stores the virtual disk configuration */
struct _virDomainDiskDef {
608
    virStorageSourcePtr src; /* non-NULL.  XXX Allow NULL for empty cdrom? */
609

610 611
    virObjectPtr privateData;

612 613 614 615
    int device; /* enum virDomainDiskDevice */
    int bus; /* enum virDomainDiskBus */
    char *dst;
    int tray_status; /* enum virDomainDiskTray */
J
Ján Tomko 已提交
616
    int removable; /* enum virTristateSwitch */
L
Lei Li 已提交
617

618
    virStorageSourcePtr mirror;
619
    int mirrorState; /* enum virDomainDiskMirrorState */
E
Eric Blake 已提交
620
    int mirrorJob; /* virDomainBlockJobType */
621

J
J.B. Joret 已提交
622 623 624 625
    struct {
        unsigned int cylinders;
        unsigned int heads;
        unsigned int sectors;
626
        int trans; /* enum virDomainDiskGeometryTrans */
J
J.B. Joret 已提交
627 628
    } geometry;

629 630 631
    struct {
        unsigned int logical_block_size;
        unsigned int physical_block_size;
V
Viktor Mihajlovski 已提交
632
    } blockio;
633

L
Lei Li 已提交
634 635
    virDomainBlockIoTuneInfo blkdeviotune;

636
    char *serial;
O
Osier Yang 已提交
637
    char *wwn;
638 639
    char *vendor;
    char *product;
640
    int cachemode; /* enum virDomainDiskCache */
641 642
    int error_policy;  /* enum virDomainDiskErrorPolicy */
    int rerror_policy; /* enum virDomainDiskErrorPolicy */
643
    int iomode; /* enum virDomainDiskIo */
J
Ján Tomko 已提交
644 645 646
    int ioeventfd; /* enum virTristateSwitch */
    int event_idx; /* enum virTristateSwitch */
    int copy_on_read; /* enum virTristateSwitch */
647
    int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */
648
    int startupPolicy; /* enum virDomainStartupPolicy */
649
    bool transient;
650
    virDomainDeviceInfo info;
651
    int rawio; /* enum virTristateBool */
652
    int sgio; /* enum virDomainDeviceSGIO */
O
Osier Yang 已提交
653
    int discard; /* enum virDomainDiskDiscard */
654
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
655
    int detect_zeroes; /* enum virDomainDiskDetectZeroes */
656
    char *domain_name; /* backend domain name */
657 658 659
};


660
typedef enum {
661 662 663 664
    VIR_DOMAIN_CONTROLLER_TYPE_IDE,
    VIR_DOMAIN_CONTROLLER_TYPE_FDC,
    VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
    VIR_DOMAIN_CONTROLLER_TYPE_SATA,
665
    VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
E
Eric Blake 已提交
666
    VIR_DOMAIN_CONTROLLER_TYPE_CCID,
667
    VIR_DOMAIN_CONTROLLER_TYPE_USB,
J
Ján Tomko 已提交
668
    VIR_DOMAIN_CONTROLLER_TYPE_PCI,
669 670

    VIR_DOMAIN_CONTROLLER_TYPE_LAST
671
} virDomainControllerType;
672

673

674
typedef enum {
J
Ján Tomko 已提交
675
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT,
L
Laine Stump 已提交
676
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT,
J
Ján Tomko 已提交
677
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
678
    VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
679
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT,
680
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT,
681
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT,
682
    VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS,
683
    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS,
J
Ján Tomko 已提交
684 685

    VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
686
} virDomainControllerModelPCI;
J
Ján Tomko 已提交
687

688 689 690 691
typedef enum {
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE,
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE,
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE,
692
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420,
693
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM,
694
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM,
695
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB,
696
    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE,
697 698 699 700

    VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST
} virDomainControllerPCIModelName;

701
typedef enum {
702 703 704 705 706
    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,
707
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI,
708
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI,
709
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078,
710

711
    VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST
712
} virDomainControllerModelSCSI;
713

714
typedef enum {
M
Marc-André Lureau 已提交
715 716 717 718 719 720 721 722 723
    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 已提交
724
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
725 726
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1,
    VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2,
727
    VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
M
Marc-André Lureau 已提交
728 729

    VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
730
} virDomainControllerModelUSB;
M
Marc-André Lureau 已提交
731

732 733 734 735 736 737 738
# define IS_USB2_CONTROLLER(ctrl) \
    (((ctrl)->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) && \
     ((ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1 || \
      (ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1 || \
      (ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2 || \
      (ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3))

739 740 741 742 743 744 745
typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr;
struct _virDomainVirtioSerialOpts {
    int ports;   /* -1 == undef */
    int vectors; /* -1 == undef */
};

746 747 748
typedef struct _virDomainPCIControllerOpts virDomainPCIControllerOpts;
typedef virDomainPCIControllerOpts *virDomainPCIControllerOptsPtr;
struct _virDomainPCIControllerOpts {
749 750
    bool pcihole64;
    unsigned long pcihole64size;
751 752 753 754 755 756 757

    /* 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 */
758 759 760 761 762 763 764 765

    /* 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 */
766 767 768 769
    /* chassis & port used by
     * pcie-root-port/pcie-switch-downstream-port, -1 = unspecified */
    int chassis;
    int port;
770 771 772 773 774
    int busNr; /* used by pci-expander-bus, -1 == unspecified */
    /* numaNode is a *subelement* of target (to match existing
     * item in memory target config) -1 == unspecified
     */
    int numaNode;
775
};
776

777 778 779 780 781 782
typedef struct _virDomainUSBControllerOpts virDomainUSBControllerOpts;
typedef virDomainUSBControllerOpts *virDomainUSBControllerOptsPtr;
struct _virDomainUSBControllerOpts {
    int ports;   /* -1 == undef */
};

783 784 785
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
    int type;
786
    int idx;
787
    int model; /* -1 == undef */
788
    unsigned int queues;
789 790
    unsigned int cmd_per_lun;
    unsigned int max_sectors;
791
    int ioeventfd; /* enum virTristateSwitch */
792
    unsigned int iothread; /* unused = 0, > 0 specific thread # */
793 794
    union {
        virDomainVirtioSerialOpts vioserial;
795
        virDomainPCIControllerOpts pciopts;
796
        virDomainUSBControllerOpts usbopts;
797
    } opts;
798 799 800 801
    virDomainDeviceInfo info;
};


G
Giuseppe Scrivano 已提交
802
/* Types of disk backends */
803
typedef enum {
804 805 806 807 808 809
    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 */
810
    VIR_DOMAIN_FS_TYPE_VOLUME, /* Mounts storage pool volume to a guest */
811 812

    VIR_DOMAIN_FS_TYPE_LAST
813
} virDomainFSType;
814

815
/* Filesystem driver type */
816
typedef enum {
817 818 819
    VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
    VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
    VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
820
    VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
821
    VIR_DOMAIN_FS_DRIVER_TYPE_NBD,
D
Dmitry Guryanov 已提交
822
    VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP,
823 824

    VIR_DOMAIN_FS_DRIVER_TYPE_LAST
825
} virDomainFSDriverType;
826

827
/* Filesystem mount access mode  */
828
typedef enum {
829 830 831 832 833
    VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH,
    VIR_DOMAIN_FS_ACCESSMODE_MAPPED,
    VIR_DOMAIN_FS_ACCESSMODE_SQUASH,

    VIR_DOMAIN_FS_ACCESSMODE_LAST
834
} virDomainFSAccessMode;
835

836
/* Filesystem Write policy */
837
typedef enum {
838 839 840 841
    VIR_DOMAIN_FS_WRPOLICY_DEFAULT = 0,
    VIR_DOMAIN_FS_WRPOLICY_IMMEDIATE,

    VIR_DOMAIN_FS_WRPOLICY_LAST
842
} virDomainFSWrpolicy;
843

844 845 846
/* Allow 2 MB ram usage */
# define VIR_DOMAIN_FS_RAM_DEFAULT_USAGE (1024 * 2)

847 848
struct _virDomainFSDef {
    int type;
849 850
    int fsdriver; /* enum virDomainFSDriverType */
    int accessmode; /* enum virDomainFSAccessMode */
851
    int wrpolicy; /* enum virDomainFSWrpolicy */
852
    int format; /* virStorageFileFormat */
853
    unsigned long long usage; /* in bytes */
854
    virStorageSourcePtr src;
855
    char *dst;
856
    bool readonly;
857
    virDomainDeviceInfo info;
858 859
    unsigned long long space_hard_limit; /* in bytes */
    unsigned long long space_soft_limit; /* in bytes */
860
    bool symlinksResolved;
861 862 863
};


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

879
    VIR_DOMAIN_NET_TYPE_LAST
880
} virDomainNetType;
881

882
/* the backend driver used for virtio interfaces */
883
typedef enum {
884 885 886 887
    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 */

888
    VIR_DOMAIN_NET_BACKEND_TYPE_LAST
889
} virDomainNetBackendType;
890

891
/* the TX algorithm used for virtio interfaces */
892
typedef enum {
893 894 895 896
    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,

897
    VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST
898
} virDomainNetVirtioTxModeType;
899

900
/* link interface states */
901
typedef enum {
902 903 904 905 906
        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
907
} virDomainNetInterfaceLinkState;
908

909 910 911 912 913 914 915 916 917 918 919 920
/* 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.
 */
typedef struct _virDomainActualNetDef virDomainActualNetDef;
typedef virDomainActualNetDef *virDomainActualNetDefPtr;
struct _virDomainActualNetDef {
    int type; /* enum virDomainNetType */
    union {
        struct {
            char *brname;
921
            int macTableManager; /* enum virNetworkBridgeMACTableManagerType */
922 923 924 925 926
        } bridge;
        struct {
            char *linkdev;
            int mode; /* enum virMacvtapMode from util/macvtap.h */
        } direct;
927 928 929
        struct {
            virDomainHostdevDef def;
        } hostdev;
930
    } data;
931
    virNetDevVPortProfilePtr virtPortProfile;
932
    virNetDevBandwidthPtr bandwidth;
933
    virNetDevVlan vlan;
934
    int trustGuestRxFilters; /* enum virTristateBool */
935
    unsigned int class_id; /* class ID for bandwidth 'floor' */
936 937
};

938 939
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
940
    virDomainNetType type;
941
    virMacAddr mac;
942
    char *model;
943 944
    union {
        struct {
945 946
            virDomainNetBackendType name; /* which driver backend to use */
            virDomainNetVirtioTxModeType txmode;
J
Ján Tomko 已提交
947 948
            virTristateSwitch ioeventfd;
            virTristateSwitch event_idx;
949
            unsigned int queues; /* Multiqueue virtio-net */
950
            unsigned int rx_queue_size;
951 952 953 954 955 956 957
            struct {
                virTristateSwitch csum;
                virTristateSwitch gso;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
958
                virTristateSwitch mrg_rxbuf;
959 960 961 962 963 964 965 966
            } host;
            struct {
                virTristateSwitch csum;
                virTristateSwitch tso4;
                virTristateSwitch tso6;
                virTristateSwitch ecn;
                virTristateSwitch ufo;
            } guest;
967 968
        } virtio;
    } driver;
969 970 971 972
    struct {
        char *tap;
        char *vhost;
    } backend;
973
    union {
M
Michele Paolino 已提交
974
        virDomainChrSourceDefPtr vhostuser;
975 976 977
        struct {
            char *address;
            int port;
978 979
            char *localaddr;
            int localport;
980 981 982
        } socket; /* any of NET_CLIENT or NET_SERVER or NET_MCAST */
        struct {
            char *name;
983 984 985 986 987 988 989 990 991 992
            char *portgroup;
            /* actual has info about the currently used physical
             * device (if the network is of type
             * bridge/private/vepa/passthrough). This is saved in the
             * domain state, but never written to persistent config,
             * since it needs to be re-allocated whenever the domain
             * is restarted. It is also never shown to the user, and
             * the user cannot specify it in XML documents.
             */
            virDomainActualNetDefPtr actual;
993 994 995 996
        } network;
        struct {
            char *brname;
        } bridge;
D
Daniel Veillard 已提交
997 998 999
        struct {
            char *name;
        } internal;
1000 1001
        struct {
            char *linkdev;
1002
            int mode; /* enum virMacvtapMode from util/macvtap.h */
1003
        } direct;
1004 1005 1006
        struct {
            virDomainHostdevDef def;
        } hostdev;
1007
    } data;
1008 1009
    /* virtPortProfile is used by network/bridge/direct/hostdev */
    virNetDevVPortProfilePtr virtPortProfile;
1010 1011 1012 1013
    struct {
        bool sndbuf_specified;
        unsigned long sndbuf;
    } tune;
1014
    char *script;
1015
    char *domain_name; /* backend domain name */
1016 1017
    char *ifname; /* interface name on the host (<target dev='x'/>) */
    virNetDevIPInfo hostIP;
1018
    char *ifname_guest_actual;
1019 1020
    char *ifname_guest;
    virNetDevIPInfo guestIP;
1021
    virDomainDeviceInfo info;
1022 1023
    char *filter;
    virNWFilterHashTablePtr filterparams;
1024
    virNetDevBandwidthPtr bandwidth;
1025
    virNetDevVlan vlan;
1026
    int trustGuestRxFilters; /* enum virTristateBool */
1027
    int linkstate;
1028
    unsigned int mtu;
1029 1030
};

E
Eric Blake 已提交
1031 1032 1033 1034
/* Used for prefix of ifname of any network name generated dynamically
 * by libvirt, and cannot be used for a persistent network name.  */
# define VIR_NET_GENERATED_PREFIX "vnet"

1035 1036 1037 1038 1039 1040 1041 1042 1043 1044
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;

VIR_ENUM_DECL(virDomainChrDeviceState)

1045
typedef enum {
1046
    VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
1047 1048
    VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
    VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE,
1049
    VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL,
1050

1051
    VIR_DOMAIN_CHR_DEVICE_TYPE_LAST
1052
} virDomainChrDeviceType;
1053

1054
typedef enum {
G
Guannan Ren 已提交
1055 1056
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA = 0,
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
M
Michal Privoznik 已提交
1057
    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
G
Guannan Ren 已提交
1058 1059

    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
1060
} virDomainChrSerialTargetType;
G
Guannan Ren 已提交
1061

1062
typedef enum {
1063 1064
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
1065
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
J
Joao Martins 已提交
1066
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN,
1067

1068
    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST
1069
} virDomainChrChannelTargetType;
1070

1071
typedef enum {
1072 1073
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE  = 0,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
1074 1075
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
C
Cole Robinson 已提交
1076
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
1077 1078
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
1079 1080
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP,
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM,
1081

1082
    VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST
1083
} virDomainChrConsoleTargetType;
1084

1085
typedef enum {
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095
    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,
1096
    VIR_DOMAIN_CHR_TYPE_SPICEVMC,
1097
    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
1098
    VIR_DOMAIN_CHR_TYPE_NMDM,
1099

1100
    VIR_DOMAIN_CHR_TYPE_LAST
1101
} virDomainChrType;
1102

1103
typedef enum {
1104 1105
    VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW,
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET,
1106 1107
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS, /* secure telnet */
    VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS,
1108

1109
    VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST
1110
} virDomainChrTcpProtocol;
1111

1112
typedef enum {
E
Eric Blake 已提交
1113 1114
    VIR_DOMAIN_CHR_SPICEVMC_VDAGENT,
    VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD,
1115
    VIR_DOMAIN_CHR_SPICEVMC_USBREDIR,
E
Eric Blake 已提交
1116

1117
    VIR_DOMAIN_CHR_SPICEVMC_LAST
1118
} virDomainChrSpicevmcName;
E
Eric Blake 已提交
1119

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

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

    bool targetTypeAttr;
1167 1168 1169 1170
    int targetType; /* enum virDomainChrConsoleTargetType ||
                       enum virDomainChrChannelTargetType ||
                       enum virDomainChrSerialTargetType according to deviceType */

1171 1172 1173 1174 1175 1176
    union {
        int port; /* parallel, serial, console */
        virSocketAddrPtr addr; /* guestfwd */
        char *name; /* virtio */
    } target;

1177 1178
    virDomainChrDeviceState state;

1179
    virDomainChrSourceDefPtr source;
1180 1181

    virDomainDeviceInfo info;
1182 1183 1184

    size_t nseclabels;
    virSecurityDeviceLabelDefPtr *seclabels;
1185 1186
};

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

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

# define VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES 3
# define VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE "/etc/pki/nssdb"

struct _virDomainSmartcardDef {
    int type; /* virDomainSmartcardType */
    union {
        /* no extra data for 'host' */
        struct {
            char *file[VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES];
            char *database;
        } cert; /* 'host-certificates' */
1206
        virDomainChrSourceDefPtr passthru; /* 'passthrough' */
E
Eric Blake 已提交
1207 1208 1209 1210 1211
    } data;

    virDomainDeviceInfo info;
};

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

1217
typedef enum {
1218 1219 1220
    VIR_DOMAIN_TPM_MODEL_TIS,

    VIR_DOMAIN_TPM_MODEL_LAST
1221
} virDomainTPMModel;
1222

1223
typedef enum {
1224 1225 1226
    VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,

    VIR_DOMAIN_TPM_TYPE_LAST
1227
} virDomainTPMBackendType;
1228 1229 1230 1231

# define VIR_DOMAIN_TPM_DEFAULT_DEVICE "/dev/tpm0"

struct _virDomainTPMDef {
1232
    virDomainTPMBackendType type;
1233
    virDomainDeviceInfo info;
1234
    virDomainTPMModel model;
1235 1236 1237 1238 1239 1240 1241
    union {
        struct {
            virDomainChrSourceDef source;
        } passthrough;
    } data;
};

1242
typedef enum {
1243 1244
    VIR_DOMAIN_INPUT_TYPE_MOUSE,
    VIR_DOMAIN_INPUT_TYPE_TABLET,
L
Li Zhang 已提交
1245
    VIR_DOMAIN_INPUT_TYPE_KBD,
1246
    VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH,
1247

1248
    VIR_DOMAIN_INPUT_TYPE_LAST
1249
} virDomainInputType;
1250

1251
typedef enum {
1252 1253 1254
    VIR_DOMAIN_INPUT_BUS_PS2,
    VIR_DOMAIN_INPUT_BUS_USB,
    VIR_DOMAIN_INPUT_BUS_XEN,
1255
    VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
1256
    VIR_DOMAIN_INPUT_BUS_VIRTIO,
1257 1258

    VIR_DOMAIN_INPUT_BUS_LAST
1259
} virDomainInputBus;
1260 1261 1262 1263

struct _virDomainInputDef {
    int type;
    int bus;
1264 1265 1266
    struct {
        char *evdev;
    } source;
1267
    virDomainDeviceInfo info;
1268 1269
};

1270
typedef enum {
1271 1272 1273 1274
    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
    VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO,

    VIR_DOMAIN_SOUND_CODEC_TYPE_LAST
1275
} virDomainSoundCodecType;
1276

1277
typedef enum {
1278 1279 1280
    VIR_DOMAIN_SOUND_MODEL_SB16,
    VIR_DOMAIN_SOUND_MODEL_ES1370,
    VIR_DOMAIN_SOUND_MODEL_PCSPK,
D
Daniel P. Berrange 已提交
1281
    VIR_DOMAIN_SOUND_MODEL_AC97,
1282
    VIR_DOMAIN_SOUND_MODEL_ICH6,
1283
    VIR_DOMAIN_SOUND_MODEL_ICH9,
1284
    VIR_DOMAIN_SOUND_MODEL_USB,
1285 1286

    VIR_DOMAIN_SOUND_MODEL_LAST
1287
} virDomainSoundModel;
1288

1289 1290 1291 1292 1293
struct _virDomainSoundCodecDef {
    int type;
    int cad;
};

1294 1295
struct _virDomainSoundDef {
    int model;
1296
    virDomainDeviceInfo info;
1297

1298
    size_t ncodecs;
1299
    virDomainSoundCodecDefPtr *codecs;
1300 1301
};

1302
typedef enum {
R
Richard Jones 已提交
1303 1304
    VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB,
    VIR_DOMAIN_WATCHDOG_MODEL_IB700,
1305
    VIR_DOMAIN_WATCHDOG_MODEL_DIAG288,
R
Richard Jones 已提交
1306 1307

    VIR_DOMAIN_WATCHDOG_MODEL_LAST
1308
} virDomainWatchdogModel;
R
Richard Jones 已提交
1309

1310
typedef enum {
R
Richard Jones 已提交
1311 1312 1313 1314
    VIR_DOMAIN_WATCHDOG_ACTION_RESET,
    VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
    VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
    VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
H
Hu Tao 已提交
1315
    VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
R
Richard Jones 已提交
1316
    VIR_DOMAIN_WATCHDOG_ACTION_NONE,
1317
    VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI,
R
Richard Jones 已提交
1318 1319

    VIR_DOMAIN_WATCHDOG_ACTION_LAST
1320
} virDomainWatchdogAction;
R
Richard Jones 已提交
1321 1322 1323 1324

struct _virDomainWatchdogDef {
    int model;
    int action;
1325
    virDomainDeviceInfo info;
R
Richard Jones 已提交
1326 1327
};

1328

1329
typedef enum {
1330 1331 1332 1333 1334
    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,
1335
    VIR_DOMAIN_VIDEO_TYPE_QXL,
1336
    VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
M
Marc-André Lureau 已提交
1337
    VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
F
Fabian Freyer 已提交
1338
    VIR_DOMAIN_VIDEO_TYPE_GOP,
1339 1340

    VIR_DOMAIN_VIDEO_TYPE_LAST
1341
} virDomainVideoType;
1342 1343


1344 1345 1346
typedef struct _virDomainVideoAccelDef virDomainVideoAccelDef;
typedef virDomainVideoAccelDef *virDomainVideoAccelDefPtr;
struct _virDomainVideoAccelDef {
1347 1348
    int accel2d; /* enum virTristateBool */
    int accel3d; /* enum virTristateBool */
1349 1350 1351
};


1352 1353
struct _virDomainVideoDef {
    int type;
1354 1355
    unsigned int ram;  /* kibibytes (multiples of 1024) */
    unsigned int vram; /* kibibytes (multiples of 1024) */
1356
    unsigned int vram64; /* kibibytes (multiples of 1024) */
1357
    unsigned int vgamem; /* kibibytes (multiples of 1024) */
1358
    unsigned int heads;
1359
    bool primary;
1360
    virDomainVideoAccelDefPtr accel;
1361
    virDomainDeviceInfo info;
1362 1363
};

1364
/* graphics console modes */
1365
typedef enum {
1366 1367
    VIR_DOMAIN_GRAPHICS_TYPE_SDL,
    VIR_DOMAIN_GRAPHICS_TYPE_VNC,
1368 1369
    VIR_DOMAIN_GRAPHICS_TYPE_RDP,
    VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
1370
    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
1371

1372
    VIR_DOMAIN_GRAPHICS_TYPE_LAST
1373
} virDomainGraphicsType;
1374

1375
typedef enum {
1376 1377 1378 1379 1380 1381
    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
1382
} virDomainGraphicsVNCSharePolicy;
1383

1384
typedef enum {
1385 1386 1387 1388 1389 1390
    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
1391
} virDomainGraphicsAuthConnectedType;
1392

1393 1394 1395 1396
typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef;
typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr;
struct _virDomainGraphicsAuthDef {
    char *passwd;
1397
    bool expires; /* Whether there is an expiry time set */
1398
    time_t validTo;  /* seconds since epoch */
1399
    int connected; /* action if connected */
1400 1401
};

1402
typedef enum {
1403 1404 1405 1406 1407 1408
    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 已提交
1409
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_SMARTCARD,
1410
    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_USBREDIR,
1411 1412

    VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST
1413
} virDomainGraphicsSpiceChannelName;
1414

1415
typedef enum {
1416 1417 1418 1419 1420
    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
1421
} virDomainGraphicsSpiceChannelMode;
1422

1423
typedef enum {
1424 1425 1426 1427 1428 1429 1430 1431 1432
    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
1433
} virDomainGraphicsSpiceImageCompression;
1434

1435
typedef enum {
1436 1437 1438 1439 1440 1441
    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
1442
} virDomainGraphicsSpiceJpegCompression;
1443

1444
typedef enum {
1445 1446 1447 1448 1449 1450
    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
1451
} virDomainGraphicsSpiceZlibCompression;
1452

1453
typedef enum {
P
Peng Zhou 已提交
1454 1455 1456 1457 1458
    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
1459
} virDomainGraphicsSpiceMouseMode;
P
Peng Zhou 已提交
1460

1461
typedef enum {
1462 1463 1464 1465 1466 1467
    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
1468
} virDomainGraphicsSpiceStreamingMode;
1469

1470
typedef enum {
1471 1472 1473
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
1474
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
1475

1476
    VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
1477
} virDomainGraphicsListenType;
1478

1479
typedef enum {
M
Marc-André Lureau 已提交
1480 1481
    VIR_DOMAIN_HUB_TYPE_USB,

1482
    VIR_DOMAIN_HUB_TYPE_LAST
1483
} virDomainHubType;
M
Marc-André Lureau 已提交
1484

1485 1486 1487
typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef;
typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr;
struct _virDomainGraphicsListenDef {
1488
    virDomainGraphicsListenType type;
1489 1490
    char *address;
    char *network;
1491
    char *socket;
1492
    bool fromConfig;    /* true if the @address is config file originated */
1493
    bool autoGenerated;
1494 1495
};

1496
struct _virDomainGraphicsDef {
M
Michal Privoznik 已提交
1497 1498 1499 1500 1501
    /* 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.
     */
1502
    virDomainGraphicsType type;
1503 1504 1505
    union {
        struct {
            int port;
1506
            bool portReserved;
M
Martin Kletzander 已提交
1507
            int websocket;
1508
            bool websocketGenerated;
1509
            bool autoport;
1510
            char *keymap;
1511
            virDomainGraphicsAuthDef auth;
1512
            int sharePolicy;
1513 1514 1515 1516
        } vnc;
        struct {
            char *display;
            char *xauth;
1517
            bool fullscreen;
1518
        } sdl;
1519 1520
        struct {
            int port;
1521 1522 1523
            bool autoport;
            bool replaceUser;
            bool multiUser;
1524 1525 1526
        } rdp;
        struct {
            char *display;
1527
            bool fullscreen;
1528
        } desktop;
1529 1530 1531
        struct {
            int port;
            int tlsPort;
1532 1533
            bool portReserved;
            bool tlsPortReserved;
1534
            virDomainGraphicsSpiceMouseMode mousemode;
1535
            char *keymap;
1536
            virDomainGraphicsAuthDef auth;
1537
            bool autoport;
1538
            int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
1539
            virDomainGraphicsSpiceChannelMode defaultMode;
1540 1541 1542 1543
            int image;
            int jpeg;
            int zlib;
            int playback;
1544
            int streaming;
1545 1546 1547
            virTristateBool copypaste;
            virTristateBool filetransfer;
            virTristateBool gl;
1548
            char *rendernode;
1549
        } spice;
1550
    } data;
1551 1552 1553 1554 1555
    /* 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;
1556 1557
};

1558
typedef enum {
1559 1560 1561
    VIR_DOMAIN_REDIRDEV_BUS_USB,

    VIR_DOMAIN_REDIRDEV_BUS_LAST
1562
} virDomainRedirdevBus;
1563 1564 1565 1566

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

1567
    virDomainChrSourceDefPtr source;
1568 1569 1570

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

1572
struct _virDomainRedirFilterUSBDevDef {
1573 1574 1575 1576
    int usbClass;
    int vendor;
    int product;
    int version;
1577
    bool allow;
1578 1579 1580 1581
};

struct _virDomainRedirFilterDef {
    size_t nusbdevs;
1582
    virDomainRedirFilterUSBDevDefPtr *usbdevs;
1583 1584
};

1585
typedef enum {
1586 1587
    VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO,
    VIR_DOMAIN_MEMBALLOON_MODEL_XEN,
1588
    VIR_DOMAIN_MEMBALLOON_MODEL_NONE,
1589 1590

    VIR_DOMAIN_MEMBALLOON_MODEL_LAST
1591
} virDomainMemballoonModel;
1592 1593 1594 1595

struct _virDomainMemballoonDef {
    int model;
    virDomainDeviceInfo info;
1596
    int period; /* seconds between collections */
1597
    int autodeflate; /* enum virTristateSwitch */
1598 1599
};

L
Li Zhang 已提交
1600 1601 1602
struct _virDomainNVRAMDef {
    virDomainDeviceInfo info;
};
1603

1604 1605
typedef enum {
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
1606 1607
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
1608 1609 1610 1611

    VIR_DOMAIN_SHMEM_MODEL_LAST
} virDomainShmemModel;

1612 1613 1614
struct _virDomainShmemDef {
    char *name;
    unsigned long long size;
1615
    int model; /* enum virDomainShmemModel */
1616 1617
    struct {
        bool enabled;
1618
        virDomainChrSourceDef chr;
1619 1620 1621 1622 1623 1624 1625 1626 1627
    } server;
    struct {
        bool enabled;
        unsigned vectors;
        virTristateSwitch ioeventfd;
    } msi;
    virDomainDeviceInfo info;
};

1628
typedef enum {
1629
    VIR_DOMAIN_SMBIOS_NONE = 0,
1630 1631 1632 1633 1634
    VIR_DOMAIN_SMBIOS_EMULATE,
    VIR_DOMAIN_SMBIOS_HOST,
    VIR_DOMAIN_SMBIOS_SYSINFO,

    VIR_DOMAIN_SMBIOS_LAST
1635
} virDomainSmbiosMode;
1636

1637

1638
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
1639

1640
typedef enum {
1641 1642 1643 1644 1645
    VIR_DOMAIN_BOOT_FLOPPY,
    VIR_DOMAIN_BOOT_CDROM,
    VIR_DOMAIN_BOOT_DISK,
    VIR_DOMAIN_BOOT_NET,

1646
    VIR_DOMAIN_BOOT_LAST
1647
} virDomainBootOrder;
1648

1649
typedef enum {
1650 1651 1652
    VIR_DOMAIN_FEATURE_ACPI,
    VIR_DOMAIN_FEATURE_APIC,
    VIR_DOMAIN_FEATURE_PAE,
J
Jim Fehlig 已提交
1653
    VIR_DOMAIN_FEATURE_HAP,
1654
    VIR_DOMAIN_FEATURE_VIRIDIAN,
1655
    VIR_DOMAIN_FEATURE_PRIVNET,
1656
    VIR_DOMAIN_FEATURE_HYPERV,
1657
    VIR_DOMAIN_FEATURE_KVM,
1658
    VIR_DOMAIN_FEATURE_PVSPINLOCK,
1659
    VIR_DOMAIN_FEATURE_CAPABILITIES,
1660
    VIR_DOMAIN_FEATURE_PMU,
1661
    VIR_DOMAIN_FEATURE_VMPORT,
M
Michal Privoznik 已提交
1662
    VIR_DOMAIN_FEATURE_GIC,
M
Michal Privoznik 已提交
1663
    VIR_DOMAIN_FEATURE_SMM,
1664 1665

    VIR_DOMAIN_FEATURE_LAST
1666
} virDomainFeature;
1667

1668 1669
# define VIR_DOMAIN_HYPERV_VENDOR_ID_MAX 12

1670
typedef enum {
1671
    VIR_DOMAIN_HYPERV_RELAXED = 0,
1672 1673
    VIR_DOMAIN_HYPERV_VAPIC,
    VIR_DOMAIN_HYPERV_SPINLOCKS,
1674 1675 1676 1677 1678 1679
    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,
1680 1681

    VIR_DOMAIN_HYPERV_LAST
1682
} virDomainHyperv;
1683

1684 1685 1686 1687 1688 1689
typedef enum {
    VIR_DOMAIN_KVM_HIDDEN = 0,

    VIR_DOMAIN_KVM_LAST
} virDomainKVM;

1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739
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;

1740
typedef enum {
1741 1742 1743 1744 1745 1746
    VIR_DOMAIN_LIFECYCLE_DESTROY,
    VIR_DOMAIN_LIFECYCLE_RESTART,
    VIR_DOMAIN_LIFECYCLE_RESTART_RENAME,
    VIR_DOMAIN_LIFECYCLE_PRESERVE,

    VIR_DOMAIN_LIFECYCLE_LAST
1747
} virDomainLifecycleAction;
1748

1749
typedef enum {
1750 1751 1752 1753 1754 1755 1756 1757
    VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY,
    VIR_DOMAIN_LIFECYCLE_CRASH_RESTART,
    VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME,
    VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE,
    VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY,
    VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART,

    VIR_DOMAIN_LIFECYCLE_CRASH_LAST
1758
} virDomainLifecycleCrashAction;
1759

1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771
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;

VIR_ENUM_DECL(virDomainLockFailure)

M
Michal Privoznik 已提交
1772 1773 1774
typedef struct _virDomainBIOSDef virDomainBIOSDef;
typedef virDomainBIOSDef *virDomainBIOSDefPtr;
struct _virDomainBIOSDef {
J
Ján Tomko 已提交
1775
    int useserial; /* enum virTristateBool */
1776 1777 1778
    /* reboot-timeout parameters */
    bool rt_set;
    int rt_delay;
M
Michal Privoznik 已提交
1779 1780
};

1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795
typedef enum {
    VIR_DOMAIN_LOADER_TYPE_ROM = 0,
    VIR_DOMAIN_LOADER_TYPE_PFLASH,

    VIR_DOMAIN_LOADER_TYPE_LAST
} virDomainLoader;

VIR_ENUM_DECL(virDomainLoader)

typedef struct _virDomainLoaderDef virDomainLoaderDef;
typedef virDomainLoaderDef *virDomainLoaderDefPtr;
struct _virDomainLoaderDef {
    char *path;
    int readonly;   /* enum virTristateBool */
    virDomainLoader type;
1796
    int secure;     /* enum virTristateBool */
1797
    char *nvram;    /* path to non-volatile RAM */
1798
    char *templt;   /* user override of path to master nvram */
1799 1800 1801 1802
};

void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);

1803 1804 1805 1806
/* Operating system configuration data & machine / arch */
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
1807
    int type;
1808
    virArch arch;
1809
    char *machine;
1810
    size_t nBootDevs;
1811
    int bootDevs[VIR_DOMAIN_BOOT_LAST];
J
Ján Tomko 已提交
1812
    int bootmenu; /* enum virTristateBool */
1813 1814
    unsigned int bm_timeout;
    bool bm_timeout_set;
1815
    char *init;
1816
    char **initargv;
1817 1818 1819
    char *kernel;
    char *initrd;
    char *cmdline;
1820
    char *dtb;
1821
    char *root;
J
Ján Tomko 已提交
1822
    char *slic_table;
1823
    virDomainLoaderDefPtr loader;
1824 1825
    char *bootloader;
    char *bootloaderArgs;
1826
    int smbios_mode;
1827

M
Michal Privoznik 已提交
1828
    virDomainBIOSDef bios;
1829 1830
};

1831
typedef enum {
1832 1833 1834 1835 1836
    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 已提交
1837
    VIR_DOMAIN_TIMER_NAME_KVMCLOCK,
1838
    VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK,
1839

1840
    VIR_DOMAIN_TIMER_NAME_LAST
1841
} virDomainTimerNameType;
1842

1843
typedef enum {
1844 1845 1846
    VIR_DOMAIN_TIMER_TRACK_BOOT = 0,
    VIR_DOMAIN_TIMER_TRACK_GUEST,
    VIR_DOMAIN_TIMER_TRACK_WALL,
1847

1848
    VIR_DOMAIN_TIMER_TRACK_LAST
1849
} virDomainTimerTrackType;
1850

1851
typedef enum {
1852 1853 1854 1855 1856
    VIR_DOMAIN_TIMER_TICKPOLICY_DELAY = 0,
    VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP,
    VIR_DOMAIN_TIMER_TICKPOLICY_MERGE,
    VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD,

1857
    VIR_DOMAIN_TIMER_TICKPOLICY_LAST
1858
} virDomainTimerTickpolicyType;
1859

1860
typedef enum {
1861 1862 1863 1864
    VIR_DOMAIN_TIMER_MODE_AUTO = 0,
    VIR_DOMAIN_TIMER_MODE_NATIVE,
    VIR_DOMAIN_TIMER_MODE_EMULATE,
    VIR_DOMAIN_TIMER_MODE_PARAVIRT,
1865
    VIR_DOMAIN_TIMER_MODE_SMPSAFE,
1866

1867
    VIR_DOMAIN_TIMER_MODE_LAST
1868
} virDomainTimerModeType;
1869

1870
typedef enum {
1871
    VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
O
Osier Yang 已提交
1872 1873
    VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,

1874
    VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST
1875
} virDomainCpuPlacementMode;
O
Osier Yang 已提交
1876

1877 1878 1879
typedef struct _virDomainThreadSchedParam virDomainThreadSchedParam;
typedef virDomainThreadSchedParam *virDomainThreadSchedParamPtr;
struct _virDomainThreadSchedParam {
1880
    virProcessSchedPolicy policy;
1881 1882 1883
    int priority;
};

1884 1885 1886 1887 1888 1889 1890 1891
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
    unsigned long threshold;
    unsigned long slew;
    unsigned long limit;
};

1892 1893 1894 1895 1896 1897 1898
typedef struct _virDomainTimerDef virDomainTimerDef;
typedef virDomainTimerDef *virDomainTimerDefPtr;
struct _virDomainTimerDef {
    int name;
    int present;    /* unspecified = -1, no = 0, yes = 1 */
    int tickpolicy; /* none|catchup|merge|discard */

1899 1900 1901 1902
    virDomainTimerCatchupDef catchup;

    /* track is only valid for name='platform|rtc' */
    int track;  /* host|guest */
1903 1904 1905 1906 1907 1908

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

1909
typedef enum {
1910 1911
    VIR_DOMAIN_CLOCK_OFFSET_UTC = 0,
    VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME = 1,
1912
    VIR_DOMAIN_CLOCK_OFFSET_VARIABLE = 2,
1913
    VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE = 3,
1914

1915
    VIR_DOMAIN_CLOCK_OFFSET_LAST
1916
} virDomainClockOffsetType;
1917

1918
typedef enum {
1919 1920 1921
    VIR_DOMAIN_CLOCK_BASIS_UTC = 0,
    VIR_DOMAIN_CLOCK_BASIS_LOCALTIME = 1,

1922
    VIR_DOMAIN_CLOCK_BASIS_LAST
1923
} virDomainClockBasis;
1924

1925 1926 1927 1928
typedef struct _virDomainClockDef virDomainClockDef;
typedef virDomainClockDef *virDomainClockDefPtr;
struct _virDomainClockDef {
    int offset;
1929

1930
    union {
1931 1932 1933
        /* Bug-compatibility-mode for Xen utc|localtime */
        int utc_reset;
        /* Adjustment in seconds, relative to UTC or LOCALTIME, when
1934
         * offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE */
1935 1936 1937
        struct {
            long long adjustment;
            int basis;
1938 1939 1940 1941 1942 1943 1944

            /* 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;
1945
        } variable;
1946 1947 1948 1949 1950

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

1952
    size_t ntimers;
1953
    virDomainTimerDefPtr *timers;
1954 1955
};

1956

1957 1958 1959
typedef struct _virBlkioDevice virBlkioDevice;
typedef virBlkioDevice *virBlkioDevicePtr;
struct _virBlkioDevice {
1960 1961
    char *path;
    unsigned int weight;
1962 1963 1964 1965
    unsigned int riops;
    unsigned int wiops;
    unsigned long long rbps;
    unsigned long long wbps;
1966 1967
};

1968
typedef enum {
1969 1970 1971
    VIR_DOMAIN_RNG_MODEL_VIRTIO,

    VIR_DOMAIN_RNG_MODEL_LAST
1972
} virDomainRNGModel;
1973

1974
typedef enum {
1975 1976 1977 1978 1979
    VIR_DOMAIN_RNG_BACKEND_RANDOM,
    VIR_DOMAIN_RNG_BACKEND_EGD,
    /* VIR_DOMAIN_RNG_BACKEND_POOL, */

    VIR_DOMAIN_RNG_BACKEND_LAST
1980
} virDomainRNGBackend;
1981 1982 1983 1984

struct _virDomainRNGDef {
    int model;
    int backend;
1985 1986
    unsigned int rate; /* bytes per period */
    unsigned int period; /* milliseconds */
1987 1988 1989 1990 1991 1992 1993 1994 1995 1996

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

    virDomainDeviceInfo info;
};

1997 1998 1999
typedef enum {
    VIR_DOMAIN_MEMORY_MODEL_NONE,
    VIR_DOMAIN_MEMORY_MODEL_DIMM, /* dimm hotpluggable memory device */
M
Michal Privoznik 已提交
2000
    VIR_DOMAIN_MEMORY_MODEL_NVDIMM, /* nvdimm memory device */
2001 2002 2003 2004 2005 2006 2007 2008

    VIR_DOMAIN_MEMORY_MODEL_LAST
} virDomainMemoryModel;

struct _virDomainMemoryDef {
    /* source */
    virBitmapPtr sourceNodes;
    unsigned long long pagesize; /* kibibytes */
M
Michal Privoznik 已提交
2009
    char *nvdimmPath;
2010 2011 2012

    /* target */
    int model; /* virDomainMemoryModel */
2013
    int targetNode;
2014 2015 2016 2017 2018 2019 2020
    unsigned long long size; /* kibibytes */

    virDomainDeviceInfo info;
};

void virDomainMemoryDefFree(virDomainMemoryDefPtr def);

2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035
struct _virDomainIdMapEntry {
    unsigned int start;
    unsigned int target;
    unsigned int count;
};

struct _virDomainIdMapDef {
    size_t nuidmap;
    virDomainIdMapEntryPtr uidmap;

    size_t ngidmap;
    virDomainIdMapEntryPtr gidmap;
};


2036 2037 2038 2039 2040
typedef enum {
    VIR_DOMAIN_PANIC_MODEL_DEFAULT,
    VIR_DOMAIN_PANIC_MODEL_ISA,
    VIR_DOMAIN_PANIC_MODEL_PSERIES,
    VIR_DOMAIN_PANIC_MODEL_HYPERV,
2041
    VIR_DOMAIN_PANIC_MODEL_S390,
2042 2043 2044 2045

    VIR_DOMAIN_PANIC_MODEL_LAST
} virDomainPanicModel;

H
Hu Tao 已提交
2046
struct _virDomainPanicDef {
2047
    int model; /* virDomainPanicModel */
H
Hu Tao 已提交
2048 2049 2050 2051
    virDomainDeviceInfo info;
};


2052
void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
2053
                              int ndevices);
2054

2055 2056 2057 2058 2059
typedef struct _virDomainResourceDef virDomainResourceDef;
typedef virDomainResourceDef *virDomainResourceDefPtr;
struct _virDomainResourceDef {
    char *partition;
};
2060

2061
typedef struct _virDomainHugePage virDomainHugePage;
2062 2063
typedef virDomainHugePage *virDomainHugePagePtr;

2064
struct _virDomainHugePage {
2065 2066 2067 2068
    virBitmapPtr nodemask;      /* guest's NUMA node mask */
    unsigned long long size;    /* hugepage size in KiB */
};

2069 2070
# define VIR_DOMAIN_CPUMASK_LEN 1024

2071 2072 2073 2074 2075 2076
typedef struct _virDomainIOThreadIDDef virDomainIOThreadIDDef;
typedef virDomainIOThreadIDDef *virDomainIOThreadIDDefPtr;

struct _virDomainIOThreadIDDef {
    bool autofill;
    unsigned int iothread_id;
2077
    int thread_id;
2078
    virBitmapPtr cpumask;
2079 2080

    virDomainThreadSchedParam sched;
2081 2082 2083 2084
};

void virDomainIOThreadIDDefFree(virDomainIOThreadIDDefPtr def);

2085

2086 2087 2088 2089
typedef struct _virDomainCputune virDomainCputune;
typedef virDomainCputune *virDomainCputunePtr;

struct _virDomainCputune {
2090
    unsigned long long shares;
2091 2092 2093
    bool sharesSpecified;
    unsigned long long period;
    long long quota;
2094
    unsigned long long global_period;
2095
    long long global_quota;
2096 2097
    unsigned long long emulator_period;
    long long emulator_quota;
2098 2099
    unsigned long long iothread_period;
    long long iothread_quota;
2100
    virBitmapPtr emulatorpin;
2101 2102
};

2103

2104 2105
typedef struct _virDomainVcpuDef virDomainVcpuDef;
typedef virDomainVcpuDef *virDomainVcpuDefPtr;
2106

2107
struct _virDomainVcpuDef {
2108
    bool online;
2109 2110 2111
    virTristateBool hotpluggable;
    unsigned int order;

2112
    virBitmapPtr cpumask;
2113 2114

    virDomainThreadSchedParam sched;
2115 2116

    virObjectPtr privateData;
2117 2118
};

2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132
typedef struct _virDomainBlkiotune virDomainBlkiotune;
typedef virDomainBlkiotune *virDomainBlkiotunePtr;

struct _virDomainBlkiotune {
    unsigned int weight;

    size_t ndevices;
    virBlkioDevicePtr devices;
};

typedef struct _virDomainMemtune virDomainMemtune;
typedef virDomainMemtune *virDomainMemtunePtr;

struct _virDomainMemtune {
2133 2134 2135
    /* total memory size including memory modules in kibibytes, this field
     * should be accessed only via accessors */
    unsigned long long total_memory;
2136 2137
    unsigned long long cur_balloon; /* in kibibytes, capped at ulong thanks
                                       to virDomainGetInfo */
2138 2139 2140 2141

    virDomainHugePagePtr hugepages;
    size_t nhugepages;

2142 2143 2144 2145
    /* 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 */

2146 2147 2148
    bool nosharepages;
    bool locked;
    int dump_core; /* enum virTristateSwitch */
2149 2150 2151 2152
    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 */
2153 2154 2155 2156

    int source; /* enum virDomainMemorySource */
    int access; /* enum virDomainMemoryAccess */
    int allocation; /* enum virDomainMemoryAllocation */
2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167
};

typedef struct _virDomainPowerManagement virDomainPowerManagement;
typedef virDomainPowerManagement *virDomainPowerManagementPtr;

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

Q
Qiaowei Ren 已提交
2168 2169 2170 2171 2172 2173 2174
typedef struct _virDomainPerfDef virDomainPerfDef;
typedef virDomainPerfDef *virDomainPerfDefPtr;
struct _virDomainPerfDef {
    /* These options are of type enum virTristateBool */
    int events[VIR_PERF_EVENT_LAST];
};

2175 2176 2177 2178 2179 2180 2181
typedef struct _virDomainKeyWrapDef virDomainKeyWrapDef;
typedef virDomainKeyWrapDef *virDomainKeyWrapDefPtr;
struct _virDomainKeyWrapDef {
    int aes; /* enum virTristateSwitch */
    int dea; /* enum virTristateSwitch */
};

J
Ján Tomko 已提交
2182 2183 2184 2185 2186 2187 2188 2189 2190
typedef enum {
    VIR_DOMAIN_IOMMU_MODEL_INTEL,

    VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;

struct _virDomainIOMMUDef {
    virDomainIOMMUModel model;
};
2191 2192 2193 2194 2195 2196
/*
 * Guest VM main configuration
 *
 * NB: if adding to this struct, virDomainDefCheckABIStability
 * may well need an update
 */
2197 2198
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
2199
struct _virDomainDef {
2200
    virDomainVirtType virtType;
2201 2202 2203
    int id;
    unsigned char uuid[VIR_UUID_BUFLEN];
    char *name;
2204
    char *title;
2205
    char *description;
2206

2207 2208
    virDomainBlkiotune blkio;
    virDomainMemtune mem;
2209

2210
    virDomainVcpuDefPtr *vcpus;
2211
    size_t maxvcpus;
2212 2213
    /* set if the vcpu definition was specified individually */
    bool individualvcpus;
O
Osier Yang 已提交
2214
    int placement_mode;
H
Hu Tao 已提交
2215
    virBitmapPtr cpumask;
2216

2217 2218
    size_t niothreadids;
    virDomainIOThreadIDDefPtr *iothreadids;
2219

2220
    virDomainCputune cputune;
2221

2222
    virDomainNumaPtr numa;
2223
    virDomainResourceDefPtr resource;
2224
    virDomainIdMapDef idmap;
2225

2226 2227 2228 2229 2230
    /* These 3 are based on virDomainLifeCycleAction enum flags */
    int onReboot;
    int onPoweroff;
    int onCrash;

2231 2232
    int onLockFailure; /* enum virDomainLockFailureAction */

2233
    virDomainPowerManagement pm;
2234

2235
    virDomainPerfDef perf;
Q
Qiaowei Ren 已提交
2236

2237 2238
    virDomainOSDef os;
    char *emulator;
2239 2240 2241
    /* These three options are of type virTristateSwitch,
     * except VIR_DOMAIN_FEATURE_CAPABILITIES that is of type
     * virDomainCapabilitiesPolicy */
2242
    int features[VIR_DOMAIN_FEATURE_LAST];
2243
    int apic_eoi;
2244
    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
2245
    int kvm_features[VIR_DOMAIN_KVM_LAST];
2246
    unsigned int hyperv_spinlocks;
2247
    virGICVersion gic_version;
2248
    char *hyperv_vendor_id;
2249

J
Ján Tomko 已提交
2250
    /* These options are of type virTristateSwitch: ON = keep, OFF = drop */
2251 2252
    int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST];

2253
    virDomainClockDef clock;
2254

2255
    size_t ngraphics;
2256
    virDomainGraphicsDefPtr *graphics;
2257

2258
    size_t ndisks;
2259 2260
    virDomainDiskDefPtr *disks;

2261
    size_t ncontrollers;
2262 2263
    virDomainControllerDefPtr *controllers;

2264
    size_t nfss;
2265 2266
    virDomainFSDefPtr *fss;

2267
    size_t nnets;
2268 2269
    virDomainNetDefPtr *nets;

2270
    size_t ninputs;
2271 2272
    virDomainInputDefPtr *inputs;

2273
    size_t nsounds;
2274 2275
    virDomainSoundDefPtr *sounds;

2276
    size_t nvideos;
2277 2278
    virDomainVideoDefPtr *videos;

2279
    size_t nhostdevs;
2280 2281
    virDomainHostdevDefPtr *hostdevs;

2282
    size_t nredirdevs;
2283 2284
    virDomainRedirdevDefPtr *redirdevs;

2285
    size_t nsmartcards;
E
Eric Blake 已提交
2286 2287
    virDomainSmartcardDefPtr *smartcards;

2288
    size_t nserials;
2289 2290
    virDomainChrDefPtr *serials;

2291
    size_t nparallels;
2292 2293
    virDomainChrDefPtr *parallels;

2294
    size_t nchannels;
2295 2296
    virDomainChrDefPtr *channels;

2297
    size_t nconsoles;
2298 2299
    virDomainChrDefPtr *consoles;

2300
    size_t nleases;
2301 2302
    virDomainLeaseDefPtr *leases;

2303
    size_t nhubs;
M
Marc-André Lureau 已提交
2304 2305
    virDomainHubDefPtr *hubs;

2306 2307 2308
    size_t nseclabels;
    virSecurityLabelDefPtr *seclabels;

2309 2310 2311
    size_t nrngs;
    virDomainRNGDefPtr *rngs;

2312 2313 2314
    size_t nshmems;
    virDomainShmemDefPtr *shmems;

2315 2316 2317
    size_t nmems;
    virDomainMemoryDefPtr *mems;

D
Dmitry Andreev 已提交
2318 2319 2320
    size_t npanics;
    virDomainPanicDefPtr *panics;

2321
    /* Only 1 */
R
Richard Jones 已提交
2322
    virDomainWatchdogDefPtr watchdog;
2323
    virDomainMemballoonDefPtr memballoon;
L
Li Zhang 已提交
2324
    virDomainNVRAMDefPtr nvram;
2325
    virDomainTPMDefPtr tpm;
2326
    virCPUDefPtr cpu;
2327
    virSysinfoDefPtr sysinfo;
2328
    virDomainRedirFilterDefPtr redirfilter;
J
Ján Tomko 已提交
2329
    virDomainIOMMUDefPtr iommu;
2330 2331 2332

    void *namespaceData;
    virDomainXMLNamespace ns;
2333

2334 2335
    virDomainKeyWrapDefPtr keywrap;

2336 2337
    /* Application-specific custom metadata */
    xmlNodePtr metadata;
2338 2339
};

2340

2341
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
2342
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);
2343
unsigned long long virDomainDefGetMemoryTotal(const virDomainDef *def);
2344
bool virDomainDefHasMemoryHotplug(const virDomainDef *def);
2345

2346 2347 2348 2349 2350 2351 2352
typedef enum {
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_AES,
    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_DEA,

    VIR_DOMAIN_KEY_WRAP_CIPHER_NAME_LAST
} virDomainKeyWrapCipherName;

2353
typedef enum {
2354 2355 2356 2357 2358
    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 */
2359
    VIR_DOMAIN_TAINT_EXTERNAL_LAUNCH,  /* Externally launched guest domain */
2360
    VIR_DOMAIN_TAINT_HOST_CPU,         /* Host CPU passthrough in use */
2361
    VIR_DOMAIN_TAINT_HOOK,             /* Domain (possibly) changed via hook script */
2362
    VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH,/* CDROM passthrough */
Y
Yuri Chornoivan 已提交
2363
    VIR_DOMAIN_TAINT_CUSTOM_DTB,       /* Custom device tree blob was specified */
2364 2365

    VIR_DOMAIN_TAINT_LAST
2366
} virDomainTaintFlags;
2367

2368
/* Guest VM runtime state */
J
Jiri Denemark 已提交
2369 2370 2371 2372 2373 2374
typedef struct _virDomainStateReason virDomainStateReason;
struct _virDomainStateReason {
    int state;
    int reason;
};

2375 2376 2377
typedef struct _virDomainObj virDomainObj;
typedef virDomainObj *virDomainObjPtr;
struct _virDomainObj {
2378
    virObjectLockable parent;
2379
    virCond cond;
2380

2381
    pid_t pid;
J
Jiri Denemark 已提交
2382
    virDomainStateReason state;
2383 2384 2385

    unsigned int autostart : 1;
    unsigned int persistent : 1;
2386
    unsigned int updated : 1;
2387
    unsigned int removing : 1;
2388 2389 2390

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

2392
    virDomainSnapshotObjListPtr snapshots;
C
Chris Lalancette 已提交
2393 2394
    virDomainSnapshotObjPtr current_snapshot;

2395 2396
    bool hasManagedSave;

2397 2398
    void *privateData;
    void (*privateDataFreeFunc)(void *);
2399 2400

    int taint;
2401 2402 2403

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

2406 2407
typedef bool (*virDomainObjListACLFilter)(virConnectPtr conn,
                                          virDomainDefPtr def);
2408

2409

2410 2411
typedef enum {
    VIR_DOMAIN_DEF_FEATURE_WIDE_SCSI = (1 << 0),
2412
    VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1),
2413
    VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2),
2414
    VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3),
2415
    VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4),
2416 2417 2418
} virDomainDefFeatures;


2419 2420
/* This structure holds various callbacks and data needed
 * while parsing and creating domain XMLs */
2421 2422
typedef struct _virDomainXMLOption virDomainXMLOption;
typedef virDomainXMLOption *virDomainXMLOptionPtr;
2423

2424
/* Called once after everything else has been parsed, for adjusting
2425 2426 2427 2428
 * overall domain defaults.
 * @parseOpaque is opaque data passed by virDomainDefParse* caller,
 * @opaque is opaque data set by driver (usually pointer to driver
 * private data). */
2429 2430
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
                                             virCapsPtr caps,
2431
                                             unsigned int parseFlags,
2432 2433
                                             void *opaque,
                                             void *parseOpaque);
2434
/* Called once per device, for adjusting per-device settings while
2435 2436 2437 2438
 * 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). */
2439
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
2440
                                                   const virDomainDef *def,
2441
                                                   virCapsPtr caps,
2442
                                                   unsigned int parseFlags,
2443 2444
                                                   void *opaque,
                                                   void *parseOpaque);
2445
/* Drive callback for assigning device addresses, called at the end
2446 2447 2448 2449
 * 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). */
2450 2451 2452
typedef int (*virDomainDefAssignAddressesCallback)(virDomainDef *def,
                                                   virCapsPtr caps,
                                                   unsigned int parseFlags,
2453 2454
                                                   void *opaque,
                                                   void *parseOpaque);
2455

2456 2457 2458 2459 2460 2461
/* 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);
2462

2463 2464 2465 2466 2467 2468
/* 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);

2469 2470 2471
typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
struct _virDomainDefParserConfig {
2472
    /* driver domain definition callbacks */
2473 2474
    virDomainDefPostParseCallback domainPostParseCallback;
    virDomainDeviceDefPostParseCallback devicesPostParseCallback;
2475
    virDomainDefAssignAddressesCallback assignAddressesCallback;
2476

2477 2478
    /* validation callbacks */
    virDomainDefValidateCallback domainValidateCallback;
2479
    virDomainDeviceDefValidateCallback deviceValidateCallback;
2480

2481
    /* private data for the callbacks */
2482 2483
    void *priv;
    virFreeCallback privFree;
2484 2485

    /* data */
2486
    unsigned int features; /* virDomainDefFeatures */
2487
    unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
2488 2489
};

2490 2491 2492 2493 2494 2495 2496 2497 2498
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void);
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef virObjectPtr (*virDomainXMLPrivateDataNewFunc)(void);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr,
                                                 virDomainObjPtr);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr,
                                                virDomainObjPtr,
                                                virDomainDefParserConfigPtr);

2499 2500 2501 2502 2503
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
struct _virDomainXMLPrivateDataCallbacks {
    virDomainXMLPrivateDataAllocFunc  alloc;
    virDomainXMLPrivateDataFreeFunc   free;
2504 2505
    /* note that private data for devices are not copied when using
     * virDomainDefCopy and similar functions */
2506
    virDomainXMLPrivateDataNewFunc    diskNew;
2507
    virDomainXMLPrivateDataNewFunc    hostdevNew;
2508
    virDomainXMLPrivateDataNewFunc    vcpuNew;
2509
    virDomainXMLPrivateDataNewFunc    chrSourceNew;
2510 2511 2512 2513
    virDomainXMLPrivateDataFormatFunc format;
    virDomainXMLPrivateDataParseFunc  parse;
};

2514 2515 2516
virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
                                            virDomainXMLPrivateDataCallbacksPtr priv,
                                            virDomainXMLNamespacePtr xmlns);
2517

2518 2519
void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);

2520
virDomainXMLNamespacePtr
2521
virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
2522 2523
    ATTRIBUTE_NONNULL(1);

2524 2525 2526 2527 2528
int virDomainDefPostParse(virDomainDefPtr def,
                          virCapsPtr caps,
                          unsigned int parseFlags,
                          virDomainXMLOptionPtr xmlopt,
                          void *parseOpaque);
2529

2530
int virDomainDefValidate(virDomainDefPtr def,
2531 2532 2533 2534
                         virCapsPtr caps,
                         unsigned int parseFlags,
                         virDomainXMLOptionPtr xmlopt);

2535
static inline bool
D
Daniel P. Berrange 已提交
2536
virDomainObjIsActive(virDomainObjPtr dom)
2537 2538 2539 2540
{
    return dom->def->id != -1;
}

2541 2542 2543 2544 2545 2546 2547 2548 2549 2550
int virDomainDefSetVcpusMax(virDomainDefPtr def,
                            unsigned int vcpus,
                            virDomainXMLOptionPtr xmlopt);
bool virDomainDefHasVcpusOffline(const virDomainDef *def);
unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
unsigned int virDomainDefGetVcpus(const virDomainDef *def);
virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def);
virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
    ATTRIBUTE_RETURN_CHECK;
2551
void virDomainDefVcpuOrderClear(virDomainDefPtr def);
P
Peter Krempa 已提交
2552 2553
int  virDomainDefGetVcpusTopology(const virDomainDef *def,
                                  unsigned int *maxvcpus);
2554

2555
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
2556
    ATTRIBUTE_NONNULL(1);
2557

M
Michal Privoznik 已提交
2558 2559
void virDomainObjEndAPI(virDomainObjPtr *vm);

2560
bool virDomainObjTaint(virDomainObjPtr obj,
2561
                       virDomainTaintFlags taint);
2562

2563 2564 2565 2566
void virDomainObjBroadcast(virDomainObjPtr vm);
int virDomainObjWait(virDomainObjPtr vm);
int virDomainObjWaitUntil(virDomainObjPtr vm,
                          unsigned long long whenms);
2567

H
Hu Tao 已提交
2568
void virDomainPanicDefFree(virDomainPanicDefPtr panic);
2569
void virDomainResourceDefFree(virDomainResourceDefPtr resource);
2570 2571
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
2572
virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
2573
void virDomainDiskDefFree(virDomainDiskDefPtr def);
2574
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
2575 2576
int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
2577
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
2578 2579 2580 2581 2582 2583 2584
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
    ATTRIBUTE_RETURN_CHECK;
const char *virDomainDiskGetDriver(virDomainDiskDefPtr def);
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
    ATTRIBUTE_RETURN_CHECK;
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
2585
int virDomainDeviceFindControllerModel(const virDomainDef *def,
H
Han Cheng 已提交
2586 2587
                                       virDomainDeviceInfoPtr info,
                                       int controllerType);
2588 2589 2590
virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                 int bus,
                                                 char *dst);
2591
void virDomainControllerDefFree(virDomainControllerDefPtr def);
2592
virDomainFSDefPtr virDomainFSDefNew(void);
2593 2594
virDomainControllerDefPtr
virDomainControllerDefNew(virDomainControllerType type);
2595
void virDomainFSDefFree(virDomainFSDefPtr def);
2596
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
2597
void virDomainNetDefClear(virDomainNetDefPtr def);
2598
void virDomainNetDefFree(virDomainNetDefPtr def);
E
Eric Blake 已提交
2599
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
2600
void virDomainChrDefFree(virDomainChrDefPtr def);
2601
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
2602 2603
int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr src,
                              virDomainChrSourceDefPtr dest);
2604
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
2605
void virDomainSoundDefFree(virDomainSoundDefPtr def);
2606
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
L
Li Zhang 已提交
2607
void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
R
Richard Jones 已提交
2608
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
2609
void virDomainVideoDefFree(virDomainVideoDefPtr def);
2610
virDomainHostdevDefPtr virDomainHostdevDefAlloc(virDomainXMLOptionPtr xmlopt);
2611
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
2612
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
M
Marc-André Lureau 已提交
2613
void virDomainHubDefFree(virDomainHubDefPtr def);
2614
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
2615
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
2616
void virDomainShmemDefFree(virDomainShmemDefPtr def);
2617
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
2618
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
2619
                                             const virDomainDef *def,
2620 2621
                                             virCapsPtr caps,
                                             virDomainXMLOptionPtr xmlopt);
2622 2623
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
                                  int type);
2624
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
2625 2626
int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst,
                            virDomainDeviceInfoPtr src);
2627
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info);
2628
void virDomainTPMDefFree(virDomainTPMDefPtr def);
2629

2630
typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
2631 2632
                                           virDomainDeviceDefPtr dev,
                                           virDomainDeviceInfoPtr info,
2633 2634 2635 2636 2637 2638
                                           void *opaque);

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

2639 2640 2641 2642
bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
                                  virDomainDeviceInfoPtr info)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

2643 2644
void virDomainDefFree(virDomainDefPtr vm);

2645
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
M
Michal Novotny 已提交
2646

2647 2648 2649 2650
virDomainDefPtr virDomainDefNew(void);
virDomainDefPtr virDomainDefNewFull(const char *name,
                                    const unsigned char *uuid,
                                    int id);
2651

2652
void virDomainObjAssignDef(virDomainObjPtr domain,
2653
                           virDomainDefPtr def,
2654 2655
                           bool live,
                           virDomainDefPtr *oldDef);
2656
int virDomainObjSetDefTransient(virCapsPtr caps,
2657
                                virDomainXMLOptionPtr xmlopt,
2658
                                virDomainObjPtr domain);
2659
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
2660 2661
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
2662
                             virDomainXMLOptionPtr xmlopt,
2663
                             virDomainObjPtr domain);
2664 2665 2666 2667 2668 2669 2670 2671

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

int virDomainObjGetDefs(virDomainObjPtr vm,
                        unsigned int flags,
                        virDomainDefPtr *liveDef,
                        virDomainDefPtr *persDef);
2672 2673 2674
virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
                                           unsigned int flags,
                                           bool *state);
2675
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
2676

2677 2678 2679
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
                                 virCapsPtr caps,
                                 virDomainXMLOptionPtr xmlopt,
2680
                                 void *parseOpaque,
2681 2682 2683 2684
                                 bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt);
2685

2686 2687 2688
typedef enum {
    /* parse internal domain status information */
    VIR_DOMAIN_DEF_PARSE_STATUS          = 1 << 0,
2689 2690 2691 2692
    /* 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. */
2693 2694 2695 2696 2697
    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,
2698
    /* internal flag passed to device info sub-parser to allow using <rom> */
2699
    VIR_DOMAIN_DEF_PARSE_ALLOW_ROM       = 1 << 4,
2700
    /* internal flag passed to device info sub-parser to allow specifying boot order */
2701 2702
    VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT      = 1 << 5,
    /* parse only source half of <disk> */
2703
    VIR_DOMAIN_DEF_PARSE_DISK_SOURCE     = 1 << 6,
2704
    /* perform RNG schema validation on the passed XML document */
2705
    VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA = 1 << 7,
2706
    /* don't validate os.type and arch against capabilities. Prevents
2707
     * VMs from disappearing when qemu is removed and libvirtd is restarted */
2708
    VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS = 1 << 8,
2709 2710
    /* allow updates in post parse callback that would break ABI otherwise */
    VIR_DOMAIN_DEF_PARSE_ABI_UPDATE = 1 << 9,
2711 2712
    /* skip definition validation checks meant to be executed on define time only */
    VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 10,
2713 2714
    /* skip parsing of security labels */
    VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL        = 1 << 11,
2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732
} virDomainDefParseFlags;

typedef enum {
    VIR_DOMAIN_DEF_FORMAT_SECURE          = 1 << 0,
    VIR_DOMAIN_DEF_FORMAT_INACTIVE        = 1 << 1,
    VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU      = 1 << 2,
    VIR_DOMAIN_DEF_FORMAT_MIGRATABLE      = 1 << 3,
    /* format internal domain status information */
    VIR_DOMAIN_DEF_FORMAT_STATUS          = 1 << 4,
    /* format <actual> element */
    VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET      = 1 << 5,
    /* format original states of host PCI device */
    VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES = 1 << 6,
    VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM       = 1 << 7,
    VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT      = 1 << 8,
    VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST    = 1 << 9,
} virDomainDefFormatFlags;

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

2742
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
2743
                                              const virDomainDef *def,
2744 2745
                                              virCapsPtr caps,
                                              virDomainXMLOptionPtr xmlopt,
L
Laine Stump 已提交
2746
                                              unsigned int flags);
2747 2748 2749 2750
virStorageSourcePtr virDomainDiskDefSourceParse(const char *xmlStr,
                                                const virDomainDef *def,
                                                virDomainXMLOptionPtr xmlopt,
                                                unsigned int flags);
2751 2752
virDomainDefPtr virDomainDefParseString(const char *xmlStr,
                                        virCapsPtr caps,
2753
                                        virDomainXMLOptionPtr xmlopt,
2754
                                        void *parseOpaque,
L
Laine Stump 已提交
2755
                                        unsigned int flags);
2756 2757
virDomainDefPtr virDomainDefParseFile(const char *filename,
                                      virCapsPtr caps,
2758
                                      virDomainXMLOptionPtr xmlopt,
2759
                                      void *parseOpaque,
L
Laine Stump 已提交
2760
                                      unsigned int flags);
2761
virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc,
2762
                                      xmlNodePtr root,
2763 2764
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
2765
                                      void *parseOpaque,
L
Laine Stump 已提交
2766
                                      unsigned int flags);
2767 2768 2769 2770 2771
virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml,
                                      xmlNodePtr root,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
2772 2773 2774 2775
virDomainObjPtr virDomainObjParseFile(const char *filename,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      unsigned int flags);
2776

2777 2778 2779
bool virDomainDefCheckABIStability(virDomainDefPtr src,
                                   virDomainDefPtr dst);

2780 2781 2782 2783
bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
                                        virDomainDefPtr dst,
                                        unsigned int flags);

2784
int virDomainDefAddImplicitDevices(virDomainDefPtr def);
2785

2786
virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def,
2787 2788 2789 2790 2791
                                                  unsigned int iothread_id);
virDomainIOThreadIDDefPtr virDomainIOThreadIDAdd(virDomainDefPtr def,
                                                 unsigned int iothread_id);
void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id);

2792 2793
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);

2794
char *virDomainDefFormat(virDomainDefPtr def,
2795
                         virCapsPtr caps,
L
Laine Stump 已提交
2796
                         unsigned int flags);
2797 2798
char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
                         virDomainObjPtr obj,
2799
                         virCapsPtr caps,
2800
                         unsigned int flags);
2801
int virDomainDefFormatInternal(virDomainDefPtr def,
2802
                               virCapsPtr caps,
2803 2804
                               unsigned int flags,
                               virBufferPtr buf);
2805

2806 2807 2808 2809
int virDomainDiskSourceFormat(virBufferPtr buf,
                              virStorageSourcePtr src,
                              int policy,
                              unsigned int flags);
2810

2811 2812
int virDomainNetDefFormat(virBufferPtr buf,
                          virDomainNetDefPtr def,
2813
                          char *prefix,
2814 2815
                          unsigned int flags);

2816 2817 2818 2819 2820 2821
typedef enum {
    VIR_DOMAIN_DEVICE_ACTION_ATTACH,
    VIR_DOMAIN_DEVICE_ACTION_DETACH,
    VIR_DOMAIN_DEVICE_ACTION_UPDATE,
} virDomainDeviceAction;

2822
int virDomainDefCompatibleDevice(virDomainDefPtr def,
2823 2824
                                 virDomainDeviceDefPtr dev,
                                 virDomainDeviceAction action);
2825

2826 2827
void virDomainRNGDefFree(virDomainRNGDefPtr def);

2828
int virDomainDiskIndexByAddress(virDomainDefPtr def,
2829
                                virPCIDeviceAddressPtr pci_controller,
2830 2831
                                unsigned int bus, unsigned int target,
                                unsigned int unit);
2832
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
2833
                                           virPCIDeviceAddressPtr pci_controller,
2834 2835 2836
                                           unsigned int bus,
                                           unsigned int target,
                                           unsigned int unit);
2837 2838
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
                             bool allow_ambiguous);
2839 2840 2841
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
                                        const char *name,
                                        bool allow_ambiguous);
2842
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
2843
int virDomainDiskInsert(virDomainDefPtr def,
2844 2845
                        virDomainDiskDefPtr disk)
    ATTRIBUTE_RETURN_CHECK;
2846 2847
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
                                   virDomainDiskDefPtr disk);
2848
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
2849 2850
                                  virDomainDiskDefPtr def,
                                  const virDomainDef *vmdef);
2851

2852 2853 2854 2855
virDomainDiskDefPtr
virDomainDiskRemove(virDomainDefPtr def, size_t i);
virDomainDiskDefPtr
virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
2856
int virDomainDiskSourceParse(xmlNodePtr node,
2857
                             xmlXPathContextPtr ctxt,
2858
                             virStorageSourcePtr src);
2859

2860 2861
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
2862
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
2863
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
2864
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
2865
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
2866

L
Laine Stump 已提交
2867
int virDomainHostdevInsert(virDomainDefPtr def, virDomainHostdevDefPtr hostdev);
2868 2869
virDomainHostdevDefPtr
virDomainHostdevRemove(virDomainDefPtr def, size_t i);
L
Laine Stump 已提交
2870 2871 2872
int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
                         virDomainHostdevDefPtr *found);

2873 2874
virDomainGraphicsListenDefPtr
virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
2875 2876
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
                                         const char *address)
2877
            ATTRIBUTE_NONNULL(1);
2878 2879 2880
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
                                        const char *socket)
            ATTRIBUTE_NONNULL(1);
2881

2882
virDomainNetType virDomainNetGetActualType(virDomainNetDefPtr iface);
2883
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
2884
int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface);
2885
const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
2886
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
2887
virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface);
2888
virNetDevVPortProfilePtr
2889
virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface);
2890
virNetDevBandwidthPtr
2891
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
2892
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
2893
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
2894
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
2895 2896 2897
                                const char *address,
                                int family,
                                unsigned int prefix);
2898

2899
int virDomainControllerInsert(virDomainDefPtr def,
2900 2901
                              virDomainControllerDefPtr controller)
    ATTRIBUTE_RETURN_CHECK;
2902 2903
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                                         virDomainControllerDefPtr controller);
2904
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
2905
int virDomainControllerFindByType(virDomainDefPtr def, int type);
2906
int virDomainControllerFindByPCIAddress(virDomainDefPtr def,
2907
                                        virPCIDeviceAddressPtr addr);
2908
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
2909
virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
2910
const char *virDomainControllerAliasFind(const virDomainDef *def,
2911 2912
                                         int type, int idx)
    ATTRIBUTE_NONNULL(1);
2913 2914 2915 2916 2917

int virDomainLeaseIndex(virDomainDefPtr def,
                        virDomainLeaseDefPtr lease);
int virDomainLeaseInsert(virDomainDefPtr def,
                         virDomainLeaseDefPtr lease);
2918 2919
int virDomainLeaseInsertPreAlloc(virDomainDefPtr def)
    ATTRIBUTE_RETURN_CHECK;
2920 2921
void virDomainLeaseInsertPreAlloced(virDomainDefPtr def,
                                    virDomainLeaseDefPtr lease);
2922 2923 2924 2925 2926
virDomainLeaseDefPtr
virDomainLeaseRemoveAt(virDomainDefPtr def, size_t i);
virDomainLeaseDefPtr
virDomainLeaseRemove(virDomainDefPtr def,
                     virDomainLeaseDefPtr lease);
2927

2928
void
2929
virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
2930
                          virDomainChrDeviceType type,
2931 2932 2933
                          const virDomainChrDef ***arrPtr,
                          size_t *cntPtr)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
2934 2935 2936
virDomainChrDefPtr
virDomainChrFind(virDomainDefPtr def,
                 virDomainChrDefPtr target);
2937 2938 2939
bool
virDomainChrEquals(virDomainChrDefPtr src,
                   virDomainChrDefPtr tgt);
2940
int
2941 2942 2943 2944 2945
virDomainChrPreAlloc(virDomainDefPtr vmdef,
                     virDomainChrDefPtr chr);
void
virDomainChrInsertPreAlloced(virDomainDefPtr vmdef,
                             virDomainChrDefPtr chr);
2946 2947 2948 2949
virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
                   virDomainChrDefPtr chr);

2950 2951 2952
ssize_t virDomainRNGFind(virDomainDefPtr def, virDomainRNGDefPtr rng);
virDomainRNGDefPtr virDomainRNGRemove(virDomainDefPtr def, size_t idx);

2953 2954 2955 2956
ssize_t virDomainRedirdevDefFind(virDomainDefPtr def,
                                 virDomainRedirdevDefPtr redirdev);
virDomainRedirdevDefPtr virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx);

2957
int virDomainSaveXML(const char *configDir,
2958 2959 2960
                     virDomainDefPtr def,
                     const char *xml);

2961
int virDomainSaveConfig(const char *configDir,
2962
                        virCapsPtr caps,
2963
                        virDomainDefPtr def);
2964
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
2965
                        const char *statusDir,
2966 2967
                        virDomainObjPtr obj,
                        virCapsPtr caps) ATTRIBUTE_RETURN_CHECK;
2968

2969 2970 2971 2972
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
                                          int newDomain,
                                          void *opaque);

2973
int virDomainDeleteConfig(const char *configDir,
2974
                          const char *autostartDir,
2975 2976
                          virDomainObjPtr dom);

2977
char *virDomainConfigFile(const char *dir,
2978 2979
                          const char *name);

2980 2981 2982 2983
int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
                                int *busIdx,
                                int *devIdx);

2984
virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
2985
                                                  const char *target);
2986
int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
2987
int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
2988 2989
virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);

2990
int virDomainVideoDefaultType(const virDomainDef *def);
2991 2992
unsigned int virDomainVideoDefaultRAM(const virDomainDef *def,
                                      const virDomainVideoType type);
2993

E
Eric Blake 已提交
2994 2995 2996 2997 2998 2999 3000 3001 3002
typedef int (*virDomainSmartcardDefIterator)(virDomainDefPtr def,
                                             virDomainSmartcardDefPtr dev,
                                             void *opaque);

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

3003 3004 3005 3006 3007 3008 3009 3010 3011
typedef int (*virDomainChrDefIterator)(virDomainDefPtr def,
                                       virDomainChrDefPtr dev,
                                       void *opaque);

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

3012 3013 3014 3015 3016
typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk,
                                            const char *path,
                                            size_t depth,
                                            void *opaque);

3017 3018 3019 3020 3021 3022 3023
typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info,
                                             void *opaque);
int virDomainUSBDeviceDefForeach(virDomainDefPtr def,
                                 virDomainUSBDeviceDefIterator iter,
                                 void *opaque,
                                 bool skipHubs);

3024 3025 3026 3027 3028
int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
                                bool ignoreOpenFailure,
                                virDomainDiskDefPathIterator iter,
                                void *opaque);

J
Jiri Denemark 已提交
3029 3030 3031 3032 3033 3034 3035
void
virDomainObjSetState(virDomainObjPtr obj, virDomainState state, int reason)
        ATTRIBUTE_NONNULL(1);
virDomainState
virDomainObjGetState(virDomainObjPtr obj, int *reason)
        ATTRIBUTE_NONNULL(1);

3036 3037 3038
virSecurityLabelDefPtr
virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model);

3039 3040 3041
virSecurityDeviceLabelDefPtr
virDomainChrDefGetSecurityLabelDef(virDomainChrDefPtr def, const char *model);

3042 3043
typedef const char* (*virEventActionToStringFunc)(int type);
typedef int (*virEventActionFromStringFunc)(const char *type);
3044

3045 3046 3047 3048 3049 3050 3051 3052 3053 3054
int virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
virDomainMemoryDefPtr virDomainMemoryRemove(virDomainDefPtr def, int idx)
    ATTRIBUTE_NONNULL(1);
int virDomainMemoryFindByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

3055 3056 3057 3058 3059 3060 3061 3062 3063
int virDomainShmemDefInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
bool virDomainShmemDefEquals(virDomainShmemDefPtr src, virDomainShmemDefPtr dst)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
virDomainShmemDefPtr virDomainShmemDefRemove(virDomainDefPtr def, size_t idx)
    ATTRIBUTE_NONNULL(1);

3064
VIR_ENUM_DECL(virDomainTaint)
3065 3066 3067
VIR_ENUM_DECL(virDomainVirt)
VIR_ENUM_DECL(virDomainBoot)
VIR_ENUM_DECL(virDomainFeature)
3068 3069
VIR_ENUM_DECL(virDomainCapabilitiesPolicy)
VIR_ENUM_DECL(virDomainCapsFeature)
3070
VIR_ENUM_DECL(virDomainLifecycle)
3071
VIR_ENUM_DECL(virDomainLifecycleCrash)
3072
VIR_ENUM_DECL(virDomainDevice)
3073
VIR_ENUM_DECL(virDomainDeviceAddress)
3074
VIR_ENUM_DECL(virDomainDiskDevice)
J
J.B. Joret 已提交
3075
VIR_ENUM_DECL(virDomainDiskGeometryTrans)
3076
VIR_ENUM_DECL(virDomainDiskBus)
3077
VIR_ENUM_DECL(virDomainDiskCache)
3078
VIR_ENUM_DECL(virDomainDiskErrorPolicy)
M
Matthias Dahl 已提交
3079
VIR_ENUM_DECL(virDomainDiskIo)
3080
VIR_ENUM_DECL(virDomainDeviceSGIO)
3081
VIR_ENUM_DECL(virDomainDiskTray)
O
Osier Yang 已提交
3082
VIR_ENUM_DECL(virDomainDiskDiscard)
3083
VIR_ENUM_DECL(virDomainDiskDetectZeroes)
3084
VIR_ENUM_DECL(virDomainDiskMirrorState)
3085
VIR_ENUM_DECL(virDomainController)
J
Ján Tomko 已提交
3086
VIR_ENUM_DECL(virDomainControllerModelPCI)
3087
VIR_ENUM_DECL(virDomainControllerPCIModelName)
3088
VIR_ENUM_DECL(virDomainControllerModelSCSI)
M
Marc-André Lureau 已提交
3089
VIR_ENUM_DECL(virDomainControllerModelUSB)
3090
VIR_ENUM_DECL(virDomainFS)
3091
VIR_ENUM_DECL(virDomainFSDriver)
3092
VIR_ENUM_DECL(virDomainFSAccessMode)
3093
VIR_ENUM_DECL(virDomainFSWrpolicy)
3094
VIR_ENUM_DECL(virDomainNet)
3095
VIR_ENUM_DECL(virDomainNetBackend)
3096
VIR_ENUM_DECL(virDomainNetVirtioTxMode)
3097
VIR_ENUM_DECL(virDomainNetInterfaceLinkState)
3098
VIR_ENUM_DECL(virDomainChrDevice)
3099
VIR_ENUM_DECL(virDomainChrChannelTarget)
3100
VIR_ENUM_DECL(virDomainChrConsoleTarget)
G
Guannan Ren 已提交
3101
VIR_ENUM_DECL(virDomainChrSerialTarget)
E
Eric Blake 已提交
3102
VIR_ENUM_DECL(virDomainSmartcard)
3103
VIR_ENUM_DECL(virDomainChr)
3104
VIR_ENUM_DECL(virDomainChrTcpProtocol)
E
Eric Blake 已提交
3105
VIR_ENUM_DECL(virDomainChrSpicevmc)
3106
VIR_ENUM_DECL(virDomainSoundCodec)
3107
VIR_ENUM_DECL(virDomainSoundModel)
3108
VIR_ENUM_DECL(virDomainKeyWrapCipherName)
3109
VIR_ENUM_DECL(virDomainMemballoonModel)
3110
VIR_ENUM_DECL(virDomainSmbiosMode)
R
Richard Jones 已提交
3111 3112
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
3113
VIR_ENUM_DECL(virDomainPanicModel)
3114
VIR_ENUM_DECL(virDomainVideo)
3115 3116
VIR_ENUM_DECL(virDomainHostdevMode)
VIR_ENUM_DECL(virDomainHostdevSubsys)
3117
VIR_ENUM_DECL(virDomainHostdevCaps)
M
Marc-André Lureau 已提交
3118
VIR_ENUM_DECL(virDomainHub)
3119
VIR_ENUM_DECL(virDomainRedirdevBus)
3120 3121 3122
VIR_ENUM_DECL(virDomainInput)
VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
3123
VIR_ENUM_DECL(virDomainGraphicsListen)
3124
VIR_ENUM_DECL(virDomainGraphicsAuthConnected)
3125 3126
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
3127 3128 3129
VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
3130
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
P
Peng Zhou 已提交
3131
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
3132
VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy)
3133
VIR_ENUM_DECL(virDomainHyperv)
3134
VIR_ENUM_DECL(virDomainKVM)
3135 3136
VIR_ENUM_DECL(virDomainRNGModel)
VIR_ENUM_DECL(virDomainRNGBackend)
3137 3138
VIR_ENUM_DECL(virDomainTPMModel)
VIR_ENUM_DECL(virDomainTPMBackend)
3139 3140
VIR_ENUM_DECL(virDomainMemoryModel)
VIR_ENUM_DECL(virDomainMemoryBackingModel)
3141 3142
VIR_ENUM_DECL(virDomainMemorySource)
VIR_ENUM_DECL(virDomainMemoryAllocation)
J
Ján Tomko 已提交
3143
VIR_ENUM_DECL(virDomainIOMMUModel)
3144
VIR_ENUM_DECL(virDomainShmemModel)
3145 3146
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
J
Jiri Denemark 已提交
3147 3148 3149 3150 3151 3152 3153
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)
3154
VIR_ENUM_DECL(virDomainPMSuspendedReason)
J
Jiri Denemark 已提交
3155 3156 3157 3158

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

3159
VIR_ENUM_DECL(virDomainSeclabel)
3160
VIR_ENUM_DECL(virDomainClockOffset)
3161
VIR_ENUM_DECL(virDomainClockBasis)
3162

3163
VIR_ENUM_DECL(virDomainTimerName)
3164
VIR_ENUM_DECL(virDomainTimerTrack)
3165 3166
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)
O
Osier Yang 已提交
3167
VIR_ENUM_DECL(virDomainCpuPlacementMode)
3168

3169
VIR_ENUM_DECL(virDomainStartupPolicy)
3170

3171 3172
virDomainControllerDefPtr
virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model);
3173 3174
int
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
3175 3176 3177 3178 3179
int
virDomainDefMaybeAddController(virDomainDefPtr def,
                               int type,
                               int idx,
                               int model);
3180 3181 3182 3183
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
                          int type,
                          int bus);
3184

3185 3186
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);

3187 3188
int virDomainDefFindDevice(virDomainDefPtr def,
                           const char *devAlias,
3189 3190
                           virDomainDeviceDefPtr dev,
                           bool reportError);
3191

3192 3193
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);

3194 3195 3196 3197 3198
char *virDomainObjGetMetadata(virDomainObjPtr vm,
                              int type,
                              const char *uri,
                              unsigned int flags);

3199 3200 3201 3202 3203 3204 3205
int virDomainObjSetMetadata(virDomainObjPtr vm,
                            int type,
                            const char *metadata,
                            const char *key,
                            const char *uri,
                            virCapsPtr caps,
                            virDomainXMLOptionPtr xmlopt,
3206
                            const char *stateDir,
3207 3208 3209
                            const char *configDir,
                            unsigned int flags);

3210 3211 3212 3213 3214 3215 3216 3217
int
virDomainParseMemory(const char *xpath,
                     const char *units_xpath,
                     xmlXPathContextPtr ctxt,
                     unsigned long long *mem,
                     bool required,
                     bool capped);

3218 3219 3220
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

3221 3222
int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a,
                                       const virDomainDiskDef *b)
3223
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3224

3225 3226 3227 3228 3229 3230 3231 3232
int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
                                     int maplen,
                                     int ncpumaps,
                                     unsigned char *cpumaps,
                                     int hostcpus,
                                     virBitmapPtr autoCpuset)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;

3233 3234
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);

3235
char *virDomainObjGetShortName(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
M
Martin Kletzander 已提交
3236

3237 3238 3239 3240 3241
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
                                         virTypedParameterPtr params,
                                         int *nparams,
                                         int maxparams);
3242 3243 3244 3245 3246

bool
virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a,
                                  const virDomainDeviceInfo *b)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
3247 3248 3249 3250

int virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
                                virDomainBlockIoTuneInfo *info);

3251
#endif /* __DOMAIN_CONF_H */