Commit Graph

50104 Commits

Author SHA1 Message Date
Paolo Bonzini 75f19f8c30 megasas: do not call pci_dma_unmap after having freed the frame once
Commit 8cc4678 ("megasas: remove useless check for cmd->frame", 2016-07-17) was
wrong because I trusted Coverity too much.  It turns out that there _is_ a
path through which cmd->frame can become NULL.  After megasas_handle_frame's
switch (md->frame->header.frame_cmd), megasas_init_firmware can be called.
From there, megasas_reset_frames will call megasas_unmap_frame which resets
cmd->frame = NULL.

However, there is another bug to fix in there, because megasas_unmap_frame
is called again after setting the command status.  In this case QEMU should
not do anything, instead it calls pci_dma_unmap again.  Harmless, but
better fix it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-11-28 15:11:17 +01:00
Guenter Roeck b77257d7ba arm: Create /chosen and /memory devicetree nodes if necessary
While customary, the /chosen and /memory devicetree nodes do not have to
exist. Create if necessary. Also create the /memory/device_type property
if needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Message-id: 1479346221-18474-1-git-send-email-linux@roeck-us.net
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-11-28 11:32:34 +00:00
Alistair Francis 6aa3a61657 generic-loader: file: Only set a PC if a CPU is specified
This patch fixes the generic-loader file loading to only set the program
counter if a CPU is specified. This follows what is written in the
documentation and was always part of the original intention.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 537bf4d08be7acf7a89b590cff69e19db7f0a6cd.1478908712.git.alistair.francis@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-11-28 11:25:58 +00:00
Eduardo Habkost 685479bd5d target-i386: Remove unused local_err variable
local_err can never be set to non-NULL. Remove the variable.

Detected by Coverity:

    *** CID 1365201:  Possible Control flow issues  (DEADCODE)
    /target-i386/cpu.c: 2050 in x86_cpu_parse_featurestr()
    2044             prop->value = g_strdup(val);
    2045             prop->errp = &error_fatal;
    2046             qdev_prop_register_global(prop);
    2047         }
    2048
    2049         if (local_err) {
    >>>     CID 1365201:  Possible Control flow issues  (DEADCODE)
    >>>     Execution cannot reach this statement: "error_propagate(errp, local...".
    2050             error_propagate(errp, local_err);
    2051         }
    2052     }
    2053
    2054     static void x86_cpu_load_features(X86CPU *cpu, Error **errp);
    2055     static int x86_cpu_filter_features(X86CPU *cpu);

Reported-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1480087313-15102-1-git-send-email-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2016-11-25 15:12:23 -02:00
Alberto Garcia 8f57758311 docs: Specify that cache-clean-interval is only supported in Linux
Make it clear that having Linux is a hard requirement for this
feature.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2016-11-25 13:51:31 +01:00
Alberto Garcia a8b99dd516 qcow2: Remove stale comment
We haven't been using CONFIG_MADVISE since 02d0e09503

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2016-11-25 13:51:30 +01:00
Alberto Garcia 91203f08f0 qcow2: Allow 'cache-clean-interval' in Linux only
The cache-clean-interval option of qcow2 only works on Linux. However
we allow setting it in other systems regardless of whether it works or
not.

In those systems this option is not simply a no-op: it actually
invalidates perfectly valid cache tables for no good reason without
freeing their memory.

This patch forbids using that option in non-Linux systems.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2016-11-25 13:51:30 +01:00
Alberto Garcia 2f2c8d6b37 qcow2: Make qcow2_cache_table_release() work only in Linux
We are using QEMU_MADV_DONTNEED to discard the memory of individual L2
cache tables. The problem with this is that those semantics are
specific to the Linux madvise() system call. Other implementations of
madvise() (including the very Linux implementation of posix_madvise())
don't do that, so we cannot use them for the same purpose.

This patch makes the code Linux-specific and uses madvise() directly
since there's no point in going through qemu_madvise() for this.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2016-11-25 13:51:30 +01:00
Stefan Hajnoczi 511008f5cc -----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJYNwZzAAoJEPMMOL0/L7482q0P/3TbgAqccdyBT6NQ8ksbz4lO
 70QYdwwjRm02TJThnHqwSgx8UJPPXhYXJ2E1lbzP2K2NcN+FPNkYtpbG0gvyHr76
 OXRQ2MjJ2rXCDdk0vVhudjZTCR2V9mtLma2o+MUa0v4bmapmSIPbjomeYFEDYUrI
 Zv8+RrtcJC7C67Rrk1UB8mV+rK6bjc0bUq9jmwMFQO4llXWvcnOwzr8vVc8EYAw8
 MuyQmt1rw3lc5NddOoidnAhPJlF82c+MPuLx7UiNKI7i7ZByMH4tDNsrrpKRjWUj
 UJyc79gZTltIg3pYSHtPu2y2druafm2A/VAd/0vtkCOGRC3Jzlk36+gflaCW1tpo
 n5BR0pzpc0iYI54Qnb38iv92Qz5PDrPva0vWzaKn6yntZyN+wc9AXGfjLXjgf8Da
 8CMP7iTqmIby9UUMhS64rohfQNNc9Hc0rV3dQMuz1sm+5T6LC0WzOGBMBjwCoNY8
 +3xH/VKZa8FZfb/hDWshQfKG/4SVgyFgZ/Q5COLLAfIW1jZPbMJPlTao/nusMCcg
 bvf37Dg1ZHFpi0I2rNbZ/3XUYQIYb4WZTXc86z1NjN8XAvhZwfaMuG7K13tYrgx8
 tOqvPMhpc6w5VjBcdS3XV+MzEj//7OC++TDk7xat+oZnxGBcuiHaEoAtxyMX2Yie
 28TfVOn18rfhDIwkB7dn
 =rvc6
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'vivier-m68k/tags/m68k-for-2.8-pull-request' into staging

# gpg: Signature made Thu 24 Nov 2016 03:25:39 PM GMT
# gpg:                using RSA key 0xF30C38BD3F2FBE3C
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>"
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>"
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>"
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* vivier-m68k/tags/m68k-for-2.8-pull-request:
  target-m68k: fix muluw/mulsw
  target-m68k: Fix cmpa operand size
  target-m68k: fix EXG instruction

Message-id: 1480001287-17515-1-git-send-email-laurent@vivier.eu
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-25 12:03:36 +00:00
Stefan Hajnoczi 628d0a4bdf Update OpenBIOS images
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQEcBAABAgAGBQJYN1vEAAoJEFvCxW+uDzIfexcH/iEOn4hl5oKAIxaVINW2i7Q6
 aozdigQl/zrJNAEfzhyFoI28FQcLBwmOJv5rLZ7MOGdIKbqLLc9JzZxD7lTn16vx
 Y0h2bRwtFh6LAOO4X5/Q0Pc5I43GU9MRIkDSgbg9NA2HLm0fUubiwaFvbAdpvhm5
 qwPcGlM6Aq/Ef0weg6al9eqMYF08PMTSfreewo62pOwT7R3cOhX3BlRA86RRaxGy
 ZjFbcoV5U7z/W1Yk4WNN9NUokLhk/BEYpkIzLWdxRlnxUOQrbgWwSThTsPvXYoqx
 g0x9TUllAVFAS5Egxu9C+qx5UMnZB47r29mVNhlTdbzcACzXg+kOGy0+7ueprrA=
 =MeZ5
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'mcayland/tags/qemu-openbios-signed' into staging

Update OpenBIOS images

 # gpg: Signature made Thu 24 Nov 2016 09:29:40 PM GMT
 # gpg:                using RSA key 0x5BC2C56FAE0F321F
 # gpg: Good signature from "Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>"
 # Primary key fingerprint: CC62 1AB9 8E82 200D 915C  C9C4 5BC2 C56F AE0F 321F

* mcayland/tags/qemu-openbios-signed:
  Update OpenBIOS images to ef8a14e built from submodule.

Message-id: 20161124214109.GB29463@kentang.lan
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-25 10:33:26 +00:00
Mark Cave-Ayland 06c33754a1 Update OpenBIOS images to ef8a14e built from submodule.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2016-11-24 21:26:00 +00:00
Laurent Vivier 4a18cd44f3 target-m68k: fix muluw/mulsw
"The multiplier and multiplicand are both word operands, and the result
is a long-word operand."

So compute flags on a long-word result, not on a word result.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2016-11-24 16:24:27 +01:00
Stefan Hajnoczi 0fecd0292c This pull request fixes some leaks (memory, fd) in the handle and proxy
backends.
 -----BEGIN PGP SIGNATURE-----
 
 iEYEABECAAYFAlg1kVUACgkQAvw66wEB28IIzACfXKtN7ut2ZiakDKHH182CadeO
 PoMAni7ivvO1KGqO9osvwiEeY2KPIkED
 =ZAcB
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'gkurz/tags/for-upstream' into staging

This pull request fixes some leaks (memory, fd) in the handle and proxy
backends.

 # gpg: Signature made Wed 23 Nov 2016 12:53:41 PM GMT
 # gpg:                using DSA key 0x02FC3AEB0101DBC2
 # gpg: Good signature from "Greg Kurz <groug@kaod.org>"
 # gpg:                 aka "Greg Kurz <groug@free.fr>"
 # gpg:                 aka "Greg Kurz <gkurz@fr.ibm.com>"
 # gpg:                 aka "Greg Kurz <gkurz@linux.vnet.ibm.com>"
 # gpg:                 aka "Gregory Kurz (Groug) <groug@free.fr>"
 # gpg:                 aka "Gregory Kurz (Cimai Technology) <gkurz@cimai.com>"
 # gpg:                 aka "Gregory Kurz (Meiosys Technology) <gkurz@meiosys.com>"
 # gpg: WARNING: This key is not certified with a trusted signature!
 # gpg:          There is no indication that the signature belongs to the owner.
 # Primary key fingerprint: 2BD4 3B44 535E C0A7 9894  DBA2 02FC 3AEB 0101 DBC2

* gkurz/tags/for-upstream:
  9pfs: add cleanup operation for proxy backend driver
  9pfs: add cleanup operation for handle backend driver
  9pfs: add cleanup operation in FileOperations
  9pfs: adjust the order of resource cleanup in device unrealize

Message-id: 1479920298-24983-1-git-send-email-groug@kaod.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-24 10:16:23 +00:00
Stefan Hajnoczi 801edfcbb5 Fix alpha smp interrupt masking
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJYNY7FAAoJEK0ScMxN0CebQaoIALD/nXVxyFMi3wkPcXeUu6/n
 wmGMKwiOqRtoRG/QeVoYrlwmcneD97j7iCHmrfQRmtEn4UkU76fa/IqSjnA438Yu
 6LRb728PPuhf9YJZBP8vJzxJ+D+YhXfEQ91b24eQtkfAJDrC0GqCnShgSbGSmuwE
 DZwLv2iMJdwQIopx8I/5dZwkF6a12wnDs2bDXG/ALZFs2nkFyH7uYPC1i2feh++M
 W7D85SBvPHwZtzh6wiYhuyZJQ319ItC6Hn+sZBjP9kiGwgRrM5wIGll1gzyBl0Lx
 mkyPyGU4GOz5has/Vbxdd1DjZ7di6FUbuB20gXb1Aug97tNcg6EaZcD9bwuWKqE=
 =6FvR
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'rth/tags/pull-axp-20161123' into staging

Fix alpha smp interrupt masking

# gpg: Signature made Wed 23 Nov 2016 12:42:45 PM GMT
# gpg:                using RSA key 0xAD1270CC4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"
# Primary key fingerprint: 9CB1 8DDA F8E8 49AD 2AFC  16A4 AD12 70CC 4DD0 279B

* rth/tags/pull-axp-20161123:
  target-alpha: Fix interrupt mask for cpu1

Message-id: 1479905195-7424-1-git-send-email-rth@twiddle.net
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-24 09:50:32 +00:00
Laurent Vivier 5436c29d78 target-m68k: Fix cmpa operand size
"The size of the operation can be specified as word or long.
Word length source operands are sign-extended to 32 bits for
comparison."

So comparison is always done using OS_LONG.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2016-11-24 09:39:05 +01:00
Laurent Vivier c090c97d92 target-m68k: fix EXG instruction
opcodes of "EXG Ax,Ay" and "EXG Dx,Dy" have been swapped

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2016-11-24 09:38:44 +01:00
Olaf Hering 7875efb9f6 xen_disk: split discard input to match internal representation
The guest sends discard requests as u64 sector/count pairs, but the
block layer operates internally with s64/s32 pairs. The conversion
leads to IO errors in the guest, the discard request is not processed.

  domU.cfg:
  'vdev=xvda, format=qcow2, backendtype=qdisk, target=/x.qcow2'
  domU:
  mkfs.ext4 -F /dev/xvda
  Discarding device blocks: failed - Input/output error

Fix this by splitting the request into chunks of BDRV_REQUEST_MAX_SECTORS.
Add input range checking to avoid overflow.

Fixes f313520 ("xen_disk: add discard support")

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2016-11-23 10:47:48 -08:00
Li Qiang 898ae90a44 9pfs: add cleanup operation for proxy backend driver
In the init operation of proxy backend dirver, it allocates a
V9fsProxy struct and some other resources. We should free these
resources when the 9pfs device is unrealized. This is what this
patch does.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
2016-11-23 13:53:34 +01:00
Li Qiang 971f406b77 9pfs: add cleanup operation for handle backend driver
In the init operation of handle backend dirver, it allocates a
handle_data struct and opens a mount file. We should free these
resources when the 9pfs device is unrealized. This is what this
patch does.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
2016-11-23 13:53:34 +01:00
Li Qiang 702dbcc274 9pfs: add cleanup operation in FileOperations
Currently, the backend of VirtFS doesn't have a cleanup
function. This will lead resource leak issues if the backed
driver allocates resources. This patch addresses this issue.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
2016-11-23 13:53:34 +01:00
Li Qiang 4774718e5c 9pfs: adjust the order of resource cleanup in device unrealize
Unrealize should undo things that were set during realize in
reverse order. So should do in the error path in realize.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
2016-11-23 13:53:34 +01:00
Stefan Hajnoczi 659fc8d342 ppc patch queue 2016-11-23
Here's the first set of 2.8 hard freeze bugfixes for ppc.
 
 The biggest thing here is a batch of fixes for migration breakages in
 both 2.7 and current 2.8.  Alas, there is at least one more migration
 problem, which prevents memory unplug after a migration.  I hoped to
 include a fix for that here, but it turned out to have some problems
 bigger than those it was solving.  So, I expect at least one more hard
 freeze pull request.
 
 There are also a few other assorted bug fixes.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJYNP4mAAoJEGw4ysog2bOSouIQALsw0PNpduvEsUzgEZ6GOgFw
 77jEawt4me+eCgB0oipj0Bz9ho2DIGeheiFrvU7vTsD/q00CDc5kZ6GNPlY43sGM
 OzT65EyycQ7MDZFDfVgpmaHjXqIGVf5zZbyz8ZD5wU3w10DdRtrDogYcjb+ZQzCG
 0vRnAkV/tuVkn9Z5ogWrdvhQa0/ER3Yk/BpTXoe4JFoLgViwydkI6yCSw5dwatEU
 djprDinCsBziKDT03Z9wmiTGTvZk6iGHMJWPOLJOSTBd5v9pzdpxtuNrZrF1oOQd
 pBE1qlNkCpnd+LLKyW+nsTdo1FyxUg0pg7kWqnSPwqm+KM09Phpp00FN69Hmz/DR
 P+aMX9qKaTJoNPHklY15pmF/olIkcxVlidNKaqgKAbZZR5BuHF3YBVILWL8ZfaeE
 n6Gw0GqJeTSW5mO81uikKTZt5kqOVChHbxXcxfVl/4vzk8TTS3fy5AW0IERbfgHN
 NbBesSZejqL++xzVrfoVyfJV8nkF1M+08FITQdyXpkdYVB565e9YmlIaLpZ5a7It
 gLVBqbAEOaC+5swlEyAp70h+nhjVN631+b8gs+bi9trrBL9IL8q3g7U0l7XKM0Zs
 MU6nxV2zogbdVraiPv9KrwtOeUKXAPUJfe3fXRr4rBYTL7HK9CBQWjaGNVtFJPKk
 vWybUBSmwF402OmslZKp
 =cds8
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'dgibson/tags/ppc-for-2.8-20161123' into staging

ppc patch queue 2016-11-23

Here's the first set of 2.8 hard freeze bugfixes for ppc.

The biggest thing here is a batch of fixes for migration breakages in
both 2.7 and current 2.8.  Alas, there is at least one more migration
problem, which prevents memory unplug after a migration.  I hoped to
include a fix for that here, but it turned out to have some problems
bigger than those it was solving.  So, I expect at least one more hard
freeze pull request.

There are also a few other assorted bug fixes.

# gpg: Signature made Wed 23 Nov 2016 02:25:42 AM GMT
# gpg:                using RSA key 0x6C38CACA20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>"
# gpg:                 aka "David Gibson (kernel.org) <dwg@kernel.org>"
# gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>"
# gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>"
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392

* dgibson/tags/ppc-for-2.8-20161123:
  spapr: Fix 2.7<->2.8 migration of PCI host bridge
  Revert "spapr: Fix migration of PCI host bridges from qemu-2.7"
  target-ppc: Allow eventual removal of old migration mistakes
  migration: Add VMSTATE_UINTTL_TEST()
  target-ppc: Fix CPU migration from qemu-2.6 <-> later versions
  ppc: Make uninorth interrupt swizzling identical to Grackle
  target-ppc: fix index array of national digits
  hw/char/spapr_vty: Return amount of free buffer entries in vty_can_receive()
  ppc: BOOK3E: nothing should be done when MSR:PR is set
  spapr: migration support for CAS-negotiated option vectors
  tests/postcopy: Use KVM on ppc64 only if it is KVM-HV

Message-id: 1479869383-16162-1-git-send-email-david@gibson.dropbear.id.au
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-23 11:46:15 +00:00
Stefan Hajnoczi f0c10c392f Small fixes for rc1.
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQEcBAABAgAGBQJYNMYwAAoJEL/70l94x66DBrUIAKeNK59lTbUm1WVl15nyB2qM
 jE2804Kcp+EGTwFHeo5GGsb+CplK54uMzHq2wzN6G3EmnaV3xbbdiZ7cmNl5Q6Tr
 qq7/pAer/T+xvQ3iDOTkAvJcqiMUZIx+MXrFED46KBUtqANJ2tAg2uEEqbI0RbOU
 +qtMZlPxo3IOuYnVROug1PPdNQDluBvZjrCYtb7VfZNo13u2UGYmRjZttobVfihF
 AQjv57uiawPs2e3VmUvIH8fjjEgV4MlPLiilL1eYsLaszjIBgdfrQOO7bdfetLo8
 THkNJEZTpS9T9ChcbcTKS7yovI3OiIxPMwyftELClacX3wVtSie2WNx0sj/3Xpw=
 =DPxR
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'bonzini/tags/for-upstream' into staging

Small fixes for rc1.

# gpg: Signature made Tue 22 Nov 2016 10:26:56 PM GMT
# gpg:                using RSA key 0xBFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>"
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* bonzini/tags/for-upstream:
  scsi/esp: do not raise an interrupt when reading the FIFO register
  nbd: Allow unmap and fua during write zeroes
  cpu_ldst.h: use correct guest address parameter

Message-id: 1479853676-35995-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-23 11:44:29 +00:00
David Gibson 5c4537bded spapr: Fix 2.7<->2.8 migration of PCI host bridge
daa2369 "spapr_pci: Add a 64-bit MMIO window" subtly broke migration
from qemu-2.7 to the current version.  It split the device's MMIO
window into two pieces for 32-bit and 64-bit MMIO.

The patch included backwards compatibility code to convert the old
property into the new format.  However, the property value was also
transferred in the migration stream and compared with a (probably
unwise) VMSTATE_EQUAL.  So, the "raw" value from 2.7 is compared to
the new style converted value from (pre-)2.8 giving a mismatch and
migration failure.

Along with the actual field that caused the breakage, there are
several other ill-advised VMSTATE_EQUAL()s.  To fix forwards
migration, we read the values in the stream into scratch variables and
ignore them, instead of comparing for equality.  To fix backwards
migration, we populate those scratch variables in pre_save() with
adjusted values to match the old behaviour.

To permit the eventual possibility of removing this cruft from the
stream, we only include these compatibility fields if a new
'pre-2.8-migration' property is set.  We clear it on the pseries-2.8
machine type, which obviously can't be migrated backwards, but set it
on earlier machine type versions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-11-23 12:00:48 +11:00
David Gibson 5a78b821eb Revert "spapr: Fix migration of PCI host bridges from qemu-2.7"
This reverts commit 9b54ca0ba7.

The commit above corrected a migration breakage between qemu-2.7 and
qemu-2.8.  However it did so by advancing the migration version for
the PCI host bridge, which obviously breaks migration backwards to
earlier qemu versions.

Although it's not totally essential, we'd like to maintain the
possibility for backwards migration, so revert the change in
preparation for a better fix.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-11-23 12:00:48 +11:00
David Gibson 146c11f16f target-ppc: Allow eventual removal of old migration mistakes
Until very recently, the vmstate for ppc cpus included some poorly
thought out VMSTATE_EQUAL() components, that can easily break
migration compatibility, and did so between qemu-2.6 and later
versions.  A hack was recently added which fixes this migration
breakage, but it leaves the unhelpful cruft of these fields in the
migration stream.

This patch adds a new cpu property allowing these fields to be removed
from the stream entirely.  For the pseries-2.8 machine type - which
comes after the fix - and for all non-pseries machine types - which
aren't mature enough to care about cross-version migration - we remove
the fields from the stream.

For pseries-2.7 and earlier, The migration hack remains in place,
allowing backwards and forwards migration with the older machine
types.

This restricts the migration compatibility cruft to older machine
types, and at least opens the possibility of eventually deprecating
and removing it entirely.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-11-23 12:00:48 +11:00
David Gibson 3fed86eefc migration: Add VMSTATE_UINTTL_TEST()
include/migration/cpu.h defines VMSTATE_UINTTL() and several variants
for migrating target_ulong fields.  It's defined in terms of
VMSTATE_UINT32() or VMSTATE_UINT64() as appropriate.

It doesn't, however, include a VMSTATE_UINTTL_TEST() variant, which
I'm going to need shortly.  So, add it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
2016-11-23 12:00:48 +11:00
David Gibson 16a2497bd4 target-ppc: Fix CPU migration from qemu-2.6 <-> later versions
When migration for target-ppc was converted to vmstate, several
VMSTATE_EQUAL() checks were foolishly included of things that really
should be internal state.  Specifically we verified equality of the
insns_flags and insns_flags2 fields, which are used within TCG to
determine which groups of instructions are available on this cpu
model.  Between qemu-2.6 and qemu-2.7 we made some changes to these
classes which broke migration.

This path fixes migration both forwards and backwards.  On migration
from 2.6 to later versions we import the fields into teporary
variables, which we then ignore.  In migration backwards, we populate
the temporary fields from the runtime fields, but mask out the bits
which were added after qemu-2.6, allowing the VMSTATE_EQUAL in
qemu-2.6 to accept the stream.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
2016-11-23 12:00:48 +11:00
Benjamin Herrenschmidt 39d97e14a1 ppc: Make uninorth interrupt swizzling identical to Grackle
It's currently broken as it uses an incorrect shift, it tries
to use the slot number but uses the top bits of the bus number
instead.

Note: Neither implementation matches what OpenBIOS ends up putting
in the device-tree either, which will have to be fixed separately.

This is not quite correct for modelling a real Mac since Apple
tend to tie all 4 interrupt lines of a slot together and have
separate interrupts for every slot and every motherboard devices
going straight to the PIC but we'll sort that out later.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-11-23 12:00:48 +11:00
Jose Ricardo Ziviani a813fe7362 target-ppc: fix index array of national digits
Fixes the big endian array access of national digits, from commits
b815587 and e2106d7.

Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-11-23 12:00:48 +11:00
Thomas Huth 8a273cbe53 hw/char/spapr_vty: Return amount of free buffer entries in vty_can_receive()
The can_receive() callbacks of the character devices should return
the amount of characters that can be accepted at once, not just a
boolean value (which rather means only one character at a time).

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-11-23 12:00:48 +11:00
Vladimir Svoboda 0d28aa197d ppc: BOOK3E: nothing should be done when MSR:PR is set
The server architecture (BOOK3S) specifies that any instruction that
sets MSR:PR will also set MSR:EE, IR and DR.
However there is no such behavior specification for the embedded
architecture (BOOK3E).

Signed-off-by: Vladimir Svoboda <ze.vlad@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2016-11-23 12:00:48 +11:00
Michael Roth 62ef3760d4 spapr: migration support for CAS-negotiated option vectors
With the additional of the OV5_HP_EVT option vector, we now have
certain functionality (namely, memory unplug) that checks at run-time
for whether or not the guest negotiated the option via CAS. Because
we don't currently migrate these negotiated values, we are unable
to unplug memory from a guest after it's been migrated until after
the guest is rebooted and CAS-negotiation is repeated.

This patch fixes this by adding CAS-negotiated options to the
migration stream. We do this using a subsection, since the
negotiated value of OV5_HP_EVT is the only option currently needed
to maintain proper functionality for a running guest.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-11-23 12:00:48 +11:00
Thomas Huth 171da9d5db tests/postcopy: Use KVM on ppc64 only if it is KVM-HV
The ppc64 postcopy test does not work with KVM-PR, and it is also
causing annoying warning messages when run on a x86 host. So let's
use KVM here only if we know that we're running with KVM-HV (which
automatically also means that we're running on a ppc64 host), and
fall back to TCG otherwise.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-11-23 12:00:48 +11:00
Stefan Hajnoczi 00227fefd2 Update version for v2.8.0-rc1 release
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-22 22:29:08 +00:00
Hervé Poussineau 1d895feb3b scsi/esp: do not raise an interrupt when reading the FIFO register
This fixes SCSI adapter self-tests done in MIPS Jazz emulation,
broken since ff589551c8.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Message-Id: <1479508397-8443-1-git-send-email-hpoussin@reactos.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-11-22 23:26:51 +01:00
Eric Blake 169407e1f7 nbd: Allow unmap and fua during write zeroes
Commit fa778fff wired up support to send the NBD_CMD_WRITE_ZEROES,
but forgot to inform the block layer that FUA unmapping of zeroes is
supported.  Without BDRV_REQ_MAY_UNMAP listed as a supported flag,
the block layer will always insist on the NBD layer passing
NBD_CMD_FLAG_NO_HOLE, resulting in the server always allocating
things even when it was desired to let the server punch holes.
Similarly, failing to set BDRV_REQ_FUA means that the client may
send unnecessary NBD_CMD_FLUSH when it could have instead used the
NBD_CMD_FLAG_FUA bit.

CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1479413642-22463-2-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-11-22 23:26:51 +01:00
Bobby Bingham c2a8531690 cpu_ldst.h: use correct guest address parameter
In the user emulation code path, tlb_vaddr_to_host erronesously passed
vaddr as the guest address to be translated, instead of addr, the parameter
which actually contained the guest address.

This resulted in incorrect addresses being used when emulating block copy
(mvc/mvpg) and block clear (xc) instructions for the s390x target.

Signed-off-by: Bobby Bingham <koorogi@koorogi.info>
Message-Id: <20161113050523.23909-1-koorogi@koorogi.info>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-11-22 23:26:51 +01:00
Stefan Hajnoczi 01d7d15ce3 Xen 2016/11/22
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJYNJFTAAoJEIlPj0hw4a6QeoQP/0EZQQCM2N0xUjiuaJ3tkl7I
 LSVQACtkSZ8ZHXilu30cmav9+HoyO1kE2lTeLAW9nkKAdiwhumVodBxBYYMbxL3m
 nVzccXnOzj1kJ3ObffZY/cIegiJEoDjJR/QqC6LmmyrV68KlYoaU9nD1GXoz/Moc
 ScOe6o/mOdbYfRP7CJITLzKQ3wu6eg6Azgks/jjoZ14Kjjl0kPPg2uiCew0m52Q6
 2/9d24db5QABVrokG6/7DNTy7/knOBug4dHIQhkgQuTY6US+97Ovw2xK5V5oUlsJ
 QaA5EF5Fz55Ifc1H4dpFytRVI6ljGqfpv9xPyn0M4eycVZL5fpuMA3l1g3wExNoo
 bI3YV/akIYNNBTmNcKZiS7xcAZF6IGkcpjhoSoTK0xAX2NVxA0kTX9Zw6A6q+YGI
 jk/lvm1NnHqZjhqe1LqhVX7kTIdNqxH9Eom/Y8yfIDwb3QKKSRPFu1ySQ/yGmQsR
 Dxk/IxLN8b3BkxvhaTr7K9F+3DUwa8c+9JmVg4ejVoIh/B+20SQGjSjAmQhWNa8g
 eHJHx498dgReWkft30T/iB0PzcsbpUvz7057cTTB3qCbf9MoyQdaZvgxO+2xUUrm
 JuHhGd2beWH4O3O1Nx8GkhrAWW0027Gb2BBR4sDyGpC0zTivNw3cdar0UUITdI+E
 3DKBdrec0c2Y5E7PLvgJ
 =DmJS
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'sstabellini/tags/xen-20161122-tag' into staging

Xen 2016/11/22

# gpg: Signature made Tue 22 Nov 2016 06:41:23 PM GMT
# gpg:                using RSA key 0x894F8F4870E1AE90
# gpg: Good signature from "Stefano Stabellini <sstabellini@kernel.org>"
# gpg:                 aka "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"
# Primary key fingerprint: D04E 33AB A51F 67BA 07D3  0AEA 894F 8F48 70E1 AE90

* sstabellini/tags/xen-20161122-tag:
  xen: attach pvusb usb bus to backend qdev
  xen: create qdev for each backend device
  qdev: add function qdev_set_id()
  xen: add an own bus for xen backend devices
  xen: fix ioreq handling

Message-id: alpine.DEB.2.10.1611221037010.21858@sstabellini-ThinkPad-X260
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-22 19:30:39 +00:00
Stefan Hajnoczi 76989f4ffa Block layer patches for 2.8.0-rc1
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJYNGp6AAoJEH8JsnLIjy/WAgYP/isOOb1NF6OWQKkVHc6cipMd
 RElj5HQlFYP7FmdP4Z2QdNI82K12G/wnctGtREAqmUQqivpJoejsLHXo70Oik6EZ
 KIafgD/xD1zXw+DBTsJBZI5iE/VWRXcQ7l49OqtRTqYEF0V4chzJmlo8m4+TLHbq
 119b48GmjYy94a4xbgPBL3Yhude1tvkXR3VNfEQU7EzxpwTGZnH+egqdNvpMpvmY
 Ty400of4oq/eH25XtJ5pUESeLvUv13WTMsLMCmGBpliJx2R9nqN7ScgJW8z7/fkS
 z3RC49jroL1O1TIMXIY/EGzFoiGWFAdolVrnLyvzV2sFtynLcbKrM6XHXqUN6ITt
 rNPpjMX5cij8106kPNgwynpao4/n9abOx8RxtMBZvVVyWvJ/f6HD+gx9QFPseKXC
 ++l50aOkAu3oLh/KIrXcD/sLe5wCNnJRC5NjNjfi8Bi2Lxcwt8XHHYbGlyierDDW
 KDL98jshA3tlnC+hso7D5pnwNBt67zN4sOlBiqywZieFTJhwCvhWSUUfEXnIIIrl
 QV/Fu/y3ohTDiNpzJ4g0Zgb1UbTu+nccQiuaUHaUBIhgKjZR9oyAEsjdky47o67T
 qvB7wSsfXnURblncn303Q0BuZIGV60JTdxTXEdOp8X3dJy+mkvzH9zRagzWIk10Y
 FRatMVcTna8MsBJ1pYTy
 =1Mkm
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'kwolf/tags/for-upstream' into staging

Block layer patches for 2.8.0-rc1

# gpg: Signature made Tue 22 Nov 2016 03:55:38 PM GMT
# gpg:                using RSA key 0x7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* kwolf/tags/for-upstream:
  block: Pass unaligned discard requests to drivers
  block: Return -ENOTSUP rather than assert on unaligned discards
  block: Let write zeroes fallback work even with small max_transfer
  qcow2: Inform block layer about discard boundaries

Message-id: 1479830693-26676-1-git-send-email-kwolf@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-22 19:30:03 +00:00
Stefan Hajnoczi 5167dff8c7 seabios: update to 1.10.1 stable release
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJYNAwHAAoJEEy22O7T6HE4b6kQAKF9QqZG0/hgTF8GjOMI9V9t
 ha7lTV/X5OhkqwI3w1LXM/3YsroXM6tgpPdu1qVJXZxLD0vqiEPuSbV0vgKeYtdK
 TckWoj+07zZvHjdsgSmw6zC77vOFvDI3J6zy2EgOhNNhY+nL6dp2HzdGyNvkFOro
 YfV5RaXLduykrmV/zfg5wuz87/5PDgu2ZTqmTixBjzVN3cNRJW8pn3PjW1WO1zDT
 swQzBYaKx+LHWwHoYC3kmMB4QQC3pNPvvy0QKMNEHD0Wa5biIKlXml8RcdDPVxmh
 jv9HV49rxL7YyEQ7C7Jkh02J5ImPI7l1YHT5wHbehdkDhXKfQusUysiMFlhYht64
 qxyknqn0FF1oKeYxh0bueJWe8+vuzlk5apgwNG3H74mHPh65/TSEAFF9SeEhmIMt
 Yc8zORuQUaUr/Qh5/2O4h1P16alp6SVhMAadQA3nXAo1sKD6U6VPlvm/DhVlz7Wn
 T5Eud6mPbBlA9VxaboFj1b4Ojvy800ySibwX/3HK8CxrOI0W/k0RHuSVM4fjHY9M
 8i2omx0eXoZwE0hZYQ9p+iOm8kg/u7jBrPZAUX8L4Fi56KJ0Gl1CQcROeO5rGuks
 cFOXY0xqkziPRjc5zhzx6XwafGldXZRAA1DIwp2mmyfOHQTgQKgBBQxunlMdzjYa
 i4VumSQL9o6pdUtj6314
 =bq9b
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'kraxel/tags/pull-seabios-20161122-1' into staging

seabios: update to 1.10.1 stable release

# gpg: Signature made Tue 22 Nov 2016 09:12:39 AM GMT
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* kraxel/tags/pull-seabios-20161122-1:
  seabios: update to 1.10.1 stable release

Message-id: 1479806144-25599-1-git-send-email-kraxel@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-11-22 19:29:30 +00:00
Juergen Gross f1784a222e xen: attach pvusb usb bus to backend qdev
Attach the usb bus of a new pvusb controller to the qdev associated
with the Xen backend. Any device connected to that controller can now
specify the bus and port directly via its properties.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
2016-11-22 10:29:41 -08:00
Juergen Gross 3a6c9172ac xen: create qdev for each backend device
Create a qdev plugged to the xen-sysbus for each new backend device.
This device can be used as a parent for all needed devices of that
backend. The id of the new device will be "xen-<type>-<dev>" with
<type> being the xen backend type (e.g. "qdisk") and <dev> the xen
backend number of the type under which it is to be found in xenstore.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
2016-11-22 10:29:39 -08:00
Juergen Gross ce49b734b4 qdev: add function qdev_set_id()
In order to have an easy way to add a new qdev with a specific id
carve out the needed functionality from qdev_device_add() into a new
function qdev_set_id().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
2016-11-22 10:29:37 -08:00
Juergen Gross 873d57abba xen: add an own bus for xen backend devices
Add a bus for Xen backend devices in order to be able to establish a
dedicated device path for pluggable devices.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
2016-11-22 10:29:32 -08:00
Jan Beulich b85f9dfdb1 xen: fix ioreq handling
Avoid double fetches and bounds check size to avoid overflowing
internal variables.

This is CVE-2016-9381 / XSA-197.

Reported-by: yanghongke <yanghongke@huawei.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
2016-11-22 10:29:22 -08:00
Richard Henderson 424ad8388f target-alpha: Fix interrupt mask for cpu1
A typo prevents ISA interrupts from being recognized on cpu0,
which is where the smp kernel normally wants to see them.

Signed-off-by: Richard Henderson <rth@twiddle.net>
2016-11-22 16:53:53 +01:00
Eric Blake 3482b9bc41 block: Pass unaligned discard requests to drivers
Discard is advisory, so rounding the requests to alignment
boundaries is never semantically wrong from the data that
the guest sees.  But at least the Dell Equallogic iSCSI SANs
has an interesting property that its advertised discard
alignment is 15M, yet documents that discarding a sequence
of 1M slices will eventually result in the 15M page being
marked as discarded, and it is possible to observe which
pages have been discarded.

Between commits 9f1963b and b8d0a980, we converted the block
layer to a byte-based interface that ultimately ignores any
unaligned head or tail based on the driver's advertised
discard granularity, which means that qemu 2.7 refuses to
pass any discard request smaller than 15M down to the Dell
Equallogic hardware.  This is a slight regression in behavior
compared to earlier qemu, where a guest executing discards
in power-of-2 chunks used to be able to get every page
discarded, but is now left with various pages still allocated
because the guest requests did not align with the hardware's
15M pages.

Since the SCSI specification says nothing about a minimum
discard granularity, and only documents the preferred
alignment, it is best if the block layer gives the driver
every bit of information about discard requests, rather than
rounding it to alignment boundaries early.

Rework the block layer discard algorithm to mirror the write
zero algorithm: always peel off any unaligned head or tail
and manage that in isolation, then do the bulk of the request
on an aligned boundary.  The fallback when the driver returns
-ENOTSUP for an unaligned request is to silently ignore that
portion of the discard request; but for devices that can pass
the partial request all the way down to hardware, this can
result in the hardware coalescing requests and discarding
aligned pages after all.

Reported by: Peter Lieven <pl@kamp.de>
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2016-11-22 15:59:23 +01:00
Eric Blake 49228d1e95 block: Return -ENOTSUP rather than assert on unaligned discards
Right now, the block layer rounds discard requests, so that
individual drivers are able to assert that discard requests
will never be unaligned.  But there are some ISCSI devices
that track and coalesce multiple unaligned requests, turning it
into an actual discard if the requests eventually cover an
entire page, which implies that it is better to always pass
discard requests as low down the stack as possible.

In isolation, this patch has no semantic effect, since the
block layer currently never passes an unaligned request through.
But the block layer already has code that silently ignores
drivers that return -ENOTSUP for a discard request that cannot
be honored (as well as drivers that return 0 even when nothing
was done).  But the next patch will update the block layer to
fragment discard requests, so that clients are guaranteed that
they are either dealing with an unaligned head or tail, or an
aligned core, making it similar to the block layer semantics of
write zero fragmentation.

CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2016-11-22 15:59:22 +01:00
Eric Blake b2f95feec5 block: Let write zeroes fallback work even with small max_transfer
Commit 443668ca rewrote the write_zeroes logic to guarantee that
an unaligned request never crosses a cluster boundary.  But
in the rewrite, the new code assumed that at most one iteration
would be needed to get to an alignment boundary.

However, it is easy to trigger an assertion failure: the Linux
kernel limits loopback devices to advertise a max_transfer of
only 64k.  Any operation that requires falling back to writes
rather than more efficient zeroing must obey max_transfer during
that fallback, which means an unaligned head may require multiple
iterations of the write fallbacks before reaching the aligned
boundaries, when layering a format with clusters larger than 64k
atop the protocol of file access to a loopback device.

Test case:

$ qemu-img create -f qcow2 -o cluster_size=1M file 10M
$ losetup /dev/loop2 /path/to/file
$ qemu-io -f qcow2 /dev/loop2
qemu-io> w 7m 1k
qemu-io> w -z 8003584 2093056

In fairness to Denis (as the original listed author of the culprit
commit), the faulty logic for at most one iteration is probably all
my fault in reworking his idea.  But the solution is to restore what
was in place prior to that commit: when dealing with an unaligned
head or tail, iterate as many times as necessary while fragmenting
the operation at max_transfer boundaries.

Reported-by: Ed Swierk <eswierk@skyportsystems.com>
CC: qemu-stable@nongnu.org
CC: Denis V. Lunev <den@openvz.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2016-11-22 15:59:22 +01:00