qemu_monitor_json.h 20.6 KB
Newer Older
D
Daniel P. Berrange 已提交
1 2 3
/*
 * qemu_monitor_json.h: interaction with QEMU monitor console
 *
4
 * Copyright (C) 2006-2009, 2011-2015 Red Hat, Inc.
D
Daniel P. Berrange 已提交
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/>.
D
Daniel P. Berrange 已提交
20 21 22 23 24 25
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */


#ifndef QEMU_MONITOR_JSON_H
26
# define QEMU_MONITOR_JSON_H
D
Daniel P. Berrange 已提交
27

28
# include "internal.h"
D
Daniel P. Berrange 已提交
29

30
# include "qemu_monitor.h"
31
# include "virbitmap.h"
32
# include "cpu/cpu.h"
A
Andrea Bolognani 已提交
33
# include "util/virgic.h"
D
Daniel P. Berrange 已提交
34

35 36 37 38
int qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
                                 const char *line,
                                 qemuMonitorMessagePtr msg);

D
Daniel P. Berrange 已提交
39 40 41 42 43
int qemuMonitorJSONIOProcess(qemuMonitorPtr mon,
                             const char *data,
                             size_t len,
                             qemuMonitorMessagePtr msg);

44 45 46 47 48
int qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
                                      const char *cmd,
                                      int scm_fd,
                                      char **reply);

49 50
int qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon);

D
Daniel P. Berrange 已提交
51 52 53
int qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
                             virConnectPtr conn);
int qemuMonitorJSONStopCPUs(qemuMonitorPtr mon);
54 55 56
int qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
                             bool *running,
                             virDomainPausedReason *reason);
D
Daniel P. Berrange 已提交
57 58

int qemuMonitorJSONSystemPowerdown(qemuMonitorPtr mon);
59
int qemuMonitorJSONSystemReset(qemuMonitorPtr mon);
D
Daniel P. Berrange 已提交
60

61 62
int qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
                             int **pids);
63
int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
64
                               virDomainVirtType *virtType);
65 66 67
int qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
                                         virDomainVideoDefPtr video,
                                         char *path);
68 69 70
int qemuMonitorJSONUpdateVideoVram64Size(qemuMonitorPtr mon,
                                         virDomainVideoDefPtr video,
                                         char *path);
D
Daniel P. Berrange 已提交
71
int qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
72
                                  unsigned long long *currmem);
73
int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
74
                                  char *balloonpath,
75 76
                                  virDomainMemoryStatPtr stats,
                                  unsigned int nr_stats);
77 78 79
int qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitorPtr mon,
                                        char *balloonpath,
                                        int period);
80
int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
81
                                virHashTablePtr table);
82
int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
83
                                        virHashTablePtr hash,
84
                                        bool backingChain);
85
int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
86 87
                                            virHashTablePtr stats,
                                            bool backingChain);
88 89 90
int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
                               const char *devce,
                               unsigned long long size);
D
Daniel P. Berrange 已提交
91 92 93

int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
                                  const char *password);
94 95 96 97 98 99 100
int qemuMonitorJSONSetPassword(qemuMonitorPtr mon,
                               const char *protocol,
                               const char *password,
                               const char *action_if_connected);
int qemuMonitorJSONExpirePassword(qemuMonitorPtr mon,
                                  const char *protocol,
                                  const char *expire_time);
D
Daniel P. Berrange 已提交
101
int qemuMonitorJSONSetBalloon(qemuMonitorPtr mon,
102
                              unsigned long long newmem);
103
int qemuMonitorJSONSetCPU(qemuMonitorPtr mon, int cpu, bool online);
D
Daniel P. Berrange 已提交
104 105

int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
106
                              const char *dev_name,
107
                              bool force);
D
Daniel P. Berrange 已提交
108
int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon,
109
                               const char *dev_name,
D
Daniel P. Berrange 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
                               const char *newmedia,
                               const char *format);


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

int qemuMonitorJSONSetMigrationSpeed(qemuMonitorPtr mon,
                                     unsigned long bandwidth);

126 127 128
int qemuMonitorJSONSetMigrationDowntime(qemuMonitorPtr mon,
                                        unsigned long long downtime);

129 130 131 132 133
int qemuMonitorJSONGetMigrationCacheSize(qemuMonitorPtr mon,
                                         unsigned long long *cacheSize);
int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
                                         unsigned long long cacheSize);

134 135 136 137
int qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
                                      qemuMonitorMigrationParamsPtr params);
int qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
                                      qemuMonitorMigrationParamsPtr params);
138

139 140
int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
                                     qemuMonitorMigrationStatsPtr stats);
D
Daniel P. Berrange 已提交
141

142 143
int qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
                                            char ***capabilities);
144 145 146
int qemuMonitorJSONGetMigrationCapability(qemuMonitorPtr mon,
                                          qemuMonitorMigrationCaps capability);
int qemuMonitorJSONSetMigrationCapability(qemuMonitorPtr mon,
147 148
                                          qemuMonitorMigrationCaps capability,
                                          bool state);
149

A
Andrea Bolognani 已提交
150 151 152
int qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
                                      virGICCapability **capabilities);

153 154 155
int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
                           unsigned int flags,
                           const char *uri);
156 157 158
int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr mon,
                                           bool *spice_migrated);

D
Daniel P. Berrange 已提交
159 160 161

int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);

162 163 164
int qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
                                                const char *capability);

165
int qemuMonitorJSONDump(qemuMonitorPtr mon,
166 167
                        const char *protocol,
                        const char *dumpformat);
168

169 170 171 172 173 174 175
int qemuMonitorJSONGraphicsRelocate(qemuMonitorPtr mon,
                                    int type,
                                    const char *hostname,
                                    int port,
                                    int tlsPort,
                                    const char *tlsSubject);

D
Daniel P. Berrange 已提交
176
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
177 178
                                    virPCIDeviceAddress *hostAddr,
                                    virPCIDeviceAddress *guestAddr);
D
Daniel P. Berrange 已提交
179 180 181 182

int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
                              const char *path,
                              const char *bus,
183
                              virPCIDeviceAddress *guestAddr);
D
Daniel P. Berrange 已提交
184 185 186

int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
                                 const char *nicstr,
187
                                 virPCIDeviceAddress *guestAddr);
D
Daniel P. Berrange 已提交
188 189

int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
190
                                   virPCIDeviceAddress *guestAddr);
D
Daniel P. Berrange 已提交
191 192 193 194

int qemuMonitorJSONSendFileHandle(qemuMonitorPtr mon,
                                  const char *fdname,
                                  int fd);
195 196
int qemuMonitorJSONAddFd(qemuMonitorPtr mon, int fdset, int fd,
                         const char *name);
D
Daniel P. Berrange 已提交
197 198 199

int qemuMonitorJSONCloseFileHandle(qemuMonitorPtr mon,
                                   const char *fdname);
200
int qemuMonitorJSONRemoveFd(qemuMonitorPtr mon, int fdset, int fd);
D
Daniel P. Berrange 已提交
201

202 203 204 205 206 207
int qemuMonitorJSONAddNetdev(qemuMonitorPtr mon,
                             const char *netdevstr);

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

208 209 210
int qemuMonitorJSONQueryRxFilter(qemuMonitorPtr mon, const char *alias,
                                 virNetDevRxFilterPtr *filter);

211 212
int qemuMonitorJSONGetChardevInfo(qemuMonitorPtr mon,
                                  virHashTablePtr info);
213

214 215
int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon,
                                           const char *bus,
216
                                           virPCIDeviceAddress *guestAddr);
217

218 219
int qemuMonitorJSONAddDeviceArgs(qemuMonitorPtr mon,
                                 virJSONValuePtr args);
220 221 222
int qemuMonitorJSONAddDevice(qemuMonitorPtr mon,
                             const char *devicestr);

223
int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
224
                             const char *devalias);
225

226 227 228 229 230 231 232 233
int qemuMonitorJSONAddObject(qemuMonitorPtr mon,
                             const char *type,
                             const char *objalias,
                             virJSONValuePtr props);

int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
                             const char *objalias);

234 235 236 237
int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
                                      const char *alias,
                                      const char *passphrase);

C
Chris Lalancette 已提交
238 239 240 241
int qemuMonitorJSONCreateSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorJSONLoadSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorJSONDeleteSnapshot(qemuMonitorPtr mon, const char *name);

242
int qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon,
243
                                virJSONValuePtr actions,
244
                                const char *device,
245 246
                                const char *file,
                                const char *format,
247 248 249 250 251 252 253 254 255 256
                                bool reuse)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr actions)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon,
                               const char *device,
                               const char *file,
                               const char *format,
                               unsigned long long speed,
257 258
                               unsigned int granularity,
                               unsigned long long buf_size,
259 260 261
                               unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon,
262
                              const char *device)
263
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
264

265 266 267 268
int qemuMonitorJSONBlockCommit(qemuMonitorPtr mon,
                               const char *device,
                               const char *top,
                               const char *base,
269
                               const char *backingName,
270
                               unsigned long long bandwidth)
271
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
272

273 274 275 276 277 278 279
char *qemuMonitorJSONDiskNameLookup(qemuMonitorPtr mon,
                                    const char *device,
                                    virStorageSourcePtr top,
                                    virStorageSourcePtr target)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
    ATTRIBUTE_NONNULL(4);

280 281
int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
                                    const char *cmd_str,
282 283
                                    char **reply_str,
                                    bool hmp);
284

285
int qemuMonitorJSONInjectNMI(qemuMonitorPtr mon);
286

287 288 289 290 291
int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
                           unsigned int holdtime,
                           unsigned int *keycodes,
                           unsigned int nkeycodes);

292 293 294
int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
                              const char *file);

295 296 297 298 299 300
int qemuMonitorJSONBlockStream(qemuMonitorPtr mon,
                               const char *device,
                               const char *base,
                               const char *backingName,
                               unsigned long long speed,
                               bool modern)
301
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
302

303 304 305 306 307
int qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon,
                                  const char *device,
                                  bool modern)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

308 309 310 311 312 313
int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
                                    const char *device,
                                    unsigned long long speed,
                                    bool modern)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

314 315
virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
316

317 318
int qemuMonitorJSONSetLink(qemuMonitorPtr mon,
                           const char *name,
319
                           virDomainNetInterfaceLinkState state);
320

321 322 323 324 325
int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon,
                                const char *protocol,
                                const char *fdname,
                                bool skipauth);

326 327
int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
                                      const char *device,
328 329
                                      virDomainBlockIoTuneInfoPtr info,
                                      bool supportMaxOptions);
330 331 332

int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon,
                                      const char *device,
333
                                      virDomainBlockIoTuneInfoPtr reply);
334

335 336
int qemuMonitorJSONSystemWakeup(qemuMonitorPtr mon);

337 338 339 340 341 342 343
int qemuMonitorJSONGetVersion(qemuMonitorPtr mon,
                              int *major,
                              int *minor,
                              int *micro,
                              char **package)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

344 345 346 347
int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
                               qemuMonitorMachineInfoPtr **machines)
    ATTRIBUTE_NONNULL(2);

348 349 350 351
int qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
                                     char ***cpus)
    ATTRIBUTE_NONNULL(2);

352 353 354
int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
                               char ***commands)
    ATTRIBUTE_NONNULL(2);
355 356 357
int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
                             char ***events)
    ATTRIBUTE_NONNULL(2);
358 359
int qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
                                                  const char *option,
360 361
                                                  char ***params,
                                                  bool *found)
362
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
363

364 365 366 367 368
int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
                               bool *enabled,
                               bool *present)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

369 370 371
int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon,
                                  char ***types)
    ATTRIBUTE_NONNULL(2);
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388

/* ListPath structures and API's are public only for qemumonitorjsontest */
typedef struct _qemuMonitorJSONListPath qemuMonitorJSONListPath;
typedef qemuMonitorJSONListPath *qemuMonitorJSONListPathPtr;

struct _qemuMonitorJSONListPath {
    char *name;
    char *type;
};

int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon,
                                      const char *path,
                                      qemuMonitorJSONListPathPtr **paths)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);

void qemuMonitorJSONListPathFree(qemuMonitorJSONListPathPtr paths);

389 390 391
/* ObjectProperty structures and Get/Set API's are public only
 * for qemumonitorjsontest
 */
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
/* Flags for the 'type' field in _qemuMonitorJSONObjectProperty */
typedef enum {
    QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN=1,
    QEMU_MONITOR_OBJECT_PROPERTY_INT,
    QEMU_MONITOR_OBJECT_PROPERTY_LONG,
    QEMU_MONITOR_OBJECT_PROPERTY_UINT,
    QEMU_MONITOR_OBJECT_PROPERTY_ULONG,
    QEMU_MONITOR_OBJECT_PROPERTY_DOUBLE,
    QEMU_MONITOR_OBJECT_PROPERTY_STRING,

    QEMU_MONITOR_OBJECT_PROPERTY_LAST
} qemuMonitorJSONObjectPropertyType;

typedef struct _qemuMonitorJSONObjectProperty qemuMonitorJSONObjectProperty;
typedef qemuMonitorJSONObjectProperty *qemuMonitorJSONObjectPropertyPtr;
struct _qemuMonitorJSONObjectProperty {
    int type;    /* qemuMonitorJSONObjectPropertyType */
    union {
        bool b;
        int iv;
        long long l;
        unsigned int ui;
        unsigned long long ul;
        double d;
        char *str;
    } val;
};

int qemuMonitorJSONGetObjectProperty(qemuMonitorPtr mon,
                                     const char *path,
                                     const char *property,
                                     qemuMonitorJSONObjectPropertyPtr prop)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

426 427 428 429 430 431
int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr mon,
                                     const char *path,
                                     const char *property,
                                     qemuMonitorJSONObjectPropertyPtr prop)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);

432 433 434 435
int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
                                  const char *type,
                                  char ***props)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
436
char *qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon);
437

438 439 440
int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
                                  const char *host,
                                  unsigned int port);
441 442 443
int qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
                                const char *deviceID,
                                bool writable);
444
int qemuMonitorJSONNBDServerStop(qemuMonitorPtr mon);
S
Stefan Berger 已提交
445 446 447 448 449 450 451 452
int qemuMonitorJSONGetTPMModels(qemuMonitorPtr mon,
                                char ***tpmmodels)
    ATTRIBUTE_NONNULL(2);

int qemuMonitorJSONGetTPMTypes(qemuMonitorPtr mon,
                               char ***tpmtypes)
    ATTRIBUTE_NONNULL(2);

453 454 455
int qemuMonitorJSONAttachCharDev(qemuMonitorPtr mon,
                                 const char *chrID,
                                 virDomainChrSourceDefPtr chr);
456 457
int qemuMonitorJSONDetachCharDev(qemuMonitorPtr mon,
                                 const char *chrID);
458 459 460 461

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

462 463 464 465
int qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon,
                                 const char *property,
                                 virCPUDataPtr *cpudata);

466 467 468
int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
                               virArch arch,
                               virCPUDataPtr *data);
469 470

int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon);
471 472

int qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
473
                                qemuMonitorIOThreadInfoPtr **iothreads)
474
    ATTRIBUTE_NONNULL(2);
475 476 477 478 479

int qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
                                       virHashTablePtr info)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

480 481
int qemuMonitorJSONFindLinkPath(qemuMonitorPtr mon,
                                const char *name,
482
                                const char *alias,
483
                                char **path)
484
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
485 486 487 488 489

int qemuMonitorJSONMigrateIncoming(qemuMonitorPtr mon,
                                   const char *uri)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);

490 491 492
int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);

493 494 495
int qemuMonitorJSONGetRTCTime(qemuMonitorPtr mon,
                              struct tm *tm)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
D
Daniel P. Berrange 已提交
496
#endif /* QEMU_MONITOR_JSON_H */