Commit Graph

21403 Commits

Author SHA1 Message Date
Corey Bryant 2e1e79dae7 block: Convert close calls to qemu_close
This patch converts all block layer close calls, that correspond
to qemu_open calls, to qemu_close.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-08-15 10:48:57 +02:00
Corey Bryant 6165f4d85d block: Convert open calls to qemu_open
This patch converts all block layer open calls to qemu_open.

Note that this adds the O_CLOEXEC flag to the changed open paths
when the O_CLOEXEC macro is defined.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-08-15 10:48:57 +02:00
Corey Bryant e174082835 block: Prevent detection of /dev/fdset/ as floppy
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-08-15 10:48:57 +02:00
Corey Bryant ba1c048a8f qapi: Introduce add-fd, remove-fd, query-fdsets
This patch adds support that enables passing of file descriptors
to the QEMU monitor where they will be stored in specified file
descriptor sets.

A file descriptor set can be used by a client like libvirt to
store file descriptors for the same file.  This allows the
client to open a file with different access modes (O_RDWR,
O_WRONLY, O_RDONLY) and add/remove the passed fds to/from an fd
set as needed.  This will allow QEMU to (in a later patch in this
series) "open" and "reopen" the same file by dup()ing the fd in
the fd set that corresponds to the file, where the fd has the
matching access mode flag that QEMU requests.

The new QMP commands are:
  add-fd: Add a file descriptor to an fd set
  remove-fd: Remove a file descriptor from an fd set
  query-fdsets: Return information describing all fd sets

Note: These commands are not compatible with the existing getfd
and closefd QMP commands.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-08-15 10:48:57 +02:00
Corey Bryant 06138651f3 qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg
Set the close-on-exec flag for the file descriptor received
via SCM_RIGHTS.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-08-15 10:48:57 +02:00
Anthony Liguori 03834e22ab Merge remote-tracking branch 'origin/master' into staging
* origin/master:
  linux-user: ARM: Ignore immediate value for svc in thumb mode
  linux-user: Use init_guest_space when -R and -B are specified
  linux-user: Factor out guest space probing into a function
  flatload: fix bss clearing
  linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
  linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
  linux-user: pass sockaddr from host to target
  x86: switch to AREG0 free mode
  x86: avoid AREG0 in segmentation helpers
  x86: avoid AREG0 for misc helpers
  x86: use wrappers for memory access helpers
  x86: avoid AREG0 for SMM helpers
  x86: avoid AREG0 for SVM helpers
  x86: avoid AREG0 for integer helpers
  x86: avoid AREG0 for condition code helpers
  x86: avoid AREG0 for FPU helpers
  linux-user: Move target_to_host_errno_table[] setup out of ioctl loop
  linux-user: Fix SNDCTL_DSP_MAP{IN, OUT}BUF ioctl definitions
  linux-user: Fix incorrect TARGET_BLKBSZGET, TARGET_BLKBSZSET
2012-08-14 15:19:50 -05:00
Blue Swirl 873359d411 Merge branch 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm
* 'linux-user.next' of git://git.linaro.org/people/pmaydell/qemu-arm:
  linux-user: ARM: Ignore immediate value for svc in thumb mode
  linux-user: Use init_guest_space when -R and -B are specified
  linux-user: Factor out guest space probing into a function
  flatload: fix bss clearing
  linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
  linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
  linux-user: pass sockaddr from host to target
  linux-user: Move target_to_host_errno_table[] setup out of ioctl loop
  linux-user: Fix SNDCTL_DSP_MAP{IN, OUT}BUF ioctl definitions
  linux-user: Fix incorrect TARGET_BLKBSZGET, TARGET_BLKBSZSET
2012-08-14 19:50:22 +00:00
Alexander Graf 3a1363acf9 linux-user: ARM: Ignore immediate value for svc in thumb mode
When running in thumb mode, Linux doesn't evaluate the immediate value
of the svc instruction, but instead just always assumes the syscall number
to be in r7.

This fixes executing go_bootstrap while building go for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14 20:26:56 +01:00
Meador Inge 806d102141 linux-user: Use init_guest_space when -R and -B are specified
Roll the code used to initialize the guest memory space when -R
or -B is used into 'init_guest_space' and then call 'init_guest_space'
from the driver.  This way the reserved guest memory space can
be probed for.  Calling 'mmap' just once as is currently done is not
guaranteed to succeed since the host address space validation might fail.

Signed-off-by: Meador Inge <meadori@codesourcery.com>
[PMM: Fixed minor whitespace errors.]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14 20:26:55 +01:00
Meador Inge dce104013d linux-user: Factor out guest space probing into a function
Signed-off-by: Meador Inge <meadori@codesourcery.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14 20:26:55 +01:00
Mike Frysinger cd8e407d24 flatload: fix bss clearing
The current bss clear logic assumes the target mmap address and host
address are the same.  Use g2h to translate from the target address
space to the host so we can call memset on it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14 20:26:55 +01:00
Jing Huang aebf5bc727 linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14 20:26:55 +01:00
Jing Huang 920394db81 linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14 20:26:55 +01:00
Jing Huang ca6190673c linux-user: pass sockaddr from host to target
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14 20:26:55 +01:00
Blue Swirl 92fc4b586f x86: switch to AREG0 free mode
Add an explicit CPUX86State parameter instead of relying on AREG0.

Remove temporary wrappers and switch to AREG0 free mode.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:26 +00:00
Blue Swirl 2999a0b200 x86: avoid AREG0 in segmentation helpers
Add an explicit CPUX86State parameter instead of relying on AREG0.

Rename remains of op_helper.c to seg_helper.c.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:26 +00:00
Blue Swirl 4a7443be52 x86: avoid AREG0 for misc helpers
Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:26 +00:00
Blue Swirl 329e607d8e x86: use wrappers for memory access helpers
Switch to wrapped versions of memory access functions.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:25 +00:00
Blue Swirl 608badfc66 x86: avoid AREG0 for SMM helpers
Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:25 +00:00
Blue Swirl 052e80d5e0 x86: avoid AREG0 for SVM helpers
Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:25 +00:00
Blue Swirl 7923057bae x86: avoid AREG0 for integer helpers
Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:25 +00:00
Blue Swirl f0967a1add x86: avoid AREG0 for condition code helpers
Add an explicit CPUX86State parameter instead of relying on AREG0.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:25 +00:00
Blue Swirl d3eb5eaeb5 x86: avoid AREG0 for FPU helpers
Make FPU helpers take a parameter for CPUState instead
of relying on global env.

Introduce temporary wrappers for FPU load and store ops. Remove
wrappers for non-AREG0 code. Don't call unconverted helpers
directly.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-14 19:01:25 +00:00
Anthony Liguori 28a9a00e95 Merge remote-tracking branch 'kraxel/seabios-5a02306' into staging
* kraxel/seabios-5a02306:
  update seabios to latest master
2012-08-14 13:46:35 -05:00
Stefan Hajnoczi 2f00463fa6 MAINTAINERS: Update email address for Stefan Hajnoczi
Switch to my personal email address.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-08-14 07:34:01 -05:00
Anthony Liguori 633decd711 Merge remote-tracking branch 'qmp/queue/qmp' into staging
* qmp/queue/qmp: (48 commits)
  target-ppc: add implementation of query-cpu-definitions (v2)
  target-i386: add implementation of query-cpu-definitions (v2)
  qapi: add query-cpu-definitions command (v2)
  compiler: add macro for GCC weak symbols
  qapi: add query-machines command
  qapi: mark QOM commands stable
  qmp: introduce device-list-properties command
  qmp: add SUSPEND_DISK event
  qmp: qmp-events.txt: add missing doc for the SUSPEND event
  qmp: qmp-events.txt: put events in alphabetical order
  qmp: emit the WAKEUP event when the guest is put to run
  qmp: don't emit the RESET event on wakeup from S3
  scripts: qapi-commands.py: qmp-commands.h: include qdict.h
  docs: writing-qmp-commands.txt: update error section
  error, qerror: drop QDict member
  qerror: drop qerror_table and qerror_format()
  error, qerror: pass desc string to error calls
  error: drop error_get_qobject()/error_set_qobject()
  qemu-ga: switch to the new error format on the wire
  qmp: switch to the new error format on the wire
  ...
2012-08-13 16:12:35 -05:00
Anthony Liguori ac839ccd8c Merge remote-tracking branch 'quintela/migration-next-20120808' into staging
* quintela/migration-next-20120808:
  Restart optimization on stage3 update version
  Add XBZRLE statistics
  Add migration accounting for normal and duplicate pages
  Change total_time to total-time in MigrationStats
  Add migrate_set_cache_size command
  Add XBZRLE to ram_save_block and ram_save_live
  Add xbzrle_encode_buffer and xbzrle_decode_buffer functions
  Add uleb encoding/decoding functions
  Add cache handling functions
  Add XBZRLE documentation
  Add migrate-set-capabilities
  Add migration capabilities
2012-08-13 16:02:11 -05:00
Anthony Liguori 6a1f9d0c1f Merge remote-tracking branch 'pmaydell/arm-devs.next' into staging
* pmaydell/arm-devs.next:
  arm: Move some ARM devices into libhw
  ssd0323: abort() instead of exit(1) on error.
  hw/sd.c: make sd_wp_addr() return bool
  hw/sd.c: make sd_dataready() return bool
  hw/sd.c: convert binary variables to bool
  hw/sd.c: introduce wrapper for conversion address to wp group
  hw/sd.c: make sd_wp_addr() accept 64 bit address argument
  hw/sd.c: convert wp_groups in SDState to bitfield
  armv7m: Guard against no -kernel argument
  hw/armv7m_nvic: Fix incorrect default for num-irqs property
2012-08-13 15:59:11 -05:00
Anthony Liguori 70b7660a4e target-ppc: add implementation of query-cpu-definitions (v2)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:19 -03:00
Anthony Liguori e3966126d0 target-i386: add implementation of query-cpu-definitions (v2)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:19 -03:00
Anthony Liguori e4e31c6324 qapi: add query-cpu-definitions command (v2)
This command attempts to map to the behavior of -cpu ?.  Unfortunately, the
output of this command differs wildly across targets.

To accommodate this, we use a weak symbol to implement a default version of the
command that fails with a QERR_NOT_SUPPORTED error code.  Targets can then
override and implement this command if it makes sense for them.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:18 -03:00
Anthony Liguori 6ee373a003 compiler: add macro for GCC weak symbols
This lets us provide a default implementation of a symbol which targets can
override.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:18 -03:00
Anthony Liguori 01d3c80d68 qapi: add query-machines command
This provides the same output as -M ? but in a structured way.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:18 -03:00
Anthony Liguori 5192082097 qapi: mark QOM commands stable
We've had a cycle to tweak.  It is time to commit to supporting them.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:18 -03:00
Anthony Liguori 1daa31b9db qmp: introduce device-list-properties command
This can be used in conjunction with qom-list-types to determine the supported
set of devices and their parameters.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:18 -03:00
Luiz Capitulino 25df49f6eb qmp: add SUSPEND_DISK event
Emitted when the guest makes a request to enter S4 state.

There are three possible ways of having this event, as described here:

 http://lists.gnu.org/archive/html/qemu-devel/2012-07/msg02307.html

I've decided to add a new event and make it indepedent of SHUTDOWN.
This means that the SHUTDOWN event will eventually follow the
SUSPEND_DISK event.

I've choosen this way because of two reasons:

 1. Having an indepedent event makes it possible to query for its
    existence by using query-events

 2. In the future, we may allow the user to change what QEMU should
    do as a result of the guest entering S4. So it's a good idea to
    keep both events separated

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:18 -03:00
Luiz Capitulino 67e3cf2664 qmp: qmp-events.txt: add missing doc for the SUSPEND event
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
2012-08-13 16:10:18 -03:00
Luiz Capitulino cb8900fe0d qmp: qmp-events.txt: put events in alphabetical order
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
2012-08-13 16:10:18 -03:00
Luiz Capitulino 17c8660b0b qmp: emit the WAKEUP event when the guest is put to run
Today, the WAKEUP event is emitted when a wakeup _request_ is made.
This could be the system_wakeup command, for example.

A better semantic would be to emit the event when the guest is
already running, as that's what matters in the end. This commit does
that change.

In theory, this could break compatibility. In practice, it shouldn't
happen though, as clients shouldn't rely on timing characteristics of
the events. That is, a client relying that the guest is not running
when the event arrives may break if the event arrives after the guest
is already running.

This commit also adds the missing documentation for the WAKEUP event.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
2012-08-13 16:10:18 -03:00
Luiz Capitulino 1405819637 qmp: don't emit the RESET event on wakeup from S3
QEMU is basically using reset logic when waking up from S3. This
causes the QMP RESET event to be emitted, which is wrong. Also,
the runstate checks done in reset are not necessary for S3 wakeup.

Fix this by untangling wakeup from reset logic and passing
VMRESET_SILENT to qemu_system_reset() to avoid emitting the RESET
event.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
2012-08-13 16:10:18 -03:00
Luiz Capitulino 08b76b9fc3 scripts: qapi-commands.py: qmp-commands.h: include qdict.h
qmp-commands.h declares several functions that have arguments of
type QDict. However, qdict.h is not included. This will cause a
build breakage when a file includes qmp-commands.h but doesn't
include qdict.h.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-08-13 16:10:18 -03:00
Luiz Capitulino adb2072ed0 docs: writing-qmp-commands.txt: update error section
Add information about the new error format and improve the text a bit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 14:17:53 -03:00
Luiz Capitulino 6d3f0dbb30 error, qerror: drop QDict member
Used to store error information, but it's unused now.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 14:17:53 -03:00
Luiz Capitulino 3647f5c161 qerror: drop qerror_table and qerror_format()
They are unused since last commit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 14:17:53 -03:00
Luiz Capitulino df1e608a01 error, qerror: pass desc string to error calls
This commit changes all QERR_ macros to contain a human message (ie.
the desc string found in qerr_table[]) instead of a json dictionary
in string format.

Before this commit, error_set() and qerror_report() would receive
a json dictionary in string format and build a qobject from it. Now,
both function receive a human message instead and the qobject is
not built anymore.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 14:17:53 -03:00
Luiz Capitulino 7795b166d9 error: drop error_get_qobject()/error_set_qobject()
error_get_qobject() is unused since last commit, error_set_qobject()
has never been used. Also drops error_int.h.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 14:17:53 -03:00
Luiz Capitulino 93b91c59db qemu-ga: switch to the new error format on the wire
IMPORTANT: this BREAKS qemu-ga compatibility for the error response.

Instead of returning something like:

{ "error": { "class": "InvalidParameterValue",
             "data": {"name": "mode", "expected": "halt|powerdown|reboot" } } }

qemu-ga now returns:

 { "error": { "class": "GenericError",
              "desc": "Parameter 'mode' expects halt|powerdown|reboot" } }

Notice that this is also a bug fix, as qemu-ga wasn't returning the
human message.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 14:17:53 -03:00
Luiz Capitulino de253f1491 qmp: switch to the new error format on the wire
IMPORTANT: this BREAKS QMP's compatibility for the error response.

This commit changes QMP's wire protocol to make use of the simpler
error format introduced by previous commits.

There are two important (and mostly incompatible) changes:

 1. Almost all error classes have been replaced by GenericError. The
    only classes that are still supported for compatibility with
    libvirt are: CommandNotFound, DeviceNotActive, KVMMissingCap,
    DeviceNotFound and MigrationExpected

 2. The 'data' field of the error dictionary is gone

As an example, an error response like:

  { "error": { "class": "DeviceNotRemovable",
               "data": { "device": "virtio0" },
               "desc": "Device 'virtio0' is not removable" } }

Will now be emitted as:

  { "error": { "class": "GenericError",
               "desc": "Device 'virtio0' is not removable" } }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 14:17:53 -03:00
Luiz Capitulino a8cb2d302e error: drop unused functions
Besides being unused, they operate on the current error format,
which is going to be replaced soon.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 14:17:46 -03:00
Luiz Capitulino ab878ddfee hmp: hmp_change(): use error_get_class()
The error_is_type() function is going to be dropped.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13 13:21:37 -03:00