Commit Graph

451 Commits

Author SHA1 Message Date
Jes Sorensen 70b4f4bb05 Make strtosz() return int64_t instead of ssize_t
strtosz() needs to return a 64 bit type even on 32 bit
architectures. Otherwise qemu-img will fail to create disk
images >= 2GB

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-24 11:08:50 +01:00
Blue Swirl 2d5b50749a monitor: fix a typo
Fix usage of wrong variable, spotted by clang:
/src/qemu/monitor.c:2278:36: warning: The left operand of '&' is a garbage value
                        prot = pde & (PG_USER_MASK | PG_RW_MASK |

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-01-15 08:31:00 +00:00
Aurelien Jarno 818c2e1b97 Merge branch 'spice.v23.pull' of git://anongit.freedesktop.org/spice/qemu
* 'spice.v23.pull' of git://anongit.freedesktop.org/spice/qemu:
  vnc/spice: add set_passwd monitor command.
  vnc: support password expire
  vnc: auth reject cleanup
  spice: add qmp 'query-spice' and hmp 'info spice' commands.
  spice: connection events.
  spice: add qxl device
  spice: add qxl vgabios binary.
2010-12-27 22:59:48 +01:00
Blue Swirl d41160a3e6 Sparc: implement monitor command 'info tlb'
Use existing dump_mmu() to implement monitor command 'info tlb'.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-19 13:42:56 +00:00
Anthony Liguori fef395782d Merge remote branch 'qmp/for-anthony' into staging 2010-12-17 08:23:05 -06:00
Blue Swirl 1b3cba6e91 monitor: implement x86 info mem for PAE and long modes
'info mem' didn't show correct information for PAE mode and
x86_64 long mode.

Fix by implementing the output for missing modes.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-11 18:56:27 +00:00
Blue Swirl d65aaf3773 monitor: implement x86 info tlb for PAE and long modes
'info tlb' didn't show correct information for PAE mode and
x86_64 long mode.

Implement the missing modes. Also print NX bit for PAE and long modes.
Fix off-by-one error in 32 bit mode mask.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-12-11 18:56:24 +00:00
Gerd Hoffmann 7572150c18 vnc/spice: add set_passwd monitor command.
This patch adds new set_password and expire_password monitor commands
which allows to change and expire the password for spice and vnc
connections.  See the doc update patch chunk for details.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-12-09 14:23:25 +01:00
Gerd Hoffmann cb42a870c3 spice: add qmp 'query-spice' and hmp 'info spice' commands.
The patch adds a 'query-spice' monitor command which returns
informations about the spice server configuration and also a list of
channel connections.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-12-09 14:23:24 +01:00
Gerd Hoffmann 6f8c63fbd7 spice: connection events.
This patch adds support for connection events to spice.  The events are
quite simliar to the vnc events.  Unlike vnc spice uses multiple tcp
channels though.  qemu will report every single tcp connection (aka
spice channel).  If you want track spice sessions only you can filter
for the main channel (channel-type == 1).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2010-12-09 14:23:24 +01:00
Luiz Capitulino 83a27d4d1c QMP: Simplify monitor_json_emitter()
Use the ternary operator instead of an if (also fixes bad indentation).

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-12-06 09:51:41 -02:00
Luiz Capitulino 6d44143054 QMP: Drop dead code
The first if/else clause in handler_audit() makes no sense for two
reasons:

  1. this function is now called only by QMP code, so testing if
     it's a QMP call makes no sense anymore

  2. the else clause first asserts that there's no error in the
     monitor object, then it tries to free it!

Just drop it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-12-06 09:51:41 -02:00
Luiz Capitulino c01e688531 QMP: Fix default response regression
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-12-06 09:51:41 -02:00
Luiz Capitulino 0268d97c51 QMP: Introduce Human Monitor passthrough command
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-17 09:52:24 -02:00
Jes Sorensen 07de3e60b0 Remove obsolete 'f' double parameter type
'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-03 12:48:09 -05:00
Jes Sorensen dbc0c67faf Add support for 'o' octet (bytes) format as monitor parameter.
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-11-03 12:48:09 -05:00
Kusanagi Kouichi 46c7fc182d monitor: Ignore "." and ".." when completing file name.
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-22 10:08:38 -02:00
Blue Swirl f871d6893a trace: print a warning if user tries to enable an unknown trace event
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-13 19:14:29 +00:00
Anthony Liguori 48f57044e6 Merge remote branch 'qmp/for-anthony' into staging 2010-10-05 13:54:49 -05:00
Stefan Weil 8b7968f7c4 Use GCC_FMT_ATTR (format checking)
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-10-03 06:34:51 +00:00
Luiz Capitulino acd0a09337 Monitor: Rename the qemu-monitor.hx file
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-01 10:20:07 -03:00
Luiz Capitulino fc29df759e QMP: Introduce qmp_call_cmd()
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-01 10:20:07 -03:00
Luiz Capitulino de79ba6f53 Monitor: Directly call QObject handlers
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-01 10:20:07 -03:00
Luiz Capitulino 4903de0ceb Monitor: Rename monitor_handler_is_async()
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-01 10:20:07 -03:00
Luiz Capitulino 9e80721eff Monitor: Rename monitor_handler_ported()
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-01 10:20:06 -03:00
Luiz Capitulino 0e19a62770 Monitor: Drop monitor_cmd_user_only()
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-01 10:20:06 -03:00
Luiz Capitulino 30f5041ef1 Monitor: Drop QMP info from the qemu-monitor.hx file
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-01 10:20:06 -03:00
Luiz Capitulino d1249eaa4b QMP: Small cleanup in handle_qmp_command()
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-01 10:20:06 -03:00
Luiz Capitulino 2e061a7c86 QMP: Simplify do_info_commands()
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-01 10:20:06 -03:00
Luiz Capitulino 3e12a751ed QMP: Introduce query commands dispatch table
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-01 10:20:06 -03:00
Luiz Capitulino f36b4afba9 QMP: Introduce command dispatch table
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-01 10:20:06 -03:00
Luiz Capitulino bead3ce139 QMP: Introduce qmp_find_cmd()
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-01 10:20:06 -03:00
Luiz Capitulino 1162daa6c1 Monitor: Convert do_info() back to HMP
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-01 10:20:06 -03:00
Luiz Capitulino d4551293d6 Monitor: Drop is_async_return()
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-01 10:20:06 -03:00
Luiz Capitulino 1dcbd6f6b7 Monitor: Drop QMP bits from do_info()
As of last commit, QMP doesn't use do_info() anymore. Simplify it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-10-01 10:20:06 -03:00
Luiz Capitulino 030db6e89d QMP: Don't use do_info()
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-01 10:20:06 -03:00
Luiz Capitulino 0fb88582e6 QMP: handle_qmp_command(): Move 'cmd' sanity check
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-01 10:20:06 -03:00
Luiz Capitulino 945c5ac8d3 Monitor: Introduce search_dispatch_table()
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-01 10:20:06 -03:00
Daniel P. Berrange 39eaab9ac2 Add option to turn on JSON pretty printing in monitor
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-10-01 10:12:43 -03:00
Stefan Hajnoczi c5ceb523fa trace: Add trace-file command to open/close/flush trace file
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-09 16:22:44 -05:00
Prerna Saxena 22890ab5e8 trace: Support for dynamically enabling/disabling trace events
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-09-09 16:22:44 -05:00
Miguel Di Ciurcio Filho 0ec0291d67 QMP/monitor: update do_info_version() to output broken down version string
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-22 17:11:06 -05:00
Miguel Di Ciurcio Filho f0aa7a8b2d loadvm: improve tests before bdrv_snapshot_goto()
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-08-03 15:57:22 +02:00
Amit Shah 8e84865e54 migration: Accept 'cont' only after successful incoming migration
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-30 23:14:08 +02:00
Anthony Liguori 02d0ba1420 Merge remote branch 'qmp/for-anthony' into staging 2010-07-06 08:31:17 -05:00
Paolo Bonzini a88790a14f remove exec-all.h inclusion from cpu.h
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-03 09:48:24 +03:00
Jan Kiszka a6c4d36425 monitor: Allow to exclude commands from QMP
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-01 14:27:14 -03:00
Luiz Capitulino e4940c603a QMP: handle_qmp_command(): Small cleanup
Drop a unneeded label and QDECREF() call.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01 14:27:14 -03:00
Luiz Capitulino 0bbab46db6 QMP: Drop old input object checking
Previous commit added qmp_check_input_obj(), it does all the
checking we need.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-07-01 14:27:13 -03:00
Luiz Capitulino c917c8f3d0 QMP: Introduce qmp_check_input_obj()
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-01 14:27:13 -03:00