qemu_monitor.h 49.0 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

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

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

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

struct _qemuMonitorMessage {
    int txFD;

    char *txBuffer;
    int txOffset;
    int txLength;

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

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

    qemuMonitorPasswordHandler passwordHandler;
    void *passwordOpaque;
};

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

    QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_LAST
} qemuMonitorEventPanicInfoType;

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

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

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

109
char *qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr info);
110
void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info);
J
Jiri Denemark 已提交
111 112

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

211 212 213 214 215 216
typedef int (*qemuMonitorDomainSerialChangeCallback)(qemuMonitorPtr mon,
                                                     virDomainObjPtr vm,
                                                     const char *devAlias,
                                                     bool connected,
                                                     void *opaque);

217 218 219 220
typedef int (*qemuMonitorDomainSpiceMigratedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      void *opaque);

221 222 223 224 225
typedef int (*qemuMonitorDomainMigrationStatusCallback)(qemuMonitorPtr mon,
                                                        virDomainObjPtr vm,
                                                        int status,
                                                        void *opaque);

226 227 228 229 230
typedef int (*qemuMonitorDomainMigrationPassCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      int pass,
                                                      void *opaque);

231 232 233 234 235 236 237 238 239 240
typedef int (*qemuMonitorDomainAcpiOstInfoCallback)(qemuMonitorPtr mon,
                                                    virDomainObjPtr vm,
                                                    const char *alias,
                                                    const char *slotType,
                                                    const char *slot,
                                                    unsigned int source,
                                                    unsigned int status,
                                                    void *opaque);


241 242 243 244 245 246 247 248
typedef int (*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon,
                                                       virDomainObjPtr vm,
                                                       const char *nodename,
                                                       unsigned long long threshold,
                                                       unsigned long long excess,
                                                       void *opaque);


249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
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;

VIR_ENUM_DECL(qemuMonitorDumpStatus)

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

268 269 270 271 272 273 274
typedef int (*qemuMonitorDomainDumpCompletedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
                                                      int status,
                                                      qemuMonitorDumpStatsPtr stats,
                                                      const char *error,
                                                      void *opaque);

275 276 277 278 279 280
typedef int (*qemuMonitorDomainPRManagerStatusChangedCallback)(qemuMonitorPtr mon,
                                                               virDomainObjPtr vm,
                                                               const char *prManager,
                                                               bool connected,
                                                               void *opaque);

281 282 283
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
struct _qemuMonitorCallbacks {
J
Jiri Denemark 已提交
284 285 286
    qemuMonitorDestroyCallback destroy;
    qemuMonitorEofNotifyCallback eofNotify;
    qemuMonitorErrorNotifyCallback errorNotify;
287
    qemuMonitorDomainEventCallback domainEvent;
J
Jiri Denemark 已提交
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
    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;
305
    qemuMonitorDomainNicRxFilterChangedCallback domainNicRxFilterChanged;
306
    qemuMonitorDomainSerialChangeCallback domainSerialChange;
307
    qemuMonitorDomainSpiceMigratedCallback domainSpiceMigrated;
308
    qemuMonitorDomainMigrationStatusCallback domainMigrationStatus;
309
    qemuMonitorDomainMigrationPassCallback domainMigrationPass;
310
    qemuMonitorDomainAcpiOstInfoCallback domainAcpiOstInfo;
311
    qemuMonitorDomainBlockThresholdCallback domainBlockThreshold;
312
    qemuMonitorDomainDumpCompletedCallback domainDumpCompleted;
313
    qemuMonitorDomainPRManagerStatusChangedCallback domainPRManagerStatusChanged;
314 315
};

316
char *qemuMonitorEscapeArg(const char *in);
317
char *qemuMonitorUnescapeArg(const char *in);
318

319
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
320
                               virDomainChrSourceDefPtr config,
E
Eric Blake 已提交
321
                               bool json,
322
                               bool retry,
323
                               unsigned long long timeout,
324 325
                               qemuMonitorCallbacksPtr cb,
                               void *opaque)
326
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(6);
327 328
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
                                 int sockfd,
E
Eric Blake 已提交
329
                                 bool json,
330 331
                                 qemuMonitorCallbacksPtr cb,
                                 void *opaque)
332
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
333

334 335
bool qemuMonitorRegister(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
336 337
void qemuMonitorUnregister(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
338
void qemuMonitorClose(qemuMonitorPtr mon);
339

340 341
virErrorPtr qemuMonitorLastError(qemuMonitorPtr mon);

342
int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
343

344 345
int qemuMonitorSetLink(qemuMonitorPtr mon,
                       const char *name,
346 347
                       virDomainNetInterfaceLinkState state)
    ATTRIBUTE_NONNULL(2);
348

349
/* These APIs are for use by the internal Text/JSON monitor impl code only */
350
char *qemuMonitorNextCommandID(qemuMonitorPtr mon);
351 352
int qemuMonitorSend(qemuMonitorPtr mon,
                    qemuMonitorMessagePtr msg);
353 354 355 356
virJSONValuePtr qemuMonitorGetOptions(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
void qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
    ATTRIBUTE_NONNULL(1);
357 358
int qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon,
                                     virDomainVideoDefPtr video,
C
Cao jin 已提交
359
                                     const char *videoName)
360
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
361 362 363
int qemuMonitorUpdateVideoVram64Size(qemuMonitorPtr mon,
                                     virDomainVideoDefPtr video,
                                     const char *videoName)
364
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
365 366 367 368 369 370
int qemuMonitorHMPCommandWithFd(qemuMonitorPtr mon,
                                const char *cmd,
                                int scm_fd,
                                char **reply);
# define qemuMonitorHMPCommand(mon, cmd, reply) \
    qemuMonitorHMPCommandWithFd(mon, cmd, -1, reply)
371

372 373 374
int qemuMonitorEmitEvent(qemuMonitorPtr mon, const char *event,
                         long long seconds, unsigned int micros,
                         const char *details);
375
int qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest);
376 377 378
int qemuMonitorEmitReset(qemuMonitorPtr mon);
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
int qemuMonitorEmitStop(qemuMonitorPtr mon);
379
int qemuMonitorEmitResume(qemuMonitorPtr mon);
380
int qemuMonitorEmitRTCChange(qemuMonitorPtr mon, long long offset);
381
int qemuMonitorEmitWatchdog(qemuMonitorPtr mon, int action);
382 383
int qemuMonitorEmitIOError(qemuMonitorPtr mon,
                           const char *diskAlias,
384
                           const char *nodename,
385 386
                           int action,
                           const char *reason);
387 388 389 390 391 392 393 394 395 396 397
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);
398 399
int qemuMonitorEmitTrayChange(qemuMonitorPtr mon,
                              const char *devAlias,
400
                              const char *devid,
401
                              int reason);
O
Osier Yang 已提交
402
int qemuMonitorEmitPMWakeup(qemuMonitorPtr mon);
O
Osier Yang 已提交
403
int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon);
404 405 406
int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
                            const char *diskAlias,
                            int type,
407 408
                            int status,
                            const char *error);
409 410
int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
                                 unsigned long long actual);
411
int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
412 413
int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon,
                              qemuMonitorEventPanicInfoPtr info);
414 415
int qemuMonitorEmitDeviceDeleted(qemuMonitorPtr mon,
                                 const char *devAlias);
416 417
int qemuMonitorEmitNicRxFilterChanged(qemuMonitorPtr mon,
                                      const char *devAlias);
418 419 420
int qemuMonitorEmitSerialChange(qemuMonitorPtr mon,
                                const char *devAlias,
                                bool connected);
421
int qemuMonitorEmitSpiceMigrated(qemuMonitorPtr mon);
422 423
int qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
                                   int status);
424 425
int qemuMonitorEmitMigrationPass(qemuMonitorPtr mon,
                                 int pass);
426

427 428 429 430 431 432 433
int qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon,
                               const char *alias,
                               const char *slotType,
                               const char *slot,
                               unsigned int source,
                               unsigned int status);

434 435 436 437 438
int qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
                                  const char *nodename,
                                  unsigned long long threshold,
                                  unsigned long long excess);

439 440 441 442 443
int qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
                                 int status,
                                 qemuMonitorDumpStatsPtr stats,
                                 const char *error);

444 445 446 447
int qemuMonitorEmitPRManagerStatusChanged(qemuMonitorPtr mon,
                                          const char *prManager,
                                          bool connected);

448
int qemuMonitorStartCPUs(qemuMonitorPtr mon);
449
int qemuMonitorStopCPUs(qemuMonitorPtr mon);
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464

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,
465
    QEMU_MONITOR_VM_STATUS_GUEST_PANICKED,
466 467 468 469 470 471

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

472
int qemuMonitorCheck(qemuMonitorPtr mon);
473 474
int qemuMonitorGetStatus(qemuMonitorPtr mon,
                         bool *running,
475 476
                         virDomainPausedReason *reason)
    ATTRIBUTE_NONNULL(2);
477

478
int qemuMonitorSystemReset(qemuMonitorPtr mon);
479 480
int qemuMonitorSystemPowerdown(qemuMonitorPtr mon);

481
struct qemuMonitorQueryCpusEntry {
482
    int qemu_id; /* id of the cpu as reported by qemu */
483
    pid_t tid;
484
    char *qom_path;
485
    bool halted;
486 487 488 489
};
void qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
                              size_t nentries);

490

491 492 493 494 495 496 497 498 499 500 501
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;
502 503 504

    /* internal data */
    int enable_id;
505 506 507 508 509
};
void qemuMonitorQueryHotpluggableCpusFree(struct qemuMonitorQueryHotpluggableCpusEntry *entries,
                                          size_t nentries);


510 511
struct _qemuMonitorCPUInfo {
    pid_t tid;
512
    int id; /* order of enabling of the given cpu */
513
    int qemu_id; /* identifier of the cpu as reported by query-cpus */
514

515 516 517 518
    /* state data */
    bool online;
    bool hotpluggable;

519 520 521 522 523
    /* topology info for hotplug purposes. Hotplug of given vcpu impossible if
     * all entries are -1 */
    int socket_id;
    int core_id;
    int thread_id;
524
    int node_id;
525 526 527 528 529 530 531 532 533 534
    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;
535 536

    bool halted;
537 538 539 540 541 542
};
typedef struct _qemuMonitorCPUInfo qemuMonitorCPUInfo;
typedef qemuMonitorCPUInfo *qemuMonitorCPUInfoPtr;

void qemuMonitorCPUInfoFree(qemuMonitorCPUInfoPtr list,
                            size_t nitems);
543
int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
544
                          qemuMonitorCPUInfoPtr *vcpus,
545
                          size_t maxvcpus,
546 547 548 549 550
                          bool hotplug,
                          bool fast);
virBitmapPtr qemuMonitorGetCpuHalted(qemuMonitorPtr mon,
                                     size_t maxvcpus,
                                     bool fast);
551

552
int qemuMonitorGetVirtType(qemuMonitorPtr mon,
553
                           virDomainVirtType *virtType);
554
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
555
                              unsigned long long *currmem);
556
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
557
                              virDomainMemballoonDefPtr balloon,
558 559
                              virDomainMemoryStatPtr stats,
                              unsigned int nr_stats);
560
int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
561
                                    virDomainMemballoonDefPtr balloon,
562
                                    int period);
563

564
int qemuMonitorBlockIOStatusToError(const char *status);
565 566
virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon);

567
virJSONValuePtr qemuMonitorQueryBlockstats(qemuMonitorPtr mon);
568

569 570 571 572 573 574 575 576 577 578 579
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;
580 581
    unsigned long long capacity;
    unsigned long long physical;
582 583 584

    /* value of wr_highest_offset is valid if it's non 0 or
     * if wr_highest_offset_valid is true */
585
    unsigned long long wr_highest_offset;
586
    bool wr_highest_offset_valid;
587 588 589

    /* write_threshold is valid only if it's non-zero, conforming to qemu semantics */
    unsigned long long write_threshold;
590 591 592
};

int qemuMonitorGetAllBlockStatsInfo(qemuMonitorPtr mon,
593 594
                                    virHashTablePtr *ret_stats,
                                    bool backingChain)
595
    ATTRIBUTE_NONNULL(2);
596

597
int qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
598 599
                                        virHashTablePtr stats,
                                        bool backingChain)
600
    ATTRIBUTE_NONNULL(2);
601

602 603 604 605
int qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
                                                virHashTablePtr stats)
    ATTRIBUTE_NONNULL(2);

606
int qemuMonitorBlockResize(qemuMonitorPtr mon,
607 608
                           const char *device,
                           const char *nodename,
609
                           unsigned long long size);
610 611
int qemuMonitorSetVNCPassword(qemuMonitorPtr mon,
                              const char *password);
612 613 614 615 616 617 618
int qemuMonitorSetPassword(qemuMonitorPtr mon,
                           int type,
                           const char *password,
                           const char *action_if_connected);
int qemuMonitorExpirePassword(qemuMonitorPtr mon,
                              int type,
                              const char *expire_time);
619
int qemuMonitorSetBalloon(qemuMonitorPtr mon,
620
                          unsigned long long newmem);
621
int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, bool online);
622

623 624

/* XXX should we pass the virDomainDiskDefPtr instead
625
 * and hide dev_name details inside monitor. Reconsider
626 627 628
 * this when doing the QMP implementation
 */
int qemuMonitorEjectMedia(qemuMonitorPtr mon,
629
                          const char *dev_name,
630
                          bool force);
631
int qemuMonitorChangeMedia(qemuMonitorPtr mon,
632
                           const char *dev_name,
633 634
                           const char *newmedia,
                           const char *format);
635 636 637 638 639 640 641 642 643 644 645 646 647 648


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

649 650 651
int qemuMonitorSetMigrationDowntime(qemuMonitorPtr mon,
                                    unsigned long long downtime);

652 653 654 655 656
int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long *cacheSize);
int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long cacheSize);

657
int qemuMonitorGetMigrationParams(qemuMonitorPtr mon,
658
                                  virJSONValuePtr *params);
659
int qemuMonitorSetMigrationParams(qemuMonitorPtr mon,
660
                                  virJSONValuePtr params);
661

662
typedef enum {
663
    QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
664
    QEMU_MONITOR_MIGRATION_STATUS_SETUP,
665
    QEMU_MONITOR_MIGRATION_STATUS_ACTIVE,
666 667
    QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER,
    QEMU_MONITOR_MIGRATION_STATUS_DEVICE,
668
    QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY,
669 670
    QEMU_MONITOR_MIGRATION_STATUS_COMPLETED,
    QEMU_MONITOR_MIGRATION_STATUS_ERROR,
671
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLING,
672 673 674
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLED,

    QEMU_MONITOR_MIGRATION_STATUS_LAST
675
} qemuMonitorMigrationStatus;
676

677 678
VIR_ENUM_DECL(qemuMonitorMigrationStatus)

679 680 681
typedef struct _qemuMonitorMigrationStats qemuMonitorMigrationStats;
typedef qemuMonitorMigrationStats *qemuMonitorMigrationStatsPtr;
struct _qemuMonitorMigrationStats {
682
    int status; /* qemuMonitorMigrationStatus */
683 684 685 686
    unsigned long long total_time;
    /* total or expected depending on status */
    bool downtime_set;
    unsigned long long downtime;
687 688 689 690 691 692 693
    /*
     * 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;
694 695 696 697

    unsigned long long ram_transferred;
    unsigned long long ram_remaining;
    unsigned long long ram_total;
698
    unsigned long long ram_bps;
699 700 701 702
    bool ram_duplicate_set;
    unsigned long long ram_duplicate;
    unsigned long long ram_normal;
    unsigned long long ram_normal_bytes;
703
    unsigned long long ram_dirty_rate;
704
    unsigned long long ram_page_size;
705
    unsigned long long ram_iteration;
706 707 708 709

    unsigned long long disk_transferred;
    unsigned long long disk_remaining;
    unsigned long long disk_total;
710
    unsigned long long disk_bps;
711 712 713 714 715 716 717

    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;
718 719

    int cpu_throttle_percentage;
720 721
};

722
int qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
723 724
                                 qemuMonitorMigrationStatsPtr stats,
                                 char **error);
725

726 727
int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
                                        char ***capabilities);
728
int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
729
                                        virJSONValuePtr caps);
730

A
Andrea Bolognani 已提交
731 732 733
int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon,
                                  virGICCapability **capabilities);

734 735 736
int qemuMonitorGetSEVCapabilities(qemuMonitorPtr mon,
                                  virSEVCapability **capabilities);

737
typedef enum {
738
  QEMU_MONITOR_MIGRATE_BACKGROUND       = 1 << 0,
739 740 741 742 743
  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 已提交
744 745 746 747
int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
                           unsigned int flags,
                           int fd);

748
int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
749
                             unsigned int flags,
750
                             const char *protocol,
751 752 753 754 755
                             const char *hostname,
                             int port);

int qemuMonitorMigrateCancel(qemuMonitorPtr mon);

756 757 758
int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
                                            const char *capability);

759 760 761
int qemuMonitorQueryDump(qemuMonitorPtr mon,
                         qemuMonitorDumpStatsPtr stats);

762
int qemuMonitorDumpToFd(qemuMonitorPtr mon,
763
                        int fd,
764 765
                        const char *dumpformat,
                        bool detach);
766

767 768 769 770 771 772
int qemuMonitorGraphicsRelocate(qemuMonitorPtr mon,
                                int type,
                                const char *hostname,
                                int port,
                                int tlsPort,
                                const char *tlsSubject);
773 774 775 776

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

779 780
/* These two functions preserve previous error and only set their own
 * error if no error was set before.
781
 */
782 783
int qemuMonitorCloseFileHandle(qemuMonitorPtr mon,
                               const char *fdname);
784
int qemuMonitorRemoveFd(qemuMonitorPtr mon, int fdset, int fd);
785

786
int qemuMonitorAddNetdev(qemuMonitorPtr mon,
787
                         const char *netdevstr,
788 789
                         int *tapfd, char **tapfdName, int tapfdSize,
                         int *vhostfd, char **vhostfdName, int vhostfdSize);
790 791 792 793

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

794 795 796
int qemuMonitorQueryRxFilter(qemuMonitorPtr mon, const char *alias,
                             virNetDevRxFilterPtr *filter);

797 798 799 800 801 802
typedef struct _qemuMonitorChardevInfo qemuMonitorChardevInfo;
typedef qemuMonitorChardevInfo *qemuMonitorChardevInfoPtr;
struct _qemuMonitorChardevInfo {
    char *ptyPath;
    virDomainChrDeviceState state;
};
803
void qemuMonitorChardevInfoFree(void *data, const void *name);
804 805
int qemuMonitorGetChardevInfo(qemuMonitorPtr mon,
                              virHashTablePtr *retinfo);
806

807 808
int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
                                       const char *bus,
809
                                       virPCIDeviceAddress *guestAddr);
810

811 812
int qemuMonitorAddDeviceArgs(qemuMonitorPtr mon,
                             virJSONValuePtr args);
813 814 815
int qemuMonitorAddDevice(qemuMonitorPtr mon,
                         const char *devicestr);

816 817 818 819 820
int qemuMonitorAddDeviceWithFd(qemuMonitorPtr mon,
                               const char *devicestr,
                               int fd,
                               const char *fdname);

821
int qemuMonitorDelDevice(qemuMonitorPtr mon,
822
                         const char *devalias);
823

824 825 826 827 828 829 830 831 832 833 834
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,
835
                         char **alias)
836
    ATTRIBUTE_NONNULL(2);
837

838 839 840
int qemuMonitorDelObject(qemuMonitorPtr mon,
                         const char *objalias);

841 842 843
int qemuMonitorAddDrive(qemuMonitorPtr mon,
                        const char *drivestr);

844
int qemuMonitorDriveDel(qemuMonitorPtr mon,
845 846
                        const char *drivestr);

C
Chris Lalancette 已提交
847 848 849 850
int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);

851
int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions)
852
    ATTRIBUTE_NONNULL(2);
853 854 855 856
int qemuMonitorDriveMirror(qemuMonitorPtr mon,
                           const char *device,
                           const char *file,
                           const char *format,
857
                           unsigned long long bandwidth,
858 859
                           unsigned int granularity,
                           unsigned long long buf_size,
860
                           unsigned int flags)
861
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
862 863 864 865 866 867 868 869 870
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,
                              unsigned int flags)
    ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
871
int qemuMonitorDrivePivot(qemuMonitorPtr mon,
872
                          const char *jobname)
873
    ATTRIBUTE_NONNULL(2);
874

875 876 877 878
int qemuMonitorBlockCommit(qemuMonitorPtr mon,
                           const char *device,
                           const char *top,
                           const char *base,
879
                           const char *backingName,
880
                           unsigned long long bandwidth)
881
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
882
bool qemuMonitorSupportsActiveCommit(qemuMonitorPtr mon);
883 884 885 886
char *qemuMonitorDiskNameLookup(qemuMonitorPtr mon,
                                const char *device,
                                virStorageSourcePtr top,
                                virStorageSourcePtr target)
887
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
888

889 890 891 892
int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
                                const char *cmd,
                                char **reply,
                                bool hmp);
893

894 895
int qemuMonitorInjectNMI(qemuMonitorPtr mon);

896
int qemuMonitorScreendump(qemuMonitorPtr mon,
897 898
                          const char *device,
                          unsigned int head,
899 900
                          const char *file);

901 902 903 904 905
int qemuMonitorSendKey(qemuMonitorPtr mon,
                       unsigned int holdtime,
                       unsigned int *keycodes,
                       unsigned int nkeycodes);

906 907 908 909
int qemuMonitorBlockStream(qemuMonitorPtr mon,
                           const char *device,
                           const char *base,
                           const char *backingName,
910
                           unsigned long long bandwidth)
911
    ATTRIBUTE_NONNULL(2);
912

913
int qemuMonitorBlockJobCancel(qemuMonitorPtr mon,
914
                              const char *jobname)
915
    ATTRIBUTE_NONNULL(2);
916

917
int qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,
918
                                const char *jobname,
919
                                unsigned long long bandwidth);
920

921 922 923 924 925 926 927
typedef struct _qemuMonitorBlockJobInfo qemuMonitorBlockJobInfo;
typedef qemuMonitorBlockJobInfo *qemuMonitorBlockJobInfoPtr;
struct _qemuMonitorBlockJobInfo {
    int type; /* virDomainBlockJobType */
    unsigned long long bandwidth; /* in bytes/s */
    virDomainBlockJobCursor cur;
    virDomainBlockJobCursor end;
928
    int ready; /* -1 if unknown, 0 if not ready, 1 if ready */
929 930 931 932 933 934
};

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

937 938 939 940 941 942
int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                            const char *protocol,
                            int fd,
                            const char *fdname,
                            bool skipauth);

943
int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
944 945
                                  const char *drivealias,
                                  const char *qomid,
946
                                  virDomainBlockIoTuneInfoPtr info,
947
                                  bool supportMaxOptions,
948
                                  bool supportGroupNameOption,
949
                                  bool supportMaxLengthOptions);
950 951

int qemuMonitorGetBlockIoThrottle(qemuMonitorPtr mon,
952 953
                                  const char *drivealias,
                                  const char *qdevid,
954
                                  virDomainBlockIoTuneInfoPtr reply);
955

956 957
int qemuMonitorSystemWakeup(qemuMonitorPtr mon);

958 959 960 961 962 963 964
int qemuMonitorGetVersion(qemuMonitorPtr mon,
                          int *major,
                          int *minor,
                          int *micro,
                          char **package)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

965 966 967 968 969 970 971 972

typedef struct _qemuMonitorMachineInfo qemuMonitorMachineInfo;
typedef qemuMonitorMachineInfo *qemuMonitorMachineInfoPtr;

struct _qemuMonitorMachineInfo {
    char *name;
    bool isDefault;
    char *alias;
973
    unsigned int maxCpus;
974
    bool hotplugCpus;
975 976 977 978 979 980 981
};

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

void qemuMonitorMachineInfoFree(qemuMonitorMachineInfoPtr machine);

982 983 984 985
typedef struct _qemuMonitorCPUDefInfo qemuMonitorCPUDefInfo;
typedef qemuMonitorCPUDefInfo *qemuMonitorCPUDefInfoPtr;

struct _qemuMonitorCPUDefInfo {
986
    virTristateBool usable;
987
    char *name;
988
    char **blockers; /* NULL-terminated string list */
989 990
};

991
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
992 993
                                 qemuMonitorCPUDefInfoPtr **cpus);
void qemuMonitorCPUDefInfoFree(qemuMonitorCPUDefInfoPtr cpu);
994

995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
typedef enum {
    QEMU_MONITOR_CPU_PROPERTY_BOOLEAN,
    QEMU_MONITOR_CPU_PROPERTY_STRING,
    QEMU_MONITOR_CPU_PROPERTY_NUMBER,

    QEMU_MONITOR_CPU_PROPERTY_LAST
} qemuMonitorCPUPropertyType;

VIR_ENUM_DECL(qemuMonitorCPUProperty)

typedef struct _qemuMonitorCPUProperty qemuMonitorCPUProperty;
typedef qemuMonitorCPUProperty *qemuMonitorCPUPropertyPtr;
struct _qemuMonitorCPUProperty {
    char *name;
    qemuMonitorCPUPropertyType type;
    union {
        bool boolean;
        char *string;
        long long number;
    } value;
1015
    virTristateBool migratable;
1016 1017
};

1018 1019 1020 1021 1022 1023
typedef struct _qemuMonitorCPUModelInfo qemuMonitorCPUModelInfo;
typedef qemuMonitorCPUModelInfo *qemuMonitorCPUModelInfoPtr;

struct _qemuMonitorCPUModelInfo {
    char *name;
    size_t nprops;
1024
    qemuMonitorCPUPropertyPtr props;
1025
    bool migratability;
1026 1027
};

1028 1029
typedef enum {
    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
1030 1031
    QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL,
    QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
1032 1033
} qemuMonitorCPUModelExpansionType;

1034
int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
1035
                                    qemuMonitorCPUModelExpansionType type,
1036
                                    const char *model_name,
1037
                                    bool migratable,
1038 1039 1040 1041 1042 1043 1044
                                    qemuMonitorCPUModelInfoPtr *model_info);

void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info);

qemuMonitorCPUModelInfoPtr
qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);

1045 1046
int qemuMonitorGetCommands(qemuMonitorPtr mon,
                           char ***commands);
1047 1048
int qemuMonitorGetEvents(qemuMonitorPtr mon,
                         char ***events);
1049 1050
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                              const char *option,
1051 1052
                                              char ***params,
                                              bool *found);
1053

1054 1055 1056 1057
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
                           bool *enabled,
                           bool *present);

1058 1059
int qemuMonitorGetObjectTypes(qemuMonitorPtr mon,
                              char ***types);
1060 1061
int qemuMonitorGetDeviceProps(qemuMonitorPtr mon,
                              const char *device,
1062
                              char ***props);
1063 1064 1065
int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
                              const char *object,
                              char ***props);
1066
char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
1067

1068 1069
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
                              const char *host,
1070 1071
                              unsigned int port,
                              const char *tls_alias);
1072 1073 1074
int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
                            const char *deviceID,
                            bool writable);
1075
int qemuMonitorNBDServerStop(qemuMonitorPtr);
S
Stefan Berger 已提交
1076 1077 1078 1079 1080 1081
int qemuMonitorGetTPMModels(qemuMonitorPtr mon,
                            char ***tpmmodels);

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

1082 1083 1084
int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
                             const char *chrID,
                             virDomainChrSourceDefPtr chr);
1085 1086
int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
                             const char *chrID);
1087 1088 1089 1090

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

1091 1092 1093
typedef void (*qemuMonitorReportDomainLogError)(qemuMonitorPtr mon,
                                                const char *msg,
                                                void *opaque);
1094 1095 1096 1097
void qemuMonitorSetDomainLogLocked(qemuMonitorPtr mon,
                                   qemuMonitorReportDomainLogError func,
                                   void *opaque,
                                   virFreeCallback destroy);
1098 1099 1100 1101
void qemuMonitorSetDomainLog(qemuMonitorPtr mon,
                             qemuMonitorReportDomainLogError func,
                             void *opaque,
                             virFreeCallback destroy);
1102

1103 1104
int qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
                           virArch arch,
1105 1106
                           virCPUDataPtr *data,
                           virCPUDataPtr *disabled);
1107

1108 1109
int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon);

1110 1111
typedef struct _qemuMonitorIOThreadInfo qemuMonitorIOThreadInfo;
typedef qemuMonitorIOThreadInfo *qemuMonitorIOThreadInfoPtr;
1112

1113
struct _qemuMonitorIOThreadInfo {
1114
    unsigned int iothread_id;
1115
    int thread_id;
1116 1117 1118 1119
    bool poll_valid;
    unsigned long long poll_max_ns;
    unsigned int poll_grow;
    unsigned int poll_shrink;
1120 1121 1122
    bool set_poll_max_ns;
    bool set_poll_grow;
    bool set_poll_shrink;
1123 1124
};
int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
1125
                            qemuMonitorIOThreadInfoPtr **iothreads);
1126 1127
int qemuMonitorSetIOThread(qemuMonitorPtr mon,
                           qemuMonitorIOThreadInfoPtr iothreadInfo);
1128

1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142
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);

1143 1144 1145
int qemuMonitorMigrateIncoming(qemuMonitorPtr mon,
                               const char *uri);

1146 1147
int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon);

1148 1149 1150
int qemuMonitorMigrateContinue(qemuMonitorPtr mon,
                               qemuMonitorMigrationStatus status);

1151 1152 1153
int qemuMonitorGetRTCTime(qemuMonitorPtr mon,
                          struct tm *tm);

1154
virJSONValuePtr qemuMonitorQueryQMPSchema(qemuMonitorPtr mon);
1155

1156 1157 1158 1159
int qemuMonitorSetBlockThreshold(qemuMonitorPtr mon,
                                 const char *nodename,
                                 unsigned long long threshold);

1160
virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon);
1161

M
Michal Privoznik 已提交
1162 1163
int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon,
                                 const char *action);
1164 1165 1166 1167 1168 1169 1170

int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
                           virJSONValuePtr props);

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

1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184
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);

1185 1186 1187
char *
qemuMonitorGetSEVMeasurement(qemuMonitorPtr mon);

1188 1189 1190 1191 1192 1193 1194 1195 1196
typedef struct _qemuMonitorPRManagerInfo qemuMonitorPRManagerInfo;
typedef qemuMonitorPRManagerInfo *qemuMonitorPRManagerInfoPtr;
struct _qemuMonitorPRManagerInfo {
    bool connected;
};

int qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon,
                                virHashTablePtr *retinfo);

1197
#endif /* LIBVIRT_QEMU_MONITOR_H */