2 * Human Monitor Interface
4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
18 #include "sysemu/char.h"
19 #include "qemu/option.h"
20 #include "qemu/timer.h"
21 #include "qmp-commands.h"
22 #include "qemu/sockets.h"
23 #include "monitor/monitor.h"
24 #include "qapi/opts-visitor.h"
25 #include "ui/console.h"
26 #include "block/qapi.h"
29 static void hmp_handle_error(Monitor
*mon
, Error
**errp
)
31 if (error_is_set(errp
)) {
32 monitor_printf(mon
, "%s\n", error_get_pretty(*errp
));
37 void hmp_info_name(Monitor
*mon
, const QDict
*qdict
)
41 info
= qmp_query_name(NULL
);
43 monitor_printf(mon
, "%s\n", info
->name
);
45 qapi_free_NameInfo(info
);
48 void hmp_info_version(Monitor
*mon
, const QDict
*qdict
)
52 info
= qmp_query_version(NULL
);
54 monitor_printf(mon
, "%" PRId64
".%" PRId64
".%" PRId64
"%s\n",
55 info
->qemu
.major
, info
->qemu
.minor
, info
->qemu
.micro
,
58 qapi_free_VersionInfo(info
);
61 void hmp_info_kvm(Monitor
*mon
, const QDict
*qdict
)
65 info
= qmp_query_kvm(NULL
);
66 monitor_printf(mon
, "kvm support: ");
68 monitor_printf(mon
, "%s\n", info
->enabled
? "enabled" : "disabled");
70 monitor_printf(mon
, "not compiled\n");
73 qapi_free_KvmInfo(info
);
76 void hmp_info_status(Monitor
*mon
, const QDict
*qdict
)
80 info
= qmp_query_status(NULL
);
82 monitor_printf(mon
, "VM status: %s%s",
83 info
->running
? "running" : "paused",
84 info
->singlestep
? " (single step mode)" : "");
86 if (!info
->running
&& info
->status
!= RUN_STATE_PAUSED
) {
87 monitor_printf(mon
, " (%s)", RunState_lookup
[info
->status
]);
90 monitor_printf(mon
, "\n");
92 qapi_free_StatusInfo(info
);
95 void hmp_info_uuid(Monitor
*mon
, const QDict
*qdict
)
99 info
= qmp_query_uuid(NULL
);
100 monitor_printf(mon
, "%s\n", info
->UUID
);
101 qapi_free_UuidInfo(info
);
104 void hmp_info_chardev(Monitor
*mon
, const QDict
*qdict
)
106 ChardevInfoList
*char_info
, *info
;
108 char_info
= qmp_query_chardev(NULL
);
109 for (info
= char_info
; info
; info
= info
->next
) {
110 monitor_printf(mon
, "%s: filename=%s\n", info
->value
->label
,
111 info
->value
->filename
);
114 qapi_free_ChardevInfoList(char_info
);
117 void hmp_info_mice(Monitor
*mon
, const QDict
*qdict
)
119 MouseInfoList
*mice_list
, *mouse
;
121 mice_list
= qmp_query_mice(NULL
);
123 monitor_printf(mon
, "No mouse devices connected\n");
127 for (mouse
= mice_list
; mouse
; mouse
= mouse
->next
) {
128 monitor_printf(mon
, "%c Mouse #%" PRId64
": %s%s\n",
129 mouse
->value
->current
? '*' : ' ',
130 mouse
->value
->index
, mouse
->value
->name
,
131 mouse
->value
->absolute
? " (absolute)" : "");
134 qapi_free_MouseInfoList(mice_list
);
137 void hmp_info_migrate(Monitor
*mon
, const QDict
*qdict
)
140 MigrationCapabilityStatusList
*caps
, *cap
;
142 info
= qmp_query_migrate(NULL
);
143 caps
= qmp_query_migrate_capabilities(NULL
);
145 /* do not display parameters during setup */
146 if (info
->has_status
&& caps
) {
147 monitor_printf(mon
, "capabilities: ");
148 for (cap
= caps
; cap
; cap
= cap
->next
) {
149 monitor_printf(mon
, "%s: %s ",
150 MigrationCapability_lookup
[cap
->value
->capability
],
151 cap
->value
->state
? "on" : "off");
153 monitor_printf(mon
, "\n");
156 if (info
->has_status
) {
157 monitor_printf(mon
, "Migration status: %s\n", info
->status
);
158 monitor_printf(mon
, "total time: %" PRIu64
" milliseconds\n",
160 if (info
->has_expected_downtime
) {
161 monitor_printf(mon
, "expected downtime: %" PRIu64
" milliseconds\n",
162 info
->expected_downtime
);
164 if (info
->has_downtime
) {
165 monitor_printf(mon
, "downtime: %" PRIu64
" milliseconds\n",
168 if (info
->has_setup_time
) {
169 monitor_printf(mon
, "setup: %" PRIu64
" milliseconds\n",
175 monitor_printf(mon
, "transferred ram: %" PRIu64
" kbytes\n",
176 info
->ram
->transferred
>> 10);
177 monitor_printf(mon
, "throughput: %0.2f mbps\n",
179 monitor_printf(mon
, "remaining ram: %" PRIu64
" kbytes\n",
180 info
->ram
->remaining
>> 10);
181 monitor_printf(mon
, "total ram: %" PRIu64
" kbytes\n",
182 info
->ram
->total
>> 10);
183 monitor_printf(mon
, "duplicate: %" PRIu64
" pages\n",
184 info
->ram
->duplicate
);
185 monitor_printf(mon
, "skipped: %" PRIu64
" pages\n",
187 monitor_printf(mon
, "normal: %" PRIu64
" pages\n",
189 monitor_printf(mon
, "normal bytes: %" PRIu64
" kbytes\n",
190 info
->ram
->normal_bytes
>> 10);
191 if (info
->ram
->dirty_pages_rate
) {
192 monitor_printf(mon
, "dirty pages rate: %" PRIu64
" pages\n",
193 info
->ram
->dirty_pages_rate
);
197 if (info
->has_disk
) {
198 monitor_printf(mon
, "transferred disk: %" PRIu64
" kbytes\n",
199 info
->disk
->transferred
>> 10);
200 monitor_printf(mon
, "remaining disk: %" PRIu64
" kbytes\n",
201 info
->disk
->remaining
>> 10);
202 monitor_printf(mon
, "total disk: %" PRIu64
" kbytes\n",
203 info
->disk
->total
>> 10);
206 if (info
->has_xbzrle_cache
) {
207 monitor_printf(mon
, "cache size: %" PRIu64
" bytes\n",
208 info
->xbzrle_cache
->cache_size
);
209 monitor_printf(mon
, "xbzrle transferred: %" PRIu64
" kbytes\n",
210 info
->xbzrle_cache
->bytes
>> 10);
211 monitor_printf(mon
, "xbzrle pages: %" PRIu64
" pages\n",
212 info
->xbzrle_cache
->pages
);
213 monitor_printf(mon
, "xbzrle cache miss: %" PRIu64
"\n",
214 info
->xbzrle_cache
->cache_miss
);
215 monitor_printf(mon
, "xbzrle overflow : %" PRIu64
"\n",
216 info
->xbzrle_cache
->overflow
);
219 qapi_free_MigrationInfo(info
);
220 qapi_free_MigrationCapabilityStatusList(caps
);
223 void hmp_info_migrate_capabilities(Monitor
*mon
, const QDict
*qdict
)
225 MigrationCapabilityStatusList
*caps
, *cap
;
227 caps
= qmp_query_migrate_capabilities(NULL
);
230 monitor_printf(mon
, "capabilities: ");
231 for (cap
= caps
; cap
; cap
= cap
->next
) {
232 monitor_printf(mon
, "%s: %s ",
233 MigrationCapability_lookup
[cap
->value
->capability
],
234 cap
->value
->state
? "on" : "off");
236 monitor_printf(mon
, "\n");
239 qapi_free_MigrationCapabilityStatusList(caps
);
242 void hmp_info_migrate_cache_size(Monitor
*mon
, const QDict
*qdict
)
244 monitor_printf(mon
, "xbzrel cache size: %" PRId64
" kbytes\n",
245 qmp_query_migrate_cache_size(NULL
) >> 10);
248 void hmp_info_cpus(Monitor
*mon
, const QDict
*qdict
)
250 CpuInfoList
*cpu_list
, *cpu
;
252 cpu_list
= qmp_query_cpus(NULL
);
254 for (cpu
= cpu_list
; cpu
; cpu
= cpu
->next
) {
257 if (cpu
->value
->CPU
== monitor_get_cpu_index()) {
261 monitor_printf(mon
, "%c CPU #%" PRId64
":", active
, cpu
->value
->CPU
);
263 if (cpu
->value
->has_pc
) {
264 monitor_printf(mon
, " pc=0x%016" PRIx64
, cpu
->value
->pc
);
266 if (cpu
->value
->has_nip
) {
267 monitor_printf(mon
, " nip=0x%016" PRIx64
, cpu
->value
->nip
);
269 if (cpu
->value
->has_npc
) {
270 monitor_printf(mon
, " npc=0x%016" PRIx64
, cpu
->value
->npc
);
272 if (cpu
->value
->has_PC
) {
273 monitor_printf(mon
, " PC=0x%016" PRIx64
, cpu
->value
->PC
);
276 if (cpu
->value
->halted
) {
277 monitor_printf(mon
, " (halted)");
280 monitor_printf(mon
, " thread_id=%" PRId64
"\n", cpu
->value
->thread_id
);
283 qapi_free_CpuInfoList(cpu_list
);
286 void hmp_info_block(Monitor
*mon
, const QDict
*qdict
)
288 BlockInfoList
*block_list
, *info
;
289 ImageInfo
*image_info
;
290 const char *device
= qdict_get_try_str(qdict
, "device");
291 bool verbose
= qdict_get_try_bool(qdict
, "verbose", 0);
293 block_list
= qmp_query_block(NULL
);
295 for (info
= block_list
; info
; info
= info
->next
) {
296 if (device
&& strcmp(device
, info
->value
->device
)) {
300 if (info
!= block_list
) {
301 monitor_printf(mon
, "\n");
304 monitor_printf(mon
, "%s", info
->value
->device
);
305 if (info
->value
->has_inserted
) {
306 monitor_printf(mon
, ": %s (%s%s%s)\n",
307 info
->value
->inserted
->file
,
308 info
->value
->inserted
->drv
,
309 info
->value
->inserted
->ro
? ", read-only" : "",
310 info
->value
->inserted
->encrypted
? ", encrypted" : "");
312 monitor_printf(mon
, ": [not inserted]\n");
315 if (info
->value
->has_io_status
&& info
->value
->io_status
!= BLOCK_DEVICE_IO_STATUS_OK
) {
316 monitor_printf(mon
, " I/O status: %s\n",
317 BlockDeviceIoStatus_lookup
[info
->value
->io_status
]);
320 if (info
->value
->removable
) {
321 monitor_printf(mon
, " Removable device: %slocked, tray %s\n",
322 info
->value
->locked
? "" : "not ",
323 info
->value
->tray_open
? "open" : "closed");
327 if (!info
->value
->has_inserted
) {
331 if (info
->value
->inserted
->has_backing_file
) {
334 "(chain depth: %" PRId64
")\n",
335 info
->value
->inserted
->backing_file
,
336 info
->value
->inserted
->backing_file_depth
);
339 if (info
->value
->inserted
->bps
340 || info
->value
->inserted
->bps_rd
341 || info
->value
->inserted
->bps_wr
342 || info
->value
->inserted
->iops
343 || info
->value
->inserted
->iops_rd
344 || info
->value
->inserted
->iops_wr
)
346 monitor_printf(mon
, " I/O throttling: bps=%" PRId64
347 " bps_rd=%" PRId64
" bps_wr=%" PRId64
349 " bps_rd_max=%" PRId64
350 " bps_wr_max=%" PRId64
351 " iops=%" PRId64
" iops_rd=%" PRId64
354 " iops_rd_max=%" PRId64
355 " iops_wr_max=%" PRId64
356 " iops_size=%" PRId64
"\n",
357 info
->value
->inserted
->bps
,
358 info
->value
->inserted
->bps_rd
,
359 info
->value
->inserted
->bps_wr
,
360 info
->value
->inserted
->bps_max
,
361 info
->value
->inserted
->bps_rd_max
,
362 info
->value
->inserted
->bps_wr_max
,
363 info
->value
->inserted
->iops
,
364 info
->value
->inserted
->iops_rd
,
365 info
->value
->inserted
->iops_wr
,
366 info
->value
->inserted
->iops_max
,
367 info
->value
->inserted
->iops_rd_max
,
368 info
->value
->inserted
->iops_wr_max
,
369 info
->value
->inserted
->iops_size
);
373 monitor_printf(mon
, "\nImages:\n");
374 image_info
= info
->value
->inserted
->image
;
376 bdrv_image_info_dump((fprintf_function
)monitor_printf
,
378 if (image_info
->has_backing_image
) {
379 image_info
= image_info
->backing_image
;
387 qapi_free_BlockInfoList(block_list
);
390 void hmp_info_blockstats(Monitor
*mon
, const QDict
*qdict
)
392 BlockStatsList
*stats_list
, *stats
;
394 stats_list
= qmp_query_blockstats(NULL
);
396 for (stats
= stats_list
; stats
; stats
= stats
->next
) {
397 if (!stats
->value
->has_device
) {
401 monitor_printf(mon
, "%s:", stats
->value
->device
);
402 monitor_printf(mon
, " rd_bytes=%" PRId64
404 " rd_operations=%" PRId64
405 " wr_operations=%" PRId64
406 " flush_operations=%" PRId64
407 " wr_total_time_ns=%" PRId64
408 " rd_total_time_ns=%" PRId64
409 " flush_total_time_ns=%" PRId64
411 stats
->value
->stats
->rd_bytes
,
412 stats
->value
->stats
->wr_bytes
,
413 stats
->value
->stats
->rd_operations
,
414 stats
->value
->stats
->wr_operations
,
415 stats
->value
->stats
->flush_operations
,
416 stats
->value
->stats
->wr_total_time_ns
,
417 stats
->value
->stats
->rd_total_time_ns
,
418 stats
->value
->stats
->flush_total_time_ns
);
421 qapi_free_BlockStatsList(stats_list
);
424 void hmp_info_vnc(Monitor
*mon
, const QDict
*qdict
)
428 VncClientInfoList
*client
;
430 info
= qmp_query_vnc(&err
);
432 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
437 if (!info
->enabled
) {
438 monitor_printf(mon
, "Server: disabled\n");
442 monitor_printf(mon
, "Server:\n");
443 if (info
->has_host
&& info
->has_service
) {
444 monitor_printf(mon
, " address: %s:%s\n", info
->host
, info
->service
);
446 if (info
->has_auth
) {
447 monitor_printf(mon
, " auth: %s\n", info
->auth
);
450 if (!info
->has_clients
|| info
->clients
== NULL
) {
451 monitor_printf(mon
, "Client: none\n");
453 for (client
= info
->clients
; client
; client
= client
->next
) {
454 monitor_printf(mon
, "Client:\n");
455 monitor_printf(mon
, " address: %s:%s\n",
456 client
->value
->host
, client
->value
->service
);
457 monitor_printf(mon
, " x509_dname: %s\n",
458 client
->value
->x509_dname
?
459 client
->value
->x509_dname
: "none");
460 monitor_printf(mon
, " username: %s\n",
461 client
->value
->has_sasl_username
?
462 client
->value
->sasl_username
: "none");
467 qapi_free_VncInfo(info
);
470 void hmp_info_spice(Monitor
*mon
, const QDict
*qdict
)
472 SpiceChannelList
*chan
;
475 info
= qmp_query_spice(NULL
);
477 if (!info
->enabled
) {
478 monitor_printf(mon
, "Server: disabled\n");
482 monitor_printf(mon
, "Server:\n");
483 if (info
->has_port
) {
484 monitor_printf(mon
, " address: %s:%" PRId64
"\n",
485 info
->host
, info
->port
);
487 if (info
->has_tls_port
) {
488 monitor_printf(mon
, " address: %s:%" PRId64
" [tls]\n",
489 info
->host
, info
->tls_port
);
491 monitor_printf(mon
, " migrated: %s\n",
492 info
->migrated
? "true" : "false");
493 monitor_printf(mon
, " auth: %s\n", info
->auth
);
494 monitor_printf(mon
, " compiled: %s\n", info
->compiled_version
);
495 monitor_printf(mon
, " mouse-mode: %s\n",
496 SpiceQueryMouseMode_lookup
[info
->mouse_mode
]);
498 if (!info
->has_channels
|| info
->channels
== NULL
) {
499 monitor_printf(mon
, "Channels: none\n");
501 for (chan
= info
->channels
; chan
; chan
= chan
->next
) {
502 monitor_printf(mon
, "Channel:\n");
503 monitor_printf(mon
, " address: %s:%s%s\n",
504 chan
->value
->host
, chan
->value
->port
,
505 chan
->value
->tls
? " [tls]" : "");
506 monitor_printf(mon
, " session: %" PRId64
"\n",
507 chan
->value
->connection_id
);
508 monitor_printf(mon
, " channel: %" PRId64
":%" PRId64
"\n",
509 chan
->value
->channel_type
, chan
->value
->channel_id
);
514 qapi_free_SpiceInfo(info
);
517 void hmp_info_balloon(Monitor
*mon
, const QDict
*qdict
)
522 info
= qmp_query_balloon(&err
);
524 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
529 monitor_printf(mon
, "balloon: actual=%" PRId64
"\n", info
->actual
>> 20);
531 qapi_free_BalloonInfo(info
);
534 static void hmp_info_pci_device(Monitor
*mon
, const PciDeviceInfo
*dev
)
536 PciMemoryRegionList
*region
;
538 monitor_printf(mon
, " Bus %2" PRId64
", ", dev
->bus
);
539 monitor_printf(mon
, "device %3" PRId64
", function %" PRId64
":\n",
540 dev
->slot
, dev
->function
);
541 monitor_printf(mon
, " ");
543 if (dev
->class_info
.has_desc
) {
544 monitor_printf(mon
, "%s", dev
->class_info
.desc
);
546 monitor_printf(mon
, "Class %04" PRId64
, dev
->class_info
.q_class
);
549 monitor_printf(mon
, ": PCI device %04" PRIx64
":%04" PRIx64
"\n",
550 dev
->id
.vendor
, dev
->id
.device
);
553 monitor_printf(mon
, " IRQ %" PRId64
".\n", dev
->irq
);
556 if (dev
->has_pci_bridge
) {
557 monitor_printf(mon
, " BUS %" PRId64
".\n",
558 dev
->pci_bridge
->bus
.number
);
559 monitor_printf(mon
, " secondary bus %" PRId64
".\n",
560 dev
->pci_bridge
->bus
.secondary
);
561 monitor_printf(mon
, " subordinate bus %" PRId64
".\n",
562 dev
->pci_bridge
->bus
.subordinate
);
564 monitor_printf(mon
, " IO range [0x%04"PRIx64
", 0x%04"PRIx64
"]\n",
565 dev
->pci_bridge
->bus
.io_range
->base
,
566 dev
->pci_bridge
->bus
.io_range
->limit
);
569 " memory range [0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
570 dev
->pci_bridge
->bus
.memory_range
->base
,
571 dev
->pci_bridge
->bus
.memory_range
->limit
);
573 monitor_printf(mon
, " prefetchable memory range "
574 "[0x%08"PRIx64
", 0x%08"PRIx64
"]\n",
575 dev
->pci_bridge
->bus
.prefetchable_range
->base
,
576 dev
->pci_bridge
->bus
.prefetchable_range
->limit
);
579 for (region
= dev
->regions
; region
; region
= region
->next
) {
582 addr
= region
->value
->address
;
583 size
= region
->value
->size
;
585 monitor_printf(mon
, " BAR%" PRId64
": ", region
->value
->bar
);
587 if (!strcmp(region
->value
->type
, "io")) {
588 monitor_printf(mon
, "I/O at 0x%04" PRIx64
589 " [0x%04" PRIx64
"].\n",
590 addr
, addr
+ size
- 1);
592 monitor_printf(mon
, "%d bit%s memory at 0x%08" PRIx64
593 " [0x%08" PRIx64
"].\n",
594 region
->value
->mem_type_64
? 64 : 32,
595 region
->value
->prefetch
? " prefetchable" : "",
596 addr
, addr
+ size
- 1);
600 monitor_printf(mon
, " id \"%s\"\n", dev
->qdev_id
);
602 if (dev
->has_pci_bridge
) {
603 if (dev
->pci_bridge
->has_devices
) {
604 PciDeviceInfoList
*cdev
;
605 for (cdev
= dev
->pci_bridge
->devices
; cdev
; cdev
= cdev
->next
) {
606 hmp_info_pci_device(mon
, cdev
->value
);
612 void hmp_info_pci(Monitor
*mon
, const QDict
*qdict
)
614 PciInfoList
*info_list
, *info
;
617 info_list
= qmp_query_pci(&err
);
619 monitor_printf(mon
, "PCI devices not supported\n");
624 for (info
= info_list
; info
; info
= info
->next
) {
625 PciDeviceInfoList
*dev
;
627 for (dev
= info
->value
->devices
; dev
; dev
= dev
->next
) {
628 hmp_info_pci_device(mon
, dev
->value
);
632 qapi_free_PciInfoList(info_list
);
635 void hmp_info_block_jobs(Monitor
*mon
, const QDict
*qdict
)
637 BlockJobInfoList
*list
;
640 list
= qmp_query_block_jobs(&err
);
644 monitor_printf(mon
, "No active jobs\n");
649 if (strcmp(list
->value
->type
, "stream") == 0) {
650 monitor_printf(mon
, "Streaming device %s: Completed %" PRId64
651 " of %" PRId64
" bytes, speed limit %" PRId64
658 monitor_printf(mon
, "Type %s, device %s: Completed %" PRId64
659 " of %" PRId64
" bytes, speed limit %" PRId64
671 void hmp_info_tpm(Monitor
*mon
, const QDict
*qdict
)
673 TPMInfoList
*info_list
, *info
;
676 TPMPassthroughOptions
*tpo
;
678 info_list
= qmp_query_tpm(&err
);
680 monitor_printf(mon
, "TPM device not supported\n");
686 monitor_printf(mon
, "TPM device:\n");
689 for (info
= info_list
; info
; info
= info
->next
) {
690 TPMInfo
*ti
= info
->value
;
691 monitor_printf(mon
, " tpm%d: model=%s\n",
692 c
, TpmModel_lookup
[ti
->model
]);
694 monitor_printf(mon
, " \\ %s: type=%s",
695 ti
->id
, TpmTypeOptionsKind_lookup
[ti
->options
->kind
]);
697 switch (ti
->options
->kind
) {
698 case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH
:
699 tpo
= ti
->options
->passthrough
;
700 monitor_printf(mon
, "%s%s%s%s",
701 tpo
->has_path
? ",path=" : "",
702 tpo
->has_path
? tpo
->path
: "",
703 tpo
->has_cancel_path
? ",cancel-path=" : "",
704 tpo
->has_cancel_path
? tpo
->cancel_path
: "");
706 case TPM_TYPE_OPTIONS_KIND_MAX
:
709 monitor_printf(mon
, "\n");
712 qapi_free_TPMInfoList(info_list
);
715 void hmp_quit(Monitor
*mon
, const QDict
*qdict
)
717 monitor_suspend(mon
);
721 void hmp_stop(Monitor
*mon
, const QDict
*qdict
)
726 void hmp_system_reset(Monitor
*mon
, const QDict
*qdict
)
728 qmp_system_reset(NULL
);
731 void hmp_system_powerdown(Monitor
*mon
, const QDict
*qdict
)
733 qmp_system_powerdown(NULL
);
736 void hmp_cpu(Monitor
*mon
, const QDict
*qdict
)
740 /* XXX: drop the monitor_set_cpu() usage when all HMP commands that
741 use it are converted to the QAPI */
742 cpu_index
= qdict_get_int(qdict
, "index");
743 if (monitor_set_cpu(cpu_index
) < 0) {
744 monitor_printf(mon
, "invalid CPU index\n");
748 void hmp_memsave(Monitor
*mon
, const QDict
*qdict
)
750 uint32_t size
= qdict_get_int(qdict
, "size");
751 const char *filename
= qdict_get_str(qdict
, "filename");
752 uint64_t addr
= qdict_get_int(qdict
, "val");
755 qmp_memsave(addr
, size
, filename
, true, monitor_get_cpu_index(), &errp
);
756 hmp_handle_error(mon
, &errp
);
759 void hmp_pmemsave(Monitor
*mon
, const QDict
*qdict
)
761 uint32_t size
= qdict_get_int(qdict
, "size");
762 const char *filename
= qdict_get_str(qdict
, "filename");
763 uint64_t addr
= qdict_get_int(qdict
, "val");
766 qmp_pmemsave(addr
, size
, filename
, &errp
);
767 hmp_handle_error(mon
, &errp
);
770 void hmp_ringbuf_write(Monitor
*mon
, const QDict
*qdict
)
772 const char *chardev
= qdict_get_str(qdict
, "device");
773 const char *data
= qdict_get_str(qdict
, "data");
776 qmp_ringbuf_write(chardev
, data
, false, 0, &errp
);
778 hmp_handle_error(mon
, &errp
);
781 void hmp_ringbuf_read(Monitor
*mon
, const QDict
*qdict
)
783 uint32_t size
= qdict_get_int(qdict
, "size");
784 const char *chardev
= qdict_get_str(qdict
, "device");
789 data
= qmp_ringbuf_read(chardev
, size
, false, 0, &errp
);
791 monitor_printf(mon
, "%s\n", error_get_pretty(errp
));
796 for (i
= 0; data
[i
]; i
++) {
797 unsigned char ch
= data
[i
];
800 monitor_printf(mon
, "\\\\");
801 } else if ((ch
< 0x20 && ch
!= '\n' && ch
!= '\t') || ch
== 0x7F) {
802 monitor_printf(mon
, "\\u%04X", ch
);
804 monitor_printf(mon
, "%c", ch
);
808 monitor_printf(mon
, "\n");
812 static void hmp_cont_cb(void *opaque
, int err
)
819 static bool key_is_missing(const BlockInfo
*bdev
)
821 return (bdev
->inserted
&& bdev
->inserted
->encryption_key_missing
);
824 void hmp_cont(Monitor
*mon
, const QDict
*qdict
)
826 BlockInfoList
*bdev_list
, *bdev
;
829 bdev_list
= qmp_query_block(NULL
);
830 for (bdev
= bdev_list
; bdev
; bdev
= bdev
->next
) {
831 if (key_is_missing(bdev
->value
)) {
832 monitor_read_block_device_key(mon
, bdev
->value
->device
,
839 hmp_handle_error(mon
, &errp
);
842 qapi_free_BlockInfoList(bdev_list
);
845 void hmp_system_wakeup(Monitor
*mon
, const QDict
*qdict
)
847 qmp_system_wakeup(NULL
);
850 void hmp_inject_nmi(Monitor
*mon
, const QDict
*qdict
)
854 qmp_inject_nmi(&errp
);
855 hmp_handle_error(mon
, &errp
);
858 void hmp_set_link(Monitor
*mon
, const QDict
*qdict
)
860 const char *name
= qdict_get_str(qdict
, "name");
861 int up
= qdict_get_bool(qdict
, "up");
864 qmp_set_link(name
, up
, &errp
);
865 hmp_handle_error(mon
, &errp
);
868 void hmp_block_passwd(Monitor
*mon
, const QDict
*qdict
)
870 const char *device
= qdict_get_str(qdict
, "device");
871 const char *password
= qdict_get_str(qdict
, "password");
874 qmp_block_passwd(true, device
, false, NULL
, password
, &errp
);
875 hmp_handle_error(mon
, &errp
);
878 void hmp_balloon(Monitor
*mon
, const QDict
*qdict
)
880 int64_t value
= qdict_get_int(qdict
, "value");
883 qmp_balloon(value
, &errp
);
885 monitor_printf(mon
, "balloon: %s\n", error_get_pretty(errp
));
890 void hmp_block_resize(Monitor
*mon
, const QDict
*qdict
)
892 const char *device
= qdict_get_str(qdict
, "device");
893 int64_t size
= qdict_get_int(qdict
, "size");
896 qmp_block_resize(true, device
, false, NULL
, size
, &errp
);
897 hmp_handle_error(mon
, &errp
);
900 void hmp_drive_mirror(Monitor
*mon
, const QDict
*qdict
)
902 const char *device
= qdict_get_str(qdict
, "device");
903 const char *filename
= qdict_get_str(qdict
, "target");
904 const char *format
= qdict_get_try_str(qdict
, "format");
905 int reuse
= qdict_get_try_bool(qdict
, "reuse", 0);
906 int full
= qdict_get_try_bool(qdict
, "full", 0);
907 enum NewImageMode mode
;
911 error_set(&errp
, QERR_MISSING_PARAMETER
, "target");
912 hmp_handle_error(mon
, &errp
);
917 mode
= NEW_IMAGE_MODE_EXISTING
;
919 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
922 qmp_drive_mirror(device
, filename
, !!format
, format
,
923 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
924 true, mode
, false, 0, false, 0, false, 0,
925 false, 0, false, 0, &errp
);
926 hmp_handle_error(mon
, &errp
);
929 void hmp_drive_backup(Monitor
*mon
, const QDict
*qdict
)
931 const char *device
= qdict_get_str(qdict
, "device");
932 const char *filename
= qdict_get_str(qdict
, "target");
933 const char *format
= qdict_get_try_str(qdict
, "format");
934 int reuse
= qdict_get_try_bool(qdict
, "reuse", 0);
935 int full
= qdict_get_try_bool(qdict
, "full", 0);
936 enum NewImageMode mode
;
940 error_set(&errp
, QERR_MISSING_PARAMETER
, "target");
941 hmp_handle_error(mon
, &errp
);
946 mode
= NEW_IMAGE_MODE_EXISTING
;
948 mode
= NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
951 qmp_drive_backup(device
, filename
, !!format
, format
,
952 full
? MIRROR_SYNC_MODE_FULL
: MIRROR_SYNC_MODE_TOP
,
953 true, mode
, false, 0, false, 0, false, 0, &errp
);
954 hmp_handle_error(mon
, &errp
);
957 void hmp_snapshot_blkdev(Monitor
*mon
, const QDict
*qdict
)
959 const char *device
= qdict_get_str(qdict
, "device");
960 const char *filename
= qdict_get_try_str(qdict
, "snapshot-file");
961 const char *format
= qdict_get_try_str(qdict
, "format");
962 int reuse
= qdict_get_try_bool(qdict
, "reuse", 0);
963 enum NewImageMode mode
;
967 /* In the future, if 'snapshot-file' is not specified, the snapshot
968 will be taken internally. Today it's actually required. */
969 error_set(&errp
, QERR_MISSING_PARAMETER
, "snapshot-file");
970 hmp_handle_error(mon
, &errp
);
974 mode
= reuse
? NEW_IMAGE_MODE_EXISTING
: NEW_IMAGE_MODE_ABSOLUTE_PATHS
;
975 qmp_blockdev_snapshot_sync(true, device
, false, NULL
,
976 filename
, false, NULL
,
979 hmp_handle_error(mon
, &errp
);
982 void hmp_snapshot_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
984 const char *device
= qdict_get_str(qdict
, "device");
985 const char *name
= qdict_get_str(qdict
, "name");
988 qmp_blockdev_snapshot_internal_sync(device
, name
, &errp
);
989 hmp_handle_error(mon
, &errp
);
992 void hmp_snapshot_delete_blkdev_internal(Monitor
*mon
, const QDict
*qdict
)
994 const char *device
= qdict_get_str(qdict
, "device");
995 const char *name
= qdict_get_str(qdict
, "name");
996 const char *id
= qdict_get_try_str(qdict
, "id");
999 qmp_blockdev_snapshot_delete_internal_sync(device
, !!id
, id
,
1001 hmp_handle_error(mon
, &errp
);
1004 void hmp_migrate_cancel(Monitor
*mon
, const QDict
*qdict
)
1006 qmp_migrate_cancel(NULL
);
1009 void hmp_migrate_set_downtime(Monitor
*mon
, const QDict
*qdict
)
1011 double value
= qdict_get_double(qdict
, "value");
1012 qmp_migrate_set_downtime(value
, NULL
);
1015 void hmp_migrate_set_cache_size(Monitor
*mon
, const QDict
*qdict
)
1017 int64_t value
= qdict_get_int(qdict
, "value");
1020 qmp_migrate_set_cache_size(value
, &err
);
1022 monitor_printf(mon
, "%s\n", error_get_pretty(err
));
1028 void hmp_migrate_set_speed(Monitor
*mon
, const QDict
*qdict
)
1030 int64_t value
= qdict_get_int(qdict
, "value");
1031 qmp_migrate_set_speed(value
, NULL
);
1034 void hmp_migrate_set_capability(Monitor
*mon
, const QDict
*qdict
)
1036 const char *cap
= qdict_get_str(qdict
, "capability");
1037 bool state
= qdict_get_bool(qdict
, "state");
1039 MigrationCapabilityStatusList
*caps
= g_malloc0(sizeof(*caps
));
1042 for (i
= 0; i
< MIGRATION_CAPABILITY_MAX
; i
++) {
1043 if (strcmp(cap
, MigrationCapability_lookup
[i
]) == 0) {
1044 caps
->value
= g_malloc0(sizeof(*caps
->value
));
1045 caps
->value
->capability
= i
;
1046 caps
->value
->state
= state
;
1048 qmp_migrate_set_capabilities(caps
, &err
);
1053 if (i
== MIGRATION_CAPABILITY_MAX
) {
1054 error_set(&err
, QERR_INVALID_PARAMETER
, cap
);
1057 qapi_free_MigrationCapabilityStatusList(caps
);
1060 monitor_printf(mon
, "migrate_set_capability: %s\n",
1061 error_get_pretty(err
));
1066 void hmp_set_password(Monitor
*mon
, const QDict
*qdict
)
1068 const char *protocol
= qdict_get_str(qdict
, "protocol");
1069 const char *password
= qdict_get_str(qdict
, "password");
1070 const char *connected
= qdict_get_try_str(qdict
, "connected");
1073 qmp_set_password(protocol
, password
, !!connected
, connected
, &err
);
1074 hmp_handle_error(mon
, &err
);
1077 void hmp_expire_password(Monitor
*mon
, const QDict
*qdict
)
1079 const char *protocol
= qdict_get_str(qdict
, "protocol");
1080 const char *whenstr
= qdict_get_str(qdict
, "time");
1083 qmp_expire_password(protocol
, whenstr
, &err
);
1084 hmp_handle_error(mon
, &err
);
1087 void hmp_eject(Monitor
*mon
, const QDict
*qdict
)
1089 int force
= qdict_get_try_bool(qdict
, "force", 0);
1090 const char *device
= qdict_get_str(qdict
, "device");
1093 qmp_eject(device
, true, force
, &err
);
1094 hmp_handle_error(mon
, &err
);
1097 static void hmp_change_read_arg(void *opaque
, const char *password
,
1098 void *readline_opaque
)
1100 qmp_change_vnc_password(password
, NULL
);
1101 monitor_read_command(opaque
, 1);
1104 void hmp_change(Monitor
*mon
, const QDict
*qdict
)
1106 const char *device
= qdict_get_str(qdict
, "device");
1107 const char *target
= qdict_get_str(qdict
, "target");
1108 const char *arg
= qdict_get_try_str(qdict
, "arg");
1111 if (strcmp(device
, "vnc") == 0 &&
1112 (strcmp(target
, "passwd") == 0 ||
1113 strcmp(target
, "password") == 0)) {
1115 monitor_read_password(mon
, hmp_change_read_arg
, NULL
);
1120 qmp_change(device
, target
, !!arg
, arg
, &err
);
1122 error_get_class(err
) == ERROR_CLASS_DEVICE_ENCRYPTED
) {
1124 monitor_read_block_device_key(mon
, device
, NULL
, NULL
);
1127 hmp_handle_error(mon
, &err
);
1130 void hmp_block_set_io_throttle(Monitor
*mon
, const QDict
*qdict
)
1134 qmp_block_set_io_throttle(qdict_get_str(qdict
, "device"),
1135 qdict_get_int(qdict
, "bps"),
1136 qdict_get_int(qdict
, "bps_rd"),
1137 qdict_get_int(qdict
, "bps_wr"),
1138 qdict_get_int(qdict
, "iops"),
1139 qdict_get_int(qdict
, "iops_rd"),
1140 qdict_get_int(qdict
, "iops_wr"),
1141 false, /* no burst max via HMP */
1153 false, /* No default I/O size */
1155 hmp_handle_error(mon
, &err
);
1158 void hmp_block_stream(Monitor
*mon
, const QDict
*qdict
)
1160 Error
*error
= NULL
;
1161 const char *device
= qdict_get_str(qdict
, "device");
1162 const char *base
= qdict_get_try_str(qdict
, "base");
1163 int64_t speed
= qdict_get_try_int(qdict
, "speed", 0);
1165 qmp_block_stream(device
, base
!= NULL
, base
,
1166 qdict_haskey(qdict
, "speed"), speed
,
1167 true, BLOCKDEV_ON_ERROR_REPORT
, &error
);
1169 hmp_handle_error(mon
, &error
);
1172 void hmp_block_job_set_speed(Monitor
*mon
, const QDict
*qdict
)
1174 Error
*error
= NULL
;
1175 const char *device
= qdict_get_str(qdict
, "device");
1176 int64_t value
= qdict_get_int(qdict
, "speed");
1178 qmp_block_job_set_speed(device
, value
, &error
);
1180 hmp_handle_error(mon
, &error
);
1183 void hmp_block_job_cancel(Monitor
*mon
, const QDict
*qdict
)
1185 Error
*error
= NULL
;
1186 const char *device
= qdict_get_str(qdict
, "device");
1187 bool force
= qdict_get_try_bool(qdict
, "force", 0);
1189 qmp_block_job_cancel(device
, true, force
, &error
);
1191 hmp_handle_error(mon
, &error
);
1194 void hmp_block_job_pause(Monitor
*mon
, const QDict
*qdict
)
1196 Error
*error
= NULL
;
1197 const char *device
= qdict_get_str(qdict
, "device");
1199 qmp_block_job_pause(device
, &error
);
1201 hmp_handle_error(mon
, &error
);
1204 void hmp_block_job_resume(Monitor
*mon
, const QDict
*qdict
)
1206 Error
*error
= NULL
;
1207 const char *device
= qdict_get_str(qdict
, "device");
1209 qmp_block_job_resume(device
, &error
);
1211 hmp_handle_error(mon
, &error
);
1214 void hmp_block_job_complete(Monitor
*mon
, const QDict
*qdict
)
1216 Error
*error
= NULL
;
1217 const char *device
= qdict_get_str(qdict
, "device");
1219 qmp_block_job_complete(device
, &error
);
1221 hmp_handle_error(mon
, &error
);
1224 typedef struct MigrationStatus
1228 bool is_block_migration
;
1231 static void hmp_migrate_status_cb(void *opaque
)
1233 MigrationStatus
*status
= opaque
;
1234 MigrationInfo
*info
;
1236 info
= qmp_query_migrate(NULL
);
1237 if (!info
->has_status
|| strcmp(info
->status
, "active") == 0 ||
1238 strcmp(info
->status
, "setup") == 0) {
1239 if (info
->has_disk
) {
1242 if (info
->disk
->remaining
) {
1243 progress
= info
->disk
->transferred
* 100 / info
->disk
->total
;
1248 monitor_printf(status
->mon
, "Completed %d %%\r", progress
);
1249 monitor_flush(status
->mon
);
1252 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
) + 1000);
1254 if (status
->is_block_migration
) {
1255 monitor_printf(status
->mon
, "\n");
1257 monitor_resume(status
->mon
);
1258 timer_del(status
->timer
);
1262 qapi_free_MigrationInfo(info
);
1265 void hmp_migrate(Monitor
*mon
, const QDict
*qdict
)
1267 int detach
= qdict_get_try_bool(qdict
, "detach", 0);
1268 int blk
= qdict_get_try_bool(qdict
, "blk", 0);
1269 int inc
= qdict_get_try_bool(qdict
, "inc", 0);
1270 const char *uri
= qdict_get_str(qdict
, "uri");
1273 qmp_migrate(uri
, !!blk
, blk
, !!inc
, inc
, false, false, &err
);
1275 monitor_printf(mon
, "migrate: %s\n", error_get_pretty(err
));
1281 MigrationStatus
*status
;
1283 if (monitor_suspend(mon
) < 0) {
1284 monitor_printf(mon
, "terminal does not allow synchronous "
1285 "migration, continuing detached\n");
1289 status
= g_malloc0(sizeof(*status
));
1291 status
->is_block_migration
= blk
|| inc
;
1292 status
->timer
= timer_new_ms(QEMU_CLOCK_REALTIME
, hmp_migrate_status_cb
,
1294 timer_mod(status
->timer
, qemu_clock_get_ms(QEMU_CLOCK_REALTIME
));
1298 void hmp_device_del(Monitor
*mon
, const QDict
*qdict
)
1300 const char *id
= qdict_get_str(qdict
, "id");
1303 qmp_device_del(id
, &err
);
1304 hmp_handle_error(mon
, &err
);
1307 void hmp_dump_guest_memory(Monitor
*mon
, const QDict
*qdict
)
1310 int paging
= qdict_get_try_bool(qdict
, "paging", 0);
1311 const char *file
= qdict_get_str(qdict
, "filename");
1312 bool has_begin
= qdict_haskey(qdict
, "begin");
1313 bool has_length
= qdict_haskey(qdict
, "length");
1319 begin
= qdict_get_int(qdict
, "begin");
1322 length
= qdict_get_int(qdict
, "length");
1325 prot
= g_strconcat("file:", file
, NULL
);
1327 qmp_dump_guest_memory(paging
, prot
, has_begin
, begin
, has_length
, length
,
1329 hmp_handle_error(mon
, &errp
);
1333 void hmp_netdev_add(Monitor
*mon
, const QDict
*qdict
)
1338 opts
= qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict
, &err
);
1343 netdev_add(opts
, &err
);
1345 qemu_opts_del(opts
);
1349 hmp_handle_error(mon
, &err
);
1352 void hmp_netdev_del(Monitor
*mon
, const QDict
*qdict
)
1354 const char *id
= qdict_get_str(qdict
, "id");
1357 qmp_netdev_del(id
, &err
);
1358 hmp_handle_error(mon
, &err
);
1361 void hmp_object_add(Monitor
*mon
, const QDict
*qdict
)
1371 opts
= qemu_opts_from_qdict(qemu_find_opts("object"), qdict
, &err
);
1376 ov
= opts_visitor_new(opts
);
1377 pdict
= qdict_clone_shallow(qdict
);
1379 visit_start_struct(opts_get_visitor(ov
), &dummy
, NULL
, NULL
, 0, &err
);
1384 qdict_del(pdict
, "qom-type");
1385 visit_type_str(opts_get_visitor(ov
), &type
, "qom-type", &err
);
1390 qdict_del(pdict
, "id");
1391 visit_type_str(opts_get_visitor(ov
), &id
, "id", &err
);
1396 object_add(type
, id
, pdict
, opts_get_visitor(ov
), &err
);
1400 visit_end_struct(opts_get_visitor(ov
), &err
);
1402 qmp_object_del(id
, NULL
);
1406 opts_visitor_cleanup(ov
);
1409 qemu_opts_del(opts
);
1415 hmp_handle_error(mon
, &err
);
1418 void hmp_getfd(Monitor
*mon
, const QDict
*qdict
)
1420 const char *fdname
= qdict_get_str(qdict
, "fdname");
1423 qmp_getfd(fdname
, &errp
);
1424 hmp_handle_error(mon
, &errp
);
1427 void hmp_closefd(Monitor
*mon
, const QDict
*qdict
)
1429 const char *fdname
= qdict_get_str(qdict
, "fdname");
1432 qmp_closefd(fdname
, &errp
);
1433 hmp_handle_error(mon
, &errp
);
1436 void hmp_send_key(Monitor
*mon
, const QDict
*qdict
)
1438 const char *keys
= qdict_get_str(qdict
, "keys");
1439 KeyValueList
*keylist
, *head
= NULL
, *tmp
= NULL
;
1440 int has_hold_time
= qdict_haskey(qdict
, "hold-time");
1441 int hold_time
= qdict_get_try_int(qdict
, "hold-time", -1);
1443 char keyname_buf
[16];
1448 separator
= strchr(keys
, '-');
1449 keyname_len
= separator
? separator
- keys
: strlen(keys
);
1450 pstrcpy(keyname_buf
, sizeof(keyname_buf
), keys
);
1452 /* Be compatible with old interface, convert user inputted "<" */
1453 if (!strncmp(keyname_buf
, "<", 1) && keyname_len
== 1) {
1454 pstrcpy(keyname_buf
, sizeof(keyname_buf
), "less");
1457 keyname_buf
[keyname_len
] = 0;
1459 keylist
= g_malloc0(sizeof(*keylist
));
1460 keylist
->value
= g_malloc0(sizeof(*keylist
->value
));
1466 tmp
->next
= keylist
;
1470 if (strstart(keyname_buf
, "0x", NULL
)) {
1472 int value
= strtoul(keyname_buf
, &endp
, 0);
1473 if (*endp
!= '\0') {
1476 keylist
->value
->kind
= KEY_VALUE_KIND_NUMBER
;
1477 keylist
->value
->number
= value
;
1479 int idx
= index_from_key(keyname_buf
);
1480 if (idx
== Q_KEY_CODE_MAX
) {
1483 keylist
->value
->kind
= KEY_VALUE_KIND_QCODE
;
1484 keylist
->value
->qcode
= idx
;
1490 keys
= separator
+ 1;
1493 qmp_send_key(head
, has_hold_time
, hold_time
, &err
);
1494 hmp_handle_error(mon
, &err
);
1497 qapi_free_KeyValueList(head
);
1501 monitor_printf(mon
, "invalid parameter: %s\n", keyname_buf
);
1505 void hmp_screen_dump(Monitor
*mon
, const QDict
*qdict
)
1507 const char *filename
= qdict_get_str(qdict
, "filename");
1510 qmp_screendump(filename
, &err
);
1511 hmp_handle_error(mon
, &err
);
1514 void hmp_nbd_server_start(Monitor
*mon
, const QDict
*qdict
)
1516 const char *uri
= qdict_get_str(qdict
, "uri");
1517 int writable
= qdict_get_try_bool(qdict
, "writable", 0);
1518 int all
= qdict_get_try_bool(qdict
, "all", 0);
1519 Error
*local_err
= NULL
;
1520 BlockInfoList
*block_list
, *info
;
1521 SocketAddress
*addr
;
1523 if (writable
&& !all
) {
1524 error_setg(&local_err
, "-w only valid together with -a");
1528 /* First check if the address is valid and start the server. */
1529 addr
= socket_parse(uri
, &local_err
);
1530 if (local_err
!= NULL
) {
1534 qmp_nbd_server_start(addr
, &local_err
);
1535 qapi_free_SocketAddress(addr
);
1536 if (local_err
!= NULL
) {
1544 /* Then try adding all block devices. If one fails, close all and
1547 block_list
= qmp_query_block(NULL
);
1549 for (info
= block_list
; info
; info
= info
->next
) {
1550 if (!info
->value
->has_inserted
) {
1554 qmp_nbd_server_add(info
->value
->device
, true, writable
, &local_err
);
1556 if (local_err
!= NULL
) {
1557 qmp_nbd_server_stop(NULL
);
1562 qapi_free_BlockInfoList(block_list
);
1565 hmp_handle_error(mon
, &local_err
);
1568 void hmp_nbd_server_add(Monitor
*mon
, const QDict
*qdict
)
1570 const char *device
= qdict_get_str(qdict
, "device");
1571 int writable
= qdict_get_try_bool(qdict
, "writable", 0);
1572 Error
*local_err
= NULL
;
1574 qmp_nbd_server_add(device
, true, writable
, &local_err
);
1576 if (local_err
!= NULL
) {
1577 hmp_handle_error(mon
, &local_err
);
1581 void hmp_nbd_server_stop(Monitor
*mon
, const QDict
*qdict
)
1585 qmp_nbd_server_stop(&errp
);
1586 hmp_handle_error(mon
, &errp
);
1589 void hmp_cpu_add(Monitor
*mon
, const QDict
*qdict
)
1594 cpuid
= qdict_get_int(qdict
, "id");
1595 qmp_cpu_add(cpuid
, &err
);
1596 hmp_handle_error(mon
, &err
);
1599 void hmp_chardev_add(Monitor
*mon
, const QDict
*qdict
)
1601 const char *args
= qdict_get_str(qdict
, "args");
1605 opts
= qemu_opts_parse(qemu_find_opts("chardev"), args
, 1);
1607 error_setg(&err
, "Parsing chardev args failed");
1609 qemu_chr_new_from_opts(opts
, NULL
, &err
);
1611 hmp_handle_error(mon
, &err
);
1614 void hmp_chardev_remove(Monitor
*mon
, const QDict
*qdict
)
1616 Error
*local_err
= NULL
;
1618 qmp_chardev_remove(qdict_get_str(qdict
, "id"), &local_err
);
1619 hmp_handle_error(mon
, &local_err
);
1622 void hmp_qemu_io(Monitor
*mon
, const QDict
*qdict
)
1624 BlockDriverState
*bs
;
1625 const char* device
= qdict_get_str(qdict
, "device");
1626 const char* command
= qdict_get_str(qdict
, "command");
1629 bs
= bdrv_find(device
);
1631 qemuio_command(bs
, command
);
1633 error_set(&err
, QERR_DEVICE_NOT_FOUND
, device
);
1636 hmp_handle_error(mon
, &err
);
1639 void hmp_object_del(Monitor
*mon
, const QDict
*qdict
)
1641 const char *id
= qdict_get_str(qdict
, "id");
1644 qmp_object_del(id
, &err
);
1645 hmp_handle_error(mon
, &err
);