qemu_monitor.h 54.6 KB
Newer Older
1 2 3
/*
 * qemu_monitor.h: interaction with QEMU monitor console
 *
4
 * Copyright (C) 2006-2015 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
#pragma once
23

24
#include "internal.h"
25

26 27 28 29 30 31 32 33 34
#include "domain_conf.h"
#include "virbitmap.h"
#include "virhash.h"
#include "virjson.h"
#include "virnetdev.h"
#include "device_conf.h"
#include "cpu/cpu.h"
#include "util/virgic.h"
#include "virenum.h"
35

36 37
typedef struct _qemuMonitor qemuMonitor;
typedef qemuMonitor *qemuMonitorPtr;
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
typedef struct _qemuMonitorMessage qemuMonitorMessage;
typedef qemuMonitorMessage *qemuMonitorMessagePtr;

typedef int (*qemuMonitorPasswordHandler)(qemuMonitorPtr mon,
                                          qemuMonitorMessagePtr msg,
                                          const char *data,
                                          size_t len,
                                          void *opaque);

struct _qemuMonitorMessage {
    int txFD;

    char *txBuffer;
    int txOffset;
    int txLength;

55
    /* Used by the text monitor reply / error */
56 57
    char *rxBuffer;
    int rxLength;
58 59
    /* Used by the JSON monitor to hold reply / error */
    void *rxObject;
60

61 62 63 64
    /* True if rxBuffer / rxObject are ready, or a
     * fatal error occurred on the monitor channel
     */
    bool finished;
65 66 67 68 69

    qemuMonitorPasswordHandler passwordHandler;
    void *passwordOpaque;
};

70 71 72
typedef enum {
    QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE = 0,
    QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV,
73
    QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390,
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

    QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_LAST
} qemuMonitorEventPanicInfoType;

typedef struct _qemuMonitorEventPanicInfoHyperv qemuMonitorEventPanicInfoHyperv;
typedef qemuMonitorEventPanicInfoHyperv *qemuMonitorEventPanicInfoHypervPtr;
struct _qemuMonitorEventPanicInfoHyperv {
    /* Hyper-V specific guest panic information (HV crash MSRs) */
    unsigned long long arg1;
    unsigned long long arg2;
    unsigned long long arg3;
    unsigned long long arg4;
    unsigned long long arg5;
};

89 90 91 92 93 94 95 96 97 98
typedef struct _qemuMonitorEventPanicInfoS390 qemuMonitorEventPanicInfoS390;
typedef qemuMonitorEventPanicInfoS390 *qemuMonitorEventPanicInfoS390Ptr;
struct _qemuMonitorEventPanicInfoS390 {
    /* S390 specific guest panic information */
    int core;
    unsigned long long psw_mask;
    unsigned long long psw_addr;
    char *reason;
};

99 100 101 102 103 104
typedef struct _qemuMonitorEventPanicInfo qemuMonitorEventPanicInfo;
typedef qemuMonitorEventPanicInfo *qemuMonitorEventPanicInfoPtr;
struct _qemuMonitorEventPanicInfo {
    qemuMonitorEventPanicInfoType type;
    union {
        qemuMonitorEventPanicInfoHyperv hyperv;
105
        qemuMonitorEventPanicInfoS390 s390;
106 107 108
    } data;
};

109 110 111 112 113 114 115 116 117 118 119

typedef struct _qemuMonitorRdmaGidStatus qemuMonitorRdmaGidStatus;
typedef qemuMonitorRdmaGidStatus *qemuMonitorRdmaGidStatusPtr;
struct _qemuMonitorRdmaGidStatus {
    char *netdev;
    bool gid_status;
    unsigned long long subnet_prefix;
    unsigned long long interface_id;
};


120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
typedef enum {
    QEMU_MONITOR_JOB_TYPE_UNKNOWN, /* internal value, not exposed by qemu */
    QEMU_MONITOR_JOB_TYPE_COMMIT,
    QEMU_MONITOR_JOB_TYPE_STREAM,
    QEMU_MONITOR_JOB_TYPE_MIRROR,
    QEMU_MONITOR_JOB_TYPE_BACKUP,
    QEMU_MONITOR_JOB_TYPE_CREATE,
    QEMU_MONITOR_JOB_TYPE_LAST
} qemuMonitorJobType;

VIR_ENUM_DECL(qemuMonitorJob);

typedef enum {
    QEMU_MONITOR_JOB_STATUS_UNKNOWN, /* internal value, not exposed by qemu */
    QEMU_MONITOR_JOB_STATUS_CREATED,
    QEMU_MONITOR_JOB_STATUS_RUNNING,
    QEMU_MONITOR_JOB_STATUS_PAUSED,
    QEMU_MONITOR_JOB_STATUS_READY,
    QEMU_MONITOR_JOB_STATUS_STANDBY,
    QEMU_MONITOR_JOB_STATUS_WAITING,
    QEMU_MONITOR_JOB_STATUS_PENDING,
    QEMU_MONITOR_JOB_STATUS_ABORTING,
    QEMU_MONITOR_JOB_STATUS_CONCLUDED,
    QEMU_MONITOR_JOB_STATUS_UNDEFINED, /* the job states below should not be visible outside of qemu */
    QEMU_MONITOR_JOB_STATUS_NULL,
    QEMU_MONITOR_JOB_STATUS_LAST
} qemuMonitorJobStatus;

VIR_ENUM_DECL(qemuMonitorJobStatus);

typedef struct _qemuMonitorJobInfo qemuMonitorJobInfo;
typedef qemuMonitorJobInfo *qemuMonitorJobInfoPtr;
struct _qemuMonitorJobInfo {
    char *id;
    qemuMonitorJobType type;
    qemuMonitorJobStatus status;
    char *error;
    long long progressCurrent;
    long long progressTotal;
};


162
char *qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr info);
163
void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info);
164
void qemuMonitorEventRdmaGidStatusFree(qemuMonitorRdmaGidStatusPtr info);
J
Jiri Denemark 已提交
165 166

typedef void (*qemuMonitorDestroyCallback)(qemuMonitorPtr mon,
167 168
                                           virDomainObjPtr vm,
                                           void *opaque);
J
Jiri Denemark 已提交
169
typedef void (*qemuMonitorEofNotifyCallback)(qemuMonitorPtr mon,
170 171
                                             virDomainObjPtr vm,
                                             void *opaque);
J
Jiri Denemark 已提交
172
typedef void (*qemuMonitorErrorNotifyCallback)(qemuMonitorPtr mon,
173 174
                                               virDomainObjPtr vm,
                                               void *opaque);
175 176 177 178 179 180 181
typedef int (*qemuMonitorDomainEventCallback)(qemuMonitorPtr mon,
                                              virDomainObjPtr vm,
                                              const char *event,
                                              long long seconds,
                                              unsigned int micros,
                                              const char *details,
                                              void *opaque);
J
Jiri Denemark 已提交
182
typedef int (*qemuMonitorDomainShutdownCallback)(qemuMonitorPtr mon,
183
                                                 virDomainObjPtr vm,
184
                                                 virTristateBool guest,
185
                                                 void *opaque);
J
Jiri Denemark 已提交
186
typedef int (*qemuMonitorDomainResetCallback)(qemuMonitorPtr mon,
187 188
                                              virDomainObjPtr vm,
                                              void *opaque);
J
Jiri Denemark 已提交
189
typedef int (*qemuMonitorDomainPowerdownCallback)(qemuMonitorPtr mon,
190 191
                                                  virDomainObjPtr vm,
                                                  void *opaque);
J
Jiri Denemark 已提交
192
typedef int (*qemuMonitorDomainStopCallback)(qemuMonitorPtr mon,
193 194
                                             virDomainObjPtr vm,
                                             void *opaque);
J
Jiri Denemark 已提交
195
typedef int (*qemuMonitorDomainResumeCallback)(qemuMonitorPtr mon,
196 197
                                               virDomainObjPtr vm,
                                               void *opaque);
J
Jiri Denemark 已提交
198 199
typedef int (*qemuMonitorDomainRTCChangeCallback)(qemuMonitorPtr mon,
                                                  virDomainObjPtr vm,
200 201
                                                  long long offset,
                                                  void *opaque);
J
Jiri Denemark 已提交
202 203
typedef int (*qemuMonitorDomainWatchdogCallback)(qemuMonitorPtr mon,
                                                 virDomainObjPtr vm,
204 205
                                                 int action,
                                                 void *opaque);
J
Jiri Denemark 已提交
206 207 208
typedef int (*qemuMonitorDomainIOErrorCallback)(qemuMonitorPtr mon,
                                                virDomainObjPtr vm,
                                                const char *diskAlias,
209
                                                const char *nodename,
J
Jiri Denemark 已提交
210
                                                int action,
211 212
                                                const char *reason,
                                                void *opaque);
J
Jiri Denemark 已提交
213 214 215 216 217 218 219 220 221 222 223
typedef int (*qemuMonitorDomainGraphicsCallback)(qemuMonitorPtr mon,
                                                 virDomainObjPtr vm,
                                                 int phase,
                                                 int localFamily,
                                                 const char *localNode,
                                                 const char *localService,
                                                 int remoteFamily,
                                                 const char *remoteNode,
                                                 const char *remoteService,
                                                 const char *authScheme,
                                                 const char *x509dname,
224 225
                                                 const char *saslUsername,
                                                 void *opaque);
J
Jiri Denemark 已提交
226 227 228 229
typedef int (*qemuMonitorDomainBlockJobCallback)(qemuMonitorPtr mon,
                                                 virDomainObjPtr vm,
                                                 const char *diskAlias,
                                                 int type,
230
                                                 int status,
231
                                                 const char *error,
232
                                                 void *opaque);
233 234 235 236 237
typedef int (*qemuMonitorDomainJobStatusChangeCallback)(qemuMonitorPtr mon,
                                                        virDomainObjPtr vm,
                                                        const char *jobname,
                                                        int status,
                                                        void *opaque);
J
Jiri Denemark 已提交
238 239 240
typedef int (*qemuMonitorDomainTrayChangeCallback)(qemuMonitorPtr mon,
                                                   virDomainObjPtr vm,
                                                   const char *devAlias,
241
                                                   const char *devid,
242 243
                                                   int reason,
                                                   void *opaque);
J
Jiri Denemark 已提交
244
typedef int (*qemuMonitorDomainPMWakeupCallback)(qemuMonitorPtr mon,
245 246
                                                 virDomainObjPtr vm,
                                                 void *opaque);
J
Jiri Denemark 已提交
247
typedef int (*qemuMonitorDomainPMSuspendCallback)(qemuMonitorPtr mon,
248 249
                                                  virDomainObjPtr vm,
                                                  void *opaque);
J
Jiri Denemark 已提交
250 251
typedef int (*qemuMonitorDomainBalloonChangeCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
252 253
                                                      unsigned long long actual,
                                                      void *opaque);
J
Jiri Denemark 已提交
254
typedef int (*qemuMonitorDomainPMSuspendDiskCallback)(qemuMonitorPtr mon,
255 256
                                                      virDomainObjPtr vm,
                                                      void *opaque);
J
Jiri Denemark 已提交
257
typedef int (*qemuMonitorDomainGuestPanicCallback)(qemuMonitorPtr mon,
258
                                                   virDomainObjPtr vm,
259
                                                   qemuMonitorEventPanicInfoPtr info,
260
                                                   void *opaque);
J
Jiri Denemark 已提交
261 262
typedef int (*qemuMonitorDomainDeviceDeletedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
263 264
                                                      const char *devAlias,
                                                      void *opaque);
265 266 267 268
typedef int (*qemuMonitorDomainNicRxFilterChangedCallback)(qemuMonitorPtr mon,
                                                           virDomainObjPtr vm,
                                                           const char *devAlias,
                                                           void *opaque);
J
Jiri Denemark 已提交
269

270 271 272 273 274 275
typedef int (*qemuMonitorDomainSerialChangeCallback)(qemuMonitorPtr mon,
                                                     virDomainObjPtr vm,
                                                     const char *devAlias,
                                                     bool connected,
                                                     void *opaque);

276 277 278 279
typedef int (*qemuMonitorDomainSpiceMigratedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      void *opaque);

280 281 282 283 284
typedef int (*qemuMonitorDomainMigrationStatusCallback)(qemuMonitorPtr mon,
                                                        virDomainObjPtr vm,
                                                        int status,
                                                        void *opaque);

285 286 287 288 289
typedef int (*qemuMonitorDomainMigrationPassCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      int pass,
                                                      void *opaque);

290 291 292 293 294 295 296 297 298 299
typedef int (*qemuMonitorDomainAcpiOstInfoCallback)(qemuMonitorPtr mon,
                                                    virDomainObjPtr vm,
                                                    const char *alias,
                                                    const char *slotType,
                                                    const char *slot,
                                                    unsigned int source,
                                                    unsigned int status,
                                                    void *opaque);


300 301 302 303 304 305 306 307
typedef int (*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon,
                                                       virDomainObjPtr vm,
                                                       const char *nodename,
                                                       unsigned long long threshold,
                                                       unsigned long long excess,
                                                       void *opaque);


308 309 310 311 312 313 314 315 316
typedef enum {
    QEMU_MONITOR_DUMP_STATUS_NONE,
    QEMU_MONITOR_DUMP_STATUS_ACTIVE,
    QEMU_MONITOR_DUMP_STATUS_COMPLETED,
    QEMU_MONITOR_DUMP_STATUS_FAILED,

    QEMU_MONITOR_DUMP_STATUS_LAST,
} qemuMonitorDumpStatus;

317
VIR_ENUM_DECL(qemuMonitorDumpStatus);
318 319 320 321 322 323 324 325 326

typedef struct _qemuMonitorDumpStats qemuMonitorDumpStats;
typedef qemuMonitorDumpStats *qemuMonitorDumpStatsPtr;
struct _qemuMonitorDumpStats {
    int status; /* qemuMonitorDumpStatus */
    unsigned long long completed; /* bytes written */
    unsigned long long total; /* total bytes to be written */
};

327 328 329 330 331 332 333
typedef int (*qemuMonitorDomainDumpCompletedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      int status,
                                                      qemuMonitorDumpStatsPtr stats,
                                                      const char *error,
                                                      void *opaque);

334 335 336 337 338 339
typedef int (*qemuMonitorDomainPRManagerStatusChangedCallback)(qemuMonitorPtr mon,
                                                               virDomainObjPtr vm,
                                                               const char *prManager,
                                                               bool connected,
                                                               void *opaque);

340 341 342 343
typedef int (*qemuMonitorDomainRdmaGidStatusChangedCallback)(qemuMonitorPtr mon,
                                                             virDomainObjPtr vm,
                                                             const char *netdev,
                                                             bool gid_status,
344 345
                                                             unsigned long long subnet_prefix,
                                                             unsigned long long interface_id,
346 347
                                                             void *opaque);

348 349 350
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
struct _qemuMonitorCallbacks {
J
Jiri Denemark 已提交
351 352 353
    qemuMonitorDestroyCallback destroy;
    qemuMonitorEofNotifyCallback eofNotify;
    qemuMonitorErrorNotifyCallback errorNotify;
354
    qemuMonitorDomainEventCallback domainEvent;
J
Jiri Denemark 已提交
355 356 357 358 359 360 361 362 363 364
    qemuMonitorDomainShutdownCallback domainShutdown;
    qemuMonitorDomainResetCallback domainReset;
    qemuMonitorDomainPowerdownCallback domainPowerdown;
    qemuMonitorDomainStopCallback domainStop;
    qemuMonitorDomainResumeCallback domainResume;
    qemuMonitorDomainRTCChangeCallback domainRTCChange;
    qemuMonitorDomainWatchdogCallback domainWatchdog;
    qemuMonitorDomainIOErrorCallback domainIOError;
    qemuMonitorDomainGraphicsCallback domainGraphics;
    qemuMonitorDomainBlockJobCallback domainBlockJob;
365
    qemuMonitorDomainJobStatusChangeCallback jobStatusChange;
J
Jiri Denemark 已提交
366 367 368 369 370 371 372
    qemuMonitorDomainTrayChangeCallback domainTrayChange;
    qemuMonitorDomainPMWakeupCallback domainPMWakeup;
    qemuMonitorDomainPMSuspendCallback domainPMSuspend;
    qemuMonitorDomainBalloonChangeCallback domainBalloonChange;
    qemuMonitorDomainPMSuspendDiskCallback domainPMSuspendDisk;
    qemuMonitorDomainGuestPanicCallback domainGuestPanic;
    qemuMonitorDomainDeviceDeletedCallback domainDeviceDeleted;
373
    qemuMonitorDomainNicRxFilterChangedCallback domainNicRxFilterChanged;
374
    qemuMonitorDomainSerialChangeCallback domainSerialChange;
375
    qemuMonitorDomainSpiceMigratedCallback domainSpiceMigrated;
376
    qemuMonitorDomainMigrationStatusCallback domainMigrationStatus;
377
    qemuMonitorDomainMigrationPassCallback domainMigrationPass;
378
    qemuMonitorDomainAcpiOstInfoCallback domainAcpiOstInfo;
379
    qemuMonitorDomainBlockThresholdCallback domainBlockThreshold;
380
    qemuMonitorDomainDumpCompletedCallback domainDumpCompleted;
381
    qemuMonitorDomainPRManagerStatusChangedCallback domainPRManagerStatusChanged;
382
    qemuMonitorDomainRdmaGidStatusChangedCallback domainRdmaGidStatusChanged;
383 384
};

385
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
386
                               virDomainChrSourceDefPtr config,
387
                               bool retry,
388
                               unsigned long long timeout,
389 390
                               qemuMonitorCallbacksPtr cb,
                               void *opaque)
J
John Ferlan 已提交
391
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
392 393
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
                                 int sockfd,
394 395
                                 qemuMonitorCallbacksPtr cb,
                                 void *opaque)
396
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
397

398 399
bool qemuMonitorRegister(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
400 401
void qemuMonitorUnregister(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
402
void qemuMonitorClose(qemuMonitorPtr mon);
403

404 405
virErrorPtr qemuMonitorLastError(qemuMonitorPtr mon);

406
int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
407

408 409
int qemuMonitorSetLink(qemuMonitorPtr mon,
                       const char *name,
410 411
                       virDomainNetInterfaceLinkState state)
    ATTRIBUTE_NONNULL(2);
412

413
/* These APIs are for use by the internal Text/JSON monitor impl code only */
414
char *qemuMonitorNextCommandID(qemuMonitorPtr mon);
415 416
int qemuMonitorSend(qemuMonitorPtr mon,
                    qemuMonitorMessagePtr msg);
417 418 419 420
virJSONValuePtr qemuMonitorGetOptions(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
void qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
    ATTRIBUTE_NONNULL(1);
421 422
int qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon,
                                     virDomainVideoDefPtr video,
C
Cao jin 已提交
423
                                     const char *videoName)
424
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
425 426 427
int qemuMonitorUpdateVideoVram64Size(qemuMonitorPtr mon,
                                     virDomainVideoDefPtr video,
                                     const char *videoName)
428
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
429

430 431 432
int qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
                         long long seconds, unsigned int micros,
                         const char *details);
433
int qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest);
434 435 436
int qemuMonitorEmitReset(qemuMonitorPtr mon);
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
int qemuMonitorEmitStop(qemuMonitorPtr mon);
437
int qemuMonitorEmitResume(qemuMonitorPtr mon);
438
int qemuMonitorEmitRTCChange(qemuMonitorPtr mon, long long offset);
439
int qemuMonitorEmitWatchdog(qemuMonitorPtr mon, int action);
440 441
int qemuMonitorEmitIOError(qemuMonitorPtr mon,
                           const char *diskAlias,
442
                           const char *nodename,
443 444
                           int action,
                           const char *reason);
445 446 447 448 449 450 451 452 453 454 455
int qemuMonitorEmitGraphics(qemuMonitorPtr mon,
                            int phase,
                            int localFamily,
                            const char *localNode,
                            const char *localService,
                            int remoteFamily,
                            const char *remoteNode,
                            const char *remoteService,
                            const char *authScheme,
                            const char *x509dname,
                            const char *saslUsername);
456 457
int qemuMonitorEmitTrayChange(qemuMonitorPtr mon,
                              const char *devAlias,
458
                              const char *devid,
459
                              int reason);
O
Osier Yang 已提交
460
int qemuMonitorEmitPMWakeup(qemuMonitorPtr mon);
O
Osier Yang 已提交
461
int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon);
462 463 464
int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
                            const char *diskAlias,
                            int type,
465 466
                            int status,
                            const char *error);
467 468 469
int qemuMonitorEmitJobStatusChange(qemuMonitorPtr mon,
                                   const char *jobname,
                                   qemuMonitorJobStatus status);
470 471
int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
                                 unsigned long long actual);
472
int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
473 474
int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon,
                              qemuMonitorEventPanicInfoPtr info);
475 476
int qemuMonitorEmitDeviceDeleted(qemuMonitorPtr mon,
                                 const char *devAlias);
477 478
int qemuMonitorEmitNicRxFilterChanged(qemuMonitorPtr mon,
                                      const char *devAlias);
479 480 481
int qemuMonitorEmitSerialChange(qemuMonitorPtr mon,
                                const char *devAlias,
                                bool connected);
482
int qemuMonitorEmitSpiceMigrated(qemuMonitorPtr mon);
483 484
int qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
                                   int status);
485 486
int qemuMonitorEmitMigrationPass(qemuMonitorPtr mon,
                                 int pass);
487

488 489 490 491 492 493 494
int qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon,
                               const char *alias,
                               const char *slotType,
                               const char *slot,
                               unsigned int source,
                               unsigned int status);

495 496 497 498 499
int qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
                                  const char *nodename,
                                  unsigned long long threshold,
                                  unsigned long long excess);

500 501 502 503 504
int qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
                                 int status,
                                 qemuMonitorDumpStatsPtr stats,
                                 const char *error);

505 506 507 508
int qemuMonitorEmitPRManagerStatusChanged(qemuMonitorPtr mon,
                                          const char *prManager,
                                          bool connected);

509 510 511 512 513
int qemuMonitorEmitRdmaGidStatusChanged(qemuMonitorPtr mon,
                                        const char *netdev,
                                        bool gid_status,
                                        unsigned long long subnet_prefix,
                                        unsigned long long interface_id);
514

515
int qemuMonitorStartCPUs(qemuMonitorPtr mon);
516
int qemuMonitorStopCPUs(qemuMonitorPtr mon);
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531

typedef enum {
    QEMU_MONITOR_VM_STATUS_DEBUG,
    QEMU_MONITOR_VM_STATUS_INMIGRATE,
    QEMU_MONITOR_VM_STATUS_INTERNAL_ERROR,
    QEMU_MONITOR_VM_STATUS_IO_ERROR,
    QEMU_MONITOR_VM_STATUS_PAUSED,
    QEMU_MONITOR_VM_STATUS_POSTMIGRATE,
    QEMU_MONITOR_VM_STATUS_PRELAUNCH,
    QEMU_MONITOR_VM_STATUS_FINISH_MIGRATE,
    QEMU_MONITOR_VM_STATUS_RESTORE_VM,
    QEMU_MONITOR_VM_STATUS_RUNNING,
    QEMU_MONITOR_VM_STATUS_SAVE_VM,
    QEMU_MONITOR_VM_STATUS_SHUTDOWN,
    QEMU_MONITOR_VM_STATUS_WATCHDOG,
532
    QEMU_MONITOR_VM_STATUS_GUEST_PANICKED,
533 534 535

    QEMU_MONITOR_VM_STATUS_LAST
} qemuMonitorVMStatus;
536
VIR_ENUM_DECL(qemuMonitorVMStatus);
537 538
int qemuMonitorVMStatusToPausedReason(const char *status);

539
int qemuMonitorCheck(qemuMonitorPtr mon);
540 541
int qemuMonitorGetStatus(qemuMonitorPtr mon,
                         bool *running,
542 543
                         virDomainPausedReason *reason)
    ATTRIBUTE_NONNULL(2);
544

545
int qemuMonitorSystemReset(qemuMonitorPtr mon);
546 547
int qemuMonitorSystemPowerdown(qemuMonitorPtr mon);

548
struct qemuMonitorQueryCpusEntry {
549
    int qemu_id; /* id of the cpu as reported by qemu */
550
    pid_t tid;
551
    char *qom_path;
552
    bool halted;
553 554 555 556
};
void qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
                              size_t nentries);

557

558 559 560 561 562 563
struct qemuMonitorQueryHotpluggableCpusEntry {
    char *type; /* name of the cpu to use with device_add */
    unsigned int vcpus; /* count of virtual cpus in the guest this entry adds */
    char *qom_path; /* full device qom path only present for online cpus */
    char *alias; /* device alias, may be NULL for non-hotpluggable entities */

564 565 566
    /* verbatim copy of the JSON data representing the CPU which must be used for hotplug */
    virJSONValuePtr props;

567 568 569 570 571
    /* topology information -1 if qemu didn't report given parameter */
    int node_id;
    int socket_id;
    int core_id;
    int thread_id;
572 573 574

    /* internal data */
    int enable_id;
575 576 577 578 579
};
void qemuMonitorQueryHotpluggableCpusFree(struct qemuMonitorQueryHotpluggableCpusEntry *entries,
                                          size_t nentries);


580 581
struct _qemuMonitorCPUInfo {
    pid_t tid;
582
    int id; /* order of enabling of the given cpu */
583
    int qemu_id; /* identifier of the cpu as reported by query-cpus */
584

585 586 587 588
    /* state data */
    bool online;
    bool hotpluggable;

589 590 591 592 593
    /* topology info for hotplug purposes. Hotplug of given vcpu impossible if
     * all entries are -1 */
    int socket_id;
    int core_id;
    int thread_id;
594
    int node_id;
595 596 597 598 599
    unsigned int vcpus; /* number of vcpus added if given entry is hotplugged */

    /* name of the qemu type to add in case of hotplug */
    char *type;

600 601 602
    /* verbatim copy of the returned data from qemu which should be used when plugging */
    virJSONValuePtr props;

603 604 605 606 607
    /* alias of an hotpluggable entry. Entries with alias can be hot-unplugged */
    char *alias;

    /* internal for use in the matching code */
    char *qom_path;
608 609

    bool halted;
610 611 612 613 614 615
};
typedef struct _qemuMonitorCPUInfo qemuMonitorCPUInfo;
typedef qemuMonitorCPUInfo *qemuMonitorCPUInfoPtr;

void qemuMonitorCPUInfoFree(qemuMonitorCPUInfoPtr list,
                            size_t nitems);
616
int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
617
                          qemuMonitorCPUInfoPtr *vcpus,
618
                          size_t maxvcpus,
619 620 621 622 623
                          bool hotplug,
                          bool fast);
virBitmapPtr qemuMonitorGetCpuHalted(qemuMonitorPtr mon,
                                     size_t maxvcpus,
                                     bool fast);
624

625
int qemuMonitorGetVirtType(qemuMonitorPtr mon,
626
                           virDomainVirtType *virtType);
627
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
628
                              unsigned long long *currmem);
629
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
630
                              virDomainMemballoonDefPtr balloon,
631 632
                              virDomainMemoryStatPtr stats,
                              unsigned int nr_stats);
633
int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
634
                                    virDomainMemballoonDefPtr balloon,
635
                                    int period);
636

637
int qemuMonitorBlockIOStatusToError(const char *status);
638 639
virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon);

640
virJSONValuePtr qemuMonitorQueryBlockstats(qemuMonitorPtr mon);
641

642 643 644 645 646 647 648 649 650 651 652
typedef struct _qemuBlockStats qemuBlockStats;
typedef qemuBlockStats *qemuBlockStatsPtr;
struct _qemuBlockStats {
    long long rd_req;
    long long rd_bytes;
    long long wr_req;
    long long wr_bytes;
    long long rd_total_times;
    long long wr_total_times;
    long long flush_req;
    long long flush_total_times;
653 654
    unsigned long long capacity;
    unsigned long long physical;
655 656 657

    /* value of wr_highest_offset is valid if it's non 0 or
     * if wr_highest_offset_valid is true */
658
    unsigned long long wr_highest_offset;
659
    bool wr_highest_offset_valid;
660 661 662

    /* write_threshold is valid only if it's non-zero, conforming to qemu semantics */
    unsigned long long write_threshold;
663 664 665
};

int qemuMonitorGetAllBlockStatsInfo(qemuMonitorPtr mon,
666 667
                                    virHashTablePtr *ret_stats,
                                    bool backingChain)
668
    ATTRIBUTE_NONNULL(2);
669

670
int qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
671 672
                                        virHashTablePtr stats,
                                        bool backingChain)
673
    ATTRIBUTE_NONNULL(2);
674

675 676 677 678
int qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
                                                virHashTablePtr stats)
    ATTRIBUTE_NONNULL(2);

679
int qemuMonitorBlockResize(qemuMonitorPtr mon,
680 681
                           const char *device,
                           const char *nodename,
682
                           unsigned long long size);
683 684 685 686 687 688 689
int qemuMonitorSetPassword(qemuMonitorPtr mon,
                           int type,
                           const char *password,
                           const char *action_if_connected);
int qemuMonitorExpirePassword(qemuMonitorPtr mon,
                              int type,
                              const char *expire_time);
690
int qemuMonitorSetBalloon(qemuMonitorPtr mon,
691
                          unsigned long long newmem);
692
int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, bool online);
693

E
Eric Blake 已提交
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
int qemuMonitorAddBitmap(qemuMonitorPtr mon,
                         const char *node,
                         const char *bitmap,
                         bool persistent)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorEnableBitmap(qemuMonitorPtr mon,
                            const char *node,
                            const char *bitmap)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorMergeBitmaps(qemuMonitorPtr mon,
                            const char *node,
                            const char *dst,
                            virJSONValuePtr *src)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
int qemuMonitorDeleteBitmap(qemuMonitorPtr mon,
                            const char *node,
                            const char *bitmap)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

713 714

/* XXX should we pass the virDomainDiskDefPtr instead
715
 * and hide dev_name details inside monitor. Reconsider
716 717 718
 * this when doing the QMP implementation
 */
int qemuMonitorEjectMedia(qemuMonitorPtr mon,
719
                          const char *dev_name,
720
                          bool force);
721
int qemuMonitorChangeMedia(qemuMonitorPtr mon,
722
                           const char *dev_name,
723 724
                           const char *newmedia,
                           const char *format);
725 726 727 728 729 730 731 732 733 734 735 736 737 738


int qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon,
                                 unsigned long long offset,
                                 size_t length,
                                 const char *path);
int qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon,
                                  unsigned long long offset,
                                  size_t length,
                                  const char *path);

int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon,
                                 unsigned long bandwidth);

739 740 741
int qemuMonitorSetMigrationDowntime(qemuMonitorPtr mon,
                                    unsigned long long downtime);

742 743 744 745 746
int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long *cacheSize);
int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long cacheSize);

747
int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
748
                                  virJSONValuePtr *params);
749
int qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
750
                                  virJSONValuePtr params);
751

752
typedef enum {
753
    QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
754
    QEMU_MONITOR_MIGRATION_STATUS_SETUP,
755
    QEMU_MONITOR_MIGRATION_STATUS_ACTIVE,
756 757
    QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER,
    QEMU_MONITOR_MIGRATION_STATUS_DEVICE,
758
    QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY,
759 760
    QEMU_MONITOR_MIGRATION_STATUS_COMPLETED,
    QEMU_MONITOR_MIGRATION_STATUS_ERROR,
761
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLING,
762 763 764
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLED,

    QEMU_MONITOR_MIGRATION_STATUS_LAST
765
} qemuMonitorMigrationStatus;
766

767
VIR_ENUM_DECL(qemuMonitorMigrationStatus);
768

769 770 771
typedef struct _qemuMonitorMigrationStats qemuMonitorMigrationStats;
typedef qemuMonitorMigrationStats *qemuMonitorMigrationStatsPtr;
struct _qemuMonitorMigrationStats {
772
    int status; /* qemuMonitorMigrationStatus */
773 774 775 776
    unsigned long long total_time;
    /* total or expected depending on status */
    bool downtime_set;
    unsigned long long downtime;
777 778 779 780 781 782 783
    /*
     * Duration of the QEMU 'setup' state.
     * for RDMA, this may be on the order of several seconds
     * if pinning support is requested before the migration begins.
     */
    bool setup_time_set;
    unsigned long long setup_time;
784 785 786 787

    unsigned long long ram_transferred;
    unsigned long long ram_remaining;
    unsigned long long ram_total;
788
    unsigned long long ram_bps;
789 790 791 792
    bool ram_duplicate_set;
    unsigned long long ram_duplicate;
    unsigned long long ram_normal;
    unsigned long long ram_normal_bytes;
793
    unsigned long long ram_dirty_rate;
794
    unsigned long long ram_page_size;
795
    unsigned long long ram_iteration;
796
    unsigned long long ram_postcopy_reqs;
797 798 799 800

    unsigned long long disk_transferred;
    unsigned long long disk_remaining;
    unsigned long long disk_total;
801
    unsigned long long disk_bps;
802 803 804 805 806 807 808

    bool xbzrle_set;
    unsigned long long xbzrle_cache_size;
    unsigned long long xbzrle_bytes;
    unsigned long long xbzrle_pages;
    unsigned long long xbzrle_cache_miss;
    unsigned long long xbzrle_overflow;
809 810

    int cpu_throttle_percentage;
811 812
};

813
int qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
814 815
                                 qemuMonitorMigrationStatsPtr stats,
                                 char **error);
816

817 818
int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
                                        char ***capabilities);
819
int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
820
                                        virJSONValuePtr caps);
821

A
Andrea Bolognani 已提交
822 823 824
int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon,
                                  virGICCapability **capabilities);

825 826 827
int qemuMonitorGetSEVCapabilities(qemuMonitorPtr mon,
                                  virSEVCapability **capabilities);

828
typedef enum {
829
  QEMU_MONITOR_MIGRATE_BACKGROUND       = 1 << 0,
830 831 832 833 834
  QEMU_MONITOR_MIGRATE_NON_SHARED_DISK  = 1 << 1, /* migration with non-shared storage with full disk copy */
  QEMU_MONITOR_MIGRATE_NON_SHARED_INC   = 1 << 2, /* migration with non-shared storage with incremental copy */
  QEMU_MONITOR_MIGRATION_FLAGS_LAST
} QEMU_MONITOR_MIGRATE;

E
Eric Blake 已提交
835 836 837 838
int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
                           unsigned int flags,
                           int fd);

839
int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
840
                             unsigned int flags,
841
                             const char *protocol,
842 843 844 845 846
                             const char *hostname,
                             int port);

int qemuMonitorMigrateCancel(qemuMonitorPtr mon);

847 848 849
int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
                                            const char *capability);

850 851 852
int qemuMonitorQueryDump(qemuMonitorPtr mon,
                         qemuMonitorDumpStatsPtr stats);

853
int qemuMonitorDumpToFd(qemuMonitorPtr mon,
854
                        int fd,
855 856
                        const char *dumpformat,
                        bool detach);
857

858 859 860 861 862 863
int qemuMonitorGraphicsRelocate(qemuMonitorPtr mon,
                                int type,
                                const char *hostname,
                                int port,
                                int tlsPort,
                                const char *tlsSubject);
864 865 866 867 868

int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
                              const char *fdname,
                              int fd);

869
/* This function preserves previous error and only set their own
870
 * error if no error was set before.
871
 */
872 873 874
int qemuMonitorCloseFileHandle(qemuMonitorPtr mon,
                               const char *fdname);

875
int qemuMonitorAddNetdev(qemuMonitorPtr mon,
876
                         const char *netdevstr,
877
                         int *tapfd, char **tapfdName, int tapfdSize,
878 879
                         int *vhostfd, char **vhostfdName, int vhostfdSize,
                         int slirpfd, char *slirpfdName);
880 881 882 883

int qemuMonitorRemoveNetdev(qemuMonitorPtr mon,
                            const char *alias);

884 885 886
int qemuMonitorQueryRxFilter(qemuMonitorPtr mon, const char *alias,
                             virNetDevRxFilterPtr *filter);

887 888 889 890 891 892
typedef struct _qemuMonitorChardevInfo qemuMonitorChardevInfo;
typedef qemuMonitorChardevInfo *qemuMonitorChardevInfoPtr;
struct _qemuMonitorChardevInfo {
    char *ptyPath;
    virDomainChrDeviceState state;
};
893
void qemuMonitorChardevInfoFree(void *data, const void *name);
894 895
int qemuMonitorGetChardevInfo(qemuMonitorPtr mon,
                              virHashTablePtr *retinfo);
896

897 898
int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
                                       const char *bus,
899
                                       virPCIDeviceAddress *guestAddr);
900

901 902
int qemuMonitorAddDeviceArgs(qemuMonitorPtr mon,
                             virJSONValuePtr args);
903 904 905
int qemuMonitorAddDevice(qemuMonitorPtr mon,
                         const char *devicestr);

906 907 908 909 910
int qemuMonitorAddDeviceWithFd(qemuMonitorPtr mon,
                               const char *devicestr,
                               int fd,
                               const char *fdname);

911
int qemuMonitorDelDevice(qemuMonitorPtr mon,
912
                         const char *devalias);
913

914 915 916 917 918 919 920 921 922 923 924
virJSONValuePtr qemuMonitorCreateObjectPropsWrap(const char *type,
                                                 const char *alias,
                                                 virJSONValuePtr *props);

int qemuMonitorCreateObjectProps(virJSONValuePtr *propsret,
                                 const char *type,
                                 const char *alias,
                                 ...);

int qemuMonitorAddObject(qemuMonitorPtr mon,
                         virJSONValuePtr *props,
925
                         char **alias)
926
    ATTRIBUTE_NONNULL(2);
927

928 929 930
int qemuMonitorDelObject(qemuMonitorPtr mon,
                         const char *objalias);

931 932 933
int qemuMonitorAddDrive(qemuMonitorPtr mon,
                        const char *drivestr);

934
int qemuMonitorDriveDel(qemuMonitorPtr mon,
935 936
                        const char *drivestr);

C
Chris Lalancette 已提交
937 938 939 940
int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);

941
int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions)
942
    ATTRIBUTE_NONNULL(2);
943 944 945 946
int qemuMonitorDriveMirror(qemuMonitorPtr mon,
                           const char *device,
                           const char *file,
                           const char *format,
947
                           unsigned long long bandwidth,
948 949
                           unsigned int granularity,
                           unsigned long long buf_size,
950 951
                           bool shallow,
                           bool reuse)
952
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
953 954
int qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
                              const char *jobname,
955
                              bool persistjob,
956 957 958 959 960
                              const char *device,
                              const char *target,
                              unsigned long long bandwidth,
                              unsigned int granularity,
                              unsigned long long buf_size,
961
                              bool shallow)
962
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
963
int qemuMonitorDrivePivot(qemuMonitorPtr mon,
964
                          const char *jobname)
965
    ATTRIBUTE_NONNULL(2);
966

967 968
int qemuMonitorBlockCommit(qemuMonitorPtr mon,
                           const char *device,
969 970
                           const char *jobname,
                           bool persistjob,
971
                           const char *top,
972
                           const char *topNode,
973
                           const char *base,
974
                           const char *baseNode,
975
                           const char *backingName,
976
                           unsigned long long bandwidth)
977
    ATTRIBUTE_NONNULL(2);
978
bool qemuMonitorSupportsActiveCommit(qemuMonitorPtr mon);
979 980 981 982
char *qemuMonitorDiskNameLookup(qemuMonitorPtr mon,
                                const char *device,
                                virStorageSourcePtr top,
                                virStorageSourcePtr target)
983
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
984

985 986 987 988
int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
                                const char *cmd,
                                char **reply,
                                bool hmp);
989

990 991
int qemuMonitorInjectNMI(qemuMonitorPtr mon);

992
int qemuMonitorScreendump(qemuMonitorPtr mon,
993 994
                          const char *device,
                          unsigned int head,
995 996
                          const char *file);

997 998 999 1000 1001
int qemuMonitorSendKey(qemuMonitorPtr mon,
                       unsigned int holdtime,
                       unsigned int *keycodes,
                       unsigned int nkeycodes);

1002 1003
int qemuMonitorBlockStream(qemuMonitorPtr mon,
                           const char *device,
1004 1005
                           const char *jobname,
                           bool persistjob,
1006
                           const char *base,
1007
                           const char *baseNode,
1008
                           const char *backingName,
1009
                           unsigned long long bandwidth)
1010
    ATTRIBUTE_NONNULL(2);
1011

1012
int qemuMonitorBlockJobCancel(qemuMonitorPtr mon,
1013
                              const char *jobname)
1014
    ATTRIBUTE_NONNULL(2);
1015

1016
int qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,
1017
                                const char *jobname,
1018
                                unsigned long long bandwidth);
1019

1020 1021 1022 1023 1024 1025 1026
typedef struct _qemuMonitorBlockJobInfo qemuMonitorBlockJobInfo;
typedef qemuMonitorBlockJobInfo *qemuMonitorBlockJobInfoPtr;
struct _qemuMonitorBlockJobInfo {
    int type; /* virDomainBlockJobType */
    unsigned long long bandwidth; /* in bytes/s */
    virDomainBlockJobCursor cur;
    virDomainBlockJobCursor end;
1027
    int ready; /* -1 if unknown, 0 if not ready, 1 if ready */
1028 1029
};

1030 1031
virHashTablePtr qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
                                              bool rawjobname);
1032 1033 1034
int qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
                               const char *device,
                               qemuMonitorBlockJobInfoPtr info)
1035
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
1036

1037 1038 1039 1040
int qemuMonitorJobDismiss(qemuMonitorPtr mon,
                          const char *jobname)
    ATTRIBUTE_NONNULL(2);

1041 1042 1043 1044 1045
int qemuMonitorJobCancel(qemuMonitorPtr mon,
                         const char *jobname,
                         bool quiet)
    ATTRIBUTE_NONNULL(2);

1046 1047 1048 1049
int qemuMonitorJobComplete(qemuMonitorPtr mon,
                           const char *jobname)
    ATTRIBUTE_NONNULL(2);

1050 1051 1052 1053 1054 1055
int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                            const char *protocol,
                            int fd,
                            const char *fdname,
                            bool skipauth);

1056
int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
1057 1058
                                  const char *drivealias,
                                  const char *qomid,
1059
                                  virDomainBlockIoTuneInfoPtr info,
1060
                                  bool supportMaxOptions,
1061
                                  bool supportGroupNameOption,
1062
                                  bool supportMaxLengthOptions);
1063 1064

int qemuMonitorGetBlockIoThrottle(qemuMonitorPtr mon,
1065 1066
                                  const char *drivealias,
                                  const char *qdevid,
1067
                                  virDomainBlockIoTuneInfoPtr reply);
1068

1069 1070
int qemuMonitorSystemWakeup(qemuMonitorPtr mon);

1071 1072 1073 1074 1075 1076 1077
int qemuMonitorGetVersion(qemuMonitorPtr mon,
                          int *major,
                          int *minor,
                          int *micro,
                          char **package)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

1078 1079 1080 1081 1082 1083 1084 1085

typedef struct _qemuMonitorMachineInfo qemuMonitorMachineInfo;
typedef qemuMonitorMachineInfo *qemuMonitorMachineInfoPtr;

struct _qemuMonitorMachineInfo {
    char *name;
    bool isDefault;
    char *alias;
1086
    unsigned int maxCpus;
1087
    bool hotplugCpus;
1088 1089 1090 1091 1092 1093 1094
};

int qemuMonitorGetMachines(qemuMonitorPtr mon,
                           qemuMonitorMachineInfoPtr **machines);

void qemuMonitorMachineInfoFree(qemuMonitorMachineInfoPtr machine);

1095 1096 1097 1098
typedef struct _qemuMonitorCPUDefInfo qemuMonitorCPUDefInfo;
typedef qemuMonitorCPUDefInfo *qemuMonitorCPUDefInfoPtr;

struct _qemuMonitorCPUDefInfo {
1099
    virTristateBool usable;
1100
    char *name;
1101
    char **blockers; /* NULL-terminated string list */
1102 1103
};

1104
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
1105 1106
                                 qemuMonitorCPUDefInfoPtr **cpus);
void qemuMonitorCPUDefInfoFree(qemuMonitorCPUDefInfoPtr cpu);
1107

1108 1109 1110 1111 1112 1113 1114 1115
typedef enum {
    QEMU_MONITOR_CPU_PROPERTY_BOOLEAN,
    QEMU_MONITOR_CPU_PROPERTY_STRING,
    QEMU_MONITOR_CPU_PROPERTY_NUMBER,

    QEMU_MONITOR_CPU_PROPERTY_LAST
} qemuMonitorCPUPropertyType;

1116
VIR_ENUM_DECL(qemuMonitorCPUProperty);
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127

typedef struct _qemuMonitorCPUProperty qemuMonitorCPUProperty;
typedef qemuMonitorCPUProperty *qemuMonitorCPUPropertyPtr;
struct _qemuMonitorCPUProperty {
    char *name;
    qemuMonitorCPUPropertyType type;
    union {
        bool boolean;
        char *string;
        long long number;
    } value;
1128
    virTristateBool migratable;
1129 1130
};

1131 1132 1133 1134 1135 1136
typedef struct _qemuMonitorCPUModelInfo qemuMonitorCPUModelInfo;
typedef qemuMonitorCPUModelInfo *qemuMonitorCPUModelInfoPtr;

struct _qemuMonitorCPUModelInfo {
    char *name;
    size_t nprops;
1137
    qemuMonitorCPUPropertyPtr props;
1138
    bool migratability;
1139 1140
};

1141 1142
typedef enum {
    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
1143 1144
    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL,
    QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
1145 1146
} qemuMonitorCPUModelExpansionType;

1147
int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
1148
                                    qemuMonitorCPUModelExpansionType type,
1149
                                    const char *model_name,
1150
                                    bool migratable,
1151 1152 1153 1154 1155 1156 1157
                                    qemuMonitorCPUModelInfoPtr *model_info);

void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info);

qemuMonitorCPUModelInfoPtr
qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);

1158 1159
int qemuMonitorGetCommands(qemuMonitorPtr mon,
                           char ***commands);
1160 1161
int qemuMonitorGetEvents(qemuMonitorPtr mon,
                         char ***events);
1162 1163
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                              const char *option,
1164 1165
                                              char ***params,
                                              bool *found);
1166

1167 1168 1169 1170
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
                           bool *enabled,
                           bool *present);

1171 1172
int qemuMonitorGetObjectTypes(qemuMonitorPtr mon,
                              char ***types);
1173 1174
int qemuMonitorGetDeviceProps(qemuMonitorPtr mon,
                              const char *device,
1175
                              char ***props);
1176 1177 1178
int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
                              const char *object,
                              char ***props);
1179
char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
1180

1181
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
1182 1183 1184
                              const virStorageNetHostDef *server,
                              const char *tls_alias)
    ATTRIBUTE_NONNULL(2);
1185 1186
int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
                            const char *deviceID,
1187 1188 1189
                            const char *export,
                            bool writable,
                            const char *bitmap);
1190
int qemuMonitorNBDServerStop(qemuMonitorPtr);
S
Stefan Berger 已提交
1191 1192 1193 1194 1195 1196
int qemuMonitorGetTPMModels(qemuMonitorPtr mon,
                            char ***tpmmodels);

int qemuMonitorGetTPMTypes(qemuMonitorPtr mon,
                           char ***tpmtypes);

1197 1198 1199
int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
                             const char *chrID,
                             virDomainChrSourceDefPtr chr);
1200 1201
int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
                             const char *chrID);
1202 1203 1204 1205

int qemuMonitorGetDeviceAliases(qemuMonitorPtr mon,
                                char ***aliases);

1206 1207 1208
typedef void (*qemuMonitorReportDomainLogError)(qemuMonitorPtr mon,
                                                const char *msg,
                                                void *opaque);
1209 1210 1211 1212
void qemuMonitorSetDomainLogLocked(qemuMonitorPtr mon,
                                   qemuMonitorReportDomainLogError func,
                                   void *opaque,
                                   virFreeCallback destroy);
1213 1214 1215 1216
void qemuMonitorSetDomainLog(qemuMonitorPtr mon,
                             qemuMonitorReportDomainLogError func,
                             void *opaque,
                             virFreeCallback destroy);
1217

1218 1219 1220
int qemuMonitorGetGuestCPUx86(qemuMonitorPtr mon,
                              virCPUDataPtr *data,
                              virCPUDataPtr *disabled);
1221

1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
typedef const char *(*qemuMonitorCPUFeatureTranslationCallback)(const char *name,
                                                                void *opaque);

int qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
                           virArch arch,
                           qemuMonitorCPUFeatureTranslationCallback translate,
                           void *opaque,
                           virCPUDataPtr *enabled,
                           virCPUDataPtr *disabled);

1232 1233
int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon);

1234 1235
typedef struct _qemuMonitorIOThreadInfo qemuMonitorIOThreadInfo;
typedef qemuMonitorIOThreadInfo *qemuMonitorIOThreadInfoPtr;
1236

1237
struct _qemuMonitorIOThreadInfo {
1238
    unsigned int iothread_id;
1239
    int thread_id;
1240 1241 1242 1243
    bool poll_valid;
    unsigned long long poll_max_ns;
    unsigned int poll_grow;
    unsigned int poll_shrink;
1244 1245 1246
    bool set_poll_max_ns;
    bool set_poll_grow;
    bool set_poll_shrink;
1247 1248
};
int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
1249
                            qemuMonitorIOThreadInfoPtr **iothreads);
1250 1251
int qemuMonitorSetIOThread(qemuMonitorPtr mon,
                           qemuMonitorIOThreadInfoPtr iothreadInfo);
1252

1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
typedef struct _qemuMonitorMemoryDeviceInfo qemuMonitorMemoryDeviceInfo;
typedef qemuMonitorMemoryDeviceInfo *qemuMonitorMemoryDeviceInfoPtr;

struct _qemuMonitorMemoryDeviceInfo {
    unsigned long long address;
    unsigned int slot;
    bool hotplugged;
    bool hotpluggable;
};

int qemuMonitorGetMemoryDeviceInfo(qemuMonitorPtr mon,
                                   virHashTablePtr *info)
    ATTRIBUTE_NONNULL(2);

1267 1268 1269
int qemuMonitorMigrateIncoming(qemuMonitorPtr mon,
                               const char *uri);

1270 1271
int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon);

1272 1273 1274
int qemuMonitorMigrateContinue(qemuMonitorPtr mon,
                               qemuMonitorMigrationStatus status);

1275 1276 1277
int qemuMonitorGetRTCTime(qemuMonitorPtr mon,
                          struct tm *tm);

1278
virJSONValuePtr qemuMonitorQueryQMPSchema(qemuMonitorPtr mon);
1279

1280 1281 1282 1283
int qemuMonitorSetBlockThreshold(qemuMonitorPtr mon,
                                 const char *nodename,
                                 unsigned long long threshold);

1284
virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon);
1285

M
Michal Privoznik 已提交
1286 1287
int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon,
                                 const char *action);
1288

1289 1290 1291 1292
int qemuMonitorBlockdevCreate(qemuMonitorPtr mon,
                              const char *jobname,
                              virJSONValuePtr props);

1293 1294 1295 1296 1297 1298
int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
                           virJSONValuePtr props);

int qemuMonitorBlockdevDel(qemuMonitorPtr mon,
                           const char *nodename);

1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312
int qemuMonitorBlockdevTrayOpen(qemuMonitorPtr mon,
                                const char *id,
                                bool force);

int qemuMonitorBlockdevTrayClose(qemuMonitorPtr mon,
                                 const char *id);

int qemuMonitorBlockdevMediumRemove(qemuMonitorPtr mon,
                                    const char *id);

int qemuMonitorBlockdevMediumInsert(qemuMonitorPtr mon,
                                    const char *id,
                                    const char *nodename);

1313 1314 1315
char *
qemuMonitorGetSEVMeasurement(qemuMonitorPtr mon);

1316 1317 1318 1319 1320 1321 1322 1323 1324
typedef struct _qemuMonitorPRManagerInfo qemuMonitorPRManagerInfo;
typedef qemuMonitorPRManagerInfo *qemuMonitorPRManagerInfoPtr;
struct _qemuMonitorPRManagerInfo {
    bool connected;
};

int qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon,
                                virHashTablePtr *retinfo);

1325 1326 1327 1328 1329 1330 1331 1332
typedef struct  _qemuMonitorCurrentMachineInfo qemuMonitorCurrentMachineInfo;
typedef qemuMonitorCurrentMachineInfo *qemuMonitorCurrentMachineInfoPtr;
struct _qemuMonitorCurrentMachineInfo {
    bool wakeupSuspendSupport;
};

int qemuMonitorGetCurrentMachineInfo(qemuMonitorPtr mon,
                                     qemuMonitorCurrentMachineInfoPtr info);
1333 1334 1335 1336 1337 1338 1339
void qemuMonitorJobInfoFree(qemuMonitorJobInfoPtr job);

VIR_DEFINE_AUTOPTR_FUNC(qemuMonitorJobInfo, qemuMonitorJobInfoFree);

int qemuMonitorGetJobInfo(qemuMonitorPtr mon,
                          qemuMonitorJobInfoPtr **jobs,
                          size_t *njobs);