summaryrefslogtreecommitdiffstats
path: root/monitor.c
Commit message (Collapse)AuthorAgeFilesLines
* monitor: do_balloon(): Use 'M' argument typeLuiz Capitulino2009-12-191-2/+1
| | | | | | | | This makes do_balloon() accept megabyte values from the user Monitor while accepting byte values for QMP. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Introduce 'M' argument typeLuiz Capitulino2009-12-191-0/+4
| | | | | | | | | | | This is a target long value in megabytes which should be converted to bytes. It will be used by handlers which accept a megabyte value when in "user mode". Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Assure that returned data is a QDictLuiz Capitulino2009-12-191-0/+1
| | | | | | | This is for debug purposes only. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Return an empty dict by defaultLuiz Capitulino2009-12-191-1/+2
| | | | | | | | | | | | | | | | | Currently, when a regular command doesn't have any data to output, QMP will emit: { "return": "OK" } Returning an empty dict is better though, because dicts can support some protocol changes in a compatible way. So, with this commit we will return: { "return": {} } Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Only handle converted commandsLuiz Capitulino2009-12-191-1/+1
| | | | | | | | | | | | Looks like I dropped this check when addressing the 'query-' commands request. QMP should only handle converted commands, obviously. Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Accept input only byte-wiseJan Kiszka2009-12-181-1/+1
| | | | | | | | This allows to suspend command interpretation and execution synchronously, e.g. during migration. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Catch printing to non-existent monitorLuiz Capitulino2009-12-181-3/+3
| | | | | | | | | | | | | | | | The monitor_vprintf() function now touches the 'mon' pointer before calling monitor_puts(), this causes block migration to segfault as its functions call monitor_printf() with a NULL 'mon'. To fix the problem this commit moves the 'mon' NULL check from monitor_puts() to monitor_vprintf(). This can potentially hide bugs, but for some reason this has been the behavior for a long time. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Avoid readline functions in QMPLuiz Capitulino2009-12-181-0/+3
| | | | | | | | The monitor_read_command() function is readline specific and should only be used when readline is available. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: do_balloon(): Check for errorsLuiz Capitulino2009-12-181-9/+26
| | | | | | | | | | do_balloon() should check for ballooning availability as do_info_balloon() does. Noted by Daniel P. Berrange <berrange@redhat.com>. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Use 'device' in ejectLuiz Capitulino2009-12-181-1/+1
| | | | | | | | Monitor's eject command uses 'filename' for the device name argument, but 'device' is a better name. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* VNC: Convert do_info_vnc() to QObjectLuiz Capitulino2009-12-121-1/+2
| | | | | | | | | | | | | | Return a QDict with server information. Connected clients are returned as a QList of QDicts. The new functions (vnc_qdict_remote_addr(), vnc_qdict_local_addr() and put_addr_qdict()) are used to insert 'host' and 'service' information in the returned QDict. This patch is big, but I don't see how to split it. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* char: Convert qemu_chr_info() to QObjectLuiz Capitulino2009-12-121-1/+2
| | | | | | | | | | Each device is represented by a QDict. The returned QObject is a QList of all devices. This commit should not change user output. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* block: Convert bdrv_info_stats() to QObjectLuiz Capitulino2009-12-121-1/+2
| | | | | | | | | | Each device statistic information is stored in a QDict and the returned QObject is a QList of all devices. This commit should not change user output. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* block: Convert bdrv_info() to QObjectLuiz Capitulino2009-12-121-1/+2
| | | | | | | | | | Each block device information is stored in a QDict and the returned QObject is a QList of all devices. This commit should not change user output. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* migration: Convert do_info_migrate() to QObjectLuiz Capitulino2009-12-121-1/+2
| | | | | | | | | | | | | | Return a QDict, which may contain up to more two QDicts, depending on the type of migration we're performing. IMPORTANT: as a QInt stores a int64_t integer, RAM values are going to be stored as int64_t and not as uint64_t as they are today. If this is a problem QInt will have to be changed. This commit should not change user output. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Convert do_info_mice() to QObjectLuiz Capitulino2009-12-121-1/+2
| | | | | | | | | | Each mouse is represented by a QDict, the returned QObject is a QList of all mice. This commit should not change user output. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Convert do_info_uuid() to QObjectLuiz Capitulino2009-12-121-3/+23
| | | | | | | | snprintf() is used because the UUID_FMT is too complex for qobject_from_jsonf(). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Convert do_info_hpet() to QObjectLuiz Capitulino2009-12-121-3/+21
| | | | | Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Convert do_info_name() to QObjectLuiz Capitulino2009-12-121-4/+28
| | | | | Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Convert do_info_kvm() to QObjectLuiz Capitulino2009-12-121-8/+33
| | | | | Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Convert do_info_status() to QObjectLuiz Capitulino2009-12-121-9/+35
| | | | | Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: do_info_version(): Use QDictLuiz Capitulino2009-12-121-20/+22
| | | | | | | | | All 'info' commands should use QDict, this commit also kills monitor_print_qobject() as do_info_version() doesn't use it anymore (and no handler will). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: do_info_cpus(): Use QBoolLuiz Capitulino2009-12-121-13/+25
| | | | | | | While there update the documentation as well. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Fix do_info_commands() outputLuiz Capitulino2009-12-121-3/+27
| | | | | | | | Should return a QDict and should not print the user protocol bits (eg. "c|cont"). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Fix do_info_balloon() outputLuiz Capitulino2009-12-121-3/+16
| | | | | | | | Monitor commands should always return values in bytes and info commands should always return a QDict. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Revert "monitor: Command-line flag to enable control mode"Gerd Hoffmann2009-12-121-18/+0
| | | | | | | | | | | This reverts commit adcb181afe5a951c521411c7a8e9d9b791aa6742. Conflicts: monitor.h Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: add human-readable description to error responseMarkus Armbruster2009-12-071-0/+1
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: convert do_getfd() to QErrorMarkus Armbruster2009-12-071-4/+6
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: convert do_closefd() to QErrorMarkus Armbruster2009-12-071-2/+1
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: convert do_change() to QObject, QErrorMarkus Armbruster2009-12-071-8/+11
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: convert do_eject() to QErrorMarkus Armbruster2009-12-071-3/+4
| | | | | | | Also affects do_change(), because the two share eject_device(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Fix double-prompt after "change vnc passwd BLA"Markus Armbruster2009-12-071-3/+8
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: do_cont(): Don't ask for passwordsLuiz Capitulino2009-12-071-1/+9
| | | | | | | | | | | | The do_cont() function will ask the user to enter a password if a device is encrypted. This is invalid under QMP, so we raise a QERR_DEVICE_ENCRYPTED error. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Introduce 'block_passwd' commandLuiz Capitulino2009-12-071-0/+16
| | | | | | | | | | | | | | | | | | When using encrypted disk images, QEMU will prompt the user for passwords when started. This makes sense for the user protocol, but doesn't for QMP. The solution is to have Monitor command which allows the user or a Client to set passwords in advance, so that we avoid the prompt completely. This is what block_passwd does, for example: (QEMU) block_passwd ide0-hd0 foobar Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: fix use of plain integer as NULL pointer, spotted by SparseBlue Swirl2009-12-041-1/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* monitor: use qemu_gettimeofday(), not gettimeofday()Blue Swirl2009-12-041-2/+3
| | | | | | Fix mingw32 build. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* monitor: rename EVENT_* to QEVENT_* to avoid conflict on mingw32Blue Swirl2009-12-041-6/+6
| | | | | | Partially fixes mingw32 build. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* net: move slirp code from net.c to net/slirp.cMark McLoughlin2009-12-031-0/+1
| | | | | Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Disable monitor print functionsLuiz Capitulino2009-12-031-3/+11
| | | | | | | | | | | | | | | | | | We still have handlers which will call monitor print functions in several places. Usually to report errors. If they do this when we are in control mode, we will be emitting garbage to our clients. To avoid this problem, this commit adds a way to disable those functions. If any of them is called when in control mode, we will emit a generic error. Although this is far from the perfect solution, it guarantees that only JSON is sent to Clients. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Introduce basic asynchronous eventsLuiz Capitulino2009-12-031-0/+15
| | | | | | | | Debug, shutdown, reset, powerdown and stop are all basic events, as they are very simple they can be added in the same commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Asynchronous events infrastructureLuiz Capitulino2009-12-031-0/+50
| | | | | | | | | | | | | | | | | | Asynchronous events are generated with a call to monitor_protocol_event(). This function builds the right data-type and emit the event right away. The emitted data is always a JSON object and its format is as follows: { "event": json-string, "timestamp": { "seconds": json-number, "microseconds": json-number }, "data": json-value } This design is based on ideas by Amit Shah <amit.shah@redhat.com>. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Allow 'query-' commandsLuiz Capitulino2009-12-031-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'info' command makes sense for the user protocol, but for QMP it doesn't, as its return data is not well defined. That is, it can return anything. To fix this Avi proposes having 'query-' commands when in protocol mode. For example, 'info balloon' would become 'query-balloon'. The right way of supporting this would probably be to move all info handlers to qemu-monitor.hx, add a flags field to mon_cmd_t to identify them and then modify do_info() to do its search based on that flag. Unfortunately, this would require a big change in the Monitor. To make things simpler for now, this commit takes a different approach: a check for commands starting with "query-" is added to toplevel QMP code, if it's true we setup things so that do_info() is called with the appropriate arguments. This is a hack, but is a temporary one and guarantees that query- commands will work from the first day. Also note that 'info' is not allowed in protocol mode. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Input supportLuiz Capitulino2009-12-031-1/+240
| | | | | | | | | | | | | | | | | | | | | | | | The JSON stream parser is used to do QMP input. When there are enough characters to be parsed it calls Monitor's handle_qmp_command() function to handle the input. This function's job is to check if the input is correct and call the appropriate handler. In other words, it does for QMP what handle_user_command() does for the user protocol. This means that handle_qmp_command() also has to parse the (ugly) "args_type" format to able to get the arguments names and types expected by the handler. The format to input commands in QMP is as follows: { "execute": json-string, "id": json-value, "arguments": json-object } Please, note that this commit also adds "id" support. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: do_info() checksLuiz Capitulino2009-12-031-3/+15
| | | | | | | | This commit adds specific QMP checks to do_info(), so that it behaves as expected in QMP mode. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Output supportLuiz Capitulino2009-12-031-4/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the new Monitor output is always performed by only two functions: do_info() and monitor_call_handler(). To support QMP output, we modify those functions to check if we are in control mode. If so, we call monitor_protocol_emitter() to emit QMP output, otherwise we do regular output. QMP has two types of responses to issued commands: success and error. The outputed data is always a JSON object. Success responses have the following format: { "return": json-value, "id": json-value } Error responses have the following format: { "error": { "class": json-string, "desc": json-string, "data": json-value } "id": json-value } Please, note that the "id" key is part of the input code, and thus is not added in this commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QMP: Initial supportLuiz Capitulino2009-12-031-2/+51
| | | | | | | | | | | | | | | | | | This commit adds initial QMP support in QEMU. It's important to notice that most QMP code will be part of the Monitor. Input will be read by monitor_control_read(). Currently it does nothing but next patches will add proper input support. The function monitor_json_emitter(), as its name implies, is used by the Monitor to emit JSON output. In this commit it's used by monitor_control_event() to print our greeting message. Finally, control mode support is also added to monitor_init(), allowing QMP to be really enabled. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Introduce 'info commands'Luiz Capitulino2009-12-031-0/+37
| | | | | | | | List QMP available commands. Only valid in control mode, where has to be used as 'query-commands. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Rename monitor_handle_command()Luiz Capitulino2009-12-031-3/+3
| | | | | | | | | | | As this series will add a new kind of Monitor command, it's better to rename monitor_handle_command() to what it really is: handle_user_command(). This will avoid confusion. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Introduce monitor_find_command()Luiz Capitulino2009-12-031-7/+15
| | | | | | | | | | This commit moves the loop which searches for the command entry corresponding to a command name to its own function. It will be used by QMP code as well. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Introduce monitor_call_handler()Luiz Capitulino2009-12-031-7/+13
| | | | | | | | This commit moves the code which calls Monitor handlers to its own function, as it will be used by QMP code as well. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud