qemu_monitor.h 57.9 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
typedef struct _qemuMonitorMessage qemuMonitorMessage;
typedef qemuMonitorMessage *qemuMonitorMessagePtr;

struct _qemuMonitorMessage {
    int txFD;

    char *txBuffer;
    int txOffset;
    int txLength;

49
    /* Used by the text monitor reply / error */
50 51
    char *rxBuffer;
    int rxLength;
52 53
    /* Used by the JSON monitor to hold reply / error */
    void *rxObject;
54

55 56 57 58
    /* True if rxBuffer / rxObject are ready, or a
     * fatal error occurred on the monitor channel
     */
    bool finished;
59 60
};

61 62 63
typedef enum {
    QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_NONE = 0,
    QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV,
64
    QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390,
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

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

80 81 82 83 84 85 86 87 88 89
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;
};

90 91 92 93 94 95
typedef struct _qemuMonitorEventPanicInfo qemuMonitorEventPanicInfo;
typedef qemuMonitorEventPanicInfo *qemuMonitorEventPanicInfoPtr;
struct _qemuMonitorEventPanicInfo {
    qemuMonitorEventPanicInfoType type;
    union {
        qemuMonitorEventPanicInfoHyperv hyperv;
96
        qemuMonitorEventPanicInfoS390 s390;
97 98 99
    } data;
};

100 101 102 103 104 105 106 107 108 109 110

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


111 112 113 114 115 116 117 118 119 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
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;
148 149
    unsigned long long progressCurrent;
    unsigned long long progressTotal;
150 151 152
};


153
char *qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr info);
154
void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info);
155
void qemuMonitorEventRdmaGidStatusFree(qemuMonitorRdmaGidStatusPtr info);
J
Jiri Denemark 已提交
156 157

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

261 262 263 264 265 266
typedef int (*qemuMonitorDomainSerialChangeCallback)(qemuMonitorPtr mon,
                                                     virDomainObjPtr vm,
                                                     const char *devAlias,
                                                     bool connected,
                                                     void *opaque);

267 268 269 270
typedef int (*qemuMonitorDomainSpiceMigratedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      void *opaque);

271 272 273 274 275
typedef int (*qemuMonitorDomainMigrationStatusCallback)(qemuMonitorPtr mon,
                                                        virDomainObjPtr vm,
                                                        int status,
                                                        void *opaque);

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

281 282 283 284 285 286 287 288 289 290
typedef int (*qemuMonitorDomainAcpiOstInfoCallback)(qemuMonitorPtr mon,
                                                    virDomainObjPtr vm,
                                                    const char *alias,
                                                    const char *slotType,
                                                    const char *slot,
                                                    unsigned int source,
                                                    unsigned int status,
                                                    void *opaque);


291 292 293 294 295 296 297 298
typedef int (*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon,
                                                       virDomainObjPtr vm,
                                                       const char *nodename,
                                                       unsigned long long threshold,
                                                       unsigned long long excess,
                                                       void *opaque);


299 300 301 302 303 304 305 306 307
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;

308
VIR_ENUM_DECL(qemuMonitorDumpStatus);
309 310 311 312 313 314 315 316 317

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

318 319 320 321 322 323 324
typedef int (*qemuMonitorDomainDumpCompletedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      int status,
                                                      qemuMonitorDumpStatsPtr stats,
                                                      const char *error,
                                                      void *opaque);

325 326 327 328 329 330
typedef int (*qemuMonitorDomainPRManagerStatusChangedCallback)(qemuMonitorPtr mon,
                                                               virDomainObjPtr vm,
                                                               const char *prManager,
                                                               bool connected,
                                                               void *opaque);

331 332 333 334
typedef int (*qemuMonitorDomainRdmaGidStatusChangedCallback)(qemuMonitorPtr mon,
                                                             virDomainObjPtr vm,
                                                             const char *netdev,
                                                             bool gid_status,
335 336
                                                             unsigned long long subnet_prefix,
                                                             unsigned long long interface_id,
337 338
                                                             void *opaque);

339 340 341 342
typedef int (*qemuMonitorDomainGuestCrashloadedCallback)(qemuMonitorPtr mon,
                                                         virDomainObjPtr vm,
                                                         void *opaque);

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

381
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
382
                               virDomainChrSourceDefPtr config,
383
                               bool retry,
384
                               unsigned long long timeout,
385
                               GMainContext *context,
386 387
                               qemuMonitorCallbacksPtr cb,
                               void *opaque)
J
John Ferlan 已提交
388
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
389

390
void qemuMonitorRegister(qemuMonitorPtr mon)
391
    ATTRIBUTE_NONNULL(1);
392 393
void qemuMonitorUnregister(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
394
void qemuMonitorClose(qemuMonitorPtr mon);
395

396 397
virErrorPtr qemuMonitorLastError(qemuMonitorPtr mon);

398
int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
399

400 401
int qemuMonitorSetLink(qemuMonitorPtr mon,
                       const char *name,
402 403
                       virDomainNetInterfaceLinkState state)
    ATTRIBUTE_NONNULL(2);
404

405
/* These APIs are for use by the internal Text/JSON monitor impl code only */
406
char *qemuMonitorNextCommandID(qemuMonitorPtr mon);
407 408
int qemuMonitorSend(qemuMonitorPtr mon,
                    qemuMonitorMessagePtr msg);
409 410 411 412
virJSONValuePtr qemuMonitorGetOptions(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
void qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
    ATTRIBUTE_NONNULL(1);
413 414
int qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon,
                                     virDomainVideoDefPtr video,
C
Cao jin 已提交
415
                                     const char *videoName)
416
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
417 418 419
int qemuMonitorUpdateVideoVram64Size(qemuMonitorPtr mon,
                                     virDomainVideoDefPtr video,
                                     const char *videoName)
420
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
421

422 423 424
int qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
                         long long seconds, unsigned int micros,
                         const char *details);
425
int qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest);
426 427 428
int qemuMonitorEmitReset(qemuMonitorPtr mon);
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
int qemuMonitorEmitStop(qemuMonitorPtr mon);
429
int qemuMonitorEmitResume(qemuMonitorPtr mon);
430
int qemuMonitorEmitRTCChange(qemuMonitorPtr mon, long long offset);
431
int qemuMonitorEmitWatchdog(qemuMonitorPtr mon, int action);
432 433
int qemuMonitorEmitIOError(qemuMonitorPtr mon,
                           const char *diskAlias,
434
                           const char *nodename,
435 436
                           int action,
                           const char *reason);
437 438 439 440 441 442 443 444 445 446 447
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);
448 449
int qemuMonitorEmitTrayChange(qemuMonitorPtr mon,
                              const char *devAlias,
450
                              const char *devid,
451
                              int reason);
O
Osier Yang 已提交
452
int qemuMonitorEmitPMWakeup(qemuMonitorPtr mon);
O
Osier Yang 已提交
453
int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon);
454 455 456
int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
                            const char *diskAlias,
                            int type,
457 458
                            int status,
                            const char *error);
459 460 461
int qemuMonitorEmitJobStatusChange(qemuMonitorPtr mon,
                                   const char *jobname,
                                   qemuMonitorJobStatus status);
462 463
int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
                                 unsigned long long actual);
464
int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
465 466
int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon,
                              qemuMonitorEventPanicInfoPtr info);
467 468
int qemuMonitorEmitDeviceDeleted(qemuMonitorPtr mon,
                                 const char *devAlias);
469 470
int qemuMonitorEmitNicRxFilterChanged(qemuMonitorPtr mon,
                                      const char *devAlias);
471 472 473
int qemuMonitorEmitSerialChange(qemuMonitorPtr mon,
                                const char *devAlias,
                                bool connected);
474
int qemuMonitorEmitSpiceMigrated(qemuMonitorPtr mon);
475 476
int qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
                                   int status);
477 478
int qemuMonitorEmitMigrationPass(qemuMonitorPtr mon,
                                 int pass);
479

480 481 482 483 484 485 486
int qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon,
                               const char *alias,
                               const char *slotType,
                               const char *slot,
                               unsigned int source,
                               unsigned int status);

487 488 489 490 491
int qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
                                  const char *nodename,
                                  unsigned long long threshold,
                                  unsigned long long excess);

492 493 494 495 496
int qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
                                 int status,
                                 qemuMonitorDumpStatsPtr stats,
                                 const char *error);

497 498 499 500
int qemuMonitorEmitPRManagerStatusChanged(qemuMonitorPtr mon,
                                          const char *prManager,
                                          bool connected);

501 502 503 504 505
int qemuMonitorEmitRdmaGidStatusChanged(qemuMonitorPtr mon,
                                        const char *netdev,
                                        bool gid_status,
                                        unsigned long long subnet_prefix,
                                        unsigned long long interface_id);
506

507 508
int qemuMonitorEmitGuestCrashloaded(qemuMonitorPtr mon);

509
int qemuMonitorStartCPUs(qemuMonitorPtr mon);
510
int qemuMonitorStopCPUs(qemuMonitorPtr mon);
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525

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,
526
    QEMU_MONITOR_VM_STATUS_GUEST_PANICKED,
527 528 529

    QEMU_MONITOR_VM_STATUS_LAST
} qemuMonitorVMStatus;
530
VIR_ENUM_DECL(qemuMonitorVMStatus);
531 532
int qemuMonitorVMStatusToPausedReason(const char *status);

533
int qemuMonitorCheck(qemuMonitorPtr mon);
534 535
int qemuMonitorGetStatus(qemuMonitorPtr mon,
                         bool *running,
536 537
                         virDomainPausedReason *reason)
    ATTRIBUTE_NONNULL(2);
538

539
int qemuMonitorSystemReset(qemuMonitorPtr mon);
540 541
int qemuMonitorSystemPowerdown(qemuMonitorPtr mon);

542
struct qemuMonitorQueryCpusEntry {
543
    int qemu_id; /* id of the cpu as reported by qemu */
544
    pid_t tid;
545
    char *qom_path;
546
    bool halted;
547 548 549 550
};
void qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
                              size_t nentries);

551

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

558 559 560
    /* verbatim copy of the JSON data representing the CPU which must be used for hotplug */
    virJSONValuePtr props;

561 562 563
    /* topology information -1 if qemu didn't report given parameter */
    int node_id;
    int socket_id;
564
    int die_id;
565 566
    int core_id;
    int thread_id;
567 568 569

    /* internal data */
    int enable_id;
570 571 572 573 574
};
void qemuMonitorQueryHotpluggableCpusFree(struct qemuMonitorQueryHotpluggableCpusEntry *entries,
                                          size_t nentries);


575 576
struct _qemuMonitorCPUInfo {
    pid_t tid;
577
    int id; /* order of enabling of the given cpu */
578
    int qemu_id; /* identifier of the cpu as reported by query-cpus */
579

580 581 582 583
    /* state data */
    bool online;
    bool hotpluggable;

584 585 586
    /* topology info for hotplug purposes. Hotplug of given vcpu impossible if
     * all entries are -1 */
    int socket_id;
587
    int die_id;
588 589
    int core_id;
    int thread_id;
590
    int node_id;
591 592 593 594 595
    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;

596 597 598
    /* verbatim copy of the returned data from qemu which should be used when plugging */
    virJSONValuePtr props;

599 600 601 602 603
    /* alias of an hotpluggable entry. Entries with alias can be hot-unplugged */
    char *alias;

    /* internal for use in the matching code */
    char *qom_path;
604 605

    bool halted;
606 607 608 609 610 611
};
typedef struct _qemuMonitorCPUInfo qemuMonitorCPUInfo;
typedef qemuMonitorCPUInfo *qemuMonitorCPUInfoPtr;

void qemuMonitorCPUInfoFree(qemuMonitorCPUInfoPtr list,
                            size_t nitems);
612
int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
613
                          qemuMonitorCPUInfoPtr *vcpus,
614
                          size_t maxvcpus,
615 616 617 618 619
                          bool hotplug,
                          bool fast);
virBitmapPtr qemuMonitorGetCpuHalted(qemuMonitorPtr mon,
                                     size_t maxvcpus,
                                     bool fast);
620

621
int qemuMonitorGetVirtType(qemuMonitorPtr mon,
622
                           virDomainVirtType *virtType);
623
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
624
                              unsigned long long *currmem);
625
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
626
                              virDomainMemballoonDefPtr balloon,
627 628
                              virDomainMemoryStatPtr stats,
                              unsigned int nr_stats);
629
int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
630
                                    virDomainMemballoonDefPtr balloon,
631
                                    int period);
632

633
int qemuMonitorBlockIOStatusToError(const char *status);
634 635
virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon);

636
virJSONValuePtr qemuMonitorQueryBlockstats(qemuMonitorPtr mon);
637

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

    /* value of wr_highest_offset is valid if it's non 0 or
     * if wr_highest_offset_valid is true */
654
    unsigned long long wr_highest_offset;
655
    bool wr_highest_offset_valid;
656 657 658

    /* write_threshold is valid only if it's non-zero, conforming to qemu semantics */
    unsigned long long write_threshold;
659 660 661
};

int qemuMonitorGetAllBlockStatsInfo(qemuMonitorPtr mon,
662 663
                                    virHashTablePtr *ret_stats,
                                    bool backingChain)
664
    ATTRIBUTE_NONNULL(2);
665

666
int qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
667 668
                                        virHashTablePtr stats,
                                        bool backingChain)
669
    ATTRIBUTE_NONNULL(2);
670

671 672 673 674
int qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
                                                virHashTablePtr stats)
    ATTRIBUTE_NONNULL(2);

675 676 677 678 679 680 681 682 683 684 685 686
typedef struct _qemuBlockNamedNodeDataBitmap qemuBlockNamedNodeDataBitmap;
typedef qemuBlockNamedNodeDataBitmap *qemuBlockNamedNodeDataBitmapPtr;
struct _qemuBlockNamedNodeDataBitmap {
    char *name;
    bool recording;
    bool busy;
    bool persistent;
    bool inconsistent;

    unsigned long long dirtybytes;
    unsigned long long granularity;
};
687 688 689 690 691 692

typedef struct _qemuBlockNamedNodeData qemuBlockNamedNodeData;
typedef qemuBlockNamedNodeData *qemuBlockNamedNodeDataPtr;
struct _qemuBlockNamedNodeData {
    unsigned long long capacity;
    unsigned long long physical;
693 694 695

    qemuBlockNamedNodeDataBitmapPtr *bitmaps;
    size_t nbitmaps;
696 697 698
};

virHashTablePtr
699 700
qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon,
                                 bool supports_flat);
701

702
int qemuMonitorBlockResize(qemuMonitorPtr mon,
703 704
                           const char *device,
                           const char *nodename,
705
                           unsigned long long size);
706 707 708 709 710 711 712
int qemuMonitorSetPassword(qemuMonitorPtr mon,
                           int type,
                           const char *password,
                           const char *action_if_connected);
int qemuMonitorExpirePassword(qemuMonitorPtr mon,
                              int type,
                              const char *expire_time);
713
int qemuMonitorSetBalloon(qemuMonitorPtr mon,
714
                          unsigned long long newmem);
715
int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, bool online);
716

717 718

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


int qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon,
                                 unsigned long long offset,
733
                                 unsigned long long length,
734 735 736
                                 const char *path);
int qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon,
                                  unsigned long long offset,
737
                                  unsigned long long length,
738 739 740 741 742
                                  const char *path);

int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon,
                                 unsigned long bandwidth);

743 744 745
int qemuMonitorSetMigrationDowntime(qemuMonitorPtr mon,
                                    unsigned long long downtime);

746 747 748 749 750
int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long *cacheSize);
int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long cacheSize);

751
int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
752
                                  virJSONValuePtr *params);
753
int qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
754
                                  virJSONValuePtr params);
755

756
typedef enum {
757
    QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
758
    QEMU_MONITOR_MIGRATION_STATUS_SETUP,
759
    QEMU_MONITOR_MIGRATION_STATUS_ACTIVE,
760 761
    QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER,
    QEMU_MONITOR_MIGRATION_STATUS_DEVICE,
762
    QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY,
763 764
    QEMU_MONITOR_MIGRATION_STATUS_COMPLETED,
    QEMU_MONITOR_MIGRATION_STATUS_ERROR,
765
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLING,
766
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLED,
767
    QEMU_MONITOR_MIGRATION_STATUS_WAIT_UNPLUG,
768 769

    QEMU_MONITOR_MIGRATION_STATUS_LAST
770
} qemuMonitorMigrationStatus;
771

772
VIR_ENUM_DECL(qemuMonitorMigrationStatus);
773

774 775 776
typedef struct _qemuMonitorMigrationStats qemuMonitorMigrationStats;
typedef qemuMonitorMigrationStats *qemuMonitorMigrationStatsPtr;
struct _qemuMonitorMigrationStats {
777
    int status; /* qemuMonitorMigrationStatus */
778 779 780 781
    unsigned long long total_time;
    /* total or expected depending on status */
    bool downtime_set;
    unsigned long long downtime;
782 783 784 785 786 787 788
    /*
     * 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;
789 790 791 792

    unsigned long long ram_transferred;
    unsigned long long ram_remaining;
    unsigned long long ram_total;
793
    unsigned long long ram_bps;
794 795 796 797
    bool ram_duplicate_set;
    unsigned long long ram_duplicate;
    unsigned long long ram_normal;
    unsigned long long ram_normal_bytes;
798
    unsigned long long ram_dirty_rate;
799
    unsigned long long ram_page_size;
800
    unsigned long long ram_iteration;
801
    unsigned long long ram_postcopy_reqs;
802 803 804 805

    unsigned long long disk_transferred;
    unsigned long long disk_remaining;
    unsigned long long disk_total;
806
    unsigned long long disk_bps;
807 808 809 810 811 812 813

    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;
814 815

    int cpu_throttle_percentage;
816 817
};

818
int qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
819 820
                                 qemuMonitorMigrationStatsPtr stats,
                                 char **error);
821

822 823
int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
                                        char ***capabilities);
824
int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
825
                                        virJSONValuePtr caps);
826

A
Andrea Bolognani 已提交
827 828 829
int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon,
                                  virGICCapability **capabilities);

830 831 832
int qemuMonitorGetSEVCapabilities(qemuMonitorPtr mon,
                                  virSEVCapability **capabilities);

833
typedef enum {
834
  QEMU_MONITOR_MIGRATE_BACKGROUND       = 1 << 0,
835 836 837 838 839
  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 已提交
840 841 842 843
int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
                           unsigned int flags,
                           int fd);

844
int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
845
                             unsigned int flags,
846
                             const char *protocol,
847 848 849 850 851
                             const char *hostname,
                             int port);

int qemuMonitorMigrateCancel(qemuMonitorPtr mon);

852 853 854
int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
                                            const char *capability);

855 856 857
int qemuMonitorQueryDump(qemuMonitorPtr mon,
                         qemuMonitorDumpStatsPtr stats);

858
int qemuMonitorDumpToFd(qemuMonitorPtr mon,
859
                        int fd,
860 861
                        const char *dumpformat,
                        bool detach);
862

863 864 865 866 867 868
int qemuMonitorGraphicsRelocate(qemuMonitorPtr mon,
                                int type,
                                const char *hostname,
                                int port,
                                int tlsPort,
                                const char *tlsSubject);
869 870 871 872 873

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

874
/* This function preserves previous error and only set their own
875
 * error if no error was set before.
876
 */
877 878 879
int qemuMonitorCloseFileHandle(qemuMonitorPtr mon,
                               const char *fdname);

880
int qemuMonitorAddNetdev(qemuMonitorPtr mon,
881
                         const char *netdevstr,
882
                         int *tapfd, char **tapfdName, int tapfdSize,
883 884
                         int *vhostfd, char **vhostfdName, int vhostfdSize,
                         int slirpfd, char *slirpfdName);
885 886 887 888

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

889 890 891
int qemuMonitorQueryRxFilter(qemuMonitorPtr mon, const char *alias,
                             virNetDevRxFilterPtr *filter);

892 893 894 895 896 897
typedef struct _qemuMonitorChardevInfo qemuMonitorChardevInfo;
typedef qemuMonitorChardevInfo *qemuMonitorChardevInfoPtr;
struct _qemuMonitorChardevInfo {
    char *ptyPath;
    virDomainChrDeviceState state;
};
898
void qemuMonitorChardevInfoFree(void *data);
899 900
int qemuMonitorGetChardevInfo(qemuMonitorPtr mon,
                              virHashTablePtr *retinfo);
901

902 903
int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
                                       const char *bus,
904
                                       virPCIDeviceAddress *guestAddr);
905

906 907
int qemuMonitorAddDeviceArgs(qemuMonitorPtr mon,
                             virJSONValuePtr args);
908 909 910
int qemuMonitorAddDevice(qemuMonitorPtr mon,
                         const char *devicestr);

911 912 913 914 915
int qemuMonitorAddDeviceWithFd(qemuMonitorPtr mon,
                               const char *devicestr,
                               int fd,
                               const char *fdname);

916
int qemuMonitorDelDevice(qemuMonitorPtr mon,
917
                         const char *devalias);
918

919 920 921 922 923 924 925 926 927 928 929
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,
930
                         char **alias)
931
    ATTRIBUTE_NONNULL(2);
932

933 934 935
int qemuMonitorDelObject(qemuMonitorPtr mon,
                         const char *objalias);

936 937 938
int qemuMonitorAddDrive(qemuMonitorPtr mon,
                        const char *drivestr);

939
int qemuMonitorDriveDel(qemuMonitorPtr mon,
940 941
                        const char *drivestr);

C
Chris Lalancette 已提交
942 943 944 945
int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);

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

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

990 991 992 993
int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
                                const char *cmd,
                                char **reply,
                                bool hmp);
994

995 996
int qemuMonitorInjectNMI(qemuMonitorPtr mon);

997
int qemuMonitorScreendump(qemuMonitorPtr mon,
998 999
                          const char *device,
                          unsigned int head,
1000 1001
                          const char *file);

1002 1003 1004 1005 1006
int qemuMonitorSendKey(qemuMonitorPtr mon,
                       unsigned int holdtime,
                       unsigned int *keycodes,
                       unsigned int nkeycodes);

1007 1008
int qemuMonitorBlockStream(qemuMonitorPtr mon,
                           const char *device,
1009 1010
                           const char *jobname,
                           bool persistjob,
1011
                           const char *base,
1012
                           const char *baseNode,
1013
                           const char *backingName,
1014
                           unsigned long long bandwidth)
1015
    ATTRIBUTE_NONNULL(2);
1016

1017
int qemuMonitorBlockJobCancel(qemuMonitorPtr mon,
1018
                              const char *jobname)
1019
    ATTRIBUTE_NONNULL(2);
1020

1021
int qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,
1022
                                const char *jobname,
1023
                                unsigned long long bandwidth);
1024

1025 1026 1027 1028 1029 1030 1031
typedef struct _qemuMonitorBlockJobInfo qemuMonitorBlockJobInfo;
typedef qemuMonitorBlockJobInfo *qemuMonitorBlockJobInfoPtr;
struct _qemuMonitorBlockJobInfo {
    int type; /* virDomainBlockJobType */
    unsigned long long bandwidth; /* in bytes/s */
    virDomainBlockJobCursor cur;
    virDomainBlockJobCursor end;
1032
    int ready; /* -1 if unknown, 0 if not ready, 1 if ready */
1033 1034
};

1035 1036
virHashTablePtr qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
                                              bool rawjobname);
1037 1038 1039
int qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
                               const char *device,
                               qemuMonitorBlockJobInfoPtr info)
1040
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
1041

1042 1043 1044 1045
int qemuMonitorJobDismiss(qemuMonitorPtr mon,
                          const char *jobname)
    ATTRIBUTE_NONNULL(2);

1046 1047 1048 1049 1050
int qemuMonitorJobCancel(qemuMonitorPtr mon,
                         const char *jobname,
                         bool quiet)
    ATTRIBUTE_NONNULL(2);

1051 1052 1053 1054
int qemuMonitorJobComplete(qemuMonitorPtr mon,
                           const char *jobname)
    ATTRIBUTE_NONNULL(2);

1055 1056 1057 1058 1059 1060
int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                            const char *protocol,
                            int fd,
                            const char *fdname,
                            bool skipauth);

1061
int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
1062 1063
                                  const char *drivealias,
                                  const char *qomid,
1064
                                  virDomainBlockIoTuneInfoPtr info,
1065
                                  bool supportMaxOptions,
1066
                                  bool supportGroupNameOption,
1067
                                  bool supportMaxLengthOptions);
1068 1069

int qemuMonitorGetBlockIoThrottle(qemuMonitorPtr mon,
1070 1071
                                  const char *drivealias,
                                  const char *qdevid,
1072
                                  virDomainBlockIoTuneInfoPtr reply);
1073

1074 1075
int qemuMonitorSystemWakeup(qemuMonitorPtr mon);

1076 1077 1078 1079 1080 1081 1082
int qemuMonitorGetVersion(qemuMonitorPtr mon,
                          int *major,
                          int *minor,
                          int *micro,
                          char **package)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

1083 1084 1085 1086 1087 1088 1089 1090

typedef struct _qemuMonitorMachineInfo qemuMonitorMachineInfo;
typedef qemuMonitorMachineInfo *qemuMonitorMachineInfoPtr;

struct _qemuMonitorMachineInfo {
    char *name;
    bool isDefault;
    char *alias;
1091
    unsigned int maxCpus;
1092
    bool hotplugCpus;
J
Jiri Denemark 已提交
1093
    char *defaultCPU;
1094 1095 1096 1097 1098 1099 1100
};

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

void qemuMonitorMachineInfoFree(qemuMonitorMachineInfoPtr machine);

1101 1102 1103 1104
typedef struct _qemuMonitorCPUDefInfo qemuMonitorCPUDefInfo;
typedef qemuMonitorCPUDefInfo *qemuMonitorCPUDefInfoPtr;

struct _qemuMonitorCPUDefInfo {
1105
    virDomainCapsCPUUsable usable;
1106
    char *name;
1107
    char *type;
1108
    char **blockers; /* NULL-terminated string list */
1109 1110
};

1111 1112 1113 1114
typedef struct _qemuMonitorCPUDefs qemuMonitorCPUDefs;
typedef qemuMonitorCPUDefs *qemuMonitorCPUDefsPtr;
struct _qemuMonitorCPUDefs {
    size_t ncpus;
1115
    qemuMonitorCPUDefInfoPtr cpus;
1116 1117
};

1118
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
1119 1120
                                 qemuMonitorCPUDefsPtr *cpuDefs);
qemuMonitorCPUDefsPtr qemuMonitorCPUDefsNew(size_t count);
J
Jiri Denemark 已提交
1121
qemuMonitorCPUDefsPtr qemuMonitorCPUDefsCopy(qemuMonitorCPUDefsPtr src);
1122 1123 1124
void qemuMonitorCPUDefsFree(qemuMonitorCPUDefsPtr defs);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMonitorCPUDefs, qemuMonitorCPUDefsFree);

1125

1126 1127 1128 1129 1130 1131 1132 1133
typedef enum {
    QEMU_MONITOR_CPU_PROPERTY_BOOLEAN,
    QEMU_MONITOR_CPU_PROPERTY_STRING,
    QEMU_MONITOR_CPU_PROPERTY_NUMBER,

    QEMU_MONITOR_CPU_PROPERTY_LAST
} qemuMonitorCPUPropertyType;

1134
VIR_ENUM_DECL(qemuMonitorCPUProperty);
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145

typedef struct _qemuMonitorCPUProperty qemuMonitorCPUProperty;
typedef qemuMonitorCPUProperty *qemuMonitorCPUPropertyPtr;
struct _qemuMonitorCPUProperty {
    char *name;
    qemuMonitorCPUPropertyType type;
    union {
        bool boolean;
        char *string;
        long long number;
    } value;
1146
    virTristateBool migratable;
1147 1148
};

1149 1150 1151 1152 1153 1154
typedef struct _qemuMonitorCPUModelInfo qemuMonitorCPUModelInfo;
typedef qemuMonitorCPUModelInfo *qemuMonitorCPUModelInfoPtr;

struct _qemuMonitorCPUModelInfo {
    char *name;
    size_t nprops;
1155
    qemuMonitorCPUPropertyPtr props;
1156
    bool migratability;
1157 1158
};

1159 1160
typedef enum {
    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
1161 1162
    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL,
    QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
1163 1164
} qemuMonitorCPUModelExpansionType;

1165
int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
1166
                                    qemuMonitorCPUModelExpansionType type,
1167
                                    virCPUDefPtr cpu,
1168
                                    bool migratable,
1169
                                    bool fail_no_props,
1170 1171 1172 1173
                                    qemuMonitorCPUModelInfoPtr *model_info);

void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info);

1174 1175 1176 1177 1178
int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
                                   virCPUDefPtr cpu_a,
                                   virCPUDefPtr cpu_b,
                                   qemuMonitorCPUModelInfoPtr *baseline);

1179 1180 1181 1182 1183
int qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon,
                                     virCPUDefPtr cpu_a,
                                     virCPUDefPtr cpu_b,
                                     char **result);

1184 1185 1186
qemuMonitorCPUModelInfoPtr
qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);

1187 1188
int qemuMonitorGetCommands(qemuMonitorPtr mon,
                           char ***commands);
1189 1190
int qemuMonitorGetEvents(qemuMonitorPtr mon,
                         char ***events);
1191 1192
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                              const char *option,
1193 1194
                                              char ***params,
                                              bool *found);
1195

1196 1197 1198 1199
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
                           bool *enabled,
                           bool *present);

1200 1201
int qemuMonitorGetObjectTypes(qemuMonitorPtr mon,
                              char ***types);
1202 1203
int qemuMonitorGetDeviceProps(qemuMonitorPtr mon,
                              const char *device,
1204
                              char ***props);
1205 1206 1207
int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
                              const char *object,
                              char ***props);
1208
char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
1209

1210
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
1211 1212 1213
                              const virStorageNetHostDef *server,
                              const char *tls_alias)
    ATTRIBUTE_NONNULL(2);
1214 1215
int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
                            const char *deviceID,
1216 1217 1218
                            const char *export,
                            bool writable,
                            const char *bitmap);
1219
int qemuMonitorNBDServerStop(qemuMonitorPtr);
S
Stefan Berger 已提交
1220 1221 1222 1223 1224 1225
int qemuMonitorGetTPMModels(qemuMonitorPtr mon,
                            char ***tpmmodels);

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

1226 1227 1228
int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
                             const char *chrID,
                             virDomainChrSourceDefPtr chr);
1229 1230
int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
                             const char *chrID);
1231 1232 1233 1234

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

1235 1236 1237
typedef void (*qemuMonitorReportDomainLogError)(qemuMonitorPtr mon,
                                                const char *msg,
                                                void *opaque);
1238 1239 1240 1241
void qemuMonitorSetDomainLogLocked(qemuMonitorPtr mon,
                                   qemuMonitorReportDomainLogError func,
                                   void *opaque,
                                   virFreeCallback destroy);
1242 1243 1244 1245
void qemuMonitorSetDomainLog(qemuMonitorPtr mon,
                             qemuMonitorReportDomainLogError func,
                             void *opaque,
                             virFreeCallback destroy);
1246

1247 1248 1249
int qemuMonitorGetGuestCPUx86(qemuMonitorPtr mon,
                              virCPUDataPtr *data,
                              virCPUDataPtr *disabled);
1250

1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
typedef const char *(*qemuMonitorCPUFeatureTranslationCallback)(const char *name,
                                                                void *opaque);

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

1261 1262
int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon);

1263 1264
typedef struct _qemuMonitorIOThreadInfo qemuMonitorIOThreadInfo;
typedef qemuMonitorIOThreadInfo *qemuMonitorIOThreadInfoPtr;
1265

1266
struct _qemuMonitorIOThreadInfo {
1267
    unsigned int iothread_id;
1268
    int thread_id;
1269 1270 1271 1272
    bool poll_valid;
    unsigned long long poll_max_ns;
    unsigned int poll_grow;
    unsigned int poll_shrink;
1273 1274 1275
    bool set_poll_max_ns;
    bool set_poll_grow;
    bool set_poll_shrink;
1276 1277
};
int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
1278
                            qemuMonitorIOThreadInfoPtr **iothreads);
1279 1280
int qemuMonitorSetIOThread(qemuMonitorPtr mon,
                           qemuMonitorIOThreadInfoPtr iothreadInfo);
1281

1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295
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);

1296 1297 1298
int qemuMonitorMigrateIncoming(qemuMonitorPtr mon,
                               const char *uri);

1299 1300
int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon);

1301 1302 1303
int qemuMonitorMigrateContinue(qemuMonitorPtr mon,
                               qemuMonitorMigrationStatus status);

1304 1305 1306
int qemuMonitorGetRTCTime(qemuMonitorPtr mon,
                          struct tm *tm);

1307
virJSONValuePtr qemuMonitorQueryQMPSchema(qemuMonitorPtr mon);
1308

1309 1310 1311 1312
int qemuMonitorSetBlockThreshold(qemuMonitorPtr mon,
                                 const char *nodename,
                                 unsigned long long threshold);

1313
virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon);
1314

M
Michal Privoznik 已提交
1315 1316
int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon,
                                 const char *action);
1317

1318 1319 1320 1321
int qemuMonitorBlockdevCreate(qemuMonitorPtr mon,
                              const char *jobname,
                              virJSONValuePtr props);

1322
int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
1323
                           virJSONValuePtr *props);
1324

1325 1326 1327
int qemuMonitorBlockdevReopen(qemuMonitorPtr mon,
                              virJSONValuePtr *props);

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

1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344
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);

1345 1346 1347
char *
qemuMonitorGetSEVMeasurement(qemuMonitorPtr mon);

1348 1349 1350 1351 1352 1353 1354 1355 1356
typedef struct _qemuMonitorPRManagerInfo qemuMonitorPRManagerInfo;
typedef qemuMonitorPRManagerInfo *qemuMonitorPRManagerInfoPtr;
struct _qemuMonitorPRManagerInfo {
    bool connected;
};

int qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon,
                                virHashTablePtr *retinfo);

1357 1358 1359 1360 1361 1362 1363 1364
typedef struct  _qemuMonitorCurrentMachineInfo qemuMonitorCurrentMachineInfo;
typedef qemuMonitorCurrentMachineInfo *qemuMonitorCurrentMachineInfoPtr;
struct _qemuMonitorCurrentMachineInfo {
    bool wakeupSuspendSupport;
};

int qemuMonitorGetCurrentMachineInfo(qemuMonitorPtr mon,
                                     qemuMonitorCurrentMachineInfoPtr info);
1365 1366
void qemuMonitorJobInfoFree(qemuMonitorJobInfoPtr job);

1367
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMonitorJobInfo, qemuMonitorJobInfoFree);
1368 1369 1370 1371

int qemuMonitorGetJobInfo(qemuMonitorPtr mon,
                          qemuMonitorJobInfoPtr **jobs,
                          size_t *njobs);
1372 1373 1374 1375 1376 1377

int
qemuMonitorTransactionBitmapAdd(virJSONValuePtr actions,
                                const char *node,
                                const char *name,
                                bool persistent,
1378 1379
                                bool disabled,
                                unsigned long long granularity);
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
int
qemuMonitorTransactionBitmapRemove(virJSONValuePtr actions,
                                   const char *node,
                                   const char *name);
int
qemuMonitorTransactionBitmapEnable(virJSONValuePtr actions,
                                   const char *node,
                                   const char *name);
int
qemuMonitorTransactionBitmapDisable(virJSONValuePtr actions,
                                    const char *node,
                                    const char *name);
int
qemuMonitorTransactionBitmapMerge(virJSONValuePtr actions,
                                  const char *node,
                                  const char *target,
                                  virJSONValuePtr *sources);
1397 1398 1399 1400
int
qemuMonitorTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sources,
                                                 const char *sourcenode,
                                                 const char *sourcebitmap);
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411

int
qemuMonitorTransactionSnapshotLegacy(virJSONValuePtr actions,
                                     const char *device,
                                     const char *path,
                                     const char *format,
                                     bool existing);
int
qemuMonitorTransactionSnapshotBlockdev(virJSONValuePtr actions,
                                       const char *node,
                                       const char *overlay);
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426

typedef enum {
    QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_NONE = 0,
    QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_INCREMENTAL,
    QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_FULL,
    QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_LAST,
} qemuMonitorTransactionBackupSyncMode;

int
qemuMonitorTransactionBackup(virJSONValuePtr actions,
                             const char *device,
                             const char *jobname,
                             const char *target,
                             const char *bitmap,
                             qemuMonitorTransactionBackupSyncMode syncmode);