qemu_monitor.h 51.5 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 23
#ifndef LIBVIRT_QEMU_MONITOR_H
# define LIBVIRT_QEMU_MONITOR_H
24

25
# include "internal.h"
26

27
# include "domain_conf.h"
28
# include "virbitmap.h"
29
# include "virhash.h"
30
# include "virjson.h"
31
# include "virnetdev.h"
32
# include "device_conf.h"
33
# include "cpu/cpu.h"
A
Andrea Bolognani 已提交
34
# include "util/virgic.h"
35
# include "virenum.h"
36

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

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
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;

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

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

    qemuMonitorPasswordHandler passwordHandler;
    void *passwordOpaque;
};

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

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

90 91 92 93 94 95 96 97 98 99
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;
};

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

110 111 112 113 114 115 116 117 118 119 120

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


121
char *qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr info);
122
void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info);
123
void qemuMonitorEventRdmaGidStatusFree(qemuMonitorRdmaGidStatusPtr info);
J
Jiri Denemark 已提交
124 125

typedef void (*qemuMonitorDestroyCallback)(qemuMonitorPtr mon,
126 127
                                           virDomainObjPtr vm,
                                           void *opaque);
J
Jiri Denemark 已提交
128
typedef void (*qemuMonitorEofNotifyCallback)(qemuMonitorPtr mon,
129 130
                                             virDomainObjPtr vm,
                                             void *opaque);
J
Jiri Denemark 已提交
131
typedef void (*qemuMonitorErrorNotifyCallback)(qemuMonitorPtr mon,
132 133
                                               virDomainObjPtr vm,
                                               void *opaque);
134 135 136 137 138 139 140
typedef int (*qemuMonitorDomainEventCallback)(qemuMonitorPtr mon,
                                              virDomainObjPtr vm,
                                              const char *event,
                                              long long seconds,
                                              unsigned int micros,
                                              const char *details,
                                              void *opaque);
J
Jiri Denemark 已提交
141
typedef int (*qemuMonitorDomainShutdownCallback)(qemuMonitorPtr mon,
142
                                                 virDomainObjPtr vm,
143
                                                 virTristateBool guest,
144
                                                 void *opaque);
J
Jiri Denemark 已提交
145
typedef int (*qemuMonitorDomainResetCallback)(qemuMonitorPtr mon,
146 147
                                              virDomainObjPtr vm,
                                              void *opaque);
J
Jiri Denemark 已提交
148
typedef int (*qemuMonitorDomainPowerdownCallback)(qemuMonitorPtr mon,
149 150
                                                  virDomainObjPtr vm,
                                                  void *opaque);
J
Jiri Denemark 已提交
151
typedef int (*qemuMonitorDomainStopCallback)(qemuMonitorPtr mon,
152 153
                                             virDomainObjPtr vm,
                                             void *opaque);
J
Jiri Denemark 已提交
154
typedef int (*qemuMonitorDomainResumeCallback)(qemuMonitorPtr mon,
155 156
                                               virDomainObjPtr vm,
                                               void *opaque);
J
Jiri Denemark 已提交
157 158
typedef int (*qemuMonitorDomainRTCChangeCallback)(qemuMonitorPtr mon,
                                                  virDomainObjPtr vm,
159 160
                                                  long long offset,
                                                  void *opaque);
J
Jiri Denemark 已提交
161 162
typedef int (*qemuMonitorDomainWatchdogCallback)(qemuMonitorPtr mon,
                                                 virDomainObjPtr vm,
163 164
                                                 int action,
                                                 void *opaque);
J
Jiri Denemark 已提交
165 166 167
typedef int (*qemuMonitorDomainIOErrorCallback)(qemuMonitorPtr mon,
                                                virDomainObjPtr vm,
                                                const char *diskAlias,
168
                                                const char *nodename,
J
Jiri Denemark 已提交
169
                                                int action,
170 171
                                                const char *reason,
                                                void *opaque);
J
Jiri Denemark 已提交
172 173 174 175 176 177 178 179 180 181 182
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,
183 184
                                                 const char *saslUsername,
                                                 void *opaque);
J
Jiri Denemark 已提交
185 186 187 188
typedef int (*qemuMonitorDomainBlockJobCallback)(qemuMonitorPtr mon,
                                                 virDomainObjPtr vm,
                                                 const char *diskAlias,
                                                 int type,
189
                                                 int status,
190
                                                 const char *error,
191
                                                 void *opaque);
J
Jiri Denemark 已提交
192 193 194
typedef int (*qemuMonitorDomainTrayChangeCallback)(qemuMonitorPtr mon,
                                                   virDomainObjPtr vm,
                                                   const char *devAlias,
195
                                                   const char *devid,
196 197
                                                   int reason,
                                                   void *opaque);
J
Jiri Denemark 已提交
198
typedef int (*qemuMonitorDomainPMWakeupCallback)(qemuMonitorPtr mon,
199 200
                                                 virDomainObjPtr vm,
                                                 void *opaque);
J
Jiri Denemark 已提交
201
typedef int (*qemuMonitorDomainPMSuspendCallback)(qemuMonitorPtr mon,
202 203
                                                  virDomainObjPtr vm,
                                                  void *opaque);
J
Jiri Denemark 已提交
204 205
typedef int (*qemuMonitorDomainBalloonChangeCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
206 207
                                                      unsigned long long actual,
                                                      void *opaque);
J
Jiri Denemark 已提交
208
typedef int (*qemuMonitorDomainPMSuspendDiskCallback)(qemuMonitorPtr mon,
209 210
                                                      virDomainObjPtr vm,
                                                      void *opaque);
J
Jiri Denemark 已提交
211
typedef int (*qemuMonitorDomainGuestPanicCallback)(qemuMonitorPtr mon,
212
                                                   virDomainObjPtr vm,
213
                                                   qemuMonitorEventPanicInfoPtr info,
214
                                                   void *opaque);
J
Jiri Denemark 已提交
215 216
typedef int (*qemuMonitorDomainDeviceDeletedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
217 218
                                                      const char *devAlias,
                                                      void *opaque);
219 220 221 222
typedef int (*qemuMonitorDomainNicRxFilterChangedCallback)(qemuMonitorPtr mon,
                                                           virDomainObjPtr vm,
                                                           const char *devAlias,
                                                           void *opaque);
J
Jiri Denemark 已提交
223

224 225 226 227 228 229
typedef int (*qemuMonitorDomainSerialChangeCallback)(qemuMonitorPtr mon,
                                                     virDomainObjPtr vm,
                                                     const char *devAlias,
                                                     bool connected,
                                                     void *opaque);

230 231 232 233
typedef int (*qemuMonitorDomainSpiceMigratedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      void *opaque);

234 235 236 237 238
typedef int (*qemuMonitorDomainMigrationStatusCallback)(qemuMonitorPtr mon,
                                                        virDomainObjPtr vm,
                                                        int status,
                                                        void *opaque);

239 240 241 242 243
typedef int (*qemuMonitorDomainMigrationPassCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      int pass,
                                                      void *opaque);

244 245 246 247 248 249 250 251 252 253
typedef int (*qemuMonitorDomainAcpiOstInfoCallback)(qemuMonitorPtr mon,
                                                    virDomainObjPtr vm,
                                                    const char *alias,
                                                    const char *slotType,
                                                    const char *slot,
                                                    unsigned int source,
                                                    unsigned int status,
                                                    void *opaque);


254 255 256 257 258 259 260 261
typedef int (*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon,
                                                       virDomainObjPtr vm,
                                                       const char *nodename,
                                                       unsigned long long threshold,
                                                       unsigned long long excess,
                                                       void *opaque);


262 263 264 265 266 267 268 269 270
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;

271
VIR_ENUM_DECL(qemuMonitorDumpStatus);
272 273 274 275 276 277 278 279 280

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

281 282 283 284 285 286 287
typedef int (*qemuMonitorDomainDumpCompletedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      int status,
                                                      qemuMonitorDumpStatsPtr stats,
                                                      const char *error,
                                                      void *opaque);

288 289 290 291 292 293
typedef int (*qemuMonitorDomainPRManagerStatusChangedCallback)(qemuMonitorPtr mon,
                                                               virDomainObjPtr vm,
                                                               const char *prManager,
                                                               bool connected,
                                                               void *opaque);

294 295 296 297
typedef int (*qemuMonitorDomainRdmaGidStatusChangedCallback)(qemuMonitorPtr mon,
                                                             virDomainObjPtr vm,
                                                             const char *netdev,
                                                             bool gid_status,
298 299
                                                             unsigned long long subnet_prefix,
                                                             unsigned long long interface_id,
300 301
                                                             void *opaque);

302 303 304
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
struct _qemuMonitorCallbacks {
J
Jiri Denemark 已提交
305 306 307
    qemuMonitorDestroyCallback destroy;
    qemuMonitorEofNotifyCallback eofNotify;
    qemuMonitorErrorNotifyCallback errorNotify;
308
    qemuMonitorDomainEventCallback domainEvent;
J
Jiri Denemark 已提交
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
    qemuMonitorDomainShutdownCallback domainShutdown;
    qemuMonitorDomainResetCallback domainReset;
    qemuMonitorDomainPowerdownCallback domainPowerdown;
    qemuMonitorDomainStopCallback domainStop;
    qemuMonitorDomainResumeCallback domainResume;
    qemuMonitorDomainRTCChangeCallback domainRTCChange;
    qemuMonitorDomainWatchdogCallback domainWatchdog;
    qemuMonitorDomainIOErrorCallback domainIOError;
    qemuMonitorDomainGraphicsCallback domainGraphics;
    qemuMonitorDomainBlockJobCallback domainBlockJob;
    qemuMonitorDomainTrayChangeCallback domainTrayChange;
    qemuMonitorDomainPMWakeupCallback domainPMWakeup;
    qemuMonitorDomainPMSuspendCallback domainPMSuspend;
    qemuMonitorDomainBalloonChangeCallback domainBalloonChange;
    qemuMonitorDomainPMSuspendDiskCallback domainPMSuspendDisk;
    qemuMonitorDomainGuestPanicCallback domainGuestPanic;
    qemuMonitorDomainDeviceDeletedCallback domainDeviceDeleted;
326
    qemuMonitorDomainNicRxFilterChangedCallback domainNicRxFilterChanged;
327
    qemuMonitorDomainSerialChangeCallback domainSerialChange;
328
    qemuMonitorDomainSpiceMigratedCallback domainSpiceMigrated;
329
    qemuMonitorDomainMigrationStatusCallback domainMigrationStatus;
330
    qemuMonitorDomainMigrationPassCallback domainMigrationPass;
331
    qemuMonitorDomainAcpiOstInfoCallback domainAcpiOstInfo;
332
    qemuMonitorDomainBlockThresholdCallback domainBlockThreshold;
333
    qemuMonitorDomainDumpCompletedCallback domainDumpCompleted;
334
    qemuMonitorDomainPRManagerStatusChangedCallback domainPRManagerStatusChanged;
335
    qemuMonitorDomainRdmaGidStatusChangedCallback domainRdmaGidStatusChanged;
336 337
};

338
char *qemuMonitorEscapeArg(const char *in);
339
char *qemuMonitorUnescapeArg(const char *in);
340

341
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
342
                               virDomainChrSourceDefPtr config,
E
Eric Blake 已提交
343
                               bool json,
344
                               bool retry,
345
                               unsigned long long timeout,
346 347
                               qemuMonitorCallbacksPtr cb,
                               void *opaque)
348
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(6);
349 350
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
                                 int sockfd,
E
Eric Blake 已提交
351
                                 bool json,
352 353
                                 qemuMonitorCallbacksPtr cb,
                                 void *opaque)
354
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
355

356 357
bool qemuMonitorRegister(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
358 359
void qemuMonitorUnregister(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
360
void qemuMonitorClose(qemuMonitorPtr mon);
361

362 363
virErrorPtr qemuMonitorLastError(qemuMonitorPtr mon);

364
int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
365

366 367
int qemuMonitorSetLink(qemuMonitorPtr mon,
                       const char *name,
368 369
                       virDomainNetInterfaceLinkState state)
    ATTRIBUTE_NONNULL(2);
370

371
/* These APIs are for use by the internal Text/JSON monitor impl code only */
372
char *qemuMonitorNextCommandID(qemuMonitorPtr mon);
373 374
int qemuMonitorSend(qemuMonitorPtr mon,
                    qemuMonitorMessagePtr msg);
375 376 377 378
virJSONValuePtr qemuMonitorGetOptions(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
void qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
    ATTRIBUTE_NONNULL(1);
379 380
int qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon,
                                     virDomainVideoDefPtr video,
C
Cao jin 已提交
381
                                     const char *videoName)
382
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
383 384 385
int qemuMonitorUpdateVideoVram64Size(qemuMonitorPtr mon,
                                     virDomainVideoDefPtr video,
                                     const char *videoName)
386
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
387 388 389 390 391 392
int qemuMonitorHMPCommandWithFd(qemuMonitorPtr mon,
                                const char *cmd,
                                int scm_fd,
                                char **reply);
# define qemuMonitorHMPCommand(mon, cmd, reply) \
    qemuMonitorHMPCommandWithFd(mon, cmd, -1, reply)
393

394 395 396
int qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
                         long long seconds, unsigned int micros,
                         const char *details);
397
int qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest);
398 399 400
int qemuMonitorEmitReset(qemuMonitorPtr mon);
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
int qemuMonitorEmitStop(qemuMonitorPtr mon);
401
int qemuMonitorEmitResume(qemuMonitorPtr mon);
402
int qemuMonitorEmitRTCChange(qemuMonitorPtr mon, long long offset);
403
int qemuMonitorEmitWatchdog(qemuMonitorPtr mon, int action);
404 405
int qemuMonitorEmitIOError(qemuMonitorPtr mon,
                           const char *diskAlias,
406
                           const char *nodename,
407 408
                           int action,
                           const char *reason);
409 410 411 412 413 414 415 416 417 418 419
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);
420 421
int qemuMonitorEmitTrayChange(qemuMonitorPtr mon,
                              const char *devAlias,
422
                              const char *devid,
423
                              int reason);
O
Osier Yang 已提交
424
int qemuMonitorEmitPMWakeup(qemuMonitorPtr mon);
O
Osier Yang 已提交
425
int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon);
426 427 428
int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
                            const char *diskAlias,
                            int type,
429 430
                            int status,
                            const char *error);
431 432
int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
                                 unsigned long long actual);
433
int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
434 435
int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon,
                              qemuMonitorEventPanicInfoPtr info);
436 437
int qemuMonitorEmitDeviceDeleted(qemuMonitorPtr mon,
                                 const char *devAlias);
438 439
int qemuMonitorEmitNicRxFilterChanged(qemuMonitorPtr mon,
                                      const char *devAlias);
440 441 442
int qemuMonitorEmitSerialChange(qemuMonitorPtr mon,
                                const char *devAlias,
                                bool connected);
443
int qemuMonitorEmitSpiceMigrated(qemuMonitorPtr mon);
444 445
int qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
                                   int status);
446 447
int qemuMonitorEmitMigrationPass(qemuMonitorPtr mon,
                                 int pass);
448

449 450 451 452 453 454 455
int qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon,
                               const char *alias,
                               const char *slotType,
                               const char *slot,
                               unsigned int source,
                               unsigned int status);

456 457 458 459 460
int qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
                                  const char *nodename,
                                  unsigned long long threshold,
                                  unsigned long long excess);

461 462 463 464 465
int qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
                                 int status,
                                 qemuMonitorDumpStatsPtr stats,
                                 const char *error);

466 467 468 469
int qemuMonitorEmitPRManagerStatusChanged(qemuMonitorPtr mon,
                                          const char *prManager,
                                          bool connected);

470 471 472 473 474
int qemuMonitorEmitRdmaGidStatusChanged(qemuMonitorPtr mon,
                                        const char *netdev,
                                        bool gid_status,
                                        unsigned long long subnet_prefix,
                                        unsigned long long interface_id);
475

476
int qemuMonitorStartCPUs(qemuMonitorPtr mon);
477
int qemuMonitorStopCPUs(qemuMonitorPtr mon);
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492

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,
493
    QEMU_MONITOR_VM_STATUS_GUEST_PANICKED,
494 495 496

    QEMU_MONITOR_VM_STATUS_LAST
} qemuMonitorVMStatus;
497
VIR_ENUM_DECL(qemuMonitorVMStatus);
498 499
int qemuMonitorVMStatusToPausedReason(const char *status);

500
int qemuMonitorCheck(qemuMonitorPtr mon);
501 502
int qemuMonitorGetStatus(qemuMonitorPtr mon,
                         bool *running,
503 504
                         virDomainPausedReason *reason)
    ATTRIBUTE_NONNULL(2);
505

506
int qemuMonitorSystemReset(qemuMonitorPtr mon);
507 508
int qemuMonitorSystemPowerdown(qemuMonitorPtr mon);

509
struct qemuMonitorQueryCpusEntry {
510
    int qemu_id; /* id of the cpu as reported by qemu */
511
    pid_t tid;
512
    char *qom_path;
513
    bool halted;
514 515 516 517
};
void qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
                              size_t nentries);

518

519 520 521 522 523 524 525 526 527 528 529
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 */

    /* topology information -1 if qemu didn't report given parameter */
    int node_id;
    int socket_id;
    int core_id;
    int thread_id;
530 531 532

    /* internal data */
    int enable_id;
533 534 535 536 537
};
void qemuMonitorQueryHotpluggableCpusFree(struct qemuMonitorQueryHotpluggableCpusEntry *entries,
                                          size_t nentries);


538 539
struct _qemuMonitorCPUInfo {
    pid_t tid;
540
    int id; /* order of enabling of the given cpu */
541
    int qemu_id; /* identifier of the cpu as reported by query-cpus */
542

543 544 545 546
    /* state data */
    bool online;
    bool hotpluggable;

547 548 549 550 551
    /* topology info for hotplug purposes. Hotplug of given vcpu impossible if
     * all entries are -1 */
    int socket_id;
    int core_id;
    int thread_id;
552
    int node_id;
553 554 555 556 557 558 559 560 561 562
    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;

    /* alias of an hotpluggable entry. Entries with alias can be hot-unplugged */
    char *alias;

    /* internal for use in the matching code */
    char *qom_path;
563 564

    bool halted;
565 566 567 568 569 570
};
typedef struct _qemuMonitorCPUInfo qemuMonitorCPUInfo;
typedef qemuMonitorCPUInfo *qemuMonitorCPUInfoPtr;

void qemuMonitorCPUInfoFree(qemuMonitorCPUInfoPtr list,
                            size_t nitems);
571
int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
572
                          qemuMonitorCPUInfoPtr *vcpus,
573
                          size_t maxvcpus,
574 575 576 577 578
                          bool hotplug,
                          bool fast);
virBitmapPtr qemuMonitorGetCpuHalted(qemuMonitorPtr mon,
                                     size_t maxvcpus,
                                     bool fast);
579

580
int qemuMonitorGetVirtType(qemuMonitorPtr mon,
581
                           virDomainVirtType *virtType);
582
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
583
                              unsigned long long *currmem);
584
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
585
                              virDomainMemballoonDefPtr balloon,
586 587
                              virDomainMemoryStatPtr stats,
                              unsigned int nr_stats);
588
int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
589
                                    virDomainMemballoonDefPtr balloon,
590
                                    int period);
591

592
int qemuMonitorBlockIOStatusToError(const char *status);
593 594
virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon);

595
virJSONValuePtr qemuMonitorQueryBlockstats(qemuMonitorPtr mon);
596

597 598 599 600 601 602 603 604 605 606 607
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;
608 609
    unsigned long long capacity;
    unsigned long long physical;
610 611 612

    /* value of wr_highest_offset is valid if it's non 0 or
     * if wr_highest_offset_valid is true */
613
    unsigned long long wr_highest_offset;
614
    bool wr_highest_offset_valid;
615 616 617

    /* write_threshold is valid only if it's non-zero, conforming to qemu semantics */
    unsigned long long write_threshold;
618 619 620
};

int qemuMonitorGetAllBlockStatsInfo(qemuMonitorPtr mon,
621 622
                                    virHashTablePtr *ret_stats,
                                    bool backingChain)
623
    ATTRIBUTE_NONNULL(2);
624

625
int qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
626 627
                                        virHashTablePtr stats,
                                        bool backingChain)
628
    ATTRIBUTE_NONNULL(2);
629

630 631 632 633
int qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
                                                virHashTablePtr stats)
    ATTRIBUTE_NONNULL(2);

634
int qemuMonitorBlockResize(qemuMonitorPtr mon,
635 636
                           const char *device,
                           const char *nodename,
637
                           unsigned long long size);
638 639 640 641 642 643 644
int qemuMonitorSetPassword(qemuMonitorPtr mon,
                           int type,
                           const char *password,
                           const char *action_if_connected);
int qemuMonitorExpirePassword(qemuMonitorPtr mon,
                              int type,
                              const char *expire_time);
645
int qemuMonitorSetBalloon(qemuMonitorPtr mon,
646
                          unsigned long long newmem);
647
int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, bool online);
648

E
Eric Blake 已提交
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
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);

668 669

/* XXX should we pass the virDomainDiskDefPtr instead
670
 * and hide dev_name details inside monitor. Reconsider
671 672 673
 * this when doing the QMP implementation
 */
int qemuMonitorEjectMedia(qemuMonitorPtr mon,
674
                          const char *dev_name,
675
                          bool force);
676
int qemuMonitorChangeMedia(qemuMonitorPtr mon,
677
                           const char *dev_name,
678 679
                           const char *newmedia,
                           const char *format);
680 681 682 683 684 685 686 687 688 689 690 691 692 693


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

694 695 696
int qemuMonitorSetMigrationDowntime(qemuMonitorPtr mon,
                                    unsigned long long downtime);

697 698 699 700 701
int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long *cacheSize);
int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long cacheSize);

702
int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
703
                                  virJSONValuePtr *params);
704
int qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
705
                                  virJSONValuePtr params);
706

707
typedef enum {
708
    QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
709
    QEMU_MONITOR_MIGRATION_STATUS_SETUP,
710
    QEMU_MONITOR_MIGRATION_STATUS_ACTIVE,
711 712
    QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER,
    QEMU_MONITOR_MIGRATION_STATUS_DEVICE,
713
    QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY,
714 715
    QEMU_MONITOR_MIGRATION_STATUS_COMPLETED,
    QEMU_MONITOR_MIGRATION_STATUS_ERROR,
716
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLING,
717 718 719
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLED,

    QEMU_MONITOR_MIGRATION_STATUS_LAST
720
} qemuMonitorMigrationStatus;
721

722
VIR_ENUM_DECL(qemuMonitorMigrationStatus);
723

724 725 726
typedef struct _qemuMonitorMigrationStats qemuMonitorMigrationStats;
typedef qemuMonitorMigrationStats *qemuMonitorMigrationStatsPtr;
struct _qemuMonitorMigrationStats {
727
    int status; /* qemuMonitorMigrationStatus */
728 729 730 731
    unsigned long long total_time;
    /* total or expected depending on status */
    bool downtime_set;
    unsigned long long downtime;
732 733 734 735 736 737 738
    /*
     * 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;
739 740 741 742

    unsigned long long ram_transferred;
    unsigned long long ram_remaining;
    unsigned long long ram_total;
743
    unsigned long long ram_bps;
744 745 746 747
    bool ram_duplicate_set;
    unsigned long long ram_duplicate;
    unsigned long long ram_normal;
    unsigned long long ram_normal_bytes;
748
    unsigned long long ram_dirty_rate;
749
    unsigned long long ram_page_size;
750
    unsigned long long ram_iteration;
751
    unsigned long long ram_postcopy_reqs;
752 753 754 755

    unsigned long long disk_transferred;
    unsigned long long disk_remaining;
    unsigned long long disk_total;
756
    unsigned long long disk_bps;
757 758 759 760 761 762 763

    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;
764 765

    int cpu_throttle_percentage;
766 767
};

768
int qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
769 770
                                 qemuMonitorMigrationStatsPtr stats,
                                 char **error);
771

772 773
int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
                                        char ***capabilities);
774
int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
775
                                        virJSONValuePtr caps);
776

A
Andrea Bolognani 已提交
777 778 779
int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon,
                                  virGICCapability **capabilities);

780 781 782
int qemuMonitorGetSEVCapabilities(qemuMonitorPtr mon,
                                  virSEVCapability **capabilities);

783
typedef enum {
784
  QEMU_MONITOR_MIGRATE_BACKGROUND       = 1 << 0,
785 786 787 788 789
  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 已提交
790 791 792 793
int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
                           unsigned int flags,
                           int fd);

794
int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
795
                             unsigned int flags,
796
                             const char *protocol,
797 798 799 800 801
                             const char *hostname,
                             int port);

int qemuMonitorMigrateCancel(qemuMonitorPtr mon);

802 803 804
int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
                                            const char *capability);

805 806 807
int qemuMonitorQueryDump(qemuMonitorPtr mon,
                         qemuMonitorDumpStatsPtr stats);

808
int qemuMonitorDumpToFd(qemuMonitorPtr mon,
809
                        int fd,
810 811
                        const char *dumpformat,
                        bool detach);
812

813 814 815 816 817 818
int qemuMonitorGraphicsRelocate(qemuMonitorPtr mon,
                                int type,
                                const char *hostname,
                                int port,
                                int tlsPort,
                                const char *tlsSubject);
819 820 821 822

int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
                              const char *fdname,
                              int fd);
823
int qemuMonitorAddFd(qemuMonitorPtr mon, int fdset, int fd, const char *name);
824

825 826
/* These two functions preserve previous error and only set their own
 * error if no error was set before.
827
 */
828 829
int qemuMonitorCloseFileHandle(qemuMonitorPtr mon,
                               const char *fdname);
830
int qemuMonitorRemoveFd(qemuMonitorPtr mon, int fdset, int fd);
831

832
int qemuMonitorAddNetdev(qemuMonitorPtr mon,
833
                         const char *netdevstr,
834 835
                         int *tapfd, char **tapfdName, int tapfdSize,
                         int *vhostfd, char **vhostfdName, int vhostfdSize);
836 837 838 839

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

840 841 842
int qemuMonitorQueryRxFilter(qemuMonitorPtr mon, const char *alias,
                             virNetDevRxFilterPtr *filter);

843 844 845 846 847 848
typedef struct _qemuMonitorChardevInfo qemuMonitorChardevInfo;
typedef qemuMonitorChardevInfo *qemuMonitorChardevInfoPtr;
struct _qemuMonitorChardevInfo {
    char *ptyPath;
    virDomainChrDeviceState state;
};
849
void qemuMonitorChardevInfoFree(void *data, const void *name);
850 851
int qemuMonitorGetChardevInfo(qemuMonitorPtr mon,
                              virHashTablePtr *retinfo);
852

853 854
int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
                                       const char *bus,
855
                                       virPCIDeviceAddress *guestAddr);
856

857 858
int qemuMonitorAddDeviceArgs(qemuMonitorPtr mon,
                             virJSONValuePtr args);
859 860 861
int qemuMonitorAddDevice(qemuMonitorPtr mon,
                         const char *devicestr);

862 863 864 865 866
int qemuMonitorAddDeviceWithFd(qemuMonitorPtr mon,
                               const char *devicestr,
                               int fd,
                               const char *fdname);

867
int qemuMonitorDelDevice(qemuMonitorPtr mon,
868
                         const char *devalias);
869

870 871 872 873 874 875 876 877 878 879 880
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,
881
                         char **alias)
882
    ATTRIBUTE_NONNULL(2);
883

884 885 886
int qemuMonitorDelObject(qemuMonitorPtr mon,
                         const char *objalias);

887 888 889
int qemuMonitorAddDrive(qemuMonitorPtr mon,
                        const char *drivestr);

890
int qemuMonitorDriveDel(qemuMonitorPtr mon,
891 892
                        const char *drivestr);

C
Chris Lalancette 已提交
893 894 895 896
int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);

897
int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions)
898
    ATTRIBUTE_NONNULL(2);
899 900 901 902
int qemuMonitorDriveMirror(qemuMonitorPtr mon,
                           const char *device,
                           const char *file,
                           const char *format,
903
                           unsigned long long bandwidth,
904 905
                           unsigned int granularity,
                           unsigned long long buf_size,
906 907
                           bool shallow,
                           bool reuse)
908
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
909 910 911 912 913 914 915
int qemuMonitorBlockdevMirror(qemuMonitorPtr mon,
                              const char *jobname,
                              const char *device,
                              const char *target,
                              unsigned long long bandwidth,
                              unsigned int granularity,
                              unsigned long long buf_size,
916
                              bool shallow)
917
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
918
int qemuMonitorDrivePivot(qemuMonitorPtr mon,
919
                          const char *jobname)
920
    ATTRIBUTE_NONNULL(2);
921

922 923 924 925
int qemuMonitorBlockCommit(qemuMonitorPtr mon,
                           const char *device,
                           const char *top,
                           const char *base,
926
                           const char *backingName,
927
                           unsigned long long bandwidth)
928
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
929
bool qemuMonitorSupportsActiveCommit(qemuMonitorPtr mon);
930 931 932 933
char *qemuMonitorDiskNameLookup(qemuMonitorPtr mon,
                                const char *device,
                                virStorageSourcePtr top,
                                virStorageSourcePtr target)
934
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
935

936 937 938 939
int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
                                const char *cmd,
                                char **reply,
                                bool hmp);
940

941 942
int qemuMonitorInjectNMI(qemuMonitorPtr mon);

943
int qemuMonitorScreendump(qemuMonitorPtr mon,
944 945
                          const char *device,
                          unsigned int head,
946 947
                          const char *file);

948 949 950 951 952
int qemuMonitorSendKey(qemuMonitorPtr mon,
                       unsigned int holdtime,
                       unsigned int *keycodes,
                       unsigned int nkeycodes);

953 954 955 956
int qemuMonitorBlockStream(qemuMonitorPtr mon,
                           const char *device,
                           const char *base,
                           const char *backingName,
957
                           unsigned long long bandwidth)
958
    ATTRIBUTE_NONNULL(2);
959

960
int qemuMonitorBlockJobCancel(qemuMonitorPtr mon,
961
                              const char *jobname)
962
    ATTRIBUTE_NONNULL(2);
963

964
int qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,
965
                                const char *jobname,
966
                                unsigned long long bandwidth);
967

968 969 970 971 972 973 974
typedef struct _qemuMonitorBlockJobInfo qemuMonitorBlockJobInfo;
typedef qemuMonitorBlockJobInfo *qemuMonitorBlockJobInfoPtr;
struct _qemuMonitorBlockJobInfo {
    int type; /* virDomainBlockJobType */
    unsigned long long bandwidth; /* in bytes/s */
    virDomainBlockJobCursor cur;
    virDomainBlockJobCursor end;
975
    int ready; /* -1 if unknown, 0 if not ready, 1 if ready */
976 977 978 979 980 981
};

virHashTablePtr qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon);
int qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
                               const char *device,
                               qemuMonitorBlockJobInfoPtr info)
982
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
983

984 985 986 987 988 989
int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                            const char *protocol,
                            int fd,
                            const char *fdname,
                            bool skipauth);

990
int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
991 992
                                  const char *drivealias,
                                  const char *qomid,
993
                                  virDomainBlockIoTuneInfoPtr info,
994
                                  bool supportMaxOptions,
995
                                  bool supportGroupNameOption,
996
                                  bool supportMaxLengthOptions);
997 998

int qemuMonitorGetBlockIoThrottle(qemuMonitorPtr mon,
999 1000
                                  const char *drivealias,
                                  const char *qdevid,
1001
                                  virDomainBlockIoTuneInfoPtr reply);
1002

1003 1004
int qemuMonitorSystemWakeup(qemuMonitorPtr mon);

1005 1006 1007 1008 1009 1010 1011
int qemuMonitorGetVersion(qemuMonitorPtr mon,
                          int *major,
                          int *minor,
                          int *micro,
                          char **package)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

1012 1013 1014 1015 1016 1017 1018 1019

typedef struct _qemuMonitorMachineInfo qemuMonitorMachineInfo;
typedef qemuMonitorMachineInfo *qemuMonitorMachineInfoPtr;

struct _qemuMonitorMachineInfo {
    char *name;
    bool isDefault;
    char *alias;
1020
    unsigned int maxCpus;
1021
    bool hotplugCpus;
1022 1023 1024 1025 1026 1027 1028
};

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

void qemuMonitorMachineInfoFree(qemuMonitorMachineInfoPtr machine);

1029 1030 1031 1032
typedef struct _qemuMonitorCPUDefInfo qemuMonitorCPUDefInfo;
typedef qemuMonitorCPUDefInfo *qemuMonitorCPUDefInfoPtr;

struct _qemuMonitorCPUDefInfo {
1033
    virTristateBool usable;
1034
    char *name;
1035
    char **blockers; /* NULL-terminated string list */
1036 1037
};

1038
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
1039 1040
                                 qemuMonitorCPUDefInfoPtr **cpus);
void qemuMonitorCPUDefInfoFree(qemuMonitorCPUDefInfoPtr cpu);
1041

1042 1043 1044 1045 1046 1047 1048 1049
typedef enum {
    QEMU_MONITOR_CPU_PROPERTY_BOOLEAN,
    QEMU_MONITOR_CPU_PROPERTY_STRING,
    QEMU_MONITOR_CPU_PROPERTY_NUMBER,

    QEMU_MONITOR_CPU_PROPERTY_LAST
} qemuMonitorCPUPropertyType;

1050
VIR_ENUM_DECL(qemuMonitorCPUProperty);
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061

typedef struct _qemuMonitorCPUProperty qemuMonitorCPUProperty;
typedef qemuMonitorCPUProperty *qemuMonitorCPUPropertyPtr;
struct _qemuMonitorCPUProperty {
    char *name;
    qemuMonitorCPUPropertyType type;
    union {
        bool boolean;
        char *string;
        long long number;
    } value;
1062
    virTristateBool migratable;
1063 1064
};

1065 1066 1067 1068 1069 1070
typedef struct _qemuMonitorCPUModelInfo qemuMonitorCPUModelInfo;
typedef qemuMonitorCPUModelInfo *qemuMonitorCPUModelInfoPtr;

struct _qemuMonitorCPUModelInfo {
    char *name;
    size_t nprops;
1071
    qemuMonitorCPUPropertyPtr props;
1072
    bool migratability;
1073 1074
};

1075 1076
typedef enum {
    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
1077 1078
    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL,
    QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
1079 1080
} qemuMonitorCPUModelExpansionType;

1081
int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
1082
                                    qemuMonitorCPUModelExpansionType type,
1083
                                    const char *model_name,
1084
                                    bool migratable,
1085 1086 1087 1088 1089 1090 1091
                                    qemuMonitorCPUModelInfoPtr *model_info);

void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info);

qemuMonitorCPUModelInfoPtr
qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);

1092 1093
int qemuMonitorGetCommands(qemuMonitorPtr mon,
                           char ***commands);
1094 1095
int qemuMonitorGetEvents(qemuMonitorPtr mon,
                         char ***events);
1096 1097
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                              const char *option,
1098 1099
                                              char ***params,
                                              bool *found);
1100

1101 1102 1103 1104
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
                           bool *enabled,
                           bool *present);

1105 1106
int qemuMonitorGetObjectTypes(qemuMonitorPtr mon,
                              char ***types);
1107 1108
int qemuMonitorGetDeviceProps(qemuMonitorPtr mon,
                              const char *device,
1109
                              char ***props);
1110 1111 1112
int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
                              const char *object,
                              char ***props);
1113
char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
1114

1115
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
1116 1117 1118
                              const virStorageNetHostDef *server,
                              const char *tls_alias)
    ATTRIBUTE_NONNULL(2);
1119 1120 1121
int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
                            const char *deviceID,
                            bool writable);
1122
int qemuMonitorNBDServerStop(qemuMonitorPtr);
S
Stefan Berger 已提交
1123 1124 1125 1126 1127 1128
int qemuMonitorGetTPMModels(qemuMonitorPtr mon,
                            char ***tpmmodels);

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

1129 1130 1131
int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
                             const char *chrID,
                             virDomainChrSourceDefPtr chr);
1132 1133
int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
                             const char *chrID);
1134 1135 1136 1137

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

1138 1139 1140
typedef void (*qemuMonitorReportDomainLogError)(qemuMonitorPtr mon,
                                                const char *msg,
                                                void *opaque);
1141 1142 1143 1144
void qemuMonitorSetDomainLogLocked(qemuMonitorPtr mon,
                                   qemuMonitorReportDomainLogError func,
                                   void *opaque,
                                   virFreeCallback destroy);
1145 1146 1147 1148
void qemuMonitorSetDomainLog(qemuMonitorPtr mon,
                             qemuMonitorReportDomainLogError func,
                             void *opaque,
                             virFreeCallback destroy);
1149

1150 1151
int qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
                           virArch arch,
1152 1153
                           virCPUDataPtr *data,
                           virCPUDataPtr *disabled);
1154

1155 1156
int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon);

1157 1158
typedef struct _qemuMonitorIOThreadInfo qemuMonitorIOThreadInfo;
typedef qemuMonitorIOThreadInfo *qemuMonitorIOThreadInfoPtr;
1159

1160
struct _qemuMonitorIOThreadInfo {
1161
    unsigned int iothread_id;
1162
    int thread_id;
1163 1164 1165 1166
    bool poll_valid;
    unsigned long long poll_max_ns;
    unsigned int poll_grow;
    unsigned int poll_shrink;
1167 1168 1169
    bool set_poll_max_ns;
    bool set_poll_grow;
    bool set_poll_shrink;
1170 1171
};
int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
1172
                            qemuMonitorIOThreadInfoPtr **iothreads);
1173 1174
int qemuMonitorSetIOThread(qemuMonitorPtr mon,
                           qemuMonitorIOThreadInfoPtr iothreadInfo);
1175

1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189
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);

1190 1191 1192
int qemuMonitorMigrateIncoming(qemuMonitorPtr mon,
                               const char *uri);

1193 1194
int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon);

1195 1196 1197
int qemuMonitorMigrateContinue(qemuMonitorPtr mon,
                               qemuMonitorMigrationStatus status);

1198 1199 1200
int qemuMonitorGetRTCTime(qemuMonitorPtr mon,
                          struct tm *tm);

1201
virJSONValuePtr qemuMonitorQueryQMPSchema(qemuMonitorPtr mon);
1202

1203 1204 1205 1206
int qemuMonitorSetBlockThreshold(qemuMonitorPtr mon,
                                 const char *nodename,
                                 unsigned long long threshold);

1207
virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon);
1208

M
Michal Privoznik 已提交
1209 1210
int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon,
                                 const char *action);
1211 1212 1213 1214 1215 1216 1217

int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
                           virJSONValuePtr props);

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

1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231
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);

1232 1233 1234
char *
qemuMonitorGetSEVMeasurement(qemuMonitorPtr mon);

1235 1236 1237 1238 1239 1240 1241 1242 1243
typedef struct _qemuMonitorPRManagerInfo qemuMonitorPRManagerInfo;
typedef qemuMonitorPRManagerInfo *qemuMonitorPRManagerInfoPtr;
struct _qemuMonitorPRManagerInfo {
    bool connected;
};

int qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon,
                                virHashTablePtr *retinfo);

1244 1245 1246 1247 1248 1249 1250 1251 1252
typedef struct  _qemuMonitorCurrentMachineInfo qemuMonitorCurrentMachineInfo;
typedef qemuMonitorCurrentMachineInfo *qemuMonitorCurrentMachineInfoPtr;
struct _qemuMonitorCurrentMachineInfo {
    bool wakeupSuspendSupport;
};

int qemuMonitorGetCurrentMachineInfo(qemuMonitorPtr mon,
                                     qemuMonitorCurrentMachineInfoPtr info);

1253
#endif /* LIBVIRT_QEMU_MONITOR_H */