summaryrefslogtreecommitdiff
path: root/monitor.c
AgeCommit message (Collapse)AuthorFilesLines
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>
2010-06-01Monitor: Drop QMP documentation from codeLuiz Capitulino1-102/+0
Previous commit added QMP documentation to the qemu-monitor.hx file, it's is a copy of this information. While it's good to keep it near code, maintaining two copies of the same information is too hard and has little benefit as we don't expect client writers to consult the code to find how to use a QMP command. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-05-19Monitor: Return before exiting with 'quit'Luiz Capitulino1-1/+4
This is a new version of the (now reverted) following commit: 0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d The 'quit' Monitor command (implemented by do_quit()) calls exit() directly, this is problematic under QMP because QEMU exits before having a chance to send the ok response. Clients don't know if QEMU exited because of a problem or because the 'quit' command has been executed. This commit fixes that by making do_quit() use qemu_system_shutdown_request(), so that we exit gracefully. Thanks to Paolo Bonzini <pbonzini@redhat.com> for suggesting this solution. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-05-19Revert "Monitor: Return before exiting with 'quit'"Luiz Capitulino1-2/+1
This reverts commit 0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d. Next commits will do the same thing in a better way. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-05-09sparc: Fix lazy flag calculation on interrupts, refactorBlue Swirl1-1/+2
Recalculate Sparc64 CPU flags on interrupts, otherwise some earlier flags could be stored to pstate. Refactor PSR/CCR/CWP handling: concentrate the actual functions to op_helper.c. Thanks to Igor Kovalenko for reporting. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-05-03block: read-only: open cdrom as read-only when using monitor's change commandNaphtali Sprei1-1/+3
Current code of monitor command: 'change', used to open file for read-write uncoditionally. Change to open it as read-only for CDROM, and read-write for all others. Signed-off-by: Naphtali Sprei <nsprei@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-05-03QMP: Introduce RESUME eventLuiz Capitulino1-0/+3
It's emitted when the Virtual Machine resumes execution. We currently have the STOP event but don't have the matching RESUME one, this means that clients are notified when the VM is stopped but don't get anything when it resumes. Let's fix that as it's already causing some trouble to libvirt. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-04-26stash away SCM_RIGHTS fd until a getfd command arrivesPaolo Bonzini1-9/+0
If there is already a fd in s->msgfd before recvmsg it is closed by parts that this patch does not touch. So, only one descriptor can be "leaked" by attaching it to a command other than getfd. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-26Monitor: Return before exiting with 'quit'Luiz Capitulino1-1/+2
The 'quit' Monitor command (implemented by do_quit()) calls exit() directly, this is problematic under QMP because QEMU exits before having a chance to send the ok response. Clients don't know if QEMU exited because of a problem or because the 'quit' command has been executed. This commit fixes that by moving the exit() call to the main loop, so that do_quit() requests the system to quit, instead of calling exit() directly. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-26QMP: Check "arguments" member's typeLuiz Capitulino1-0/+3
Otherwise the following input crashes QEMU: { "execute": "migrate", "arguments": "tcp:0:4446" } Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-26QMP: Use QERR_QMP_BAD_INPUT_OBJECT_MEMBERLuiz Capitulino1-1/+1
The QERR_QMP_BAD_INPUT_OBJECT error is going to be used only for two problems: the input is not an object or the "execute" key is missing. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-23Replace calls of old bdrv_openKevin Wolf1-1/+1
What is known today as bdrv_open2 becomes the new bdrv_open. All remaining callers of the old function are converted to the new one. In some places they even know the right format, so they should have used bdrv_open2 from the beginning. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-04-18Monitor: Convert do_screen_dump() to QObjectLuiz Capitulino1-1/+2
Trivial, as it never fails, doesn't have output nor return any data. Note that it's also available under QMP, as kvm-autotest needs this. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-18monitor: New argument type 'b'Markus Armbruster1-0/+31
This is a boolean value. Human monitor accepts "on" or "off". Consistent with option parsing (see parse_option_bool()). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-18monitor: Rename argument type 'b' to 'f'Markus Armbruster1-4/+4
To make 'b' available for boolean argument. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-18error: Use QERR_INVALID_PARAMETER_VALUE instead of QERR_INVALID_PARAMETERMarkus Armbruster1-2/+4
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-18Add qerror message if the 'change' target filename can't be openedRyan Harper1-0/+1
Currently when using the change command to switch the file in the cd drive the command doesn't complain if the file doesn't exit or can't be opened and the drive keeps the existing image. This patch adds a qerror_report call to print a message out indicating the failure. This error message can be used to catch failures. Current behavior: QEMU 0.12.50 monitor - type 'help' for more information (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 [not inserted] floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) change ide1-cd0 /home/rharper/work/isos/Fedora-9-i386-DVD.iso (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 file=/home/rharper/work/isos/Fedora-9-i386-DVD.iso ro=0 drv=raw encrypted=0 floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) change ide1-cd0 /tmp/non_existent_file.iso (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 [not inserted] floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) With patch: QEMU 0.12.50 monitor - type 'help' for more information (qemu) change ide1-cd0 /tmp/non_existent_file.iso Could not open '/tmp/non_existent_file.iso' (qemu) Signed-off-by: Ryan Harper <ryanh@us.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-04-09move balloon handling to balloon.cPaolo Bonzini1-85/+0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-27error: Trim includes after "Move qemu_error & friends..."Markus Armbruster1-2/+0
Missed in commit 2f792016. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-17Wrong error message in block_passwd commandShahar Havivi1-1/+6
Signed-off-by: Shahar Havivi <shaharh@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-16monitor: New argument type 'O'Markus Armbruster1-4/+50
In the human monitor, it declares a single optional argument to be parsed according to the QemuOptsList given by its name. In QMP, it declares an optional argument for each member of the QemuOptsList. Restriction: only lists with empty desc are supported for now. Good enough for the job at hand. We'll lift the restriction when we need that.
2010-03-16error: Let converted handlers print in human monitorMarkus Armbruster1-43/+37
While fully converted handlers are not supposed to print anything when running in a QMP monitor, they are free to print in a human monitor. For instance, device_add (not yet converted) prints help, and will continue to do so after conversion. Moreover, utility functions converted to QError should remain usable from unconverted handlers. Two problems: * handler_audit() complains when a converted handler prints. Limit that to QMP monitors. * With QMP, handlers need to pass the error object by way of monitor_set_error(). However, we do that both for QMP and for the human monitor. The human monitor prints the error object after the handler returns. If the handler prints anything else, that output "overtakes" the error message. Limit use of monitor_set_error() to QMP monitors. Update handler_audit() accordingly.
2010-03-16monitor: New monitor_cur_is_qmp()Markus Armbruster1-0/+6
2010-03-16error: Rename qemu_error_new() to qerror_report()Markus Armbruster1-40/+40
2010-03-16error: Simplify error sink setupMarkus Armbruster1-6/+0
qemu_error_sink can either point to a monitor or a file. In practice, it always points to the current monitor if we have one, else to stderr. Simply route errors to the current monitor or else to stderr, and remove qemu_error_sink along with the functions to control it. Actually, the old code switches the sink slightly later, in handle_user_command() and handle_qmp_command(), than it gets switched now, implicitly, by setting the current monitor in monitor_read() and monitor_control_read(). Likewise, it switches back slightly earlier (same places). Doesn't make a difference, because there are no calls of qemu_error() in between.
2010-03-16error: Move qemu_error() & friends from monitor.c to own fileMarkus Armbruster1-89/+0
They're about reporting errors, not about the monitor.
2010-03-16monitor: Factor monitor_set_error() out of qemu_error_internal()Markus Armbruster1-8/+13
This separates the monitor part from the QError part.
2010-03-16monitor: Separate "default monitor" and "current monitor" cleanlyMarkus Armbruster1-3/+4
Commits 376253ec..731b0364 introduced global variable cur_mon, which points to the "default monitor" (if any), except during execution of monitor_read() or monitor_control_read() it points to the monitor from which we're reading instead (the "current monitor"). Monitor command handlers run within monitor_read() or monitor_control_read(). Default monitor and current monitor are really separate things, and squashing them together is confusing and error-prone. For instance, usb_host_scan() can run both in "info usbhost" and periodically via usb_host_auto_check(). It prints to cur_mon, which is what we want in the former case: the monitor executing "info usbhost". But since that's the default monitor in the latter case, it periodically spams the default monitor there. A few places use cur_mon to log stuff to the default monitor. If we ever log something while cur_mon points to current monitor instead of default monitor, the log temporarily "jumps" to another monitor. Whether that can or cannot happen isn't always obvious. Maybe logging to the default monitor (which may not even exist) is a bad idea, and we should log to stderr or a logfile instead. But that's outside the scope of this commit. Change cur_mon to point to the current monitor. Create new default_mon to point to the default monitor. Update users of cur_mon accordingly. This fixes the periodical spamming of the default monitor by usb_host_scan(). It also stops "log jumping", should that problem exist.
2010-03-16savevm: Fix -loadvm to report errors to stderr, not the monitorMarkus Armbruster1-1/+1
A monitor may not even exist. Change load_vmstate() to use qemu_error() instead of monitor_printf(). Parameter mon is now unused, remove it.
2010-03-09QMP: Introduce WATCHDOG eventLuiz Capitulino1-0/+3
It's emitted whenever the watchdog device's timer expires. The action taken is provided in the 'data' member. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-08QMP: Introduce RTC_CHANGE eventLuiz Capitulino1-0/+3
Emitted whenever the RTC time changes. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-08QMP: Drop DEBUG eventLuiz Capitulino1-3/+0
This event has been introduced in the first round of QMP commits, turns out that it's based on the usage of the EXCP_DEBUG macro, which has discussable semantics when exposed through QMP. As libvirt doesn't use this, let's just drop it. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-08Fix hanging user monitor when using balloon commandAdam Litke1-1/+1
This patch application failed. My patch adds a cb() call in do_balloon(), but the change in git has added the cb() call to do_info_balloon(). That is causing qemu segfaults. Applying the following should correct the damage. Thanks. Fix for commit: 5c366a8a3d7ac71beda8499caa815cb3ea95eb58 The cb() call is needed in do_balloon(), not do_info_balloon(). Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>