qemu_domain.h 44.5 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;
D
Daniel P. Berrange 已提交
296 297 298 299

    qemuAgentPtr agent;
    bool agentError;

300
    bool beingDestroyed;
301
    char *pidfile;
302

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

306
    virQEMUCapsPtr qemuCaps;
307
    char *lockState;
308 309

    bool fakeReboot;
310
    virTristateBool allowReboot;
311 312

    int jobs_queued;
313 314

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

320
    virChrdevsPtr devs;
321 322 323 324

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

    virCgroupPtr cgroup;
327

328 329
    virPerfPtr perf;

330 331
    qemuDomainUnpluggingDevice unplug;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    virHashTablePtr dbusVMStates;
398
    bool disableSlirp;
399 400
};

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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


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

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


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

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

512
    int vhost_user_fd;
513 514 515
};


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

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

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


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

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

537
    qemuSlirpPtr slirp;
538 539 540
};


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

    QEMU_PROCESS_EVENT_LAST
} qemuProcessEventType;

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

564 565
void qemuProcessEventFree(struct qemuProcessEvent *event);

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

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

    virCPUDefPtr cpu;
575
    bool slirpHelper;
576 577
};

578 579 580 581 582 583 584 585 586 587

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

    size_t ncapsadd;
    char **capsadd;

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

596
virDomainObjPtr qemuDomainObjFromDomain(virDomainPtr domain);
597

598 599
qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);

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

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

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

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

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

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


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


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

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

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

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

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

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

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

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

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

748 749
virLogManagerPtr qemuDomainLogContextGetManager(qemuDomainLogContextPtr ctxt);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

876 877
void qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv);

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

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

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

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

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

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

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

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

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

925
virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
926

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

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

949
void qemuDomainUpdateCurrentMemorySize(virDomainObjPtr vm);
950

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

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

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

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

976 977
bool qemuDomainNetSupportsMTU(virDomainNetType type);

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

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

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

int qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv);

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

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

void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);

994 995
bool qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivatePtr priv);

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

999 1000
void qemuDomainSecretInfoDestroy(qemuDomainSecretInfoPtr secinfo);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1057 1058 1059
int qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1);

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

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

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

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

1073 1074
bool qemuDomainNeedsVFIO(const virDomainDef *def);

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

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

int qemuDomainCreateNamespace(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

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

1092 1093
bool qemuDomainNamespaceAvailable(qemuDomainNamespace ns);

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

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

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

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

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

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

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

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

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

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

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

int qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
                                     virDomainInputDefPtr input);

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

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

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

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

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

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

1155 1156 1157
char *
qemuDomainGetMachineName(virDomainObjPtr vm);

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

int
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
                                        virTristateBool *allowReboot);

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

1172
int
1173
qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
1174
                                virStorageSourcePtr src)
1175
    G_GNUC_WARN_UNUSED_RESULT;
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 1211 1212 1213 1214
int
qemuDomainNVRAMPathFormat(virQEMUDriverConfigPtr cfg,
                            virDomainDefPtr def,
                            char **path);

1215 1216 1217 1218
int
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;