qemu_domain.h 24.7 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 188 189

    int nvcpupids;
    int *vcpupids;

190
    virDomainPCIAddressSetPtr pciaddrs;
J
Ján Tomko 已提交
191
    virDomainCCWAddressSetPtr ccwaddrs;
192
    virDomainVirtioSerialAddrSetPtr vioserialaddrs;
193
    int persistentAddrs;
194

195
    virQEMUCapsPtr qemuCaps;
196
    char *lockState;
197 198

    bool fakeReboot;
199 200

    int jobs_queued;
201 202

    unsigned long migMaxBandwidth;
J
Jiri Denemark 已提交
203
    char *origname;
204
    int nbdPort; /* Port used for migration with NBD */
205
    unsigned short migrationPort;
206
    int preMigrationState;
207

208
    virChrdevsPtr devs;
209 210 211 212

    qemuDomainCleanupCallback *cleanupCallbacks;
    size_t ncleanupCallbacks;
    size_t ncleanupCallbacks_max;
213 214

    virCgroupPtr cgroup;
215

216 217
    virPerfPtr perf;

218 219
    qemuDomainUnpluggingDevice unplug;

220
    char **qemuDevices; /* NULL-terminated list of devices aliases known to QEMU */
221 222

    bool hookRun;  /* true if there was a hook run over this domain */
223 224

    /* Bitmaps below hold data from the auto NUMA feature */
225
    virBitmapPtr autoNodeset;
226
    virBitmapPtr autoCpuset;
227 228 229

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

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

242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
/* Type of domain secret */
typedef enum {
    VIR_DOMAIN_SECRET_INFO_PLAIN = 0,

    VIR_DOMAIN_SECRET_INFO_LAST
} qemuDomainSecretInfoType;

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

typedef struct _qemuDomainSecretInfo qemuDomainSecretInfo;
typedef qemuDomainSecretInfo *qemuDomainSecretInfoPtr;
struct _qemuDomainSecretInfo {
    int type;  /* qemuDomainSecretInfoType */
    union {
        qemuDomainSecretPlain plain;
    } s;
};

265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
# 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 */
282 283

    bool migrating; /* the disk is being migrated */
284 285 286 287

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

290 291 292 293 294 295 296 297 298 299 300 301 302
# define QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev)	\
    ((qemuDomainHostdevPrivatePtr) (hostdev)->privateData)

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

C
Chen Fan 已提交
303 304
typedef enum {
    QEMU_PROCESS_EVENT_WATCHDOG = 0,
305
    QEMU_PROCESS_EVENT_GUESTPANIC,
306
    QEMU_PROCESS_EVENT_DEVICE_DELETED,
307
    QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED,
308
    QEMU_PROCESS_EVENT_SERIAL_CHANGED,
309
    QEMU_PROCESS_EVENT_BLOCK_JOB,
310
    QEMU_PROCESS_EVENT_MONITOR_EOF,
C
Chen Fan 已提交
311 312 313 314 315

    QEMU_PROCESS_EVENT_LAST
} qemuProcessEventType;

struct qemuProcessEvent {
316
    virDomainObjPtr vm;
C
Chen Fan 已提交
317
    qemuProcessEventType eventType;
318
    int action;
319
    int status;
320
    void *data;
321 322
};

323 324 325
typedef struct _qemuDomainLogContext qemuDomainLogContext;
typedef qemuDomainLogContext *qemuDomainLogContextPtr;

326
const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
327
                                            int phase);
328
int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
329 330
                                      const char *phase);

331
void qemuDomainEventFlush(int timer, void *opaque);
332

333
void qemuDomainEventQueue(virQEMUDriverPtr driver,
334
                          virObjectEventPtr event);
335 336
void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm);
337

338
int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
339
                          virDomainObjPtr obj,
340
                          qemuDomainJob job)
341
    ATTRIBUTE_RETURN_CHECK;
342
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
343
                               virDomainObjPtr obj,
344
                               qemuDomainAsyncJob asyncJob)
345
    ATTRIBUTE_RETURN_CHECK;
346 347 348 349
int qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver,
                                virDomainObjPtr obj,
                                qemuDomainAsyncJob asyncJob)
    ATTRIBUTE_RETURN_CHECK;
350

351 352 353 354
void qemuDomainObjEndJob(virQEMUDriverPtr driver,
                         virDomainObjPtr obj);
void qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver,
                              virDomainObjPtr obj);
355
void qemuDomainObjAbortAsyncJob(virDomainObjPtr obj);
356
void qemuDomainObjSetJobPhase(virQEMUDriverPtr driver,
J
Jiri Denemark 已提交
357 358
                              virDomainObjPtr obj,
                              int phase);
359 360
void qemuDomainObjSetAsyncJobMask(virDomainObjPtr obj,
                                  unsigned long long allowedJobs);
361 362
void qemuDomainObjRestoreJob(virDomainObjPtr obj,
                             struct qemuDomainJobObj *job);
363
void qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver,
364
                                  virDomainObjPtr obj);
365
void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj);
366

367 368
qemuMonitorPtr qemuDomainGetMonitor(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);
369
void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
370 371
                               virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
372 373
int qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
                             virDomainObjPtr obj)
374 375
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
    ATTRIBUTE_RETURN_CHECK;
376
int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
377
                                   virDomainObjPtr obj,
378
                                   qemuDomainAsyncJob asyncJob)
379
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
D
Daniel P. Berrange 已提交
380 381


382
qemuAgentPtr qemuDomainGetAgent(virDomainObjPtr vm);
383 384 385 386
void qemuDomainObjEnterAgent(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
void qemuDomainObjExitAgent(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
D
Daniel P. Berrange 已提交
387 388


389 390 391 392
void qemuDomainObjEnterRemote(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
void qemuDomainObjExitRemote(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
393

394 395 396 397
virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
                                  virDomainDefPtr src,
                                  unsigned int flags);

398
int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
399 400 401 402
                           virDomainDefPtr vm,
                           unsigned int flags,
                           virBuffer *buf);

403
char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
404
                             virDomainDefPtr vm,
405
                             unsigned int flags);
406

407
char *qemuDomainFormatXML(virQEMUDriverPtr driver,
408
                          virDomainObjPtr vm,
409
                          unsigned int flags);
410

411
char *qemuDomainDefFormatLive(virQEMUDriverPtr driver,
412
                              virDomainDefPtr def,
413 414
                              bool inactive,
                              bool compatible);
415

416
void qemuDomainObjTaint(virQEMUDriverPtr driver,
417
                        virDomainObjPtr obj,
418
                        virDomainTaintFlags taint,
419
                        qemuDomainLogContextPtr logCtxt);
420

421
void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
422
                             virDomainObjPtr obj,
423
                             qemuDomainLogContextPtr logCtxt);
424
void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver,
425
                                 virDomainObjPtr obj,
426
                                 virDomainDiskDefPtr disk,
427
                                 qemuDomainLogContextPtr logCtxt);
428 429 430
void qemuDomainObjCheckHostdevTaint(virQEMUDriverPtr driver,
                                    virDomainObjPtr obj,
                                    virDomainHostdevDefPtr disk,
431
                                    qemuDomainLogContextPtr logCtxt);
432
void qemuDomainObjCheckNetTaint(virQEMUDriverPtr driver,
433
                                virDomainObjPtr obj,
434
                                virDomainNetDefPtr net,
435
                                qemuDomainLogContextPtr logCtxt);
436

437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
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);
454

455 456
virLogManagerPtr qemuDomainLogContextGetManager(qemuDomainLogContextPtr ctxt);

457
const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
458 459 460

int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
                                    virDomainSnapshotObjPtr snapshot,
461
                                    virCapsPtr caps,
462 463
                                    char *snapshotDir);

464
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
465 466 467 468 469
                                   virDomainObjPtr vm,
                                   virDomainSnapshotObjPtr snap,
                                   const char *op,
                                   bool try_all);

470
int qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
471 472 473 474 475
                              virDomainObjPtr vm,
                              virDomainSnapshotObjPtr snap,
                              bool update_current,
                              bool metadata_only);

476 477 478
typedef struct _virQEMUSnapRemove virQEMUSnapRemove;
typedef virQEMUSnapRemove *virQEMUSnapRemovePtr;
struct _virQEMUSnapRemove {
479
    virQEMUDriverPtr driver;
480 481 482 483 484 485
    virDomainObjPtr vm;
    int err;
    bool metadata_only;
    bool current;
};

486 487 488
int qemuDomainSnapshotDiscardAll(void *payload,
                                 const void *name,
                                 void *data);
489

490
int qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
491 492
                                         virDomainObjPtr vm);

493
void qemuDomainRemoveInactive(virQEMUDriverPtr driver,
494 495
                              virDomainObjPtr vm);

496
void qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
497 498 499
                             virDomainObjPtr vm,
                             bool value);

500
bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv,
501
                          qemuDomainJob job);
M
Michal Privoznik 已提交
502

503
int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
M
Michal Privoznik 已提交
504 505
                                virDomainObjPtr vm,
                                bool start_with_state);
506

507
int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
508
                                 virDomainObjPtr vm,
509
                                 virDomainDiskDefPtr disk,
510 511
                                 bool force_probe,
                                 bool report_broken);
512

513
bool qemuDomainDiskSourceDiffers(virDomainDiskDefPtr disk,
514 515
                                 virDomainDiskDefPtr origDisk);

516 517 518
bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
                                   virDomainDiskDefPtr orig_disk);

519 520 521
int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
                              virStorageSourcePtr src);
522
char *qemuDomainStorageAlias(const char *device, int depth);
523

524 525 526 527 528 529 530 531
void qemuDomainDiskChainElementRevoke(virQEMUDriverPtr driver,
                                      virDomainObjPtr vm,
                                      virStorageSourcePtr elem);
int qemuDomainDiskChainElementPrepare(virQEMUDriverPtr driver,
                                      virDomainObjPtr vm,
                                      virStorageSourcePtr elem,
                                      bool readonly);

532 533 534 535
int qemuDomainCleanupAdd(virDomainObjPtr vm,
                         qemuDomainCleanupCallback cb);
void qemuDomainCleanupRemove(virDomainObjPtr vm,
                             qemuDomainCleanupCallback cb);
536
void qemuDomainCleanupRun(virQEMUDriverPtr driver,
537 538
                          virDomainObjPtr vm);

539 540
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
541
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
542

543
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
544
                               virDomainObjPtr vm, int asyncJob);
545

546 547 548 549
int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     int asyncJob);

550 551 552
bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
                                    virDomainDefPtr src,
                                    virDomainDefPtr dst);
553

554
bool qemuDomainAgentAvailable(virDomainObjPtr vm,
555 556
                              bool reportError);

J
Jiri Denemark 已提交
557 558
int qemuDomainJobInfoUpdateTime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
559 560
int qemuDomainJobInfoUpdateDowntime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
J
Jiri Denemark 已提交
561 562 563 564 565 566 567 568 569 570
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);

571 572
int qemuDomainSupportsBlockJobs(virDomainObjPtr vm, bool *modern)
    ATTRIBUTE_NONNULL(1);
573
bool qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk);
574 575
bool qemuDomainHasBlockjob(virDomainObjPtr vm, bool copy_only)
    ATTRIBUTE_NONNULL(1);
576

577
int qemuDomainAlignMemorySizes(virDomainDefPtr def);
578 579
void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem);
580

581
virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
582

583 584
bool qemuDomainMachineIsQ35(const virDomainDef *def);
bool qemuDomainMachineIsI440FX(const virDomainDef *def);
585
bool qemuDomainMachineNeedsFDC(const virDomainDef *def);
586
bool qemuDomainMachineIsS390CCW(const virDomainDef *def);
J
Ján Tomko 已提交
587
bool qemuDomainMachineIsVirt(const virDomainDef *def);
588
bool qemuDomainMachineHasBuiltinIDE(const virDomainDef *def);
589

590 591 592
int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
                                      virDomainObjPtr vm);

593 594
unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDefPtr def);
bool qemuDomainRequiresMemLock(virDomainDefPtr def);
595
int qemuDomainAdjustMaxMemLock(virDomainObjPtr vm);
596

597 598 599 600
int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
                                       virQEMUCapsPtr qemuCaps,
                                       const virDomainMemoryDef *mem);

601
bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
602
pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpu);
603 604
int qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, virDomainObjPtr vm,
                             int asyncJob);
605

606 607 608 609 610 611 612 613
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
                              virQEMUCapsPtr qemuCaps,
                              virDomainNetDefPtr net);

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

J
John Ferlan 已提交
614
int qemuDomainNetVLAN(virDomainNetDefPtr def);
615

616 617 618
int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

619
void qemuDomainClearPrivatePaths(virDomainObjPtr vm);
P
Peter Krempa 已提交
620 621 622

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

J
John Ferlan 已提交
623 624 625 626
char *qemuDomainGetMasterKeyFilePath(const char *libDir);

int qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv);

M
Martin Kletzander 已提交
627 628
int qemuDomainMasterKeyCreate(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);
J
John Ferlan 已提交
629 630 631

void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);

632 633 634 635 636 637
void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
    ATTRIBUTE_NONNULL(1);

int qemuDomainSecretDiskPrepare(virConnectPtr conn, virDomainDiskDefPtr disk)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

638 639 640 641 642 643 644
void qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr disk)
    ATTRIBUTE_NONNULL(1);

int qemuDomainSecretHostdevPrepare(virConnectPtr conn,
                                   virDomainHostdevDefPtr hostdev)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

645 646 647 648 649 650
void qemuDomainSecretDestroy(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);

int qemuDomainSecretPrepare(virConnectPtr conn, virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

651
#endif /* __QEMU_DOMAIN_H__ */