]> git.proxmox.com Git - qemu.git/log
qemu.git
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 agousb: fix serial number for hid devices
Gerd Hoffmann [Wed, 12 Jun 2013 11:08:45 +0000 (13:08 +0200)]
usb: fix serial number for hid devices

commit 7b074a22dab4bdda9864b933f1bc811a3db42845 changed the serial
number of hid devices.  Add compat properties to keep the old serial
number for qemu 0.12 and older.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb: add serial bus property
Gerd Hoffmann [Wed, 12 Jun 2013 11:01:49 +0000 (13:01 +0200)]
usb: add serial bus property

This patch adds a serial property for all usb devices, which can be
used to set the serial number of a usb device (as listed by lsusb -v)
to a specific value.  Applies to emulated devices only.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb-host-libusb: set USB_DEV_FLAG_IS_HOST
Gerd Hoffmann [Wed, 12 Jun 2013 11:17:02 +0000 (13:17 +0200)]
usb-host-libusb: set USB_DEV_FLAG_IS_HOST

... like host-{linux,bsd}.c do.

Cc: qemu-stable@nongnu.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb/host-libusb: Fix building with libusb git master code
Hans de Goede [Thu, 6 Jun 2013 14:39:34 +0000 (16:39 +0200)]
usb/host-libusb: Fix building with libusb git master code

The next libusb release will deprecate libusb_get_port_path, and since
we compile with -Werror, this breaks the build.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb/hcd-ehci: Add Faraday FUSBH200 support
Kuo-Jung Su [Thu, 6 Jun 2013 13:41:13 +0000 (15:41 +0200)]
usb/hcd-ehci: Add Faraday FUSBH200 support

Add Faraday FUSBH200 support, which is slightly different from EHCI spec.
(Or maybe simply a bad/wrong implementation...)

Signed-off-by: Kuo-Jung Su <dantesu@faraday-tech.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb/hcd-ehci: Replace PORTSC macros with variables
Kuo-Jung Su [Thu, 6 Jun 2013 13:41:12 +0000 (15:41 +0200)]
usb/hcd-ehci: Replace PORTSC macros with variables

Replace PORTSC macros with variables which could then be
configured in ehci_xxxx_class_init(...)

Signed-off-by: Kuo-Jung Su <dantesu@faraday-tech.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb/hcd-ehci: Add Tegra2 SysBus EHCI device
Andreas Färber [Thu, 6 Jun 2013 13:41:11 +0000 (15:41 +0200)]
usb/hcd-ehci: Add Tegra2 SysBus EHCI device

This prepares an EHCI device for the Nvidia Tegra2 SoC family.
Values based on patch by Vincent Palatin and verified against TRM v01p.

Cc: Vincent Palatin <vpalatin@chromium.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb/hcd-ehci: Split off instance_init from realize
Andreas Färber [Thu, 6 Jun 2013 13:41:10 +0000 (15:41 +0200)]
usb/hcd-ehci: Split off instance_init from realize

This makes the mem MemoryRegion available to derived instance_inits.

Keep the bus in realize for now since naming breaks in instance_init.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agousb/hcd-ehci-sysbus: Convert to QOM realize
Andreas Färber [Thu, 6 Jun 2013 13:41:09 +0000 (15:41 +0200)]
usb/hcd-ehci-sysbus: Convert to QOM realize

The SysBus qdev initfn merely calls SysBusDeviceClass::init, so we can
replace it with a realizefn already. This avoids getting into any initfn
ambiguity with the upcoming Faraday EHCI implementation.

Rename internal usb_ehci_initfn() to usb_ehci_realize() to allow to
return Errors from common initialization code as well.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agospice: Add -spice disable-agent-file-transfer cmdline option (rhbz#961850)
Hans de Goede [Sat, 8 Jun 2013 13:37:27 +0000 (15:37 +0200)]
spice: Add -spice disable-agent-file-transfer cmdline option (rhbz#961850)

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoqxl: fix Coverity scan SIGN_EXTENSION error
Gerd Hoffmann [Mon, 3 Jun 2013 08:36:54 +0000 (10:36 +0200)]
qxl: fix Coverity scan SIGN_EXTENSION error

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agoconfigure: Add signed*signed check to [u]int128_t test
Peter Maydell [Fri, 21 Jun 2013 13:01:31 +0000 (14:01 +0100)]
configure: Add signed*signed check to [u]int128_t test

clang 3.3 with -fsanitize=undefined will fail to link code containing an
int128_t * int128_t multiply (http://llvm.org/bugs/show_bug.cgi?id=16404)
so add this to our configure test for whether [u]int128_t are usable.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoMakefile: pass include directives to dtc via CPPFLAGS, not CFLAGS
Peter Maydell [Fri, 21 Jun 2013 13:00:17 +0000 (14:00 +0100)]
Makefile: pass include directives to dtc via CPPFLAGS, not CFLAGS

The dtc submodule's makefile expects -I include directives to be
in CPPFLAGS, not CFLAGS. Getting this wrong meant that the include
directive would not be applied when generating the dependency .d
files. This in turn meant that we couldn't build libfdt when
doing an out of tree build with clang. (gcc's dependency output
is slightly different from clang in this situation so it happened
to work.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoqapi: lack of two commas in dict
Amos Kong [Wed, 19 Jun 2013 09:23:27 +0000 (17:23 +0800)]
qapi: lack of two commas in dict

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agosd: pass bool parameter for sd_init
liguang [Tue, 18 Jun 2013 03:45:36 +0000 (11:45 +0800)]
sd: pass bool parameter for sd_init

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoqemu-char: use bool in qemu_chr_open_socket and simplify code a bit
liguang [Tue, 18 Jun 2013 03:45:35 +0000 (11:45 +0800)]
qemu-char: use bool in qemu_chr_open_socket and simplify code a bit

Local variables is_* should be bool by usage.
While at it, simplify the logic/code a bit.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agovnc: use booleans for vnc_connect, vnc_listen_read and vnc_display_add_client
Michael Tokarev [Tue, 11 Jun 2013 11:42:44 +0000 (15:42 +0400)]
vnc: use booleans for vnc_connect, vnc_listen_read and vnc_display_add_client

Some arguments to these functions are booleans - either by declaration,
or by actual usage, but sometimes value of 0 or 1 is passed for a bool,
and sometimes it is declared as int but a bool value, or true/false,
is passed to it instead.  Clean it up a bit.

Cc: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoblock/nand: Formatting sweep
Peter Crosthwaite [Tue, 18 Jun 2013 11:08:57 +0000 (21:08 +1000)]
block/nand: Formatting sweep

Make this code closer to passing checkpatch. Mostly missing braces, but
a few rogue tabs in there as well.

Cc: qemu-trivial@nongnu.org
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoqxl: Fix QXLRam initialisation.
Anthony PERARD [Mon, 17 Jun 2013 16:38:26 +0000 (17:38 +0100)]
qxl: Fix QXLRam initialisation.

The qxl driver expect NULL for QXLRam.memory_configs, but this is never
initialized.

If memory is set to 0xc2c2.., it leads to a spice-critical error when
trying to start qxl.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoacl: acl_add can't insert before last list element, fix
Markus Armbruster [Tue, 18 Jun 2013 08:05:23 +0000 (10:05 +0200)]
acl: acl_add can't insert before last list element, fix

Watch this:

    $ upstream-qemu -nodefaults -S -vnc :0,acl,sasl -monitor stdio
    QEMU 1.5.50 monitor - type 'help' for more information
    (qemu) acl_add vnc.username drei allow
    acl: added rule at position 1
    (qemu) acl_show vnc.username
    policy: deny
    1: allow drei
    (qemu) acl_add vnc.username zwei allow 1
    acl: added rule at position 2
    (qemu) acl_show vnc.username
    policy: deny
    1: allow drei
    2: allow zwei
    (qemu) acl_add vnc.username eins allow 1
    acl: added rule at position 1
    (qemu) acl_show vnc.username
    policy: deny
    1: allow eins
    2: allow drei
    3: allow zwei

The second acl_add inserts at position 2 instead of 1.

Root cause is an off-by-one in qemu_acl_insert(): when index ==
acl->nentries, it appends instead of inserting before the last list
element.

Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoconfigure: Fix "ERROR: ERROR: " for missing/incompatible DTC
Andreas Färber [Mon, 17 Jun 2013 23:09:06 +0000 (01:09 +0200)]
configure: Fix "ERROR: ERROR: " for missing/incompatible DTC

error_exit already prepends "ERROR: ", so no need to print it manually.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoaudio: Replace static functions in header file by macros, remove GCC_ATTR
Stefan Weil [Sun, 16 Jun 2013 09:19:31 +0000 (11:19 +0200)]
audio: Replace static functions in header file by macros, remove GCC_ATTR

Using macros instead of static functions for dolog and for ldebug
simplifies the code and can also reduce the total code size.

GCC_ATTR was only used in audio_int.h, so it is now unused and
the definition can be removed from compiler.h.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agolibcacard: Fix cppcheck warning and remove unneeded code
Stefan Weil [Sun, 16 Jun 2013 09:08:52 +0000 (11:08 +0200)]
libcacard: Fix cppcheck warning and remove unneeded code

The local function vcard_emul_alloc_arrays always returned PR_TRUE.
Therefore cppcheck complained about code which handled the
non-existent PR_FALSE case.

Remove the function's return value and the dead code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agosavevm: Fix potential memory leak
Stefan Weil [Sun, 16 Jun 2013 11:33:05 +0000 (13:33 +0200)]
savevm: Fix potential memory leak

The leak was reported by cppcheck. Fix it by moving the g_malloc0 after
the argument validity check.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agokvm: Fix potential resource leak (missing fclose)
Stefan Weil [Sun, 16 Jun 2013 11:37:25 +0000 (13:37 +0200)]
kvm: Fix potential resource leak (missing fclose)

This leak was detected by cppcheck.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoqemu-img: Add missing GCC_FMT_ATTR
Stefan Weil [Sun, 16 Jun 2013 15:01:05 +0000 (17:01 +0200)]
qemu-img: Add missing GCC_FMT_ATTR

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoqemu-options: trivial fix for -mon args help
Michael Tokarev [Sat, 15 Jun 2013 09:47:32 +0000 (13:47 +0400)]
qemu-options: trivial fix for -mon args help

It is the (implied sub)option name which is optional, not
the value of that (sub)option, make it so in the help output.
(Introduced by commit 22a0e04b9bb)

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agovl: reformat SDL ifdeffery a bit
Michael Tokarev [Sat, 15 Jun 2013 10:44:20 +0000 (14:44 +0400)]
vl: reformat SDL ifdeffery a bit

This reformats #ifdef..#endif and case statement a bit,
to make it a bit shorter and matching other cases like that
(no code changes).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
10 years agoMerge remote-tracking branch 'bonzini/iommu-for-anthony' into staging
Anthony Liguori [Thu, 20 Jun 2013 21:53:39 +0000 (16:53 -0500)]
Merge remote-tracking branch 'bonzini/iommu-for-anthony' into staging

# By Paolo Bonzini (12) and others
# Via Paolo Bonzini
* bonzini/iommu-for-anthony: (25 commits)
  memory: render_memory_region: factor out fr constant setters
  memory: as_update_topology_pass: Improve comments
  memory: Fix comment typo
  memory: give name to every AddressSpace
  dma: eliminate DMAContext
  spapr_vio: take care of creating our own AddressSpace/DMAContext
  pci: use memory core for iommu support
  dma: eliminate old-style IOMMU support
  spapr: use memory core for iommu support
  spapr: make IOMMU translation go through IOMMUTLBEntry
  spapr: convert TCE API to use an opaque type
  vfio: abort if an emulated iommu is used
  memory: Add iommu map/unmap notifiers
  memory: iommu support
  memory: make section size a 128-bit integer
  exec: reorganize mem_add to match Int128 version
  Revert "s390x: reduce TARGET_PHYS_ADDR_SPACE_BITS to 62"
  Revert "memory: limit sections in the radix tree to the actual address space size"
  exec: return MemoryRegion from address_space_translate
  exec: Implement subpage_read/write via address_space_rw
  ...

Message-id: 1371739493-10187-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'kiszka/queues/slirp' into staging
Anthony Liguori [Thu, 20 Jun 2013 21:53:08 +0000 (16:53 -0500)]
Merge remote-tracking branch 'kiszka/queues/slirp' into staging

# By Bas van Sisseren (1) and Gertjan Halkes (1)
# Via Jan Kiszka
* kiszka/queues/slirp:
  make user networking hostfwd work with restrict=y
  fix -net user checks by reordering checks

Message-id: cover.1371638848.git.jan.kiszka@siemens.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agomemory: render_memory_region: factor out fr constant setters
Peter Crosthwaite [Mon, 3 Jun 2013 05:33:29 +0000 (15:33 +1000)]
memory: render_memory_region: factor out fr constant setters

These 4 replicated lines set properties of fr that are constant over
the course of the function. Factor out their repeated setting (and also
guards against them being set multiple times in the loop below).

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: as_update_topology_pass: Improve comments
Peter Crosthwaite [Mon, 3 Jun 2013 05:32:42 +0000 (15:32 +1000)]
memory: as_update_topology_pass: Improve comments

These comments were a little difficult to read. First one had
incorrect parenthesis. The part about attributes changing is
really applicable to the region being 'in both' rather than 'in
new'

Second comment has an obscure parenthetic about 'Logging may have
changed'. Made clearer, as this if is supposed to handle the case where
the memory region is unchanged (with the notable exception re logging).

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: Fix comment typo
Peter Crosthwaite [Mon, 3 Jun 2013 05:31:56 +0000 (15:31 +1000)]
memory: Fix comment typo

s/ajacent/adjacent

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: give name to every AddressSpace
Alexey Kardashevskiy [Mon, 29 Apr 2013 16:25:51 +0000 (16:25 +0000)]
memory: give name to every AddressSpace

The "info mtree" command in QEMU console prints only "memory" and "I/O"
address spaces while there are actually a lot more other AddressSpace
structs created by PCI and VIO devices. Those devices do not normally
have names and therefore not present in "info mtree" output.

The patch fixes this.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agodma: eliminate DMAContext
Paolo Bonzini [Wed, 10 Apr 2013 16:15:49 +0000 (18:15 +0200)]
dma: eliminate DMAContext

The DMAContext is a simple pointer to an AddressSpace that is now always
already available.  Make everyone hold the address space directly,
and clean up the DMA API to use the AddressSpace directly.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agospapr_vio: take care of creating our own AddressSpace/DMAContext
Paolo Bonzini [Thu, 11 Apr 2013 10:38:50 +0000 (12:38 +0200)]
spapr_vio: take care of creating our own AddressSpace/DMAContext

Fetch the root region from the sPAPRTCETable, and use it to build
an AddressSpace and DMAContext.

Now, everywhere we have a DMAContext we also have access to the
corresponding AddressSpace (either because we create it just before
the DMAContext, or because dma_context_memory's AddressSpace is
trivially address_space_memory).

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agopci: use memory core for iommu support
Avi Kivity [Tue, 30 Oct 2012 11:47:48 +0000 (13:47 +0200)]
pci: use memory core for iommu support

Use the new iommu support in the memory core for iommu support.  The only
user, spapr, is also converted, but it still provides a DMAContext
interface until the non-PCI bits switch to AddressSpace.

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Avi Kivity <avi.kivity@gmail.com>
[ Do not calls memory_region_del_subregion() on the device's
  bus_master_enable_region, it is an alias; return an AddressSpace
  from the IOMMU hook and remove the destructor hook. - David Gibson ]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agodma: eliminate old-style IOMMU support
Paolo Bonzini [Wed, 10 Apr 2013 15:49:04 +0000 (17:49 +0200)]
dma: eliminate old-style IOMMU support

The translate function in the DMAContext is now always NULL.
Remove every reference to it.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agospapr: use memory core for iommu support
Paolo Bonzini [Thu, 11 Apr 2013 10:35:33 +0000 (12:35 +0200)]
spapr: use memory core for iommu support

Now we can stop using a "translating" DMAContext, but we do not yet modify
the sPAPRTCETable users to get an AddressSpace; they keep using the table
via a DMAContext.

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agospapr: make IOMMU translation go through IOMMUTLBEntry
Paolo Bonzini [Tue, 16 Apr 2013 13:05:06 +0000 (15:05 +0200)]
spapr: make IOMMU translation go through IOMMUTLBEntry

The next step is to introduce the translation code that will be used for
IOMMU MemoryRegions, but still do the actual translation in a DMAContext.

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agospapr: convert TCE API to use an opaque type
Paolo Bonzini [Wed, 10 Apr 2013 15:30:48 +0000 (17:30 +0200)]
spapr: convert TCE API to use an opaque type

The TCE table is currently returned as a DMAContext, and non-type-safe
APIs are called later passing back the DMAContext.  Since we want to move
away from DMAContext, use an opaque type instead, and add an accessor
to retrieve the DMAContext from it.

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovfio: abort if an emulated iommu is used
Avi Kivity [Tue, 30 Oct 2012 11:47:49 +0000 (13:47 +0200)]
vfio: abort if an emulated iommu is used

vfio doesn't support guest iommus yet, indicate it to the user
by gently depositing a core on their disk.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi.kivity@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: Add iommu map/unmap notifiers
David Gibson [Tue, 14 May 2013 09:13:56 +0000 (19:13 +1000)]
memory: Add iommu map/unmap notifiers

This patch adds a NotifierList to MemoryRegions which represent IOMMUs
allowing other parts of the code to register interest in mappings or
unmappings from the IOMMU.  All IOMMU implementations will need to call
memory_region_notify_iommu() to inform those waiting on the notifier list,
whenever an IOMMU mapping is made or removed.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: iommu support
Avi Kivity [Tue, 30 Oct 2012 11:47:46 +0000 (13:47 +0200)]
memory: iommu support

Add a new memory region type that translates addresses it is given,
then forwards them to a target address space.  This is similar to
an alias, except that the mapping is more flexible than a linear
translation and trucation, and also less efficient since the
translation happens at runtime.

The implementation uses an AddressSpace mapping the target region to
avoid hierarchical dispatch all the way to the resolved region; only
iommu regions are looked up dynamically.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi.kivity@gmail.com>
[Modified to put translation in address_space_translate; assume
 IOMMUs are not reachable from TCG. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: make section size a 128-bit integer
Paolo Bonzini [Mon, 27 May 2013 08:08:27 +0000 (10:08 +0200)]
memory: make section size a 128-bit integer

So far, the size of all regions passed to listeners could fit in 64 bits,
because artificial regions (containers and aliases) are eliminated by
the memory core, leaving only device regions which have reasonable sizes

An IOMMU however cannot be eliminated by the memory core, and may have
an artificial size, hence we may need 65 bits to represent its size.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: reorganize mem_add to match Int128 version
Paolo Bonzini [Mon, 27 May 2013 08:47:10 +0000 (10:47 +0200)]
exec: reorganize mem_add to match Int128 version

When adding support for 2^64-byte sections, we will have to change
the structure of mem_add to avoid failures in int128_get64.
Reorganize the code now before introducing Int128.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoRevert "s390x: reduce TARGET_PHYS_ADDR_SPACE_BITS to 62"
Paolo Bonzini [Mon, 27 May 2013 11:18:06 +0000 (13:18 +0200)]
Revert "s390x: reduce TARGET_PHYS_ADDR_SPACE_BITS to 62"

This reverts commit 311f83ca08c011b048c063c2fd3038a8957970bc.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoRevert "memory: limit sections in the radix tree to the actual address space size"
Paolo Bonzini [Mon, 27 May 2013 11:18:01 +0000 (13:18 +0200)]
Revert "memory: limit sections in the radix tree to the actual address space size"

This reverts commit 86a8623692b1b559a419a92eb8b6897c221bca74.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: return MemoryRegion from address_space_translate
Paolo Bonzini [Wed, 29 May 2013 10:42:00 +0000 (12:42 +0200)]
exec: return MemoryRegion from address_space_translate

Only address_space_translate_for_iotlb needs to return the section.
Every caller of address_space_translate now uses only section->mr,
return it directly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: Implement subpage_read/write via address_space_rw
Jan Kiszka [Sun, 26 May 2013 19:55:37 +0000 (21:55 +0200)]
exec: Implement subpage_read/write via address_space_rw

This will allow to add support for unaligned memory regions: the subpage
container region can activate unaligned support unconditionally because
the read/write handler will now ensure that accesses are split as
required by calling address_space_rw. We can furthermore drop the
special handling of RAM subpages, address_space_rw takes care of this
already.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: Resolve subpages in one step except for IOTLB fills
Jan Kiszka [Sun, 26 May 2013 19:46:51 +0000 (21:46 +0200)]
exec: Resolve subpages in one step except for IOTLB fills

Except for the case of setting the IOTLB entry in TCG mode, we can avoid
the subpage dispatching handlers and do the resolution directly on
address_space_lookup_region. An IOTLB entry describes a full page, not
only the region that the first access to a sub-divided page may return.

This patch therefore introduces a special translation function,
address_space_translate_for_iotlb, that avoids the subpage resolutions.
In contrast, callers of the existing address_space_translate service
will now always receive the terminal memory region section. This will be
important for breaking the BQL and for enabling unaligned memory region.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: Allow unaligned address_space_rw
Jan Kiszka [Sun, 26 May 2013 19:42:40 +0000 (21:42 +0200)]
exec: Allow unaligned address_space_rw

This will be needed for some corner cases with para-virtual I/O ports.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: move private types to exec.c
Paolo Bonzini [Tue, 21 May 2013 10:07:21 +0000 (12:07 +0200)]
memory: move private types to exec.c

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: Introduce address_space_lookup_region
Jan Kiszka [Mon, 6 May 2013 14:48:02 +0000 (16:48 +0200)]
memory: Introduce address_space_lookup_region

This introduces a wrapper for phys_page_find (before we complicate
address_space_translate with IOMMU translation).  This function will
also encapsulate locking and reference counting when we introduce
BQL-free dispatching.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec.c: address_space_translate: handle access to addr 0 of 2^64 sized region
Peter Maydell [Thu, 20 Jun 2013 14:18:04 +0000 (15:18 +0100)]
exec.c: address_space_translate: handle access to addr 0 of 2^64 sized region

The memory API allows a MemoryRegion's size to be 2^64, as a special
case (otherwise the size always fits in a 64 bit integer). This meant
that attempts to access address zero in a 2^64 sized region would
assert in address_space_translate():

  #3  0x00007ffff3e4d192 in __GI___assert_fail#(assertion=0x555555a43f32
    "!a.hi", file=0x555555a43ef0 "include/qemu/int128.h", line=18,
    function=0x555555a4439f "int128_get64") at assert.c:103
  #4  0x0000555555877642 in int128_get64 (a=...)
    at include/qemu/int128.h:18
  #5  0x00005555558782f2 in address_space_translate (as=0x55555668d140,
   /addr=0, xlat=0x7fffafac9918, plen=0x7fffafac9920, is_write=false)
    at exec.c:221

Fix this by doing the 'min' operation in 128 bit arithmetic
rather than 64 bit arithmetic (we know the result of the 'min'
definitely fits in 64 bits because one of the inputs did).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agodoc: Drop ref to Bochs from -no-fd-bootchk documentation
Markus Armbruster [Fri, 14 Jun 2013 11:15:06 +0000 (13:15 +0200)]
doc: Drop ref to Bochs from -no-fd-bootchk documentation

Manual page and qemu-doc on talk about "Bochs BIOS".  We use SeaBIOS,
and it implements the feature.  Replace by just "BIOS", and drop the
TODO line wondering about the Bochs reference.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1371208516-7857-7-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agopc: Make -no-fd-bootchk stick across boot order changes
Markus Armbruster [Fri, 14 Jun 2013 11:15:05 +0000 (13:15 +0200)]
pc: Make -no-fd-bootchk stick across boot order changes

Option -no-fd-bootchk asks the BIOS to attempt booting from a floppy
even when the boot sector signature isn't there, by setting a bit in
RTC CMOS.  It was added back in 2006 (commit 52ca8d6a).

Two years later, commit 0ecdffbb added monitor command boot_set.
Implemented by new function pc_boot_set().  It unconditionally clears
the floppy signature bit in CMOS.

Commit e0f084bf added -boot option once to automatically change the
boot order on first reset.  Reuses pc_boot_set(), thus also clears the
floppy signature bit.  Commit d9346e81 took care to preserve this
behavior.

Thus, -no-fd-bootchk applies to any number of boots.  Except it
applies just to the first boot with -boot once, and never after
boot_set.  Weird.  Make it stick instead: set the bit according to
-no-fd-bootchk in pc_boot_set().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1371208516-7857-6-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agovl: Rename *boot_devices to *boot_order, for consistency
Markus Armbruster [Fri, 14 Jun 2013 11:15:04 +0000 (13:15 +0200)]
vl: Rename *boot_devices to *boot_order, for consistency

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1371208516-7857-5-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agovl: Fix -boot order and once regressions, and related bugs
Markus Armbruster [Fri, 14 Jun 2013 11:15:03 +0000 (13:15 +0200)]
vl: Fix -boot order and once regressions, and related bugs

Option "once" sets up a different boot order just for the initial
boot.  Boot order reverts back to normal on reset.  Option "order"
changes the normal boot order.

The reversal is implemented by reset handler restore_boot_devices(),
which takes the boot order to revert to as argument.
restore_boot_devices() does nothing on its first call, because that
must be the initial machine reset.  On its second call, it changes the
boot order back, and unregisters itself.

Because we register the handler right when -boot gets parsed, we can
revert to an incorrect normal boot order, and multiple -boot can
interact in funny ways.

Here's how things work without -boot once or order:

* boot_devices is "".

* main() passes machine->boot_order to to machine->init(), because
  boot_devices is "".  machine->init() configures firmware
  accordingly.  For PC machines, machine->boot_order is "cad", and
  pc_cmos_init() writes it to RTC CMOS, where SeaBIOS picks it up.

Now consider -boot order=:

* boot_devices is "".

* -boot order= sets boot_devices to "" (no change).

* main() passes machine->boot_order to to machine->init(), because
  boot_devices is "", as above.

  Bug: -boot order= has no effect.  Broken in commit e4ada29e.

Next, consider -boot once=a:

* boot_devices is "".

* -boot once=a registers restore_boot_devices() with argument "", and
  sets boot_devices to "a".

* main() passes boot_devices "a" to machine->init(), which configures
  firmware accordingly.  For PC machines, pc_cmos_init() writes the
  boot order to RTC CMOS.

* main() calls qemu_system_reset().  This runs reset handlers.

  - restore_boot_devices() gets called with argument "".  Does
    nothing, because it's the first call.

* Machine boots, boot order is "a".

* Machine resets (e.g. monitor command).  Reset handlers run.

  - restore_boot_devices() gets called with argument "".  Calls
    qemu_boot_set("") to reconfigure firmware.  For PC machines,
    pc_boot_set() writes it into RTC CMOS.  Reset handler
    unregistered.

    Bug: boot order reverts to "" instead of machine->boot_order.  The
    actual boot order depends on how firmware interprets "".  Broken
    in commit e4ada29e.

Next, consider -boot once=a -boot order=c:

* boot_devices is "".

* -boot once=a registers restore_boot_devices() with argument "", and
  sets boot_devices to "a".

* -boot order=c sets boot_devices to "c".

* main() passes boot_devices "c" to machine->init(), which configures
  firmware accordingly.  For PC machines, pc_cmos_init() writes the
  boot order to RTC CMOS.

* main() calls qemu_system_reset().  This runs reset handlers.

  - restore_boot_devices() gets called with argument "".  Does
    nothing, because it's the first call.

* Machine boots, boot order is "c".

  Bug: it should be "a".  I figure this has always been broken.

* Machine resets (e.g. monitor command).  Reset handlers run.

  - restore_boot_devices() gets called with argument "".  Calls
    qemu_boot_set("") to reconfigure firmware.  For PC machines,
    pc_boot_set() writes it into RTC CMOS.  Reset handler
    unregistered.

    Bug: boot order reverts to "" instead of "c".  I figure this has
    always been broken, just differently broken before commit
    e4ada29e.

Next, consider -boot once=a -boot once=b -boot once=c:

* boot_devices is "".

* -boot once=a registers restore_boot_devices() with argument "", and
  sets boot_devices to "a".

* -boot once=b registers restore_boot_devices() with argument "a", and
  sets boot_devices to "b".

* -boot once=c registers restore_boot_devices() with argument "b", and
  sets boot_devices to "c".

* main() passes boot_devices "c" to machine->init(), which configures
  firmware accordingly.  For PC machines, pc_cmos_init() writes the
  boot order to RTC CMOS.

* main() calls qemu_system_reset().  This runs reset handlers.

  - restore_boot_devices() gets called with argument "".  Does
    nothing, because it's the first call.

  - restore_boot_devices() gets called with argument "a".  Calls
    qemu_boot_set("a") to reconfigure firmware.  For PC machines,
    pc_boot_set() writes it into RTC CMOS.  Reset handler
    unregistered.

  - restore_boot_devices() gets called with argument "b".  Calls
    qemu_boot_set("b") to reconfigure firmware.  For PC machines,
    pc_boot_set() writes it into RTC CMOS.  Reset handler
    unregistered.

* Machine boots, boot order is "b".

  Bug: should really be "c", because that came last, and for all other
  -boot options, the last one wins.  I figure this was broken some
  time before commit 37905d6a, and fixed there only for a single
  occurence of "once".

* Machine resets (e.g. monitor command).  Reset handlers run.

  - restore_boot_devices() gets called with argument "".  Calls
    qemu_boot_set("") to reconfigure firmware.  For PC machines,
    pc_boot_set() writes it into RTC CMOS.  Reset handler
    unregistered.

    Same bug as above: boot order reverts to "" instead of
    machine->boot_order.

Fix by acting upon -boot options order, once and menu only after
option parsing is complete, and the machine is known.  This is how the
other -boot options work already.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1371208516-7857-4-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoqemu-option: check_params() is now unused, drop it
Markus Armbruster [Fri, 14 Jun 2013 11:15:02 +0000 (13:15 +0200)]
qemu-option: check_params() is now unused, drop it

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1371208516-7857-3-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agovl: Clean up parsing of -boot option argument
Markus Armbruster [Fri, 14 Jun 2013 11:15:01 +0000 (13:15 +0200)]
vl: Clean up parsing of -boot option argument

Commit 3d3b8303 threw in some QemuOpts parsing without replacing the
existing ad hoc parser, resulting in a confusing mess.  Clean it up.

Two user-visible changes:

1. Invalid options are reported more nicely.  Before:

        qemu: unknown boot parameter 'x' in 'x=y'

   After:

        qemu-system-x86_64: -boot x=y: Invalid parameter 'x'

2. If -boot is given multiple times, options accumulate, just like for
   -machine.  Before, only options order, once and menu accumulated.
   For the other ones, all but the first -boot in non-legacy syntax
   got simply ignored.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1371208516-7857-2-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agomake user networking hostfwd work with restrict=y
Gertjan Halkes [Fri, 11 Nov 2011 15:04:20 +0000 (16:04 +0100)]
make user networking hostfwd work with restrict=y

This patch allows the hostfwd option to override the restrict=y setting in
the user network stack, as explicitly stated in the documentation on the
restrict option:

     restrict=on|off
         If this option is enabled, the guest will be isolated, i.e. it
         will not be able to contact the host and no guest IP packets
         will be routed over the host to the outside. This option does
         not affect any explicitly set forwarding rules.

Qemu bug tracker:
https://bugs.launchpad.net/qemu/+bug/829455

Signed-off-by: Gertjan Halkes <qemu@ghalkes.nl>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
10 years agofix -net user checks by reordering checks
Bas van Sisseren [Mon, 3 Jun 2013 13:11:49 +0000 (15:11 +0200)]
fix -net user checks by reordering checks

reorder slirp config options. first check the dns-server-address,
then check the first-dhcp-address. the original code was comparing
the first-dhcp-address with the default dns-server-address, not
the configured dns-server-address.

Signed-off-by: Bas van Sisseren <bas@quarantainenet.nl>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
10 years agowdt_i6300esb: fix vmstate versioning
Michael Roth [Wed, 22 May 2013 16:32:51 +0000 (11:32 -0500)]
wdt_i6300esb: fix vmstate versioning

When this VMSD was introduced it's version fields were set to
sizeof(I6300State), making them essentially random from build to build,
version to version.

To fix this, we lock in a high version id and low minimum version id to
support old->new migration from all prior versions of this device's
state. This should work since the device state has not changed since
its introduction.

The potentially breaks migration from 1.5+ to 1.5, but since the
versioning was essentially random prior to this patch, new->old
migration was not consistently functional to begin with.

Reported-by: Nicholas Thomas <nick@bytemark.co.uk>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable@nongnu.org
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'bonzini/scsi-next' into staging
Anthony Liguori [Tue, 18 Jun 2013 15:06:47 +0000 (10:06 -0500)]
Merge remote-tracking branch 'bonzini/scsi-next' into staging

# By Paolo Bonzini (3) and others
# Via Paolo Bonzini
* bonzini/scsi-next:
  iscsi: reorganize iscsi_readcapacity_sync
  iscsi: simplify freeing of tasks
  vhost-scsi: fix k->set_guest_notifiers() NULL dereference
  scsi-disk: scsi-block device for scsi pass-through should not be removable
  scsi-generic: check the return value of bdrv_aio_ioctl in execute_command
  scsi-generic: fix sign extension of READ CAPACITY(10) data
  scsi: reset cdrom tray statuses on scsi_disk_reset

Message-id: 1371565016-2643-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'bonzini/nbd-next' into staging
Anthony Liguori [Tue, 18 Jun 2013 15:06:39 +0000 (10:06 -0500)]
Merge remote-tracking branch 'bonzini/nbd-next' into staging

# By Ján Tomko
# Via Paolo Bonzini
* bonzini/nbd-next:
  nbd: strip braces from literal IPv6 address in URI
  qemu-socket: allow hostnames starting with a digit

10 years agovirtio-rng: Fix crash with non-default backend
Cole Robinson [Fri, 31 May 2013 18:12:48 +0000 (14:12 -0400)]
virtio-rng: Fix crash with non-default backend

'default_backend' isn't always set, but 'rng' is, so use that.

$ ./x86_64-softmmu/qemu-system-x86_64 -object rng-random,id=rng0,filename=/dev/random -device virtio-rng-pci,rng=rng0
Segmentation fault (core dumped)

Regressed with virtio refactoring in 59ccd20a9ac719cff82180429458728f03ec612f

CC: qemu-stable@nongnu.org
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Amit Shah <amit.shah@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Message-id: bf4505014a0a941dbd3c62068f3cf2c496b69e6a.1370023944.git.crobinso@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoiscsi: reorganize iscsi_readcapacity_sync
Paolo Bonzini [Fri, 31 May 2013 11:56:24 +0000 (13:56 +0200)]
iscsi: reorganize iscsi_readcapacity_sync

Avoid the goto, and use the same retry logic for the 10- and 16-
byte versions.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoiscsi: simplify freeing of tasks
Paolo Bonzini [Fri, 31 May 2013 11:47:08 +0000 (13:47 +0200)]
iscsi: simplify freeing of tasks

Always free them in the iscsi_aio_*_acb functions and remove the
checks in their callers.  Remove ifs when the task struct was
previously dereferenced (spotted by Coverity).

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovhost-scsi: fix k->set_guest_notifiers() NULL dereference
Stefan Hajnoczi [Thu, 30 May 2013 14:14:44 +0000 (16:14 +0200)]
vhost-scsi: fix k->set_guest_notifiers() NULL dereference

Coverity picked up a copy-paste bug.  In vhost_scsi_start() we check for
!k->set_guest_notifiers and error out.  The check probably got copied
but instead of erroring we actually use the function pointer!

Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Asias He <asias@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoscsi-disk: scsi-block device for scsi pass-through should not be removable
Pavel Hrdina [Wed, 29 May 2013 13:47:23 +0000 (15:47 +0200)]
scsi-disk: scsi-block device for scsi pass-through should not be removable

This patch adds a new SCSI_DISK_F_NO_REMOVABLE_DEVOPS feature. By this
feature we can set that the scsi-block (scsi pass-through) device will still
be removable from the guest side, but from monitor it cannot be removed.

Cc: qemu-stable@nongnu.org
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoscsi-generic: check the return value of bdrv_aio_ioctl in execute_command
Pavel Hrdina [Wed, 29 May 2013 12:12:10 +0000 (14:12 +0200)]
scsi-generic: check the return value of bdrv_aio_ioctl in execute_command

This fixes the bug introduced by this commit ad54ae80c73f.
The bdrv_aio_ioctl() still could return null and we should return an error
in that case.

Cc: qemu-stable@nongnu.org
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoscsi-generic: fix sign extension of READ CAPACITY(10) data
Paolo Bonzini [Tue, 21 May 2013 12:08:53 +0000 (14:08 +0200)]
scsi-generic: fix sign extension of READ CAPACITY(10) data

Issuing the READ CAPACITY(10) command in the guest will cause QEMU
to update its knowledge of the maximum accessible LBA in the disk.
The recorded maximum LBA will be wrong if the disk is bigger than
1TB, because ldl_be_p returns a signed int.

When this is fixed, a latent bug will be unmasked.  If the READ
CAPACITY(10) command reported an overflow (0xFFFFFFFF), we must
not overwrite the previously-known maximum accessible LBA, or the guest
will fail to access the disk above the first 2TB.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoscsi: reset cdrom tray statuses on scsi_disk_reset
Pavel Hrdina [Mon, 20 May 2013 11:06:47 +0000 (13:06 +0200)]
scsi: reset cdrom tray statuses on scsi_disk_reset

Tray statuses should be also reset. Some guests may lock the tray and
right after resetting the guest it should be unlocked and closed. This
is done on power-on, reset and resume from suspend/hibernate on bare-metal.

This fix is already committed for IDE CD.
Check the commit a7f3d65b65b8c86a5ff0c0abcfefb45e2ec6fe4c.

Test results on bare-metal:
  - on reset/power-on the CD-ROM tray is closed even before the monitor
    is turned on
  - on resume from suspend/hibernate the tray is also closed before
    the monitor is turned on

From test results it seems that this behavior is OS and probably BIOS
independent.

Cc: qemu-stable@nongnu.org
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agonbd: strip braces from literal IPv6 address in URI
Ján Tomko [Mon, 3 Jun 2013 15:54:56 +0000 (17:54 +0200)]
nbd: strip braces from literal IPv6 address in URI

Otherwise they would get passed to getaddrinfo and fail with:
address resolution failed for [::1]:1234: Name or service not known

(Broken by commit v1.4.0-736-gf17c90b)

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoqemu-socket: allow hostnames starting with a digit
Ján Tomko [Mon, 3 Jun 2013 15:54:55 +0000 (17:54 +0200)]
qemu-socket: allow hostnames starting with a digit

According to RFC 1123 [1], hostnames can start with a digit too.

[1] http://tools.ietf.org/html/rfc1123#page-13

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Cc: qemu-stable@nongnu.org
[Use strspn, not strcspn. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agointc/xilinx_intc: Dont lower IRQ when HIE cleared
Peter Crosthwaite [Tue, 11 Jun 2013 01:00:40 +0000 (11:00 +1000)]
intc/xilinx_intc: Dont lower IRQ when HIE cleared

This is a little strange. It is lowering the parent IRQ pin on input
when HIE is cleared. There is no such behaviour in the real hardware.

ISR changes based on interrupt pin state are already guarded on HIE
being set. So we can just delete this if in its entirety.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agointc/xilinx_intc: Inhibit write to ISR when HIE
Peter Crosthwaite [Tue, 11 Jun 2013 00:59:55 +0000 (10:59 +1000)]
intc/xilinx_intc: Inhibit write to ISR when HIE

When the Hardware Interrupt Enable (HIE) bit is set, software cannot
change ISR. Add write guard accordingly.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agointc/xilinx_intc: Handle level interrupt retriggering
Peter Crosthwaite [Tue, 11 Jun 2013 00:59:09 +0000 (10:59 +1000)]
intc/xilinx_intc: Handle level interrupt retriggering

Acking a level sensitive interrupt should have no effect if the
interrupt pin is still asserted. The current implementation requires
and edge condition to occur for setting a level sensitive IRQ, which
means an ACK can clear a level sensitive interrupt, until the original
source strobes the interrupt again.

Fix by keeping track of the interrupt pin state and setting ISR based
on this every time update_irq() is called.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agointc/xilinx_intc: Don't clear level sens. IRQs without ACK
Peter Crosthwaite [Tue, 11 Jun 2013 00:58:25 +0000 (10:58 +1000)]
intc/xilinx_intc: Don't clear level sens. IRQs without ACK

For level sensitive interrupts, ISR bits are cleared when the input pin
is lowered. This is incorrect. Only software can clear ISR bits (via
IAR or direct write to ISR with !MER(2)).

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze/petalogix_s3adsp1800_mmu: Fix UART IRQ
Peter Crosthwaite [Tue, 11 Jun 2013 00:57:41 +0000 (10:57 +1000)]
microblaze/petalogix_s3adsp1800_mmu: Fix UART IRQ

The UART IRQ is edge sensitive, whereas the machine was registering it
as level sensitive. Fix.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agoMerge remote-tracking branch 'luiz/queue/qmp' into staging
Anthony Liguori [Mon, 17 Jun 2013 18:14:46 +0000 (13:14 -0500)]
Merge remote-tracking branch 'luiz/queue/qmp' into staging

# By Luiz Capitulino
# Via Luiz Capitulino
* luiz/queue/qmp:
  qerror: drop QERR_OPEN_FILE_FAILED macro
  block: bdrv_reopen_prepare(): don't use QERR_OPEN_FILE_FAILED
  savevm: qmp_xen_save_devices_state(): use error_setg_file_open()
  dump: qmp_dump_guest_memory(): use error_setg_file_open()
  cpus: use error_setg_file_open()
  blockdev: use error_setg_file_open()
  block: mirror_complete(): use error_setg_file_open()
  rng-random: use error_setg_file_open()
  error: add error_setg_file_open() helper

Message-id: 1371484631-29510-1-git-send-email-lcapitulino@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 17 Jun 2013 18:14:13 +0000 (13:14 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

# By Liu Yuan (2) and others
# Via Kevin Wolf
* kwolf/for-anthony:
  vmdk: Allow reading variable size descriptor files
  NVMe: Initial commit for new storage interface
  curl: Don't set curl options on the handle just before it's going to be deleted.
  vmdk: byteswap VMDK4Header.desc_offset field
  block/curl.c: Refuse to open the handle for writes.
  sheepdog: support 'qemu-img snapshot -a'
  sheepdog: fix snapshot tag initialization

Message-id: 1371486710-17793-1-git-send-email-kwolf@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agoMerge remote-tracking branch 'rth/fix-ppc64' into staging
Anthony Liguori [Mon, 17 Jun 2013 18:14:01 +0000 (13:14 -0500)]
Merge remote-tracking branch 'rth/fix-ppc64' into staging

# By Anton Blanchard
# Via Richard Henderson
* rth/fix-ppc64:
  tcg-ppc64: rotr_i32 rotates wrong amount
  tcg-ppc64: Fix add2_i64
  tcg-ppc64: bswap64 rotates output 32 bits
  tcg-ppc64: Fix RLDCL opcode

Message-id: 1371491129-30246-1-git-send-email-rth@twiddle.net
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
10 years agotcg-ppc64: rotr_i32 rotates wrong amount
Anton Blanchard [Sun, 2 Jun 2013 12:30:18 +0000 (22:30 +1000)]
tcg-ppc64: rotr_i32 rotates wrong amount

rotr_i32 calculates the amount to left shift and puts it into a
temporary, but then doesn't use it when doing the shift.

Cc: qemu-stable@nongnu.org
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ppc64: Fix add2_i64
Anton Blanchard [Sun, 2 Jun 2013 12:29:39 +0000 (22:29 +1000)]
tcg-ppc64: Fix add2_i64

add2_i64 was adding the lower double word to the upper double word
of each input. Fix this so we add the lower double words, then the
upper double words with carry propagation.

Cc: qemu-stable@nongnu.org
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ppc64: bswap64 rotates output 32 bits
Anton Blanchard [Sun, 2 Jun 2013 12:28:27 +0000 (22:28 +1000)]
tcg-ppc64: bswap64 rotates output 32 bits

If our input and output is in the same register, bswap64 tries to
undo a rotate of the input. This just ends up rotating the output.

Cc: qemu-stable@nongnu.org
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ppc64: Fix RLDCL opcode
Anton Blanchard [Tue, 11 Jun 2013 11:19:35 +0000 (21:19 +1000)]
tcg-ppc64: Fix RLDCL opcode

The rldcl instruction doesn't have an sh field, so the minor opcode
is shifted 1 bit. We were using the XO30 macro which shifted the
minor opcode 2 bits.

Remove XO30 and add MD30 and MDS30 macros which match the
Power ISA categories.

Cc: qemu-stable@nongnu.org
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agovmdk: Allow reading variable size descriptor files
Evgeny Budilovsky [Wed, 12 Jun 2013 11:06:30 +0000 (14:06 +0300)]
vmdk: Allow reading variable size descriptor files

the hard-coded 2k buffer on the stack won't allow reading big descriptor
files which can be generated when storing big images. For example 500G
vmdk splitted to 2G chunks.

Signed-off-by: Evgeny Budilovsky <evgeny.budilovsky@ravellosystems.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoNVMe: Initial commit for new storage interface
Keith Busch [Tue, 4 Jun 2013 15:17:10 +0000 (09:17 -0600)]
NVMe: Initial commit for new storage interface

Initial commit for emulated Non-Volatile-Memory Express (NVMe) pci
storage device.

NVMe is an open, industry driven storage specification defining
an optimized register and command set designed to deliver the full
capabilities of non-volatile memory on PCIe SSDs. Further information
may be found on the organizations website at:

http://www.nvmexpress.org/

This commit implements the minimum from the specification to work with
existing drivers.

Cc: Keith Busch <keith.busch@gmail.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agocurl: Don't set curl options on the handle just before it's going to be deleted.
Richard W.M. Jones [Mon, 10 Jun 2013 16:40:15 +0000 (17:40 +0100)]
curl: Don't set curl options on the handle just before it's going to be deleted.

(Found by Kamil Dudka)

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Cc: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agovmdk: byteswap VMDK4Header.desc_offset field
Stefan Hajnoczi [Mon, 10 Jun 2013 09:07:33 +0000 (11:07 +0200)]
vmdk: byteswap VMDK4Header.desc_offset field

Remember to byteswap VMDK4Header.desc_offset on big-endian machines.

Cc: qemu-stable@nongnu.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoblock/curl.c: Refuse to open the handle for writes.
Richard W.M. Jones [Mon, 10 Jun 2013 11:38:43 +0000 (12:38 +0100)]
block/curl.c: Refuse to open the handle for writes.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agosheepdog: support 'qemu-img snapshot -a'
Liu Yuan [Fri, 7 Jun 2013 17:54:26 +0000 (01:54 +0800)]
sheepdog: support 'qemu-img snapshot -a'

Just call sd_create_branch() in the snapshot_goto to rollback the image is good
enough. With this patch, 'loadvm' process for sheepdog is modified:

Suppose we have a snapshot chain A --> B --> C, we do 'loadvm A' so as to get
a new chain,

A --> B
|
V
C1

in the old code:

1 reload inode of A (in snapshot_goto)
2 read vmstate via A's vdi_id (loadvm_state)
3 delete C and create C1, reload inode of C1 (sd_create_branch on write)

with this patch applied:

1 reload inode of A, delete C and create C1  (in snapshot_goto)
2 read vmstate via C1's parent, that is A's vdi_id (loadvm_state)

This will fix the possible bug that QEMU exit between 2 and 3 in the old code

Cc: qemu-devel@nongnu.org
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agosheepdog: fix snapshot tag initialization
Liu Yuan [Fri, 7 Jun 2013 17:54:25 +0000 (01:54 +0800)]
sheepdog: fix snapshot tag initialization

This is an old and obvious bug. We should pass snapshot_id to the
tag. Or simple command like 'qemu-img snapshot -a tag sheepdog:image' will fail

Cc: qemu-devel@nongnu.org
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
10 years agoqerror: drop QERR_OPEN_FILE_FAILED macro
Luiz Capitulino [Fri, 7 Jun 2013 18:37:54 +0000 (14:37 -0400)]
qerror: drop QERR_OPEN_FILE_FAILED macro

Not used since the last commit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>