Revision af4ce882

b/monitor.c
71 71
typedef struct mon_cmd_t {
72 72
    const char *name;
73 73
    const char *args_type;
74
    void *handler;
75 74
    const char *params;
76 75
    const char *help;
77 76
    union {
78 77
        void (*info)(Monitor *mon);
78
        void (*cmd)(Monitor *mon, const QDict *qdict);
79 79
    } mhandler;
80 80
} mon_cmd_t;
81 81

  
......
3014 3014

  
3015 3015
    cmd = monitor_parse_command(mon, cmdline, qdict);
3016 3016
    if (cmd) {
3017
        void (*handler)(Monitor *mon, const QDict *qdict);
3018

  
3019 3017
        qemu_errors_to_mon(mon);
3020

  
3021
        handler = cmd->handler;
3022
        handler(mon, qdict);
3023

  
3018
        cmd->mhandler.cmd(mon, qdict);
3024 3019
        qemu_errors_to_previous();
3025 3020
    }
3026 3021

  
b/qemu-monitor.hx
12 12
    {
13 13
        .name       = "help|?",
14 14
        .args_type  = "name:s?",
15
        .handler    = do_help_cmd,
16 15
        .params     = "[cmd]",
17 16
        .help       = "show the help",
17
        .mhandler.cmd = do_help_cmd,
18 18
    },
19 19

  
20 20
STEXI
......
25 25
    {
26 26
        .name       = "commit",
27 27
        .args_type  = "device:B",
28
        .handler    = do_commit,
29 28
        .params     = "device|all",
30 29
        .help       = "commit changes to the disk images (if -snapshot is used) or backing files",
30
        .mhandler.cmd = do_commit,
31 31
    },
32 32

  
33 33
STEXI
......
38 38
    {
39 39
        .name       = "info",
40 40
        .args_type  = "item:s?",
41
        .handler    = do_info,
42 41
        .params     = "[subcommand]",
43 42
        .help       = "show various information about the system state",
43
        .mhandler.cmd = do_info,
44 44
    },
45 45

  
46 46
STEXI
......
116 116
    {
117 117
        .name       = "q|quit",
118 118
        .args_type  = "",
119
        .handler    = do_quit,
120 119
        .params     = "",
121 120
        .help       = "quit the emulator",
121
        .mhandler.cmd = do_quit,
122 122
    },
123 123

  
124 124
STEXI
......
129 129
    {
130 130
        .name       = "eject",
131 131
        .args_type  = "force:-f,filename:B",
132
        .handler    = do_eject,
133 132
        .params     = "[-f] device",
134 133
        .help       = "eject a removable medium (use -f to force it)",
134
        .mhandler.cmd = do_eject,
135 135
    },
136 136

  
137 137
STEXI
......
142 142
    {
143 143
        .name       = "change",
144 144
        .args_type  = "device:B,target:F,arg:s?",
145
        .handler    = do_change,
146 145
        .params     = "device filename [format]",
147 146
        .help       = "change a removable medium, optional format",
147
        .mhandler.cmd = do_change,
148 148
    },
149 149

  
150 150
STEXI
......
187 187
    {
188 188
        .name       = "screendump",
189 189
        .args_type  = "filename:F",
190
        .handler    = do_screen_dump,
191 190
        .params     = "filename",
192 191
        .help       = "save screen into PPM image 'filename'",
192
        .mhandler.cmd = do_screen_dump,
193 193
    },
194 194

  
195 195
STEXI
......
200 200
    {
201 201
        .name       = "logfile",
202 202
        .args_type  = "filename:F",
203
        .handler    = do_logfile,
204 203
        .params     = "filename",
205 204
        .help       = "output logs to 'filename'",
205
        .mhandler.cmd = do_logfile,
206 206
    },
207 207

  
208 208
STEXI
......
213 213
    {
214 214
        .name       = "log",
215 215
        .args_type  = "items:s",
216
        .handler    = do_log,
217 216
        .params     = "item1[,...]",
218 217
        .help       = "activate logging of the specified items to '/tmp/qemu.log'",
218
        .mhandler.cmd = do_log,
219 219
    },
220 220

  
221 221
STEXI
......
226 226
    {
227 227
        .name       = "savevm",
228 228
        .args_type  = "name:s?",
229
        .handler    = do_savevm,
230 229
        .params     = "[tag|id]",
231 230
        .help       = "save a VM snapshot. If no tag or id are provided, a new snapshot is created",
231
        .mhandler.cmd = do_savevm,
232 232
    },
233 233

  
234 234
STEXI
......
242 242
    {
243 243
        .name       = "loadvm",
244 244
        .args_type  = "name:s",
245
        .handler    = do_loadvm,
246 245
        .params     = "tag|id",
247 246
        .help       = "restore a VM snapshot from its tag or id",
247
        .mhandler.cmd = do_loadvm,
248 248
    },
249 249

  
250 250
STEXI
......
256 256
    {
257 257
        .name       = "delvm",
258 258
        .args_type  = "name:s",
259
        .handler    = do_delvm,
260 259
        .params     = "tag|id",
261 260
        .help       = "delete a VM snapshot from its tag or id",
261
        .mhandler.cmd = do_delvm,
262 262
    },
263 263

  
264 264
STEXI
......
269 269
    {
270 270
        .name       = "singlestep",
271 271
        .args_type  = "option:s?",
272
        .handler    = do_singlestep,
273 272
        .params     = "[on|off]",
274 273
        .help       = "run emulation in singlestep mode or switch to normal mode",
274
        .mhandler.cmd = do_singlestep,
275 275
    },
276 276

  
277 277
STEXI
......
283 283
    {
284 284
        .name       = "stop",
285 285
        .args_type  = "",
286
        .handler    = do_stop,
287 286
        .params     = "",
288 287
        .help       = "stop emulation",
288
        .mhandler.cmd = do_stop,
289 289
    },
290 290

  
291 291
STEXI
......
296 296
    {
297 297
        .name       = "c|cont",
298 298
        .args_type  = "",
299
        .handler    = do_cont,
300 299
        .params     = "",
301 300
        .help       = "resume emulation",
301
        .mhandler.cmd = do_cont,
302 302
    },
303 303

  
304 304
STEXI
......
309 309
    {
310 310
        .name       = "gdbserver",
311 311
        .args_type  = "device:s?",
312
        .handler    = do_gdbserver,
313 312
        .params     = "[device]",
314 313
        .help       = "start gdbserver on given device (default 'tcp::1234'), stop with 'none'",
314
        .mhandler.cmd = do_gdbserver,
315 315
    },
316 316

  
317 317
STEXI
......
322 322
    {
323 323
        .name       = "x",
324 324
        .args_type  = "fmt:/,addr:l",
325
        .handler    = do_memory_dump,
326 325
        .params     = "/fmt addr",
327 326
        .help       = "virtual memory dump starting at 'addr'",
327
        .mhandler.cmd = do_memory_dump,
328 328
    },
329 329

  
330 330
STEXI
......
335 335
    {
336 336
        .name       = "xp",
337 337
        .args_type  = "fmt:/,addr:l",
338
        .handler    = do_physical_memory_dump,
339 338
        .params     = "/fmt addr",
340 339
        .help       = "physical memory dump starting at 'addr'",
340
        .mhandler.cmd = do_physical_memory_dump,
341 341
    },
342 342

  
343 343
STEXI
......
401 401
    {
402 402
        .name       = "p|print",
403 403
        .args_type  = "fmt:/,val:l",
404
        .handler    = do_print,
405 404
        .params     = "/fmt expr",
406 405
        .help       = "print expression value (use $reg for CPU register access)",
406
        .mhandler.cmd = do_print,
407 407
    },
408 408

  
409 409
STEXI
......
416 416
    {
417 417
        .name       = "i",
418 418
        .args_type  = "fmt:/,addr:i,index:i.",
419
        .handler    = do_ioport_read,
420 419
        .params     = "/fmt addr",
421 420
        .help       = "I/O port read",
421
        .mhandler.cmd = do_ioport_read,
422 422
    },
423 423

  
424 424
STEXI
......
428 428
    {
429 429
        .name       = "o",
430 430
        .args_type  = "fmt:/,addr:i,val:i",
431
        .handler    = do_ioport_write,
432 431
        .params     = "/fmt addr value",
433 432
        .help       = "I/O port write",
433
        .mhandler.cmd = do_ioport_write,
434 434
    },
435 435

  
436 436
STEXI
......
440 440
    {
441 441
        .name       = "sendkey",
442 442
        .args_type  = "string:s,hold_time:i?",
443
        .handler    = do_sendkey,
444 443
        .params     = "keys [hold_ms]",
445 444
        .help       = "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)",
445
        .mhandler.cmd = do_sendkey,
446 446
    },
447 447

  
448 448
STEXI
......
462 462
    {
463 463
        .name       = "system_reset",
464 464
        .args_type  = "",
465
        .handler    = do_system_reset,
466 465
        .params     = "",
467 466
        .help       = "reset the system",
467
        .mhandler.cmd = do_system_reset,
468 468
    },
469 469

  
470 470
STEXI
......
476 476
    {
477 477
        .name       = "system_powerdown",
478 478
        .args_type  = "",
479
        .handler    = do_system_powerdown,
480 479
        .params     = "",
481 480
        .help       = "send system power down event",
481
        .mhandler.cmd = do_system_powerdown,
482 482
    },
483 483

  
484 484
STEXI
......
490 490
    {
491 491
        .name       = "sum",
492 492
        .args_type  = "start:i,size:i",
493
        .handler    = do_sum,
494 493
        .params     = "addr size",
495 494
        .help       = "compute the checksum of a memory region",
495
        .mhandler.cmd = do_sum,
496 496
    },
497 497

  
498 498
STEXI
......
504 504
    {
505 505
        .name       = "usb_add",
506 506
        .args_type  = "devname:s",
507
        .handler    = do_usb_add,
508 507
        .params     = "device",
509 508
        .help       = "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')",
509
        .mhandler.cmd = do_usb_add,
510 510
    },
511 511

  
512 512
STEXI
......
519 519
    {
520 520
        .name       = "usb_del",
521 521
        .args_type  = "devname:s",
522
        .handler    = do_usb_del,
523 522
        .params     = "device",
524 523
        .help       = "remove USB device 'bus.addr'",
524
        .mhandler.cmd = do_usb_del,
525 525
    },
526 526

  
527 527
STEXI
......
535 535
    {
536 536
        .name       = "device_add",
537 537
        .args_type  = "config:s",
538
        .handler    = do_device_add,
539 538
        .params     = "device",
540 539
        .help       = "add device, like -device on the command line",
540
        .mhandler.cmd = do_device_add,
541 541
    },
542 542

  
543 543
STEXI
......
549 549
    {
550 550
        .name       = "device_del",
551 551
        .args_type  = "id:s",
552
        .handler    = do_device_del,
553 552
        .params     = "device",
554 553
        .help       = "remove device",
554
        .mhandler.cmd = do_device_del,
555 555
    },
556 556

  
557 557
STEXI
......
563 563
    {
564 564
        .name       = "cpu",
565 565
        .args_type  = "index:i",
566
        .handler    = do_cpu_set,
567 566
        .params     = "index",
568 567
        .help       = "set the default CPU",
568
        .mhandler.cmd = do_cpu_set,
569 569
    },
570 570

  
571 571
STEXI
......
575 575
    {
576 576
        .name       = "mouse_move",
577 577
        .args_type  = "dx_str:s,dy_str:s,dz_str:s?",
578
        .handler    = do_mouse_move,
579 578
        .params     = "dx dy [dz]",
580 579
        .help       = "send mouse move events",
580
        .mhandler.cmd = do_mouse_move,
581 581
    },
582 582

  
583 583
STEXI
......
589 589
    {
590 590
        .name       = "mouse_button",
591 591
        .args_type  = "button_state:i",
592
        .handler    = do_mouse_button,
593 592
        .params     = "state",
594 593
        .help       = "change mouse button state (1=L, 2=M, 4=R)",
594
        .mhandler.cmd = do_mouse_button,
595 595
    },
596 596

  
597 597
STEXI
......
602 602
    {
603 603
        .name       = "mouse_set",
604 604
        .args_type  = "index:i",
605
        .handler    = do_mouse_set,
606 605
        .params     = "index",
607 606
        .help       = "set which mouse device receives events",
607
        .mhandler.cmd = do_mouse_set,
608 608
    },
609 609

  
610 610
STEXI
......
620 620
    {
621 621
        .name       = "wavcapture",
622 622
        .args_type  = "path:F,freq:i?,bits:i?,nchannels:i?",
623
        .handler    = do_wav_capture,
624 623
        .params     = "path [frequency [bits [channels]]]",
625 624
        .help       = "capture audio to a wave file (default frequency=44100 bits=16 channels=2)",
625
        .mhandler.cmd = do_wav_capture,
626 626
    },
627 627
#endif
628 628
STEXI
......
642 642
    {
643 643
        .name       = "stopcapture",
644 644
        .args_type  = "n:i",
645
        .handler    = do_stop_capture,
646 645
        .params     = "capture index",
647 646
        .help       = "stop capture",
647
        .mhandler.cmd = do_stop_capture,
648 648
    },
649 649
#endif
650 650
STEXI
......
658 658
    {
659 659
        .name       = "memsave",
660 660
        .args_type  = "val:l,size:i,filename:s",
661
        .handler    = do_memory_save,
662 661
        .params     = "addr size file",
663 662
        .help       = "save to disk virtual memory dump starting at 'addr' of size 'size'",
663
        .mhandler.cmd = do_memory_save,
664 664
    },
665 665

  
666 666
STEXI
......
671 671
    {
672 672
        .name       = "pmemsave",
673 673
        .args_type  = "val:l,size:i,filename:s",
674
        .handler    = do_physical_memory_save,
675 674
        .params     = "addr size file",
676 675
        .help       = "save to disk physical memory dump starting at 'addr' of size 'size'",
676
        .mhandler.cmd = do_physical_memory_save,
677 677
    },
678 678

  
679 679
STEXI
......
684 684
    {
685 685
        .name       = "boot_set",
686 686
        .args_type  = "bootdevice:s",
687
        .handler    = do_boot_set,
688 687
        .params     = "bootdevice",
689 688
        .help       = "define new values for the boot device list",
689
        .mhandler.cmd = do_boot_set,
690 690
    },
691 691

  
692 692
STEXI
......
703 703
    {
704 704
        .name       = "nmi",
705 705
        .args_type  = "cpu_index:i",
706
        .handler    = do_inject_nmi,
707 706
        .params     = "cpu",
708 707
        .help       = "inject an NMI on the given CPU",
708
        .mhandler.cmd = do_inject_nmi,
709 709
    },
710 710
#endif
711 711
STEXI
......
716 716
    {
717 717
        .name       = "migrate",
718 718
        .args_type  = "detach:-d,uri:s",
719
        .handler    = do_migrate,
720 719
        .params     = "[-d] uri",
721 720
        .help       = "migrate to URI (using -d to not wait for completion)",
721
        .mhandler.cmd = do_migrate,
722 722
    },
723 723

  
724 724
STEXI
......
729 729
    {
730 730
        .name       = "migrate_cancel",
731 731
        .args_type  = "",
732
        .handler    = do_migrate_cancel,
733 732
        .params     = "",
734 733
        .help       = "cancel the current VM migration",
734
        .mhandler.cmd = do_migrate_cancel,
735 735
    },
736 736

  
737 737
STEXI
......
742 742
    {
743 743
        .name       = "migrate_set_speed",
744 744
        .args_type  = "value:s",
745
        .handler    = do_migrate_set_speed,
746 745
        .params     = "value",
747 746
        .help       = "set maximum speed (in bytes) for migrations",
747
        .mhandler.cmd = do_migrate_set_speed,
748 748
    },
749 749

  
750 750
STEXI
......
755 755
    {
756 756
        .name       = "migrate_set_downtime",
757 757
        .args_type  = "value:s",
758
        .handler    = do_migrate_set_downtime,
759 758
        .params     = "value",
760 759
        .help       = "set maximum tolerated downtime (in seconds) for migrations",
760
        .mhandler.cmd = do_migrate_set_downtime,
761 761
    },
762 762

  
763 763
STEXI
......
769 769
    {
770 770
        .name       = "drive_add",
771 771
        .args_type  = "pci_addr:s,opts:s",
772
        .handler    = drive_hot_add,
773 772
        .params     = "[[<domain>:]<bus>:]<slot>\n"
774 773
                      "[file=file][,if=type][,bus=n]\n"
775 774
                      "[,unit=m][,media=d][index=i]\n"
776 775
                      "[,cyls=c,heads=h,secs=s[,trans=t]]\n"
777 776
                      "[snapshot=on|off][,cache=on|off]",
778 777
        .help       = "add drive to PCI storage controller",
778
        .mhandler.cmd = drive_hot_add,
779 779
    },
780 780
#endif
781 781

  
......
788 788
    {
789 789
        .name       = "pci_add",
790 790
        .args_type  = "pci_addr:s,type:s,opts:s?",
791
        .handler    = pci_device_hot_add,
792 791
        .params     = "auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...",
793 792
        .help       = "hot-add PCI device",
793
        .mhandler.cmd = pci_device_hot_add,
794 794
    },
795 795
#endif
796 796

  
......
803 803
    {
804 804
        .name       = "pci_del",
805 805
        .args_type  = "pci_addr:s",
806
        .handler    = do_pci_device_hot_remove,
807 806
        .params     = "[[<domain>:]<bus>:]<slot>",
808 807
        .help       = "hot remove PCI device",
808
        .mhandler.cmd = do_pci_device_hot_remove,
809 809
    },
810 810
#endif
811 811

  
......
817 817
    {
818 818
        .name       = "host_net_add",
819 819
        .args_type  = "device:s,opts:s?",
820
        .handler    = net_host_device_add,
821 820
        .params     = "tap|user|socket|vde|dump [options]",
822 821
        .help       = "add host VLAN client",
822
        .mhandler.cmd = net_host_device_add,
823 823
    },
824 824

  
825 825
STEXI
......
830 830
    {
831 831
        .name       = "host_net_remove",
832 832
        .args_type  = "vlan_id:i,device:s",
833
        .handler    = net_host_device_remove,
834 833
        .params     = "vlan_id name",
835 834
        .help       = "remove host VLAN client",
835
        .mhandler.cmd = net_host_device_remove,
836 836
    },
837 837

  
838 838
STEXI
......
844 844
    {
845 845
        .name       = "hostfwd_add",
846 846
        .args_type  = "arg1:s,arg2:s?,arg3:s?",
847
        .handler    = net_slirp_hostfwd_add,
848 847
        .params     = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
849 848
        .help       = "redirect TCP or UDP connections from host to guest (requires -net user)",
849
        .mhandler.cmd = net_slirp_hostfwd_add,
850 850
    },
851 851

  
852 852
    {
853 853
        .name       = "hostfwd_remove",
854 854
        .args_type  = "arg1:s,arg2:s?,arg3:s?",
855
        .handler    = net_slirp_hostfwd_remove,
856 855
        .params     = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport",
857 856
        .help       = "remove host-to-guest TCP or UDP redirection",
857
        .mhandler.cmd = net_slirp_hostfwd_remove,
858 858
    },
859 859

  
860 860
#endif
......
866 866
    {
867 867
        .name       = "balloon",
868 868
        .args_type  = "value:i",
869
        .handler    = do_balloon,
870 869
        .params     = "target",
871 870
        .help       = "request VM to change it's memory allocation (in MB)",
871
        .mhandler.cmd = do_balloon,
872 872
    },
873 873

  
874 874
STEXI
......
879 879
    {
880 880
        .name       = "set_link",
881 881
        .args_type  = "name:s,up_or_down:s",
882
        .handler    = do_set_link,
883 882
        .params     = "name up|down",
884 883
        .help       = "change the link status of a network adapter",
884
        .mhandler.cmd = do_set_link,
885 885
    },
886 886

  
887 887
STEXI
......
892 892
    {
893 893
        .name       = "watchdog_action",
894 894
        .args_type  = "action:s",
895
        .handler    = do_watchdog_action,
896 895
        .params     = "[reset|shutdown|poweroff|pause|debug|none]",
897 896
        .help       = "change watchdog action",
897
        .mhandler.cmd = do_watchdog_action,
898 898
    },
899 899

  
900 900
STEXI
......
905 905
    {
906 906
        .name       = "acl_show",
907 907
        .args_type  = "aclname:s",
908
        .handler    = do_acl_show,
909 908
        .params     = "aclname",
910 909
        .help       = "list rules in the access control list",
910
        .mhandler.cmd = do_acl_show,
911 911
    },
912 912

  
913 913
STEXI
......
921 921
    {
922 922
        .name       = "acl_policy",
923 923
        .args_type  = "aclname:s,policy:s",
924
        .handler    = do_acl_policy,
925 924
        .params     = "aclname allow|deny",
926 925
        .help       = "set default access control list policy",
926
        .mhandler.cmd = do_acl_policy,
927 927
    },
928 928

  
929 929
STEXI
......
936 936
    {
937 937
        .name       = "acl_add",
938 938
        .args_type  = "aclname:s,match:s,policy:s,index:i?",
939
        .handler    = do_acl_add,
940 939
        .params     = "aclname match allow|deny [index]",
941 940
        .help       = "add a match rule to the access control list",
941
        .mhandler.cmd = do_acl_add,
942 942
    },
943 943

  
944 944
STEXI
......
954 954
    {
955 955
        .name       = "acl_remove",
956 956
        .args_type  = "aclname:s,match:s",
957
        .handler    = do_acl_remove,
958 957
        .params     = "aclname match",
959 958
        .help       = "remove a match rule from the access control list",
959
        .mhandler.cmd = do_acl_remove,
960 960
    },
961 961

  
962 962
STEXI
......
967 967
    {
968 968
        .name       = "acl_reset",
969 969
        .args_type  = "aclname:s",
970
        .handler    = do_acl_reset,
971 970
        .params     = "aclname",
972 971
        .help       = "reset the access control list",
972
        .mhandler.cmd = do_acl_reset,
973 973
    },
974 974

  
975 975
STEXI
......
983 983
    {
984 984
        .name       = "mce",
985 985
        .args_type  = "cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l",
986
        .handler    = do_inject_mce,
987 986
        .params     = "cpu bank status mcgstatus addr misc",
988 987
        .help       = "inject a MCE on the given CPU",
988
        .mhandler.cmd = do_inject_mce,
989 989
    },
990 990

  
991 991
#endif
......
997 997
    {
998 998
        .name       = "getfd",
999 999
        .args_type  = "fdname:s",
1000
        .handler    = do_getfd,
1001 1000
        .params     = "getfd name",
1002 1001
        .help       = "receive a file descriptor via SCM rights and assign it a name",
1002
        .mhandler.cmd = do_getfd,
1003 1003
    },
1004 1004

  
1005 1005
STEXI
......
1012 1012
    {
1013 1013
        .name       = "closefd",
1014 1014
        .args_type  = "fdname:s",
1015
        .handler    = do_closefd,
1016 1015
        .params     = "closefd name",
1017 1016
        .help       = "close a file descriptor previously passed via SCM rights",
1017
        .mhandler.cmd = do_closefd,
1018 1018
    },
1019 1019

  
1020 1020
STEXI

Also available in: Unified diff