sdk/emulator/qemu.git
10 years agovirtio-net: implement per-device migration calls
Greg Kurz [Tue, 24 Jun 2014 17:19:03 +0000 (19:19 +0200)]
virtio-net: implement per-device migration calls

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovirtio: introduce device specific migration calls
Greg Kurz [Tue, 24 Jun 2014 17:15:31 +0000 (19:15 +0200)]
virtio: introduce device specific migration calls

In order to migrate virtio subsections, they should be streamed after
the device itself. We need the device specific code to be called from
the common migration code to achieve this. This patch introduces load
and save methods for this purpose.

Suggested-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovirtio-serial: don't migrate the config space
Alexander Graf [Tue, 24 Jun 2014 17:13:50 +0000 (19:13 +0200)]
virtio-serial: don't migrate the config space

The device configuration is set at realize time and never changes. It
should not be migrated as it is done today. For the sake of compatibility,
let's just skip them at load time.

Signed-off-by: Alexander Graf <agraf@suse.de>
[ added missing casts to uint16_t *,
  added From, SoB and commit message,
  Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovirtio-net: byteswap virtio-net header
Cédric Le Goater [Tue, 24 Jun 2014 17:11:32 +0000 (19:11 +0200)]
virtio-net: byteswap virtio-net header

TCP connectivity fails when the guest has a different endianness.
The packets are silently dropped on the host by the tap backend
when they are read from user space because the endianness of the
virtio-net header is in the wrong order. These lines may appear
in the guest console:

[  454.709327] skbuff: bad partial csum: csum=8704/4096 len=74
[  455.702554] skbuff: bad partial csum: csum=8704/4096 len=74

The issue that got first spotted with a ppc64le PowerKVM guest,
but it also exists for the less common case of a x86_64 guest run
by a big-endian ppc64 TCG hypervisor.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
[ Ported from PowerKVM,
  Greg Kurz <gkurz@linux.vnet.ibm.com> ]
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovhost-user: typo fixups
Michael S. Tsirkin [Sun, 29 Jun 2014 14:58:48 +0000 (17:58 +0300)]
vhost-user: typo fixups

Fix typo in field name.
Strip two consequitive empty lines.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovhost-user: fix regions provied with VHOST_USER_SET_MEM_TABLE message
Damjan Marion [Thu, 26 Jun 2014 21:01:32 +0000 (23:01 +0200)]
vhost-user: fix regions provied with VHOST_USER_SET_MEM_TABLE message

Old code was affected by memory gaps which resulted in buffer pointers
pointing to address outside of the mapped regions.

Here we are introducing following changes:
 - new function qemu_get_ram_block_host_ptr() returns host pointer
   to the ram block, it is needed to calculate offset of specific
   region in the host memory
 - new field mmap_offset is added to the VhostUserMemoryRegion. It
   contains offset where specific region starts in the mapped memory.
   As there is stil no wider adoption of vhost-user agreement was made
   that we will not bump version number due to this change
 - other fileds in VhostUserMemoryRegion struct are not changed, as
   they are all needed for usermode app implementation
 - region data is not taken from ram_list.blocks anymore, instead we
   use region data which is alredy calculated for use in vhost-net
 - Now multiple regions can have same FD and user applicaton can call
   mmap() multiple times with the same FD but with different offset
   (user needs to take care for offset page alignment)

Signed-off-by: Damjan Marion <damarion@cisco.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Damjan Marion <damarion@cisco.com>
10 years agonuma: Reject configuration if not all node IDs are present
Eduardo Habkost [Thu, 26 Jun 2014 21:33:20 +0000 (18:33 -0300)]
numa: Reject configuration if not all node IDs are present

We don't support sparse NUMA node IDs yet, so this changes QEMU to
reject configs where not all nodes are present.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agonuma: Reject duplicate node IDs
Eduardo Habkost [Thu, 26 Jun 2014 21:33:19 +0000 (18:33 -0300)]
numa: Reject duplicate node IDs

The same nodeid shouldn't appear multiple times in the command-line.

In addition to detecting command-line mistakes, this will fix a bug
where nb_numa_nodes may become larger than MAX_NODES (and cause
out-of-bounds access on the numa_info array).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agonuma: Keep track of NUMA nodes present on the command-line
Eduardo Habkost [Thu, 26 Jun 2014 21:33:18 +0000 (18:33 -0300)]
numa: Keep track of NUMA nodes present on the command-line

Based on "enable sparse node numbering" patch from Nishanth Aravamudan,
but without the code to actually support sparse node IDs. This just adds
the code to keep track of present/non-present nodes on the command-line,
without changing any behavior.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
[Rename max_numa_node to max_numa_nodeid -Eduardo]
[Initialize max_numa_nodeid to 0 -Eduardo]
[Use MAX() macro when setting max_numa_nodeid -Eduardo]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agoAllow mismatched virtio config-len
Dr. David Alan Gilbert [Fri, 27 Jun 2014 19:02:48 +0000 (20:02 +0100)]
Allow mismatched virtio config-len

Commit 'virtio: validate config_len on load' restricted config_len
loaded from the wire to match the config_len that the device had.

Unfortunately, there are cases where this isn't true, the one
we found it on was the wce addition in virtio-blk.

Allow mismatched config-lengths:
   *) If the version on the wire is shorter then fine
   *) If the version on the wire is longer, load what we have space
      for and skip the rest.

(This is mst@redhat.com's rework of what I originally posted)

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: make isapc and pc-0.10 to pc-0.13 have 1.7.0 memory layout
Don Slutz [Wed, 25 Jun 2014 20:19:07 +0000 (16:19 -0400)]
pc: make isapc and pc-0.10 to pc-0.13 have 1.7.0 memory layout

QEMU 2.0 changed memory layout for isapc and pc-0.10 to pc-0.13.
This prevents migration from QEMU 1.7.0 for these
machine types when -m 3.5G is specified.

Paolo Bonzini asked that:

    smbios_legacy_mode = true;
    has_reserved_memory = false;
    option_rom_has_mr = true;
    rom_file_has_mr = false;

also be done.

Cc: qemu-stable@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Don Slutz <dslutz@verizon.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Fixes: https://bugs.launchpad.net/qemu/+bug/1334307
Tested-by: "Slutz, Donald Christopher" <dslutz@verizon.com>
10 years agovhost-user: fix wrong ids in documentation
Damjan Marion [Wed, 25 Jun 2014 12:49:36 +0000 (14:49 +0200)]
vhost-user: fix wrong ids in documentation

Signed-off-by: Damjan Marion <damarion@cisco.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agomc146818rtc: add rtc-reset-reinjection QMP command
Marcelo Tosatti [Tue, 24 Jun 2014 21:55:11 +0000 (18:55 -0300)]
mc146818rtc: add rtc-reset-reinjection QMP command

It is necessary to reset RTC interrupt reinjection backlog if
guest time is synchronized via a different mechanism, such as
QGA's guest-set-time command.

Failing to do so causes both corrections to be applied (summed),
resulting in an incorrect guest time.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: Fix "prog_if" typo on PC_COMPAT_2_0
Eduardo Habkost [Tue, 24 Jun 2014 22:57:55 +0000 (19:57 -0300)]
pc: Fix "prog_if" typo on PC_COMPAT_2_0

The property name is "prog_if", not "prof_if".

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reported-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: Move q35 compat props to PC_COMPAT_*
Eduardo Habkost [Wed, 25 Jun 2014 02:04:44 +0000 (23:04 -0300)]
pc: Move q35 compat props to PC_COMPAT_*

For each compat property on PC_Q35_COMPAT_*, there are only two
possibilities:

 * If the device is never instantiated when using a machine other than
   pc-q35, then the compat property can be safely added to
   PC_COMPAT_*;
 * If the device can be instantiated when using a machine other than
   pc-q35, that means the other machines also need the compat property
   to be set.

That means we don't need separate PC_Q35_COMPAT_* macros at all, today.

The hpet.hpet-intcap case is interesting: piix and q35 do have something
that emulates different defaults, but the machine-specific default is
applied _after_ compat_props are applied, by simply checking if the
property is zero (which is the real default on the hpet code).

The hpet.hpet-intcap=0x4 compat property can (should?) be applied to
piix too, because 0x4 was the default on both piix and q35 before the
hpet-intcap property was introduced.

Now, if one day we change the default HPET intcap on one of the PC
machine-types again, we may want to introduce PC_{Q35,I440FX}_COMPAT
macros. But while we don't need that, we can keep the code simple.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agonuma: fix comment
Michael S. Tsirkin [Tue, 24 Jun 2014 05:50:30 +0000 (08:50 +0300)]
numa: fix comment

s/if given for/is given for/;

Reported-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoopenrisc: fix comment
Michael S. Tsirkin [Tue, 24 Jun 2014 04:44:30 +0000 (07:44 +0300)]
openrisc: fix comment

Fix English in comment:

s/the each/each/

s/  \*\// \*\//

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
10 years agonuma: fix comment
Michael S. Tsirkin [Tue, 24 Jun 2014 04:43:37 +0000 (07:43 +0300)]
numa: fix comment

Fix up English in comments:
s/the each/each/

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/xtensa/tags/20140629-xtensa' into staging
Peter Maydell [Sun, 29 Jun 2014 15:17:50 +0000 (16:17 +0100)]
Merge remote-tracking branch 'remotes/xtensa/tags/20140629-xtensa' into staging

Xtensa fixes and improvements queue 2014-06-29:
- fix FLASH mapping to boot region for KC705;
- clean up boot parameters passing;
- add uImage, DTB and initrd support.

# gpg: Signature made Sat 28 Jun 2014 23:40:32 BST using RSA key ID F83FA044
# gpg: Good signature from "Max Filippov <max.filippov@cogentembedded.com>"
# gpg:                 aka "Max Filippov <jcmvbkbc@gmail.com>"

* remotes/xtensa/tags/20140629-xtensa:
  hw/xtensa/xtfpga: implement initrd loading
  hw/xtensa/xtfpga: implement DTB loading
  hw/xtensa/xtfpga: implement uImage loading
  hw/xtensa/xtfpga: add memory info to bootparam
  hw/xtensa/xtfpga: refactor bootparameters filling
  hw/xtensa/xtfpga: use symbolic constants for bootparam tags
  hw/xtensa/xtfpga: retrieve parameters from machine_opts
  hw/xtensa: replace fprintfs with error_report
  hw/xtensa: remove extraneous xtensa_ prefix from file names
  hw/xtensa/xtfpga: fix FLASH mapping to boot region for KC705

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Sun, 29 Jun 2014 14:24:54 +0000 (15:24 +0100)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block patches for 2.1.0-rc0

# gpg: Signature made Fri 27 Jun 2014 19:50:32 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream: (47 commits)
  iotests: Fix 083 for out-of-tree builds
  iotests: Drop Python version from 065's Shebang
  iotests: Use $PYTHON for Python scripts
  iotests: Source common.env
  configure: Enable out-of-tree iotests
  iotests: Allow out-of-tree run
  block.c: Don't return success for bdrv_append_temp_snapshot() failure
  qemu-iotests: Add TestRepairQuorum to 041 to test drive-mirror node-name mode.
  block: Add replaces argument to drive-mirror
  blockjob: Fix recent BLOCK_JOB_ERROR regression
  blockjob: Fix recent BLOCK_JOB_READY regression
  virtio-blk: Rename complete_request_early to complete_request_vring
  virtio-blk: Unify {non-,}dataplane's request handlings
  virtio-blk: Schedule BH in the right context
  virtio-blk: Export request handling functions to dataplane
  virtio-blk: Make request completion function virtual
  block: acquire AioContext in qmp_query_blockstats()
  block: make bdrv_query_stats() static
  virtio-blk: Fix and clean up the in_sg and out_sg check
  virtio-blk: Fill in VirtIOBlockReq.out in dataplane code
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
Peter Maydell [Sun, 29 Jun 2014 12:39:04 +0000 (13:39 +0100)]
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging

* remotes/qmp-unstable/queue/qmp:
  docs/qmp: Fix documentation of BLOCK_JOB_READY to match code
  char: report frontend open/closed state in 'query-chardev'
  virtio-serial: report frontend connection state via monitor
  qmp: add qmp-events.txt back
  qapi event: clean up in callers
  qapi script: clean up in scripts
  qapi: ignore generated event files
  qapi: move event defines

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging
Peter Maydell [Sun, 29 Jun 2014 11:45:54 +0000 (12:45 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging

Net patches

# gpg: Signature made Fri 27 Jun 2014 14:10:57 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/net-pull-request:
  hw/net/eepro100: Implement read-only bits in MDI registers
  net: move queue number into NICPeers
  net: L2TPv3 transport
  qemu-bridge-helper: Fix fd leak in main()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/agraf/tags/signed-ppc-for-upstream' into staging
Peter Maydell [Sun, 29 Jun 2014 10:59:00 +0000 (11:59 +0100)]
Merge remote-tracking branch 'remotes/agraf/tags/signed-ppc-for-upstream' into staging

Patch queue for ppc - 2014-06-27

Changes include:

  - instruction emulation fixes
  - linux-user fixes
  - mac99: layout fixes
  - pseries: Initial VFIO support
  - pseries: support for UUID
  - pseries: support for -boot m

# gpg: Signature made Fri 27 Jun 2014 12:51:01 BST using RSA key ID 03FEDC60
# gpg: Can't check signature: public key not found

* remotes/agraf/tags/signed-ppc-for-upstream: (32 commits)
  PPC: e500: Only create dt entries for existing serial ports
  spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB
  vmstate: Add preallocation for migrating arrays (VMS_ALLOC flag)
  xics: Implement xics_ics_free()
  spapr: Remove @next_irq
  spapr: Move interrupt allocator to xics
  xics: Disable flags reset on xics reset
  xics: Add xics_find_source()
  xics: Add flags for interrupts
  spapr: Add RTAS sysparm SPLPAR Characteristics
  spapr: Add RTAS sysparm UUID
  spapr: Fix RTAS sysparm DIAGNOSTICS_RUN_MODE
  spapr: Add rtas_st_buffer utility function
  spapr: Define a 2.1 pseries machine
  spapr: Fix code design style (s/SPAPRMachine/sPAPRMachineState)
  target-ppc: Add support for POWER8 pvr 0x4D0000
  uninorth: Fix PCI hole size
  mac99: Add motherboard devices before PCI cards
  target-ppc: Remove unused gen_qemu_ld8s()
  target-ppc: Remove unused IMM and d extract helpers
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20140627' into staging
Peter Maydell [Sun, 29 Jun 2014 10:43:30 +0000 (11:43 +0100)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20140627' into staging

A series of patches to the s390-ccw bios:
- code cleanup
- improved error reporting
- most important, support to ipl (boot) from ECKD DASD (CDL, LDL or CMS
  formatted)

# gpg: Signature made Fri 27 Jun 2014 12:03:30 BST using RSA key ID C6F02FAF
# gpg: Can't check signature: public key not found

* remotes/cohuck/tags/s390x-20140627:
  pc-bios/s390-ccw: update binary
  pc-bios/s390-ccw: IPL from LDL/CMS-formatted ECKD DASD
  pc-bios/s390-ccw: IPL from CDL-formatted ECKD DASD
  pc-bios/s390-ccw: factor out ipl code
  pc-bios/s390-ccw: Add fill_hex_val func to provide better msgs
  pc-bios/s390-ccw: Unify error handling
  pc-bios/s390-ccw: add some utility code
  pc-bios/s390-ccw: handle different sector sizes
  pc-bios/s390-ccw: cleanup and enhance bootmap defintions
  pc-bios/s390-ccw: make checkpatch happy

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotcg/ppc: Fix support for 64-bit PPC MacOSX hosts
Peter Maydell [Thu, 26 Jun 2014 15:37:17 +0000 (16:37 +0100)]
tcg/ppc: Fix support for 64-bit PPC MacOSX hosts

Add back in the support for 64-bit PPC MacOSX hosts that was
broken in the recent merge of the 32-bit and 64-bit TCG backends.

Reported-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Tested-by: Andreas Färber <andreas.faerber@web.de>
10 years agohw/xtensa/xtfpga: implement initrd loading
Max Filippov [Sat, 21 Jun 2014 09:35:35 +0000 (13:35 +0400)]
hw/xtensa/xtfpga: implement initrd loading

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa/xtfpga: implement DTB loading
Max Filippov [Mon, 23 Jun 2014 14:45:43 +0000 (18:45 +0400)]
hw/xtensa/xtfpga: implement DTB loading

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa/xtfpga: implement uImage loading
Max Filippov [Mon, 4 Mar 2013 03:07:52 +0000 (07:07 +0400)]
hw/xtensa/xtfpga: implement uImage loading

Provide a simple bootloader code at the reset address that jumps to the
loaded image entry point when it's not equal to the reset address. This
is needed because the old method of setting pc doesn't work due to cpu
reset done after the machine setup.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa/xtfpga: add memory info to bootparam
Max Filippov [Mon, 23 Jun 2014 13:24:48 +0000 (17:24 +0400)]
hw/xtensa/xtfpga: add memory info to bootparam

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa/xtfpga: refactor bootparameters filling
Max Filippov [Sat, 21 Jun 2014 09:10:38 +0000 (13:10 +0400)]
hw/xtensa/xtfpga: refactor bootparameters filling

Separate filling first/last tag and size calculation from the kernel
command line setup.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa/xtfpga: use symbolic constants for bootparam tags
Max Filippov [Sat, 21 Jun 2014 06:29:29 +0000 (10:29 +0400)]
hw/xtensa/xtfpga: use symbolic constants for bootparam tags

Import bootparam tag names from linux/arch/xtensa/include/asm/bootparam.h
No functional changes.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa/xtfpga: retrieve parameters from machine_opts
Max Filippov [Mon, 23 Jun 2014 14:42:39 +0000 (18:42 +0400)]
hw/xtensa/xtfpga: retrieve parameters from machine_opts

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa: replace fprintfs with error_report
Max Filippov [Sat, 21 Jun 2014 12:14:56 +0000 (16:14 +0400)]
hw/xtensa: replace fprintfs with error_report

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa: remove extraneous xtensa_ prefix from file names
Max Filippov [Sat, 21 Jun 2014 06:39:58 +0000 (10:39 +0400)]
hw/xtensa: remove extraneous xtensa_ prefix from file names

While at it rename lx60 (named after the first board of the family) to
more generic xtfpga (the family name).

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agohw/xtensa/xtfpga: fix FLASH mapping to boot region for KC705
Max Filippov [Fri, 20 Jun 2014 14:02:10 +0000 (18:02 +0400)]
hw/xtensa/xtfpga: fix FLASH mapping to boot region for KC705

On KC705 bootloader area is located at FLASH offset 0x06000000, not 0 as
on older xtfpga boards.

Cc: qemu-stable@nongnu.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
10 years agoiotests: Fix 083 for out-of-tree builds
Max Reitz [Sat, 24 May 2014 21:25:00 +0000 (23:25 +0200)]
iotests: Fix 083 for out-of-tree builds

iotest 083 filters out debug messages from nbd, which are prefixed (and
recognized) by __FILE__. However, the current filter (/^nbd\.c…/) is
valid for in-tree builds only, as out-of-tree builds will have a path
before that filename (e.g. "/tmp/qemu/nbd.c"). Fix this by adding .*
before "nbd\.c".

While working on this, also fix the regexes: '.' should be escaped and a
single backslash is not enough for escaping when enclosed by double
quotes.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoiotests: Drop Python version from 065's Shebang
Max Reitz [Sat, 24 May 2014 21:24:59 +0000 (23:24 +0200)]
iotests: Drop Python version from 065's Shebang

Test 065 specified python2 to be used in its Shebang; this might not
work on systems without a python2 symlink and furthermore it is now
counter-productive, as the check script compares the Shebang to
"#!/usr/bin/env python" and only uses the Python interpreter selected by
configure on an exact match.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoiotests: Use $PYTHON for Python scripts
Max Reitz [Sat, 24 May 2014 21:24:58 +0000 (23:24 +0200)]
iotests: Use $PYTHON for Python scripts

Instead of invoking Python scripts directly via ./, use $PYTHON to
obtain the correct Python interpreter command.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoiotests: Source common.env
Max Reitz [Sat, 24 May 2014 21:24:57 +0000 (23:24 +0200)]
iotests: Source common.env

Source common.env in the iotests' check script.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoconfigure: Enable out-of-tree iotests
Max Reitz [Sat, 24 May 2014 21:24:56 +0000 (23:24 +0200)]
configure: Enable out-of-tree iotests

In order to allow out-of-tree iotests, create a symlink for the check
script in the build tree.

While doing so, also write configured options relevant to the iotests to
common.env in the build tree; currently, this is the command to invoke
Python 2.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoiotests: Allow out-of-tree run
Max Reitz [Sat, 24 May 2014 21:24:55 +0000 (23:24 +0200)]
iotests: Allow out-of-tree run

As out-of-tree builds are preferred for qemu, running the qemu-iotests
in that out-of-tree build should be supported as well. To do so, a
symbolic link has to be created pointing to the check script in the
source directory. That script will check whether it has been run through
a symlink, and if so, will assume it is run in the build tree. All
output and temporary operations performed by iotests are then redirected
here and, unless specified otherwise by the user, QEMU_PROG etc. will be
set to paths appropriate for the build tree.

Also, drop making every test case executable if it is not yet, as this
would modify the source tree which is not desired for out-of-tree runs
and should be fixed in the repository anyway.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock.c: Don't return success for bdrv_append_temp_snapshot() failure
Chen Gang [Mon, 23 Jun 2014 15:28:23 +0000 (23:28 +0800)]
block.c: Don't return success for bdrv_append_temp_snapshot() failure

When failure occurs, 'ret' need be set, or may return 0 to indicate
success. Previously, an error was set in errp, but 0 was returned
anyway. So let bdrv_append_temp_snapshot() return an error code and
use that for the bdrv_open() return value.

Also, error_propagate() need be called only one time within a function.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoqemu-iotests: Add TestRepairQuorum to 041 to test drive-mirror node-name mode.
Benoît Canet [Fri, 27 Jun 2014 16:25:26 +0000 (18:25 +0200)]
qemu-iotests: Add TestRepairQuorum to 041 to test drive-mirror node-name mode.

The to-replace-node-name is designed to allow repairing a broken Quorum file.
This patch introduces a new class TestRepairQuorum testing that the feature
works.
Some further work will be done on QEMU to improve the robustness of the tests.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock: Add replaces argument to drive-mirror
Benoît Canet [Fri, 27 Jun 2014 16:25:25 +0000 (18:25 +0200)]
block: Add replaces argument to drive-mirror

drive-mirror will bdrv_swap the new BDS named node-name with the one
pointed by replaces when the mirroring is finished.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblockjob: Fix recent BLOCK_JOB_ERROR regression
Markus Armbruster [Fri, 27 Jun 2014 17:24:14 +0000 (19:24 +0200)]
blockjob: Fix recent BLOCK_JOB_ERROR regression

Commit 5a2d2cb screwed up the the value of members device and action,
breaking tests/qemu-iotests/041.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Tested-By: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblockjob: Fix recent BLOCK_JOB_READY regression
Markus Armbruster [Fri, 27 Jun 2014 17:24:13 +0000 (19:24 +0200)]
blockjob: Fix recent BLOCK_JOB_READY regression

Commit bcada37 dropped the (up to now undocumented) members type, len,
offset, speed, breaking tests/qemu-iotests/040 and 041.

Restore and document them.  This fixes 040, and partially fixes 041.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Tested-By: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agodocs/qmp: Fix documentation of BLOCK_JOB_READY to match code
Markus Armbruster [Fri, 27 Jun 2014 17:24:15 +0000 (19:24 +0200)]
docs/qmp: Fix documentation of BLOCK_JOB_READY to match code

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agovirtio-blk: Rename complete_request_early to complete_request_vring
Fam Zheng [Tue, 17 Jun 2014 06:32:10 +0000 (14:32 +0800)]
virtio-blk: Rename complete_request_early to complete_request_vring

The old name is misleading in its new usage, so rename it.

Signed-off-by: Fam Zheng <famz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Unify {non-,}dataplane's request handlings
Fam Zheng [Tue, 17 Jun 2014 06:32:09 +0000 (14:32 +0800)]
virtio-blk: Unify {non-,}dataplane's request handlings

This drops request handling code from dataplane, and uses code from
hw/block/virtio-blk.c.

It starts to use multiwrite as non-dataplane does.

Dataplane sets VirtIOBlock.complete_request to vring version, and calls
into non-dataplane's process handling. In complete_request_early,
qiov.size is added to vring push length, because it's also called in rw
completion now.

Signed-off-by: Fam Zheng <famz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Schedule BH in the right context
Fam Zheng [Tue, 17 Jun 2014 06:32:08 +0000 (14:32 +0800)]
virtio-blk: Schedule BH in the right context

The BH must be called in the AioContext of bs. Currently it is only the
main loop, but with coming changes, it could also be a dataplane
IOThread.

Signed-off-by: Fam Zheng <famz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Export request handling functions to dataplane
Fam Zheng [Tue, 17 Jun 2014 06:32:07 +0000 (14:32 +0800)]
virtio-blk: Export request handling functions to dataplane

So that dataplane can use virtio_blk_handle_request and
virtio_submit_multiwrite.

Signed-off-by: Fam Zheng <famz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Make request completion function virtual
Fam Zheng [Tue, 17 Jun 2014 06:32:06 +0000 (14:32 +0800)]
virtio-blk: Make request completion function virtual

virtio_blk_req_complete will call VirtIOBlock.complete_request() to push
data and notify guest. No functional change.

Later, this will allow dataplane to provide it's own (vring_) version.

Signed-off-by: Fam Zheng <famz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock: acquire AioContext in qmp_query_blockstats()
Stefan Hajnoczi [Tue, 17 Jun 2014 06:32:05 +0000 (14:32 +0800)]
block: acquire AioContext in qmp_query_blockstats()

Make query-blockstats safe for dataplane by acquiring the
BlockDriverState's AioContext.  This ensures that the dataplane IOThread
and the main loop's monitor code do not race.

Note the assumption that acquiring the drive's BDS AioContext also
protects ->file and ->backing_hd.  This assumption is made by other
aio_context_acquire() callers too.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock: make bdrv_query_stats() static
Stefan Hajnoczi [Tue, 17 Jun 2014 06:32:04 +0000 (14:32 +0800)]
block: make bdrv_query_stats() static

This function is only called from block/qapi.c.  There is no need to
keep it public.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Fix and clean up the in_sg and out_sg check
Fam Zheng [Wed, 11 Jun 2014 04:11:50 +0000 (12:11 +0800)]
virtio-blk: Fix and clean up the in_sg and out_sg check

out_sg is checked by iov_to_buf below, so it can be dropped.

Add assert and iov_discard_back around in_sg, as the in_sg is handled in
dataplane code.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Fill in VirtIOBlockReq.out in dataplane code
Fam Zheng [Wed, 11 Jun 2014 04:11:49 +0000 (12:11 +0800)]
virtio-blk: Fill in VirtIOBlockReq.out in dataplane code

VirtIOBlockReq is allocated in process_request, and freed in command
functions.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Convert VirtIOBlockReq.out to structrue
Fam Zheng [Wed, 11 Jun 2014 04:11:48 +0000 (12:11 +0800)]
virtio-blk: Convert VirtIOBlockReq.out to structrue

The virtio code currently assumes that the outhdr is in its own iovec.
This is not guaranteed by the spec, so we should relax this assumption.

Convert the VirtIOBlockReq.out field to structrue so that we can use
iov_to_buf and then discard the header from the beginning of iovec.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Use VirtIOBlockReq.in to drop VirtIOBlockReq.inhdr
Fam Zheng [Wed, 11 Jun 2014 04:11:47 +0000 (12:11 +0800)]
virtio-blk: Use VirtIOBlockReq.in to drop VirtIOBlockReq.inhdr

In current virtio spec, inhdr is a single byte, and is unlikely to
change for both functionality and compatibility considerations.
Non-dataplane uses .in, and we are on the way to converge them. So
let's unify it to get cleaner code.

Remove .inhdr and use .in.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Replace VirtIOBlockRequest with VirtIOBlockReq
Fam Zheng [Wed, 11 Jun 2014 04:11:46 +0000 (12:11 +0800)]
virtio-blk: Replace VirtIOBlockRequest with VirtIOBlockReq

Field "inhdr" is added temporarily for a more mechanical change, and
will be dropped in the next commit.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Drop VirtIOBlockRequest.read
Fam Zheng [Wed, 11 Jun 2014 04:11:45 +0000 (12:11 +0800)]
virtio-blk: Drop VirtIOBlockRequest.read

Since it's set but not used.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Drop bounce buffer from dataplane code
Fam Zheng [Wed, 11 Jun 2014 04:11:44 +0000 (12:11 +0800)]
virtio-blk: Drop bounce buffer from dataplane code

The block layer will handle the unaligned request.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Convert VirtIOBlockReq.elem to pointer
Fam Zheng [Wed, 11 Jun 2014 04:11:43 +0000 (12:11 +0800)]
virtio-blk: Convert VirtIOBlockReq.elem to pointer

This will make converging with dataplane code easier.

Add virtio_blk_free_request to handle the freeing of request internal
fields.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovirtio-blk: Move VirtIOBlockReq to header
Fam Zheng [Wed, 11 Jun 2014 04:11:42 +0000 (12:11 +0800)]
virtio-blk: Move VirtIOBlockReq to header

For later reusing by dataplane code.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agochar: report frontend open/closed state in 'query-chardev'
Laszlo Ersek [Thu, 26 Jun 2014 15:50:03 +0000 (17:50 +0200)]
char: report frontend open/closed state in 'query-chardev'

In addition to the on-line reporting added in the previous patch, allow
libvirt to query frontend state independently of events.

Libvirt's path to identify the guest agent channel it cares about differs
between the event added in the previous patch and the QMP response field
added here. The event identifies the frontend device, by "id". The
'query-chardev' QMP command identifies the backend device (again by "id").
The association is under libvirt's control.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376

Reviewed-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agovirtio-serial: report frontend connection state via monitor
Laszlo Ersek [Thu, 26 Jun 2014 15:50:02 +0000 (17:50 +0200)]
virtio-serial: report frontend connection state via monitor

Libvirt wants to know about the guest-side connection state of some
virtio-serial ports (in particular the one(s) assigned to guest agent(s)).
Report such states with a new monitor event.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqmp: add qmp-events.txt back
Luiz Capitulino [Thu, 26 Jun 2014 13:33:47 +0000 (09:33 -0400)]
qmp: add qmp-events.txt back

The conversion of events to the QAPI, resulted in the removal of the
docs/qmp/qmp-events.txt file. This was done to avoid having duplicated
information between qmp-events.txt and qapi-event.json.

However, qmp-events.txt contains examples and we're still not sure
how to proper install QAPI docs in the host. To avoid harming users,
it's better to re-add qmp-events.txt for now and deal with the
duplication later.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agoqapi event: clean up in callers
Wenchao Xia [Tue, 24 Jun 2014 23:34:00 +0000 (16:34 -0700)]
qapi event: clean up in callers

This patch improves docs and address small issues in event
callers.

Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqapi script: clean up in scripts
Wenchao Xia [Tue, 24 Jun 2014 23:33:59 +0000 (16:33 -0700)]
qapi script: clean up in scripts

This patch improve docs and uses c_type(argentry, is_param=True)
in script.

Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqapi: ignore generated event files
Wenchao Xia [Tue, 24 Jun 2014 23:33:58 +0000 (16:33 -0700)]
qapi: ignore generated event files

Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqapi: move event defines
Wenchao Xia [Tue, 24 Jun 2014 23:33:57 +0000 (16:33 -0700)]
qapi: move event defines

Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agotcg/ppc: Fix failure in tcg_out_mem_long
Richard Henderson [Fri, 27 Jun 2014 04:26:00 +0000 (21:26 -0700)]
tcg/ppc: Fix failure in tcg_out_mem_long

With rt != r0 on loads, we use rt for scratch.  If we need an index
register different from base, we can't use rt, but r0 is usable.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Message-id: 1403843160-30332-1-git-send-email-rth@twiddle.net
Tested-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoblock: Add node-name argument to drive-mirror
Benoît Canet [Mon, 16 Jun 2014 10:00:55 +0000 (12:00 +0200)]
block: Add node-name argument to drive-mirror

This new argument can be used to specify the node-name of the new mirrored BDS.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoquorum: Add the rewrite-corrupted parameter to quorum
Benoît Canet [Wed, 11 Jun 2014 13:24:10 +0000 (15:24 +0200)]
quorum: Add the rewrite-corrupted parameter to quorum

On read operations when this parameter is set and some replicas are corrupted
while quorum can be reached quorum will proceed to rewrite the correct version
of the data to fix the corrupted replicas.

This will shine with SSD where the FTL will remap the same block at another
place on rewrite.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoPPC: e500: Only create dt entries for existing serial ports
Alexander Graf [Wed, 4 Jun 2014 11:48:18 +0000 (13:48 +0200)]
PPC: e500: Only create dt entries for existing serial ports

When the user specifies -nodefaults he can tell us that he doesn't want any
serial ports spawned by default. While we do honor that wish, we still create
device tree entries for those non-existent devices.

Make device tree generation depend on whether the device is actually available.

Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB
Alexey Kardashevskiy [Fri, 30 May 2014 09:34:20 +0000 (19:34 +1000)]
spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB

Currently SPAPR PHB keeps track of all allocated MSI (here and below
MSI stands for both MSI and MSIX) interrupt because
XICS used to be unable to reuse interrupts. This is a problem for
dynamic MSI reconfiguration which happens when guest reloads a driver
or performs PCI hotplug. Another problem is that the existing
implementation can enable MSI on 32 devices maximum
(SPAPR_MSIX_MAX_DEVS=32) and there is no good reason for that.

This makes use of new XICS ability to reuse interrupts.

This reorganizes MSI information storage in sPAPRPHBState. Instead of
static array of 32 descriptors (one per a PCI function), this patch adds
a GHashTable when @config_addr is a key and (first_irq, num) pair is
a value. GHashTable can dynamically grow and shrink so the initial limit
of 32 devices is gone.

This changes migration stream as @msi_table was a static array while new
@msi_devs is a dynamic hash table. This adds temporary array which is
used for migration, it is populated in "spapr_pci"::pre_save() callback
and expanded into the hash table in post_load() callback. Since
the destination side does not know the number of MSI-enabled devices
in advance and cannot pre-allocate the temporary array to receive
migration state, this makes use of new VMSTATE_STRUCT_VARRAY_ALLOC macro
which allocates the array automatically.

This resets the MSI configuration space when interrupts are released by
the ibm,change-msi RTAS call.

This fixed traces to be more informative.

This changes vmstate_spapr_pci_msi name from "...lsi" to "...msi" which
was incorrect by accident. As the internal representation changed,
thus bumps migration version number.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[agraf: drop g_malloc_n usage]
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agovmstate: Add preallocation for migrating arrays (VMS_ALLOC flag)
Alexey Kardashevskiy [Fri, 30 May 2014 09:34:19 +0000 (19:34 +1000)]
vmstate: Add preallocation for migrating arrays (VMS_ALLOC flag)

There are few helpers already to support array migration. However they all
require the destination side to preallocate arrays before migration which
is not always possible due to unknown array size as it might be some
sort of dynamic state. One of the examples is an array of MSIX-enabled
devices in SPAPR PHB - this array may vary from 0 to 65536 entries and
its size depends on guest's ability to enable MSIX or do PCI hotplug.

This adds new VMSTATE_VARRAY_STRUCT_ALLOC macro which is pretty similar to
VMSTATE_STRUCT_VARRAY_POINTER_INT32 but it can alloc memory for migratign
array on the destination side.

This defines VMS_ALLOC flag for a field.

This changes vmstate_base_addr() to do the allocation when receiving
migration.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Juan Quintela <quintela@redhat.com>
[agraf: drop g_malloc_n usage]
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: Implement xics_ics_free()
Alexey Kardashevskiy [Fri, 30 May 2014 09:34:18 +0000 (19:34 +1000)]
xics: Implement xics_ics_free()

This implements interrupt release function so IRQs can be returned back
to the pool for reuse in cases such as PCI hot plug.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Remove @next_irq
Alexey Kardashevskiy [Fri, 30 May 2014 09:34:17 +0000 (19:34 +1000)]
spapr: Remove @next_irq

This removes @next_irq from sPAPREnvironment which was used in old
IRQ allocator as XICS is now responsible for IRQs and keeps track of
allocated IRQs.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Move interrupt allocator to xics
Alexey Kardashevskiy [Fri, 30 May 2014 09:34:15 +0000 (19:34 +1000)]
spapr: Move interrupt allocator to xics

The current allocator returns IRQ numbers from a pool and does not
support IRQs reuse in any form as it did not keep track of what it
previously returned, it only keeps the last returned IRQ. Some use
cases such as PCI hot(un)plug may require IRQ release and reallocation.

This moves an allocator from SPAPR to XICS.

This switches IRQ users to use new API.

This uses LSI/MSI flags to know if interrupt is allocated.

The interrupt release function will be posted as a separate patch.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: Disable flags reset on xics reset
Alexey Kardashevskiy [Fri, 30 May 2014 09:34:14 +0000 (19:34 +1000)]
xics: Disable flags reset on xics reset

Since islsi[] array has been merged into the ICSState struct,
we must not reset flags as they tell if the interrupt is in use.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: Add xics_find_source()
Alexey Kardashevskiy [Fri, 30 May 2014 09:34:13 +0000 (19:34 +1000)]
xics: Add xics_find_source()

PAPR allows having multiple interrupt sources such as PHB.

This adds a source lookup function and makes use of it.

Since at the moment QEMU only supports a single source,
no change in behaviour is expected.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoxics: Add flags for interrupts
Alexey Kardashevskiy [Fri, 30 May 2014 09:34:12 +0000 (19:34 +1000)]
xics: Add flags for interrupts

The existing interrupt allocation scheme in SPAPR assumes that
interrupts are allocated at the start time, continously and the config
will not change. However, there are cases when this is not going to work
such as:

1. migration - we will have to have an ability to choose interrupt
numbers for devices in the command line and this will create gaps in
interrupt space.

2. PCI hotplug - interrupts from unplugged device need to be returned
back to interrupt pool, otherwise we will quickly run out of interrupts.

This replaces a separate lslsi[] array with a byte in the ICSIRQState
struct and defines "LSI" and "MSI" flags. Neither of these flags set
signals that the descriptor is not allocated and not in use.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Add RTAS sysparm SPLPAR Characteristics
Sam bobroff [Wed, 25 Jun 2014 03:54:32 +0000 (13:54 +1000)]
spapr: Add RTAS sysparm SPLPAR Characteristics

Add support for the SPLPAR Characteristics parameter to the emulated
RTAS call ibm,get-system-parameter.

The support provides just enough information to allow "cat
/proc/powerpc/lparcfg" to succeed without generating a kernel error
message.

Without this patch the above command will produce the following kernel
message: arch/powerpc/platforms/pseries/lparcfg.c \
parse_system_parameter_string Error calling get-system-parameter \
(0xfffffffd)

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Add RTAS sysparm UUID
Sam bobroff [Wed, 25 Jun 2014 03:54:31 +0000 (13:54 +1000)]
spapr: Add RTAS sysparm UUID

Add support for the UUID parameter to the emulated RTAS call
ibm,get-system-parameter.

Return the guest's UUID as the value for the RTAS UUID system
parameter, or null (a zero length result) if it is not set.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Fix RTAS sysparm DIAGNOSTICS_RUN_MODE
Sam bobroff [Wed, 25 Jun 2014 03:54:30 +0000 (13:54 +1000)]
spapr: Fix RTAS sysparm DIAGNOSTICS_RUN_MODE

This allows the ibm,get-system-parameter RTAS call to succeed for the
DIAGNOSTICS_RUN_MODE system parameter.

The problem can be seen with "ppc64_cpu --run-mode" from the
powerpc-utils package which fails before this patch with "Machine does
not support diagnostic run mode".

This is corrected by using the rtas_st_buffer() function to write to
the buffer.

The RTAS constants are also moved out into a header file, some new
constants added and the surrounding code slightly simplified.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
[agraf: remove some commentary]
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Add rtas_st_buffer utility function
Sam bobroff [Wed, 25 Jun 2014 03:54:29 +0000 (13:54 +1000)]
spapr: Add rtas_st_buffer utility function

Add a function to write lengh + data into a buffer as required for the
emulation of the RTAS ibm,get-system-parameter call.

If the destination is smaller than the source, the write is truncated
and success is returned. This matches the behaviour of pHyp.

This will be used in following patches.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Define a 2.1 pseries machine
Alexey Kardashevskiy [Wed, 25 Jun 2014 04:08:45 +0000 (14:08 +1000)]
spapr: Define a 2.1 pseries machine

This adds a v2.1 machine to support backward compatibility
for newer macines in the case if they ever be implemented.

This adds a "pseries-2.1" machine as a child of the "pseries"
machine and only changes visible machine name.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Fix code design style (s/SPAPRMachine/sPAPRMachineState)
Alexey Kardashevskiy [Wed, 25 Jun 2014 04:10:24 +0000 (14:10 +1000)]
spapr: Fix code design style (s/SPAPRMachine/sPAPRMachineState)

Every single sPAPR QOM object has small first "s".
Most (not all yet) QOM objects have "State" suffix.

This replaces SPAPRMachine with sPAPRMachineState to conform with QEMU
code style and removes redundant empty line.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Add support for POWER8 pvr 0x4D0000
Alexey Kardashevskiy [Wed, 25 Jun 2014 07:41:50 +0000 (17:41 +1000)]
target-ppc: Add support for POWER8 pvr 0x4D0000

At the moment QEMU knows about one version of POWER8 CPU with
PVR 0x4B.0000. This CPU class is defined as "POWER8". The linux
kernel names it as "POWER8E" which is different from the name QEMU uses.

Now we get another version of POWER8 which is architecturally equivalent
to POWER8E but has different PVR 0x4D.0000 so QEMU fails to find
a PPC CPU class on these machines. The linux kernel names these CPUs as
"POWER8".

This renames the existing "POWER8" to "POWER8E" to be more precise and
stay in sync with the linux kernel.

This adds a new "POWER8" family which calls POWER8E class init function
and defines own PVR mask (used to match a CPU class) and desc (used to
create dynamic version-less CPU class).

This does not change CPU class fw_name attribute as the host POWER8
firmware keeps using "PowerPC,POWER8" on both POWER8 and POWER8E.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agouninorth: Fix PCI hole size
BALATON Zoltan [Mon, 23 Jun 2014 19:10:59 +0000 (21:10 +0200)]
uninorth: Fix PCI hole size

Fix PCI hole size to match that what is found on real hardware.
(OpenBIOS already uses the correct length.)

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agomac99: Add motherboard devices before PCI cards
BALATON Zoltan [Mon, 23 Jun 2014 22:03:48 +0000 (00:03 +0200)]
mac99: Add motherboard devices before PCI cards

Change the order of creating devices for New World Mac emulation so
that devices on the motherboard are added first and PCI cards (VGA and
NIC) come later. As a side effect, this also causes OpenBIOS to map
the motherboard devices into the MMIO space to the same addresses as
on real hardware and allow clients that hardcode these addresses (e.g.
MorphOS) to find and use them until OpenBIOS is tought to map devices
to specific addresses. (On real hardware the graphics and network
cards are really on separate buses but we don't model that yet.) This
brings the memory map closer to what is found on PowerMac3,1.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Remove unused gen_qemu_ld8s()
Peter Maydell [Mon, 23 Jun 2014 23:05:10 +0000 (00:05 +0100)]
target-ppc: Remove unused gen_qemu_ld8s()

The gen_qemu_ld8s() function is unused; remove it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: Remove unused IMM and d extract helpers
Peter Maydell [Mon, 23 Jun 2014 23:05:09 +0000 (00:05 +0100)]
target-ppc: Remove unused IMM and d extract helpers

Remove the definition of the IMM and d extract helpers; these seem to have
been added as part of the initial PPC support in 2003 but never actually
used.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agovfio: Enable for SPAPR
Alexey Kardashevskiy [Tue, 10 Jun 2014 05:39:24 +0000 (15:39 +1000)]
vfio: Enable for SPAPR

This turns the sPAPR support on and enables VFIO container use
in the kernel.

This extends vfio_connect_container to support VFIO_SPAPR_TCE_IOMMU type
in the host kernel.

This registers a memory listener which sPAPR IOMMU will notify when
executing H_PUT_TCE/etc DMA calls. The listener then will notify the host
kernel about DMA map/unmap operation via VFIO_IOMMU_MAP_DMA/
VFIO_IOMMU_UNMAP_DMA ioctls.

This executes VFIO_IOMMU_ENABLE ioctl to make sure that the IOMMU is free
of mappings and can be exclusively given to the user. At the moment SPAPR
is the only platform requiring this call to be implemented.

Note that the host kernel function implementing VFIO_IOMMU_DISABLE
is called automatically when container's fd is closed so there is
no need to call it explicitly from QEMU. We may need to call
VFIO_IOMMU_DISABLE explicitly in the future for some sort of dynamic
reconfiguration (PCI hotplug or dynamic IOMMU group management).

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr_pci_vfio: Add spapr-pci-vfio-host-bridge to support vfio
Alexey Kardashevskiy [Tue, 10 Jun 2014 05:39:23 +0000 (15:39 +1000)]
spapr_pci_vfio: Add spapr-pci-vfio-host-bridge to support vfio

The patch adds a spapr-pci-vfio-host-bridge device type
which is a PCI Host Bridge with VFIO support. The new device
inherits from the spapr-pci-host-bridge device and adds an "iommu"
property which is an IOMMU id. This ID represents a minimal entity
for which IOMMU isolation can be guaranteed. In SPAPR architecture IOMMU
group is called a Partitionable Endpoint (PE).

Current implementation supports one IOMMU id per QEMU VFIO PHB. Since
SPAPR allows multiple PHB for no extra cost, this does not seem to
be a problem. This limitation may change in the future though.

Example of use:
Configure and Add 3 functions of a multifunctional device to QEMU:
(the NEC PCI USB card is used as an example here):
-device spapr-pci-vfio-host-bridge,id=USB,iommu=4,index=7 \
-device vfio-pci,host=4:0:1.0,addr=1.0,bus=USB,multifunction=true
-device vfio-pci,host=4:0:1.1,addr=1.1,bus=USB
-device vfio-pci,host=4:0:1.2,addr=1.2,bus=USB

where:
* index=7 is a QEMU PHB index (used as source for MMIO/MSI/IO windows
offset);
* iommu=4 is an IOMMU id which can be found in sysfs:
[aik@vpl2 ~]$ cd /sys/bus/pci/devices/0004:00:00.0/
[aik@vpl2 0004:00:00.0]$ ls -l iommu_group
lrwxrwxrwx 1 root root 0 Jun  5 12:49 iommu_group -> ../../../kernel/iommu_groups/4

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agovfio: Add vfio_container_ioctl()
Alexey Kardashevskiy [Tue, 10 Jun 2014 05:39:22 +0000 (15:39 +1000)]
vfio: Add vfio_container_ioctl()

While most operations with VFIO IOMMU driver are generic and used inside
vfio.c, there are still some operations which only specific VFIO IOMMU
drivers implement. The first example of it will be reading a DMA window
start from the host.

This adds a helper which passes an ioctl request to the container's fd.

The helper will check if @req is known. For this, stub is added. This return
-1 on any requests for now.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr_iommu: Make in-kernel TCE table optional
Alexey Kardashevskiy [Tue, 10 Jun 2014 05:39:21 +0000 (15:39 +1000)]
spapr_iommu: Make in-kernel TCE table optional

POWER KVM supports an KVM_CAP_SPAPR_TCE capability which allows allocating
TCE tables in the host kernel memory and handle H_PUT_TCE requests
targeted to specific LIOBN (logical bus number) right in the host without
switching to QEMU. At the moment this is used for emulated devices only
and the handler only puts TCE to the table. If the in-kernel H_PUT_TCE
handler finds a LIOBN and corresponding table, it will put a TCE to
the table and complete hypercall execution. The user space will not be
notified.

Upcoming VFIO support is going to use the same sPAPRTCETable device class
so KVM_CAP_SPAPR_TCE is going to be used as well. That means that TCE
tables for VFIO are going to be allocated in the host as well.
However VFIO operates with real IOMMU tables and simple copying of
a TCE to the real hardware TCE table will not work as guest physical
to host physical address translation is requited.

So until the host kernel gets VFIO support for H_PUT_TCE, we better not
to register VFIO's TCE in the host.

This adds a place holder for KVM_CAP_SPAPR_TCE_VFIO capability. It is not
in upstream yet and being discussed so now it is always false which means
that in-kernel VFIO acceleration is not supported.

This adds a bool @vfio_accel flag to the sPAPRTCETable device telling
that sPAPRTCETable should not try allocating TCE table in the host kernel
for VFIO. The flag is false now as at the moment there is no VFIO.

This adds an vfio_accel parameter to spapr_tce_new_table(), the semantic
is the same. Since there is only emulated PCI and VIO now, the flag is set
to false. Upcoming VFIO support will set it to true.

This is a preparation patch so no change in behaviour is expected

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agospapr: Fix RTAS token numbers
Alexey Kardashevskiy [Mon, 23 Jun 2014 13:26:32 +0000 (23:26 +1000)]
spapr: Fix RTAS token numbers

At the moment spapr_rtas_register() allocates a new token number for every
new RTAS callback so numbers are not fixed and depend on the number of
supported RTAS handlers and the exact order of spapr_rtas_register() calls.
These tokens are copied into the device tree and remain the same during
the guest lifetime.

When we start another guest to receive a migration, it calls
spapr_rtas_register() as well. If the number of RTAS handlers or their
order is different in QEMU on source and destination sides, the "/rtas"
node in the device tree will differ. Since migration overwrites the device
tree (as it overwrites the entire RAM), the actual RTAS config on
the destination side gets broken.

This defines global contant values for every RTAS token which QEMU
is using today.

This changes spapr_rtas_register() to accept a token number instead of
allocating one. This changes all users of spapr_rtas_register().

This changes XICS-KVM not to cache tokens registered with KVM as they
constant now.

This makes TOKEN_BASE global as RTAS_XXX use TOKEN_BASE as
a base. TOKEN_MAX is moved and renamed too and its value is changed
to the last token + 1. Boundary checks for token values are adjusted.

This reserves token numbers for "os-term" handlers and PCI hotplug
which we are working on.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agoPPC: Add support for Apple gdb in gdbstub
Alexander Graf [Mon, 23 Jun 2014 13:23:08 +0000 (15:23 +0200)]
PPC: Add support for Apple gdb in gdbstub

The Apple gdbstub protocol is different from the normal gdbstub protocol
used on PowerPC. Add support for the different variant, so that we can use
Apple's gdb to debug guest code.

Keep in mind that the switch is a compile time option. We can't detect
during runtime whether a gdb connecting to us is an upstream gdb or an
Apple gdb.

Signed-off-by: Alexander Graf <agraf@suse.de>
10 years agotarget-ppc: fixed translation of mcrxr instruction
Sorav Bansal [Tue, 17 Jun 2014 05:54:02 +0000 (11:24 +0530)]
target-ppc: fixed translation of mcrxr instruction

Fixed bug in gen_mcrxr() in target-ppc/translate.c:
The XER[SO], XER[OV], and XER[CA] flags are stored in the least
significant bit (bit 0) of their respective registers. They need
to be shifted left (by their respective offsets) to generate the final
XER value. The old translation code for the 'mcrxr' instruction
was assuming that  the flags are stored in bit 2, and was shifting them
right (incorrectly)

Signed-off-by: Sorav Bansal <sbansal@cse.iitd.ernet.in>
Reviewed-by: Tom Musta <tommusta@gmail.com>
Tested-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>