summaryrefslogtreecommitdiff
path: root/monitor.c
AgeCommit message (Collapse)AuthorFilesLines
2010-12-06QMP: Fix default response regressionLuiz Capitulino1-4/+2
Commit 030db6e89d dropped do_info() usage from QMP and introduced qmp_call_query_cmd(). However, the new function doesn't emit QMP's default OK response when the handler doesn't return data. Fix that by also calling monitor_protocol_emitter() when ret_data == NULL, so that the default response is emitted. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-11-17QMP: Introduce Human Monitor passthrough commandLuiz Capitulino1-0/+38
This command allows QMP clients to execute HMP commands. Please, check the documentation added to the qmp-commands.hx file for additional details about the interface and its limitations. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-11-03Remove obsolete 'f' double parameter typeJes Sorensen1-17/+1
'f' double is no longer used, and we should be using floating point variables to store byte sizes. Remove it. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-11-03Add support for 'o' octet (bytes) format as monitor parameter.Jes Sorensen1-0/+29
Octet format relies on strtosz which supports K/k, M/m, G/g, T/t suffixes and unit support for humans, like 1.3G Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-10-22monitor: Ignore "." and ".." when completing file name.Kusanagi Kouichi1-0/+5
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-13trace: print a warning if user tries to enable an unknown trace eventBlue Swirl1-1/+5
There was no warning if a bad trace event name was given to 'trace-event' command, thus the user could think that the command was successful even if this was not the case. Print a warning if the user tries to enable a trace event which is not known. Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-10-05Merge remote branch 'qmp/for-anthony' into stagingAnthony Liguori1-134/+232
2010-10-03Use GCC_FMT_ATTR (format checking)Stefan Weil1-1/+2
Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-10-01Monitor: Rename the qemu-monitor.hx fileLuiz Capitulino1-2/+2
Let's be consistent and call it hmp-commands.hx, so that we have qmp-commands.hx for QMP and hmp-commands.hx for HMP. Please, note that this commit doesn't touch qemu-monitor.texi. All texi files have the qemu- prefix and I don't think it's worth changing that. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01QMP: Introduce qmp_call_cmd()Luiz Capitulino1-24/+15
Calls a QObject handler and emits the QMP response, also drops monitor_call_handler() which is now unused. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Directly call QObject handlersLuiz Capitulino1-1/+9
This avoids handle_user_command() calling monitor_call_handler(), which is currently shared with QMP. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Rename monitor_handler_is_async()Luiz Capitulino1-5/+5
Let's follow the convention introduced by the previous commit and call it handler_is_async(). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Rename monitor_handler_ported()Luiz Capitulino1-3/+3
That name makes no sense anymore, as dispatch tables have been split, a better name is handler_is_qobject(), which really communicates the handler's type. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Drop monitor_cmd_user_only()Luiz Capitulino1-5/+0
This function was only needed when QMP and HMP were sharing dispatch tables, this is no longer true so just drop it. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Drop QMP info from the qemu-monitor.hx fileLuiz Capitulino1-8/+0
QMP has its own dispatch table and documentation file (qmp-commands.hx), we can now drop the following QMP specific info from qemu-monitor.hx: o SQMP/EQMP sections o The qmp_capabilities command o The query-commands command However, note that QObject handlers entries are not being removed. This will only happen when we introduce a proper QMP call interface. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01QMP: Small cleanup in handle_qmp_command()Luiz Capitulino1-8/+2
QMP has its own dispatch tables, we can now drop the following checks: o 'info' command: this command doesn't exist in QMP's dispatch table, the right thing will happen when it's issued by a client (ie. command not found error) o monitor_handler_ported(): all QMP handlers are 'ported', no need to check for that o monitor_cmd_user_only(): no HMP handler will exist in QMP's dispatch tables, that's why we have split them after all :-) Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01QMP: Simplify do_info_commands()Luiz Capitulino1-9/+4
We now iterate over QMP's dispatch tables, no need to check for QMP-only handlers anymore. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01QMP: Introduce query commands dispatch tableLuiz Capitulino1-2/+128
The new table is a copy of HMP's table, containing only QObject handlers. In the near future HMP will be making QMP calls and then we will be able to drop QObject handlers from HMP's table. From now on, QMP and HMP have different query command dispatch tables. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01QMP: Introduce command dispatch tableLuiz Capitulino1-2/+9
Also update QMP functions to use it. The table is generated from the qmp-commands.hx file. From now on, QMP and HMP have different command dispatch tables. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01QMP: Introduce qmp_find_cmd()Luiz Capitulino1-1/+6
Next commit needs this new function: it will introduce the the QMP's command dispatch table and qmp_find_cmd() will be used to search on it. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Convert do_info() back to HMPLuiz Capitulino1-3/+2
This is a HMP specific handler, it makes no sense to have it under QMP. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Drop is_async_return()Luiz Capitulino1-24/+1
If I understood it correcty, the is_async_return() logic was only used to prevent QMP from issuing duplicated success responses for asynchronous handlers. However, QMP doesn't use do_info() anymore so this is dead logic and (hopefully) can be safely dropped. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Drop QMP bits from do_info()Luiz Capitulino1-30/+7
As of last commit, QMP doesn't use do_info() anymore. Simplify it. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01QMP: Don't use do_info()Luiz Capitulino1-8/+31
Since its inception, QMP has been using HMP's do_info() function to run query commands. This was a bad choice, as it made do_info() more complex and contributed to couple QMP and HMP. This commit fixes that by doing the following changes: 1. Introduce qmp_find_query_cmd() and use it to directly lookup the info_cmds table 2. Introduce qmp_call_query_cmd() so that QMP code is able to call query handlers without using do_info() 3. Drop do_info() usage (via monitor_find_command("info")) We need all the three changes in one shot so that we don't break the calling of query commands in QMP. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01QMP: handle_qmp_command(): Move 'cmd' sanity checkLuiz Capitulino1-5/+5
Next commit will change how query commands are handled in a way that the 'cmd' sanity check is also going to be needed for query commands handling. Let's move it out of the else body then. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Monitor: Introduce search_dispatch_table()Luiz Capitulino1-2/+8
It's a generic version of monitor_find_command() which searches the dispatch table passed as an argument. Future commits will introduce new dispatch tables, so we need common code to search them. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01Add option to turn on JSON pretty printing in monitorDaniel P. Berrange1-1/+4
Expaned '-mon' arg to allow a 'pretty=on' flag. This makes the monitor pretty print its replies to easy human debugging / reading Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-09-09trace: Add trace-file command to open/close/flush trace fileStefan Hajnoczi1-0/+23
This patch adds the trace-file command: trace-file [on|off|flush] Open, close, or flush the trace file. If no argument is given, the status of the trace file is displayed. The trace file is turned on by default but is only written out when the trace buffer becomes full. The flush operation can be used to force write out at any time. Turning off the trace file does not change the state of trace events; tracing will continue to the trace buffer. When the trace file is off, use "info trace" to display the contents of the trace buffer in memory. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> This commit also contains the trace-file sub-command from the following commit: commit 5ce8d1a957afae2c52ad748944ce72848ccf57bd Author: Prerna Saxena <prerna@linux.vnet.ibm.com> Date: Wed Aug 4 16:23:54 2010 +0530 trace: Add options to specify trace file name at startup and runtime This patch adds an optional command line switch '-trace' to specify the filename to write traces to, when qemu starts. Eg, If compiled with the 'simple' trace backend, [temp@system]$ qemu -trace FILENAME IMAGE Allows the binary traces to be written to FILENAME instead of the option set at config-time. Also, this adds monitor sub-command 'set' to trace-file commands to dynamically change trace log file at runtime. Eg, (qemu)trace-file set FILENAME This allows one to set trace outputs to FILENAME from the default specified at startup. Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2010-09-09trace: Support for dynamically enabling/disabling trace eventsPrerna Saxena1-0/+40
This patch adds support for dynamically enabling/disabling of trace events. This is done by internally maintaining each trace event's state, and permitting logging of data from a trace event only if it is in an 'active' state. Monitor commands added : 1) info trace-events : to view all available trace events and their state. 2) trace-event NAME on|off : to enable/disable data logging from a given trace event. Eg, trace-event paio_submit off disables logging of data when paio_submit is hit. By default, all trace-events are disabled. One can enable desired trace-events via the monitor. Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> trace: Monitor command 'info trace' Monitor command 'info trace' to display contents of trace buffer Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> trace: Remove monitor.h dependency from simpletrace User-mode targets don't have a monitor so the simple trace backend currently does not build on those targets. This patch abstracts the monitor printing interface so there is no direct coupling between simpletrace and the monitor. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2010-08-22QMP/monitor: update do_info_version() to output broken down version stringMiguel Di Ciurcio Filho1-4/+19
This code was originally developed by Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-08-03loadvm: improve tests before bdrv_snapshot_goto()Miguel Di Ciurcio Filho1-1/+2
This patch improves the resilience of the load_vmstate() function, doing further and better ordered tests. In load_vmstate(), if there is any error on bdrv_snapshot_goto(), except if the error is on VM state device, load_vmstate() will return zero and the VM will be started with major corruption chances. The current process: - test if there is any writable device without snapshot support - if exists return -error - get the device that saves the VM state, possible return -error but unlikely because it was tested earlier - flush I/O - run bdrv_snapshot_goto() on devices - if fails, give an warning and goes to the next (not good!) - if fails on the VM state device, return zero (not good!) - check if the requested snapshot exists on the device that saves the VM state and the state is not zero - if fails return -error - open the file with the VM state - if fails return -error - load the VM state - if fails return -error - return zero New behavior: - get the device that saves the VM state - if fails return -error - check if the requested snapshot exists on the device that saves the VM state and the state is not zero - if fails return -error - test if there is any writable device without snapshot support - if exists return -error - test if the devices with snapshot support have the requested snapshot - if anyone fails, return -error - flush I/O - run snapshot_goto() on devices - if anyone fails, return -error - open the file with the VM state - if fails return -error - load the VM state - if fails return -error - return zero do_loadvm must not call vm_start if any error has occurred in load_vmstate. Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-30migration: Accept 'cont' only after successful incoming migrationAmit Shah1-0/+4
When a 'cont' is issued on a VM that's just waiting for an incoming migration, the VM reboots and boots into the guest, possibly corrupting its storage since it could be shared with another VM running elsewhere. Ensure that a VM started with '-incoming' is only run when an incoming migration successfully completes. A new qerror, QERR_MIGRATION_EXPECTED, is added to signal that 'cont' failed due to no incoming migration has been attempted yet. Reported-by: Laine Stump <laine@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-07-06Merge remote branch 'qmp/for-anthony' into stagingAnthony Liguori1-180/+255
2010-07-03remove exec-all.h inclusion from cpu.hPaolo Bonzini1-0/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-01monitor: Allow to exclude commands from QMPJan Kiszka1-3/+15
Ported commands that are marked 'user_only' will not be considered for QMP monitor sessions. This allows to implement new commands that do not (yet) provide a sufficiently stable interface for QMP use. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01QMP: handle_qmp_command(): Small cleanupLuiz Capitulino1-8/+6
Drop a unneeded label and QDECREF() call. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01QMP: Drop old input object checkingLuiz Capitulino1-18/+1
Previous commit added qmp_check_input_obj(), it does all the checking we need. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01QMP: Introduce qmp_check_input_obj()Luiz Capitulino1-1/+61
This is similar to qmp_check_client_args(), but it checks if the input object follows the specification (QMP/qmp-spec.txt section 2.3). As we're limited to three keys, the work here is quite simple: we iterate over the input object, checking each time if the current argument complies to the specification. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01QMP: Drop old client argument checkerLuiz Capitulino1-176/+0
Previous two commits added qmp_check_client_args(), which fully replaces this code and is way better. It's important to note that the new checker doesn't support the '/' arg type. As we don't have any of those handlers converted to QMP, this is just dead code. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01QMP: New argument checker (second part)Luiz Capitulino1-1/+93
This commit introduces the second (and last) part of QMP's new argument checker. The job is done by check_client_args_type(), it iterates over the client's argument qdict and for for each argument it checks if it exists and if its type is valid. It's important to observe the following changes from the existing argument checker: - If the handler accepts an O-type argument, unknown arguments are passed down to it. It's up to O-type handlers to validate their arguments - Boolean types (eg. 'b' and '-') don't accept integers anymore, only json-bool - Argument types '/' and '.' are currently unsupported under QMP, thus they're not handled Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01QMP: New argument checker (first part)Luiz Capitulino1-0/+106
Current QMP's argument checker is more complex than it should be and has (at least) one serious bug: it ignores unknown arguments. To solve both problems we introduce a new argument checker. It's added on top of the existing one, so that there are no regressions during the transition. This commit introduces the first part of the new checker, which is run by qmp_check_client_args() and does the following: 1. Check if all mandatory arguments were provided 2. Set flags for argument validation In order to do that, we transform the args_type string (from qemu-montor.hx) into a qdict and iterate over it. Next commit adds the new checker's second part: type checking and invalid argument detection. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01Monitor: handle optional '-' arg as a boolLuiz Capitulino1-14/+3
Historically, user monitor arguments beginning with '-' (eg. '-f') were passed as integers down to handlers. I've maintained this behavior in the new monitor because we didn't have a boolean type at the very beginning of QMP. Today we have it and this behavior is causing trouble to QMP's argument checker. This commit fixes the problem by doing the following changes: 1. User Monitor Before: the optional arg was represented as a QInt, we'd pass 1 down to handlers if the user specified the argument or 0 otherwise This commit: the optional arg is represented as a QBool, we pass true down to handlers if the user specified the argument, otherwise _nothing_ is passed 2. QMP Before: the client was required to pass the arg as QBool, but we'd convert it to QInt internally. If the argument wasn't passed, we'd pass 0 down This commit: still require a QBool, but doesn't do any conversion and doesn't pass any default value 3. Convert existing handlers (do_eject()/do_migrate()) to the new way Before: Both handlers would expect a QInt value, either 0 or 1 This commit: Change the handlers to accept a QBool, they handle the following cases: A) true is passed: the option is enabled B) false is passed: the option is disabled C) nothing is passed: option not specified, use default behavior Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01QMP: Fix error reporting in the async APILuiz Capitulino1-4/+8
The current asynchronous command API doesn't return a QMP response when the async command fails. This is easy to reproduce with the balloon command (the sole async command we have so far): run qemu w/o the '-balloon virtio' option and try to issue the balloon command via QMP: no response will be sent to the client. This commit fixes the problem by making qmp_async_cmd_handler() return the handler's error code and then calling monitor_protocol_emitter() if the handler has returned an error. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01monitor: Establish cmd flags and convert the async tagJan Kiszka1-3/+3
As we want to add more flags to monitor commands, convert the only so far existing one accordingly. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01monitor: Fix command completion vs. boolean switchesJan Kiszka1-1/+1
We now have to move forward to the next argument type via next_arg_type. This patch fixes completion for 'eject' and maybe also other commands. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01monitor: Fix leakage during completion processingJan Kiszka1-8/+15
Given too many arguments or an invalid command, we were leaking the duplicated argument strings. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-06-22Extra scan codes for missing keysBernhard M. Wiedemann1-1/+6
The code comes from http://lists.gnu.org/archive/html/qemu-devel/2010-05/msg02788.html Without this patch it is not possible to send at least 10 special characters (\|'"`~:;[]{}) via the monitor sendkey command. Signed-off-by: Bernhard M. Wiedemann <qemudevbmw@lsmod.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14Merge remote branch 'kwolf/for-anthony' into stagingAnthony Liguori1-103/+1
Conflicts: hw/pc.c
2010-06-13monitor/QMP: Drop info hpet / query-hpetJan Kiszka1-22/+0
This command was of minimal use before, now it is useless as the hpet become a qdev device and is thus easily discoverable. We should definitely not set query-hpet in QMP's stone, and there is also no good reason to keep it for the interactive monitor. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-06-04blockdev: Collect block device code in new blockdev.cMarkus Armbruster1-103/+1
Anything that moves hundreds of lines out of vl.c can't be all bad. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>