qemu_domain.h 29.6 KB
Newer Older
1 2 3
/*
 * qemu_domain.h: QEMU domain private state
 *
4
 * Copyright (C) 2006-2016 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
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __QEMU_DOMAIN_H__
# define __QEMU_DOMAIN_H__

27
# include "virthread.h"
28
# include "vircgroup.h"
29
# include "virperf.h"
30
# include "domain_addr.h"
31
# include "domain_conf.h"
32
# include "snapshot_conf.h"
33
# include "qemu_monitor.h"
D
Daniel P. Berrange 已提交
34
# include "qemu_agent.h"
35
# include "qemu_conf.h"
36
# include "qemu_capabilities.h"
37
# include "virchrdev.h"
38
# include "virobject.h"
39
# include "logging/log_manager.h"
40

41 42 43 44
# define QEMU_DOMAIN_FORMAT_LIVE_FLAGS      \
    (VIR_DOMAIN_XML_SECURE |                \
     VIR_DOMAIN_XML_UPDATE_CPU)

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

53
# define JOB_MASK(job)                  (1 << (job - 1))
54
# define QEMU_JOB_DEFAULT_MASK          \
55 56 57
    (JOB_MASK(QEMU_JOB_QUERY) |         \
     JOB_MASK(QEMU_JOB_DESTROY) |       \
     JOB_MASK(QEMU_JOB_ABORT))
58

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

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

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

    QEMU_JOB_LAST
81
} qemuDomainJob;
82
VIR_ENUM_DECL(qemuDomainJob)
83 84 85 86 87

/* 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.
 */
88
typedef enum {
89 90 91 92 93
    QEMU_ASYNC_JOB_NONE = 0,
    QEMU_ASYNC_JOB_MIGRATION_OUT,
    QEMU_ASYNC_JOB_MIGRATION_IN,
    QEMU_ASYNC_JOB_SAVE,
    QEMU_ASYNC_JOB_DUMP,
94
    QEMU_ASYNC_JOB_SNAPSHOT,
95
    QEMU_ASYNC_JOB_START,
96 97

    QEMU_ASYNC_JOB_LAST
98
} qemuDomainAsyncJob;
99
VIR_ENUM_DECL(qemuDomainAsyncJob)
100

J
Jiri Denemark 已提交
101 102 103 104 105
typedef struct _qemuDomainJobInfo qemuDomainJobInfo;
typedef qemuDomainJobInfo *qemuDomainJobInfoPtr;
struct _qemuDomainJobInfo {
    virDomainJobType type;
    unsigned long long started; /* When the async job started */
106
    unsigned long long stopped; /* When the domain's CPUs were stopped */
107 108 109 110
    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 已提交
111 112 113
    /* Computed values */
    unsigned long long timeElapsed;
    unsigned long long timeRemaining;
J
Jiri Denemark 已提交
114
    long long timeDelta; /* delta = received - sent, i.e., the difference
115 116 117 118 119
                            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 已提交
120
    /* Raw values from QEMU */
121
    qemuMonitorMigrationStats stats;
J
Jiri Denemark 已提交
122 123
};

124
struct qemuDomainJobObj {
125
    virCond cond;                       /* Use to coordinate jobs */
126
    qemuDomainJob active;               /* Currently running job */
127
    unsigned long long owner;           /* Thread id which set current job */
128
    const char *ownerAPI;               /* The API which owns the job */
J
Jiri Denemark 已提交
129
    unsigned long long started;         /* When the current job started */
130

131
    virCond asyncCond;                  /* Use to coordinate with async jobs */
132
    qemuDomainAsyncJob asyncJob;        /* Currently active async job */
133
    unsigned long long asyncOwner;      /* Thread which set current async job */
134
    const char *asyncOwnerAPI;          /* The API which owns the async job */
J
Jiri Denemark 已提交
135
    unsigned long long asyncStarted;    /* When the current async job started */
J
Jiri Denemark 已提交
136
    int phase;                          /* Job phase (mainly for migrations) */
137
    unsigned long long mask;            /* Jobs allowed during async job */
138
    bool dump_memory_only;              /* use dump-guest-memory to do dump */
J
Jiri Denemark 已提交
139
    qemuDomainJobInfoPtr current;       /* async job progress data */
140
    qemuDomainJobInfoPtr completed;     /* statistics data of a recently completed job */
141
    bool abortJob;                      /* abort of the job requested */
142 143
    bool spiceMigration;                /* we asked for spice migration and we
                                         * should wait for it to finish */
144
    bool spiceMigrated;                 /* spice migration completed */
145
    bool postcopyEnabled;               /* post-copy migration was enabled */
146 147
};

148
typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver,
149 150
                                          virDomainObjPtr vm);

J
John Ferlan 已提交
151
# define QEMU_DOMAIN_MASTER_KEY_LEN 32  /* 32 bytes for 256 bit random key */
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167


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

168 169 170
typedef struct _qemuDomainObjPrivate qemuDomainObjPrivate;
typedef qemuDomainObjPrivate *qemuDomainObjPrivatePtr;
struct _qemuDomainObjPrivate {
171
    struct qemuDomainJobObj job;
172 173

    qemuMonitorPtr mon;
174
    virDomainChrSourceDefPtr monConfig;
E
Eric Blake 已提交
175
    bool monJSON;
176 177
    bool monError;
    unsigned long long monStart;
D
Daniel P. Berrange 已提交
178 179 180 181 182

    qemuAgentPtr agent;
    bool agentError;
    unsigned long long agentStart;

183
    bool gotShutdown;
184
    bool beingDestroyed;
185
    char *pidfile;
186

187
    virDomainPCIAddressSetPtr pciaddrs;
J
Ján Tomko 已提交
188
    virDomainUSBAddressSetPtr usbaddrs;
189

190
    virQEMUCapsPtr qemuCaps;
191
    char *lockState;
192 193

    bool fakeReboot;
194 195

    int jobs_queued;
196 197

    unsigned long migMaxBandwidth;
J
Jiri Denemark 已提交
198
    char *origname;
199
    int nbdPort; /* Port used for migration with NBD */
200
    unsigned short migrationPort;
201
    int preMigrationState;
202

203
    virChrdevsPtr devs;
204 205 206 207

    qemuDomainCleanupCallback *cleanupCallbacks;
    size_t ncleanupCallbacks;
    size_t ncleanupCallbacks_max;
208 209

    virCgroupPtr cgroup;
210

211 212
    virPerfPtr perf;

213 214
    qemuDomainUnpluggingDevice unplug;

215
    char **qemuDevices; /* NULL-terminated list of devices aliases known to QEMU */
216 217

    bool hookRun;  /* true if there was a hook run over this domain */
218 219

    /* Bitmaps below hold data from the auto NUMA feature */
220
    virBitmapPtr autoNodeset;
221
    virBitmapPtr autoCpuset;
222 223 224

    bool signalIOError; /* true if the domain condition should be signalled on
                           I/O error */
225 226
    bool signalStop; /* true if the domain condition should be signalled on
                        QMP STOP event */
227
    char *machineName;
228 229
    char *libDir;            /* base path for per-domain files */
    char *channelTargetDir;  /* base path for per-domain channel targets */
J
John Ferlan 已提交
230 231 232 233 234

    /* 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;
235 236 237

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

240 241 242
# define QEMU_DOMAIN_PRIVATE(vm)	\
    ((qemuDomainObjPrivatePtr) (vm)->privateData)

243 244
/* Type of domain secret */
typedef enum {
245
    VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN = 0,
246
    VIR_DOMAIN_SECRET_INFO_TYPE_AES,  /* utilize GNUTLS_CIPHER_AES_256_CBC */
247

248
    VIR_DOMAIN_SECRET_INFO_TYPE_LAST
249 250 251 252 253 254
} qemuDomainSecretInfoType;

typedef struct _qemuDomainSecretPlain qemuDomainSecretPlain;
typedef struct _qemuDomainSecretPlain *qemuDomainSecretPlainPtr;
struct _qemuDomainSecretPlain {
    char *username;
255 256
    uint8_t *secret;
    size_t secretlen;
257 258
};

259 260
# define QEMU_DOMAIN_AES_IV_LEN 16   /* 16 bytes for 128 bit random */
                                     /*    initialization vector */
261 262 263
typedef struct _qemuDomainSecretAES qemuDomainSecretAES;
typedef struct _qemuDomainSecretAES *qemuDomainSecretAESPtr;
struct _qemuDomainSecretAES {
J
John Ferlan 已提交
264 265 266 267 268 269
    char *username;
    char *alias;      /* generated alias for secret */
    char *iv;         /* base64 encoded initialization vector */
    char *ciphertext; /* encoded/encrypted secret */
};

270 271 272
typedef struct _qemuDomainSecretInfo qemuDomainSecretInfo;
typedef qemuDomainSecretInfo *qemuDomainSecretInfoPtr;
struct _qemuDomainSecretInfo {
273
    qemuDomainSecretInfoType type;
274 275
    union {
        qemuDomainSecretPlain plain;
276
        qemuDomainSecretAES aes;
277 278 279
    } s;
};

280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
# define QEMU_DOMAIN_DISK_PRIVATE(disk)	\
    ((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 */
    bool blockjob;

    /* for some synchronous block jobs, we need to notify the owner */
    int blockJobType;   /* type of the block job from the event */
    int blockJobStatus; /* status of the finished block job */
    bool blockJobSync; /* the block job needs synchronized termination */
297 298

    bool migrating; /* the disk is being migrated */
299 300 301 302

    /* for storage devices using auth/secret
     * NB: *not* to be written to qemu domain object XML */
    qemuDomainSecretInfoPtr secinfo;
303

J
John Ferlan 已提交
304 305 306 307 308
    /* for storage devices using encryption/secret
     * Can have both <auth> and <encryption> for some disks
     * NB:*not* to be written to qemu domain object XML */
    qemuDomainSecretInfoPtr encinfo;

309 310 311
    /* information about the device */
    bool tray; /* device has tray */
    bool removable; /* device media can be removed/changed */
312 313
};

314 315 316
# define QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev)	\
    ((qemuDomainHostdevPrivatePtr) (hostdev)->privateData)

317 318 319 320 321 322

typedef struct _qemuDomainVcpuPrivate qemuDomainVcpuPrivate;
typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
struct _qemuDomainVcpuPrivate {
    virObject parent;

323
    pid_t tid; /* vcpu thread id */
324 325
    int enable_id; /* order in which the vcpus were enabled in qemu */
    char *alias;
326
    bool halted;
327 328 329 330 331 332 333

    /* information for hotpluggable cpus */
    char *type;
    int socket_id;
    int core_id;
    int thread_id;
    int vcpus;
334 335 336 337 338 339
};

# define QEMU_DOMAIN_VCPU_PRIVATE(vcpu)    \
    ((qemuDomainVcpuPrivatePtr) (vcpu)->privateData)


340 341 342
struct qemuDomainDiskInfo {
    bool removable;
    bool locked;
343
    bool tray;
344
    bool tray_open;
345
    bool empty;
346 347 348
    int io_status;
};

349 350 351 352 353 354 355 356 357 358
typedef struct _qemuDomainHostdevPrivate qemuDomainHostdevPrivate;
typedef qemuDomainHostdevPrivate *qemuDomainHostdevPrivatePtr;
struct _qemuDomainHostdevPrivate {
    virObject parent;

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

359 360
# define QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev)	\
    ((qemuDomainChrSourcePrivatePtr) (dev)->privateData)
361

362 363 364
typedef struct _qemuDomainChrSourcePrivate qemuDomainChrSourcePrivate;
typedef qemuDomainChrSourcePrivate *qemuDomainChrSourcePrivatePtr;
struct _qemuDomainChrSourcePrivate {
365 366 367 368 369 370 371 372
    virObject parent;

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


C
Chen Fan 已提交
373 374
typedef enum {
    QEMU_PROCESS_EVENT_WATCHDOG = 0,
375
    QEMU_PROCESS_EVENT_GUESTPANIC,
376
    QEMU_PROCESS_EVENT_DEVICE_DELETED,
377
    QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED,
378
    QEMU_PROCESS_EVENT_SERIAL_CHANGED,
379
    QEMU_PROCESS_EVENT_BLOCK_JOB,
380
    QEMU_PROCESS_EVENT_MONITOR_EOF,
C
Chen Fan 已提交
381 382 383 384 385

    QEMU_PROCESS_EVENT_LAST
} qemuProcessEventType;

struct qemuProcessEvent {
386
    virDomainObjPtr vm;
C
Chen Fan 已提交
387
    qemuProcessEventType eventType;
388
    int action;
389
    int status;
390
    void *data;
391 392
};

393 394 395
typedef struct _qemuDomainLogContext qemuDomainLogContext;
typedef qemuDomainLogContext *qemuDomainLogContextPtr;

396
const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
397
                                            int phase);
398
int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
399 400
                                      const char *phase);

401
void qemuDomainEventFlush(int timer, void *opaque);
402

403
void qemuDomainEventQueue(virQEMUDriverPtr driver,
404
                          virObjectEventPtr event);
405 406
void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm);
407

408
int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
409
                          virDomainObjPtr obj,
410
                          qemuDomainJob job)
411
    ATTRIBUTE_RETURN_CHECK;
412
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
413
                               virDomainObjPtr obj,
414
                               qemuDomainAsyncJob asyncJob)
415
    ATTRIBUTE_RETURN_CHECK;
416 417 418 419
int qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver,
                                virDomainObjPtr obj,
                                qemuDomainAsyncJob asyncJob)
    ATTRIBUTE_RETURN_CHECK;
420

421 422 423 424
void qemuDomainObjEndJob(virQEMUDriverPtr driver,
                         virDomainObjPtr obj);
void qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver,
                              virDomainObjPtr obj);
425
void qemuDomainObjAbortAsyncJob(virDomainObjPtr obj);
426
void qemuDomainObjSetJobPhase(virQEMUDriverPtr driver,
J
Jiri Denemark 已提交
427 428
                              virDomainObjPtr obj,
                              int phase);
429 430
void qemuDomainObjSetAsyncJobMask(virDomainObjPtr obj,
                                  unsigned long long allowedJobs);
431 432
void qemuDomainObjRestoreJob(virDomainObjPtr obj,
                             struct qemuDomainJobObj *job);
433
void qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver,
434
                                  virDomainObjPtr obj);
435
void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj);
436

437 438
qemuMonitorPtr qemuDomainGetMonitor(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);
439
void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
440 441
                               virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
442 443
int qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
                             virDomainObjPtr obj)
444 445
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
    ATTRIBUTE_RETURN_CHECK;
446
int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
447
                                   virDomainObjPtr obj,
448
                                   qemuDomainAsyncJob asyncJob)
449
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
D
Daniel P. Berrange 已提交
450 451


452
qemuAgentPtr qemuDomainGetAgent(virDomainObjPtr vm);
453 454 455 456
void qemuDomainObjEnterAgent(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
void qemuDomainObjExitAgent(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
D
Daniel P. Berrange 已提交
457 458


459 460 461 462
void qemuDomainObjEnterRemote(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
void qemuDomainObjExitRemote(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
463

464 465 466 467
virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
                                  virDomainDefPtr src,
                                  unsigned int flags);

468
int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
469 470 471 472
                           virDomainDefPtr vm,
                           unsigned int flags,
                           virBuffer *buf);

473
char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
474
                             virDomainDefPtr vm,
475
                             unsigned int flags);
476

477
char *qemuDomainFormatXML(virQEMUDriverPtr driver,
478
                          virDomainObjPtr vm,
479
                          unsigned int flags);
480

481
char *qemuDomainDefFormatLive(virQEMUDriverPtr driver,
482
                              virDomainDefPtr def,
483 484
                              bool inactive,
                              bool compatible);
485

486
void qemuDomainObjTaint(virQEMUDriverPtr driver,
487
                        virDomainObjPtr obj,
488
                        virDomainTaintFlags taint,
489
                        qemuDomainLogContextPtr logCtxt);
490

491
void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
492
                             virDomainObjPtr obj,
493
                             qemuDomainLogContextPtr logCtxt);
494
void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver,
495
                                 virDomainObjPtr obj,
496
                                 virDomainDiskDefPtr disk,
497
                                 qemuDomainLogContextPtr logCtxt);
498 499 500
void qemuDomainObjCheckHostdevTaint(virQEMUDriverPtr driver,
                                    virDomainObjPtr obj,
                                    virDomainHostdevDefPtr disk,
501
                                    qemuDomainLogContextPtr logCtxt);
502
void qemuDomainObjCheckNetTaint(virQEMUDriverPtr driver,
503
                                virDomainObjPtr obj,
504
                                virDomainNetDefPtr net,
505
                                qemuDomainLogContextPtr logCtxt);
506

507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
typedef enum {
    QEMU_DOMAIN_LOG_CONTEXT_MODE_START,
    QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH,
    QEMU_DOMAIN_LOG_CONTEXT_MODE_STOP,
} qemuDomainLogContextMode;

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

525 526
virLogManagerPtr qemuDomainLogContextGetManager(qemuDomainLogContextPtr ctxt);

527 528 529 530 531
int qemuDomainLogAppendMessage(virQEMUDriverPtr driver,
                               virDomainObjPtr vm,
                               const char *fmt,
                               ...) ATTRIBUTE_FMT_PRINTF(3, 4);

532
const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
533 534 535

int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
                                    virDomainSnapshotObjPtr snapshot,
536
                                    virCapsPtr caps,
537 538
                                    char *snapshotDir);

539
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
540 541 542 543 544
                                   virDomainObjPtr vm,
                                   virDomainSnapshotObjPtr snap,
                                   const char *op,
                                   bool try_all);

545
int qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
546 547 548 549 550
                              virDomainObjPtr vm,
                              virDomainSnapshotObjPtr snap,
                              bool update_current,
                              bool metadata_only);

551 552 553
typedef struct _virQEMUSnapRemove virQEMUSnapRemove;
typedef virQEMUSnapRemove *virQEMUSnapRemovePtr;
struct _virQEMUSnapRemove {
554
    virQEMUDriverPtr driver;
555 556 557 558 559 560
    virDomainObjPtr vm;
    int err;
    bool metadata_only;
    bool current;
};

561 562 563
int qemuDomainSnapshotDiscardAll(void *payload,
                                 const void *name,
                                 void *data);
564

565
int qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
566 567
                                         virDomainObjPtr vm);

568
void qemuDomainRemoveInactive(virQEMUDriverPtr driver,
569 570
                              virDomainObjPtr vm);

571
void qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
572 573 574
                             virDomainObjPtr vm,
                             bool value);

575
bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv,
576
                          qemuDomainJob job);
M
Michal Privoznik 已提交
577

578 579
int qemuDomainCheckDiskPresence(virConnectPtr conn,
                                virQEMUDriverPtr driver,
M
Michal Privoznik 已提交
580
                                virDomainObjPtr vm,
581
                                unsigned int flags);
582

583
int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
584
                                 virDomainObjPtr vm,
585
                                 virDomainDiskDefPtr disk,
586 587
                                 bool force_probe,
                                 bool report_broken);
588

589
bool qemuDomainDiskSourceDiffers(virDomainDiskDefPtr disk,
590 591
                                 virDomainDiskDefPtr origDisk);

592 593 594
bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
                                   virDomainDiskDefPtr orig_disk);

595 596 597
int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
                              virStorageSourcePtr src);
598
char *qemuDomainStorageAlias(const char *device, int depth);
599

600 601 602 603 604 605 606 607
void qemuDomainDiskChainElementRevoke(virQEMUDriverPtr driver,
                                      virDomainObjPtr vm,
                                      virStorageSourcePtr elem);
int qemuDomainDiskChainElementPrepare(virQEMUDriverPtr driver,
                                      virDomainObjPtr vm,
                                      virStorageSourcePtr elem,
                                      bool readonly);

608 609 610 611
int qemuDomainCleanupAdd(virDomainObjPtr vm,
                         qemuDomainCleanupCallback cb);
void qemuDomainCleanupRemove(virDomainObjPtr vm,
                             qemuDomainCleanupCallback cb);
612
void qemuDomainCleanupRun(virQEMUDriverPtr driver,
613 614
                          virDomainObjPtr vm);

615 616
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
617
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
618

619
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
620
                               virDomainObjPtr vm, int asyncJob);
621

622 623 624 625
int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     int asyncJob);

626 627 628
bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
                                    virDomainDefPtr src,
                                    virDomainDefPtr dst);
629

630
bool qemuDomainAgentAvailable(virDomainObjPtr vm,
631 632
                              bool reportError);

J
Jiri Denemark 已提交
633 634
int qemuDomainJobInfoUpdateTime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
635 636
int qemuDomainJobInfoUpdateDowntime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
J
Jiri Denemark 已提交
637 638 639 640 641 642 643 644 645 646
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);

647 648
int qemuDomainSupportsBlockJobs(virDomainObjPtr vm, bool *modern)
    ATTRIBUTE_NONNULL(1);
649
bool qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk);
650 651
bool qemuDomainHasBlockjob(virDomainObjPtr vm, bool copy_only)
    ATTRIBUTE_NONNULL(1);
652

653
int qemuDomainAlignMemorySizes(virDomainDefPtr def);
654 655
void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem);
656

657
virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
658

659 660
bool qemuDomainMachineIsQ35(const virDomainDef *def);
bool qemuDomainMachineIsI440FX(const virDomainDef *def);
661
bool qemuDomainMachineNeedsFDC(const virDomainDef *def);
662
bool qemuDomainMachineIsS390CCW(const virDomainDef *def);
J
Ján Tomko 已提交
663
bool qemuDomainMachineIsVirt(const virDomainDef *def);
664
bool qemuDomainMachineIsPSeries(const virDomainDef *def);
665
bool qemuDomainMachineHasBuiltinIDE(const virDomainDef *def);
666

667 668 669
int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
                                      virDomainObjPtr vm);

670 671
unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDefPtr def);
bool qemuDomainRequiresMemLock(virDomainDefPtr def);
672
int qemuDomainAdjustMaxMemLock(virDomainObjPtr vm);
673

674 675 676 677
int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
                                       virQEMUCapsPtr qemuCaps,
                                       const virDomainMemoryDef *mem);

678
bool qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm);
679
bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
680
pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid);
681
int qemuDomainValidateVcpuInfo(virDomainObjPtr vm);
682 683
int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
684 685
                              int asyncJob,
                              bool state);
686 687 688 689
bool qemuDomainGetVcpuHalted(virDomainObjPtr vm, unsigned int vcpu);
int qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                int asyncJob);
690

691 692 693 694 695 696 697
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
                              virDomainNetDefPtr net);

bool qemuDomainSupportsNetdev(virDomainDefPtr def,
                              virQEMUCapsPtr qemuCaps,
                              virDomainNetDefPtr net);

J
John Ferlan 已提交
698
int qemuDomainNetVLAN(virDomainNetDefPtr def);
699

700 701 702
int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

703
void qemuDomainClearPrivatePaths(virDomainObjPtr vm);
P
Peter Krempa 已提交
704 705 706

virDomainDiskDefPtr qemuDomainDiskByName(virDomainDefPtr def, const char *name);

J
John Ferlan 已提交
707 708 709 710
char *qemuDomainGetMasterKeyFilePath(const char *libDir);

int qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv);

711 712 713 714
int qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

int qemuDomainMasterKeyCreate(virDomainObjPtr vm);
J
John Ferlan 已提交
715 716 717

void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);

718 719 720
void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
    ATTRIBUTE_NONNULL(1);

721 722 723
bool qemuDomainSecretDiskCapable(virStorageSourcePtr src)
    ATTRIBUTE_NONNULL(1);

J
John Ferlan 已提交
724 725 726 727
int qemuDomainSecretDiskPrepare(virConnectPtr conn,
                                qemuDomainObjPrivatePtr priv,
                                virDomainDiskDefPtr disk)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
728

729 730 731 732
void qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr disk)
    ATTRIBUTE_NONNULL(1);

int qemuDomainSecretHostdevPrepare(virConnectPtr conn,
J
John Ferlan 已提交
733
                                   qemuDomainObjPrivatePtr priv,
734
                                   virDomainHostdevDefPtr hostdev)
J
John Ferlan 已提交
735
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
736

737 738 739 740 741 742 743 744 745 746 747
void qemuDomainSecretChardevDestroy(virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1);

int qemuDomainSecretChardevPrepare(virConnectPtr conn,
                                   virQEMUDriverConfigPtr cfg,
                                   qemuDomainObjPrivatePtr priv,
                                   const char *chrAlias,
                                   virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);

748 749 750
void qemuDomainSecretDestroy(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);

751 752 753 754
int qemuDomainSecretPrepare(virConnectPtr conn,
                            virQEMUDriverPtr driver,
                            virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
755

756 757 758
int qemuDomainDefValidateDiskLunSource(const virStorageSource *src)
    ATTRIBUTE_NONNULL(1);

759 760 761 762
int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
                             const char *domainChannelTargetDir)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

763 764 765 766 767 768 769 770
void qemuDomainPrepareChardevSourceTLS(virDomainChrSourceDefPtr source,
                                       virQEMUDriverConfigPtr cfg)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void qemuDomainPrepareChardevSource(virDomainDefPtr def,
                                    virQEMUDriverPtr driver)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

771 772 773
int qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1);

774 775 776
bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

777 778 779
void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

780 781 782 783
int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
                           virDomainObjPtr vm,
                           qemuDomainAsyncJob asyncJob);

784 785 786
bool qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
                                virQEMUCapsPtr qemuCaps);

787
#endif /* __QEMU_DOMAIN_H__ */