qemu_domain.h 44.6 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
#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"
36
#include "qemu_slirp.h"
37 38 39 40 41 42 43 44
#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 \
45
    (VIR_DOMAIN_XML_SECURE)
46

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

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

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

66 67 68
/* Only 1 job is allowed at any time
 * A job includes *all* monitor commands, even those just querying
 * information, not merely actions */
69
typedef enum {
70
    QEMU_JOB_NONE = 0,  /* Always set to 0 for easy if (jobActive) conditions */
71 72 73 74
    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 */
75
    QEMU_JOB_ABORT,         /* Abort current async job */
76
    QEMU_JOB_MIGRATION_OP,  /* Operation influencing outgoing migration */
77

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

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

86 87 88 89 90 91 92
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;
93
VIR_ENUM_DECL(qemuDomainAgentJob);
94

95 96 97 98
/* 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.
 */
99
typedef enum {
100 101 102 103 104
    QEMU_ASYNC_JOB_NONE = 0,
    QEMU_ASYNC_JOB_MIGRATION_OUT,
    QEMU_ASYNC_JOB_MIGRATION_IN,
    QEMU_ASYNC_JOB_SAVE,
    QEMU_ASYNC_JOB_DUMP,
105
    QEMU_ASYNC_JOB_SNAPSHOT,
106
    QEMU_ASYNC_JOB_START,
107 108

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

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

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

131 132 133 134 135 136 137 138

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

J
Jiri Denemark 已提交
139 140 141
typedef struct _qemuDomainJobInfo qemuDomainJobInfo;
typedef qemuDomainJobInfo *qemuDomainJobInfoPtr;
struct _qemuDomainJobInfo {
142
    qemuDomainJobStatus status;
143
    virDomainJobOperation operation;
J
Jiri Denemark 已提交
144
    unsigned long long started; /* When the async job started */
145
    unsigned long long stopped; /* When the domain's CPUs were stopped */
146 147 148 149
    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 已提交
150 151
    /* Computed values */
    unsigned long long timeElapsed;
J
Jiri Denemark 已提交
152
    long long timeDelta; /* delta = received - sent, i.e., the difference
153 154 155 156 157
                            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 已提交
158
    /* Raw values from QEMU */
159 160 161
    qemuDomainJobStatsType statsType;
    union {
        qemuMonitorMigrationStats mig;
162
        qemuMonitorDumpStats dump;
163
    } stats;
164
    qemuDomainMirrorStats mirrorStats;
J
Jiri Denemark 已提交
165 166
};

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

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

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

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

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

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

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

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

/* 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;
226
    bool eventSeen; /* True if DEVICE_DELETED event arrived. */
227 228
};

229

230 231 232 233 234 235 236
#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"


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

bool qemuDomainNamespaceEnabled(virDomainObjPtr vm,
                                qemuDomainNamespace ns);

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
/* 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;
};

262 263
#define QEMU_DOMAIN_AES_IV_LEN 16   /* 16 bytes for 128 bit random */
                                    /*    initialization vector */
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
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;
};

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

288
    qemuDomainJobObj job;
289

290 291
    virBitmapPtr namespaces;

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

    qemuAgentPtr agent;
    bool agentError;

301
    bool beingDestroyed;
302
    char *pidfile;
303

304
    virDomainPCIAddressSetPtr pciaddrs;
J
Ján Tomko 已提交
305
    virDomainUSBAddressSetPtr usbaddrs;
306

307
    virQEMUCapsPtr qemuCaps;
308
    char *lockState;
309 310

    bool fakeReboot;
311
    virTristateBool allowReboot;
312 313

    int jobs_queued;
314 315

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

321
    virChrdevsPtr devs;
322 323 324 325

    qemuDomainCleanupCallback *cleanupCallbacks;
    size_t ncleanupCallbacks;
    size_t ncleanupCallbacks_max;
326 327

    virCgroupPtr cgroup;
328

329 330
    virPerfPtr perf;

331 332
    qemuDomainUnpluggingDevice unplug;

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

    bool hookRun;  /* true if there was a hook run over this domain */
336 337

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

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

    /* 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;
353 354 355

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

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

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

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

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

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

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

    /* counter for generating node names for qemu disks */
    unsigned long long nodenameindex;
380 381 382 383

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

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

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

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

    /* running block jobs */
    virHashTablePtr blockjobs;
M
Marc-André Lureau 已提交
397 398

    virHashTablePtr dbusVMStates;
399
    bool disableSlirp;
400 401
};

402
#define QEMU_DOMAIN_PRIVATE(vm) \
403
    ((qemuDomainObjPrivatePtr) (vm)->privateData)
404

405
#define QEMU_DOMAIN_DISK_PRIVATE(disk) \
406 407 408 409 410 411 412 413 414 415
    ((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 */
416
    qemuBlockJobDataPtr blockjob;
417 418

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

421 422 423
    /* information about the device */
    bool tray; /* device has tray */
    bool removable; /* device media can be removed/changed */
424 425

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

429
#define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
    ((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);

446 447 448 449 450
typedef struct _qemuDomainVcpuPrivate qemuDomainVcpuPrivate;
typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
struct _qemuDomainVcpuPrivate {
    virObject parent;

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

457 458 459
    /* copy of the data that qemu returned */
    virJSONValuePtr props;

460 461 462 463 464
    /* information for hotpluggable cpus */
    char *type;
    int socket_id;
    int core_id;
    int thread_id;
465
    int node_id;
466
    int vcpus;
467 468
};

469
#define QEMU_DOMAIN_VCPU_PRIVATE(vcpu) \
470 471 472
    ((qemuDomainVcpuPrivatePtr) (vcpu)->privateData)


473 474
struct qemuDomainDiskInfo {
    bool removable;
475
    bool tray;
476
    bool tray_open;
477
    bool empty;
478
    int io_status;
479
    char *nodename;
480 481
};

482
#define QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev) \
483
    ((qemuDomainChrSourcePrivatePtr) (dev)->privateData)
484

485 486 487
typedef struct _qemuDomainChrSourcePrivate qemuDomainChrSourcePrivate;
typedef qemuDomainChrSourcePrivate *qemuDomainChrSourcePrivatePtr;
struct _qemuDomainChrSourcePrivate {
488 489 490 491 492 493 494 495
    virObject parent;

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


J
Ján Tomko 已提交
496 497 498 499 500
typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate;
typedef qemuDomainVsockPrivate *qemuDomainVsockPrivatePtr;
struct _qemuDomainVsockPrivate {
    virObject parent;

501
    int vhostfd;
J
Ján Tomko 已提交
502 503 504
};


505 506 507 508 509 510 511 512
#define QEMU_DOMAIN_VIDEO_PRIVATE(dev) \
    ((qemuDomainVideoPrivatePtr) (dev)->privateData)

typedef struct _qemuDomainVideoPrivate qemuDomainVideoPrivate;
typedef qemuDomainVideoPrivate *qemuDomainVideoPrivatePtr;
struct _qemuDomainVideoPrivate {
    virObject parent;

513
    int vhost_user_fd;
514 515 516
};


517
#define QEMU_DOMAIN_GRAPHICS_PRIVATE(dev) \
518 519 520 521 522 523 524 525
    ((qemuDomainGraphicsPrivatePtr) (dev)->privateData)

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

    char *tlsAlias;
526
    qemuDomainSecretInfoPtr secinfo;
527 528 529
};


530 531 532 533 534 535 536 537
#define QEMU_DOMAIN_NETWORK_PRIVATE(dev) \
    ((qemuDomainNetworkPrivatePtr) (dev)->privateData)

typedef struct _qemuDomainNetworkPrivate qemuDomainNetworkPrivate;
typedef qemuDomainNetworkPrivate *qemuDomainNetworkPrivatePtr;
struct _qemuDomainNetworkPrivate {
    virObject parent;

538
    qemuSlirpPtr slirp;
539 540 541
};


C
Chen Fan 已提交
542 543
typedef enum {
    QEMU_PROCESS_EVENT_WATCHDOG = 0,
544
    QEMU_PROCESS_EVENT_GUESTPANIC,
545
    QEMU_PROCESS_EVENT_DEVICE_DELETED,
546
    QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED,
547
    QEMU_PROCESS_EVENT_SERIAL_CHANGED,
548
    QEMU_PROCESS_EVENT_BLOCK_JOB,
549
    QEMU_PROCESS_EVENT_JOB_STATUS_CHANGE,
550
    QEMU_PROCESS_EVENT_MONITOR_EOF,
551
    QEMU_PROCESS_EVENT_PR_DISCONNECT,
552
    QEMU_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED,
C
Chen Fan 已提交
553 554 555 556 557

    QEMU_PROCESS_EVENT_LAST
} qemuProcessEventType;

struct qemuProcessEvent {
558
    virDomainObjPtr vm;
C
Chen Fan 已提交
559
    qemuProcessEventType eventType;
560
    int action;
561
    int status;
562
    void *data;
563 564
};

565 566
void qemuProcessEventFree(struct qemuProcessEvent *event);

567 568 569
typedef struct _qemuDomainLogContext qemuDomainLogContext;
typedef qemuDomainLogContext *qemuDomainLogContextPtr;

570 571 572 573
typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
struct _qemuDomainSaveCookie {
    virObject parent;
574 575

    virCPUDefPtr cpu;
576
    bool slirpHelper;
577 578
};

579 580 581 582 583 584 585 586 587 588

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;
589 590 591 592 593 594

    size_t ncapsadd;
    char **capsadd;

    size_t ncapsdel;
    char **capsdel;
595 596
};

597
virDomainObjPtr qemuDomainObjFromDomain(virDomainPtr domain);
598

599 600
qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);

601
const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
602
                                            int phase);
603
int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
604 605
                                      const char *phase);

606
void qemuDomainEventFlush(int timer, void *opaque);
607

608 609
void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm);
610

611
int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
612
                          virDomainObjPtr obj,
613
                          qemuDomainJob job)
614
    G_GNUC_WARN_UNUSED_RESULT;
615 616 617
int qemuDomainObjBeginAgentJob(virQEMUDriverPtr driver,
                               virDomainObjPtr obj,
                               qemuDomainAgentJob agentJob)
618
    G_GNUC_WARN_UNUSED_RESULT;
619 620 621 622
int qemuDomainObjBeginJobWithAgent(virQEMUDriverPtr driver,
                                   virDomainObjPtr obj,
                                   qemuDomainJob job,
                                   qemuDomainAgentJob agentJob)
623
    G_GNUC_WARN_UNUSED_RESULT;
624
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
625
                               virDomainObjPtr obj,
626
                               qemuDomainAsyncJob asyncJob,
627 628
                               virDomainJobOperation operation,
                               unsigned long apiFlags)
629
    G_GNUC_WARN_UNUSED_RESULT;
630 631 632
int qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver,
                                virDomainObjPtr obj,
                                qemuDomainAsyncJob asyncJob)
633
    G_GNUC_WARN_UNUSED_RESULT;
634 635 636
int qemuDomainObjBeginJobNowait(virQEMUDriverPtr driver,
                                virDomainObjPtr obj,
                                qemuDomainJob job)
637
    G_GNUC_WARN_UNUSED_RESULT;
638

639 640
void qemuDomainObjEndJob(virQEMUDriverPtr driver,
                         virDomainObjPtr obj);
641 642 643
void qemuDomainObjEndAgentJob(virDomainObjPtr obj);
void qemuDomainObjEndJobWithAgent(virQEMUDriverPtr driver,
                                  virDomainObjPtr obj);
644 645
void qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver,
                              virDomainObjPtr obj);
646
void qemuDomainObjAbortAsyncJob(virDomainObjPtr obj);
647
void qemuDomainObjSetJobPhase(virQEMUDriverPtr driver,
J
Jiri Denemark 已提交
648 649
                              virDomainObjPtr obj,
                              int phase);
650 651
void qemuDomainObjSetAsyncJobMask(virDomainObjPtr obj,
                                  unsigned long long allowedJobs);
652
void qemuDomainObjRestoreJob(virDomainObjPtr obj,
653
                             qemuDomainJobObjPtr job);
654
void qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver,
655
                                  virDomainObjPtr obj);
656
void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj);
657

658 659
qemuMonitorPtr qemuDomainGetMonitor(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);
660
void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
661 662
                               virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
663 664
int qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
                             virDomainObjPtr obj)
665
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
666
    G_GNUC_WARN_UNUSED_RESULT;
667
int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
668
                                   virDomainObjPtr obj,
669
                                   qemuDomainAsyncJob asyncJob)
670
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
D
Daniel P. Berrange 已提交
671 672


673
qemuAgentPtr qemuDomainObjEnterAgent(virDomainObjPtr obj)
674
    ATTRIBUTE_NONNULL(1);
675 676
void qemuDomainObjExitAgent(virDomainObjPtr obj, qemuAgentPtr agent)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
D
Daniel P. Berrange 已提交
677 678


679 680
void qemuDomainObjEnterRemote(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
681 682
int qemuDomainObjExitRemote(virDomainObjPtr obj,
                            bool checkActive)
683
    ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
684

685
virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
686
                                  virQEMUCapsPtr qemuCaps,
687 688 689
                                  virDomainDefPtr src,
                                  unsigned int flags);

690
int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
691
                           virQEMUCapsPtr qemuCaps,
692 693 694 695
                           virDomainDefPtr vm,
                           unsigned int flags,
                           virBuffer *buf);

696
char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
697
                             virQEMUCapsPtr qemuCaps,
698
                             virDomainDefPtr vm,
699
                             unsigned int flags);
700

701
char *qemuDomainFormatXML(virQEMUDriverPtr driver,
702
                          virDomainObjPtr vm,
703
                          unsigned int flags);
704

705
char *qemuDomainDefFormatLive(virQEMUDriverPtr driver,
706
                              virQEMUCapsPtr qemuCaps,
707
                              virDomainDefPtr def,
708
                              virCPUDefPtr origCPU,
709 710
                              bool inactive,
                              bool compatible);
711

712
void qemuDomainObjTaint(virQEMUDriverPtr driver,
713
                        virDomainObjPtr obj,
714
                        virDomainTaintFlags taint,
715
                        qemuDomainLogContextPtr logCtxt);
716

717
void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
718
                             virDomainObjPtr obj,
719
                             qemuDomainLogContextPtr logCtxt);
720
void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver,
721
                                 virDomainObjPtr obj,
722
                                 virDomainDiskDefPtr disk,
723
                                 qemuDomainLogContextPtr logCtxt);
724 725 726
void qemuDomainObjCheckHostdevTaint(virQEMUDriverPtr driver,
                                    virDomainObjPtr obj,
                                    virDomainHostdevDefPtr disk,
727
                                    qemuDomainLogContextPtr logCtxt);
728
void qemuDomainObjCheckNetTaint(virQEMUDriverPtr driver,
729
                                virDomainObjPtr obj,
730
                                virDomainNetDefPtr net,
731
                                qemuDomainLogContextPtr logCtxt);
732

733 734 735 736 737 738 739 740 741 742
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,
743
                              const char *fmt, ...) G_GNUC_PRINTF(2, 3);
744 745 746 747
ssize_t qemuDomainLogContextRead(qemuDomainLogContextPtr ctxt,
                                 char **msg);
int qemuDomainLogContextGetWriteFD(qemuDomainLogContextPtr ctxt);
void qemuDomainLogContextMarkPosition(qemuDomainLogContextPtr ctxt);
748

749 750
virLogManagerPtr qemuDomainLogContextGetManager(qemuDomainLogContextPtr ctxt);

751 752 753
int qemuDomainLogAppendMessage(virQEMUDriverPtr driver,
                               virDomainObjPtr vm,
                               const char *fmt,
754
                               ...) G_GNUC_PRINTF(3, 4);
755

756
const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
757 758

int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
759
                                    virDomainMomentObjPtr snapshot,
760
                                    virCapsPtr caps,
761
                                    virDomainXMLOptionPtr xmlopt,
762
                                    const char *snapshotDir);
763

764
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
765
                                   virDomainObjPtr vm,
766
                                   virDomainMomentObjPtr snap,
767 768 769
                                   const char *op,
                                   bool try_all);

770
int qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
771
                              virDomainObjPtr vm,
772
                              virDomainMomentObjPtr snap,
773 774 775
                              bool update_current,
                              bool metadata_only);

776 777 778
typedef struct _virQEMUMomentRemove virQEMUMomentRemove;
typedef virQEMUMomentRemove *virQEMUMomentRemovePtr;
struct _virQEMUMomentRemove {
779
    virQEMUDriverPtr driver;
780 781 782
    virDomainObjPtr vm;
    int err;
    bool metadata_only;
783 784 785 786
    virDomainMomentObjPtr current;
    bool found;
    int (*momentDiscard)(virQEMUDriverPtr, virDomainObjPtr,
                         virDomainMomentObjPtr, bool, bool);
787 788
};

789 790 791
int qemuDomainMomentDiscardAll(void *payload,
                               const void *name,
                               void *data);
792

793
int qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
794 795
                                         virDomainObjPtr vm);

796
void qemuDomainRemoveInactive(virQEMUDriverPtr driver,
797 798
                              virDomainObjPtr vm);

799 800 801
void qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

802 803 804
void qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver,
                                       virDomainObjPtr vm);

805
void qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
806 807 808
                             virDomainObjPtr vm,
                             bool value);

809
bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv,
810
                          qemuDomainJob job);
M
Michal Privoznik 已提交
811

812 813 814 815 816
int qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     size_t diskIndex,
                                     bool cold_boot);

817
int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
M
Michal Privoznik 已提交
818
                                virDomainObjPtr vm,
819
                                unsigned int flags);
820

821 822 823 824
int qemuDomainStorageSourceValidateDepth(virStorageSourcePtr src,
                                         int add,
                                         const char *diskdst);

825
int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
826
                                 virDomainObjPtr vm,
827
                                 virDomainDiskDefPtr disk,
828
                                 virStorageSourcePtr disksrc,
829
                                 bool report_broken);
830

831 832 833
bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
                                   virDomainDiskDefPtr orig_disk);

834 835 836
const char *qemuDomainDiskNodeFormatLookup(virDomainObjPtr vm,
                                           const char *disk);

837 838
int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
839 840
                              virStorageSourcePtr src,
                              virStorageSourcePtr parent);
841
char *qemuDomainStorageAlias(const char *device, int depth);
842

843 844 845 846
int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
                                  virQEMUCapsPtr qemuCaps,
                                  char **backendAlias)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
847
    ATTRIBUTE_NONNULL(3) G_GNUC_WARN_UNUSED_RESULT;
848

849 850 851 852 853 854
int qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
                                            virDomainObjPtr vm,
                                            virStorageSourcePtr src);
int qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
                                             virDomainObjPtr vm,
                                             virStorageSourcePtr src);
855

856 857 858 859 860 861 862 863
void qemuDomainStorageSourceAccessRevoke(virQEMUDriverPtr driver,
                                         virDomainObjPtr vm,
                                         virStorageSourcePtr elem);
int qemuDomainStorageSourceAccessAllow(virQEMUDriverPtr driver,
                                       virDomainObjPtr vm,
                                       virStorageSourcePtr elem,
                                       bool readonly,
                                       bool newSource);
864

865 866 867 868 869
int qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
                                           virStorageSourcePtr src,
                                           qemuDomainObjPrivatePtr priv,
                                           virQEMUDriverConfigPtr cfg);

870 871 872 873
int qemuDomainCleanupAdd(virDomainObjPtr vm,
                         qemuDomainCleanupCallback cb);
void qemuDomainCleanupRemove(virDomainObjPtr vm,
                             qemuDomainCleanupCallback cb);
874
void qemuDomainCleanupRun(virQEMUDriverPtr driver,
875 876
                          virDomainObjPtr vm);

877 878
void qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv);

879
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
880
extern virXMLNamespace virQEMUDriverDomainXMLNamespace;
881
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
882
extern virDomainABIStability virQEMUDriverDomainABIStability;
883
extern virSaveCookieCallbacks virQEMUDriverDomainSaveCookie;
884

885
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
886
                               virDomainObjPtr vm, int asyncJob);
887

888 889 890 891
int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     int asyncJob);

892
bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
893
                                    virQEMUCapsPtr qemuCaps,
894 895
                                    virDomainDefPtr src,
                                    virDomainDefPtr dst);
896

897 898 899 900
bool qemuDomainCheckABIStability(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm,
                                 virDomainDefPtr dst);

901
bool qemuDomainAgentAvailable(virDomainObjPtr vm,
902 903
                              bool reportError);

J
Jiri Denemark 已提交
904 905
int qemuDomainJobInfoUpdateTime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
906 907
int qemuDomainJobInfoUpdateDowntime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
J
Jiri Denemark 已提交
908 909 910 911 912 913 914 915 916 917
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);

918
bool qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk);
919 920
bool qemuDomainHasBlockjob(virDomainObjPtr vm, bool copy_only)
    ATTRIBUTE_NONNULL(1);
921

922
int qemuDomainAlignMemorySizes(virDomainDefPtr def);
923 924
void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem);
925

926
virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
927

928 929
/* You should normally avoid these functions and use the variant that
 * doesn't have "Machine" in the name instead. */
930 931
bool qemuDomainMachineIsARMVirt(const char *machine,
                                const virArch arch);
932 933
bool qemuDomainMachineIsPSeries(const char *machine,
                                const virArch arch);
934 935
bool qemuDomainMachineHasBuiltinIDE(const char *machine,
                                    const virArch arch);
A
Andrea Bolognani 已提交
936 937 938 939 940 941 942 943 944 945 946

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);
947 948
bool qemuDomainSupportsPCI(virDomainDefPtr def,
                           virQEMUCapsPtr qemuCaps);
949

950
void qemuDomainUpdateCurrentMemorySize(virDomainObjPtr vm);
951

952
unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDefPtr def);
953
int qemuDomainAdjustMaxMemLock(virDomainObjPtr vm);
954 955
int qemuDomainAdjustMaxMemLockHostdev(virDomainObjPtr vm,
                                      virDomainHostdevDefPtr hostdev);
956

957 958 959 960
int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
                                       virQEMUCapsPtr qemuCaps,
                                       const virDomainMemoryDef *mem);

961
bool qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm);
962
bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
963
pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid);
964
int qemuDomainValidateVcpuInfo(virDomainObjPtr vm);
965 966
int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
967 968
                              int asyncJob,
                              bool state);
969 970 971 972
bool qemuDomainGetVcpuHalted(virDomainObjPtr vm, unsigned int vcpu);
int qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                int asyncJob);
973

974 975 976
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
                              virDomainNetDefPtr net);

977 978
bool qemuDomainNetSupportsMTU(virDomainNetType type);

979 980 981
int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

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

J
John Ferlan 已提交
984 985 986 987
char *qemuDomainGetMasterKeyFilePath(const char *libDir);

int qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv);

988 989 990 991
int qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

int qemuDomainMasterKeyCreate(virDomainObjPtr vm);
J
John Ferlan 已提交
992 993 994

void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);

995 996
bool qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivatePtr priv);

997 998 999
void qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
    ATTRIBUTE_NONNULL(1);

1000 1001
void qemuDomainSecretInfoDestroy(qemuDomainSecretInfoPtr secinfo);

1002 1003 1004
void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
    ATTRIBUTE_NONNULL(1);

1005
bool qemuDomainStorageSourceHasAuth(virStorageSourcePtr src)
1006 1007
    ATTRIBUTE_NONNULL(1);

1008 1009 1010
bool qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
    ATTRIBUTE_NONNULL(1);

1011
qemuDomainSecretInfoPtr
1012
qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr priv,
1013 1014 1015
                           const char *srcAlias,
                           const char *secretUUID);

1016 1017 1018
void qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr disk)
    ATTRIBUTE_NONNULL(1);

1019
int qemuDomainSecretHostdevPrepare(qemuDomainObjPrivatePtr priv,
1020
                                   virDomainHostdevDefPtr hostdev)
1021
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
1022

1023 1024 1025
void qemuDomainSecretChardevDestroy(virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1);

1026
int qemuDomainSecretChardevPrepare(virQEMUDriverConfigPtr cfg,
1027 1028 1029 1030
                                   qemuDomainObjPrivatePtr priv,
                                   const char *chrAlias,
                                   virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
1031
    ATTRIBUTE_NONNULL(4);
1032

1033 1034 1035
void qemuDomainSecretDestroy(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);

1036
int qemuDomainSecretPrepare(virQEMUDriverPtr driver,
1037
                            virDomainObjPtr vm)
1038
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
1039

1040 1041 1042
int qemuDomainDefValidateDiskLunSource(const virStorageSource *src)
    ATTRIBUTE_NONNULL(1);

1043 1044 1045
int qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk,
                                    virQEMUCapsPtr qemuCaps);

1046 1047 1048 1049
int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
                             const char *domainChannelTargetDir)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

1050 1051 1052 1053 1054
void qemuDomainPrepareChardevSourceTLS(virDomainChrSourceDefPtr source,
                                       virQEMUDriverConfigPtr cfg)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void qemuDomainPrepareChardevSource(virDomainDefPtr def,
1055
                                    virQEMUDriverConfigPtr cfg)
1056 1057
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

1058
void  qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
1059 1060
    ATTRIBUTE_NONNULL(1);

1061 1062 1063
bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

1064 1065 1066
void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

1067 1068 1069 1070
int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
                           virDomainObjPtr vm,
                           qemuDomainAsyncJob asyncJob);

1071 1072 1073
bool qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
                                virQEMUCapsPtr qemuCaps);

1074 1075
bool qemuDomainNeedsVFIO(const virDomainDef *def);

1076 1077 1078
int qemuDomainGetHostdevPath(virDomainDefPtr def,
                             virDomainHostdevDefPtr dev,
                             bool teardown,
1079 1080 1081
                             size_t *npaths,
                             char ***path,
                             int **perms);
1082

1083 1084
int qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
                             virSecurityManagerPtr mgr,
1085 1086 1087 1088 1089
                             virDomainObjPtr vm);

int qemuDomainCreateNamespace(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

1090 1091 1092
void qemuDomainDestroyNamespace(virQEMUDriverPtr driver,
                                virDomainObjPtr vm);

1093 1094
bool qemuDomainNamespaceAvailable(qemuDomainNamespace ns);

1095
int qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
1096
                                 virStorageSourcePtr src);
1097

1098
int qemuDomainNamespaceTeardownDisk(virDomainObjPtr vm,
1099
                                    virStorageSourcePtr src);
1100

1101
int qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm,
1102 1103
                                    virDomainHostdevDefPtr hostdev);

1104
int qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
1105
                                       virDomainHostdevDefPtr hostdev);
1106

1107
int qemuDomainNamespaceSetupMemory(virDomainObjPtr vm,
M
Michal Privoznik 已提交
1108 1109
                                   virDomainMemoryDefPtr memory);

1110
int qemuDomainNamespaceTeardownMemory(virDomainObjPtr vm,
M
Michal Privoznik 已提交
1111 1112
                                      virDomainMemoryDefPtr memory);

1113
int qemuDomainNamespaceSetupChardev(virDomainObjPtr vm,
1114 1115
                                    virDomainChrDefPtr chr);

1116
int qemuDomainNamespaceTeardownChardev(virDomainObjPtr vm,
1117
                                       virDomainChrDefPtr chr);
1118

1119
int qemuDomainNamespaceSetupRNG(virDomainObjPtr vm,
1120
                                virDomainRNGDefPtr rng);
1121

1122
int qemuDomainNamespaceTeardownRNG(virDomainObjPtr vm,
1123
                                   virDomainRNGDefPtr rng);
1124

1125 1126 1127 1128 1129 1130
int qemuDomainNamespaceSetupInput(virDomainObjPtr vm,
                                  virDomainInputDefPtr input);

int qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
                                     virDomainInputDefPtr input);

1131 1132 1133 1134 1135
virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def,
                                                   const char *nodename,
                                                   virStorageSourcePtr *src,
                                                   unsigned int *idx);

1136 1137 1138 1139
char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
                                        virStorageSourcePtr src,
                                        unsigned int idx);

1140 1141 1142
virStorageSourcePtr qemuDomainGetStorageSourceByDevstr(const char *devstr,
                                                       virDomainDefPtr def);

1143 1144 1145 1146 1147
int
qemuDomainUpdateCPU(virDomainObjPtr vm,
                    virCPUDefPtr cpu,
                    virCPUDefPtr *origCPU);

1148 1149 1150 1151
int
qemuDomainFixupCPUs(virDomainObjPtr vm,
                    virCPUDefPtr *origCPU);

1152 1153 1154 1155
int
qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
                         virFileCachePtr qemuCapsCache);

1156 1157 1158
char *
qemuDomainGetMachineName(virDomainObjPtr vm);

1159 1160 1161 1162 1163 1164 1165 1166
void
qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf,
                                         virTristateBool allowReboot);

int
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
                                        virTristateBool *allowReboot);

1167 1168 1169 1170 1171
bool
qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
                                     const virDomainDeviceInfo *info,
                                     virQEMUCapsPtr qemuCaps,
                                     const char *devicename);
1172

1173
void
1174
qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
1175
                                virStorageSourcePtr src);
1176

1177 1178 1179 1180 1181 1182

int
qemuDomainValidateStorageSource(virStorageSourcePtr src,
                                virQEMUCapsPtr qemuCaps);


1183
int
1184
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
1185 1186 1187
                            qemuDomainObjPrivatePtr priv,
                            virQEMUDriverConfigPtr cfg);

1188 1189 1190 1191 1192 1193
int
qemuDomainDiskCachemodeFlags(int cachemode,
                             bool *writeback,
                             bool *direct,
                             bool *noflush);

1194
char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);
1195

1196 1197
bool qemuDomainDefHasManagedPR(virDomainObjPtr vm);

1198 1199 1200
unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivatePtr priv);
void qemuDomainStorageIdReset(qemuDomainObjPrivatePtr priv);

1201 1202 1203
virDomainEventResumedDetailType
qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);

J
John Ferlan 已提交
1204 1205 1206
bool
qemuDomainIsUsingNoShutdown(qemuDomainObjPrivatePtr priv);

1207 1208 1209
bool
qemuDomainDiskIsMissingLocalOptional(virDomainDiskDefPtr disk);

1210
void
1211 1212 1213 1214
qemuDomainNVRAMPathFormat(virQEMUDriverConfigPtr cfg,
                            virDomainDefPtr def,
                            char **path);

1215
void
1216 1217 1218
qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg,
                            virDomainDefPtr def);

1219 1220
virDomainEventSuspendedDetailType
qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason);
1221 1222 1223 1224

int
qemuDomainValidateActualNetDef(const virDomainNetDef *net,
                               virQEMUCapsPtr qemuCaps);
1225 1226 1227

int
qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm)
1228
    G_GNUC_WARN_UNUSED_RESULT;
1229 1230 1231

int
qemuDomainMakeCPUMigratable(virCPUDefPtr cpu);