qemu_monitor_json.h 20.5 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 qemuMonitorJSONGetCPUInfo(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 138
int qemuMonitorJSONGetMigrationCompression(qemuMonitorPtr mon,
                                           qemuMonitorMigrationCompressionPtr compress);
int qemuMonitorJSONSetMigrationCompression(qemuMonitorPtr mon,
                                           qemuMonitorMigrationCompressionPtr compress);

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 220
int qemuMonitorJSONAddDevice(qemuMonitorPtr mon,
                             const char *devicestr);

221
int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
222
                             const char *devalias);
223

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

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

232 233 234 235
int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
                                      const char *alias,
                                      const char *passphrase);

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

240
int qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon,
241
                                virJSONValuePtr actions,
242
                                const char *device,
243 244
                                const char *file,
                                const char *format,
245 246 247 248 249 250 251 252 253 254
                                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,
255 256
                               unsigned int granularity,
                               unsigned long long buf_size,
257 258 259
                               unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon,
260
                              const char *device)
261
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
262

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

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

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

283
int qemuMonitorJSONInjectNMI(qemuMonitorPtr mon);
284

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

290 291 292
int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
                              const char *file);

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

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

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

312 313
virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);
314

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

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

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

int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon,
                                      const char *device,
331
                                      virDomainBlockIoTuneInfoPtr reply);
332

333 334
int qemuMonitorJSONSystemWakeup(qemuMonitorPtr mon);

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

342 343 344 345
int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
                               qemuMonitorMachineInfoPtr **machines)
    ATTRIBUTE_NONNULL(2);

346 347 348 349
int qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
                                     char ***cpus)
    ATTRIBUTE_NONNULL(2);

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

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

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

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

387 388 389
/* ObjectProperty structures and Get/Set API's are public only
 * for qemumonitorjsontest
 */
390 391 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
/* 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);

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

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

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

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

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

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

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

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

int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon);
469 470

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

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

478 479 480
int qemuMonitorJSONFindLinkPath(qemuMonitorPtr mon,
                                const char *name,
                                char **path)
481
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
482 483 484 485 486

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

487 488 489
int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon)
    ATTRIBUTE_NONNULL(1);

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