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

22 23 24 25 26 27 28 29 30 31 32 33 34 35 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
#define QEMU_DOMAIN_PRIVATE(vm) \
395
    ((qemuDomainObjPrivatePtr) (vm)->privateData)
396

397
#define QEMU_DOMAIN_DISK_PRIVATE(disk) \
398 399 400 401 402 403 404 405 406 407
    ((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 */
408
    qemuBlockJobDataPtr blockjob;
409 410

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

413 414 415
    /* information about the device */
    bool tray; /* device has tray */
    bool removable; /* device media can be removed/changed */
416 417

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

421
#define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
    ((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);

438 439 440 441 442
typedef struct _qemuDomainVcpuPrivate qemuDomainVcpuPrivate;
typedef qemuDomainVcpuPrivate *qemuDomainVcpuPrivatePtr;
struct _qemuDomainVcpuPrivate {
    virObject parent;

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

    /* information for hotpluggable cpus */
    char *type;
    int socket_id;
    int core_id;
    int thread_id;
454
    int node_id;
455
    int vcpus;
456 457
};

458
#define QEMU_DOMAIN_VCPU_PRIVATE(vcpu) \
459 460 461
    ((qemuDomainVcpuPrivatePtr) (vcpu)->privateData)


462 463
struct qemuDomainDiskInfo {
    bool removable;
464
    bool tray;
465
    bool tray_open;
466
    bool empty;
467
    int io_status;
468
    char *nodename;
469 470
};

471
#define QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev) \
472
    ((qemuDomainChrSourcePrivatePtr) (dev)->privateData)
473

474 475 476
typedef struct _qemuDomainChrSourcePrivate qemuDomainChrSourcePrivate;
typedef qemuDomainChrSourcePrivate *qemuDomainChrSourcePrivatePtr;
struct _qemuDomainChrSourcePrivate {
477 478 479 480 481 482 483 484
    virObject parent;

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


J
Ján Tomko 已提交
485 486 487 488 489
typedef struct _qemuDomainVsockPrivate qemuDomainVsockPrivate;
typedef qemuDomainVsockPrivate *qemuDomainVsockPrivatePtr;
struct _qemuDomainVsockPrivate {
    virObject parent;

490
    int vhostfd;
J
Ján Tomko 已提交
491 492 493
};


494
#define QEMU_DOMAIN_GRAPHICS_PRIVATE(dev) \
495 496 497 498 499 500 501 502
    ((qemuDomainGraphicsPrivatePtr) (dev)->privateData)

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

    char *tlsAlias;
503
    qemuDomainSecretInfoPtr secinfo;
504 505 506
};


C
Chen Fan 已提交
507 508
typedef enum {
    QEMU_PROCESS_EVENT_WATCHDOG = 0,
509
    QEMU_PROCESS_EVENT_GUESTPANIC,
510
    QEMU_PROCESS_EVENT_DEVICE_DELETED,
511
    QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED,
512
    QEMU_PROCESS_EVENT_SERIAL_CHANGED,
513
    QEMU_PROCESS_EVENT_BLOCK_JOB,
514
    QEMU_PROCESS_EVENT_MONITOR_EOF,
515
    QEMU_PROCESS_EVENT_PR_DISCONNECT,
516
    QEMU_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED,
C
Chen Fan 已提交
517 518 519 520 521

    QEMU_PROCESS_EVENT_LAST
} qemuProcessEventType;

struct qemuProcessEvent {
522
    virDomainObjPtr vm;
C
Chen Fan 已提交
523
    qemuProcessEventType eventType;
524
    int action;
525
    int status;
526
    void *data;
527 528
};

529 530
void qemuProcessEventFree(struct qemuProcessEvent *event);

531 532 533
typedef struct _qemuDomainLogContext qemuDomainLogContext;
typedef qemuDomainLogContext *qemuDomainLogContextPtr;

534 535 536 537
typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
struct _qemuDomainSaveCookie {
    virObject parent;
538 539

    virCPUDefPtr cpu;
540 541
};

542 543 544 545 546 547 548 549 550 551

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;
552 553 554 555 556 557

    size_t ncapsadd;
    char **capsadd;

    size_t ncapsdel;
    char **capsdel;
558 559 560
};


561 562
qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);

563
const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
564
                                            int phase);
565
int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
J
Jiri Denemark 已提交
566 567
                                      const char *phase);

568
void qemuDomainEventFlush(int timer, void *opaque);
569

570 571
void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm);
572

573
int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
574
                          virDomainObjPtr obj,
575
                          qemuDomainJob job)
576
    ATTRIBUTE_RETURN_CHECK;
577 578 579 580 581 582 583 584 585
int qemuDomainObjBeginAgentJob(virQEMUDriverPtr driver,
                               virDomainObjPtr obj,
                               qemuDomainAgentJob agentJob)
    ATTRIBUTE_RETURN_CHECK;
int qemuDomainObjBeginJobWithAgent(virQEMUDriverPtr driver,
                                   virDomainObjPtr obj,
                                   qemuDomainJob job,
                                   qemuDomainAgentJob agentJob)
    ATTRIBUTE_RETURN_CHECK;
586
int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver,
587
                               virDomainObjPtr obj,
588
                               qemuDomainAsyncJob asyncJob,
589 590
                               virDomainJobOperation operation,
                               unsigned long apiFlags)
591
    ATTRIBUTE_RETURN_CHECK;
592 593 594 595
int qemuDomainObjBeginNestedJob(virQEMUDriverPtr driver,
                                virDomainObjPtr obj,
                                qemuDomainAsyncJob asyncJob)
    ATTRIBUTE_RETURN_CHECK;
596 597 598 599
int qemuDomainObjBeginJobNowait(virQEMUDriverPtr driver,
                                virDomainObjPtr obj,
                                qemuDomainJob job)
    ATTRIBUTE_RETURN_CHECK;
600

601 602
void qemuDomainObjEndJob(virQEMUDriverPtr driver,
                         virDomainObjPtr obj);
603 604 605
void qemuDomainObjEndAgentJob(virDomainObjPtr obj);
void qemuDomainObjEndJobWithAgent(virQEMUDriverPtr driver,
                                  virDomainObjPtr obj);
606 607
void qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver,
                              virDomainObjPtr obj);
608
void qemuDomainObjAbortAsyncJob(virDomainObjPtr obj);
609
void qemuDomainObjSetJobPhase(virQEMUDriverPtr driver,
J
Jiri Denemark 已提交
610 611
                              virDomainObjPtr obj,
                              int phase);
612 613
void qemuDomainObjSetAsyncJobMask(virDomainObjPtr obj,
                                  unsigned long long allowedJobs);
614
void qemuDomainObjRestoreJob(virDomainObjPtr obj,
615
                             qemuDomainJobObjPtr job);
616
void qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver,
617
                                  virDomainObjPtr obj);
618
void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj);
619

620 621
qemuMonitorPtr qemuDomainGetMonitor(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);
622
void qemuDomainObjEnterMonitor(virQEMUDriverPtr driver,
623 624
                               virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
625 626
int qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
                             virDomainObjPtr obj)
627 628
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
    ATTRIBUTE_RETURN_CHECK;
629
int qemuDomainObjEnterMonitorAsync(virQEMUDriverPtr driver,
630
                                   virDomainObjPtr obj,
631
                                   qemuDomainAsyncJob asyncJob)
632
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
D
Daniel P. Berrange 已提交
633 634


635
qemuAgentPtr qemuDomainObjEnterAgent(virDomainObjPtr obj)
636
    ATTRIBUTE_NONNULL(1);
637 638
void qemuDomainObjExitAgent(virDomainObjPtr obj, qemuAgentPtr agent)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
D
Daniel P. Berrange 已提交
639 640


641 642
void qemuDomainObjEnterRemote(virDomainObjPtr obj)
    ATTRIBUTE_NONNULL(1);
643 644 645
int qemuDomainObjExitRemote(virDomainObjPtr obj,
                            bool checkActive)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
646

647 648 649 650
virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
                                  virDomainDefPtr src,
                                  unsigned int flags);

651
int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
652 653 654 655
                           virDomainDefPtr vm,
                           unsigned int flags,
                           virBuffer *buf);

656
char *qemuDomainDefFormatXML(virQEMUDriverPtr driver,
657
                             virDomainDefPtr vm,
658
                             unsigned int flags);
659

660
char *qemuDomainFormatXML(virQEMUDriverPtr driver,
661
                          virDomainObjPtr vm,
662
                          unsigned int flags);
663

664
char *qemuDomainDefFormatLive(virQEMUDriverPtr driver,
665
                              virDomainDefPtr def,
666
                              virCPUDefPtr origCPU,
667 668
                              bool inactive,
                              bool compatible);
669

670
void qemuDomainObjTaint(virQEMUDriverPtr driver,
671
                        virDomainObjPtr obj,
672
                        virDomainTaintFlags taint,
673
                        qemuDomainLogContextPtr logCtxt);
674

675
void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
676
                             virDomainObjPtr obj,
677
                             qemuDomainLogContextPtr logCtxt);
678
void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr driver,
679
                                 virDomainObjPtr obj,
680
                                 virDomainDiskDefPtr disk,
681
                                 qemuDomainLogContextPtr logCtxt);
682 683 684
void qemuDomainObjCheckHostdevTaint(virQEMUDriverPtr driver,
                                    virDomainObjPtr obj,
                                    virDomainHostdevDefPtr disk,
685
                                    qemuDomainLogContextPtr logCtxt);
686
void qemuDomainObjCheckNetTaint(virQEMUDriverPtr driver,
687
                                virDomainObjPtr obj,
688
                                virDomainNetDefPtr net,
689
                                qemuDomainLogContextPtr logCtxt);
690

691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
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);
706

707 708
virLogManagerPtr qemuDomainLogContextGetManager(qemuDomainLogContextPtr ctxt);

709 710 711 712 713
int qemuDomainLogAppendMessage(virQEMUDriverPtr driver,
                               virDomainObjPtr vm,
                               const char *fmt,
                               ...) ATTRIBUTE_FMT_PRINTF(3, 4);

714
const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);
715 716

int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
717
                                    virDomainMomentObjPtr snapshot,
718
                                    virCapsPtr caps,
719
                                    virDomainXMLOptionPtr xmlopt,
720
                                    const char *snapshotDir);
721

722
int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
723
                                   virDomainObjPtr vm,
724
                                   virDomainMomentObjPtr snap,
725 726 727
                                   const char *op,
                                   bool try_all);

728
int qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
729
                              virDomainObjPtr vm,
730
                              virDomainMomentObjPtr snap,
731 732 733
                              bool update_current,
                              bool metadata_only);

734 735 736
typedef struct _virQEMUMomentRemove virQEMUMomentRemove;
typedef virQEMUMomentRemove *virQEMUMomentRemovePtr;
struct _virQEMUMomentRemove {
737
    virQEMUDriverPtr driver;
738 739 740
    virDomainObjPtr vm;
    int err;
    bool metadata_only;
741 742 743 744
    virDomainMomentObjPtr current;
    bool found;
    int (*momentDiscard)(virQEMUDriverPtr, virDomainObjPtr,
                         virDomainMomentObjPtr, bool, bool);
745 746
};

747 748 749
int qemuDomainMomentDiscardAll(void *payload,
                               const void *name,
                               void *data);
750

751
int qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver,
752 753
                                         virDomainObjPtr vm);

754
void qemuDomainRemoveInactive(virQEMUDriverPtr driver,
755 756
                              virDomainObjPtr vm);

757 758 759
void qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

760 761 762
void qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver,
                                       virDomainObjPtr vm);

763
void qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
764 765 766
                             virDomainObjPtr vm,
                             bool value);

767
bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv,
768
                          qemuDomainJob job);
M
Michal Privoznik 已提交
769

770 771 772 773 774
int qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     size_t diskIndex,
                                     bool cold_boot);

775
int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
M
Michal Privoznik 已提交
776
                                virDomainObjPtr vm,
777
                                unsigned int flags);
778

779
int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
780
                                 virDomainObjPtr vm,
781
                                 virDomainDiskDefPtr disk,
782
                                 virStorageSourcePtr disksrc,
783
                                 bool report_broken);
784

785 786 787
bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
                                   virDomainDiskDefPtr orig_disk);

788 789
int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
790 791
                              virStorageSourcePtr src,
                              virStorageSourcePtr parent);
792
char *qemuDomainStorageAlias(const char *device, int depth);
793

794 795 796 797 798 799
int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
                                  virQEMUCapsPtr qemuCaps,
                                  char **backendAlias)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;

800 801 802 803 804 805
int qemuDomainStorageSourceChainAccessAllow(virQEMUDriverPtr driver,
                                            virDomainObjPtr vm,
                                            virStorageSourcePtr src);
int qemuDomainStorageSourceChainAccessRevoke(virQEMUDriverPtr driver,
                                             virDomainObjPtr vm,
                                             virStorageSourcePtr src);
806

807 808 809 810 811 812 813 814
void qemuDomainStorageSourceAccessRevoke(virQEMUDriverPtr driver,
                                         virDomainObjPtr vm,
                                         virStorageSourcePtr elem);
int qemuDomainStorageSourceAccessAllow(virQEMUDriverPtr driver,
                                       virDomainObjPtr vm,
                                       virStorageSourcePtr elem,
                                       bool readonly,
                                       bool newSource);
815

816 817 818 819 820
int qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk,
                                           virStorageSourcePtr src,
                                           qemuDomainObjPrivatePtr priv,
                                           virQEMUDriverConfigPtr cfg);

821 822 823 824
int qemuDomainCleanupAdd(virDomainObjPtr vm,
                         qemuDomainCleanupCallback cb);
void qemuDomainCleanupRemove(virDomainObjPtr vm,
                             qemuDomainCleanupCallback cb);
825
void qemuDomainCleanupRun(virQEMUDriverPtr driver,
826 827
                          virDomainObjPtr vm);

828 829
void qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr priv);

830 831
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
832
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
833
extern virDomainABIStability virQEMUDriverDomainABIStability;
834
extern virSaveCookieCallbacks virQEMUDriverDomainSaveCookie;
835

836
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
837
                               virDomainObjPtr vm, int asyncJob);
838

839 840 841 842
int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
                                     int asyncJob);

843 844 845
bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
                                    virDomainDefPtr src,
                                    virDomainDefPtr dst);
846

847 848 849 850
bool qemuDomainCheckABIStability(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm,
                                 virDomainDefPtr dst);

851
bool qemuDomainAgentAvailable(virDomainObjPtr vm,
852 853
                              bool reportError);

J
Jiri Denemark 已提交
854 855
int qemuDomainJobInfoUpdateTime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
856 857
int qemuDomainJobInfoUpdateDowntime(qemuDomainJobInfoPtr jobInfo)
    ATTRIBUTE_NONNULL(1);
J
Jiri Denemark 已提交
858 859 860 861 862 863 864 865 866 867
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);

868
bool qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk);
869 870
bool qemuDomainHasBlockjob(virDomainObjPtr vm, bool copy_only)
    ATTRIBUTE_NONNULL(1);
871

872
int qemuDomainAlignMemorySizes(virDomainDefPtr def);
873 874
void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
                                     virDomainMemoryDefPtr mem);
875

876
virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
877

878 879
/* You should normally avoid these functions and use the variant that
 * doesn't have "Machine" in the name instead. */
880 881
bool qemuDomainMachineIsARMVirt(const char *machine,
                                const virArch arch);
882 883
bool qemuDomainMachineIsPSeries(const char *machine,
                                const virArch arch);
884 885
bool qemuDomainMachineHasBuiltinIDE(const char *machine,
                                    const virArch arch);
A
Andrea Bolognani 已提交
886 887 888 889 890 891 892 893 894 895 896

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);
897 898
bool qemuDomainSupportsPCI(virDomainDefPtr def,
                           virQEMUCapsPtr qemuCaps);
899

900
void qemuDomainUpdateCurrentMemorySize(virDomainObjPtr vm);
901

902
unsigned long long qemuDomainGetMemLockLimitBytes(virDomainDefPtr def);
903
int qemuDomainAdjustMaxMemLock(virDomainObjPtr vm);
904

905 906 907 908
int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def,
                                       virQEMUCapsPtr qemuCaps,
                                       const virDomainMemoryDef *mem);

909
bool qemuDomainSupportsNewVcpuHotplug(virDomainObjPtr vm);
910
bool qemuDomainHasVcpuPids(virDomainObjPtr vm);
911
pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpuid);
912
int qemuDomainValidateVcpuInfo(virDomainObjPtr vm);
913 914
int qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
915 916
                              int asyncJob,
                              bool state);
917 918 919 920
bool qemuDomainGetVcpuHalted(virDomainObjPtr vm, unsigned int vcpu);
int qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
                                virDomainObjPtr vm,
                                int asyncJob);
921

922 923 924
bool qemuDomainSupportsNicdev(virDomainDefPtr def,
                              virDomainNetDefPtr net);

925 926
bool qemuDomainNetSupportsMTU(virDomainNetType type);

927 928 929
int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

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

J
John Ferlan 已提交
932 933 934 935
char *qemuDomainGetMasterKeyFilePath(const char *libDir);

int qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr priv);

936 937 938 939
int qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver,
                                 virDomainObjPtr vm);

int qemuDomainMasterKeyCreate(virDomainObjPtr vm);
J
John Ferlan 已提交
940 941 942

void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);

943 944
bool qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivatePtr priv);

945 946 947
void qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
    ATTRIBUTE_NONNULL(1);

948 949
void qemuDomainSecretInfoDestroy(qemuDomainSecretInfoPtr secinfo);

950 951 952
void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
    ATTRIBUTE_NONNULL(1);

953
bool qemuDomainStorageSourceHasAuth(virStorageSourcePtr src)
954 955
    ATTRIBUTE_NONNULL(1);

956 957 958
bool qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
    ATTRIBUTE_NONNULL(1);

959
qemuDomainSecretInfoPtr
960
qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr priv,
961 962 963
                           const char *srcAlias,
                           const char *secretUUID);

964 965 966
void qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr disk)
    ATTRIBUTE_NONNULL(1);

967
int qemuDomainSecretHostdevPrepare(qemuDomainObjPrivatePtr priv,
968
                                   virDomainHostdevDefPtr hostdev)
969
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
970

971 972 973
void qemuDomainSecretChardevDestroy(virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1);

974
int qemuDomainSecretChardevPrepare(virQEMUDriverConfigPtr cfg,
975 976 977 978
                                   qemuDomainObjPrivatePtr priv,
                                   const char *chrAlias,
                                   virDomainChrSourceDefPtr dev)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
979
    ATTRIBUTE_NONNULL(4);
980

981 982 983
void qemuDomainSecretDestroy(virDomainObjPtr vm)
    ATTRIBUTE_NONNULL(1);

984
int qemuDomainSecretPrepare(virQEMUDriverPtr driver,
985
                            virDomainObjPtr vm)
986
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
987

988 989 990
int qemuDomainDefValidateDiskLunSource(const virStorageSource *src)
    ATTRIBUTE_NONNULL(1);

991 992 993
int qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk,
                                    virQEMUCapsPtr qemuCaps);

994 995 996 997
int qemuDomainPrepareChannel(virDomainChrDefPtr chr,
                             const char *domainChannelTargetDir)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

998 999 1000 1001 1002
void qemuDomainPrepareChardevSourceTLS(virDomainChrSourceDefPtr source,
                                       virQEMUDriverConfigPtr cfg)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

void qemuDomainPrepareChardevSource(virDomainDefPtr def,
1003
                                    virQEMUDriverConfigPtr cfg)
1004 1005
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

1006 1007 1008
int qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
    ATTRIBUTE_NONNULL(1);

1009 1010 1011
bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

1012 1013 1014
void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
    ATTRIBUTE_NONNULL(1);

1015 1016 1017 1018
int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
                           virDomainObjPtr vm,
                           qemuDomainAsyncJob asyncJob);

1019 1020 1021
bool qemuDomainSupportsVideoVga(virDomainVideoDefPtr video,
                                virQEMUCapsPtr qemuCaps);

1022 1023 1024
int qemuDomainGetHostdevPath(virDomainDefPtr def,
                             virDomainHostdevDefPtr dev,
                             bool teardown,
1025 1026 1027
                             size_t *npaths,
                             char ***path,
                             int **perms);
1028

1029 1030
int qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
                             virSecurityManagerPtr mgr,
1031 1032 1033 1034 1035
                             virDomainObjPtr vm);

int qemuDomainCreateNamespace(virQEMUDriverPtr driver,
                              virDomainObjPtr vm);

1036 1037 1038
void qemuDomainDestroyNamespace(virQEMUDriverPtr driver,
                                virDomainObjPtr vm);

1039 1040
bool qemuDomainNamespaceAvailable(qemuDomainNamespace ns);

1041
int qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
1042
                                 virStorageSourcePtr src);
1043

1044
int qemuDomainNamespaceTeardownDisk(virDomainObjPtr vm,
1045
                                    virStorageSourcePtr src);
1046

1047
int qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm,
1048 1049
                                    virDomainHostdevDefPtr hostdev);

1050
int qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
1051
                                       virDomainHostdevDefPtr hostdev);
1052

1053
int qemuDomainNamespaceSetupMemory(virDomainObjPtr vm,
M
Michal Privoznik 已提交
1054 1055
                                   virDomainMemoryDefPtr memory);

1056
int qemuDomainNamespaceTeardownMemory(virDomainObjPtr vm,
M
Michal Privoznik 已提交
1057 1058
                                      virDomainMemoryDefPtr memory);

1059
int qemuDomainNamespaceSetupChardev(virDomainObjPtr vm,
1060 1061
                                    virDomainChrDefPtr chr);

1062
int qemuDomainNamespaceTeardownChardev(virDomainObjPtr vm,
1063
                                       virDomainChrDefPtr chr);
1064

1065
int qemuDomainNamespaceSetupRNG(virDomainObjPtr vm,
1066
                                virDomainRNGDefPtr rng);
1067

1068
int qemuDomainNamespaceTeardownRNG(virDomainObjPtr vm,
1069
                                   virDomainRNGDefPtr rng);
1070

1071 1072 1073 1074 1075 1076
int qemuDomainNamespaceSetupInput(virDomainObjPtr vm,
                                  virDomainInputDefPtr input);

int qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
                                     virDomainInputDefPtr input);

1077 1078 1079 1080 1081
virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def,
                                                   const char *nodename,
                                                   virStorageSourcePtr *src,
                                                   unsigned int *idx);

1082 1083 1084 1085
char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
                                        virStorageSourcePtr src,
                                        unsigned int idx);

1086 1087 1088
virStorageSourcePtr qemuDomainGetStorageSourceByDevstr(const char *devstr,
                                                       virDomainDefPtr def);

1089 1090 1091 1092 1093
int
qemuDomainUpdateCPU(virDomainObjPtr vm,
                    virCPUDefPtr cpu,
                    virCPUDefPtr *origCPU);

1094 1095 1096 1097
int
qemuDomainFixupCPUs(virDomainObjPtr vm,
                    virCPUDefPtr *origCPU);

1098 1099 1100 1101
int
qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
                         virFileCachePtr qemuCapsCache);

1102 1103 1104
char *
qemuDomainGetMachineName(virDomainObjPtr vm);

1105 1106 1107 1108 1109 1110 1111 1112
void
qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf,
                                         virTristateBool allowReboot);

int
qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt,
                                        virTristateBool *allowReboot);

1113 1114 1115 1116 1117
bool
qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
                                     const virDomainDeviceInfo *info,
                                     virQEMUCapsPtr qemuCaps,
                                     const char *devicename);
1118

1119
int
1120 1121 1122 1123
qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
                                virStorageSourcePtr src,
                                virQEMUDriverConfigPtr cfg,
                                virQEMUCapsPtr qemuCaps)
1124
    ATTRIBUTE_RETURN_CHECK;
1125

1126 1127 1128 1129 1130 1131

int
qemuDomainValidateStorageSource(virStorageSourcePtr src,
                                virQEMUCapsPtr qemuCaps);


1132
int
1133
qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
1134 1135 1136
                            qemuDomainObjPrivatePtr priv,
                            virQEMUDriverConfigPtr cfg);

1137 1138 1139 1140 1141 1142
int
qemuDomainDiskCachemodeFlags(int cachemode,
                             bool *writeback,
                             bool *direct,
                             bool *noflush);

1143
char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);
1144

1145 1146 1147
unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivatePtr priv);
void qemuDomainStorageIdReset(qemuDomainObjPrivatePtr priv);

1148 1149 1150
virDomainEventResumedDetailType
qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);

J
John Ferlan 已提交
1151 1152 1153
bool
qemuDomainIsUsingNoShutdown(qemuDomainObjPrivatePtr priv);

1154 1155 1156
bool
qemuDomainDiskIsMissingLocalOptional(virDomainDiskDefPtr disk);

1157 1158 1159 1160
int
qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg,
                            virDomainDefPtr def);

1161 1162
virDomainEventSuspendedDetailType
qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason);