qemu_domain.h 43.8 KB
Newer Older
1 2 3
/*
 * qemu_domain.h: QEMU domain private state
 *
4
 * Copyright (C) 2006-2019 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17
 * Copyright (C) 2006 Daniel P. Berrange
 *
 * 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
18
 * License along with this library.  If not, see
O
Osier Yang 已提交
19
 * <http://www.gnu.org/licenses/>.
20 21
 */

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#pragma once

#include "virthread.h"
#include "vircgroup.h"
#include "virperf.h"
#include "domain_addr.h"
#include "domain_conf.h"
#include "snapshot_conf.h"
#include "qemu_monitor.h"
#include "qemu_agent.h"
#include "qemu_blockjob.h"
#include "qemu_conf.h"
#include "qemu_capabilities.h"
#include "qemu_migration_params.h"
#include "virmdev.h"
#include "virchrdev.h"
#include "virobject.h"
#include "logging/log_manager.h"
#include "virdomainmomentobjlist.h"
#include "virenum.h"

#define QEMU_DOMAIN_FORMAT_LIVE_FLAGS \
44
    (VIR_DOMAIN_XML_SECURE)
45

46
#if ULONG_MAX == 4294967295
P
Philipp Hahn 已提交
47
/* QEMU has a 64-bit limit, but we are limited by our historical choice of
48
 * representing bandwidth in a long instead of a 64-bit int.  */
49 50 51 52
# define QEMU_DOMAIN_MIG_BANDWIDTH_MAX ULONG_MAX
#else
# define QEMU_DOMAIN_MIG_BANDWIDTH_MAX (INT64_MAX / (1024 * 1024))
#endif
53

54 55
#define JOB_MASK(job)                  (job == 0 ? 0 : 1 << (job - 1))
#define QEMU_JOB_DEFAULT_MASK \
56 57
    (JOB_MASK(QEMU_JOB_QUERY) | \
     JOB_MASK(QEMU_JOB_DESTROY) | \
58
     JOB_MASK(QEMU_JOB_ABORT))
59

60
/* Jobs which have to be tracked in domain state XML. */
61
#define QEMU_DOMAIN_TRACK_JOBS \
62
    (JOB_MASK(QEMU_JOB_DESTROY) | \
63 64
     JOB_MASK(QEMU_JOB_ASYNC))

65 66 67
/* Only 1 job is allowed at any time
 * A job includes *all* monitor commands, even those just querying
 * information, not merely actions */
68
typedef enum {
69
    QEMU_JOB_NONE = 0,  /* Always set to 0 for easy if (jobActive) conditions */
70 71 72 73
    QEMU_JOB_QUERY,         /* Doesn't change any state */
    QEMU_JOB_DESTROY,       /* Destroys the domain (cannot be masked out) */
    QEMU_JOB_SUSPEND,       /* Suspends (stops vCPUs) the domain */
    QEMU_JOB_MODIFY,        /* May change state */
74
    QEMU_JOB_ABORT,         /* Abort current async job */
75
    QEMU_JOB_MIGRATION_OP,  /* Operation influencing outgoing migration */
76

77
    /* The following two items must always be the last items before JOB_LAST */
78 79
    QEMU_JOB_ASYNC,         /* Asynchronous job */
    QEMU_JOB_ASYNC_NESTED,  /* Normal job within an async job */
80 81

    QEMU_JOB_LAST
82
} qemuDomainJob;
83
VIR_ENUM_DECL(qemuDomainJob);
84

85 86 87 88 89 90 91
typedef enum {
    QEMU_AGENT_JOB_NONE = 0,    /* No agent job. */
    QEMU_AGENT_JOB_QUERY,       /* Does not change state of domain */
    QEMU_AGENT_JOB_MODIFY,      /* May change state of domain */

    QEMU_AGENT_JOB_LAST
} qemuDomainAgentJob;
92
VIR_ENUM_DECL(qemuDomainAgentJob);
93

94 95 96 97
/* Async job consists of a series of jobs that may change state. Independent
 * jobs that do not change state (and possibly others if explicitly allowed by
 * current async job) are allowed to be run even if async job is active.
 */
98
typedef enum {
99 100 101 102 103
    QEMU_ASYNC_JOB_NONE = 0,
    QEMU_ASYNC_JOB_MIGRATION_OUT,
    QEMU_ASYNC_JOB_MIGRATION_IN,
    QEMU_ASYNC_JOB_SAVE,
    QEMU_ASYNC_JOB_DUMP,
104
    QEMU_ASYNC_JOB_SNAPSHOT,
105
    QEMU_ASYNC_JOB_START,
106 107

    QEMU_ASYNC_JOB_LAST
108
} qemuDomainAsyncJob;
109
VIR_ENUM_DECL(qemuDomainAsyncJob);
110

111 112 113
typedef enum {
    QEMU_DOMAIN_JOB_STATUS_NONE = 0,
    QEMU_DOMAIN_JOB_STATUS_ACTIVE,
114
    QEMU_DOMAIN_JOB_STATUS_MIGRATING,
115
    QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED,
116
    QEMU_DOMAIN_JOB_STATUS_PAUSED,
117
    QEMU_DOMAIN_JOB_STATUS_POSTCOPY,
118 119 120 121 122
    QEMU_DOMAIN_JOB_STATUS_COMPLETED,
    QEMU_DOMAIN_JOB_STATUS_FAILED,
    QEMU_DOMAIN_JOB_STATUS_CANCELED,
} qemuDomainJobStatus;

123 124 125
typedef enum {
    QEMU_DOMAIN_JOB_STATS_TYPE_NONE = 0,
    QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION,
126
    QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP,
127
    QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP,
128 129
} qemuDomainJobStatsType;

130 131 132 133 134 135 136 137

typedef struct _qemuDomainMirrorStats qemuDomainMirrorStats;
typedef qemuDomainMirrorStats *qemuDomainMirrorStatsPtr;
struct _qemuDomainMirrorStats {
    unsigned long long transferred;
    unsigned long long total;
};

J
Jiri Denemark 已提交
138 139 140
typedef struct _qemuDomainJobInfo qemuDomainJobInfo;
typedef qemuDomainJobInfo *qemuDomainJobInfoPtr;
struct _qemuDomainJobInfo {
141
    qemuDomainJobStatus status;
142
    virDomainJobOperation operation;
J
Jiri Denemark 已提交
143
    unsigned long long started; /* When the async job started */
144
    unsigned long long stopped; /* When the domain's CPUs were stopped */
145 146 147 148
    unsigned long long sent; /* When the source sent status info to the
                                destination (only for migrations). */
    unsigned long long received; /* When the destination host received status
                                    info from the source (migrations only). */
J
Jiri Denemark 已提交
149 150
    /* Computed values */
    unsigned long long timeElapsed;
J
Jiri Denemark 已提交
151
    long long timeDelta; /* delta = received - sent, i.e., the difference
152 153 154 155 156
                            between the source and the destination time plus
                            the time between the end of Perform phase on the
                            source and the beginning of Finish phase on the
                            destination. */
    bool timeDeltaSet;
J
Jiri Denemark 已提交
157
    /* Raw values from QEMU */
158 159 160
    qemuDomainJobStatsType statsType;
    union {
        qemuMonitorMigrationStats mig;
161
        qemuMonitorDumpStats dump;
162
    } stats;
163
    qemuDomainMirrorStats mirrorStats;
J
Jiri Denemark 已提交
164 165
};

166 167 168
typedef struct _qemuDomainJobObj qemuDomainJobObj;
typedef qemuDomainJobObj *qemuDomainJobObjPtr;
struct _qemuDomainJobObj {
169
    virCond cond;                       /* Use to coordinate jobs */
170 171

    /* The following members are for QEMU_JOB_* */
172
    qemuDomainJob active;               /* Currently running job */
173
    unsigned long long owner;           /* Thread id which set current job */
174
    const char *ownerAPI;               /* The API which owns the job */
J
Jiri Denemark 已提交
175
    unsigned long long started;         /* When the current job started */
176

177 178 179 180 181 182 183
    /* The following members are for QEMU_AGENT_JOB_* */
    qemuDomainAgentJob agentActive;     /* Currently running agent job */
    unsigned long long agentOwner;      /* Thread id which set current agent job */
    const char *agentOwnerAPI;          /* The API which owns the agent job */
    unsigned long long agentStarted;    /* When the current agent job started */

    /* The following members are for QEMU_ASYNC_JOB_* */
184
    virCond asyncCond;                  /* Use to coordinate with async jobs */
185
    qemuDomainAsyncJob asyncJob;        /* Currently active async job */
186
    unsigned long long asyncOwner;      /* Thread which set current async job */
187
    const char *asyncOwnerAPI;          /* The API which owns the async job */
J
Jiri Denemark 已提交
188
    unsigned long long asyncStarted;    /* When the current async job started */
J
Jiri Denemark 已提交
189
    int phase;                          /* Job phase (mainly for migrations) */
190
    unsigned long long mask;            /* Jobs allowed during async job */
J
Jiri Denemark 已提交
191
    qemuDomainJobInfoPtr current;       /* async job progress data */
192
    qemuDomainJobInfoPtr completed;     /* statistics data of a recently completed job */
193
    bool abortJob;                      /* abort of the job requested */
194 195
    bool spiceMigration;                /* we asked for spice migration and we
                                         * should wait for it to finish */
196
    bool spiceMigrated;                 /* spice migration completed */
197 198
    char *error;                        /* job event completion error */
    bool dumpCompleted;                 /* dump completed */
199 200

    qemuMigrationParamsPtr migParams;
201
    unsigned long apiFlags; /* flags passed to the API which started the async job */
202 203
};

204
typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver,
205 206
                                          virDomainObjPtr vm);

207
#define QEMU_DOMAIN_MASTER_KEY_LEN 32  /* 32 bytes for 256 bit random key */
208

209
void qemuDomainSaveStatus(virDomainObjPtr obj);
210
void qemuDomainSaveConfig(virDomainObjPtr obj);
211

212 213 214 215 216 217 218 219 220 221 222 223 224

/* helper data types for async device unplug */
typedef enum {
    QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_NONE = 0,
    QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_OK,
    QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_GUEST_REJECTED,
} qemuDomainUnpluggingDeviceStatus;

typedef struct _qemuDomainUnpluggingDevice qemuDomainUnpluggingDevice;
typedef qemuDomainUnpluggingDevice *qemuDomainUnpluggingDevicePtr;
struct _qemuDomainUnpluggingDevice {
    const char *alias;
    qemuDomainUnpluggingDeviceStatus status;
225
    bool eventSeen; /* True if DEVICE_DELETED event arrived. */
226 227
};

228

229 230 231 232 233 234 235
#define QEMU_PROC_MOUNTS "/proc/mounts"
#define QEMU_DEVPREFIX "/dev/"
#define QEMU_DEV_VFIO "/dev/vfio/vfio"
#define QEMU_DEV_SEV "/dev/sev"
#define QEMU_DEVICE_MAPPER_CONTROL_PATH "/dev/mapper/control"


236 237 238 239
typedef enum {
    QEMU_DOMAIN_NS_MOUNT = 0,
    QEMU_DOMAIN_NS_LAST
} qemuDomainNamespace;
240
VIR_ENUM_DECL(qemuDomainNamespace);
241 242 243 244

bool qemuDomainNamespaceEnabled(virDomainObjPtr vm,
                                qemuDomainNamespace ns);

245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
/* Type of domain secret */
typedef enum {
    VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN = 0,
    VIR_DOMAIN_SECRET_INFO_TYPE_AES,  /* utilize GNUTLS_CIPHER_AES_256_CBC */

    VIR_DOMAIN_SECRET_INFO_TYPE_LAST
} qemuDomainSecretInfoType;

typedef struct _qemuDomainSecretPlain qemuDomainSecretPlain;
typedef struct _qemuDomainSecretPlain *qemuDomainSecretPlainPtr;
struct _qemuDomainSecretPlain {
    char *username;
    uint8_t *secret;
    size_t secretlen;
};

261 262
#define QEMU_DOMAIN_AES_IV_LEN 16   /* 16 bytes for 128 bit random */
                                    /*    initialization vector */
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
typedef struct _qemuDomainSecretAES qemuDomainSecretAES;
typedef struct _qemuDomainSecretAES *qemuDomainSecretAESPtr;
struct _qemuDomainSecretAES {
    char *username;
    char *alias;      /* generated alias for secret */
    char *iv;         /* base64 encoded initialization vector */
    char *ciphertext; /* encoded/encrypted secret */
};

typedef struct _qemuDomainSecretInfo qemuDomainSecretInfo;
typedef qemuDomainSecretInfo *qemuDomainSecretInfoPtr;
struct _qemuDomainSecretInfo {
    qemuDomainSecretInfoType type;
    union {
        qemuDomainSecretPlain plain;
        qemuDomainSecretAES aes;
    } s;
};

282 283 284
typedef struct _qemuDomainObjPrivate qemuDomainObjPrivate;
typedef qemuDomainObjPrivate *qemuDomainObjPrivatePtr;
struct _qemuDomainObjPrivate {
285 286
    virQEMUDriverPtr driver;

287
    qemuDomainJobObj job;
288

289 290
    virBitmapPtr namespaces;

291
    qemuMonitorPtr mon;
292
    virDomainChrSourceDefPtr monConfig;
293 294
    bool monError;
    unsigned long long monStart;
D
Daniel P. Berrange 已提交
295 296 297 298

    qemuAgentPtr agent;
    bool agentError;

299
    bool beingDestroyed;
300
    char *pidfile;
301

302
    virDomainPCIAddressSetPtr pciaddrs;
J
Ján Tomko 已提交
303
    virDomainUSBAddressSetPtr usbaddrs;
304

305
    virQEMUCapsPtr qemuCaps;
306
    char *lockState;
307 308

    bool fakeReboot;
309
    virTristateBool allowReboot;
310 311

    int jobs_queued;
312 313

    unsigned long migMaxBandwidth;
J
Jiri Denemark 已提交
314
    char *origname;
315
    int nbdPort; /* Port used for migration with NBD */
316
    unsigned short migrationPort;
317
    int preMigrationState;
318

319
    virChrdevsPtr devs;
320 321 322 323

    qemuDomainCleanupCallback *cleanupCallbacks;
    size_t ncleanupCallbacks;
    size_t ncleanupCallbacks_max;
324 325

    virCgroupPtr cgroup;
326

327 328
    virPerfPtr perf;

329 330
    qemuDomainUnpluggingDevice unplug;

331
    char **qemuDevices; /* NULL-terminated list of devices aliases known to QEMU */
332 333

    bool hookRun;  /* true if there was a hook run over this domain */
334 335

    /* Bitmaps below hold data from the auto NUMA feature */
336
    virBitmapPtr autoNodeset;
337
    virBitmapPtr autoCpuset;
338 339 340

    bool signalIOError; /* true if the domain condition should be signalled on
                           I/O error */
341 342
    bool signalStop; /* true if the domain condition should be signalled on
                        QMP STOP event */
343
    char *machineName;
344 345
    char *libDir;            /* base path for per-domain files */
    char *channelTargetDir;  /* base path for per-domain channel targets */
J
John Ferlan 已提交
346 347 348 349 350

    /* random masterKey and length for encryption (not to be saved in our */
    /* private XML) - need to restore at process reconnect */
    uint8_t *masterKey;
    size_t masterKeyLen;
351 352 353

    /* note whether memory device alias does not correspond to slot number */
    bool memAliasOrderMismatch;
354

355 356 357
    /* for migrations using TLS with a secret (not to be saved in our */
    /* private XML). */
    qemuDomainSecretInfoPtr migSecinfo;
358

359 360 361
    /* CPU def used to start the domain when it differs from the one actually
     * provided by QEMU. */
    virCPUDefPtr origCPU;
362 363 364

    /* If true virtlogd is used as stdio handler for character devices. */
    bool chardevStdioLogd;
365 366 367

    /* Tracks blockjob state for vm. Valid only while reconnecting to qemu. */
    virTristateBool reconnectBlockjobs;
368 369 370 371

    /* Migration capabilities. Rechecked on reconnect, not to be saved in
     * private XML. */
    virBitmapPtr migrationCaps;
372 373 374

    /* true if qemu-pr-helper process is running for the domain */
    bool prDaemonRunning;
375 376 377

    /* counter for generating node names for qemu disks */
    unsigned long long nodenameindex;
378 379 380 381

    /* qemuProcessStartCPUs stores the reason for starting vCPUs here for the
     * RESUME event handler to use it */
    virDomainRunningReason runningReason;
382

383 384 385 386
    /* qemuProcessStopCPUs stores the reason for pausing vCPUs here for the
     * STOP event handler to use it */
    virDomainPausedReason pausedReason;

387 388
    /* true if libvirt remembers the original owner for files */
    bool rememberOwner;
389 390 391

    /* true if global -mem-prealloc appears on cmd line */
    bool memPrealloc;
392 393 394

    /* running block jobs */
    virHashTablePtr blockjobs;
395 396
};

397
#define QEMU_DOMAIN_PRIVATE(vm) \
398
    ((qemuDomainObjPrivatePtr) (vm)->privateData)
399

400
#define QEMU_DOMAIN_DISK_PRIVATE(disk) \
401 402 403 404 405 406 407 408 409 410
    ((qemuDomainDiskPrivatePtr) (disk)->privateData)

typedef struct _qemuDomainDiskPrivate qemuDomainDiskPrivate;
typedef qemuDomainDiskPrivate *qemuDomainDiskPrivatePtr;
struct _qemuDomainDiskPrivate {
    virObject parent;

    /* ideally we want a smarter way to interlock block jobs on single qemu disk
     * in the future, but for now we just disallow any concurrent job on a
     * single disk */
411
    qemuBlockJobDataPtr blockjob;
412 413

    bool migrating; /* the disk is being migrated */
414
    virStorageSourcePtr migrSource; /* disk source object used for NBD migration */
415

416 417 418
    /* information about the device */
    bool tray; /* device has tray */
    bool removable; /* device media can be removed/changed */
419 420

    char *qomName; /* QOM path of the disk (also refers to the block backend) */
421
    char *nodeCopyOnRead; /* nodename of the disk-wide copy-on-read blockdev layer */
422 423
};

424
#define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
    ((qemuDomainStorageSourcePrivatePtr) (src)->privateData)

typedef struct _qemuDomainStorageSourcePrivate qemuDomainStorageSourcePrivate;
typedef qemuDomainStorageSourcePrivate *qemuDomainStorageSourcePrivatePtr;
struct _qemuDomainStorageSourcePrivate {
    virObject parent;

    /* data required for authentication to the storage source */
    qemuDomainSecretInfoPtr secinfo;

    /* data required for decryption of encrypted storage source */
    qemuDomainSecretInfoPtr encinfo;
};

virObjectPtr qemuDomainStorageSourcePrivateNew(void);

441 442 443 444 445
typedef struct _qemuDomainVcpuPrivate qemuDomainVcpuPrivate;
typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
struct _qemuDomainVcpuPrivate {
    virObject parent;

446
    pid_t tid; /* vcpu thread id */
447
    int enable_id; /* order in which the vcpus were enabled in qemu */
448
    int qemu_id; /* ID reported by qemu as 'CPU' in query-cpus */
449
    char *alias;
450
    virTristateBool halted;
451 452 453 454 455 456

    /* information for hotpluggable cpus */
    char *type;
    int socket_id;
    int core_id;
    int thread_id;
457
    int node_id;
458
    int vcpus;
459 460
};

461
#define QEMU_DOMAIN_VCPU_PRIVATE(vcpu) \
462 463 464
    ((qemuDomainVcpuPrivatePtr) (vcpu)->privateData)


465 466
struct qemuDomainDiskInfo {
    bool removable;
467
    bool tray;
468
    bool tray_open;
469
    bool empty;
470
    int io_status;
471
    char *nodename;
472 473
};

474
#define QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev) \
475
    ((qemuDomainChrSourcePrivatePtr) (dev)->privateData)
476

477 478 479
typedef struct _qemuDomainChrSourcePrivate qemuDomainChrSourcePrivate;
typedef qemuDomainChrSourcePrivate *qemuDomainChrSourcePrivatePtr;
struct _qemuDomainChrSourcePrivate {
480 481 482 483 484 485 486 487
    virObject parent;

    /* for char devices using secret
     * NB: *not* to be written to qemu domain object XML */
    qemuDomainSecretInfoPtr secinfo;
};


J
Ján Tomko 已提交
488 489 490 491 492
typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate;
typedef qemuDomainVsockPrivate *qemuDomainVsockPrivatePtr;
struct _qemuDomainVsockPrivate {
    virObject parent;

493
    int vhostfd;
J
Ján Tomko 已提交
494 495 496
};


497
#define QEMU_DOMAIN_GRAPHICS_PRIVATE(dev) \
498 499 500 501 502 503 504 505
    ((qemuDomainGraphicsPrivatePtr) (dev)->privateData)

typedef struct _qemuDomainGraphicsPrivate qemuDomainGraphicsPrivate;
typedef qemuDomainGraphicsPrivate *qemuDomainGraphicsPrivatePtr;
struct _qemuDomainGraphicsPrivate {
    virObject parent;

    char *tlsAlias;
506
    qemuDomainSecretInfoPtr secinfo;
507 508 509
};


C
Chen Fan 已提交
510 511
typedef enum {
    QEMU_PROCESS_EVENT_WATCHDOG = 0,
512
    QEMU_PROCESS_EVENT_GUESTPANIC,
513
    QEMU_PROCESS_EVENT_DEVICE_DELETED,
514
    QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED,
515
    QEMU_PROCESS_EVENT_SERIAL_CHANGED,
516
    QEMU_PROCESS_EVENT_BLOCK_JOB,
517
    QEMU_PROCESS_EVENT_JOB_STATUS_CHANGE,
518
    QEMU_PROCESS_EVENT_MONITOR_EOF,
519
    QEMU_PROCESS_EVENT_PR_DISCONNECT,
520
    QEMU_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED,
C
Chen Fan 已提交
521 522 523 524 525

    QEMU_PROCESS_EVENT_LAST
} qemuProcessEventType;

struct qemuProcessEvent {
526
    virDomainObjPtr vm;
C
Chen Fan 已提交
527
    qemuProcessEventType eventType;
528
    int action;
529
    int status;
530
    void *data;
531 532
};

533 534
void qemuProcessEventFree(struct qemuProcessEvent *event);

535 536 537
typedef struct _qemuDomainLogContext qemuDomainLogContext;
typedef qemuDomainLogContext *qemuDomainLogContextPtr;

538 539 540 541
typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
struct _qemuDomainSaveCookie {
    virObject parent;
542 543

    virCPUDefPtr cpu;
544 545
};

546 547 548 549 550 551 552 553 554 555

typedef struct _qemuDomainXmlNsDef qemuDomainXmlNsDef;
typedef qemuDomainXmlNsDef *qemuDomainXmlNsDefPtr;
struct _qemuDomainXmlNsDef {
    size_t num_args;
    char **args;

    unsigned int num_env;
    char **env_name;
    char **env_value;
556 557 558 559 560 561

    size_t ncapsadd;
    char **capsadd;

    size_t ncapsdel;
    char **capsdel;
562 563 564
};


565 566
qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);

567
const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
568
                                            int phase);
569
int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
570 571
                                      const char *phase);

572
void qemuDomainEventFlush(int timer, void *opaque);
573

574 575
void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm);
576

577
int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
578
                          virDomainObjPtr obj,
579
                          qemuDomainJob job)
580
    ATTRIBUTE_RETURN_CHECK;
581 582 583 584 585 586 587 588 589
int qemuDomainObjBeginAgentJob(virQEMUDriverPtr driver,
                               virDomainObjPtr obj,
                               qemuDomainAgentJob agentJob)
    ATTRIBUTE_RETURN_CHECK;
int qemuDomainObjBeginJobWithAgent(virQEMUDriverPtr driver,
                                   virDomainObjPtr obj,
                                   qemuDomainJob job,
                                   qemuDomainAgentJob agentJob)
    ATTRIBUTE_RETURN_CHECK;
590
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
591
                               virDomainObjPtr obj,
592
                               qemuDomainAsyncJob asyncJob,
593 594
                               virDomainJobOperation operation,
                               unsigned long apiFlags)
595
    ATTRIBUTE_RETURN_CHECK;
596 597 598 599
int qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver,
                                virDomainObjPtr obj,
                                qemuDomainAsyncJob asyncJob)
    ATTRIBUTE_RETURN_CHECK;
600 601 602 603
int qemuDomainObjBeginJobNowait(virQEMUDriverPtr driver,
                                virDomainObjPtr obj,
                                qemuDomainJob job)
    ATTRIBUTE_RETURN_CHECK;
604

605 606
void qemuDomainObjEndJob(virQEMUDriverPtr driver,
                         virDomainObjPtr obj);
607 608 609
void qemuDomainObjEndAgentJob(virDomainObjPtr obj);
void qemuDomainObjEndJobWithAgent(virQEMUDriverPtr driver,
                                  virDomainObjPtr obj);
610 611
void qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver,
                              virDomainObjPtr obj);
612
void qemuDomainObjAbortAsyncJob(virDomainObjPtr obj);
613
void qemuDomainObjSetJobPhase(virQEMUDriverPtr driver,
J
Jiri Denemark 已提交
614 615
                              virDomainObjPtr obj,
                              int phase);
616 617
void qemuDomainObjSetAsyncJobMask(virDomainObjPtr obj,
                                  unsigned long long allowedJobs);
618
void qemuDomainObjRestoreJob(virDomainObjPtr obj,
619
                             qemuDomainJobObjPtr job);
620
void qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver,
621
                                  virDomainObjPtr obj);
622
void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj);
623

624 625
qemuMonitorPtr qemuDomainGetMonitor(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);
626
void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
627 628
                               virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
629 630
int qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
                             virDomainObjPtr obj)
631 632
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
    ATTRIBUTE_RETURN_CHECK;
633
int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
634
                                   virDomainObjPtr obj,
635
                                   qemuDomainAsyncJob asyncJob)
636
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
D
Daniel P. Berrange 已提交
637 638


639
qemuAgentPtr qemuDomainObjEnterAgent(virDomainObjPtr obj)
640
    ATTRIBUTE_NONNULL(1);
641 642
void qemuDomainObjExitAgent(virDomainObjPtr obj, qemuAgentPtr agent)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
D
Daniel P. Berrange 已提交
643 644


645 646
void qemuDomainObjEnterRemote(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
647 648 649
int qemuDomainObjExitRemote(virDomainObjPtr obj,
                            bool checkActive)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
650

651
virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
652
                                  virQEMUCapsPtr qemuCaps,
653 654 655
                                  virDomainDefPtr src,
                                  unsigned int flags);

656
int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
657
                           virQEMUCapsPtr qemuCaps,
658 659 660 661
                           virDomainDefPtr vm,
                           unsigned int flags,
                           virBuffer *buf);

662
char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
663
                             virQEMUCapsPtr qemuCaps,
664
                             virDomainDefPtr vm,
665
                             unsigned int flags);
666

667
char *qemuDomainFormatXML(virQEMUDriverPtr driver,
668
                          virDomainObjPtr vm,
669
                          unsigned int flags);
670

671
char *qemuDomainDefFormatLive(virQEMUDriverPtr driver,
672
                              virQEMUCapsPtr qemuCaps,
673
                              virDomainDefPtr def,
674
                              virCPUDefPtr origCPU,
675 676
                              bool inactive,
                              bool compatible);
677

678
void qemuDomainObjTaint(virQEMUDriverPtr driver,
679
                        virDomainObjPtr obj,
680
                        virDomainTaintFlags taint,
681
                        qemuDomainLogContextPtr logCtxt);
682

683
void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
684
                             virDomainObjPtr obj,
685
                             qemuDomainLogContextPtr logCtxt);
686
void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver,
687
                                 virDomainObjPtr obj,
688
                                 virDomainDiskDefPtr disk,
689
                                 qemuDomainLogContextPtr logCtxt);
690 691 692
void qemuDomainObjCheckHostdevTaint(virQEMUDriverPtr driver,
                                    virDomainObjPtr obj,
                                    virDomainHostdevDefPtr disk,
693
                                    qemuDomainLogContextPtr logCtxt);
694
void qemuDomainObjCheckNetTaint(virQEMUDriverPtr driver,
695
                                virDomainObjPtr obj,
696
                                virDomainNetDefPtr net,
697
                                qemuDomainLogContextPtr logCtxt);
698

699 700 701 702 703 704 705 706 707 708 709 710 711 712 713
typedef enum {
    QEMU_DOMAIN_LOG_CONTEXT_MODE_START,
    QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH,
    QEMU_DOMAIN_LOG_CONTEXT_MODE_STOP,
} qemuDomainLogContextMode;

qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver,
                                                virDomainObjPtr vm,
                                                qemuDomainLogContextMode mode);
int qemuDomainLogContextWrite(qemuDomainLogContextPtr ctxt,
                              const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(2, 3);
ssize_t qemuDomainLogContextRead(qemuDomainLogContextPtr ctxt,
                                 char **msg);
int qemuDomainLogContextGetWriteFD(qemuDomainLogContextPtr ctxt);
void qemuDomainLogContextMarkPosition(qemuDomainLogContextPtr ctxt);
714

715 716
virLogManagerPtr qemuDomainLogContextGetManager(qemuDomainLogContextPtr ctxt);

717 718 719 720 721
int qemuDomainLogAppendMessage(virQEMUDriverPtr driver,
                               virDomainObjPtr vm,
                               const char *fmt,
                               ...) ATTRIBUTE_FMT_PRINTF(3, 4);

722
const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
723 724

int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
725
                                    virDomainMomentObjPtr snapshot,
726
                                    virCapsPtr caps,
727
                                    virDomainXMLOptionPtr xmlopt,
728
                                    const char *snapshotDir);
729

730
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
731
                                   virDomainObjPtr vm,
732
                                   virDomainMomentObjPtr snap,
733 734 735
                                   const char *op,
                                   bool try_all);

736
int qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
737
                              virDomainObjPtr vm,
738
                              virDomainMomentObjPtr snap,
739 740 741
                              bool update_current,
                              bool metadata_only);

742 743 744
typedef struct _virQEMUMomentRemove virQEMUMomentRemove;
typedef virQEMUMomentRemove *virQEMUMomentRemovePtr;
struct _virQEMUMomentRemove {
745
    virQEMUDriverPtr driver;
746 747 748
    virDomainObjPtr vm;
    int err;
    bool metadata_only;
749 750 751 752
    virDomainMomentObjPtr current;
    bool found;
    int (*momentDiscard)(virQEMUDriverPtr, virDomainObjPtr,
                         virDomainMomentObjPtr, bool, bool);
753 754
};

755 756 757
int qemuDomainMomentDiscardAll(void *payload,
                               const void *name,
                               void *data);
758

759
int qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
760 761
                                         virDomainObjPtr vm);

762 763 764 765 766 767 768 769 770 771 772 773 774 775 776
int qemuDomainCheckpointWriteMetadata(virDomainObjPtr vm,
                                      virDomainMomentObjPtr checkpoint,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      const char *checkpointDir);

int qemuDomainCheckpointDiscard(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                virDomainMomentObjPtr chk,
                                bool update_current,
                                bool metadata_only);

int qemuDomainCheckpointDiscardAllMetadata(virQEMUDriverPtr driver,
                                           virDomainObjPtr vm);

777
void qemuDomainRemoveInactive(virQEMUDriverPtr driver,
778 779
                              virDomainObjPtr vm);

780 781 782
void qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

783 784 785
void qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver,
                                       virDomainObjPtr vm);

786
void qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
787 788 789
                             virDomainObjPtr vm,
                             bool value);

790
bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv,
791
                          qemuDomainJob job);
M
Michal Privoznik 已提交
792

793 794 795 796 797
int qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     size_t diskIndex,
                                     bool cold_boot);

798
int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
M
Michal Privoznik 已提交
799
                                virDomainObjPtr vm,
800
                                unsigned int flags);
801

802
int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
803
                                 virDomainObjPtr vm,
804
                                 virDomainDiskDefPtr disk,
805
                                 virStorageSourcePtr disksrc,
806
                                 bool report_broken);
807

808 809 810
bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
                                   virDomainDiskDefPtr orig_disk);

811 812 813
const char *qemuDomainDiskNodeFormatLookup(virDomainObjPtr vm,
                                           const char *disk);

814 815
int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
816 817
                              virStorageSourcePtr src,
                              virStorageSourcePtr parent);
818
char *qemuDomainStorageAlias(const char *device, int depth);
819

820 821 822 823 824 825
int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
                                  virQEMUCapsPtr qemuCaps,
                                  char **backendAlias)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;

826 827 828 829 830 831
int qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
                                            virDomainObjPtr vm,
                                            virStorageSourcePtr src);
int qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
                                             virDomainObjPtr vm,
                                             virStorageSourcePtr src);
832

833 834 835 836 837 838 839 840
void qemuDomainStorageSourceAccessRevoke(virQEMUDriverPtr driver,
                                         virDomainObjPtr vm,
                                         virStorageSourcePtr elem);
int qemuDomainStorageSourceAccessAllow(virQEMUDriverPtr driver,
                                       virDomainObjPtr vm,
                                       virStorageSourcePtr elem,
                                       bool readonly,
                                       bool newSource);
841

842 843 844 845 846
int qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
                                           virStorageSourcePtr src,
                                           qemuDomainObjPrivatePtr priv,
                                           virQEMUDriverConfigPtr cfg);

847 848 849 850
int qemuDomainCleanupAdd(virDomainObjPtr vm,
                         qemuDomainCleanupCallback cb);
void qemuDomainCleanupRemove(virDomainObjPtr vm,
                             qemuDomainCleanupCallback cb);
851
void qemuDomainCleanupRun(virQEMUDriverPtr driver,
852 853
                          virDomainObjPtr vm);

854 855
void qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv);

856 857
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
858
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
859
extern virDomainABIStability virQEMUDriverDomainABIStability;
860
extern virSaveCookieCallbacks virQEMUDriverDomainSaveCookie;
861

862
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
863
                               virDomainObjPtr vm, int asyncJob);
864

865 866 867 868
int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     int asyncJob);

869
bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
870
                                    virQEMUCapsPtr qemuCaps,
871 872
                                    virDomainDefPtr src,
                                    virDomainDefPtr dst);
873

874 875 876 877
bool qemuDomainCheckABIStability(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm,
                                 virDomainDefPtr dst);

878
bool qemuDomainAgentAvailable(virDomainObjPtr vm,
879 880
                              bool reportError);

J
Jiri Denemark 已提交
881 882
int qemuDomainJobInfoUpdateTime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
883 884
int qemuDomainJobInfoUpdateDowntime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
J
Jiri Denemark 已提交
885 886 887 888 889 890 891 892 893 894
int qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
                            virDomainJobInfoPtr info)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
                              int *type,
                              virTypedParameterPtr *params,
                              int *nparams)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

895
bool qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk);
896 897
bool qemuDomainHasBlockjob(virDomainObjPtr vm, bool copy_only)
    ATTRIBUTE_NONNULL(1);
898

899
int qemuDomainAlignMemorySizes(virDomainDefPtr def);
900 901
void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem);
902

903
virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
904

905 906
/* You should normally avoid these functions and use the variant that
 * doesn't have "Machine" in the name instead. */
907 908
bool qemuDomainMachineIsARMVirt(const char *machine,
                                const virArch arch);
909 910
bool qemuDomainMachineIsPSeries(const char *machine,
                                const virArch arch);
911 912
bool qemuDomainMachineHasBuiltinIDE(const char *machine,
                                    const virArch arch);
A
Andrea Bolognani 已提交
913 914 915 916 917 918 919 920 921 922 923

bool qemuDomainIsQ35(const virDomainDef *def);
bool qemuDomainIsI440FX(const virDomainDef *def);
bool qemuDomainIsS390CCW(const virDomainDef *def);
bool qemuDomainIsARMVirt(const virDomainDef *def);
bool qemuDomainIsRISCVVirt(const virDomainDef *def);
bool qemuDomainIsPSeries(const virDomainDef *def);
bool qemuDomainHasPCIRoot(const virDomainDef *def);
bool qemuDomainHasPCIeRoot(const virDomainDef *def);
bool qemuDomainHasBuiltinIDE(const virDomainDef *def);
bool qemuDomainNeedsFDC(const virDomainDef *def);
924 925
bool qemuDomainSupportsPCI(virDomainDefPtr def,
                           virQEMUCapsPtr qemuCaps);
926

927
void qemuDomainUpdateCurrentMemorySize(virDomainObjPtr vm);
928

929
unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDefPtr def);
930
int qemuDomainAdjustMaxMemLock(virDomainObjPtr vm);
931

932 933 934 935
int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
                                       virQEMUCapsPtr qemuCaps,
                                       const virDomainMemoryDef *mem);

936
bool qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm);
937
bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
938
pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid);
939
int qemuDomainValidateVcpuInfo(virDomainObjPtr vm);
940 941
int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
942 943
                              int asyncJob,
                              bool state);
944 945 946 947
bool qemuDomainGetVcpuHalted(virDomainObjPtr vm, unsigned int vcpu);
int qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                int asyncJob);
948

949 950 951
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
                              virDomainNetDefPtr net);

952 953
bool qemuDomainNetSupportsMTU(virDomainNetType type);

954 955 956
int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

P
Peter Krempa 已提交
957 958
virDomainDiskDefPtr qemuDomainDiskByName(virDomainDefPtr def, const char *name);

J
John Ferlan 已提交
959 960 961 962
char *qemuDomainGetMasterKeyFilePath(const char *libDir);

int qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv);

963 964 965 966
int qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

int qemuDomainMasterKeyCreate(virDomainObjPtr vm);
J
John Ferlan 已提交
967 968 969

void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);

970 971
bool qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivatePtr priv);

972 973 974
void qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
    ATTRIBUTE_NONNULL(1);

975 976
void qemuDomainSecretInfoDestroy(qemuDomainSecretInfoPtr secinfo);

977 978 979
void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
    ATTRIBUTE_NONNULL(1);

980
bool qemuDomainStorageSourceHasAuth(virStorageSourcePtr src)
981 982
    ATTRIBUTE_NONNULL(1);

983 984 985
bool qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
    ATTRIBUTE_NONNULL(1);

986
qemuDomainSecretInfoPtr
987
qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr priv,
988 989 990
                           const char *srcAlias,
                           const char *secretUUID);

991 992 993
void qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr disk)
    ATTRIBUTE_NONNULL(1);

994
int qemuDomainSecretHostdevPrepare(qemuDomainObjPrivatePtr priv,
995
                                   virDomainHostdevDefPtr hostdev)
996
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
997

998 999 1000
void qemuDomainSecretChardevDestroy(virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1);

1001
int qemuDomainSecretChardevPrepare(virQEMUDriverConfigPtr cfg,
1002 1003 1004 1005
                                   qemuDomainObjPrivatePtr priv,
                                   const char *chrAlias,
                                   virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
1006
    ATTRIBUTE_NONNULL(4);
1007

1008 1009 1010
void qemuDomainSecretDestroy(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);

1011
int qemuDomainSecretPrepare(virQEMUDriverPtr driver,
1012
                            virDomainObjPtr vm)
1013
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
1014

1015 1016 1017
int qemuDomainDefValidateDiskLunSource(const virStorageSource *src)
    ATTRIBUTE_NONNULL(1);

1018 1019 1020
int qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk,
                                    virQEMUCapsPtr qemuCaps);

1021 1022 1023 1024
int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
                             const char *domainChannelTargetDir)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

1025 1026 1027 1028 1029
void qemuDomainPrepareChardevSourceTLS(virDomainChrSourceDefPtr source,
                                       virQEMUDriverConfigPtr cfg)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void qemuDomainPrepareChardevSource(virDomainDefPtr def,
1030
                                    virQEMUDriverConfigPtr cfg)
1031 1032
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

1033 1034 1035
int qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1);

1036 1037 1038
bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

1039 1040 1041
void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

1042 1043 1044 1045
int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
                           virDomainObjPtr vm,
                           qemuDomainAsyncJob asyncJob);

1046 1047 1048
bool qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
                                virQEMUCapsPtr qemuCaps);

1049 1050 1051
int qemuDomainGetHostdevPath(virDomainDefPtr def,
                             virDomainHostdevDefPtr dev,
                             bool teardown,
1052 1053 1054
                             size_t *npaths,
                             char ***path,
                             int **perms);
1055

1056 1057
int qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
                             virSecurityManagerPtr mgr,
1058 1059 1060 1061 1062
                             virDomainObjPtr vm);

int qemuDomainCreateNamespace(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

1063 1064 1065
void qemuDomainDestroyNamespace(virQEMUDriverPtr driver,
                                virDomainObjPtr vm);

1066 1067
bool qemuDomainNamespaceAvailable(qemuDomainNamespace ns);

1068
int qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
1069
                                 virStorageSourcePtr src);
1070

1071
int qemuDomainNamespaceTeardownDisk(virDomainObjPtr vm,
1072
                                    virStorageSourcePtr src);
1073

1074
int qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm,
1075 1076
                                    virDomainHostdevDefPtr hostdev);

1077
int qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
1078
                                       virDomainHostdevDefPtr hostdev);
1079

1080
int qemuDomainNamespaceSetupMemory(virDomainObjPtr vm,
M
Michal Privoznik 已提交
1081 1082
                                   virDomainMemoryDefPtr memory);

1083
int qemuDomainNamespaceTeardownMemory(virDomainObjPtr vm,
M
Michal Privoznik 已提交
1084 1085
                                      virDomainMemoryDefPtr memory);

1086
int qemuDomainNamespaceSetupChardev(virDomainObjPtr vm,
1087 1088
                                    virDomainChrDefPtr chr);

1089
int qemuDomainNamespaceTeardownChardev(virDomainObjPtr vm,
1090
                                       virDomainChrDefPtr chr);
1091

1092
int qemuDomainNamespaceSetupRNG(virDomainObjPtr vm,
1093
                                virDomainRNGDefPtr rng);
1094

1095
int qemuDomainNamespaceTeardownRNG(virDomainObjPtr vm,
1096
                                   virDomainRNGDefPtr rng);
1097

1098 1099 1100 1101 1102 1103
int qemuDomainNamespaceSetupInput(virDomainObjPtr vm,
                                  virDomainInputDefPtr input);

int qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
                                     virDomainInputDefPtr input);

1104 1105 1106 1107 1108
virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def,
                                                   const char *nodename,
                                                   virStorageSourcePtr *src,
                                                   unsigned int *idx);

1109 1110 1111 1112
char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
                                        virStorageSourcePtr src,
                                        unsigned int idx);

1113 1114 1115
virStorageSourcePtr qemuDomainGetStorageSourceByDevstr(const char *devstr,
                                                       virDomainDefPtr def);

1116 1117 1118 1119 1120
int
qemuDomainUpdateCPU(virDomainObjPtr vm,
                    virCPUDefPtr cpu,
                    virCPUDefPtr *origCPU);

1121 1122 1123 1124
int
qemuDomainFixupCPUs(virDomainObjPtr vm,
                    virCPUDefPtr *origCPU);

1125 1126 1127 1128
int
qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
                         virFileCachePtr qemuCapsCache);

1129 1130 1131
char *
qemuDomainGetMachineName(virDomainObjPtr vm);

1132 1133 1134 1135 1136 1137 1138 1139
void
qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf,
                                         virTristateBool allowReboot);

int
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
                                        virTristateBool *allowReboot);

1140 1141 1142 1143 1144
bool
qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
                                     const virDomainDeviceInfo *info,
                                     virQEMUCapsPtr qemuCaps,
                                     const char *devicename);
1145

1146
int
1147 1148 1149 1150
qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
                                virStorageSourcePtr src,
                                virQEMUDriverConfigPtr cfg,
                                virQEMUCapsPtr qemuCaps)
1151
    ATTRIBUTE_RETURN_CHECK;
1152

1153 1154 1155 1156 1157 1158

int
qemuDomainValidateStorageSource(virStorageSourcePtr src,
                                virQEMUCapsPtr qemuCaps);


1159
int
1160
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
1161 1162 1163
                            qemuDomainObjPrivatePtr priv,
                            virQEMUDriverConfigPtr cfg);

1164 1165 1166 1167 1168 1169
int
qemuDomainDiskCachemodeFlags(int cachemode,
                             bool *writeback,
                             bool *direct,
                             bool *noflush);

1170
char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);
1171

1172 1173
bool qemuDomainDefHasManagedPR(virDomainObjPtr vm);

1174 1175 1176
unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivatePtr priv);
void qemuDomainStorageIdReset(qemuDomainObjPrivatePtr priv);

1177 1178 1179
virDomainEventResumedDetailType
qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);

J
John Ferlan 已提交
1180 1181 1182
bool
qemuDomainIsUsingNoShutdown(qemuDomainObjPrivatePtr priv);

1183 1184 1185
bool
qemuDomainDiskIsMissingLocalOptional(virDomainDiskDefPtr disk);

1186 1187 1188 1189
int
qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg,
                            virDomainDefPtr def);

1190 1191
virDomainEventSuspendedDetailType
qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason);