Revision 4d76d2ba

b/monitor.c
2508 2508
    return p;
2509 2509
}
2510 2510

  
2511
/**
2512
 * Read key of 'type' into 'key' and return the current
2513
 * 'type' pointer.
2514
 */
2515
static char *key_get_info(const char *type, char **key)
2516
{
2517
    size_t len;
2518
    char *p, *str;
2519

  
2520
    if (*type == ',')
2521
        type++;
2522

  
2523
    p = strchr(type, ':');
2524
    if (!p) {
2525
        *key = NULL;
2526
        return NULL;
2527
    }
2528
    len = p - type;
2529

  
2530
    str = qemu_malloc(len + 1);
2531
    memcpy(str, type, len);
2532
    str[len] = '\0';
2533

  
2534
    *key = str;
2535
    return ++p;
2536
}
2537

  
2511 2538
static int default_fmt_format = 'x';
2512 2539
static int default_fmt_size = 4;
2513 2540

  
......
2520 2547
    const mon_cmd_t *cmd;
2521 2548
    char cmdname[256];
2522 2549
    char buf[1024];
2550
    char *key;
2523 2551
    void *str_allocated[MAX_ARGS];
2524 2552
    void *args[MAX_ARGS];
2525 2553
    void (*handler_0)(Monitor *mon);
......
2571 2599
    typestr = cmd->args_type;
2572 2600
    nb_args = 0;
2573 2601
    for(;;) {
2574
        c = *typestr;
2575
        if (c == '\0')
2602
        typestr = key_get_info(typestr, &key);
2603
        if (!typestr)
2576 2604
            break;
2605
        c = *typestr;
2577 2606
        typestr++;
2578 2607
        switch(c) {
2579 2608
        case 'F':
......
2787 2816
            monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);
2788 2817
            goto fail;
2789 2818
        }
2819
        qemu_free(key);
2820
        key = NULL;
2790 2821
    }
2791 2822
    /* check that all arguments were parsed */
2792 2823
    while (qemu_isspace(*p))
......
2854 2885
    qemu_errors_to_previous();
2855 2886

  
2856 2887
 fail:
2888
    qemu_free(key);
2857 2889
    for(i = 0; i < MAX_ARGS; i++)
2858 2890
        qemu_free(str_allocated[i]);
2859 2891
}
......
2972 3004
    *pnb_args = nb_args;
2973 3005
}
2974 3006

  
3007
static const char *next_arg_type(const char *typestr)
3008
{
3009
    const char *p = strchr(typestr, ':');
3010
    return (p != NULL ? ++p : typestr);
3011
}
3012

  
2975 3013
static void monitor_find_completion(const char *cmdline)
2976 3014
{
2977 3015
    const char *cmdname;
......
3014 3052
        }
3015 3053
        return;
3016 3054
    found:
3017
        ptype = cmd->args_type;
3055
        ptype = next_arg_type(cmd->args_type);
3018 3056
        for(i = 0; i < nb_args - 2; i++) {
3019 3057
            if (*ptype != '\0') {
3020
                ptype++;
3058
                ptype = next_arg_type(ptype);
3021 3059
                while (*ptype == '?')
3022
                    ptype++;
3060
                    ptype = next_arg_type(ptype);
3023 3061
            }
3024 3062
        }
3025 3063
        str = args[nb_args - 1];
b/qemu-monitor.hx
9 9
@table @option
10 10
ETEXI
11 11

  
12
    { "help|?", "s?", do_help_cmd, "[cmd]", "show the help" },
12
    { "help|?", "name:s?", do_help_cmd, "[cmd]", "show the help" },
13 13
STEXI
14 14
@item help or ? [@var{cmd}]
15 15
Show the help for all commands or just for command @var{cmd}.
16 16
ETEXI
17 17

  
18
    { "commit", "s", do_commit,
18
    { "commit", "device:s", do_commit,
19 19
      "device|all", "commit changes to the disk images (if -snapshot is used) or backing files" },
20 20
STEXI
21 21
@item commit
22 22
Commit changes to the disk images (if -snapshot is used) or backing files.
23 23
ETEXI
24 24

  
25
    { "info", "s?", do_info,
25
    { "info", "item:s?", do_info,
26 26
      "[subcommand]", "show various information about the system state" },
27 27
STEXI
28 28
@item info @var{subcommand}
......
101 101
Quit the emulator.
102 102
ETEXI
103 103

  
104
    { "eject", "-fB", do_eject,
104
    { "eject", "force:-f,filename:B", do_eject,
105 105
      "[-f] device", "eject a removable medium (use -f to force it)" },
106 106
STEXI
107 107
@item eject [-f] @var{device}
108 108
Eject a removable medium (use -f to force it).
109 109
ETEXI
110 110

  
111
    { "change", "BFs?", do_change,
111
    { "change", "device:B,target:F,arg:s?", do_change,
112 112
      "device filename [format]", "change a removable medium, optional format" },
113 113
STEXI
114 114
@item change @var{device} @var{setting}
......
147 147
@end table
148 148
ETEXI
149 149

  
150
    { "screendump", "F", do_screen_dump,
150
    { "screendump", "filename:F", do_screen_dump,
151 151
      "filename", "save screen into PPM image 'filename'" },
152 152
STEXI
153 153
@item screendump @var{filename}
154 154
Save screen into PPM image @var{filename}.
155 155
ETEXI
156 156

  
157
    { "logfile", "F", do_logfile,
157
    { "logfile", "filename:F", do_logfile,
158 158
      "filename", "output logs to 'filename'" },
159 159
STEXI
160 160
@item logfile @var{filename}
161 161
Output logs to @var{filename}.
162 162
ETEXI
163 163

  
164
    { "log", "s", do_log,
164
    { "log", "items:s", do_log,
165 165
      "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" },
166 166
STEXI
167 167
@item log @var{item1}[,...]
168 168
Activate logging of the specified items to @file{/tmp/qemu.log}.
169 169
ETEXI
170 170

  
171
    { "savevm", "s?", do_savevm,
171
    { "savevm", "name:s?", do_savevm,
172 172
      "[tag|id]", "save a VM snapshot. If no tag or id are provided, a new snapshot is created" },
173 173
STEXI
174 174
@item savevm [@var{tag}|@var{id}]
......
178 178
@ref{vm_snapshots}.
179 179
ETEXI
180 180

  
181
    { "loadvm", "s", do_loadvm,
181
    { "loadvm", "name:s", do_loadvm,
182 182
      "tag|id", "restore a VM snapshot from its tag or id" },
183 183
STEXI
184 184
@item loadvm @var{tag}|@var{id}
......
186 186
@var{tag} or the unique snapshot ID @var{id}.
187 187
ETEXI
188 188

  
189
    { "delvm", "s", do_delvm,
189
    { "delvm", "name:s", do_delvm,
190 190
      "tag|id", "delete a VM snapshot from its tag or id" },
191 191
STEXI
192 192
@item delvm @var{tag}|@var{id}
193 193
Delete the snapshot identified by @var{tag} or @var{id}.
194 194
ETEXI
195 195

  
196
    { "singlestep", "s?", do_singlestep,
196
    { "singlestep", "option:s?", do_singlestep,
197 197
      "[on|off]", "run emulation in singlestep mode or switch to normal mode", },
198 198
STEXI
199 199
@item singlestep [off]
......
215 215
Resume emulation.
216 216
ETEXI
217 217

  
218
    { "gdbserver", "s?", do_gdbserver,
218
    { "gdbserver", "device:s?", do_gdbserver,
219 219
      "[device]", "start gdbserver on given device (default 'tcp::1234'), stop with 'none'", },
220 220
STEXI
221 221
@item gdbserver [@var{port}]
222 222
Start gdbserver session (default @var{port}=1234)
223 223
ETEXI
224 224

  
225
    { "x", "/l", do_memory_dump,
225
    { "x", "fmt:/,addr:l", do_memory_dump,
226 226
      "/fmt addr", "virtual memory dump starting at 'addr'", },
227 227
STEXI
228 228
@item x/fmt @var{addr}
229 229
Virtual memory dump starting at @var{addr}.
230 230
ETEXI
231 231

  
232
    { "xp", "/l", do_physical_memory_dump,
232
    { "xp", "fmt:/,addr:l", do_physical_memory_dump,
233 233
      "/fmt addr", "physical memory dump starting at 'addr'", },
234 234
STEXI
235 235
@item xp /@var{fmt} @var{addr}
......
289 289
@end itemize
290 290
ETEXI
291 291

  
292
    { "p|print", "/l", do_print,
292
    { "p|print", "fmt:/,val:l", do_print,
293 293
      "/fmt expr", "print expression value (use $reg for CPU register access)", },
294 294
STEXI
295 295
@item p or print/@var{fmt} @var{expr}
......
298 298
used.
299 299
ETEXI
300 300

  
301
    { "i", "/ii.", do_ioport_read,
301
    { "i", "fmt:/,addr:i,index:i.", do_ioport_read,
302 302
      "/fmt addr", "I/O port read" },
303 303
STEXI
304 304
Read I/O port.
305 305
ETEXI
306 306

  
307
    { "o", "/ii", do_ioport_write,
307
    { "o", "fmt:/,addr:i,val:i", do_ioport_write,
308 308
      "/fmt addr value", "I/O port write" },
309 309
STEXI
310 310
Write to I/O port.
311 311
ETEXI
312 312

  
313
    { "sendkey", "si?", do_sendkey,
313
    { "sendkey", "string:s,hold_time:i?", do_sendkey,
314 314
      "keys [hold_ms]", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)" },
315 315
STEXI
316 316
@item sendkey @var{keys}
......
342 342
Power down the system (if supported).
343 343
ETEXI
344 344

  
345
    { "sum", "ii", do_sum,
345
    { "sum", "start:i,size:i", do_sum,
346 346
      "addr size", "compute the checksum of a memory region" },
347 347
STEXI
348 348
@item sum @var{addr} @var{size}
......
350 350
Compute the checksum of a memory region.
351 351
ETEXI
352 352

  
353
    { "usb_add", "s", do_usb_add,
353
    { "usb_add", "devname:s", do_usb_add,
354 354
      "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" },
355 355
STEXI
356 356
@item usb_add @var{devname}
......
359 359
@ref{usb_devices}
360 360
ETEXI
361 361

  
362
    { "usb_del", "s", do_usb_del,
362
    { "usb_del", "devname:s", do_usb_del,
363 363
      "device", "remove USB device 'bus.addr'" },
364 364
STEXI
365 365
@item usb_del @var{devname}
......
369 369
command @code{info usb} to see the devices you can remove.
370 370
ETEXI
371 371

  
372
    { "cpu", "i", do_cpu_set,
372
    { "cpu", "index:i", do_cpu_set,
373 373
      "index", "set the default CPU" },
374 374
STEXI
375 375
Set the default CPU.
376 376
ETEXI
377 377

  
378
    { "mouse_move", "sss?", do_mouse_move,
378
    { "mouse_move", "dx_str:s,dy_str:s,dz_str:s?", do_mouse_move,
379 379
      "dx dy [dz]", "send mouse move events" },
380 380
STEXI
381 381
@item mouse_move @var{dx} @var{dy} [@var{dz}]
......
383 383
with optional scroll axis @var{dz}.
384 384
ETEXI
385 385

  
386
    { "mouse_button", "i", do_mouse_button,
386
    { "mouse_button", "button_state:i", do_mouse_button,
387 387
      "state", "change mouse button state (1=L, 2=M, 4=R)" },
388 388
STEXI
389 389
@item mouse_button @var{val}
390 390
Change the active mouse button state @var{val} (1=L, 2=M, 4=R).
391 391
ETEXI
392 392

  
393
    { "mouse_set", "i", do_mouse_set,
393
    { "mouse_set", "index:i", do_mouse_set,
394 394
      "index", "set which mouse device receives events" },
395 395
STEXI
396 396
@item mouse_set @var{index}
......
402 402
ETEXI
403 403

  
404 404
#ifdef HAS_AUDIO
405
    { "wavcapture", "si?i?i?", do_wav_capture,
405
    { "wavcapture", "path:s,freq:i?,bits:i?,nchannels:i?", do_wav_capture,
406 406
      "path [frequency [bits [channels]]]",
407 407
      "capture audio to a wave file (default frequency=44100 bits=16 channels=2)" },
408 408
#endif
......
420 420
ETEXI
421 421

  
422 422
#ifdef HAS_AUDIO
423
    { "stopcapture", "i", do_stop_capture,
423
    { "stopcapture", "n:i", do_stop_capture,
424 424
      "capture index", "stop capture" },
425 425
#endif
426 426
STEXI
......
431 431
@end example
432 432
ETEXI
433 433

  
434
    { "memsave", "lis", do_memory_save,
434
    { "memsave", "val:l,size:i,filename:s", do_memory_save,
435 435
      "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", },
436 436
STEXI
437 437
@item memsave @var{addr} @var{size} @var{file}
438 438
save to disk virtual memory dump starting at @var{addr} of size @var{size}.
439 439
ETEXI
440 440

  
441
    { "pmemsave", "lis", do_physical_memory_save,
441
    { "pmemsave", "val:l,size:i,filename:s", do_physical_memory_save,
442 442
      "addr size file", "save to disk physical memory dump starting at 'addr' of size 'size'", },
443 443
STEXI
444 444
@item pmemsave @var{addr} @var{size} @var{file}
445 445
save to disk physical memory dump starting at @var{addr} of size @var{size}.
446 446
ETEXI
447 447

  
448
    { "boot_set", "s", do_boot_set,
448
    { "boot_set", "bootdevice:s", do_boot_set,
449 449
      "bootdevice", "define new values for the boot device list" },
450 450
STEXI
451 451
@item boot_set @var{bootdevicelist}
......
458 458
ETEXI
459 459

  
460 460
#if defined(TARGET_I386)
461
    { "nmi", "i", do_inject_nmi,
461
    { "nmi", "cpu_index:i", do_inject_nmi,
462 462
      "cpu", "inject an NMI on the given CPU", },
463 463
#endif
464 464
STEXI
......
466 466
Inject an NMI on the given CPU (x86 only).
467 467
ETEXI
468 468

  
469
    { "migrate", "-ds", do_migrate,
469
    { "migrate", "detach:-d,uri:s", do_migrate,
470 470
      "[-d] uri", "migrate to URI (using -d to not wait for completion)" },
471 471
STEXI
472 472
@item migrate [-d] @var{uri}
......
480 480
Cancel the current VM migration.
481 481
ETEXI
482 482

  
483
    { "migrate_set_speed", "s", do_migrate_set_speed,
483
    { "migrate_set_speed", "value:s", do_migrate_set_speed,
484 484
      "value", "set maximum speed (in bytes) for migrations" },
485 485
STEXI
486 486
@item migrate_set_speed @var{value}
487 487
Set maximum speed to @var{value} (in bytes) for migrations.
488 488
ETEXI
489 489

  
490
    { "migrate_set_downtime", "s", do_migrate_set_downtime,
490
    { "migrate_set_downtime", "value:s", do_migrate_set_downtime,
491 491
      "value", "set maximum tolerated downtime (in seconds) for migrations" },
492 492

  
493 493
STEXI
......
496 496
ETEXI
497 497

  
498 498
#if defined(TARGET_I386)
499
    { "drive_add", "ss", drive_hot_add, "[[<domain>:]<bus>:]<slot>\n"
500
                                         "[file=file][,if=type][,bus=n]\n"
499
    { "drive_add", "pci_addr:s,opts:s", drive_hot_add,
500
                                        "[[<domain>:]<bus>:]<slot>\n"
501
                                        "[file=file][,if=type][,bus=n]\n"
501 502
                                        "[,unit=m][,media=d][index=i]\n"
502 503
                                        "[,cyls=c,heads=h,secs=s[,trans=t]]\n"
503 504
                                        "[snapshot=on|off][,cache=on|off]",
......
509 510
ETEXI
510 511

  
511 512
#if defined(TARGET_I386)
512
    { "pci_add", "sss?", pci_device_hot_add, "auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" },
513
    { "pci_add", "pci_addr:s,type:s,opts:s?", pci_device_hot_add, "auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" },
513 514
#endif
514 515
STEXI
515 516
@item pci_add
......
517 518
ETEXI
518 519

  
519 520
#if defined(TARGET_I386)
520
    { "pci_del", "s", do_pci_device_hot_remove, "[[<domain>:]<bus>:]<slot>", "hot remove PCI device" },
521
    { "pci_del", "pci_addr:s", do_pci_device_hot_remove, "[[<domain>:]<bus>:]<slot>", "hot remove PCI device" },
521 522
#endif
522 523
STEXI
523 524
@item pci_del
524 525
Hot remove PCI device.
525 526
ETEXI
526 527

  
527
    { "host_net_add", "ss?", net_host_device_add,
528
    { "host_net_add", "device:s,opts:s?", net_host_device_add,
528 529
      "tap|user|socket|vde|dump [options]", "add host VLAN client" },
529 530
STEXI
530 531
@item host_net_add
531 532
Add host VLAN client.
532 533
ETEXI
533 534

  
534
    { "host_net_remove", "is", net_host_device_remove,
535
    { "host_net_remove", "vlan_id:i,device:s", net_host_device_remove,
535 536
      "vlan_id name", "remove host VLAN client" },
536 537
STEXI
537 538
@item host_net_remove
......
539 540
ETEXI
540 541

  
541 542
#ifdef CONFIG_SLIRP
542
    { "hostfwd_add", "ss?s?", net_slirp_hostfwd_add,
543
    { "hostfwd_add", "arg1:s,arg2:s?,arg3:s?", net_slirp_hostfwd_add,
543 544
      "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
544 545
      "redirect TCP or UDP connections from host to guest (requires -net user)" },
545
    { "hostfwd_remove", "ss?s?", net_slirp_hostfwd_remove,
546
    { "hostfwd_remove", "arg1:s,arg2:s?,arg3:s?", net_slirp_hostfwd_remove,
546 547
      "[vlan_id name] [tcp|udp]:[hostaddr]:hostport",
547 548
      "remove host-to-guest TCP or UDP redirection" },
548 549
#endif
......
551 552
Redirect TCP or UDP connections from host to guest (requires -net user).
552 553
ETEXI
553 554

  
554
    { "balloon", "i", do_balloon,
555
    { "balloon", "value:i", do_balloon,
555 556
      "target", "request VM to change it's memory allocation (in MB)" },
556 557
STEXI
557 558
@item balloon @var{value}
558 559
Request VM to change its memory allocation to @var{value} (in MB).
559 560
ETEXI
560 561

  
561
    { "set_link", "ss", do_set_link,
562
    { "set_link", "name:s,up_or_down:s", do_set_link,
562 563
      "name up|down", "change the link status of a network adapter" },
563 564
STEXI
564 565
@item set_link @var{name} [up|down]
565 566
Set link @var{name} up or down.
566 567
ETEXI
567 568

  
568
    { "watchdog_action", "s", do_watchdog_action,
569
    { "watchdog_action", "action:s", do_watchdog_action,
569 570
      "[reset|shutdown|poweroff|pause|debug|none]", "change watchdog action" },
570 571
STEXI
571 572
@item watchdog_action
572 573
Change watchdog action.
573 574
ETEXI
574 575

  
575
    { "acl_show", "s", do_acl_show, "aclname",
576
    { "acl_show", "aclname:s", do_acl_show, "aclname",
576 577
      "list rules in the access control list" },
577 578
STEXI
578 579
@item acl_show @var{aclname}
......
582 583
certificate distinguished name, and SASL username respectively.
583 584
ETEXI
584 585

  
585
    { "acl_policy", "ss", do_acl_policy, "aclname allow|deny",
586
    { "acl_policy", "aclname:s,policy:s", do_acl_policy, "aclname allow|deny",
586 587
      "set default access control list policy" },
587 588
STEXI
588 589
@item acl_policy @var{aclname} @code{allow|deny}
......
591 592
always @code{deny}.
592 593
ETEXI
593 594

  
594
    { "acl_add", "sssi?", do_acl_add, "aclname match allow|deny [index]",
595
    { "acl_add", "aclname:s,match:s,policy:s,index:i?", do_acl_add, "aclname match allow|deny [index]",
595 596
      "add a match rule to the access control list" },
596 597
STEXI
597 598
@item acl_allow @var{aclname} @var{match} @code{allow|deny} [@var{index}]
......
603 604
earlier in the list if the optional @var{index} parameter is supplied.
604 605
ETEXI
605 606

  
606
    { "acl_remove", "ss", do_acl_remove, "aclname match",
607
    { "acl_remove", "aclname:s,match:s", do_acl_remove, "aclname match",
607 608
      "remove a match rule from the access control list" },
608 609
STEXI
609 610
@item acl_remove @var{aclname} @var{match}
610 611
Remove the specified match rule from the access control list.
611 612
ETEXI
612 613

  
613
    { "acl_reset", "s", do_acl_reset, "aclname",
614
    { "acl_reset", "aclname:s", do_acl_reset, "aclname",
614 615
      "reset the access control list" },
615 616
STEXI
616 617
@item acl_remove @var{aclname} @var{match}
......
619 620
ETEXI
620 621

  
621 622
#if defined(TARGET_I386)
622
    { "mce", "iillll", do_inject_mce, "cpu bank status mcgstatus addr misc", "inject a MCE on the given CPU"},
623
    { "mce", "cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l", do_inject_mce, "cpu bank status mcgstatus addr misc", "inject a MCE on the given CPU"},
623 624
#endif
624 625
STEXI
625 626
@item mce @var{cpu} @var{bank} @var{status} @var{mcgstatus} @var{addr} @var{misc}
626 627
Inject an MCE on the given CPU (x86 only).
627 628
ETEXI
628 629

  
629
    { "getfd", "s", do_getfd, "getfd name",
630
    { "getfd", "fdname:s", do_getfd, "getfd name",
630 631
      "receive a file descriptor via SCM rights and assign it a name" },
631 632
STEXI
632 633
@item getfd @var{fdname}
......
635 636
later use by other monitor commands.
636 637
ETEXI
637 638

  
638
    { "closefd", "s", do_closefd, "closefd name",
639
    { "closefd", "fdname:s", do_closefd, "closefd name",
639 640
      "close a file descriptor previously passed via SCM rights" },
640 641
STEXI
641 642
@item closefd @var{fdname}

Also available in: Unified diff