]> git.proxmox.com Git - qemu.git/log
qemu.git
10 years agoarch_init: Fix format string by using RAM_ADDR_FMT
Stefan Weil [Thu, 27 Jun 2013 19:00:06 +0000 (21:00 +0200)]
arch_init: Fix format string by using RAM_ADDR_FMT

length is a ram_addr_t, so RAM_ADDR_FMT must be used instead of %ld.
This fixes a recently introduced regression for w64 builds.

Using RAM_ADDR_FMT also changes decimal output to sedecimal.
This is good here because length and block->length should both
use the same base in the error message.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Message-id: 1372359606-2759-1-git-send-email-sw@weilnetz.de
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'afaerber/qom-cpu' into staging
Anthony Liguori [Fri, 28 Jun 2013 16:48:09 +0000 (11:48 -0500)]
Merge remote-tracking branch 'afaerber/qom-cpu' into staging

# By Andreas Färber
# Via Andreas Färber
* afaerber/qom-cpu: (24 commits)
  cpu: Turn cpu_unassigned_access() into a CPUState hook
  hwaddr: Make hwaddr type usable beyond softmmu
  cpu: Change qemu_init_vcpu() argument to CPUState
  cpus: Change qemu_dummy_start_vcpu() argument to CPUState
  cpus: Change qemu_kvm_start_vcpu() argument to CPUState
  cpus: Change cpu_handle_guest_debug() argument to CPUState
  gdbstub: Set gdb_set_stop_cpu() argument to CPUState
  kvm: Change kvm_cpu_exec() argument to CPUState
  kvm: Change kvm_handle_internal_error() argument to CPUState
  cpu: Turn cpu_dump_{state,statistics}() into CPUState hooks
  cpus: Change qemu_kvm_init_cpu_signals() argument to CPUState
  kvm: Change kvm_set_signal_mask() argument to CPUState
  cpus: Change qemu_kvm_wait_io_event() argument to CPUState
  cpus: Change cpu_thread_is_idle() argument to CPUState
  cpu: Change cpu_exit() argument to CPUState
  kvm: Change cpu_synchronize_state() argument to CPUState
  kvm: Change kvm_cpu_synchronize_state() argument to CPUState
  gdbstub: Simplify find_cpu()
  cpu: Guard cpu_{save,load}() definitions
  target-openrisc: Register VMStateDescription for OpenRISCCPU
  ...

10 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Fri, 28 Jun 2013 15:37:33 +0000 (10:37 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

# By Stefan Hajnoczi (11) and others
# Via Kevin Wolf
* kwolf/for-anthony:
  cmd646: fix build when DEBUG_IDE is enabled.
  block: change default of .has_zero_init to 0
  vpc: Implement .bdrv_has_zero_init
  vmdk: remove wrong calculation of relative path
  gluster: Return bdrv_has_zero_init = 0
  block/ssh: Set bdrv_has_zero_init according to the file type.
  block: Make BlockJobTypes const
  qemu-iotests: add 055 drive-backup test case
  qemu-iotests: extract wait_until_completed() into iotests.py
  blockdev: add Abort transaction
  blockdev: add DriveBackup transaction
  blockdev: allow BdrvActionOps->commit() to be NULL
  blockdev: rename BlkTransactionStates to singular
  block: add drive-backup QMP command
  blockdev: use bdrv_getlength() in qmp_drive_mirror()
  blockdev: drop redundant proto_drv check
  block: add basic backup support to block driver
  block: add bdrv_add_before_write_notifier()
  notify: add NotiferWithReturn so notifier list can abort
  raw-posix: Fix /dev/cdrom magic on OS X

Message-id: 1372429509-29642-1-git-send-email-kwolf@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agocmd646: fix build when DEBUG_IDE is enabled.
Mark Cave-Ayland [Fri, 28 Jun 2013 13:43:16 +0000 (14:43 +0100)]
cmd646: fix build when DEBUG_IDE is enabled.

Make sure we use the correct TARGET/PRI macros in the debug statements.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock: change default of .has_zero_init to 0
Peter Lieven [Fri, 28 Jun 2013 10:47:42 +0000 (12:47 +0200)]
block: change default of .has_zero_init to 0

.has_zero_init defaults to 1 for all formats and protocols.

this is a dangerous default since this means that all
new added drivers need to manually overwrite it to 0 if
they do not ensure that a device is zero initialized
after bdrv_create().

if a driver needs to explicitly set this value to
1 its easier to verify the correctness in the review process.

during review of the existing drivers it turned out
that ssh and gluster had a wrong default of 1.
both protocols support host_devices as backend
which are not by default zero initialized. this
wrong assumption will lead to possible corruption
if qemu-img convert is used to write to such a backend.

vpc and vmdk also defaulted to 1 altough they support
fixed respectively flat extends. this has to be addresses
in separate patches. both formats as well as the mentioned
ssh and gluster are turned to the default of 0 with this
patch for safety.

a similar problem with the wrong default existed for
iscsi most likely because the driver developer did
oversee the default value of 1.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agocpu: Turn cpu_unassigned_access() into a CPUState hook
Andreas Färber [Mon, 27 May 2013 04:49:53 +0000 (06:49 +0200)]
cpu: Turn cpu_unassigned_access() into a CPUState hook

Use it for all targets, but be careful not to pass invalid CPUState.
cpu_single_env can be NULL, e.g. on Xen.

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agohwaddr: Make hwaddr type usable beyond softmmu
Andreas Färber [Tue, 28 May 2013 12:02:38 +0000 (14:02 +0200)]
hwaddr: Make hwaddr type usable beyond softmmu

While not normally needed for *-user, it can safely be used there since
always based on uint64_t, to avoid ifdeffery.

To avoid accidental uses, move the guards from exec/hwaddr.h to its
inclusion sites.  No need for them in include/hw/.

Prepares for hwaddr use in qom/cpu.h.

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Change qemu_init_vcpu() argument to CPUState
Andreas Färber [Mon, 27 May 2013 01:23:24 +0000 (03:23 +0200)]
cpu: Change qemu_init_vcpu() argument to CPUState

This allows to move the call into CPUState's realizefn.
Therefore move the stub into libqemustub.a.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpus: Change qemu_dummy_start_vcpu() argument to CPUState
Andreas Färber [Mon, 27 May 2013 00:24:35 +0000 (02:24 +0200)]
cpus: Change qemu_dummy_start_vcpu() argument to CPUState

Pass it to qemu_dummy_cpu_thread_fn().
Use CPUState::env_ptr for cpu_single_env.

Prepares for changing qemu_init_vcpu() argument to CPUState.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpus: Change qemu_kvm_start_vcpu() argument to CPUState
Andreas Färber [Mon, 27 May 2013 00:20:39 +0000 (02:20 +0200)]
cpus: Change qemu_kvm_start_vcpu() argument to CPUState

Pass it on to qemu_kvm_cpu_thread_fn().

Prepares for changing qemu_init_vcpu() argument to CPUState.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpus: Change cpu_handle_guest_debug() argument to CPUState
Andreas Färber [Mon, 27 May 2013 00:07:49 +0000 (02:07 +0200)]
cpus: Change cpu_handle_guest_debug() argument to CPUState

CPUArchState is no longer needed.

Prepares for changing qemu_kvm_cpu_thread_fn() opaque to CPUState.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agogdbstub: Set gdb_set_stop_cpu() argument to CPUState
Andreas Färber [Mon, 27 May 2013 00:06:09 +0000 (02:06 +0200)]
gdbstub: Set gdb_set_stop_cpu() argument to CPUState

Use CPUState::env_ptr for now.

Prepares for changing cpu_handle_guest_debug() argument to CPUState.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agokvm: Change kvm_cpu_exec() argument to CPUState
Andreas Färber [Sun, 26 May 2013 21:46:55 +0000 (23:46 +0200)]
kvm: Change kvm_cpu_exec() argument to CPUState

It no longer uses CPUArchState.

Prepares for changing qemu_kvm_cpu_thread_fn() opaque to CPUState.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agokvm: Change kvm_handle_internal_error() argument to CPUState
Andreas Färber [Sun, 26 May 2013 23:55:29 +0000 (01:55 +0200)]
kvm: Change kvm_handle_internal_error() argument to CPUState

It no longer uses CPUArchState.

Prepares for changing kvm_cpu_exec() argument to CPUState.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Turn cpu_dump_{state,statistics}() into CPUState hooks
Andreas Färber [Sun, 26 May 2013 23:33:50 +0000 (01:33 +0200)]
cpu: Turn cpu_dump_{state,statistics}() into CPUState hooks

Make cpustats monitor command available unconditionally.

Prepares for changing kvm_handle_internal_error() and kvm_cpu_exec()
arguments to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpus: Change qemu_kvm_init_cpu_signals() argument to CPUState
Andreas Färber [Sun, 26 May 2013 21:41:00 +0000 (23:41 +0200)]
cpus: Change qemu_kvm_init_cpu_signals() argument to CPUState

CPUArchState is no longer needed.

Prepares for changing qemu_kvm_cpu_thread_fn() opaque to CPUState.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agokvm: Change kvm_set_signal_mask() argument to CPUState
Andreas Färber [Sun, 26 May 2013 21:38:10 +0000 (23:38 +0200)]
kvm: Change kvm_set_signal_mask() argument to CPUState

CPUArchState is no longer needed.

Prepares for changing qemu_kvm_init_cpu_signals() argument to CPUState.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpus: Change qemu_kvm_wait_io_event() argument to CPUState
Andreas Färber [Sun, 26 May 2013 21:24:55 +0000 (23:24 +0200)]
cpus: Change qemu_kvm_wait_io_event() argument to CPUState

It no longer uses CPUArchState.

Prepares for changing qemu_kvm_cpu_thread_fn() opaque to CPUState.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpus: Change cpu_thread_is_idle() argument to CPUState
Andreas Färber [Sun, 26 May 2013 21:21:08 +0000 (23:21 +0200)]
cpus: Change cpu_thread_is_idle() argument to CPUState

It no longer needs CPUArchState.

Prepares for changing all_cpu_threads_idle() CPU loop to CPUState and
needed for changing qemu_kvm_wait_io_event() argument to CPUState.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Change cpu_exit() argument to CPUState
Andreas Färber [Fri, 17 May 2013 16:26:54 +0000 (18:26 +0200)]
cpu: Change cpu_exit() argument to CPUState

It no longer depends on CPUArchState, so move it to qom/cpu.c.

Prepares for changing GDBState::c_cpu to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agokvm: Change cpu_synchronize_state() argument to CPUState
Andreas Färber [Wed, 1 May 2013 12:24:52 +0000 (14:24 +0200)]
kvm: Change cpu_synchronize_state() argument to CPUState

Change Monitor::mon_cpu to CPUState as well.

Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agokvm: Change kvm_cpu_synchronize_state() argument to CPUState
Andreas Färber [Wed, 1 May 2013 11:45:44 +0000 (13:45 +0200)]
kvm: Change kvm_cpu_synchronize_state() argument to CPUState

It no longer relies on CPUArchState since 20d695a.

Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agogdbstub: Simplify find_cpu()
Andreas Färber [Fri, 17 May 2013 15:49:10 +0000 (17:49 +0200)]
gdbstub: Simplify find_cpu()

Use qemu_get_cpu() and CPUState::env_ptr.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Guard cpu_{save,load}() definitions
Andreas Färber [Sat, 2 Feb 2013 14:51:06 +0000 (15:51 +0100)]
cpu: Guard cpu_{save,load}() definitions

A few targets already managed to implement cpu_save() and cpu_load()
without defining CPU_SAVE_VERSION that causes them to be registered.

Guard the prototypes with CPU_SAVE_VERSION to avoid this happening again
until all targets are converted to VMState (or QIDL).

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-openrisc: Register VMStateDescription for OpenRISCCPU
Andreas Färber [Sat, 2 Feb 2013 12:59:05 +0000 (13:59 +0100)]
target-openrisc: Register VMStateDescription for OpenRISCCPU

Since commit e67db06e9f6d7e514ee2a9b9b769ecd42977f6fb (target-or32: Add
target stubs and QOM cpu) a VMStateDescription existed, but
CPU_SAVE_VERSION was not set, so it was never registered.

Drop cpu_{save,load}() and register VMStateDescription via DeviceState.
Use a version_id of 1 and specify minimum versions as well.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-alpha: Register VMStateDescription for AlphaCPU
Andreas Färber [Sun, 20 Jan 2013 23:27:16 +0000 (00:27 +0100)]
target-alpha: Register VMStateDescription for AlphaCPU

Commit b758aca1f6cdb175634812b79f5560c36c902d00 (target-alpha: Enable
the alpha-softmmu target.) introduced cpu_{save,load}() functions but
didn't define CPU_SAVE_VERSION, so they were never registered.

Drop cpu_{save,load}() and register the VMStateDescription via DeviceClass.
This operates on the AlphaCPU object instead of CPUAlphaState.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Introduce VMSTATE_CPU() macro for CPUState
Andreas Färber [Mon, 17 Jun 2013 02:09:11 +0000 (04:09 +0200)]
cpu: Introduce VMSTATE_CPU() macro for CPUState

To be used to embed common CPU state into CPU subclasses.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Introduce device_class_set_vmsd() helper
Andreas Färber [Tue, 18 Jun 2013 00:23:36 +0000 (02:23 +0200)]
cpu: Introduce device_class_set_vmsd() helper

It's the equivalent to cpu_class_set_vmsd(), to assign
DeviceClass::vmsd. It wasn't needed before since only static,
unmigratable VMStateDescriptions were assigned so far.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Fix cpu_class_set_vmsd() documentation
Andreas Färber [Tue, 18 Jun 2013 00:22:13 +0000 (02:22 +0200)]
cpu: Fix cpu_class_set_vmsd() documentation

It's CPUClass::vmsd, not CPUState::vmsd.

Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agovpc: Implement .bdrv_has_zero_init
Kevin Wolf [Fri, 28 Jun 2013 08:21:00 +0000 (10:21 +0200)]
vpc: Implement .bdrv_has_zero_init

Depending on the subformat, has_zero_init on VHD must behave like raw
and query the underlying storage (fixed) or like other sparse formats
that can always return 1 (dynamic, differencing).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovmdk: remove wrong calculation of relative path
Fam Zheng [Wed, 26 Jun 2013 09:24:32 +0000 (17:24 +0800)]
vmdk: remove wrong calculation of relative path

When creating image with backing file, the driver tries to calculate the
relative path from created image file to backing file, but the path
computation is incorrect. e.g.:

    $ qemu-img create -f vmdk -b vmdk-data-disk.vmdk vmdk-data-snapshot1
    Formatting 'vmdk-data-snapshot1', fmt=vmdk size=10737418240
    backing_file='vmdk-data-disk.vmdk' compat6=off zeroed_grain=off

    $ qemu-img info vmdk-data-snapshot1
    image: vmdk-data-snapshot1
    file format: vmdk
    virtual size: 10G (10737418240 bytes)
    disk size: 12K
->  backing file: disk.vmdk

The common part in file names, "vmdk-data-", is incorrectly forgotten by
relative_path(). As the VMDK specification has no restriction on
parentNameHint to be relative path, we simply remove this by using the
backing_file option.

Cc: qemu-stable@nongnu.org
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agogluster: Return bdrv_has_zero_init = 0
Kevin Wolf [Wed, 26 Jun 2013 07:41:57 +0000 (09:41 +0200)]
gluster: Return bdrv_has_zero_init = 0

GlusterFS volumes can be backed by block devices, in which case
bdrv_create() doesn't make sure that the image is zeroed out. It is
currently not possibly to detect whether a given image is backed by a
file or a block device, and incorrectly assuming that it is zeroed
corrupts images during qemu-img convert, so let's err on the side of
caution and always return 0.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock/ssh: Set bdrv_has_zero_init according to the file type.
Richard W.M. Jones [Tue, 25 Jun 2013 17:15:18 +0000 (18:15 +0100)]
block/ssh: Set bdrv_has_zero_init according to the file type.

If the remote is a regular file, set it to true (ie. reads of
uninitialized areas in a newly created file will return zeroes).
If we can't prove that, return false (a safe default).

Tested by adding a debugging print statement [not part of this commit]
and creating a remote file and a remote block device:

  $ ./qemu-img create ssh://localhost/tmp/new 100M
  Formatting 'ssh://localhost/tmp/new', fmt=raw size=104857600
  filename ssh://localhost/tmp/new: has_zero_init = 1
  $ sudo lvcreate -L 1G -n tmp /dev/fedora
    Logical volume "tmp" created
  $ ./qemu-img create ssh://localhost/dev/fedora/tmp 1G
  Formatting 'ssh://localhost/dev/fedora/tmp', fmt=raw size=1073741824
  filename ssh://localhost/dev/fedora/tmp: has_zero_init = 0

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock: Make BlockJobTypes const
Kevin Wolf [Tue, 25 Jun 2013 13:13:43 +0000 (15:13 +0200)]
block: Make BlockJobTypes const

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoqemu-iotests: add 055 drive-backup test case
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:20 +0000 (17:13 +0200)]
qemu-iotests: add 055 drive-backup test case

Testing drive-backup is similar to image streaming and drive mirroring.
This test case is based on 041.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoqemu-iotests: extract wait_until_completed() into iotests.py
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:19 +0000 (17:13 +0200)]
qemu-iotests: extract wait_until_completed() into iotests.py

The 'drive-mirror' tests often issue 'block-job-complete' and wait for
the QMP completion event.  Other types of block jobs also want to wait
for completion but they may not need to issue 'block-job-complete'.

Extract wait_until_completed() from 041 and put it into iotests.py.
Return the QMP event object so the caller can make additional
assertions, if necessary.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblockdev: add Abort transaction
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:18 +0000 (17:13 +0200)]
blockdev: add Abort transaction

The Abort action can be used to test QMP 'transaction' failure.  Add it
as the last action to exercise the .abort() and .cleanup() code paths
for all previous actions.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblockdev: add DriveBackup transaction
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:17 +0000 (17:13 +0200)]
blockdev: add DriveBackup transaction

This patch adds a transactional version of the drive-backup QMP command.
It allows atomic snapshots of multiple drives along with automatic
cleanup if there is a failure to start one of the backup jobs.

Note that QMP events are emitted for block job completion/cancellation
and the block job will be listed by query-block-jobs.

@device: the name of the device whose writes should be mirrored.

@target: the target of the new image. If the file exists, or if it
         is a device, the existing file/device will be used as the new
         destination.  If it does not exist, a new file will be created.

@format: #optional the format of the new destination, default is to
         probe if @mode is 'existing', else the format of the source

@mode: #optional whether and how QEMU should create a new image, default is
       'absolute-paths'.

@speed: #optional the maximum speed, in bytes per second

@on-source-error: #optional the action to take on an error on the source,
                  default 'report'.  'stop' and 'enospc' can only be used
                  if the block device supports io-status (see BlockInfo).

@on-target-error: #optional the action to take on an error on the target,
                  default 'report' (no limitations, since this applies to
                  a different block device than @device).

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblockdev: allow BdrvActionOps->commit() to be NULL
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:16 +0000 (17:13 +0200)]
blockdev: allow BdrvActionOps->commit() to be NULL

Some QMP 'transaction' types don't need to do anything on .commit().
Make .commit() optional just like .abort().

The "drive-backup" action will take advantage of this, it only needs to
cancel the block job on .abort().  Other block job actions will probably
follow the same pattern, so allow .commit() to be NULL.

Suggested-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblockdev: rename BlkTransactionStates to singular
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:15 +0000 (17:13 +0200)]
blockdev: rename BlkTransactionStates to singular

The QMP 'transaction' command keeps a list of in-flight transactions.
The transaction state structure is called BlkTransactionStates even
though it only deals with a single transaction.  The only plural thing
is the linked list of transaction states.

I find it confusing to call the single structure "States".  This patch
renames it to "State", just like BlockDriverState is singular.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock: add drive-backup QMP command
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:14 +0000 (17:13 +0200)]
block: add drive-backup QMP command

@drive-backup

Start a point-in-time copy of a block device to a new destination.  The
status of ongoing drive-backup operations can be checked with
query-block-jobs where the BlockJobInfo.type field has the value 'backup'.
The operation can be stopped before it has completed using the
block-job-cancel command.

@device: the name of the device which should be copied.

@target: the target of the new image. If the file exists, or if it
         is a device, the existing file/device will be used as the new
         destination.  If it does not exist, a new file will be created.

@format: #optional the format of the new destination, default is to
         probe if @mode is 'existing', else the format of the source

@mode: #optional whether and how QEMU should create a new image, default is
       'absolute-paths'.

@speed: #optional the maximum speed, in bytes per second

@on-source-error: #optional the action to take on an error on the source,
                  default 'report'.  'stop' and 'enospc' can only be used
                  if the block device supports io-status (see BlockInfo).

@on-target-error: #optional the action to take on an error on the target,
                  default 'report' (no limitations, since this applies to
                  a different block device than @device).

Note that @on-source-error and @on-target-error only affect background I/O.
If an error occurs during a guest write request, the device's rerror/werror
actions will be used.

Returns: nothing on success
         If @device is not a valid block device, DeviceNotFound

Since 1.6

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblockdev: use bdrv_getlength() in qmp_drive_mirror()
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:13 +0000 (17:13 +0200)]
blockdev: use bdrv_getlength() in qmp_drive_mirror()

Use bdrv_getlength() for its byte units and error return instead of
bdrv_get_geometry().

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblockdev: drop redundant proto_drv check
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:12 +0000 (17:13 +0200)]
blockdev: drop redundant proto_drv check

It is not necessary to check that we can find a protocol block driver
since we create or open the image file.  This produces the error that we
need anyway.

Besides, the QERR_INVALID_BLOCK_FORMAT is inappropriate since the
protocol is incorrect rather than the format.

Also drop an empty line between bdrv_open() and checking its return
value.  This may be due to copy-pasting from earlier code that performed
other operations before handling errors.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock: add basic backup support to block driver
Dietmar Maurer [Mon, 24 Jun 2013 15:13:11 +0000 (17:13 +0200)]
block: add basic backup support to block driver

backup_start() creates a block job that copies a point-in-time snapshot
of a block device to a target block device.

We call backup_do_cow() for each write during backup. That function
reads the original data from the block device before it gets
overwritten.  The data is then written to the target device.

Currently backup cluster size is hardcoded to 65536 bytes.

[I made a number of changes to Dietmar's original patch and folded them
in to make code review easy.  Here is the full list:

 * Drop BackupDumpFunc interface in favor of a target block device
 * Detect zero clusters with buffer_is_zero() and use bdrv_co_write_zeroes()
 * Use 0 delay instead of 1us, like other block jobs
 * Unify creation/start functions into backup_start()
 * Simplify cleanup, free bitmap in backup_run() instead of cb
 * function
 * Use HBitmap to avoid duplicating bitmap code
 * Use bdrv_getlength() instead of accessing ->total_sectors
 * directly
 * Delete the backup.h header file, it is no longer necessary
 * Move ./backup.c to block/backup.c
 * Remove #ifdefed out code
 * Coding style and whitespace cleanups
 * Use bdrv_add_before_write_notifier() instead of blockjob-specific hooks
 * Keep our own in-flight CowRequest list instead of using block.c
   tracked requests.  This means a little code duplication but is much
   simpler than trying to share the tracked requests list and use the
   backup block size.
 * Add on_source_error and on_target_error error handling.
 * Use trace events instead of DPRINTF()

-- stefanha]

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock: add bdrv_add_before_write_notifier()
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:10 +0000 (17:13 +0200)]
block: add bdrv_add_before_write_notifier()

The bdrv_add_before_write_notifier() function installs a callback that
is invoked before a write request is processed.  This will be used to
implement copy-on-write point-in-time snapshots where we need to copy
out old data before overwriting it.

Note that BdrvTrackedRequest is moved to block_int.h since it is passed
to .notify() functions.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agonotify: add NotiferWithReturn so notifier list can abort
Stefan Hajnoczi [Mon, 24 Jun 2013 15:13:09 +0000 (17:13 +0200)]
notify: add NotiferWithReturn so notifier list can abort

notifier_list_notify() has no return value.  This is fine when we just
want to invoke side-effects.

Sometimes it's useful for notifiers to produce a return value.  This
allows notifiers to "veto" an operation and will be used by the block
layer before-write notifier.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoraw-posix: Fix /dev/cdrom magic on OS X
Kevin Wolf [Tue, 11 Jun 2013 08:44:58 +0000 (10:44 +0200)]
raw-posix: Fix /dev/cdrom magic on OS X

The raw-posix driver has code to provide a /dev/cdrom on OS X even
though it doesn't really exist. However, since commit c66a6157 the real
filename is dismissed after finding it, so opening /dev/cdrom fails.
Put the filename back into the options QDict to make this work again.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agolinux-user: Fix compilation failure
Peter Maydell [Thu, 27 Jun 2013 19:53:38 +0000 (20:53 +0100)]
linux-user: Fix compilation failure

Fix compilation failures for linux-user targets following recent
migration related commits bd2fa51fcd and 43487c67.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1372362818-4740-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'quintela/migration.next' into staging
Anthony Liguori [Thu, 27 Jun 2013 13:48:38 +0000 (08:48 -0500)]
Merge remote-tracking branch 'quintela/migration.next' into staging

# By Michael R. Hines (9) and others
# Via Juan Quintela
* quintela/migration.next:
  rdma: introduce capability x-rdma-pin-all
  rdma: new QEMUFileOps hooks
  rdma: introduce qemu_ram_foreach_block()
  rdma: export qemu_fflush()
  rdma: introduce qemu_file_mode_is_not_valid()
  rdma: export throughput w/ MigrationStats QMP
  rdma: export yield_until_fd_readable()
  rdma: introduce qemu_update_position()
  rdma: add documentation
  migration: do not overwrite zero pages
  Revert "migration: do not sent zero pages in bulk stage"
  arch_init/ram_load: add error message for block length mismatch

Message-id: 1372329455-5995-1-git-send-email-quintela@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agordma: introduce capability x-rdma-pin-all
Michael R. Hines [Wed, 26 Jun 2013 01:35:36 +0000 (21:35 -0400)]
rdma: introduce capability x-rdma-pin-all

This capability allows you to disable dynamic chunk registration
for better throughput on high-performance links.

For example, using an 8GB RAM virtual machine with all 8GB of memory in
active use and the VM itself is completely idle using a 40 gbps infiniband link:

1. x-rdma-pin-all disabled total time: approximately 7.5 seconds @ 9.5 Gbps
2. x-rdma-pin-all enabled total time: approximately 4 seconds @ 26 Gbps

These numbers would of course scale up to whatever size virtual machine
you have to migrate using RDMA.

Enabling this feature does *not* have any measurable affect on
migration *downtime*. This is because, without this feature, all of the
memory will have already been registered already in advance during
the bulk round and does not need to be re-registered during the successive
iteration rounds.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agordma: new QEMUFileOps hooks
Michael R. Hines [Wed, 26 Jun 2013 01:35:35 +0000 (21:35 -0400)]
rdma: new QEMUFileOps hooks

These are the prototypes and implementation of new hooks that
RDMA takes advantage of to perform dynamic page registration.

An optional hook is also introduced for a custom function
to be able to override the default save_page function.

Also included are the prototypes and accessor methods used by
arch_init.c which invoke funtions inside savevm.c to call out
to the hooks that may or may not have been overridden
inside of QEMUFileOps.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agordma: introduce qemu_ram_foreach_block()
Michael R. Hines [Wed, 26 Jun 2013 01:35:34 +0000 (21:35 -0400)]
rdma: introduce qemu_ram_foreach_block()

This is used during RDMA initialization in order to
transmit a description of all the RAM blocks to the
peer for later dynamic chunk registration purposes.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agordma: export qemu_fflush()
Michael R. Hines [Wed, 26 Jun 2013 01:35:32 +0000 (21:35 -0400)]
rdma: export qemu_fflush()

RDMA uses this to flush the control channel before sending its
own message to handle page registrations.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agordma: introduce qemu_file_mode_is_not_valid()
Michael R. Hines [Wed, 26 Jun 2013 01:35:31 +0000 (21:35 -0400)]
rdma: introduce qemu_file_mode_is_not_valid()

QEMUFileRDMA also has read and write modes. This function is now
shared to reduce code duplication.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agordma: export throughput w/ MigrationStats QMP
Michael R. Hines [Wed, 26 Jun 2013 01:35:30 +0000 (21:35 -0400)]
rdma: export throughput w/ MigrationStats QMP

This exposes throughput (in megabits/sec) through QMP.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agordma: export yield_until_fd_readable()
Michael R. Hines [Wed, 26 Jun 2013 01:35:29 +0000 (21:35 -0400)]
rdma: export yield_until_fd_readable()

The RDMA event channel can be made non-blocking just like a TCP
socket. Exporting this function allows us to yield so that the
QEMU monitor remains available.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agordma: introduce qemu_update_position()
Michael R. Hines [Wed, 26 Jun 2013 01:35:28 +0000 (21:35 -0400)]
rdma: introduce qemu_update_position()

RDMA writes happen asynchronously, and thus the performance accounting
also needs to be able to occur asynchronously. This allows anybody
to call into savevm.c to update both f->pos as well as into arch_init.c
to update the acct_info structure with up-to-date values when
the RDMA transfer actually completes.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agordma: add documentation
Michael R. Hines [Wed, 26 Jun 2013 01:35:27 +0000 (21:35 -0400)]
rdma: add documentation

docs/rdma.txt contains full documentation,
wiki links, github url and contact information.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Chegu Vinod <chegu_vinod@hp.com>
Tested-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agomigration: do not overwrite zero pages
Peter Lieven [Mon, 10 Jun 2013 10:14:20 +0000 (12:14 +0200)]
migration: do not overwrite zero pages

on incoming migration do not memset pages to zero if they already read as zero.
this will allocate a new zero page and consume memory unnecessarily. even
if we madvise a MADV_DONTNEED later this will only deallocate the memory
asynchronously.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agoRevert "migration: do not sent zero pages in bulk stage"
Peter Lieven [Mon, 10 Jun 2013 10:14:19 +0000 (12:14 +0200)]
Revert "migration: do not sent zero pages in bulk stage"

Not sending zero pages breaks migration if a page is zero
at the source but not at the destination. This can e.g. happen
if different BIOS versions are used at source and destination.
It has also been reported that migration on pseries is completely
broken with this patch.

This effectively reverts commit f1c72795af573b24a7da5eb52375c9aba8a37972.

Conflicts:

arch_init.c

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agoarch_init/ram_load: add error message for block length mismatch
Alon Levy [Sun, 12 May 2013 11:16:28 +0000 (14:16 +0300)]
arch_init/ram_load: add error message for block length mismatch

Makes it easier to debug situations where the source and target have
different ram blocks in a device and migration fails due to that, for
instance a BAR size change on a PCI device.

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
10 years agoMerge remote-tracking branch 'pmaydell/arm-devs.for-upstream' into staging
Anthony Liguori [Tue, 25 Jun 2013 19:14:13 +0000 (14:14 -0500)]
Merge remote-tracking branch 'pmaydell/arm-devs.for-upstream' into staging

# By Peter Crosthwaite (3) and others
# Via Peter Maydell
* pmaydell/arm-devs.for-upstream:
  nand: Don't inherit from Sysbus
  block/nand: Convert Sysbus::init to Device::realize
  block/nand: QOM casting sweep
  i.MX31: Fix PRCS bit test
  arm/boot: Free dtb blob memory after use
  i.MX: Rework functions/types name and use new style initialization
  i.MX: Implement a more complete version of the GPT timer.
  ARM: Allow dumping of device tree

Message-id: 1372184516-32397-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'pmaydell/target-arm.for-upstream' into staging
Anthony Liguori [Tue, 25 Jun 2013 19:14:09 +0000 (14:14 -0500)]
Merge remote-tracking branch 'pmaydell/target-arm.for-upstream' into staging

# By Peter Maydell
# Via Peter Maydell
* pmaydell/target-arm.for-upstream:
  target-arm: Make LPAE feature imply V7MP
  target-arm: Use tuple list to sync cp regs with KVM
  target-arm: Reinitialize all KVM VCPU registers on reset
  target-arm: Initialize cpreg list from KVM when using KVM
  target-arm: Convert TCG to using (index,value) list for cp migration
  target-arm: mark up cpregs for no-migrate or raw access
  target-arm: Add raw_readfn and raw_writefn to ARMCPRegInfo
  target-arm: Allow special cpregs to have flags set

Message-id: 1372181592-32170-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'cohuck/virtio-ccw-upstr' into staging
Anthony Liguori [Tue, 25 Jun 2013 19:14:05 +0000 (14:14 -0500)]
Merge remote-tracking branch 'cohuck/virtio-ccw-upstr' into staging

# By Cornelia Huck (2) and Christian Borntraeger (1)
# Via Cornelia Huck
* cohuck/virtio-ccw-upstr:
  virtio-ccw: Wire up guest and host notifies.
  virtio-ccw: Wire up ioeventfd.
  s390/virtio-ccw: Fix virtio reset

Message-id: 1372177538-9812-1-git-send-email-cornelia.huck@de.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'sstabellini/xen-20130625' into staging
Anthony Liguori [Tue, 25 Jun 2013 19:14:00 +0000 (14:14 -0500)]
Merge remote-tracking branch 'sstabellini/xen-20130625' into staging

# By Paul Durrant (2) and Stefano Stabellini (1)
# Via Stefano Stabellini
* sstabellini/xen-20130625:
  Move hardcoded initialization of xen-platform device.
  Allow use of pc machine type (accel=xen) for Xen HVM domains.
  Revert "xen: start PCI hole at 0xe0000000 (same as pc_init1 and qemu-xen-traditional)"

Message-id: alpine.DEB.2.02.1306251323220.4782@kaball.uk.xensource.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agonand: Don't inherit from Sysbus
Peter Crosthwaite [Tue, 18 Jun 2013 11:12:41 +0000 (21:12 +1000)]
nand: Don't inherit from Sysbus

Nand chips are not sysbus devices - they do not have any sense of MMIO,
nor interrupts. Re-parent to TYPE_DEVICE accordingly.

Cc: afaerber@suse.de
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoblock/nand: Convert Sysbus::init to Device::realize
Peter Crosthwaite [Tue, 18 Jun 2013 11:11:52 +0000 (21:11 +1000)]
block/nand: Convert Sysbus::init to Device::realize

The prescribed transition from Sysbus::init function to a
Device::realize.

Cc: afaerber@suse.de
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoblock/nand: QOM casting sweep
Peter Crosthwaite [Tue, 18 Jun 2013 11:10:44 +0000 (21:10 +1000)]
block/nand: QOM casting sweep

Define and use standard QOM cast macro. Remove usages of DO_UPCAST and
direct -> style casting.

Cc: afaerber@suse.de
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoi.MX31: Fix PRCS bit test
Stefan Weil [Sun, 9 Jun 2013 20:44:22 +0000 (22:44 +0200)]
i.MX31: Fix PRCS bit test

cppcheck detected a condition which was always false.

According to the MCIMX31 Reference Manual, the PRCS bits have to be 01
to select the Frequency Pre-Multiplier (FPM). PRCS uses bits 1 and 2,
so we have to test for 2.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>
Message-id: 1370810662-32320-1-git-send-email-sw@weilnetz.de
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoarm/boot: Free dtb blob memory after use
Peter Maydell [Tue, 25 Jun 2013 17:34:13 +0000 (18:34 +0100)]
arm/boot: Free dtb blob memory after use

The dtb blob returned by load_device_tree() is in memory allocated
with g_malloc(). Free it accordingly once we have copied its
contents into the guest memory. To make this easy, we need also to
clean up the error handling in load_dtb() so that we consistently
handle errors in the same way (by printing a message and then
returning -1, rather than either plowing on or exiting immediately).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Message-id: 1371209256-11408-1-git-send-email-peter.maydell@linaro.org

10 years agoi.MX: Rework functions/types name and use new style initialization
Jean-Christophe DUBOIS [Tue, 25 Jun 2013 17:34:13 +0000 (18:34 +0100)]
i.MX: Rework functions/types name and use new style initialization

* use dynamic cast whenever possible
* Change function names to some more meaningful prefix
* Change type names to a more meaningful one
* use new style device initialization

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Message-id: 1369898943-1993-3-git-send-email-jcd@tribudubois.net
Reviewed-by: Peter Chubb <peter.chubb@nicta.com.au>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoi.MX: Implement a more complete version of the GPT timer.
Jean-Christophe DUBOIS [Tue, 25 Jun 2013 17:34:13 +0000 (18:34 +0100)]
i.MX: Implement a more complete version of the GPT timer.

* implement compare 1 2 and 3 registers
* simplify Debug printf

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Message-id: 1369898943-1993-2-git-send-email-jcd@tribudubois.net
Reviewed-by: Peter Chubb <peter.chubb@nicta.com.au>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoARM: Allow dumping of device tree
John Rigby [Tue, 25 Jun 2013 17:34:13 +0000 (18:34 +0100)]
ARM: Allow dumping of device tree

By calling qemu_devtree_dumpdtb near the end of load_dtb.

Signed-off-by: John Rigby <john.rigby@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Make LPAE feature imply V7MP
Peter Maydell [Tue, 25 Jun 2013 17:16:08 +0000 (18:16 +0100)]
target-arm: Make LPAE feature imply V7MP

The v7 ARM ARM specifies that the Large Physical Address
Extension requires implementation of the Multiprocessing
Extensions, so make our LPAE feature imply V7MP rather
than specifying both in the A15 CPU initfn.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Message-id: 1371127899-10364-1-git-send-email-peter.maydell@linaro.org

10 years agotarget-arm: Use tuple list to sync cp regs with KVM
Peter Maydell [Tue, 25 Jun 2013 17:16:07 +0000 (18:16 +0100)]
target-arm: Use tuple list to sync cp regs with KVM

Use the tuple list of cp registers for syncing KVM state to QEMU,
rather than only syncing a very minimal set by hand.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Reinitialize all KVM VCPU registers on reset
Peter Maydell [Tue, 25 Jun 2013 17:16:07 +0000 (18:16 +0100)]
target-arm: Reinitialize all KVM VCPU registers on reset

Since the ARM KVM API doesn't include a "reset this VCPU"
ioctl, we have to capture the initial values of every
register it knows about so that we can reset the VCPU
by feeding those values back again.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Initialize cpreg list from KVM when using KVM
Peter Maydell [Tue, 25 Jun 2013 17:16:07 +0000 (18:16 +0100)]
target-arm: Initialize cpreg list from KVM when using KVM

When using KVM, use the kernel's initial state to set up the
cpreg list, and sync to and from the kernel when doing
migration.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Convert TCG to using (index,value) list for cp migration
Peter Maydell [Tue, 25 Jun 2013 17:16:07 +0000 (18:16 +0100)]
target-arm: Convert TCG to using (index,value) list for cp migration

Convert the TCG ARM target to using an (index,value) list for migrating
coprocessors. The primary benefit of the (index,value) list is for
passing state between KVM and QEMU, but it works for TCG-to-TCG
migration as well and is a useful self-contained first step.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: mark up cpregs for no-migrate or raw access
Peter Maydell [Tue, 25 Jun 2013 17:16:07 +0000 (18:16 +0100)]
target-arm: mark up cpregs for no-migrate or raw access

Mark up coprocessor register definitions to add raw access
functions or mark the register as non-migratable where necessary.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Add raw_readfn and raw_writefn to ARMCPRegInfo
Peter Maydell [Tue, 25 Jun 2013 17:16:06 +0000 (18:16 +0100)]
target-arm: Add raw_readfn and raw_writefn to ARMCPRegInfo

For reading and writing register values from the kernel for KVM,
we need to provide accessor functions which are guaranteed to succeed
and don't impose access checks, mask out unwritable bits, etc.
Define new fields raw_readfn and raw_writefn for this purpose;
these only need to be provided if there is a readfn or writefn
already and it is not suitable.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotarget-arm: Allow special cpregs to have flags set
Peter Maydell [Tue, 25 Jun 2013 17:16:06 +0000 (18:16 +0100)]
target-arm: Allow special cpregs to have flags set

Relax the "is this a valid ARMCPRegInfo type value?" check to permit
"special" cpregs to have flags other than ARM_CP_SPECIAL set. At
the moment none of the other flags are relevant for special regs,
but the migration related flag we're about to introduce can apply
here too.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agovirtio-ccw: Wire up guest and host notifies.
Cornelia Huck [Tue, 19 Feb 2013 12:48:17 +0000 (13:48 +0100)]
virtio-ccw: Wire up guest and host notifies.

Guest and host notifiers are needed by vhost. We use ioeventfds for
the guest notifiers, but need to fall back on qemu injecting interrupts
for the host notifiers.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
10 years agovirtio-ccw: Wire up ioeventfd.
Cornelia Huck [Fri, 15 Feb 2013 09:18:43 +0000 (10:18 +0100)]
virtio-ccw: Wire up ioeventfd.

On hosts that support ioeventfd, make use of it for host-to-guest
notifications via diagnose 500.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
10 years agos390/virtio-ccw: Fix virtio reset
Christian Borntraeger [Fri, 7 Jun 2013 10:18:46 +0000 (12:18 +0200)]
s390/virtio-ccw: Fix virtio reset

On virtio reset we must reset the indicator to avoid stale interrupts,
e.g. after a reset.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
10 years agoMove hardcoded initialization of xen-platform device.
Paul Durrant [Tue, 25 Jun 2013 11:46:44 +0000 (11:46 +0000)]
Move hardcoded initialization of xen-platform device.

Creation of the xen-platform device is currently hardcoded into machine
type pc's initialization code, guarded by a test for the whether the xen
accelerator is enabled. This patch moves the creation of xen-platform into
the initialization code of the xenfv machine type. This maintains backwards
compatibility for that machine type but allows more flexibility if another
machine type is used with Xen HVM domains.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
10 years agoAllow use of pc machine type (accel=xen) for Xen HVM domains.
Paul Durrant [Tue, 25 Jun 2013 11:46:37 +0000 (11:46 +0000)]
Allow use of pc machine type (accel=xen) for Xen HVM domains.

Xen HVM domains normally spawn QEMU with a dedicated xenfv machine type. The
initialization code for this machine type can easily be pulled into the
generic pc initialization code and guarded with a test for whether the xen
accelerator options is specified, which is more consistent with the way
other accelerators are used.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
10 years agoRevert "xen: start PCI hole at 0xe0000000 (same as pc_init1 and qemu-xen-traditional)"
Stefano Stabellini [Tue, 25 Jun 2013 11:43:04 +0000 (11:43 +0000)]
Revert "xen: start PCI hole at 0xe0000000 (same as pc_init1 and qemu-xen-traditional)"

This reverts commit 9f24a8030a70ea4954b5b8c48f606012f086f65f.

The start of the PCI hole is actually set to 0xf0000000 by hvmloader.
In order to retain ABI compatibility with Xen we leave the start of the
PCI hole at 0xf0000000 in QEMU (for Xen) too.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
10 years agoMerge remote-tracking branch 'stefanha/block' into staging
Anthony Liguori [Mon, 24 Jun 2013 19:33:17 +0000 (14:33 -0500)]
Merge remote-tracking branch 'stefanha/block' into staging

# By Kevin Wolf (22) and Fam Zheng (1)
# Via Stefan Hajnoczi
* stefanha/block: (23 commits)
  vmdk: refuse to open higher version than supported
  block: Always enable discard on the protocol level
  qcow2: Batch discards
  qcow2: Options to enable discard for freed clusters
  qcow2: Add refcount update reason to all callers
  Revert "block: Disable driver-specific options for 1.5"
  ide: Clean up ide_exec_cmd()
  ide: Convert SMART commands to ide_cmd_table handler
  ide: Convert CF-ATA commands to ide_cmd_table handler
  ide: Convert ATAPI commands to ide_cmd_table handler
  ide: Convert SEEK to ide_cmd_table handler
  ide: Convert FLUSH CACHE to ide_cmd_table handler
  ide: Convert SET FEATURES to ide_cmd_table handler
  ide: Convert CHECK POWER MDOE to ide_cmd_table handler
  ide: Convert READ NATIVE MAX ADDRESS to ide_cmd_table handler
  ide: Convert DMA read/write commands to ide_cmd_table handler
  ide: Convert PIO read/write commands to ide_cmd_table handler
  ide: Convert read/write multiple commands to ide_cmd_table handler
  ide: Convert verify commands to ide_cmd_table handler
  ide: Convert cmd_nop commands to ide_cmd_table handler
  ...

Message-id: 1372065035-19601-1-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'spice/spice.v71' into staging
Anthony Liguori [Mon, 24 Jun 2013 19:33:09 +0000 (14:33 -0500)]
Merge remote-tracking branch 'spice/spice.v71' into staging

# By Gerd Hoffmann (1) and Hans de Goede (1)
# Via Gerd Hoffmann
* spice/spice.v71:
  spice: Add -spice disable-agent-file-transfer cmdline option (rhbz#961850)
  qxl: fix Coverity scan SIGN_EXTENSION error

Message-id: 1372060666-18182-1-git-send-email-kraxel@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'kraxel/usb.84' into staging
Anthony Liguori [Mon, 24 Jun 2013 19:33:00 +0000 (14:33 -0500)]
Merge remote-tracking branch 'kraxel/usb.84' into staging

# By Andreas Färber (3) and others
# Via Gerd Hoffmann
* kraxel/usb.84:
  usb: fix serial number for hid devices
  usb: add serial bus property
  usb-host-libusb: set USB_DEV_FLAG_IS_HOST
  usb/host-libusb: Fix building with libusb git master code
  usb/hcd-ehci: Add Faraday FUSBH200 support
  usb/hcd-ehci: Replace PORTSC macros with variables
  usb/hcd-ehci: Add Tegra2 SysBus EHCI device
  usb/hcd-ehci: Split off instance_init from realize
  usb/hcd-ehci-sysbus: Convert to QOM realize

10 years agoMerge remote-tracking branch 'mjt/trivial-patches' into staging
Anthony Liguori [Mon, 24 Jun 2013 19:32:33 +0000 (14:32 -0500)]
Merge remote-tracking branch 'mjt/trivial-patches' into staging

# By Stefan Weil (5) and others
# Via Michael Tokarev
* mjt/trivial-patches:
  configure: Add signed*signed check to [u]int128_t test
  Makefile: pass include directives to dtc via CPPFLAGS, not CFLAGS
  qapi: lack of two commas in dict
  sd: pass bool parameter for sd_init
  qemu-char: use bool in qemu_chr_open_socket and simplify code a bit
  vnc: use booleans for vnc_connect, vnc_listen_read and vnc_display_add_client
  block/nand: Formatting sweep
  qxl: Fix QXLRam initialisation.
  acl: acl_add can't insert before last list element, fix
  configure: Fix "ERROR: ERROR: " for missing/incompatible DTC
  audio: Replace static functions in header file by macros, remove GCC_ATTR
  libcacard: Fix cppcheck warning and remove unneeded code
  savevm: Fix potential memory leak
  kvm: Fix potential resource leak (missing fclose)
  qemu-img: Add missing GCC_FMT_ATTR
  qemu-options: trivial fix for -mon args help
  vl: reformat SDL ifdeffery a bit

Message-id: 1371893076-9643-1-git-send-email-mjt@msgid.tls.msk.ru
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agocadence_uart: Handle backend tx errors
Edgar E. Iglesias [Tue, 18 Jun 2013 07:22:55 +0000 (09:22 +0200)]
cadence_uart: Handle backend tx errors

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agovmdk: refuse to open higher version than supported
Fam Zheng [Thu, 13 Jun 2013 03:21:29 +0000 (11:21 +0800)]
vmdk: refuse to open higher version than supported

Refuse to open higher version for safety.

Although we try to be compatible with published VMDK spec, VMware has
newer version from ESXi 5.1 exported OVF/OVA, which we have no knowledge
what's changed in it. And it is very likely to have more new versions in
the future, so it's not safe to open them blindly.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: Always enable discard on the protocol level
Kevin Wolf [Wed, 19 Jun 2013 11:44:21 +0000 (13:44 +0200)]
block: Always enable discard on the protocol level

Turning on discard options in qcow2 doesn't help a lot when the discard
requests that it issues are thrown away by the raw-posix layer. This
patch always enables discard functionality on the protocol level so that
it's the image format's responsibility to send (or not) discard
requests. Requests sent by the guest will be allowed or ignored by the
top level BlockDriverState, which depends on the discard=... option like
before.

In particular, this means that even without specifying options, the
qcow2 default of discarding deleted snapshots actually takes effect now,
both for qemu and qemu-img.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqcow2: Batch discards
Kevin Wolf [Wed, 19 Jun 2013 11:44:20 +0000 (13:44 +0200)]
qcow2: Batch discards

This optimises the discard operation for freed clusters by batching
discard requests (both snapshot deletion and bdrv_discard end up
updating the refcounts cluster by cluster).

Note that we don't discard asynchronously, but keep s->lock held. This
is to avoid that a freed cluster is reallocated and written to while the
discard is still in flight.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqcow2: Options to enable discard for freed clusters
Kevin Wolf [Wed, 19 Jun 2013 11:44:19 +0000 (13:44 +0200)]
qcow2: Options to enable discard for freed clusters

Deleted snapshots are discarded in the image file by default, discard
requests take their default from the -drive discard=... option and other
places that free clusters must always be enabled explicitly.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqcow2: Add refcount update reason to all callers
Kevin Wolf [Wed, 19 Jun 2013 11:44:18 +0000 (13:44 +0200)]
qcow2: Add refcount update reason to all callers

This adds a refcount update reason to all callers of update_refcounts(),
so that a follow-up patch can use this information to decide whether
clusters that reach a refcount of 0 should be discarded in the image
file.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoRevert "block: Disable driver-specific options for 1.5"
Kevin Wolf [Wed, 19 Jun 2013 11:44:17 +0000 (13:44 +0200)]
Revert "block: Disable driver-specific options for 1.5"

This reverts commit 8ec7d390b0d50b5e5b4b1d8dba7ba40d64a70875.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoide: Clean up ide_exec_cmd()
Kevin Wolf [Tue, 18 Jun 2013 08:26:11 +0000 (10:26 +0200)]
ide: Clean up ide_exec_cmd()

All commands are now converted to ide_cmd_table handlers, so it can be
unconditional now and the old switch block can go.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoide: Convert SMART commands to ide_cmd_table handler
Kevin Wolf [Tue, 18 Jun 2013 08:26:10 +0000 (10:26 +0200)]
ide: Convert SMART commands to ide_cmd_table handler

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>