summaryrefslogtreecommitdiff
path: root/monitor.c
AgeCommit message (Collapse)AuthorFilesLines
2010-02-10QMP: Enforce capability negotiation rulesLuiz Capitulino1-1/+17
With this commit QMP will be started in Capabilities Negotiation mode, where the only command allowed to run is 'qmp_capabilities'. All other commands will return CommandNotFound error. Asynchronous messages are not delivered either. When 'qmp_capabilities' is successfully executed QMP enters in Command mode, where all commands (except 'qmp_capabilities') are allowed to run and asynchronous messages are delivered. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10QMP: Introduce the qmp_capabilities commandLuiz Capitulino1-0/+11
This command will be used to enable QMP capabilities advertised by the capabilities array. Note that it will be mandatory to issue this command in order to make QMP functional (although this behavior is not being enforced by this commit). Also, as we don't have any capabilities yet, the new command doesn't accept any arguments. I will postpone the decision for a format for this until we get our first capability. Finally, this command is visible from the user Monitor too, in the meaning that you can execute it but it won't do anything. Making it only visible in QMP is beyond this series' goal, as it requires changes in unrelated places. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10QMP: Add QEMU's version to the greeting messageLuiz Capitulino1-1/+9
With capability negotiation support clients will only have a chance to check QEMU's version (ie. issue 'query-version') after the negotiation procedure is done. It might be useful to clients to check QEMU's version before negotiating features, though. To allow that, this commit adds the QEMU's version object to the greeting message. Not really sure this is needed, but doesn't hurt anyway. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10QMP: BLOCK_IO_ERROR event handlingLuiz Capitulino1-0/+3
This commit adds the basic definitions for the BLOCK_IO_ERROR event, but actual event emission will be introduced by the next commits. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03monitor: Use QERR_INVALID_PARAMETER instead of QERR_INVALID_CPU_INDEXMarkus Armbruster1-1/+1
This changes the error message from "Invalid CPU index" to "Invalid parameter index" in the human monitor. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03monitor: New argument type 'T'Markus Armbruster1-1/+16
This is a double value with optional suffixes ms, us, ns. We'll need this to get migrate_set_downtime() QMP-ready. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03monitor: New argument type 'b'Markus Armbruster1-0/+64
This is a double value with optional suffixes G, g, M, m, K, k. We'll need this to get migrate_set_speed() QMP-ready. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03monitor: Document argument type 'M'Markus Armbruster1-0/+2
Was forgotten in commit b6e098d7. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-28Monitor: Fix command execution regressionLuiz Capitulino1-1/+5
Function is_async_return() added by commit 940cc30d0d4 assumes that 'data', which is returned by handlers, is always a QDict. This is not true, as QLists can also be returned, in this case we'll get a segfault. Fix that by checking if 'data' is a QDict. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-26virtio: Add memory statistics reporting to the balloon driverAdam Litke1-37/+61
When using ballooning to manage overcommitted memory on a host, a system for guests to communicate their memory usage to the host can provide information that will minimize the impact of ballooning on the guests. The current method employs a daemon running in each guest that communicates memory statistics to a host daemon at a specified time interval. The host daemon aggregates this information and inflates and/or deflates balloons according to the level of host memory pressure. This approach is effective but overly complex since a daemon must be installed inside each guest and coordinated to communicate with the host. A simpler approach is to collect memory statistics in the virtio balloon driver and communicate them directly to the hypervisor. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26New API for asynchronous monitor commandsAdam Litke1-4/+109
Qemu has a number of commands that can operate asynchronously (savevm, migrate, etc) and it will be getting more. For these commands, the user monitor needs to be suspended, but QMP monitors could continue to to accept other commands. This patch introduces a new command API that isolates the details of handling different monitor types from the actual command execution. A monitor command can use this API by implementing the mhandler.cmd_async handler (or info_async if appropriate). This function is responsible for submitting the command and does not return any data although it may raise errors. When the command completes, the QMPCompletion callback should be invoked with its opaque data and the command result. The process for submitting and completing an asynchronous command is different for QMP and user monitors. A user monitor must be suspended at submit time and resumed at completion time. The user_print() function must be passed to the QMPCompletion callback so the result can be displayed properly. QMP monitors are simpler. No submit time setup is required. When the command completes, monitor_protocol_emitter() writes the result in JSON format. This API can also be used to implement synchronous commands. In this case, the cmd_async handler should immediately call the QMPCompletion callback. It is my hope that this new interface will work for all commands, leading to a drastically simplified monitor.c once all commands are ported. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26PCI: Convert pci_info() to QObjectLuiz Capitulino1-1/+2
The returned QObject is a QList of all buses. Each bus is represented by a QDict, which has a key with a QList of all PCI devices attached to it. Each device is represented by a QDict. As has happended to other complex conversions, it's hard to split this commit as part of it are new functions which are called by each other. IMPORTANT: support for printing PCI bridge attached devices is NOT part of this commit, it's going to be added by the next commit, as it's untested. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26monitor.c: fix warnings with _FORTIFY_SOURCEKirill A. Shutemov1-2/+10
CC i386-softmmu/monitor.o cc1: warnings being treated as errors /usr/src/RPM/BUILD/qemu-0.11.92/monitor.c: In function 'do_memory_save': /usr/src/RPM/BUILD/qemu-0.11.92/monitor.c:1318: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result /usr/src/RPM/BUILD/qemu-0.11.92/monitor.c: In function 'do_physical_memory_save': /usr/src/RPM/BUILD/qemu-0.11.92/monitor.c:1345: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result make[1]: *** [monitor.o] Error 1 Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26monitor: convert do_cpu_set() to QObject, QErrorMarkus Armbruster1-2/+2
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26monitor: convert do_physical_memory_save() to QErrorMarkus Armbruster1-1/+1
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26monitor: convert do_memory_save() to QErrorMarkus Armbruster1-1/+1
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26monitor: Don't check for mon_get_cpu() failureMarkus Armbruster1-36/+3
mon_get_cpu() can't return null pointer, because it passes its return value to cpu_synchronize_state() first, which crashes if its argument is null. Remove the (pretty cheesy) handling of this non-existing error. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-20QMP: Fix asynchronous events deliveryLuiz Capitulino1-4/+3
Commit f039a563f200beee80cc10fd70b21ea396979dab introduces a regression as monitor_protocol_event() will return in the first user Monitor it finds in the QLIST_FOREACH() loop. The right thing to do is to only delivery an asynchronous event if the 'mon' is a QMP Monitor. The aforementioned commit was an early version, if it was applied to stable (it should) this one has to be applied there too. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-20Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY ↵Naphtali Sprei1-1/+1
gone (and so is BDRV_O_ACCESS). Default value for bdrv_flags (0/zero) is READ-ONLY. Need to explicitly request READ-WRITE. Instead of using the field 'readonly' of the BlockDriverState struct for passing the request, pass the request in the flags parameter to the function. Signed-off-by: Naphtali Sprei <nsprei@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19QMP: Emit asynchronous events on all QMP monitorsAdam Litke1-5/+7
When using a control/QMP monitor in tandem with a regular monitor, asynchronous messages can get lost depending on the order of the QEMU program arguments. QEMU events issued by monitor_protocol_event() always go to cur_mon. If the user monitor was specified on the command line first (or it has ,default), the message will be directed to the user monitor (not the QMP monitor). Additionally, only one QMP session is currently able to receive async messages. To avoid this confusion, scan through the list of monitors and emit the message on each QMP monitor. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19QMP: Introduce VNC_INITIALIZED eventLuiz Capitulino1-0/+3
It's emitted when a VNC client session is activated by QEMU, client's information such as port, IP and auth ID (if the session is authenticated) are provided. Event example: { "event": "VNC_INITIALIZED", "timestamp": {"seconds": 1263475302, "microseconds": 150772}, "data": { "server": { "auth": "sasl", "family": "ipv4", "service": "5901", "host": "0.0.0.0"}, "client": { "family": "ipv4", "service": "46089", "host": "127.0.0.1", "sasl_username": "lcapitulino" } } } Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19QMP: Introduce VNC_DISCONNECTED eventLuiz Capitulino1-0/+3
It's emitted when a VNC client disconnects from QEMU, client's information such as port and IP address are provided. Event example: { "event": "VNC_DISCONNECTED", "timestamp": { "seconds": 1262976601, "microseconds": 975795 }, "data": { "server": { "auth": "sasl", "family": "ipv4", "service": "5901", "host": "0.0.0.0" }, "client": { "family": "ipv4", "service": "58425", "host": "127.0.0.1", "sasl_username": "foo" } } } Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19QMP: Introduce VNC_CONNECTED eventLuiz Capitulino1-0/+3
It's emitted when a VNC client connects to QEMU, client's information such as port and IP address are provided. Note that this event is emitted right when the connection is established. This means that it happens before authentication procedure and session initialization. Event example: { "event": "VNC_CONNECTED", "timestamp": { "seconds": 1262976601, "microseconds": 975795 }, "data": { "server": { "auth": "sasl", "family": "ipv4", "service": "5901", "host": "0.0.0.0" }, "client": { "family": "ipv4", "service": "58425", "host": "127.0.0.1" } } } Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-12monitor: fix dead assignment spotted by clangBlue Swirl1-2/+1
Value stored to 'nb_per_line' is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-12QMP: Don't free async event's 'data'Luiz Capitulino1-1/+3
The monitor_protocol_event() function will free the event's data, this is wrong as 'data' management is up to the caller. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-08QMP: Drop wrong assert()Luiz Capitulino1-1/+0
Some commands return a QList of QDicts, which is valid, but will trig the assert(). Just drop it. Reported-by: Nathan Baum <nathan@parenthephobia.org.uk> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-19monitor: do_balloon(): Use 'M' argument typeLuiz Capitulino1-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>
2009-12-19monitor: Introduce 'M' argument typeLuiz Capitulino1-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>
2009-12-19QMP: Assure that returned data is a QDictLuiz Capitulino1-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>
2009-12-19QMP: Return an empty dict by defaultLuiz Capitulino1-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>
2009-12-19QMP: Only handle converted commandsLuiz Capitulino1-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>
2009-12-18monitor: Accept input only byte-wiseJan Kiszka1-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>
2009-12-18monitor: Catch printing to non-existent monitorLuiz Capitulino1-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>
2009-12-18monitor: Avoid readline functions in QMPLuiz Capitulino1-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>
2009-12-18monitor: do_balloon(): Check for errorsLuiz Capitulino1-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>
2009-12-18monitor: Use 'device' in ejectLuiz Capitulino1-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>
2009-12-12VNC: Convert do_info_vnc() to QObjectLuiz Capitulino1-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>
2009-12-12char: Convert qemu_chr_info() to QObjectLuiz Capitulino1-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>
2009-12-12block: Convert bdrv_info_stats() to QObjectLuiz Capitulino1-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>
2009-12-12block: Convert bdrv_info() to QObjectLuiz Capitulino1-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>
2009-12-12migration: Convert do_info_migrate() to QObjectLuiz Capitulino1-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>
2009-12-12monitor: Convert do_info_mice() to QObjectLuiz Capitulino1-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>
2009-12-12monitor: Convert do_info_uuid() to QObjectLuiz Capitulino1-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>
2009-12-12monitor: Convert do_info_hpet() to QObjectLuiz Capitulino1-3/+21
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12monitor: Convert do_info_name() to QObjectLuiz Capitulino1-4/+28
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12monitor: Convert do_info_kvm() to QObjectLuiz Capitulino1-8/+33
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12monitor: Convert do_info_status() to QObjectLuiz Capitulino1-9/+35
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12monitor: do_info_version(): Use QDictLuiz Capitulino1-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>
2009-12-12monitor: do_info_cpus(): Use QBoolLuiz Capitulino1-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>
2009-12-12monitor: Fix do_info_commands() outputLuiz Capitulino1-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>