Commit Graph

760 Commits

Author SHA1 Message Date
Anthony Liguori b85a4ec8a7 Merge remote-tracking branch 'stefanha/trivial-patches' into staging
* stefanha/trivial-patches:
  qemu-ga: for w32, fix leaked handle ov.hEvent in ga_channel_write()
  ioapic: fix build with DEBUG_IOAPIC
  .gitignore: add qemu-bridge-helper and option rom build products
  cleanup obsolete typedef
  monitor: Remove unused bool field 'qapi' in mon_cmd_t struct
  ds1338: Add missing break statement
  vnc: Fix packed boolean struct members
  Remove type field in ModuleEntry as it's not used
2012-03-19 13:37:41 -05:00
Yonit Halperin 6ec5dae5a4 monitor: fix client_migrate_info error handling
Report QERR_MISSING_PARAMETER when port is missing. Otherwise
QERR_UNDEFINED_ERROR will occur.

rhbz #795652

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-03-19 13:12:19 +01:00
Jeff Cody c07c163e0e monitor: Remove unused bool field 'qapi' in mon_cmd_t struct
Some minor code cleanup: the 'qapi' bool field in mon_cmd_t is
unused, and can be removed.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-03-19 10:52:52 +00:00
Andreas Färber 9349b4f9fd Rename CPUState -> CPUArchState
Scripted conversion:
  for file in *.[hc] hw/*.[hc] hw/kvm/*.[hc] linux-user/*.[hc] linux-user/m68k/*.[hc] bsd-user/*.[hc] darwin-user/*.[hc] tcg/*/*.[hc] target-*/cpu.h; do
    sed -i "s/CPUState/CPUArchState/g" $file
  done

All occurrences of CPUArchState are expected to be replaced by QOM CPUState,
once all targets are QOM'ified and common fields have been extracted.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2012-03-14 22:20:27 +01:00
Andreas Färber e59d167fe4 monitor: Don't access registers through CPUState
Use CPUX86State etc. instead (hand-converted).

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2012-03-14 22:20:24 +01:00
Blue Swirl b3e54c689c Merge branch 'xtensa' of git://jcmvbkbc.spb.ru/dumb/qemu-xtensa
* 'xtensa' of git://jcmvbkbc.spb.ru/dumb/qemu-xtensa:
  target-xtensa: add breakpoint tests
  target-xtensa: add DEBUG_SECTION to overlay tool
  target-xtensa: add DBREAK data breakpoints
  exec: let cpu_watchpoint_insert accept larger watchpoints
  exec: fix check_watchpoint exiting cpu_loop
  exec: add missing breaks to the watch_mem_write
  target-xtensa: add ICOUNT SR and debug exception
  target-xtensa: implement instruction breakpoints
  target-xtensa: add DEBUGCAUSE SR and configuration
  target-xtensa: fetch 3rd opcode byte only when needed
  target-xtensa: implement info tlb monitor command
  target-xtensa: define TLB_TEMPLATE for MMU-less cores
2012-03-03 17:53:41 +00:00
Gerd Hoffmann 53370b78ec suspend: add qmp events
Send qmp events on suspend and wakeup so libvirt
has a chance to track the vm state.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-24 13:36:04 -06:00
Luiz Capitulino 6f382ed226 qmp: add DEVICE_TRAY_MOVED event
It's emitted whenever the tray is moved by the guest or by HMP/QMP
commands.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
2012-02-22 17:23:50 -02:00
Daniel P. Berrange f1f5f4070c Add SPICE support to add_client monitor command
With the acceptance of some new APIs to libspice-server.so it
is possible to add support for SPICE to the 'add_client'
monitor command, bringing parity with VNC. Since SPICE can
use TLS or plain connections, the command also gains a new
'tls' parameter to specify whether TLS should be attempted
on the injected client sockets.

This new feature is only enabled if building against a
libspice-server >= 0.10.1

* qmp-commands.hx: Add 'tls' parameter & missing doc for
  'skipauth' parameter
* monitor.c: Wire up SPICE for 'add_client' command
* ui/qemu-spice.h, ui/spice-core.c: Add qemu_spice_display_add_client
  API to wire up from monitor

[1] http://cgit.freedesktop.org/spice/spice/commit/server/spice.h?id=d55b68b6b44f2499278fa860fb47ff22f5011faa
    http://cgit.freedesktop.org/spice/spice/commit/server/spice.h?id=bd07dde530d9504e1cfe7ed5837fc00c26f36716

Changes in v3:
 - Added 'optional' flag to new parameters documented
 - Added no-op impl of qemu_spice_display_add_client when
   SPICE is disabled during build

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-21 10:36:05 +01:00
Max Filippov 692f737cc2 target-xtensa: implement info tlb monitor command
Command dumps valid ITLB and DTLB entries.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2012-02-18 01:25:28 +04:00
Stefan Hajnoczi fb5458cd10 qmp: add query-block-jobs
Add query-block-jobs, which shows the progress of ongoing block device
operations.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-01-26 14:49:18 +01:00
Stefan Hajnoczi 370521a1d6 qmp: add block_job_cancel command
Add block_job_cancel, which stops an active block streaming operation.
When the operation has been cancelled the new BLOCK_JOB_CANCELLED event
is emitted.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-01-26 14:49:18 +01:00
Stefan Hajnoczi 12bd451fe0 qmp: add block_stream command
Add the block_stream command, which starts copy backing file contents
into the image file.  Also add the BLOCK_JOB_COMPLETED QMP event which
is emitted when image streaming completes.  Later patches add control
over the background copy speed, cancelation, and querying running
streaming operations.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-01-26 14:49:14 +01:00
Luiz Capitulino 333a96ec9f qapi: Convert change
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-01-18 10:23:39 -02:00
Luiz Capitulino 903a881481 qerror: Extend QERR_DEVICE_ENCRYPTED
Include the name of the encrypted file.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-01-18 10:23:39 -02:00
Anthony Liguori 7060b478d3 monitor: expose readline state
HMP is now implemented in terms of QMP.  The monitor has a bunch of logic to
deal with HMP right now like readline support.  Export it from the monitor so
we can consume it in hmp.c.

In short time, hmp.c will take over all of the readline bits.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-01-18 10:23:39 -02:00
Luiz Capitulino 9ad5372daa qapi: Convert expire_password
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-01-18 10:23:38 -02:00
Luiz Capitulino fbf796fd6f qapi: Convert set_password
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-01-18 10:23:38 -02:00
Luiz Capitulino a6aa9d3e26 vnc: Simplify vnc_display_password()
Drop the qerror_report() call from it and let its callers set the error
themselves. This also allows for dropping the 'ret' variable.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-01-18 10:23:38 -02:00
Luiz Capitulino d51a67b4d3 qapi: Convert human-monitor-command
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-12-06 11:40:01 -02:00
Luiz Capitulino ab49ab5c48 qapi: Convert inject-nmi
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-12-06 11:40:01 -02:00
Luiz Capitulino e42e818bf4 qapi: Convert cont
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-12-06 11:40:01 -02:00
Luiz Capitulino 6d3962bf84 qapi: Convert pmemsave
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-12-06 11:40:01 -02:00
Luiz Capitulino 0cfd6a9ab4 qapi: Convert memsave
Please, note that the QMP command has a new 'cpu-index' parameter.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-12-06 11:40:00 -02:00
Luiz Capitulino 22e1bb9c15 qapi: Complete system_powerdown conversion
Commit 5bc465e4b1 converted only
the HMP part of the system_powerdown command to the QAPI, this
commit completes it by converting the QMP part too.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-12-06 11:40:00 -02:00
Markus Armbruster c951d9a675 monitor: Fix file_completion() to check for stat() failure
stat() can fail for a file name just read with readdir().  Easiest way
to trigger is a dangling symbolic link --- look ma, no race!  When it
fails, file_completion() uses sb.st_mode uninitialized.  If the
directory bit happens to be set, it appends a "/" to the completed
name.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-11-17 12:57:49 +00:00
Wayne Xia 816f89256e Sort the help info shown in monitor at runtime
This patch would try sort the command list in monitor at runtime. As a result,
command help and help info would show a more friendly sorted command list.
For eg:
(qemu)help
acl_add
acl_policy
acl_remove
acl_reset
acl_show
balloon
block_passwd
...
the command list is sorted.

v3: using qsort function to sort the command list.

Tested-by: Wenyi Gao <wenyi@linux.vnet.ibm.com>
Signed-off-by: Wayne Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-01 16:52:08 -05:00
Anthony Liguori 96b3d73f5a Merge remote-tracking branch 'qmp/queue/qmp' into staging
Conflicts:
	ui/spice-core.c
2011-10-31 11:02:29 -05:00
Anthony Liguori eca968d0d4 Merge remote-tracking branch 'spice/spice.v45' into staging 2011-10-31 10:12:14 -05:00
Luiz Capitulino b5c30586c9 Monitor: do_info(): Drop QMP command handling code
Previous commits converted all existing QMP commands to the QAPI,
now each info command does its own QMP call.

Let's then drop all QMP command handling code from do_info().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino 40e5a01d1a QMP: Drop the query commands dispatch table
Because QMP development originated in the monitor, it has
inherited the monitor's distinction between query- and
non-query commands.

However, previous commits unified both commands and the
distinction is gone. This commit drops the query commands
dispatch table and does some simplifications along the way.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino 79627472db qapi: Convert query-pci
This also fixes a bug with the old version: QMP would invert device id
and vendor id. This would look ok on HMP because it was printing
"device:vendor" instead of "vendor:device".

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino 96637bcdf9 qapi: Convert query-balloon
Please, note that some of the code supporting memory statistics is
still around (eg. virtio_balloon_receive_stats() and reset_stats()).

Also, the qmp_query_balloon() function is synchronous and thus doesn't
make any use of the (not fully working) monitor's asynchronous command
support (the old non-qapi implementation did).

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino d1f29646f2 qapi: Convert query-spice
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino 2b54aa879e qapi: Convert query-vnc
There are three important remarks in relation to the non-qapi command:

 1. This commit also fixes the behavior of the 'query-vnc' and 'info vnc'
    commands to return an error when qemu is built without VNC support
    (ie. --disable-vnc). The non-qapi command would return the OK
    response in QMP and no response in HMP

 2. The qapi version explicitly marks the fields 'host', 'family',
    'service' and 'auth' as optional. Their are not documented as optional
    in the non-qapi command doc, but they would not be returned if
    vnc support is disabled. The qapi version maintains the same
    semantics, but documents those fields correctly

 3. The 'clients' field, which is a list, is marked as optional but is
    always returned. If there are no clients connected an empty list
    is returned. This is not the Right Way to this in the qapi but it's
    how the non-qapi command used to work

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino f11f57e405 qapi: Convert query-blockstats
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino b202381800 qapi: Convert query-block
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino de0b36b67e qapi: Convert query-cpus
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:47 -02:00
Luiz Capitulino 755f196898 qapi: Convert the cpu command
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:46 -02:00
Luiz Capitulino 99b7796f60 Monitor: Introduce monitor_get_cpu_index()
Returns 'cur_mons's CPU index. A future commit will use it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:46 -02:00
Luiz Capitulino b025c8b4ab Monitor: Make mon_set_cpu() public
Also rename it to monitor_set_cpu().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:46 -02:00
Luiz Capitulino 791e7c820e qapi: Convert query-migrate
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:46 -02:00
Luiz Capitulino e235cec376 qapi: Convert query-mice
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-27 11:48:46 -02:00
Richard Henderson 30038fd818 target-sparc: Change fpr representation to doubles.
This allows a more efficient representation for 64-bit hosts.
It should be about the same for 32-bit hosts, as we can still
access the individual pieces of the double.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2011-10-26 13:55:26 -07:00
Yonit Halperin edc5cb1a52 spice: turn client_migrate_info to async
RHBZ 737921
Spice client is required to connect to the migration target before/as migration
starts. Since after migration starts, the target qemu is blocked and cannot accept new spice client
we trigger the connection to the target upon client_migrate_info command.
client_migrate_info completion cb will be called after spice client has been
connected to the target (or a timeout). See following patches and spice patches.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-10-25 14:00:53 +02:00
Jan Kiszka 661f1929d0 monitor: Restrict pic/irq_info to supporting targets
This allows to drop various stubs and move the i8359 into hwlib.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-16 11:11:55 +00:00
Luiz Capitulino 28a7282a5d block: Keep track of devices' I/O status
This commit adds support to the BlockDriverState type to keep track
of devices' I/O status.

There are three possible status: BDRV_IOS_OK (no error), BDRV_IOS_ENOSPC
(no space error) and BDRV_IOS_FAILED (any other error). The distinction
between no space and other errors is important because a management
application may want to watch for no space in order to extend the
space assigned to the VM and put it to run again.

Qemu devices supporting the I/O status feature have to enable it
explicitly by calling bdrv_iostatus_enable() _and_ have to be
configured to stop the VM on errors (ie. werror=stop|enospc or
rerror=stop).

In case of multiple errors being triggered in sequence only the first
one is stored. The I/O status is always reset to BDRV_IOS_OK when the
'cont' command is issued.

Next commits will add support to some devices and extend the
query-block/info block commands to return the I/O status information.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-11 09:41:47 +02:00
Anthony Liguori ebffe2afce Merge remote-tracking branch 'qmp/queue/qmp' into staging 2011-10-10 08:21:46 -05:00
Blue Swirl 211685040f Merge branch 'tracing' of git://repo.or.cz/qemu/stefanha
* 'tracing' of git://repo.or.cz/qemu/stefanha:
  trace: add arguments to bdrv_co_io_em() trace event
  trace: trace monitor qmp dispatch/completion
  trace: trace bdrv_open_common()
  hmp: re-enable trace-file command
2011-10-08 15:38:14 +00:00
Scott Wood bebabbc7aa ppc: booke206: add "info tlb" support
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-10-06 09:48:04 +02:00
Luiz Capitulino 38d226535a qapi: Convert system_reset
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino 5f158f21f9 qapi: Convert stop
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino 7a7f325e05 qapi: Convert quit
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino aa9b79bcd8 qapi: Convert query-commands
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino c5a415a0af qapi: Convert query-chardev
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino efab767eaa qapi: Convert query-uuid
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino 1fa9a5e4ae qapi: Convert query-status
Please, note that the RunState type as defined in sysemu.h and its
runstate_as_string() function are being dropped in favor of the
RunState type generated by the QAPI.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino 0461d5a699 RunState: Rename enum values as generated by the QAPI
Next commit will convert the query-status command to use the
RunState type as generated by the QAPI.

In order to "transparently" replace the current enum by the QAPI
one, we have to make some changes to some enum values.

As the changes are simple renames, I'll do them in one shot. The
changes are:

 - Rename the prefix from RSTATE_ to RUN_STATE_
 - RUN_STATE_SAVEVM to RUN_STATE_SAVE_VM
 - RUN_STATE_IN_MIGRATE to RUN_STATE_INMIGRATE
 - RUN_STATE_PANICKED to RUN_STATE_INTERNAL_ERROR
 - RUN_STATE_POST_MIGRATE to RUN_STATE_POSTMIGRATE
 - RUN_STATE_PRE_LAUNCH to RUN_STATE_PRELAUNCH
 - RUN_STATE_PRE_MIGRATE to RUN_STATE_PREMIGRATE
 - RUN_STATE_RESTORE to RUN_STATE_RESTORE_VM
 - RUN_STATE_PRE_MIGRATE to RUN_STATE_FINISH_MIGRATE

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino 292a26027c qapi: Convert query-kvm
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:02:57 -03:00
Luiz Capitulino b9c15f16d7 qapi: Convert query-version
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:01:30 -03:00
Anthony Liguori 48a32bedfe qapi: convert query-name
A simple example conversion 'info name'.  This also adds the new files for
QMP and HMP.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:01:30 -03:00
Anthony Liguori e3193601c8 qapi: use middle mode in QMP server
Use the new middle mode within the existing QMP server.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04 11:00:46 -03:00
Stefan Hajnoczi 89bd820acb trace: trace monitor qmp dispatch/completion
Add trace events for handle_qmp_command(), which dispatches qmp
commands, and monitor_protocol_emitter(), which produces the reply to a
qmp command.

Also remove duplicate #include "trace/control.h".

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-03 10:56:25 +01:00
Michael Roth c45a81682d hmp: re-enable trace-file command
Commit 31965ae27b reverted a previous
renaming of CONFIG_SIMPLE_TRACE->CONFIG_TRACE_SIMPLE in a couple spots,
leading to trace-file currently being unavailable.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-03 10:55:50 +01:00
Blue Swirl 314e298735 memory: simple memory tree printer
Add a monitor command 'info mtree' to show the memory hierarchy
much like /proc/iomem in Linux.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-02 16:27:13 +02:00
Luiz Capitulino 6e0ca8820d HMP: info status: Print the VM state
Today our printf format for the "info status" command is:

  VM status: %s

Where the string can be "running", "running (single step mode)" or
"paused".

This commit extends it to:

 VM status: %s (%s)

The second string corresponds to the "status" field as returned
by the query-status QMP command and it's only printed if "status"
is not "running" or "paused".

Example:

 VM status: paused (shutdown)

PS: libvirt uses "info status" when using HMP, but the new format
    should not break it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15 16:39:32 -03:00
Luiz Capitulino 9e37b9dc5b QMP: query-status: Introduce 'status' key
This new key reports the current VM status to clients. Please, check
the documentation being added in this commit for more details.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15 16:39:32 -03:00
Luiz Capitulino 6667b23f30 Monitor/QMP: Don't allow cont on bad VM state
We have two states where issuing cont before system_reset can
cause problems: RSTATE_SHUTDOWN (when -no-shutdown is used) and
RSTATE_PANICKED (which only happens with kvm).

This commit fixes that by doing the following when state is
RSTATE_SHUTDOWN or RSTATE_PANICKED:

 1. returning an error to the user/client if cont is issued
 2. automatically transition to RSTATE_PAUSED during system_reset

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15 16:39:32 -03:00
Luiz Capitulino 1354869c38 Drop the vm_running global variable
Use runstate_is_running() instead, which is introduced by this commit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15 16:39:32 -03:00
Luiz Capitulino 1bcef683bf Drop the incoming_expected global variable
Test against RSTATE_IN_MIGRATE instead.

Please, note that the RSTATE_IN_MIGRATE state is only set when all the
initial VM setup is done, while 'incoming_expected' was set right in
the beginning when parsing command-line options. Shouldn't be a problem
as far as I could check.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15 16:39:32 -03:00
Luiz Capitulino 1dfb4dd993 Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(),
we pass a VMSTOP macro as the 'reason' argument. This is not ideal
because the VMSTOP macros tell why qemu stopped and not exactly
what the current VM state is.

One example to demonstrate this problem is that vm_start() calls
vm_state_notify() with reason=0, which turns out to be VMSTOP_USER.

This commit fixes that by replacing the VMSTOP macros with a proper
state type called RunState.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15 16:39:32 -03:00
Nathan Kunkee 3f9c359507 SPARC: Trivial patch to clean up npc monitor output
This patch fixes the spacing of the PC output from 'info cpus' for
SPARC.

Signed-off-by: Nathan Kunkee <nkunkee42@hotmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-09-09 09:50:52 +01:00
Lluís 31965ae27b trace: always compile support for controlling and querying trace event states
The current interface is generic for this small set of operations, and thus
other backends can easily modify the "trace/control.c" file to add their own
implementation.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
2011-09-01 10:34:54 +01:00
Lluís fc76410539 trace: separate trace event control and query routines from the simple backend
Generalize the 'st_print_trace_events' and 'st_change_trace_event_state' into
backend-specific 'trace_print_events' and 'trace_event_set_state' (respectively)
in the "trace/control.h" file.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
2011-09-01 10:34:54 +01:00
Lluís 6d8a764e0f trace: [configure] rename CONFIG_*_TRACE into CONFIG_TRACE_*
Provides a more hierarchical view of the variable domain.

Also adds the CONFIG_TRACE_* variables for all backends.

[Stefan added missing 'test' in stap if statement]

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-09-01 10:34:53 +01:00
Jamie Iles 860341f605 monitor: fix build breakage for !CONFIG_VNC
Commit c62f6d1 (monitor: fix build breakage with --disable-vnc)
conditionalised some VNC setup code but left an unused variable.  Move
the variable into the conditional code to fix the build breakage.

Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-08-25 12:40:07 -03:00
Anthony Liguori 74c0d6f020 char: rename qemu_chr_get_msgfd() -> qemu_chr_fe_get_msgfd()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:44 -05:00
Anthony Liguori 15f31519b4 char: rename qemu_chr_set_echo() -> qemu_chr_fe_set_echo()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:37 -05:00
Anthony Liguori 2cc6e0a142 char: rename qemu_chr_write() -> qemu_chr_fe_write()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-22 10:17:15 -05:00
Austin Clements 94ac5cd20c monitor: Prevent sign-extension of 32-bit addresses printed by info tlb
This is the same fix that was recently applied to info mem.  Before
this change, info tlb output looked like:

ffffffffffffc000: 000000000fffc000 --------W
ffffffffffffd000: 000000000fffd000 --------W
ffffffffffffe000: 000000000fffe000 --------W
fffffffffffff000: 000000000ffff000 --------W

With this change, it looks like

00000000ffffc000: 000000000fffc000 --------W
00000000ffffd000: 000000000fffd000 --------W
00000000ffffe000: 000000000fffe000 --------W
00000000fffff000: 000000000ffff000 --------W

Signed-off-by: Austin Clements <amdragon@mit.edu>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 19:50:03 +00:00
Austin Clements c76c8416be monitor: Show combined protection bits in "info mem"
Previously, "info mem" considered and displayed only the last-level
protection bits for a memory range, which doesn't accurrately
represent the protection of that range.  Now it shows the combined
protection.

Signed-off-by: Austin Clements <amdragon@mit.edu>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 16:42:39 +00:00
Austin Clements 8a94b8ca53 monitor: Fix "info mem" to print the last memory range
"info mem" groups its output into contiguous ranges with identical
protection bits, but previously forgot to print the last range.

Signed-off-by: Austin Clements <amdragon@mit.edu>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 16:42:36 +00:00
Austin Clements b49ca72dd7 monitor: Prevent sign-extension of 32-bit addresses printed by info mem
Previously, on 32-bit i386, info mem used signed 32-bit int's to store
the page table indexes.  As a result, address calculation was done in
32 bits and then incorrectly sign-extended to 64 bits, yielding output
like

ffffffffef000000-ffffffffef031000 0000000000031000 ur-
ffffffffef7bc000-ffffffffef7bd000 0000000000001000 urw
ffffffffef7bd000-ffffffffef7be000 0000000000001000 ur-

This makes these indexes unsigned, which yields correct output

00000000ef000000-00000000ef031000 0000000000031000 ur-
00000000ef7bc000-00000000ef7bd000 0000000000001000 urw
00000000ef7bd000-00000000ef7be000 0000000000001000 ur-

Signed-off-by: Austin Clements <amdragon@mit.edu>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-21 16:42:31 +00:00
Anthony Liguori 7267c0947d Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20 23:01:08 -05:00
TeLeMan c62f6d1d76 monitor: fix build breakage with --disable-vnc
The breakage was introduced by the commit 1366108981

Signed-off-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-29 09:33:56 -05:00
Daniel P. Berrange 1366108981 Introduce a 'client_add' monitor command accepting an open FD
Allow client connections for VNC and socket based character
devices to be passed in over the monitor using SCM_RIGHTS.

One intended usage scenario is to start QEMU with VNC on a
UNIX domain socket. An unprivileged user which cannot access
the UNIX domain socket, can then connect to QEMU's VNC server
by passing an open FD to libvirt, which passes it onto QEMU.

 { "execute": "get_fd", "arguments": { "fdname": "myclient" } }
 { "return": {} }
 { "execute": "add_client", "arguments": { "protocol": "vnc",
                                           "fdname": "myclient",
                                           "skipauth": true } }
 { "return": {} }

In this case 'protocol' can be 'vnc' or 'spice', or the name
of a character device (eg from -chardev id=XXXX)

The 'skipauth' parameter can be used to skip any configured
VNC authentication scheme, which is useful if the mgmt layer
talking to the monitor has already authenticated the client
in another way.

* console.h: Define 'vnc_display_add_client' method
* monitor.c: Implement 'client_add' command
* qemu-char.c, qemu-char.h: Add 'qemu_char_add_client' method
* qerror.c, qerror.h: Add QERR_ADD_CLIENT_FAILED
* qmp-commands.hx: Declare 'client_add' command
* ui/vnc.c: Implement 'vnc_display_add_client' method

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-23 11:19:02 -05:00
Blue Swirl 2b41f10e18 Remove exec-all.h include directives
Most exec-all.h include directives are now useless, remove them.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-06-26 18:25:35 +00:00
Luiz Capitulino e9b4b432e7 HMP: Use QMP inject nmi implementation
This **CHANGES** the human monitor "nmi" command behavior.

Currently it accepts an CPU argument which, when provided, will send
the NMI to the specified CPU. This feature is of discussable value
though and HMP shouldn't have more features than QMP, so let's use
QMP's instead (it's also simpler).

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-06-01 11:42:25 -03:00
Lai Jiangshan a404666457 QMP: add inject-nmi qmp command
inject-nmi command injects an NMI on all CPUs of guest.
It is only supported for x86 guest currently, it will
returns "Unsupported" error for non-x86 guest.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-06-01 11:42:25 -03:00
Scott Wood 90dc881222 monitor: add PPC BookE SPRs
Read them via KVM_GET_SREGS in kvm_arch_get_registers(),
and display them in "info registers".

Also get CR and PID from the existing KVM_GET_REGS.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-05-09 22:31:37 +02:00
Stefan Weil 54f7b4a396 Replace cpu_physical_memory_rw were possible
Using cpu_physical_memory_read, cpu_physical_memory_write and ldub_phys
improves readability and allows removing some type casts.

lduw_phys and ldl_phys were not used because both require aligned
addresses. Therefore it is not possible to simply replace existing
calls by one of these functions.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-12 21:51:50 +02:00
Stefan Weil b8b79323d0 monitor: Remove some type casts which are no longer needed
All other type casts in calls of cpu_physical_memory_read are
used by hardware emulations and will be fixed by separate patches.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-12 21:51:50 +02:00
David Gibson bb593904c1 Parse SDR1 on mtspr instead of at translate time
On ppc machines with hash table MMUs, the special purpose register SDR1
contains both the base address of the encoded size (hashed) page tables.

At present, we interpret the SDR1 value within the address translation
path.  But because the encodings of the size for 32-bit and 64-bit are
different this makes for a confusing branch on the MMU type with a bunch
of curly shifts and masks in the middle of the translate path.

This patch cleans things up by moving the interpretation on SDR1 into the
helper function handling the write to the register.  This leaves a simple
pre-sanitized base address and mask for the hash table in the CPUState
structure which is easier to work with in the translation path.

This makes the translation path more readable.  It addresses the FIXME
comment currently in the mtsdr1 helper, by validating the SDR1 value during
interpretation.  Finally it opens the way for emulating a pSeries-style
partition where the hash table used for translation is not mapped into
the guests's RAM.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-04-01 18:34:55 +02:00
Jes Sorensen 821601ea5b Make VNC support optional
Per default VNC is enabled.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-03-22 08:39:12 -05:00
Anthony Liguori 31b7c261a2 Merge remote branch 'qemu-kvm/uq/master' into staging 2011-03-21 17:42:20 -05:00
Paolo Bonzini 7447545544 change all other clock references to use nanosecond resolution accessors
This was done with:

    sed -i 's/qemu_get_clock\>/qemu_get_clock_ns/' \
        $(git grep -l 'qemu_get_clock\>' )
    sed -i 's/qemu_new_timer\>/qemu_new_timer_ns/' \
        $(git grep -l 'qemu_new_timer\>' )

after checking that get_clock and new_timer never occur twice
on the same line.  There were no missed occurrences; however, even
if there had been, they would have been caught by the compiler.

There was exactly one false positive in qemu_run_timers:

     -    current_time = qemu_get_clock (clock);
     +    current_time = qemu_get_clock_ns (clock);

which is of course not in this patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-03-21 09:23:23 +01:00
Jan Kiszka dc7a09cfe4 Expose thread_id in info cpus
Based on patch by Glauber Costa:

To allow management applications like libvirt to apply CPU affinities to
the VCPU threads, expose their ID via info cpus. This patch provides the
pre-existing and used interface from qemu-kvm.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-03-16 17:11:07 -03:00
Jan Kiszka 747461c76b x86: Optionally avoid injecting AO MCEs while others are pending
Allow to tell cpu_x86_inject_mce that it should ignore Action Optional
MCE events when the target VCPU is still processing another one. This
will be used by KVM soon.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Huang Ying <ying.huang@intel.com>
CC: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
CC: Jin Dongming <jin.dongming@np.css.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-03-15 01:19:05 -03:00
Jan Kiszka 316378e4d0 x86: Refine error reporting of MCE injection services
As this service is used by the human monitor, make sure that errors get
reported to the right channel, and also raise the verbosity.

This requires to move Monitor typedef in qemu-common.h to resolve the
include dependency.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Huang Ying <ying.huang@intel.com>
CC: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
CC: Jin Dongming <jin.dongming@np.css.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-03-15 01:19:05 -03:00
Jan Kiszka 2fa11da0c3 x86: Small cleanups of MCE helpers
Fix some code style issues, use proper headers, and align to cpu_x86
naming scheme. No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Huang Ying <ying.huang@intel.com>
CC: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
CC: Jin Dongming <jin.dongming@np.css.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-03-15 01:19:05 -03:00
Jan Kiszka e07bbac542 Improve vm_stop reason declarations
Define and use dedicated constants for vm_stop reasons, they actually
have nothing to do with the EXCP_* defines used so far. At this chance,
specify more detailed reasons so that VM state change handlers can
evaluate them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Paolo Bonzini c48855e140 add qemu_chr_set_echo
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01 16:50:43 -06:00
Anthony Liguori b3a98367ee Merge remote branch 'qemu-kvm/uq/master' into staging
aliguori: fix build with !defined(KVM_CAP_ASYNC_PF)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-01 15:32:18 -06:00
Anthony Liguori 9363ee31ab Merge remote branch 'spice/spice.v29.pull' into staging
Conflicts:
	trace-events
2011-02-01 15:22:48 -06:00
Anthony Liguori 1cd20f8bf0 vnc: Fix password expiration through 'change vnc ""' (v2)
commit 52c18be9e9 introduced a regression in the
change vnc password command that changed the behavior of setting the VNC
password to an empty string from disabling login to disabling authentication.

This commit refactors the code to eliminate this overloaded semantics in
vnc_display_password and instead introduces the vnc_display_disable_login.   The
monitor implementation then determines the behavior of an empty or missing
string.

Recently, a set_password command was added that allows both the Spice and VNC
password to be set.  This command has not shown up in a release yet so the
behavior is not yet defined.

This patch proposes that an empty password be treated as an empty password with
no special handling.  For specifically disabling login, I believe a new command
should be introduced instead of overloading semantics.

I'm not sure how Spice handles this but I would recommend that we have Spice
and VNC have consistent semantics here for the 0.14.0 release.

Reported-by: Neil Wilson <neil@aldur.co.uk>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1 -> v2
 - Add a proper return to make sure that login is really disabled instead of
   relying on the VNC server to treat empty passwords specially
2011-02-01 15:16:48 -06:00
Isaku Yamahata d00b261816 monitor: use after free in do_wav_capture()
use after free in do_wav_capture() on the error path.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-01-25 09:22:51 +01:00
Marc-André Lureau 8d86e2bfe3 vnc/spice: fix "never" and "now" expire_time 2011-01-24 15:13:54 +01:00
Gerd Hoffmann e866e23959 spice/vnc: client migration.
Handle spice client migration, i.e. inform a spice client connected
about the new host and connection parameters, so it can move over the
connection automatically.

The monitor command has a not-yet used protocol argument simliar to
set_password and expire_password commands.  This allows to add a simliar
feature to vnc in the future.  Daniel Berrange plans to work on this.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-01-24 15:13:54 +01:00
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
Jin Dongming 31ce5e0c49 Add "broadcast" option for mce command
When the following test case is injected with mce command, maybe user could not
get the expected result.
    DATA
               command cpu bank status             mcg_status  addr   misc
        (qemu) mce     1   1    0xbd00000000000000 0x05        0x1234 0x8c

    Expected Result
           panic type: "Fatal Machine check"

That is because each mce command can only inject the given cpu and could not
inject mce interrupt to other cpus. So user will get the following result:
    panic type: "Fatal machine check on current CPU"

"broadcast" option is used for injecting dummy data into other cpus. Injecting
mce with this option the expected result could be gotten.

Usage:
    Broadcast[on]
           command broadcast cpu bank status             mcg_status  addr   misc
    (qemu) mce     -b        1   1    0xbd00000000000000 0x05        0x1234 0x8c

    Broadcast[off]
           command cpu bank status             mcg_status  addr   misc
    (qemu) mce     1   1    0xbd00000000000000 0x05        0x1234 0x8c

Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-01-21 14:05:22 -02: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
Luiz Capitulino f6b4fc8b23 QMP: Drop old client argument checker
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-01 14:27:13 -03:00
Luiz Capitulino 4af9193ae9 QMP: New argument checker (second part)
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-01 14:27:13 -03:00
Luiz Capitulino 2dbc8db0ba QMP: New argument checker (first part)
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-01 14:27:13 -03:00
Luiz Capitulino eb159d13ee Monitor: handle optional '-' arg as a bool
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-01 14:27:13 -03:00
Luiz Capitulino 5af7bbae0c QMP: Fix error reporting in the async API
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-01 14:27:13 -03:00
Jan Kiszka 8ac470c1f9 monitor: Establish cmd flags and convert the async tag
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-01 13:58:38 -03:00
Jan Kiszka 3b6dbf2772 monitor: Fix command completion vs. boolean switches
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-01 13:58:38 -03:00
Jan Kiszka 03a63484a6 monitor: Fix leakage during completion processing
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-07-01 13:58:38 -03:00
Bernhard M. Wiedemann 49b586a922 Extra scan codes for missing keys
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-22 15:15:30 -05:00
Anthony Liguori a4673e2762 Merge remote branch 'kwolf/for-anthony' into staging
Conflicts:
	hw/pc.c
2010-06-14 10:33:36 -05:00
Jan Kiszka ea4e78e590 monitor/QMP: Drop info hpet / query-hpet
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-13 15:33:02 +03:00
Markus Armbruster 666daa6823 blockdev: Collect block device code in new blockdev.c
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-04 15:20:47 +02:00
Luiz Capitulino 637503d122 Monitor: Drop QMP documentation from code
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-06-01 13:48:43 -05:00
Luiz Capitulino 39b59d2606 Monitor: Return before exiting with 'quit'
This is a new version of the (now reverted) following commit:

0e8d2b5575

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-19 12:45:54 -03:00
Luiz Capitulino a875170167 Revert "Monitor: Return before exiting with 'quit'"
This reverts commit 0e8d2b5575.

Next commits will do the same thing in a better way.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-05-19 12:45:53 -03:00
Blue Swirl 5a834bb47c sparc: Fix lazy flag calculation on interrupts, refactor
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-09 20:19:04 +00:00
Naphtali Sprei cb4e5f8ed1 block: read-only: open cdrom as read-only when using monitor's change command
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-03 12:39:53 -05:00
Luiz Capitulino 6ed2c484f2 QMP: Introduce RESUME event
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-05-03 12:39:12 -05:00
Paolo Bonzini e53f27b9d9 stash away SCM_RIGHTS fd until a getfd command arrives
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-26 16:36:31 -03:00
Luiz Capitulino 0e8d2b5575 Monitor: Return before exiting with 'quit'
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-26 16:36:01 -03:00
Luiz Capitulino 04f8c053cc QMP: Check "arguments" member's type
Otherwise the following input crashes QEMU:

{ "execute": "migrate", "arguments": "tcp:0:4446" }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-26 11:17:19 -03:00
Luiz Capitulino 88f7db8462 QMP: Use QERR_QMP_BAD_INPUT_OBJECT_MEMBER
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-26 11:17:09 -03:00
Kevin Wolf d6e9098e10 Replace calls of old bdrv_open
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-23 16:08:46 +02:00
Luiz Capitulino f1dc58e07d Monitor: Convert do_screen_dump() to QObject
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-18 23:55:19 +02:00
Markus Armbruster 942cd1f288 monitor: New argument type 'b'
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-18 23:55:19 +02:00
Markus Armbruster ee9545dad4 monitor: Rename argument type 'b' to 'f'
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-18 23:55:19 +02:00
Markus Armbruster e17ba87c52 error: Use QERR_INVALID_PARAMETER_VALUE instead of QERR_INVALID_PARAMETER
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-04-18 23:46:48 +02:00
Ryan Harper 07a5d95a3b Add qerror message if the 'change' target filename can't be opened
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-18 22:31:21 +02:00
Paolo Bonzini 28c2897373 move balloon handling to balloon.c
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-04-09 18:55:56 +02:00
Markus Armbruster 9f59b566a6 error: Trim includes after "Move qemu_error & friends..."
Missed in commit 2f792016.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-27 14:30:36 +01:00
Shahar Havivi fd04a2aeda Wrong error message in block_passwd command
Signed-off-by: Shahar Havivi <shaharh@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-17 10:41:38 -05:00
Markus Armbruster 361127dfb4 monitor: New argument type 'O'
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-16 17:45:35 +01:00
Markus Armbruster cde0fc7544 error: Let converted handlers print in human monitor
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-16 17:01:08 +01:00
Markus Armbruster 6620d3ce9e monitor: New monitor_cur_is_qmp() 2010-03-16 17:01:08 +01:00
Markus Armbruster ab5b027ee6 error: Rename qemu_error_new() to qerror_report() 2010-03-16 16:58:32 +01:00
Markus Armbruster 6e4f984cb9 error: Simplify error sink setup
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-16 16:55:05 +01:00
Markus Armbruster b4a51f7f5d error: Move qemu_error() & friends from monitor.c to own file
They're about reporting errors, not about the monitor.
2010-03-16 16:55:05 +01:00
Markus Armbruster d6f468337a monitor: Factor monitor_set_error() out of qemu_error_internal()
This separates the monitor part from the QError part.
2010-03-16 16:55:05 +01:00
Markus Armbruster 8631b6084a monitor: Separate "default monitor" and "current monitor" cleanly
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-16 16:55:05 +01:00
Markus Armbruster 03cd4655cb savevm: Fix -loadvm to report errors to stderr, not the monitor
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-16 16:55:05 +01:00
Luiz Capitulino 9eedeb3b88 QMP: Introduce WATCHDOG event
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-09 08:47:27 -06:00
Luiz Capitulino 80cd34787f QMP: Introduce RTC_CHANGE event
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-08 11:30:09 -06:00
Luiz Capitulino 51a3bd71b3 QMP: Drop DEBUG event
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-08 11:30:08 -06:00
Adam Litke 93d67ee69d Fix hanging user monitor when using balloon command
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: 5c366a8a3d

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>
2010-03-08 11:29:17 -06:00
Gleb Natapov c64484a543 fix 'i' format handling in memory dump
It was broken by 09b9418c6d. (!env && !is_physical) != (!is_physical)
when env is true.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-23 13:23:29 -06:00
Adam Litke 5c366a8a3d Fix hanging user monitor when using balloon command
Arghh... Adding missing S-O-B

Hi Anthony.  I wonder if there was a problem when importing my async
command handler patchset.  Since the 'balloon' command completes
immediately, it must call the completion callback before returning.
That call was missing but is added by the patch below.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:32:15 -06:00
Luiz Capitulino 068b332a65 Monitor: Report more than one error in handlers
Handlers can generate only one error in a call, we let the
programmer know if they brake this rule and clients will only
get the first generated error.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:18 -06:00
Luiz Capitulino 10e4f606ec Monitor: Debug stray prints the right way
QObject Monitor handlers should not call any Monitor print
function: they should only build objects, printing is done
by common code.

Current QMP code will ignore such calls, as we can't send
garbage to clients, additionally it will also emit an
undefined error on the assumption that print calls usually
report errors.

However, the right way to deal with this is to rely on a
return code. This has been fixed by other commit already.

Now, this commit drops the error from monitor_vprintf() and
adds a better debugging mechanism for those 'stray' prints:
we count them if debug is enabled and let the developer know
if a QObject handler is trying to print anything.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:18 -06:00
Luiz Capitulino bb89c2e901 Monitor: Audit handler return
This commit verifies the following two rules specified by
Markus Armbruster:

1. If the handler returns failure, it must have passed an error.

   If it didn't, it's broken. Report an internal error to the client,
   and report the bug to the programmer.

2. If the handler returns success, it must not have passed an error.

   If it did, it's broken. Report the error to the client, and report
   the bug to the programmer.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:18 -06:00
Luiz Capitulino b8b08266bd Monitor: Drop the print disabling mechanism
We can ignore calls to monitor_vprintf() in QMP mode and use
monitor_puts() directly in monitor_json_emitter().

This allows us to drop this ugly hack.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:18 -06:00
Luiz Capitulino b4475aa2b3 Monitor: Debugging support
Add configure options (--enable-debug-mon and --disable-debug-mon)
plus the MON_DEBUG() macro.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:18 -06:00
Luiz Capitulino 261394dbff Monitor: Rename cmd_new_ret()
Now that all handlers are converted to cmd_new_ret(), we can rename
it back to cmd_new(). But now it returns a value.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:17 -06:00
Luiz Capitulino 0bbc47bb21 Monitor: Convert do_change() to cmd_new_ret()
Not that trivial as the call chain also has to be modified.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:17 -06:00
Luiz Capitulino 4fdc94b406 Monitor: Convert do_info() to cmd_new_ret()
Note that this function only fails in QMP, in the user Monitor
it prints the help text instead.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:17 -06:00
Luiz Capitulino fe38a32acc Monitor: Convert do_physical_memory_save() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:17 -06:00
Luiz Capitulino 9869622ee8 Monitor: Convert do_memory_save() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:17 -06:00
Luiz Capitulino aeb91c1e13 Monitor: Convert do_closefd() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:17 -06:00
Luiz Capitulino 6ad3ebd28e Monitor: Convert do_getfd() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:17 -06:00
Luiz Capitulino ba85d35191 Monitor: Convert do_block_set_passwd() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:16 -06:00
Luiz Capitulino 584cbdb596 Monitor: Convert do_cpu_set() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:16 -06:00
Luiz Capitulino 9b9d4d9c79 Monitor: Convert do_eject() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:16 -06:00
Luiz Capitulino d5a7b38f5c Monitor: Convert do_cont() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:16 -06:00
Luiz Capitulino ef4b7eeec1 Monitor: Convert simple handlers to cmd_new_ret()
The following handlers always succeed and hence can be converted
to cmd_new_ret() in the same commit.

- do_stop()
- do_quit()
- do_system_reset()
- do_system_powerdown()
- do_migrate_cancel()
- do_qmp_capabilities()
- do_migrate_set_speed()
- do_migrate_set_downtime()

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:16 -06:00
Luiz Capitulino 97536cffbf Monitor: Introduce cmd_new_ret()
In order to implement the new error handling and debugging
mechanism for command handlers, we need to change the cmd_new()
callback to return a value.

This commit introduces cmd_new_ret(), which returns a value and
will be used only temporarily to handle the transition from
cmd_new().

That is, as soon as all command handlers are ported to cmd_new_ret(),
it will be renamed back to cmd_new() and the new error handling
and debugging mechanism will be added on top of it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:18:16 -06:00
Luiz Capitulino 47116d1c90 QMP: Don't leak on connection close
QMP's chardev event callback doesn't call
json_message_parser_destroy() on CHR_EVENT_CLOSED. As the call
to json_message_parser_init() on CHR_EVENT_OPENED allocates memory,
we'are leaking on close.

Fix that by just calling json_message_parser_destroy() on
CHR_EVENT_CLOSED.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 13:46:17 -06:00
Luiz Capitulino 27a749fb73 QError: Don't abort on multiple faults
Ideally, Monitor code should report an error only once and
return the error information up the call chain.

To assure that this happens as expected and that no error is
lost, we have an assert() in qemu_error_internal().

However, we still have not fully converted handlers using
monitor_printf() to report errors. As there can be multiple
monitor_printf() calls on an error, the assertion is easily
triggered when debugging is enabled; and we will get a memory
leak if it's not.

The solution to this problem is to allow multiple faults by only
reporting the first one, and to release the additional error objects.

A better mechanism to report multiple errors to programmers is
underway.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 13:46:17 -06:00
Luiz Capitulino ba14414174 Monitor: remove unneeded checks
It's not needed to check the return of qobject_from_jsonf()
anymore, as an assert() has been added there.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 13:46:17 -06:00
Luiz Capitulino 09069b19f4 QMP: Enforce capability negotiation rules
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-10 12:46:05 -06:00
Luiz Capitulino 4a7e1190df QMP: Introduce the qmp_capabilities command
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-10 12:46:05 -06:00
Luiz Capitulino ca9567e234 QMP: Add QEMU's version to the greeting message
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-10 12:46:05 -06:00
Luiz Capitulino aa1db6edaf QMP: BLOCK_IO_ERROR event handling
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-10 11:57:02 -06:00
Markus Armbruster cc0c4185e5 monitor: Use QERR_INVALID_PARAMETER instead of QERR_INVALID_CPU_INDEX
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-03 12:39:01 -06:00
Markus Armbruster fccfb11e0d monitor: New argument type 'T'
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-03 12:36:26 -06:00
Markus Armbruster 3350a4dd07 monitor: New argument type 'b'
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-03 12:36:26 -06:00
Markus Armbruster 9fec543fa6 monitor: Document argument type 'M'
Was forgotten in commit b6e098d7.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-03 12:36:25 -06:00
Luiz Capitulino 82617d7ce3 Monitor: Fix command execution regression
Function is_async_return() added by commit 940cc30d0d 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-28 19:09:44 +00:00
Adam Litke 625a5befc2 virtio: Add memory statistics reporting to the balloon driver
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-26 17:08:03 -06:00
Adam Litke 940cc30d0d New API for asynchronous monitor commands
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-26 17:08:03 -06:00
Luiz Capitulino 163c8a59f6 PCI: Convert pci_info() to QObject
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-26 15:42:02 -06:00
Kirill A. Shutemov 27e3ddd3e0 monitor.c: fix warnings with _FORTIFY_SOURCE
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-26 14:59:20 -06:00
Markus Armbruster 81a1b45ac7 monitor: convert do_cpu_set() to QObject, QError
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 14:55:11 -06:00
Markus Armbruster 95fada8c2c monitor: convert do_physical_memory_save() to QError
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 14:55:11 -06:00
Markus Armbruster c34ed28b6b monitor: convert do_memory_save() to QError
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 14:55:10 -06:00
Markus Armbruster 09b9418c6d monitor: Don't check for mon_get_cpu() failure
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-26 14:55:10 -06:00
Luiz Capitulino 23fabed136 QMP: Fix asynchronous events delivery
Commit f039a563f2 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-20 08:25:23 -06:00
Naphtali Sprei f5edb014ed Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY 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-20 08:25:22 -06:00
Adam Litke f039a563f2 QMP: Emit asynchronous events on all QMP monitors
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-19 16:31:04 -06:00
Luiz Capitulino 0d2ed46af4 QMP: Introduce VNC_INITIALIZED event
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-19 16:31:04 -06:00
Luiz Capitulino 0d72f3d31b QMP: Introduce VNC_DISCONNECTED event
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-19 16:31:03 -06:00
Luiz Capitulino 586153d952 QMP: Introduce VNC_CONNECTED event
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-19 16:31:03 -06:00
Blue Swirl 23842aabe6 monitor: fix dead assignment spotted by clang
Value stored to 'nb_per_line' is never read.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-12 20:27:43 +00:00