* [Qemu-devel] [PATCH 0/7]: Initial QObject conversion
@ 2009-09-16 21:32 Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 1/7] monitor: Add user_print() to mon_cmd_t Luiz Capitulino
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-16 21:32 UTC (permalink / raw)
To: qemu-devel
Hi there,
Here goes the first series for Monitor handlers conversion to QObjects.
The first patches introduce infrastructure needed to support incremental
conversion, that is, functions which call handlers will have to deal
with the current calling style and the new one.
The remaining patches convert very simple handlers.
Thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 1/7] monitor: Add user_print() to mon_cmd_t
2009-09-16 21:32 [Qemu-devel] [PATCH 0/7]: Initial QObject conversion Luiz Capitulino
@ 2009-09-16 21:32 ` Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 2/7] monitor: Handle new and old style handlers Luiz Capitulino
` (5 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-16 21:32 UTC (permalink / raw)
To: qemu-devel
This new struct member will store a pointer to a function that
should be used to output data in the user protocol format.
It will also serve as a flag to say if a given handler has already
been converted to the new QObject style.
Additionally, this commit converts mon_cmd_t static initializations
to the C99 way.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 349 +++++++++++++++++++++++++------
qemu-monitor.hx | 615 ++++++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 774 insertions(+), 190 deletions(-)
diff --git a/monitor.c b/monitor.c
index 18bcc92..fe604d8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -71,6 +71,7 @@ typedef struct mon_cmd_t {
const char *name;
const char *args_type;
void *handler;
+ void (*user_print)(Monitor *mon, const QObject *data);
const char *params;
const char *help;
} mon_cmd_t;
@@ -1809,82 +1810,294 @@ static const mon_cmd_t mon_cmds[] = {
/* Please update qemu-monitor.hx when adding or changing commands */
static const mon_cmd_t info_cmds[] = {
- { "version", "", do_info_version,
- "", "show the version of QEMU" },
- { "network", "", do_info_network,
- "", "show the network state" },
- { "chardev", "", qemu_chr_info,
- "", "show the character devices" },
- { "block", "", bdrv_info,
- "", "show the block devices" },
- { "blockstats", "", bdrv_info_stats,
- "", "show block device statistics" },
- { "registers", "", do_info_registers,
- "", "show the cpu registers" },
- { "cpus", "", do_info_cpus,
- "", "show infos for each CPU" },
- { "history", "", do_info_history,
- "", "show the command line history", },
- { "irq", "", irq_info,
- "", "show the interrupts statistics (if available)", },
- { "pic", "", pic_info,
- "", "show i8259 (PIC) state", },
- { "pci", "", pci_info,
- "", "show PCI info", },
+ {
+ .name = "version",
+ .args_type = "",
+ .handler = do_info_version,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the version of QEMU"
+ },
+ {
+ .name = "network",
+ .args_type = "",
+ .handler = do_info_network,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the network state"
+ },
+ {
+ .name = "chardev",
+ .args_type = "",
+ .handler = qemu_chr_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the character devices"
+ },
+ {
+ .name = "block",
+ .args_type = "",
+ .handler = bdrv_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the block devices"
+ },
+ {
+ .name = "blockstats",
+ .args_type = "",
+ .handler = bdrv_info_stats,
+ .user_print = NULL,
+ .params = "",
+ .help = "show block device statistics"
+ },
+ {
+ .name = "registers",
+ .args_type = "",
+ .handler = do_info_registers,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the cpu registers"
+ },
+ {
+ .name = "cpus",
+ .args_type = "",
+ .handler = do_info_cpus,
+ .user_print = NULL,
+ .params = "",
+ .help = "show infos for each CPU"
+ },
+ {
+ .name = "history",
+ .args_type = "",
+ .handler = do_info_history,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the command line history"
+ },
+ {
+ .name = "irq",
+ .args_type = "",
+ .handler = irq_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the interrupts statistics (if available)"
+ },
+ {
+ .name = "pic",
+ .args_type = "",
+ .handler = pic_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show i8259 (PIC) state"
+ },
+ {
+ .name = "pci",
+ .args_type = "",
+ .handler = pci_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show PCI info"
+ },
#if defined(TARGET_I386) || defined(TARGET_SH4)
- { "tlb", "", tlb_info,
- "", "show virtual to physical memory mappings", },
+ {
+ .name = "tlb",
+ .args_type = "",
+ .handler = tlb_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show virtual to physical memory mappings"
+ },
#endif
#if defined(TARGET_I386)
- { "mem", "", mem_info,
- "", "show the active virtual memory mappings", },
- { "hpet", "", do_info_hpet,
- "", "show state of HPET", },
+ {
+ .name = "mem",
+ .args_type = "",
+ .handler = mem_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the active virtual memory mappings"
+ },
+ {
+ .name = "hpet",
+ .args_type = "",
+ .handler = do_info_hpet,
+ .user_print = NULL,
+ .params = "",
+ .help = "show state of HPET"
+ },
#endif
- { "jit", "", do_info_jit,
- "", "show dynamic compiler info", },
- { "kvm", "", do_info_kvm,
- "", "show KVM information", },
- { "numa", "", do_info_numa,
- "", "show NUMA information", },
- { "usb", "", usb_info,
- "", "show guest USB devices", },
- { "usbhost", "", usb_host_info,
- "", "show host USB devices", },
- { "profile", "", do_info_profile,
- "", "show profiling information", },
- { "capture", "", do_info_capture,
- "", "show capture information" },
- { "snapshots", "", do_info_snapshots,
- "", "show the currently saved VM snapshots" },
- { "status", "", do_info_status,
- "", "show the current VM status (running|paused)" },
- { "pcmcia", "", pcmcia_info,
- "", "show guest PCMCIA status" },
- { "mice", "", do_info_mice,
- "", "show which guest mouse is receiving events" },
- { "vnc", "", do_info_vnc,
- "", "show the vnc server status"},
- { "name", "", do_info_name,
- "", "show the current VM name" },
- { "uuid", "", do_info_uuid,
- "", "show the current VM UUID" },
+ {
+ .name = "jit",
+ .args_type = "",
+ .handler = do_info_jit,
+ .user_print = NULL,
+ .params = "",
+ .help = "show dynamic compiler info"
+ },
+ {
+ .name = "kvm",
+ .args_type = "",
+ .handler = do_info_kvm,
+ .user_print = NULL,
+ .params = "",
+ .help = "show KVM information"
+ },
+ {
+ .name = "numa",
+ .args_type = "",
+ .handler = do_info_numa,
+ .user_print = NULL,
+ .params = "",
+ .help = "show NUMA information"
+ },
+ {
+ .name = "usb",
+ .args_type = "",
+ .handler = usb_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show guest USB devices"
+ },
+ {
+ .name = "usbhost",
+ .args_type = "",
+ .handler = usb_host_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show host USB devices"
+ },
+ {
+ .name = "profile",
+ .args_type = "",
+ .handler = do_info_profile,
+ .user_print = NULL,
+ .params = "",
+ .help = "show profiling information"
+ },
+ {
+ .name = "capture",
+ .args_type = "",
+ .handler = do_info_capture,
+ .user_print = NULL,
+ .params = "",
+ .help = "show capture information"
+ },
+ {
+ .name = "snapshots",
+ .args_type = "",
+ .handler = do_info_snapshots,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the currently saved VM snapshots"
+ },
+ {
+ .name = "status",
+ .args_type = "",
+ .handler = do_info_status,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the current VM status (running|paused)"
+ },
+ {
+ .name = "pcmcia",
+ .args_type = "",
+ .handler = pcmcia_info,
+ .user_print = NULL,
+ .params = "",
+ .help = "show guest PCMCIA status"
+ },
+ {
+ .name = "mice",
+ .args_type = "",
+ .handler = do_info_mice,
+ .user_print = NULL,
+ .params = "",
+ .help = "show which guest mouse is receiving events"
+ },
+ {
+ .name = "vnc",
+ .args_type = "",
+ .handler = do_info_vnc,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the vnc server status"
+ },
+ {
+ .name = "name",
+ .args_type = "",
+ .handler = do_info_name,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the current VM name"
+ },
+ {
+ .name = "uuid",
+ .args_type = "",
+ .handler = do_info_uuid,
+ .user_print = NULL,
+ .params = "",
+ .help = "show the current VM UUID"
+ },
#if defined(TARGET_PPC)
- { "cpustats", "", do_info_cpu_stats,
- "", "show CPU statistics", },
+ {
+ .name = "cpustats",
+ .args_type = "",
+ .handler = do_info_cpu_stats,
+ .user_print = NULL,
+ .params = "",
+ .help = "show CPU statistics"
+ },
#endif
#if defined(CONFIG_SLIRP)
- { "usernet", "", do_info_usernet,
- "", "show user network stack connection states", },
+ {
+ .name = "usernet",
+ .args_type = "",
+ .handler = do_info_usernet,
+ .user_print = NULL,
+ .params = "",
+ .help = "show user network stack connection states"
+ },
#endif
- { "migrate", "", do_info_migrate, "", "show migration status" },
- { "balloon", "", do_info_balloon,
- "", "show balloon information" },
- { "qtree", "", do_info_qtree,
- "", "show device tree" },
- { "qdm", "", do_info_qdm,
- "", "show qdev device model list" },
- { NULL, NULL, },
+ {
+ .name = "migrate",
+ .args_type = "",
+ .handler = do_info_migrate,
+ .user_print = NULL,
+ .params = "",
+ .help = "show migration status"
+ },
+ {
+ .name = "balloon",
+ .args_type = "",
+ .handler = do_info_balloon,
+ .user_print = NULL,
+ .params = "",
+ .help = "show balloon information"
+ },
+ {
+ .name = "qtree",
+ .args_type = "",
+ .handler = do_info_qtree,
+ .user_print = NULL,
+ .params = "",
+ .help = "show device tree"
+ },
+ {
+ .name = "qdm",
+ .args_type = "",
+ .handler = do_info_qdm,
+ .user_print = NULL,
+ .params = "",
+ .help = "show qdev device model list"
+ },
+ {
+ .name = NULL,
+ .args_type = NULL,
+ .handler = NULL,
+ .user_print = NULL,
+ .params = NULL,
+ .help = NULL
+ },
};
/*******************************************************************/
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 9f91873..400d2bd 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -9,21 +9,41 @@ STEXI
@table @option
ETEXI
- { "help|?", "name:s?", do_help_cmd, "[cmd]", "show the help" },
+ {
+ .name = "help|?",
+ .args_type = "name:s?",
+ .handler = do_help_cmd,
+ .user_print = NULL,
+ .params = "[cmd]",
+ .help = "show the help"
+ },
+
STEXI
@item help or ? [@var{cmd}]
Show the help for all commands or just for command @var{cmd}.
ETEXI
- { "commit", "device:s", do_commit,
- "device|all", "commit changes to the disk images (if -snapshot is used) or backing files" },
+ {
+ .name = "commit",
+ .args_type = "device:s",
+ .handler = do_commit,
+ .user_print = NULL,
+ .params = "device|all",
+ .help = "commit changes to the disk images (if -snapshot is used) or backing files"
+ },
STEXI
@item commit
Commit changes to the disk images (if -snapshot is used) or backing files.
ETEXI
- { "info", "item:s?", do_info,
- "[subcommand]", "show various information about the system state" },
+ {
+ .name = "info",
+ .args_type = "item:s?",
+ .handler = do_info,
+ .user_print = NULL,
+ .params = "[subcommand]",
+ .help = "show various information about the system state"
+ },
STEXI
@item info @var{subcommand}
Show various information about the system state.
@@ -94,22 +114,40 @@ show device tree
@end table
ETEXI
- { "q|quit", "", do_quit,
- "", "quit the emulator" },
+ {
+ .name = "q|quit",
+ .args_type = "",
+ .handler = do_quit,
+ .user_print = NULL,
+ .params = "",
+ .help = "quit the emulator"
+ },
STEXI
@item q or quit
Quit the emulator.
ETEXI
- { "eject", "force:-f,filename:B", do_eject,
- "[-f] device", "eject a removable medium (use -f to force it)" },
+ {
+ .name = "eject",
+ .args_type = "force:-f,filename:B",
+ .handler = do_eject,
+ .user_print = NULL,
+ .params = "[-f] device",
+ .help = "eject a removable medium (use -f to force it)"
+ },
STEXI
@item eject [-f] @var{device}
Eject a removable medium (use -f to force it).
ETEXI
- { "change", "device:B,target:F,arg:s?", do_change,
- "device filename [format]", "change a removable medium, optional format" },
+ {
+ .name = "change",
+ .args_type = "device:B,target:F,arg:s?",
+ .handler = do_change,
+ .user_print = NULL,
+ .params = "device filename [format]",
+ .help = "change a removable medium, optional format"
+ },
STEXI
@item change @var{device} @var{setting}
@@ -147,29 +185,53 @@ Password: ********
@end table
ETEXI
- { "screendump", "filename:F", do_screen_dump,
- "filename", "save screen into PPM image 'filename'" },
+ {
+ .name = "screendump",
+ .args_type = "filename:F",
+ .handler = do_screen_dump,
+ .user_print = NULL,
+ .params = "filename",
+ .help = "save screen into PPM image 'filename'"
+ },
STEXI
@item screendump @var{filename}
Save screen into PPM image @var{filename}.
ETEXI
- { "logfile", "filename:F", do_logfile,
- "filename", "output logs to 'filename'" },
+ {
+ .name = "logfile",
+ .args_type = "filename:F",
+ .handler = do_logfile,
+ .user_print = NULL,
+ .params = "filename",
+ .help = "output logs to 'filename'"
+ },
STEXI
@item logfile @var{filename}
Output logs to @var{filename}.
ETEXI
- { "log", "items:s", do_log,
- "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" },
+ {
+ .name = "log",
+ .args_type = "items:s",
+ .handler = do_log,
+ .user_print = NULL,
+ .params = "item1[,...]",
+ .help = "activate logging of the specified items to '/tmp/qemu.log'"
+ },
STEXI
@item log @var{item1}[,...]
Activate logging of the specified items to @file{/tmp/qemu.log}.
ETEXI
- { "savevm", "name:s?", do_savevm,
- "[tag|id]", "save a VM snapshot. If no tag or id are provided, a new snapshot is created" },
+ {
+ .name = "savevm",
+ .args_type = "name:s?",
+ .handler = do_savevm,
+ .user_print = NULL,
+ .params = "[tag|id]",
+ .help = "save a VM snapshot. If no tag or id are provided, a new snapshot is created"
+ },
STEXI
@item savevm [@var{tag}|@var{id}]
Create a snapshot of the whole virtual machine. If @var{tag} is
@@ -178,59 +240,107 @@ a snapshot with the same tag or ID, it is replaced. More info at
@ref{vm_snapshots}.
ETEXI
- { "loadvm", "name:s", do_loadvm,
- "tag|id", "restore a VM snapshot from its tag or id" },
+ {
+ .name = "loadvm",
+ .args_type = "name:s",
+ .handler = do_loadvm,
+ .user_print = NULL,
+ .params = "tag|id",
+ .help = "restore a VM snapshot from its tag or id"
+ },
STEXI
@item loadvm @var{tag}|@var{id}
Set the whole virtual machine to the snapshot identified by the tag
@var{tag} or the unique snapshot ID @var{id}.
ETEXI
- { "delvm", "name:s", do_delvm,
- "tag|id", "delete a VM snapshot from its tag or id" },
+ {
+ .name = "delvm",
+ .args_type = "name:s",
+ .handler = do_delvm,
+ .user_print = NULL,
+ .params = "tag|id",
+ .help = "delete a VM snapshot from its tag or id"
+ },
STEXI
@item delvm @var{tag}|@var{id}
Delete the snapshot identified by @var{tag} or @var{id}.
ETEXI
- { "singlestep", "option:s?", do_singlestep,
- "[on|off]", "run emulation in singlestep mode or switch to normal mode", },
+ {
+ .name = "singlestep",
+ .args_type = "option:s?",
+ .handler = do_singlestep,
+ .user_print = NULL,
+ .params = "[on|off]",
+ .help = "run emulation in singlestep mode or switch to normal mode",
+ },
STEXI
@item singlestep [off]
Run the emulation in single step mode.
If called with option off, the emulation returns to normal mode.
ETEXI
- { "stop", "", do_stop,
- "", "stop emulation", },
+ {
+ .name = "stop",
+ .args_type = "",
+ .handler = do_stop,
+ .user_print = NULL,
+ .params = "",
+ .help = "stop emulation",
+ },
STEXI
@item stop
Stop emulation.
ETEXI
- { "c|cont", "", do_cont,
- "", "resume emulation", },
+ {
+ .name = "c|cont",
+ .args_type = "",
+ .handler = do_cont,
+ .user_print = NULL,
+ .params = "",
+ .help = "resume emulation",
+ },
STEXI
@item c or cont
Resume emulation.
ETEXI
- { "gdbserver", "device:s?", do_gdbserver,
- "[device]", "start gdbserver on given device (default 'tcp::1234'), stop with 'none'", },
+ {
+ .name = "gdbserver",
+ .args_type = "device:s?",
+ .handler = do_gdbserver,
+ .user_print = NULL,
+ .params = "[device]",
+ .help = "start gdbserver on given device (default 'tcp::1234'), stop with 'none'",
+ },
STEXI
@item gdbserver [@var{port}]
Start gdbserver session (default @var{port}=1234)
ETEXI
- { "x", "fmt:/,addr:l", do_memory_dump,
- "/fmt addr", "virtual memory dump starting at 'addr'", },
+ {
+ .name = "x",
+ .args_type = "fmt:/,addr:l",
+ .handler = do_memory_dump,
+ .handler = NULL,
+ .params = "/fmt addr",
+ .help = "virtual memory dump starting at 'addr'",
+ },
STEXI
@item x/fmt @var{addr}
Virtual memory dump starting at @var{addr}.
ETEXI
- { "xp", "fmt:/,addr:l", do_physical_memory_dump,
- "/fmt addr", "physical memory dump starting at 'addr'", },
+ {
+ .name = "xp",
+ .args_type = "fmt:/,addr:l",
+ .handler = do_physical_memory_dump,
+ .user_print = NULL,
+ .params = "/fmt addr",
+ .help = "physical memory dump starting at 'addr'",
+ },
STEXI
@item xp /@var{fmt} @var{addr}
Physical memory dump starting at @var{addr}.
@@ -289,8 +399,14 @@ Dump 80 16 bit values at the start of the video memory.
@end itemize
ETEXI
- { "p|print", "fmt:/,val:l", do_print,
- "/fmt expr", "print expression value (use $reg for CPU register access)", },
+ {
+ .name = "p|print",
+ .args_type = "fmt:/,val:l",
+ .handler = do_print,
+ .user_print = NULL,
+ .params = "/fmt expr",
+ .help = "print expression value (use $reg for CPU register access)",
+ },
STEXI
@item p or print/@var{fmt} @var{expr}
@@ -298,20 +414,38 @@ Print expression value. Only the @var{format} part of @var{fmt} is
used.
ETEXI
- { "i", "fmt:/,addr:i,index:i.", do_ioport_read,
- "/fmt addr", "I/O port read" },
+ {
+ .name = "i",
+ .args_type = "fmt:/,addr:i,index:i.",
+ .handler = do_ioport_read,
+ .user_print = NULL,
+ .params = "/fmt addr",
+ .help = "I/O port read"
+ },
STEXI
Read I/O port.
ETEXI
- { "o", "fmt:/,addr:i,val:i", do_ioport_write,
- "/fmt addr value", "I/O port write" },
+ {
+ .name = "o",
+ .args_type = "fmt:/,addr:i,val:i",
+ .handler = do_ioport_write,
+ .user_print = NULL,
+ .params = "/fmt addr value",
+ .help = "I/O port write"
+ },
STEXI
Write to I/O port.
ETEXI
- { "sendkey", "string:s,hold_time:i?", do_sendkey,
- "keys [hold_ms]", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)" },
+ {
+ .name = "sendkey",
+ .args_type = "string:s,hold_time:i?",
+ .handler = do_sendkey,
+ .user_print = NULL,
+ .params = "keys [hold_ms]",
+ .help = "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)"
+ },
STEXI
@item sendkey @var{keys}
@@ -326,32 +460,56 @@ This command is useful to send keys that your graphical user interface
intercepts at low level, such as @code{ctrl-alt-f1} in X Window.
ETEXI
- { "system_reset", "", do_system_reset,
- "", "reset the system" },
+ {
+ .name = "system_reset",
+ .args_type = "",
+ .handler = do_system_reset,
+ .user_print = NULL,
+ .params = "",
+ .help = "reset the system"
+ },
STEXI
@item system_reset
Reset the system.
ETEXI
- { "system_powerdown", "", do_system_powerdown,
- "", "send system power down event" },
+ {
+ .name = "system_powerdown",
+ .args_type = "",
+ .handler = do_system_powerdown,
+ .user_print = NULL,
+ .params = "",
+ .help = "send system power down event"
+ },
STEXI
@item system_powerdown
Power down the system (if supported).
ETEXI
- { "sum", "start:i,size:i", do_sum,
- "addr size", "compute the checksum of a memory region" },
+ {
+ .name = "sum",
+ .args_type = "start:i,size:i",
+ .handler = do_sum,
+ .user_print = NULL,
+ .params = "addr size",
+ .help = "compute the checksum of a memory region"
+ },
STEXI
@item sum @var{addr} @var{size}
Compute the checksum of a memory region.
ETEXI
- { "usb_add", "devname:s", do_usb_add,
- "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" },
+ {
+ .name = "usb_add",
+ .args_type = "devname:s",
+ .handler = do_usb_add,
+ .user_print = NULL,
+ .params = "device",
+ .help = "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')"
+ },
STEXI
@item usb_add @var{devname}
@@ -359,8 +517,14 @@ Add the USB device @var{devname}. For details of available devices see
@ref{usb_devices}
ETEXI
- { "usb_del", "devname:s", do_usb_del,
- "device", "remove USB device 'bus.addr'" },
+ {
+ .name = "usb_del",
+ .args_type = "devname:s",
+ .handler = do_usb_del,
+ .user_print = NULL,
+ .params = "device",
+ .help = "remove USB device 'bus.addr'"
+ },
STEXI
@item usb_del @var{devname}
@@ -369,29 +533,53 @@ hub. @var{devname} has the syntax @code{bus.addr}. Use the monitor
command @code{info usb} to see the devices you can remove.
ETEXI
- { "cpu", "index:i", do_cpu_set,
- "index", "set the default CPU" },
+ {
+ .name = "cpu",
+ .args_type = "index:i",
+ .handler = do_cpu_set,
+ .user_print = NULL,
+ .params = "index",
+ .help = "set the default CPU"
+ },
STEXI
Set the default CPU.
ETEXI
- { "mouse_move", "dx_str:s,dy_str:s,dz_str:s?", do_mouse_move,
- "dx dy [dz]", "send mouse move events" },
+ {
+ .name = "mouse_move",
+ .args_type = "dx_str:s,dy_str:s,dz_str:s?",
+ .handler = do_mouse_move,
+ .user_print = NULL,
+ .params = "dx dy [dz]",
+ .help = "send mouse move events"
+ },
STEXI
@item mouse_move @var{dx} @var{dy} [@var{dz}]
Move the active mouse to the specified coordinates @var{dx} @var{dy}
with optional scroll axis @var{dz}.
ETEXI
- { "mouse_button", "button_state:i", do_mouse_button,
- "state", "change mouse button state (1=L, 2=M, 4=R)" },
+ {
+ .name = "mouse_button",
+ .args_type = "button_state:i",
+ .handler = do_mouse_button,
+ .user_print = NULL,
+ .params = "state",
+ .help = "change mouse button state (1=L, 2=M, 4=R)"
+ },
STEXI
@item mouse_button @var{val}
Change the active mouse button state @var{val} (1=L, 2=M, 4=R).
ETEXI
- { "mouse_set", "index:i", do_mouse_set,
- "index", "set which mouse device receives events" },
+ {
+ .name = "mouse_set",
+ .args_type = "index:i",
+ .handler = do_mouse_set,
+ .user_print = NULL,
+ .params = "index",
+ .help = "set which mouse device receives events"
+ },
STEXI
@item mouse_set @var{index}
Set which mouse device receives events at given @var{index}, index
@@ -402,9 +590,13 @@ info mice
ETEXI
#ifdef HAS_AUDIO
- { "wavcapture", "path:s,freq:i?,bits:i?,nchannels:i?", do_wav_capture,
- "path [frequency [bits [channels]]]",
- "capture audio to a wave file (default frequency=44100 bits=16 channels=2)" },
+ {
+ .name = "wavcapture",
+ .args_type = "path:s,freq:i?,bits:i?,nchannels:i?",
+ .handler = do_wav_capture,
+ .user_print = NULL,
+ .params = "path [frequency [bits [channels]]]",
+ .help = "capture audio to a wave file (default frequency=44100 bits=16 channels=2)" },
#endif
STEXI
@item wavcapture @var{filename} [@var{frequency} [@var{bits} [@var{channels}]]]
@@ -420,8 +612,14 @@ Defaults:
ETEXI
#ifdef HAS_AUDIO
- { "stopcapture", "n:i", do_stop_capture,
- "capture index", "stop capture" },
+ {
+ .name = "stopcapture",
+ .args_type = "n:i",
+ .handler = do_stop_capture,
+ .user_print = NULL,
+ .params = "capture index",
+ .help = "stop capture"
+ },
#endif
STEXI
@item stopcapture @var{index}
@@ -431,22 +629,40 @@ info capture
@end example
ETEXI
- { "memsave", "val:l,size:i,filename:s", do_memory_save,
- "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", },
+ {
+ .name = "memsave",
+ .args_type = "val:l,size:i,filename:s",
+ .handler = do_memory_save,
+ .user_print = NULL,
+ .params = "addr size file",
+ .help = "save to disk virtual memory dump starting at 'addr' of size 'size'",
+ },
STEXI
@item memsave @var{addr} @var{size} @var{file}
save to disk virtual memory dump starting at @var{addr} of size @var{size}.
ETEXI
- { "pmemsave", "val:l,size:i,filename:s", do_physical_memory_save,
- "addr size file", "save to disk physical memory dump starting at 'addr' of size 'size'", },
+ {
+ .name = "pmemsave",
+ .args_type = "val:l,size:i,filename:s",
+ .handler = do_physical_memory_save,
+ .user_print = NULL,
+ .params = "addr size file",
+ .help = "save to disk physical memory dump starting at 'addr' of size 'size'",
+ },
STEXI
@item pmemsave @var{addr} @var{size} @var{file}
save to disk physical memory dump starting at @var{addr} of size @var{size}.
ETEXI
- { "boot_set", "bootdevice:s", do_boot_set,
- "bootdevice", "define new values for the boot device list" },
+ {
+ .name = "boot_set",
+ .args_type = "bootdevice:s",
+ .handler = do_boot_set,
+ .user_print = NULL,
+ .params = "bootdevice",
+ .help = "define new values for the boot device list"
+ },
STEXI
@item boot_set @var{bootdevicelist}
@@ -458,37 +674,67 @@ the same that can be specified in the @code{-boot} command line option.
ETEXI
#if defined(TARGET_I386)
- { "nmi", "cpu_index:i", do_inject_nmi,
- "cpu", "inject an NMI on the given CPU", },
+ {
+ .name = "nmi",
+ .args_type = "cpu_index:i",
+ .handler = do_inject_nmi,
+ .user_print = NULL,
+ .params = "cpu",
+ .help = "inject an NMI on the given CPU"
+ },
#endif
STEXI
@item nmi @var{cpu}
Inject an NMI on the given CPU (x86 only).
ETEXI
- { "migrate", "detach:-d,uri:s", do_migrate,
- "[-d] uri", "migrate to URI (using -d to not wait for completion)" },
+ {
+ .name = "migrate",
+ .args_type = "detach:-d,uri:s",
+ .handler = do_migrate,
+ .user_print = NULL,
+ .params = "[-d] uri",
+ .help = "migrate to URI (using -d to not wait for completion)"
+ },
STEXI
@item migrate [-d] @var{uri}
Migrate to @var{uri} (using -d to not wait for completion).
ETEXI
- { "migrate_cancel", "", do_migrate_cancel,
- "", "cancel the current VM migration" },
+ {
+ .name = "migrate_cancel",
+ .args_type = "",
+ .handler = do_migrate_cancel,
+ .user_print = NULL,
+ .params = "",
+ .help = "cancel the current VM migration"
+ },
STEXI
@item migrate_cancel
Cancel the current VM migration.
ETEXI
- { "migrate_set_speed", "value:s", do_migrate_set_speed,
- "value", "set maximum speed (in bytes) for migrations" },
+ {
+ .name = "migrate_set_speed",
+ .args_type = "value:s",
+ .handler = do_migrate_set_speed,
+ .user_print = NULL,
+ .params = "value",
+ .help = "set maximum speed (in bytes) for migrations"
+ },
STEXI
@item migrate_set_speed @var{value}
Set maximum speed to @var{value} (in bytes) for migrations.
ETEXI
- { "migrate_set_downtime", "value:s", do_migrate_set_downtime,
- "value", "set maximum tolerated downtime (in seconds) for migrations" },
+ {
+ .name = "migrate_set_downtime",
+ .args_type = "value:s",
+ .handler = do_migrate_set_downtime,
+ .user_print = NULL,
+ .params = "value",
+ .help = "set maximum tolerated downtime (in seconds) for migrations"
+ },
STEXI
@item migrate_set_downtime @var{second}
@@ -496,85 +742,159 @@ Set maximum tolerated downtime (in seconds) for migration.
ETEXI
#if defined(TARGET_I386)
- { "drive_add", "pci_addr:s,opts:s", drive_hot_add,
- "[[<domain>:]<bus>:]<slot>\n"
- "[file=file][,if=type][,bus=n]\n"
- "[,unit=m][,media=d][index=i]\n"
- "[,cyls=c,heads=h,secs=s[,trans=t]]\n"
- "[snapshot=on|off][,cache=on|off]",
- "add drive to PCI storage controller" },
+ {
+ .name = "drive_add",
+ .args_type = "pci_addr:s,opts:s",
+ .handler = drive_hot_add,
+ .user_print = NULL,
+ .params = "[[<domain>:]<bus>:]<slot>\n"
+ "[file=file][,if=type][,bus=n]\n"
+ "[,unit=m][,media=d][index=i]\n"
+ "[,cyls=c,heads=h,secs=s[,trans=t]]\n"
+ "[snapshot=on|off][,cache=on|off]",
+ .help = "add drive to PCI storage controller"
+ },
#endif
+
STEXI
@item drive_add
Add drive to PCI storage controller.
ETEXI
#if defined(TARGET_I386)
- { "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" },
+ {
+ .name = "pci_add",
+ .args_type = "pci_addr:s,type:s,opts:s?",
+ .handler = pci_device_hot_add,
+ .user_print = NULL,
+ .params = "auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...",
+ .help = "hot-add PCI device"
+ },
#endif
+
STEXI
@item pci_add
Hot-add PCI device.
ETEXI
#if defined(TARGET_I386)
- { "pci_del", "pci_addr:s", do_pci_device_hot_remove, "[[<domain>:]<bus>:]<slot>", "hot remove PCI device" },
+ {
+ .name = "pci_del",
+ .args_type = "pci_addr:s",
+ .handler = do_pci_device_hot_remove,
+ .user_print = NULL,
+ .params = "[[<domain>:]<bus>:]<slot>",
+ .help = "hot remove PCI device"
+ },
#endif
+
STEXI
@item pci_del
Hot remove PCI device.
ETEXI
- { "host_net_add", "device:s,opts:s?", net_host_device_add,
- "tap|user|socket|vde|dump [options]", "add host VLAN client" },
+ {
+ .name = "host_net_add",
+ .args_type = "device:s,opts:s?",
+ .handler = net_host_device_add,
+ .user_print = NULL,
+ .params = "tap|user|socket|vde|dump [options]",
+ .help = "add host VLAN client"
+ },
STEXI
@item host_net_add
Add host VLAN client.
ETEXI
- { "host_net_remove", "vlan_id:i,device:s", net_host_device_remove,
- "vlan_id name", "remove host VLAN client" },
+ {
+ .name = "host_net_remove",
+ .args_type = "vlan_id:i,device:s",
+ .handler = net_host_device_remove,
+ .user_print = NULL,
+ .params = "vlan_id name",
+ .help = "remove host VLAN client"
+ },
+
STEXI
@item host_net_remove
Remove host VLAN client.
ETEXI
#ifdef CONFIG_SLIRP
- { "hostfwd_add", "arg1:s,arg2:s?,arg3:s?", net_slirp_hostfwd_add,
- "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
- "redirect TCP or UDP connections from host to guest (requires -net user)" },
- { "hostfwd_remove", "arg1:s,arg2:s?,arg3:s?", net_slirp_hostfwd_remove,
- "[vlan_id name] [tcp|udp]:[hostaddr]:hostport",
- "remove host-to-guest TCP or UDP redirection" },
+ {
+ .name = "hostfwd_add",
+ .args_type = "arg1:s,arg2:s?,arg3:s?",
+ .handler = net_slirp_hostfwd_add,
+ .user_print = NULL,
+ .params = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
+ .help = "redirect TCP or UDP connections from host to guest (requires -net user)" },
+
+ {
+ .name = "hostfwd_remove",
+ .args_type = "arg1:s,arg2:s?,arg3:s?",
+ .handler = net_slirp_hostfwd_remove,
+ .user_print = NULL,
+ .params = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport",
+ .help = "remove host-to-guest TCP or UDP redirection"
+ },
+
#endif
STEXI
@item host_net_redir
Redirect TCP or UDP connections from host to guest (requires -net user).
ETEXI
- { "balloon", "value:i", do_balloon,
- "target", "request VM to change it's memory allocation (in MB)" },
+ {
+ .name = "balloon",
+ .args_type = "value:i",
+ .handler = do_balloon,
+ .user_print = NULL,
+ .params = "target",
+ .help = "request VM to change it's memory allocation (in MB)"
+ },
+
STEXI
@item balloon @var{value}
Request VM to change its memory allocation to @var{value} (in MB).
ETEXI
- { "set_link", "name:s,up_or_down:s", do_set_link,
- "name up|down", "change the link status of a network adapter" },
+ {
+ .name = "set_link",
+ .args_type = "name:s,up_or_down:s",
+ .handler = do_set_link,
+ .user_print = NULL,
+ .params = "name up|down",
+ .help = "change the link status of a network adapter"
+ },
+
STEXI
@item set_link @var{name} [up|down]
Set link @var{name} up or down.
ETEXI
- { "watchdog_action", "action:s", do_watchdog_action,
- "[reset|shutdown|poweroff|pause|debug|none]", "change watchdog action" },
+ {
+ .name = "watchdog_action",
+ .args_type = "action:s",
+ .handler = do_watchdog_action,
+ .user_print = NULL,
+ .params = "[reset|shutdown|poweroff|pause|debug|none]",
+ .help = "change watchdog action"
+ },
+
STEXI
@item watchdog_action
Change watchdog action.
ETEXI
- { "acl_show", "aclname:s", do_acl_show, "aclname",
- "list rules in the access control list" },
+ {
+ .name = "acl_show",
+ .args_type = "aclname:s",
+ .handler = do_acl_show,
+ .user_print = NULL,
+ .params = "aclname",
+ .help = "list rules in the access control list"
+ },
+
STEXI
@item acl_show @var{aclname}
List all the matching rules in the access control list, and the default
@@ -583,8 +903,15 @@ policy. There are currently two named access control lists,
certificate distinguished name, and SASL username respectively.
ETEXI
- { "acl_policy", "aclname:s,policy:s", do_acl_policy, "aclname allow|deny",
- "set default access control list policy" },
+ {
+ .name = "acl_policy",
+ .args_type = "aclname:s,policy:s",
+ .handler = do_acl_policy,
+ .user_print = NULL,
+ .params = "aclname allow|deny",
+ .help = "set default access control list policy"
+ },
+
STEXI
@item acl_policy @var{aclname} @code{allow|deny}
Set the default access control list policy, used in the event that
@@ -592,8 +919,15 @@ none of the explicit rules match. The default policy at startup is
always @code{deny}.
ETEXI
- { "acl_add", "aclname:s,match:s,policy:s,index:i?", do_acl_add, "aclname match allow|deny [index]",
- "add a match rule to the access control list" },
+ {
+ .name = "acl_add",
+ .args_type = "aclname:s,match:s,policy:s,index:i?",
+ .handler = do_acl_add,
+ .user_print = NULL,
+ .params = "aclname match allow|deny [index]",
+ .help = "add a match rule to the access control list"
+ },
+
STEXI
@item acl_allow @var{aclname} @var{match} @code{allow|deny} [@var{index}]
Add a match rule to the access control list, allowing or denying access.
@@ -604,15 +938,29 @@ normally be appended to the end of the ACL, but can be inserted
earlier in the list if the optional @var{index} parameter is supplied.
ETEXI
- { "acl_remove", "aclname:s,match:s", do_acl_remove, "aclname match",
- "remove a match rule from the access control list" },
+ {
+ .name = "acl_remove",
+ .args_type = "aclname:s,match:s",
+ .handler = do_acl_remove,
+ .user_print = NULL,
+ .params = "aclname match",
+ .help = "remove a match rule from the access control list"
+ },
+
STEXI
@item acl_remove @var{aclname} @var{match}
Remove the specified match rule from the access control list.
ETEXI
- { "acl_reset", "aclname:s", do_acl_reset, "aclname",
- "reset the access control list" },
+ {
+ .name = "acl_reset",
+ .args_type = "aclname:s",
+ .handler = do_acl_reset,
+ .user_print = NULL,
+ .params = "aclname",
+ .help = "reset the access control list"
+ },
+
STEXI
@item acl_remove @var{aclname} @var{match}
Remove all matches from the access control list, and set the default
@@ -620,15 +968,31 @@ policy back to @code{deny}.
ETEXI
#if defined(TARGET_I386)
- { "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"},
+
+ {
+ .name = "mce",
+ .args_type = "cpu_index:i,bank:i,status:l,mcg_status:l,addr:l,misc:l",
+ .handler = do_inject_mce,
+ .user_print = NULL,
+ .params = "cpu bank status mcgstatus addr misc",
+ .help = "inject a MCE on the given CPU"
+ },
+
#endif
STEXI
@item mce @var{cpu} @var{bank} @var{status} @var{mcgstatus} @var{addr} @var{misc}
Inject an MCE on the given CPU (x86 only).
ETEXI
- { "getfd", "fdname:s", do_getfd, "getfd name",
- "receive a file descriptor via SCM rights and assign it a name" },
+ {
+ .name = "getfd",
+ .args_type = "fdname:s",
+ .handler = do_getfd,
+ .user_print = NULL,
+ .params = "getfd name",
+ .help = "receive a file descriptor via SCM rights and assign it a name"
+ },
+
STEXI
@item getfd @var{fdname}
If a file descriptor is passed alongside this command using the SCM_RIGHTS
@@ -636,8 +1000,15 @@ mechanism on unix sockets, it is stored using the name @var{fdname} for
later use by other monitor commands.
ETEXI
- { "closefd", "fdname:s", do_closefd, "closefd name",
- "close a file descriptor previously passed via SCM rights" },
+ {
+ .name = "closefd",
+ .args_type = "fdname:s",
+ .handler = do_closefd,
+ .user_print = NULL,
+ .params = "closefd name",
+ .help = "close a file descriptor previously passed via SCM rights"
+ },
+
STEXI
@item closefd @var{fdname}
Close the file descriptor previously assigned to @var{fdname} using the
--
1.6.5.rc0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 2/7] monitor: Handle new and old style handlers
2009-09-16 21:32 [Qemu-devel] [PATCH 0/7]: Initial QObject conversion Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 1/7] monitor: Add user_print() to mon_cmd_t Luiz Capitulino
@ 2009-09-16 21:32 ` Luiz Capitulino
2009-09-17 6:39 ` [Qemu-devel] " Paolo Bonzini
2009-09-16 21:32 ` [Qemu-devel] [PATCH 3/7] monitor: do_info(): handle new and old info handlers Luiz Capitulino
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-16 21:32 UTC (permalink / raw)
To: qemu-devel
This commit changes monitor_handle_command() to support old style
and new style handlers.
New style handlers are protocol independent, they return their
data to the Monitor, which in turn decides how to print them
(ie. user protocol vs. machine protocol).
Converted handlers will use the 'user_print' member of 'mon_cmd_t'
to define its user protocol function, which will be called to print
data in the user protocol format.
Handlers which don't have 'user_print' defined are not converted.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/monitor.c b/monitor.c
index fe604d8..17754fb 100644
--- a/monitor.c
+++ b/monitor.c
@@ -210,6 +210,11 @@ static int monitor_fprintf(FILE *stream, const char *fmt, ...)
return 0;
}
+static int monitor_handler_ported(const mon_cmd_t *cmd)
+{
+ return (cmd->user_print == NULL ? 0 : 1);
+}
+
static int compare_cmd(const char *name, const char *list)
{
const char *p, *pstart;
@@ -3041,17 +3046,32 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
qdict = qdict_new();
cmd = monitor_parse_command(mon, cmdline, qdict);
- if (cmd) {
- void (*handler)(Monitor *mon, const QDict *qdict);
+ if (!cmd)
+ goto out;
+
+ qemu_errors_to_mon(mon);
- qemu_errors_to_mon(mon);
+ if (monitor_handler_ported(cmd)) {
+ QObject *data = NULL;
+ int (*handler_new)(Monitor *mon,
+ const QDict *params, QObject **ret_data);
- handler = cmd->handler;
- handler(mon, qdict);
+ handler_new = cmd->handler;
+ handler_new(mon, qdict, &data);
- qemu_errors_to_previous();
+ cmd->user_print(mon, data);
+
+ if (data)
+ qobject_decref(data);
+ } else {
+ void (*handler_old)(Monitor *mon, const QDict *qdict);
+ handler_old = cmd->handler;
+ handler_old(mon, qdict);
}
+ qemu_errors_to_previous();
+
+out:
QDECREF(qdict);
}
--
1.6.5.rc0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 3/7] monitor: do_info(): handle new and old info handlers
2009-09-16 21:32 [Qemu-devel] [PATCH 0/7]: Initial QObject conversion Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 1/7] monitor: Add user_print() to mon_cmd_t Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 2/7] monitor: Handle new and old style handlers Luiz Capitulino
@ 2009-09-16 21:32 ` Luiz Capitulino
2009-09-23 15:46 ` Markus Armbruster
2009-09-16 21:32 ` [Qemu-devel] [PATCH 4/7] monitor: Convert do_quit() do QObject Luiz Capitulino
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-16 21:32 UTC (permalink / raw)
To: qemu-devel
do_info() is special, its job is to call 'info handlers'.
This is similar to what monitor_handle_command() does,
therefore do_info() also has to distinguish among new and
old style info handlers.
This commit converts do_info() to the new QObject style and
makes the appropriate changes so that it can handle both
info handlers styles.
In the future, when all handlers are converted to QObject's
style, it will be possible to share more code with
monitor_handle_command().
Also note that this commit adds a new function called
monitor_print_nothing(), which will be used by converted
handlers that don't have data to print in the user protocol.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 44 ++++++++++++++++++++++++++++++++------------
qemu-monitor.hx | 2 +-
2 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/monitor.c b/monitor.c
index 17754fb..cfbedf8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -210,6 +210,11 @@ static int monitor_fprintf(FILE *stream, const char *fmt, ...)
return 0;
}
+static void monitor_print_nothing(Monitor *mon, const QObject *data)
+{
+ return;
+}
+
static int monitor_handler_ported(const mon_cmd_t *cmd)
{
return (cmd->user_print == NULL ? 0 : 1);
@@ -284,24 +289,39 @@ static void do_commit(Monitor *mon, const QDict *qdict)
}
}
-static void do_info(Monitor *mon, const QDict *qdict)
+static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
+ int ret = 0;
const mon_cmd_t *cmd;
const char *item = qdict_get_try_str(qdict, "item");
- void (*handler)(Monitor *);
- if (!item)
- goto help;
- for(cmd = info_cmds; cmd->name != NULL; cmd++) {
+ if (!item) {
+ help_cmd(mon, "info");
+ return 0;
+ }
+
+ for (cmd = info_cmds; cmd->name != NULL; cmd++) {
if (compare_cmd(item, cmd->name))
- goto found;
+ break;
}
- help:
- help_cmd(mon, "info");
- return;
- found:
- handler = cmd->handler;
- handler(mon);
+
+ if (cmd->name == NULL)
+ return -1;
+
+ if (monitor_handler_ported(cmd)) {
+ int (*handler_new)(Monitor *mon, QObject **ret_data);
+
+ handler_new = cmd->handler;
+ ret = handler_new(mon, ret_data);
+
+ cmd->user_print(mon, *ret_data);
+ } else {
+ void (*handler_old)(Monitor *mon);
+ handler_old = cmd->handler;
+ handler_old(mon);
+ }
+
+ return ret;
}
static void do_info_version(Monitor *mon)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 400d2bd..b7217f3 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -40,7 +40,7 @@ ETEXI
.name = "info",
.args_type = "item:s?",
.handler = do_info,
- .user_print = NULL,
+ .user_print = monitor_print_nothing,
.params = "[subcommand]",
.help = "show various information about the system state"
},
--
1.6.5.rc0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 4/7] monitor: Convert do_quit() do QObject
2009-09-16 21:32 [Qemu-devel] [PATCH 0/7]: Initial QObject conversion Luiz Capitulino
` (2 preceding siblings ...)
2009-09-16 21:32 ` [Qemu-devel] [PATCH 3/7] monitor: do_info(): handle new and old info handlers Luiz Capitulino
@ 2009-09-16 21:32 ` Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 5/7] monitor: Convert do_stop() to QObject Luiz Capitulino
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-16 21:32 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 8 +++++++-
qemu-monitor.hx | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/monitor.c b/monitor.c
index cfbedf8..b324538 100644
--- a/monitor.c
+++ b/monitor.c
@@ -459,9 +459,15 @@ static void do_info_cpu_stats(Monitor *mon)
}
#endif
-static void do_quit(Monitor *mon, const QDict *qdict)
+/**
+ * do_quit(): Quit QEMU execution
+ *
+ * return always succeed.
+ */
+static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
exit(0);
+ return 0;
}
static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index b7217f3..401d5c5 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -118,7 +118,7 @@ ETEXI
.name = "q|quit",
.args_type = "",
.handler = do_quit,
- .user_print = NULL,
+ .user_print = monitor_print_nothing,
.params = "",
.help = "quit the emulator"
},
--
1.6.5.rc0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 5/7] monitor: Convert do_stop() to QObject
2009-09-16 21:32 [Qemu-devel] [PATCH 0/7]: Initial QObject conversion Luiz Capitulino
` (3 preceding siblings ...)
2009-09-16 21:32 ` [Qemu-devel] [PATCH 4/7] monitor: Convert do_quit() do QObject Luiz Capitulino
@ 2009-09-16 21:32 ` Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 6/7] monitor: Convert do_system_reset() " Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 7/7] monitor: Convert do_system_powerdown() " Luiz Capitulino
6 siblings, 0 replies; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-16 21:32 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 8 +++++++-
qemu-monitor.hx | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/monitor.c b/monitor.c
index b324538..9ef9108 100644
--- a/monitor.c
+++ b/monitor.c
@@ -604,9 +604,15 @@ static void do_singlestep(Monitor *mon, const QDict *qdict)
}
}
-static void do_stop(Monitor *mon, const QDict *qdict)
+/**
+ * do_stop(): Stop VM execution
+ *
+ * return always succeed.
+ */
+static int do_stop(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
vm_stop(EXCP_INTERRUPT);
+ return 0;
}
static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs);
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 401d5c5..f6c9911 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -285,7 +285,7 @@ ETEXI
.name = "stop",
.args_type = "",
.handler = do_stop,
- .user_print = NULL,
+ .user_print = monitor_print_nothing,
.params = "",
.help = "stop emulation",
},
--
1.6.5.rc0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 6/7] monitor: Convert do_system_reset() to QObject
2009-09-16 21:32 [Qemu-devel] [PATCH 0/7]: Initial QObject conversion Luiz Capitulino
` (4 preceding siblings ...)
2009-09-16 21:32 ` [Qemu-devel] [PATCH 5/7] monitor: Convert do_stop() to QObject Luiz Capitulino
@ 2009-09-16 21:32 ` Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 7/7] monitor: Convert do_system_powerdown() " Luiz Capitulino
6 siblings, 0 replies; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-16 21:32 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 8 +++++++-
qemu-monitor.hx | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/monitor.c b/monitor.c
index 9ef9108..ef2d8c1 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1300,9 +1300,15 @@ static void do_boot_set(Monitor *mon, const QDict *qdict)
}
}
-static void do_system_reset(Monitor *mon, const QDict *qdict)
+/**
+ * do_system_reset(): Issue a machine reset
+ *
+ * return always succeed.
+ */
+static int do_system_reset(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
qemu_system_reset_request();
+ return 0;
}
static void do_system_powerdown(Monitor *mon, const QDict *qdict)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index f6c9911..5b3f84f 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -464,7 +464,7 @@ ETEXI
.name = "system_reset",
.args_type = "",
.handler = do_system_reset,
- .user_print = NULL,
+ .user_print = monitor_print_nothing,
.params = "",
.help = "reset the system"
},
--
1.6.5.rc0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 7/7] monitor: Convert do_system_powerdown() to QObject
2009-09-16 21:32 [Qemu-devel] [PATCH 0/7]: Initial QObject conversion Luiz Capitulino
` (5 preceding siblings ...)
2009-09-16 21:32 ` [Qemu-devel] [PATCH 6/7] monitor: Convert do_system_reset() " Luiz Capitulino
@ 2009-09-16 21:32 ` Luiz Capitulino
6 siblings, 0 replies; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-16 21:32 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 9 ++++++++-
qemu-monitor.hx | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/monitor.c b/monitor.c
index ef2d8c1..db73642 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1311,9 +1311,16 @@ static int do_system_reset(Monitor *mon, const QDict *qdict, QObject **ret_data)
return 0;
}
-static void do_system_powerdown(Monitor *mon, const QDict *qdict)
+/**
+ * do_system_powerdown(): Issue a machine powerdown
+ *
+ * return always succeed.
+ */
+static int do_system_powerdown(Monitor *mon, const QDict *qdict,
+ QObject **ret_data)
{
qemu_system_powerdown_request();
+ return 0;
}
#if defined(TARGET_I386)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 5b3f84f..1159686 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -478,7 +478,7 @@ ETEXI
.name = "system_powerdown",
.args_type = "",
.handler = do_system_powerdown,
- .user_print = NULL,
+ .user_print = monitor_print_nothing,
.params = "",
.help = "send system power down event"
},
--
1.6.5.rc0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] monitor: Handle new and old style handlers
2009-09-16 21:32 ` [Qemu-devel] [PATCH 2/7] monitor: Handle new and old style handlers Luiz Capitulino
@ 2009-09-17 6:39 ` Paolo Bonzini
2009-09-17 13:18 ` Luiz Capitulino
0 siblings, 1 reply; 14+ messages in thread
From: Paolo Bonzini @ 2009-09-17 6:39 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel
On 09/16/2009 11:32 PM, Luiz Capitulino wrote:
> + return (cmd->user_print == NULL ? 0 : 1);
cmd->user_print != NULL.
I would actually inline it at the use point. Also, calling a function
with an extra argument is fine, so while keeping the void* handler you
can do:
+ QObject *data = NULL;
+ int (*handler_new)(Monitor *mon,
+ const QDict *params, QObject **ret_data);
+ handler_new = cmd->handler;
+ handler_new(mon, qdict, &data);
+ if (cmd->user_print)
+ cmd->user_print(mon, data);
+ if (data)
+ qobject_decref(data);
If you do not like calling the function with the "wrong" number of
arguments, you can mass-convert the functions to the new prototype new
and leave anyway user_print == NULL.
What are the plans for the return code of handler_new?
Paolo
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] monitor: Handle new and old style handlers
2009-09-17 6:39 ` [Qemu-devel] " Paolo Bonzini
@ 2009-09-17 13:18 ` Luiz Capitulino
2009-09-17 13:28 ` Paolo Bonzini
0 siblings, 1 reply; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-17 13:18 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Thu, 17 Sep 2009 08:39:25 +0200
Paolo Bonzini <bonzini@gnu.org> wrote:
> On 09/16/2009 11:32 PM, Luiz Capitulino wrote:
> > + return (cmd->user_print == NULL ? 0 : 1);
>
> cmd->user_print != NULL.
Right.
> I would actually inline it at the use point. Also, calling a function
> with an extra argument is fine, so while keeping the void* handler you
> can do:
>
> + QObject *data = NULL;
> + int (*handler_new)(Monitor *mon,
> + const QDict *params, QObject **ret_data);
>
> + handler_new = cmd->handler;
> + handler_new(mon, qdict, &data);
>
> + if (cmd->user_print)
> + cmd->user_print(mon, data);
> + if (data)
> + qobject_decref(data);
>
> If you do not like calling the function with the "wrong" number of
> arguments, you can mass-convert the functions to the new prototype new
> and leave anyway user_print == NULL.
The problem is that the monitor_handler_ported() branch can
have additional code in the future (eg. protocol emission code),
so different branches makes things easier to understand.
> What are the plans for the return code of handler_new?
The protocol emission code will use it to emit 'error' or
'success' messages.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] monitor: Handle new and old style handlers
2009-09-17 13:18 ` Luiz Capitulino
@ 2009-09-17 13:28 ` Paolo Bonzini
2009-09-17 17:16 ` Luiz Capitulino
0 siblings, 1 reply; 14+ messages in thread
From: Paolo Bonzini @ 2009-09-17 13:28 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel
> The problem is that the monitor_handler_ported() branch can
> have additional code in the future (eg. protocol emission code),
> so different branches makes things easier to understand.
Well, you don't know... It may end up in different functions, like
void print_cmd_result_user (Monitor *mon, MonitorCmd *cmd, int result,
QObject *data)
{
if (result)
...
else if (cmd->user_print)
cmd->user_print (mon, data);
}
void print_cmd_result_json (Monitor *mon, MonitorCmd *cmd, int result,
QObject *data)
{
... make qdict with result and data ...
qdict_print_json (mon->something, output_dict);
qobject_decref (output_dict);
}
or it may end up not being a branch (but an indirect function call) for
example:
result = handler_new (mon, qdict, &data);
mon->print_cmd_result (mon, cmd, result, data);
if (data)
qobject_decref (data);
I'd stay with the simplest thing for now. I'm not going to argue,
especially if I'm overridden by other reviewers, of course.
Paolo
Paolo
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] monitor: Handle new and old style handlers
2009-09-17 13:28 ` Paolo Bonzini
@ 2009-09-17 17:16 ` Luiz Capitulino
0 siblings, 0 replies; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-17 17:16 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Thu, 17 Sep 2009 15:28:32 +0200
Paolo Bonzini <bonzini@gnu.org> wrote:
>
> > The problem is that the monitor_handler_ported() branch can
> > have additional code in the future (eg. protocol emission code),
> > so different branches makes things easier to understand.
>
> Well, you don't know... It may end up in different functions, like
Actually, I already have this code and will post shortly (for review,
not for inclusion).
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 3/7] monitor: do_info(): handle new and old info handlers
2009-09-16 21:32 ` [Qemu-devel] [PATCH 3/7] monitor: do_info(): handle new and old info handlers Luiz Capitulino
@ 2009-09-23 15:46 ` Markus Armbruster
2009-09-23 16:05 ` Luiz Capitulino
0 siblings, 1 reply; 14+ messages in thread
From: Markus Armbruster @ 2009-09-23 15:46 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel
Luiz Capitulino <lcapitulino@redhat.com> writes:
> do_info() is special, its job is to call 'info handlers'.
> This is similar to what monitor_handle_command() does,
> therefore do_info() also has to distinguish among new and
> old style info handlers.
>
> This commit converts do_info() to the new QObject style and
> makes the appropriate changes so that it can handle both
> info handlers styles.
>
> In the future, when all handlers are converted to QObject's
> style, it will be possible to share more code with
> monitor_handle_command().
>
> Also note that this commit adds a new function called
> monitor_print_nothing(), which will be used by converted
> handlers that don't have data to print in the user protocol.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> monitor.c | 44 ++++++++++++++++++++++++++++++++------------
> qemu-monitor.hx | 2 +-
> 2 files changed, 33 insertions(+), 13 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 17754fb..cfbedf8 100644
> --- a/monitor.c
> +++ b/monitor.c
[...]
> @@ -284,24 +289,39 @@ static void do_commit(Monitor *mon, const QDict *qdict)
> }
> }
>
> -static void do_info(Monitor *mon, const QDict *qdict)
> +static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
> {
> + int ret = 0;
> const mon_cmd_t *cmd;
> const char *item = qdict_get_try_str(qdict, "item");
> - void (*handler)(Monitor *);
>
> - if (!item)
> - goto help;
> - for(cmd = info_cmds; cmd->name != NULL; cmd++) {
> + if (!item) {
> + help_cmd(mon, "info");
> + return 0;
> + }
> +
> + for (cmd = info_cmds; cmd->name != NULL; cmd++) {
> if (compare_cmd(item, cmd->name))
> - goto found;
> + break;
> }
> - help:
> - help_cmd(mon, "info");
> - return;
> - found:
> - handler = cmd->handler;
> - handler(mon);
> +
> + if (cmd->name == NULL)
> + return -1;
> +
> + if (monitor_handler_ported(cmd)) {
> + int (*handler_new)(Monitor *mon, QObject **ret_data);
> +
> + handler_new = cmd->handler;
> + ret = handler_new(mon, ret_data);
> +
> + cmd->user_print(mon, *ret_data);
> + } else {
> + void (*handler_old)(Monitor *mon);
> + handler_old = cmd->handler;
> + handler_old(mon);
> + }
> +
> + return ret;
> }
>
> static void do_info_version(Monitor *mon)
Looks like this changes do_info() to fail without printing help when the
"item" argument is not recognized. Fine with me, just mention it in the
commit message, please.
[...]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 3/7] monitor: do_info(): handle new and old info handlers
2009-09-23 15:46 ` Markus Armbruster
@ 2009-09-23 16:05 ` Luiz Capitulino
0 siblings, 0 replies; 14+ messages in thread
From: Luiz Capitulino @ 2009-09-23 16:05 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
On Wed, 23 Sep 2009 17:46:47 +0200
Markus Armbruster <armbru@redhat.com> wrote:
> Luiz Capitulino <lcapitulino@redhat.com> writes:
>
> > do_info() is special, its job is to call 'info handlers'.
> > This is similar to what monitor_handle_command() does,
> > therefore do_info() also has to distinguish among new and
> > old style info handlers.
> >
> > This commit converts do_info() to the new QObject style and
> > makes the appropriate changes so that it can handle both
> > info handlers styles.
> >
> > In the future, when all handlers are converted to QObject's
> > style, it will be possible to share more code with
> > monitor_handle_command().
> >
> > Also note that this commit adds a new function called
> > monitor_print_nothing(), which will be used by converted
> > handlers that don't have data to print in the user protocol.
> >
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > ---
> > monitor.c | 44 ++++++++++++++++++++++++++++++++------------
> > qemu-monitor.hx | 2 +-
> > 2 files changed, 33 insertions(+), 13 deletions(-)
> >
> > diff --git a/monitor.c b/monitor.c
> > index 17754fb..cfbedf8 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> [...]
> > @@ -284,24 +289,39 @@ static void do_commit(Monitor *mon, const QDict *qdict)
> > }
> > }
> >
> > -static void do_info(Monitor *mon, const QDict *qdict)
> > +static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
> > {
> > + int ret = 0;
> > const mon_cmd_t *cmd;
> > const char *item = qdict_get_try_str(qdict, "item");
> > - void (*handler)(Monitor *);
> >
> > - if (!item)
> > - goto help;
> > - for(cmd = info_cmds; cmd->name != NULL; cmd++) {
> > + if (!item) {
> > + help_cmd(mon, "info");
> > + return 0;
> > + }
> > +
> > + for (cmd = info_cmds; cmd->name != NULL; cmd++) {
> > if (compare_cmd(item, cmd->name))
> > - goto found;
> > + break;
> > }
> > - help:
> > - help_cmd(mon, "info");
> > - return;
> > - found:
> > - handler = cmd->handler;
> > - handler(mon);
> > +
> > + if (cmd->name == NULL)
> > + return -1;
> > +
> > + if (monitor_handler_ported(cmd)) {
> > + int (*handler_new)(Monitor *mon, QObject **ret_data);
> > +
> > + handler_new = cmd->handler;
> > + ret = handler_new(mon, ret_data);
> > +
> > + cmd->user_print(mon, *ret_data);
> > + } else {
> > + void (*handler_old)(Monitor *mon);
> > + handler_old = cmd->handler;
> > + handler_old(mon);
> > + }
> > +
> > + return ret;
> > }
> >
> > static void do_info_version(Monitor *mon)
>
> Looks like this changes do_info() to fail without printing help when the
> "item" argument is not recognized. Fine with me, just mention it in the
> commit message, please.
Actually, it has to maintain compatibility with the current
code, so this is a well spotted bug.
Will fix, thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2009-09-23 16:05 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-16 21:32 [Qemu-devel] [PATCH 0/7]: Initial QObject conversion Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 1/7] monitor: Add user_print() to mon_cmd_t Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 2/7] monitor: Handle new and old style handlers Luiz Capitulino
2009-09-17 6:39 ` [Qemu-devel] " Paolo Bonzini
2009-09-17 13:18 ` Luiz Capitulino
2009-09-17 13:28 ` Paolo Bonzini
2009-09-17 17:16 ` Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 3/7] monitor: do_info(): handle new and old info handlers Luiz Capitulino
2009-09-23 15:46 ` Markus Armbruster
2009-09-23 16:05 ` Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 4/7] monitor: Convert do_quit() do QObject Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 5/7] monitor: Convert do_stop() to QObject Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 6/7] monitor: Convert do_system_reset() " Luiz Capitulino
2009-09-16 21:32 ` [Qemu-devel] [PATCH 7/7] monitor: Convert do_system_powerdown() " Luiz Capitulino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).