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


#ifndef QEMU_MONITOR_H
26
# define QEMU_MONITOR_H
27

28
# include "internal.h"
29

30
# include "domain_conf.h"
31
# include "virbitmap.h"
32
# include "virhash.h"
33
# include "virjson.h"
34
# include "device_conf.h"
35
# include "cpu/cpu.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;
};

J
Jiri Denemark 已提交
71 72

typedef void (*qemuMonitorDestroyCallback)(qemuMonitorPtr mon,
73 74
                                           virDomainObjPtr vm,
                                           void *opaque);
J
Jiri Denemark 已提交
75
typedef void (*qemuMonitorEofNotifyCallback)(qemuMonitorPtr mon,
76 77
                                             virDomainObjPtr vm,
                                             void *opaque);
J
Jiri Denemark 已提交
78
typedef void (*qemuMonitorErrorNotifyCallback)(qemuMonitorPtr mon,
79 80
                                               virDomainObjPtr vm,
                                               void *opaque);
J
Jiri Denemark 已提交
81 82 83 84 85 86 87 88 89 90
/* XXX we'd really like to avoid virConnectPtr here
 * It is required so the callback can find the active
 * secret driver. Need to change this to work like the
 * security drivers do, to avoid this
 */
typedef int (*qemuMonitorDiskSecretLookupCallback)(qemuMonitorPtr mon,
                                                   virConnectPtr conn,
                                                   virDomainObjPtr vm,
                                                   const char *path,
                                                   char **secret,
91 92
                                                   size_t *secretLen,
                                                   void *opaque);
J
Jiri Denemark 已提交
93
typedef int (*qemuMonitorDomainShutdownCallback)(qemuMonitorPtr mon,
94 95
                                                 virDomainObjPtr vm,
                                                 void *opaque);
J
Jiri Denemark 已提交
96
typedef int (*qemuMonitorDomainResetCallback)(qemuMonitorPtr mon,
97 98
                                              virDomainObjPtr vm,
                                              void *opaque);
J
Jiri Denemark 已提交
99
typedef int (*qemuMonitorDomainPowerdownCallback)(qemuMonitorPtr mon,
100 101
                                                  virDomainObjPtr vm,
                                                  void *opaque);
J
Jiri Denemark 已提交
102
typedef int (*qemuMonitorDomainStopCallback)(qemuMonitorPtr mon,
103 104
                                             virDomainObjPtr vm,
                                             void *opaque);
J
Jiri Denemark 已提交
105
typedef int (*qemuMonitorDomainResumeCallback)(qemuMonitorPtr mon,
106 107
                                               virDomainObjPtr vm,
                                               void *opaque);
J
Jiri Denemark 已提交
108 109
typedef int (*qemuMonitorDomainRTCChangeCallback)(qemuMonitorPtr mon,
                                                  virDomainObjPtr vm,
110 111
                                                  long long offset,
                                                  void *opaque);
J
Jiri Denemark 已提交
112 113
typedef int (*qemuMonitorDomainWatchdogCallback)(qemuMonitorPtr mon,
                                                 virDomainObjPtr vm,
114 115
                                                 int action,
                                                 void *opaque);
J
Jiri Denemark 已提交
116 117 118 119
typedef int (*qemuMonitorDomainIOErrorCallback)(qemuMonitorPtr mon,
                                                virDomainObjPtr vm,
                                                const char *diskAlias,
                                                int action,
120 121
                                                const char *reason,
                                                void *opaque);
J
Jiri Denemark 已提交
122 123 124 125 126 127 128 129 130 131 132
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,
133 134
                                                 const char *saslUsername,
                                                 void *opaque);
J
Jiri Denemark 已提交
135 136 137 138
typedef int (*qemuMonitorDomainBlockJobCallback)(qemuMonitorPtr mon,
                                                 virDomainObjPtr vm,
                                                 const char *diskAlias,
                                                 int type,
139 140
                                                 int status,
                                                 void *opaque);
J
Jiri Denemark 已提交
141 142 143
typedef int (*qemuMonitorDomainTrayChangeCallback)(qemuMonitorPtr mon,
                                                   virDomainObjPtr vm,
                                                   const char *devAlias,
144 145
                                                   int reason,
                                                   void *opaque);
J
Jiri Denemark 已提交
146
typedef int (*qemuMonitorDomainPMWakeupCallback)(qemuMonitorPtr mon,
147 148
                                                 virDomainObjPtr vm,
                                                 void *opaque);
J
Jiri Denemark 已提交
149
typedef int (*qemuMonitorDomainPMSuspendCallback)(qemuMonitorPtr mon,
150 151
                                                  virDomainObjPtr vm,
                                                  void *opaque);
J
Jiri Denemark 已提交
152 153
typedef int (*qemuMonitorDomainBalloonChangeCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
154 155
                                                      unsigned long long actual,
                                                      void *opaque);
J
Jiri Denemark 已提交
156
typedef int (*qemuMonitorDomainPMSuspendDiskCallback)(qemuMonitorPtr mon,
157 158
                                                      virDomainObjPtr vm,
                                                      void *opaque);
J
Jiri Denemark 已提交
159
typedef int (*qemuMonitorDomainGuestPanicCallback)(qemuMonitorPtr mon,
160 161
                                                   virDomainObjPtr vm,
                                                   void *opaque);
J
Jiri Denemark 已提交
162 163
typedef int (*qemuMonitorDomainDeviceDeletedCallback)(qemuMonitorPtr mon,
                                                      virDomainObjPtr vm,
164 165
                                                      const char *devAlias,
                                                      void *opaque);
J
Jiri Denemark 已提交
166

167 168 169
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
struct _qemuMonitorCallbacks {
J
Jiri Denemark 已提交
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
    qemuMonitorDestroyCallback destroy;
    qemuMonitorEofNotifyCallback eofNotify;
    qemuMonitorErrorNotifyCallback errorNotify;
    qemuMonitorDiskSecretLookupCallback diskSecretLookup;
    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;
191 192
};

193
char *qemuMonitorEscapeArg(const char *in);
194
char *qemuMonitorUnescapeArg(const char *in);
195

196
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
197
                               virDomainChrSourceDefPtr config,
E
Eric Blake 已提交
198
                               bool json,
199 200
                               qemuMonitorCallbacksPtr cb,
                               void *opaque)
201
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
202 203
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
                                 int sockfd,
E
Eric Blake 已提交
204
                                 bool json,
205 206
                                 qemuMonitorCallbacksPtr cb,
                                 void *opaque)
207
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
208

209
void qemuMonitorClose(qemuMonitorPtr mon);
210

211
int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
212

213 214
int qemuMonitorSetLink(qemuMonitorPtr mon,
                       const char *name,
215
                       enum virDomainNetInterfaceLinkState state);
216

217
/* These APIs are for use by the internal Text/JSON monitor impl code only */
218
char *qemuMonitorNextCommandID(qemuMonitorPtr mon);
219 220
int qemuMonitorSend(qemuMonitorPtr mon,
                    qemuMonitorMessagePtr msg);
221 222 223 224
virJSONValuePtr qemuMonitorGetOptions(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
void qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options)
    ATTRIBUTE_NONNULL(1);
225 226 227 228 229 230
int qemuMonitorHMPCommandWithFd(qemuMonitorPtr mon,
                                const char *cmd,
                                int scm_fd,
                                char **reply);
# define qemuMonitorHMPCommand(mon, cmd, reply) \
    qemuMonitorHMPCommandWithFd(mon, cmd, -1, reply)
231

232
/* XXX same comment about virConnectPtr as above */
233 234 235 236 237
int qemuMonitorGetDiskSecret(qemuMonitorPtr mon,
                             virConnectPtr conn,
                             const char *path,
                             char **secret,
                             size_t *secretLen);
238

239 240 241 242
int qemuMonitorEmitShutdown(qemuMonitorPtr mon);
int qemuMonitorEmitReset(qemuMonitorPtr mon);
int qemuMonitorEmitPowerdown(qemuMonitorPtr mon);
int qemuMonitorEmitStop(qemuMonitorPtr mon);
243
int qemuMonitorEmitResume(qemuMonitorPtr mon);
244
int qemuMonitorEmitRTCChange(qemuMonitorPtr mon, long long offset);
245
int qemuMonitorEmitWatchdog(qemuMonitorPtr mon, int action);
246 247
int qemuMonitorEmitIOError(qemuMonitorPtr mon,
                           const char *diskAlias,
248 249
                           int action,
                           const char *reason);
250 251 252 253 254 255 256 257 258 259 260
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);
261 262 263
int qemuMonitorEmitTrayChange(qemuMonitorPtr mon,
                              const char *devAlias,
                              int reason);
O
Osier Yang 已提交
264
int qemuMonitorEmitPMWakeup(qemuMonitorPtr mon);
O
Osier Yang 已提交
265
int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon);
266 267 268 269
int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
                            const char *diskAlias,
                            int type,
                            int status);
270 271
int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
                                 unsigned long long actual);
272
int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
273
int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon);
274 275
int qemuMonitorEmitDeviceDeleted(qemuMonitorPtr mon,
                                 const char *devAlias);
276

277 278 279
int qemuMonitorStartCPUs(qemuMonitorPtr mon,
                         virConnectPtr conn);
int qemuMonitorStopCPUs(qemuMonitorPtr mon);
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294

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,
295
    QEMU_MONITOR_VM_STATUS_GUEST_PANICKED,
296 297 298 299 300 301 302 303 304

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

int qemuMonitorGetStatus(qemuMonitorPtr mon,
                         bool *running,
                         virDomainPausedReason *reason);
305

306
int qemuMonitorSystemReset(qemuMonitorPtr mon);
307 308 309 310
int qemuMonitorSystemPowerdown(qemuMonitorPtr mon);

int qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
                          int **pids);
311 312
int qemuMonitorGetVirtType(qemuMonitorPtr mon,
                           int *virtType);
313
int qemuMonitorGetBalloonInfo(qemuMonitorPtr mon,
314
                              unsigned long long *currmem);
315 316 317
int qemuMonitorGetMemoryStats(qemuMonitorPtr mon,
                              virDomainMemoryStatPtr stats,
                              unsigned int nr_stats);
318 319
int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
                                    int period);
320

321
int qemuMonitorBlockIOStatusToError(const char *status);
322 323 324 325 326
virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon);
struct qemuDomainDiskInfo *
qemuMonitorBlockInfoLookup(virHashTablePtr blockInfo,
                           const char *devname);

327
int qemuMonitorGetBlockStatsInfo(qemuMonitorPtr mon,
328
                                 const char *dev_name,
329 330
                                 long long *rd_req,
                                 long long *rd_bytes,
331
                                 long long *rd_total_times,
332 333
                                 long long *wr_req,
                                 long long *wr_bytes,
334 335 336
                                 long long *wr_total_times,
                                 long long *flush_req,
                                 long long *flush_total_times,
337
                                 long long *errs);
338 339
int qemuMonitorGetBlockStatsParamsNumber(qemuMonitorPtr mon,
                                         int *nparams);
340

341
int qemuMonitorGetBlockExtent(qemuMonitorPtr mon,
342
                              const char *dev_name,
343
                              unsigned long long *extent);
344 345 346
int qemuMonitorBlockResize(qemuMonitorPtr mon,
                           const char *devname,
                           unsigned long long size);
347 348
int qemuMonitorSetVNCPassword(qemuMonitorPtr mon,
                              const char *password);
349 350 351 352 353 354 355
int qemuMonitorSetPassword(qemuMonitorPtr mon,
                           int type,
                           const char *password,
                           const char *action_if_connected);
int qemuMonitorExpirePassword(qemuMonitorPtr mon,
                              int type,
                              const char *expire_time);
356 357
int qemuMonitorSetBalloon(qemuMonitorPtr mon,
                          unsigned long newmem);
358
int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, bool online);
359

360 361 362 363 364 365

/* XXX should we pass the virDomainDiskDefPtr instead
 * and hide devname details inside monitor. Reconsider
 * this when doing the QMP implementation
 */
int qemuMonitorEjectMedia(qemuMonitorPtr mon,
366
                          const char *dev_name,
367
                          bool force);
368
int qemuMonitorChangeMedia(qemuMonitorPtr mon,
369
                           const char *dev_name,
370 371
                           const char *newmedia,
                           const char *format);
372 373 374 375 376 377 378 379 380 381 382 383 384 385


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

386 387 388
int qemuMonitorSetMigrationDowntime(qemuMonitorPtr mon,
                                    unsigned long long downtime);

389 390 391 392 393
int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long *cacheSize);
int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
                                     unsigned long long cacheSize);

394 395 396 397 398 399 400 401 402 403
enum {
    QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
    QEMU_MONITOR_MIGRATION_STATUS_ACTIVE,
    QEMU_MONITOR_MIGRATION_STATUS_COMPLETED,
    QEMU_MONITOR_MIGRATION_STATUS_ERROR,
    QEMU_MONITOR_MIGRATION_STATUS_CANCELLED,

    QEMU_MONITOR_MIGRATION_STATUS_LAST
};

404 405
VIR_ENUM_DECL(qemuMonitorMigrationStatus)

406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
typedef struct _qemuMonitorMigrationStatus qemuMonitorMigrationStatus;
typedef qemuMonitorMigrationStatus *qemuMonitorMigrationStatusPtr;
struct _qemuMonitorMigrationStatus {
    int status;
    unsigned long long total_time;
    /* total or expected depending on status */
    bool downtime_set;
    unsigned long long downtime;

    unsigned long long ram_transferred;
    unsigned long long ram_remaining;
    unsigned long long ram_total;
    bool ram_duplicate_set;
    unsigned long long ram_duplicate;
    unsigned long long ram_normal;
    unsigned long long ram_normal_bytes;

    unsigned long long disk_transferred;
    unsigned long long disk_remaining;
    unsigned long long disk_total;

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

435
int qemuMonitorGetMigrationStatus(qemuMonitorPtr mon,
436
                                  qemuMonitorMigrationStatusPtr status);
437 438
int qemuMonitorGetSpiceMigrationStatus(qemuMonitorPtr mon,
                                       bool *spice_migrated);
439

440 441 442 443 444 445 446 447 448 449 450 451 452
typedef enum {
    QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,

    QEMU_MONITOR_MIGRATION_CAPS_LAST
} qemuMonitorMigrationCaps;

VIR_ENUM_DECL(qemuMonitorMigrationCaps);

int qemuMonitorGetMigrationCapability(qemuMonitorPtr mon,
                                      qemuMonitorMigrationCaps capability);
int qemuMonitorSetMigrationCapability(qemuMonitorPtr mon,
                                      qemuMonitorMigrationCaps capability);

453
typedef enum {
E
Eric Blake 已提交
454
  QEMU_MONITOR_MIGRATE_BACKGROUND	= 1 << 0,
455 456 457 458 459
  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 已提交
460 461 462 463
int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
                           unsigned int flags,
                           int fd);

464
int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
465
                             unsigned int flags,
466 467 468 469
                             const char *hostname,
                             int port);

int qemuMonitorMigrateToCommand(qemuMonitorPtr mon,
470
                                unsigned int flags,
471 472
                                const char * const *argv);

473 474 475 476 477 478 479
/* In general, BS is the smallest fundamental block size we can use to
 * access a block device; everything must be aligned to a multiple of
 * this.  Linux generally supports a BS as small as 512, but with
 * newer disks with 4k sectors, performance is better if we guarantee
 * alignment to the sector size.  However, operating on BS-sized
 * blocks is painfully slow, so we also have a transfer size that is
 * larger but only aligned to the smaller block size.
480
 */
481 482
# define QEMU_MONITOR_MIGRATE_TO_FILE_BS (1024llu * 4)
# define QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE (1024llu * 1024)
483 484

int qemuMonitorMigrateToFile(qemuMonitorPtr mon,
485
                             unsigned int flags,
486 487 488
                             const char * const *argv,
                             const char *target,
                             unsigned long long offset);
489 490

int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
491
                             unsigned int flags,
492 493 494 495
                             const char *unixfile);

int qemuMonitorMigrateCancel(qemuMonitorPtr mon);

496
int qemuMonitorDumpToFd(qemuMonitorPtr mon,
497
                        int fd);
498

499 500 501 502 503 504
int qemuMonitorGraphicsRelocate(qemuMonitorPtr mon,
                                int type,
                                const char *hostname,
                                int port,
                                int tlsPort,
                                const char *tlsSubject);
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520

/* XXX disk driver type eg,  qcow/etc.
 * XXX cache mode
 */
int qemuMonitorAddUSBDisk(qemuMonitorPtr mon,
                          const char *path);

int qemuMonitorAddUSBDeviceExact(qemuMonitorPtr mon,
                                 int bus,
                                 int dev);
int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon,
                                 int vendor,
                                 int product);


int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
521 522
                                virDevicePCIAddress *hostAddr,
                                virDevicePCIAddress *guestAddr);
523 524 525 526 527 528 529

/* XXX disk driver type eg,  qcow/etc.
 * XXX cache mode
 */
int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
                          const char *path,
                          const char *bus,
530
                          virDevicePCIAddress *guestAddr);
531 532 533 534 535 536

/* XXX do we really want to hardcode 'nicstr' as the
 * sendable item here
 */
int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
                             const char *nicstr,
537
                             virDevicePCIAddress *guestAddr);
538 539

int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
540
                               virDevicePCIAddress *guestAddr);
541 542 543 544 545


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

548 549
/* These two functions preserve previous error and only set their own
 * error if no error was set before.
550
 */
551 552
int qemuMonitorCloseFileHandle(qemuMonitorPtr mon,
                               const char *fdname);
553
int qemuMonitorRemoveFd(qemuMonitorPtr mon, int fdset, int fd);
554 555 556 557 558

/* XXX do we really want to hardcode 'netstr' as the
 * sendable item here
 */
int qemuMonitorAddHostNetwork(qemuMonitorPtr mon,
559
                              const char *netstr,
560 561
                              int *tapfd, char **tapfdName, int tapfdSize,
                              int *vhostfd, char **vhostfdName, int vhostfdSize);
562 563 564 565 566

int qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
                                 int vlan,
                                 const char *netname);

567
int qemuMonitorAddNetdev(qemuMonitorPtr mon,
568
                         const char *netdevstr,
569 570
                         int *tapfd, char **tapfdName, int tapfdSize,
                         int *vhostfd, char **vhostfdName, int vhostfdSize);
571 572 573 574

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

575 576
int qemuMonitorGetPtyPaths(qemuMonitorPtr mon,
                           virHashTablePtr paths);
577

578 579
int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
                                       const char *bus,
580
                                       virDevicePCIAddress *guestAddr);
581

582 583
int qemuMonitorAttachDrive(qemuMonitorPtr mon,
                           const char *drivestr,
584
                           virDevicePCIAddress *controllerAddr,
585 586
                           virDomainDeviceDriveAddress *driveAddr);

587 588 589 590 591

typedef struct _qemuMonitorPCIAddress qemuMonitorPCIAddress;
struct _qemuMonitorPCIAddress {
    unsigned int vendor;
    unsigned int product;
592
    virDevicePCIAddress addr;
593 594 595 596 597
};

int qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon,
                                  qemuMonitorPCIAddress **addrs);

598 599 600
int qemuMonitorAddDevice(qemuMonitorPtr mon,
                         const char *devicestr);

601 602 603 604 605
int qemuMonitorAddDeviceWithFd(qemuMonitorPtr mon,
                               const char *devicestr,
                               int fd,
                               const char *fdname);

606
int qemuMonitorDelDevice(qemuMonitorPtr mon,
607
                         const char *devalias);
608

609 610 611
int qemuMonitorAddDrive(qemuMonitorPtr mon,
                        const char *drivestr);

612
int qemuMonitorDriveDel(qemuMonitorPtr mon,
613 614
                        const char *drivestr);

615 616 617 618
int qemuMonitorSetDrivePassphrase(qemuMonitorPtr mon,
                                  const char *alias,
                                  const char *passphrase);

C
Chris Lalancette 已提交
619 620 621 622
int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);

623
int qemuMonitorDiskSnapshot(qemuMonitorPtr mon,
624
                            virJSONValuePtr actions,
625
                            const char *device,
626 627 628
                            const char *file,
                            const char *format,
                            bool reuse);
629 630
int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr actions)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
631 632 633 634 635 636 637 638 639 640 641 642
int qemuMonitorDriveMirror(qemuMonitorPtr mon,
                           const char *device,
                           const char *file,
                           const char *format,
                           unsigned long bandwidth,
                           unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorDrivePivot(qemuMonitorPtr mon,
                          const char *device,
                          const char *file,
                          const char *format)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
643

644 645 646 647 648 649 650
int qemuMonitorBlockCommit(qemuMonitorPtr mon,
                           const char *device,
                           const char *top,
                           const char *base,
                           unsigned long bandwidth)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

651 652 653 654
int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
                                const char *cmd,
                                char **reply,
                                bool hmp);
655

656 657
int qemuMonitorInjectNMI(qemuMonitorPtr mon);

658 659 660
int qemuMonitorScreendump(qemuMonitorPtr mon,
                          const char *file);

661 662 663 664 665
int qemuMonitorSendKey(qemuMonitorPtr mon,
                       unsigned int holdtime,
                       unsigned int *keycodes,
                       unsigned int nkeycodes);

666
typedef enum {
667 668 669 670 671
    BLOCK_JOB_ABORT,
    BLOCK_JOB_INFO,
    BLOCK_JOB_SPEED,
    BLOCK_JOB_PULL,
} qemuMonitorBlockJobCmd;
672 673 674

int qemuMonitorBlockJob(qemuMonitorPtr mon,
                        const char *device,
675
                        const char *back,
676 677
                        unsigned long bandwidth,
                        virDomainBlockJobInfoPtr info,
678 679
                        qemuMonitorBlockJobCmd mode,
                        bool modern)
680
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
681

682 683 684 685 686 687
int qemuMonitorOpenGraphics(qemuMonitorPtr mon,
                            const char *protocol,
                            int fd,
                            const char *fdname,
                            bool skipauth);

688 689 690 691 692 693 694 695
int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon,
                                  const char *device,
                                  virDomainBlockIoTuneInfoPtr info);

int qemuMonitorGetBlockIoThrottle(qemuMonitorPtr mon,
                                  const char *device,
                                  virDomainBlockIoTuneInfoPtr reply);

696 697
int qemuMonitorSystemWakeup(qemuMonitorPtr mon);

698 699 700 701 702 703 704
int qemuMonitorGetVersion(qemuMonitorPtr mon,
                          int *major,
                          int *minor,
                          int *micro,
                          char **package)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

705 706 707 708 709 710 711 712

typedef struct _qemuMonitorMachineInfo qemuMonitorMachineInfo;
typedef qemuMonitorMachineInfo *qemuMonitorMachineInfoPtr;

struct _qemuMonitorMachineInfo {
    char *name;
    bool isDefault;
    char *alias;
713
    unsigned int maxCpus;
714 715 716 717 718 719 720
};

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

void qemuMonitorMachineInfoFree(qemuMonitorMachineInfoPtr machine);

721 722 723
int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
                                 char ***cpus);

724 725
int qemuMonitorGetCommands(qemuMonitorPtr mon,
                           char ***commands);
726 727
int qemuMonitorGetEvents(qemuMonitorPtr mon,
                         char ***events);
728 729 730
int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                              const char *option,
                                              char ***params);
731

732 733 734 735
int qemuMonitorGetKVMState(qemuMonitorPtr mon,
                           bool *enabled,
                           bool *present);

736 737
int qemuMonitorGetObjectTypes(qemuMonitorPtr mon,
                              char ***types);
738 739 740
int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
                              const char *type,
                              char ***props);
741
char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
742

743 744 745
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
                              const char *host,
                              unsigned int port);
746 747 748
int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
                            const char *deviceID,
                            bool writable);
749
int qemuMonitorNBDServerStop(qemuMonitorPtr);
S
Stefan Berger 已提交
750 751 752 753 754 755
int qemuMonitorGetTPMModels(qemuMonitorPtr mon,
                            char ***tpmmodels);

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

756 757 758
int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
                             const char *chrID,
                             virDomainChrSourceDefPtr chr);
759 760
int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
                             const char *chrID);
761 762 763 764

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

765 766
int qemuMonitorSetDomainLog(qemuMonitorPtr mon, int logfd);

767 768 769
int qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
                           virArch arch,
                           virCPUDataPtr *data);
770

771 772 773 774 775 776 777 778 779 780 781 782 783
/**
 * When running two dd process and using <> redirection, we need a
 * shell that will not truncate files.  These two strings serve that
 * purpose.
 */
# ifdef VIR_WRAPPER_SHELL
#  define VIR_WRAPPER_SHELL_PREFIX VIR_WRAPPER_SHELL " -c '"
#  define VIR_WRAPPER_SHELL_SUFFIX "'"
# else
#  define VIR_WRAPPER_SHELL_PREFIX /* nothing */
#  define VIR_WRAPPER_SHELL_SUFFIX /* nothing */
# endif

784
#endif /* QEMU_MONITOR_H */