qemu_domain.h 44.1 KB
Newer Older
1 2 3
/*
 * qemu_domain.h: QEMU domain private state
 *
4
 * Copyright (C) 2006-2019 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17
 * Copyright (C) 2006 Daniel P. Berrange
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library.  If not, see
O
Osier Yang 已提交
19
 * <http://www.gnu.org/licenses/>.
20 21
 */

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

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

#define QEMU_DOMAIN_FORMAT_LIVE_FLAGS \
44
    (VIR_DOMAIN_XML_SECURE)
45

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

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

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

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

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

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

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

    QEMU_AGENT_JOB_LAST
} qemuDomainAgentJob;
92
VIR_ENUM_DECL(qemuDomainAgentJob);
93

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

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

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

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

130 131 132 133 134 135 136 137

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

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

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

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

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

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

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

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

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

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

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

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

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

228

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


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

bool qemuDomainNamespaceEnabled(virDomainObjPtr vm,
                                qemuDomainNamespace ns);

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

    VIR_DOMAIN_SECRET_INFO_TYPE_LAST
} qemuDomainSecretInfoType;

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

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

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

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

287
    qemuDomainJobObj job;
288

289 290
    virBitmapPtr namespaces;

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

    qemuAgentPtr agent;
    bool agentError;

299
    bool beingDestroyed;
300
    char *pidfile;
301

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

305
    virQEMUCapsPtr qemuCaps;
306
    char *lockState;
307 308

    bool fakeReboot;
309
    virTristateBool allowReboot;
310 311

    int jobs_queued;
312 313

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

319
    virChrdevsPtr devs;
320 321 322 323

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

    virCgroupPtr cgroup;
326

327 328
    virPerfPtr perf;

329 330
    qemuDomainUnpluggingDevice unplug;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    virHashTablePtr dbusVMStates;
397 398
};

399
#define QEMU_DOMAIN_PRIVATE(vm) \
400
    ((qemuDomainObjPrivatePtr) (vm)->privateData)
401

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

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

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

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

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

443 444 445 446 447
typedef struct _qemuDomainVcpuPrivate qemuDomainVcpuPrivate;
typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
struct _qemuDomainVcpuPrivate {
    virObject parent;

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

454 455 456
    /* copy of the data that qemu returned */
    virJSONValuePtr props;

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

466
#define QEMU_DOMAIN_VCPU_PRIVATE(vcpu) \
467 468 469
    ((qemuDomainVcpuPrivatePtr) (vcpu)->privateData)


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

479
#define QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev) \
480
    ((qemuDomainChrSourcePrivatePtr) (dev)->privateData)
481

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

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


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

498
    int vhostfd;
J
Ján Tomko 已提交
499 500 501
};


502
#define QEMU_DOMAIN_GRAPHICS_PRIVATE(dev) \
503 504 505 506 507 508 509 510
    ((qemuDomainGraphicsPrivatePtr) (dev)->privateData)

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

    char *tlsAlias;
511
    qemuDomainSecretInfoPtr secinfo;
512 513 514
};


C
Chen Fan 已提交
515 516
typedef enum {
    QEMU_PROCESS_EVENT_WATCHDOG = 0,
517
    QEMU_PROCESS_EVENT_GUESTPANIC,
518
    QEMU_PROCESS_EVENT_DEVICE_DELETED,
519
    QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED,
520
    QEMU_PROCESS_EVENT_SERIAL_CHANGED,
521
    QEMU_PROCESS_EVENT_BLOCK_JOB,
522
    QEMU_PROCESS_EVENT_JOB_STATUS_CHANGE,
523
    QEMU_PROCESS_EVENT_MONITOR_EOF,
524
    QEMU_PROCESS_EVENT_PR_DISCONNECT,
525
    QEMU_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED,
C
Chen Fan 已提交
526 527 528 529 530

    QEMU_PROCESS_EVENT_LAST
} qemuProcessEventType;

struct qemuProcessEvent {
531
    virDomainObjPtr vm;
C
Chen Fan 已提交
532
    qemuProcessEventType eventType;
533
    int action;
534
    int status;
535
    void *data;
536 537
};

538 539
void qemuProcessEventFree(struct qemuProcessEvent *event);

540 541 542
typedef struct _qemuDomainLogContext qemuDomainLogContext;
typedef qemuDomainLogContext *qemuDomainLogContextPtr;

543 544 545 546
typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
struct _qemuDomainSaveCookie {
    virObject parent;
547 548

    virCPUDefPtr cpu;
549 550
};

551 552 553 554 555 556 557 558 559 560

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;
561 562 563 564 565 566

    size_t ncapsadd;
    char **capsadd;

    size_t ncapsdel;
    char **capsdel;
567 568 569
};


570 571
qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);

572
const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
573
                                            int phase);
574
int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
575 576
                                      const char *phase);

577
void qemuDomainEventFlush(int timer, void *opaque);
578

579 580
void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm);
581

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

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

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


644
qemuAgentPtr qemuDomainObjEnterAgent(virDomainObjPtr obj)
645
    ATTRIBUTE_NONNULL(1);
646 647
void qemuDomainObjExitAgent(virDomainObjPtr obj, qemuAgentPtr agent)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
D
Daniel P. Berrange 已提交
648 649


650 651
void qemuDomainObjEnterRemote(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
652 653 654
int qemuDomainObjExitRemote(virDomainObjPtr obj,
                            bool checkActive)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
655

656
virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
657
                                  virQEMUCapsPtr qemuCaps,
658 659 660
                                  virDomainDefPtr src,
                                  unsigned int flags);

661
int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
662
                           virQEMUCapsPtr qemuCaps,
663 664 665 666
                           virDomainDefPtr vm,
                           unsigned int flags,
                           virBuffer *buf);

667
char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
668
                             virQEMUCapsPtr qemuCaps,
669
                             virDomainDefPtr vm,
670
                             unsigned int flags);
671

672
char *qemuDomainFormatXML(virQEMUDriverPtr driver,
673
                          virDomainObjPtr vm,
674
                          unsigned int flags);
675

676
char *qemuDomainDefFormatLive(virQEMUDriverPtr driver,
677
                              virQEMUCapsPtr qemuCaps,
678
                              virDomainDefPtr def,
679
                              virCPUDefPtr origCPU,
680 681
                              bool inactive,
                              bool compatible);
682

683
void qemuDomainObjTaint(virQEMUDriverPtr driver,
684
                        virDomainObjPtr obj,
685
                        virDomainTaintFlags taint,
686
                        qemuDomainLogContextPtr logCtxt);
687

688
void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
689
                             virDomainObjPtr obj,
690
                             qemuDomainLogContextPtr logCtxt);
691
void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver,
692
                                 virDomainObjPtr obj,
693
                                 virDomainDiskDefPtr disk,
694
                                 qemuDomainLogContextPtr logCtxt);
695 696 697
void qemuDomainObjCheckHostdevTaint(virQEMUDriverPtr driver,
                                    virDomainObjPtr obj,
                                    virDomainHostdevDefPtr disk,
698
                                    qemuDomainLogContextPtr logCtxt);
699
void qemuDomainObjCheckNetTaint(virQEMUDriverPtr driver,
700
                                virDomainObjPtr obj,
701
                                virDomainNetDefPtr net,
702
                                qemuDomainLogContextPtr logCtxt);
703

704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
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);
719

720 721
virLogManagerPtr qemuDomainLogContextGetManager(qemuDomainLogContextPtr ctxt);

722 723 724 725 726
int qemuDomainLogAppendMessage(virQEMUDriverPtr driver,
                               virDomainObjPtr vm,
                               const char *fmt,
                               ...) ATTRIBUTE_FMT_PRINTF(3, 4);

727
const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
728 729

int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
730
                                    virDomainMomentObjPtr snapshot,
731
                                    virCapsPtr caps,
732
                                    virDomainXMLOptionPtr xmlopt,
733
                                    const char *snapshotDir);
734

735
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
736
                                   virDomainObjPtr vm,
737
                                   virDomainMomentObjPtr snap,
738 739 740
                                   const char *op,
                                   bool try_all);

741
int qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
742
                              virDomainObjPtr vm,
743
                              virDomainMomentObjPtr snap,
744 745 746
                              bool update_current,
                              bool metadata_only);

747 748 749
typedef struct _virQEMUMomentRemove virQEMUMomentRemove;
typedef virQEMUMomentRemove *virQEMUMomentRemovePtr;
struct _virQEMUMomentRemove {
750
    virQEMUDriverPtr driver;
751 752 753
    virDomainObjPtr vm;
    int err;
    bool metadata_only;
754 755 756 757
    virDomainMomentObjPtr current;
    bool found;
    int (*momentDiscard)(virQEMUDriverPtr, virDomainObjPtr,
                         virDomainMomentObjPtr, bool, bool);
758 759
};

760 761 762
int qemuDomainMomentDiscardAll(void *payload,
                               const void *name,
                               void *data);
763

764
int qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
765 766
                                         virDomainObjPtr vm);

767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
int qemuDomainCheckpointWriteMetadata(virDomainObjPtr vm,
                                      virDomainMomentObjPtr checkpoint,
                                      virCapsPtr caps,
                                      virDomainXMLOptionPtr xmlopt,
                                      const char *checkpointDir);

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

int qemuDomainCheckpointDiscardAllMetadata(virQEMUDriverPtr driver,
                                           virDomainObjPtr vm);

782
void qemuDomainRemoveInactive(virQEMUDriverPtr driver,
783 784
                              virDomainObjPtr vm);

785 786 787
void qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

788 789 790
void qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver,
                                       virDomainObjPtr vm);

791
void qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
792 793 794
                             virDomainObjPtr vm,
                             bool value);

795
bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv,
796
                          qemuDomainJob job);
M
Michal Privoznik 已提交
797

798 799 800 801 802
int qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     size_t diskIndex,
                                     bool cold_boot);

803
int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
M
Michal Privoznik 已提交
804
                                virDomainObjPtr vm,
805
                                unsigned int flags);
806

807 808 809 810
int qemuDomainStorageSourceValidateDepth(virStorageSourcePtr src,
                                         int add,
                                         const char *diskdst);

811
int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
812
                                 virDomainObjPtr vm,
813
                                 virDomainDiskDefPtr disk,
814
                                 virStorageSourcePtr disksrc,
815
                                 bool report_broken);
816

817 818 819
bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
                                   virDomainDiskDefPtr orig_disk);

820 821 822
const char *qemuDomainDiskNodeFormatLookup(virDomainObjPtr vm,
                                           const char *disk);

823 824
int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
825 826
                              virStorageSourcePtr src,
                              virStorageSourcePtr parent);
827
char *qemuDomainStorageAlias(const char *device, int depth);
828

829 830 831 832 833 834
int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
                                  virQEMUCapsPtr qemuCaps,
                                  char **backendAlias)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;

835 836 837 838 839 840
int qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
                                            virDomainObjPtr vm,
                                            virStorageSourcePtr src);
int qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
                                             virDomainObjPtr vm,
                                             virStorageSourcePtr src);
841

842 843 844 845 846 847 848 849
void qemuDomainStorageSourceAccessRevoke(virQEMUDriverPtr driver,
                                         virDomainObjPtr vm,
                                         virStorageSourcePtr elem);
int qemuDomainStorageSourceAccessAllow(virQEMUDriverPtr driver,
                                       virDomainObjPtr vm,
                                       virStorageSourcePtr elem,
                                       bool readonly,
                                       bool newSource);
850

851 852 853 854 855
int qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
                                           virStorageSourcePtr src,
                                           qemuDomainObjPrivatePtr priv,
                                           virQEMUDriverConfigPtr cfg);

856 857 858 859
int qemuDomainCleanupAdd(virDomainObjPtr vm,
                         qemuDomainCleanupCallback cb);
void qemuDomainCleanupRemove(virDomainObjPtr vm,
                             qemuDomainCleanupCallback cb);
860
void qemuDomainCleanupRun(virQEMUDriverPtr driver,
861 862
                          virDomainObjPtr vm);

863 864
void qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv);

865
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
866
extern virXMLNamespace virQEMUDriverDomainXMLNamespace;
867
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
868
extern virDomainABIStability virQEMUDriverDomainABIStability;
869
extern virSaveCookieCallbacks virQEMUDriverDomainSaveCookie;
870

871
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
872
                               virDomainObjPtr vm, int asyncJob);
873

874 875 876 877
int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     int asyncJob);

878
bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
879
                                    virQEMUCapsPtr qemuCaps,
880 881
                                    virDomainDefPtr src,
                                    virDomainDefPtr dst);
882

883 884 885 886
bool qemuDomainCheckABIStability(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm,
                                 virDomainDefPtr dst);

887
bool qemuDomainAgentAvailable(virDomainObjPtr vm,
888 889
                              bool reportError);

J
Jiri Denemark 已提交
890 891
int qemuDomainJobInfoUpdateTime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
892 893
int qemuDomainJobInfoUpdateDowntime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
J
Jiri Denemark 已提交
894 895 896 897 898 899 900 901 902 903
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);

904
bool qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk);
905 906
bool qemuDomainHasBlockjob(virDomainObjPtr vm, bool copy_only)
    ATTRIBUTE_NONNULL(1);
907

908
int qemuDomainAlignMemorySizes(virDomainDefPtr def);
909 910
void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem);
911

912
virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
913

914 915
/* You should normally avoid these functions and use the variant that
 * doesn't have "Machine" in the name instead. */
916 917
bool qemuDomainMachineIsARMVirt(const char *machine,
                                const virArch arch);
918 919
bool qemuDomainMachineIsPSeries(const char *machine,
                                const virArch arch);
920 921
bool qemuDomainMachineHasBuiltinIDE(const char *machine,
                                    const virArch arch);
A
Andrea Bolognani 已提交
922 923 924 925 926 927 928 929 930 931 932

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);
933 934
bool qemuDomainSupportsPCI(virDomainDefPtr def,
                           virQEMUCapsPtr qemuCaps);
935

936
void qemuDomainUpdateCurrentMemorySize(virDomainObjPtr vm);
937

938
unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDefPtr def);
939
int qemuDomainAdjustMaxMemLock(virDomainObjPtr vm);
940

941 942 943 944
int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
                                       virQEMUCapsPtr qemuCaps,
                                       const virDomainMemoryDef *mem);

945
bool qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm);
946
bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
947
pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid);
948
int qemuDomainValidateVcpuInfo(virDomainObjPtr vm);
949 950
int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
951 952
                              int asyncJob,
                              bool state);
953 954 955 956
bool qemuDomainGetVcpuHalted(virDomainObjPtr vm, unsigned int vcpu);
int qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                int asyncJob);
957

958 959 960
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
                              virDomainNetDefPtr net);

961 962
bool qemuDomainNetSupportsMTU(virDomainNetType type);

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

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

J
John Ferlan 已提交
968 969 970 971
char *qemuDomainGetMasterKeyFilePath(const char *libDir);

int qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv);

972 973 974 975
int qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

int qemuDomainMasterKeyCreate(virDomainObjPtr vm);
J
John Ferlan 已提交
976 977 978

void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);

979 980
bool qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivatePtr priv);

981 982 983
void qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
    ATTRIBUTE_NONNULL(1);

984 985
void qemuDomainSecretInfoDestroy(qemuDomainSecretInfoPtr secinfo);

986 987 988
void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
    ATTRIBUTE_NONNULL(1);

989
bool qemuDomainStorageSourceHasAuth(virStorageSourcePtr src)
990 991
    ATTRIBUTE_NONNULL(1);

992 993 994
bool qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
    ATTRIBUTE_NONNULL(1);

995
qemuDomainSecretInfoPtr
996
qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr priv,
997 998 999
                           const char *srcAlias,
                           const char *secretUUID);

1000 1001 1002
void qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr disk)
    ATTRIBUTE_NONNULL(1);

1003
int qemuDomainSecretHostdevPrepare(qemuDomainObjPrivatePtr priv,
1004
                                   virDomainHostdevDefPtr hostdev)
1005
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
1006

1007 1008 1009
void qemuDomainSecretChardevDestroy(virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1);

1010
int qemuDomainSecretChardevPrepare(virQEMUDriverConfigPtr cfg,
1011 1012 1013 1014
                                   qemuDomainObjPrivatePtr priv,
                                   const char *chrAlias,
                                   virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
1015
    ATTRIBUTE_NONNULL(4);
1016

1017 1018 1019
void qemuDomainSecretDestroy(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);

1020
int qemuDomainSecretPrepare(virQEMUDriverPtr driver,
1021
                            virDomainObjPtr vm)
1022
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
1023

1024 1025 1026
int qemuDomainDefValidateDiskLunSource(const virStorageSource *src)
    ATTRIBUTE_NONNULL(1);

1027 1028 1029
int qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk,
                                    virQEMUCapsPtr qemuCaps);

1030 1031 1032 1033
int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
                             const char *domainChannelTargetDir)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

1034 1035 1036 1037 1038
void qemuDomainPrepareChardevSourceTLS(virDomainChrSourceDefPtr source,
                                       virQEMUDriverConfigPtr cfg)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void qemuDomainPrepareChardevSource(virDomainDefPtr def,
1039
                                    virQEMUDriverConfigPtr cfg)
1040 1041
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

1042 1043 1044
int qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1);

1045 1046 1047
bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

1048 1049 1050
void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

1051 1052 1053 1054
int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
                           virDomainObjPtr vm,
                           qemuDomainAsyncJob asyncJob);

1055 1056 1057
bool qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
                                virQEMUCapsPtr qemuCaps);

1058 1059 1060
int qemuDomainGetHostdevPath(virDomainDefPtr def,
                             virDomainHostdevDefPtr dev,
                             bool teardown,
1061 1062 1063
                             size_t *npaths,
                             char ***path,
                             int **perms);
1064

1065 1066
int qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
                             virSecurityManagerPtr mgr,
1067 1068 1069 1070 1071
                             virDomainObjPtr vm);

int qemuDomainCreateNamespace(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

1072 1073 1074
void qemuDomainDestroyNamespace(virQEMUDriverPtr driver,
                                virDomainObjPtr vm);

1075 1076
bool qemuDomainNamespaceAvailable(qemuDomainNamespace ns);

1077
int qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
1078
                                 virStorageSourcePtr src);
1079

1080
int qemuDomainNamespaceTeardownDisk(virDomainObjPtr vm,
1081
                                    virStorageSourcePtr src);
1082

1083
int qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm,
1084 1085
                                    virDomainHostdevDefPtr hostdev);

1086
int qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
1087
                                       virDomainHostdevDefPtr hostdev);
1088

1089
int qemuDomainNamespaceSetupMemory(virDomainObjPtr vm,
M
Michal Privoznik 已提交
1090 1091
                                   virDomainMemoryDefPtr memory);

1092
int qemuDomainNamespaceTeardownMemory(virDomainObjPtr vm,
M
Michal Privoznik 已提交
1093 1094
                                      virDomainMemoryDefPtr memory);

1095
int qemuDomainNamespaceSetupChardev(virDomainObjPtr vm,
1096 1097
                                    virDomainChrDefPtr chr);

1098
int qemuDomainNamespaceTeardownChardev(virDomainObjPtr vm,
1099
                                       virDomainChrDefPtr chr);
1100

1101
int qemuDomainNamespaceSetupRNG(virDomainObjPtr vm,
1102
                                virDomainRNGDefPtr rng);
1103

1104
int qemuDomainNamespaceTeardownRNG(virDomainObjPtr vm,
1105
                                   virDomainRNGDefPtr rng);
1106

1107 1108 1109 1110 1111 1112
int qemuDomainNamespaceSetupInput(virDomainObjPtr vm,
                                  virDomainInputDefPtr input);

int qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
                                     virDomainInputDefPtr input);

1113 1114 1115 1116 1117
virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def,
                                                   const char *nodename,
                                                   virStorageSourcePtr *src,
                                                   unsigned int *idx);

1118 1119 1120 1121
char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
                                        virStorageSourcePtr src,
                                        unsigned int idx);

1122 1123 1124
virStorageSourcePtr qemuDomainGetStorageSourceByDevstr(const char *devstr,
                                                       virDomainDefPtr def);

1125 1126 1127 1128 1129
int
qemuDomainUpdateCPU(virDomainObjPtr vm,
                    virCPUDefPtr cpu,
                    virCPUDefPtr *origCPU);

1130 1131 1132 1133
int
qemuDomainFixupCPUs(virDomainObjPtr vm,
                    virCPUDefPtr *origCPU);

1134 1135 1136 1137
int
qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
                         virFileCachePtr qemuCapsCache);

1138 1139 1140
char *
qemuDomainGetMachineName(virDomainObjPtr vm);

1141 1142 1143 1144 1145 1146 1147 1148
void
qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf,
                                         virTristateBool allowReboot);

int
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
                                        virTristateBool *allowReboot);

1149 1150 1151 1152 1153
bool
qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
                                     const virDomainDeviceInfo *info,
                                     virQEMUCapsPtr qemuCaps,
                                     const char *devicename);
1154

1155
int
1156 1157 1158 1159
qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
                                virStorageSourcePtr src,
                                virQEMUDriverConfigPtr cfg,
                                virQEMUCapsPtr qemuCaps)
1160
    ATTRIBUTE_RETURN_CHECK;
1161

1162 1163 1164 1165 1166 1167

int
qemuDomainValidateStorageSource(virStorageSourcePtr src,
                                virQEMUCapsPtr qemuCaps);


1168
int
1169
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
1170 1171 1172
                            qemuDomainObjPrivatePtr priv,
                            virQEMUDriverConfigPtr cfg);

1173 1174 1175 1176 1177 1178
int
qemuDomainDiskCachemodeFlags(int cachemode,
                             bool *writeback,
                             bool *direct,
                             bool *noflush);

1179
char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);
1180

1181 1182
bool qemuDomainDefHasManagedPR(virDomainObjPtr vm);

1183 1184 1185
unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivatePtr priv);
void qemuDomainStorageIdReset(qemuDomainObjPrivatePtr priv);

1186 1187 1188
virDomainEventResumedDetailType
qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);

J
John Ferlan 已提交
1189 1190 1191
bool
qemuDomainIsUsingNoShutdown(qemuDomainObjPrivatePtr priv);

1192 1193 1194
bool
qemuDomainDiskIsMissingLocalOptional(virDomainDiskDefPtr disk);

1195 1196 1197 1198
int
qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg,
                            virDomainDefPtr def);

1199 1200
virDomainEventSuspendedDetailType
qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason);