qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 78f1d3: coroutine: simplify co_aio_sleep_ns()


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 78f1d3: coroutine: simplify co_aio_sleep_ns() prototype
Date: Wed, 20 Dec 2017 05:20:08 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 78f1d3d6a6904459b0b6cfd735278e4e2b7b68c5
      
https://github.com/qemu/qemu/commit/78f1d3d6a6904459b0b6cfd735278e4e2b7b68c5
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M block/null.c
    M block/sheepdog.c
    M include/qemu/coroutine.h
    M util/qemu-coroutine-sleep.c

  Log Message:
  -----------
  coroutine: simplify co_aio_sleep_ns() prototype

The AioContext pointer argument to co_aio_sleep_ns() is only used for
the sleep timer.  It does not affect where the caller coroutine is
resumed.

Due to changes to coroutine and AIO APIs it is now possible to drop the
AioContext pointer argument.  This is safe to do since no caller has
specific requirements for which AioContext the timer must run in.

This patch drops the AioContext pointer argument and renames the
function to simplify the API.

Reported-by: Paolo Bonzini <address@hidden>
Reported-by: Eric Blake <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: e01d6a415bec6fb93a7413929fb1438a22d28419
      
https://github.com/qemu/qemu/commit/e01d6a415bec6fb93a7413929fb1438a22d28419
  Author: Mao Zhongyi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M hw/block/nvme.c

  Log Message:
  -----------
  hw/block/nvme: Convert to realize

Convert nvme_init() to realize and rename it to nvme_realize().

Cc: John Snow <address@hidden>
Cc: Keith Busch <address@hidden>
Cc: Kevin Wolf <address@hidden>
Cc: Max Reitz <address@hidden>
Cc: Markus Armbruster <address@hidden>

Signed-off-by: Mao Zhongyi <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 9d3b155186c2788570f4802700d030c84e0f0746
      
https://github.com/qemu/qemu/commit/9d3b155186c2788570f4802700d030c84e0f0746
  Author: Mao Zhongyi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M hw/block/block.c
    M hw/block/dataplane/virtio-blk.c
    M hw/block/dataplane/virtio-blk.h
    M include/hw/block/block.h

  Log Message:
  -----------
  hw/block: Fix the return type

When the function no success value to transmit, it usually make the
function return void. It has turned out not to be a success, because
it means that the extra local_err variable and error_propagate() will
be needed. It leads to cumbersome code, therefore, transmit success/
failure in the return value is worth.

So fix the return type of blkconf_apply_backend_options(),
blkconf_geometry() and virtio_blk_data_plane_create() to avoid it.

Cc: John Snow <address@hidden>
Cc: Kevin Wolf <address@hidden>
Cc: Max Reitz <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>

Signed-off-by: Mao Zhongyi <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: ceff3e1f01ee8c0d77de7e3750e7297c3af7e2ec
      
https://github.com/qemu/qemu/commit/ceff3e1f01ee8c0d77de7e3750e7297c3af7e2ec
  Author: Mao Zhongyi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M hw/block/fdc.c
    M hw/block/nvme.c
    M hw/block/virtio-blk.c
    M hw/ide/qdev.c
    M hw/scsi/scsi-disk.c
    M hw/usb/dev-storage.c

  Log Message:
  -----------
  hw/block: Use errp directly rather than local_err

[Drop virtio_blk_data_plane_create() change that misinterprets return
value when the virtio transport does not support dataplane.
--Stefan]

Cc: John Snow <address@hidden>
Cc: Kevin Wolf <address@hidden>
Cc: Max Reitz <address@hidden>
Cc: Keith Busch <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>
Cc: "Michael S. Tsirkin" <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: Gerd Hoffmann <address@hidden>
Cc: Markus Armbruster <address@hidden>

Signed-off-by: Mao Zhongyi <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 6db3ea39e2650dc4fbcd18e075510f162265512f
      
https://github.com/qemu/qemu/commit/6db3ea39e2650dc4fbcd18e075510f162265512f
  Author: Mao Zhongyi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M hw/usb/dev-storage.c

  Log Message:
  -----------
  dev-storage: Fix the unusual function name

The function name of usb_msd_{realize,unrealize}_*,
usb_msd_class_initfn_* are unusual. Rename it to
usb_msd_*_{realize,unrealize}, usb_msd_class_*_initfn.

Cc: Gerd Hoffmann <address@hidden>

Signed-off-by: Mao Zhongyi <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: a12aef24fa3e3312fac024ac22809ee9deb4d98a
      
https://github.com/qemu/qemu/commit/a12aef24fa3e3312fac024ac22809ee9deb4d98a
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M hw/core/qdev-properties-system.c

  Log Message:
  -----------
  qdev: drop unused #include "sysemu/iothread.h"

Commit 1351d1ec89eabebc9fdff20451a62c413d7accc1 ("qdev: drop iothread
property type") forgot to remove this include.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: b9464ba19f821ea6b29969104dc48dcdb26243dd
      
https://github.com/qemu/qemu/commit/b9464ba19f821ea6b29969104dc48dcdb26243dd
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M blockdev.c

  Log Message:
  -----------
  blockdev: hold AioContext for bdrv_unref() in external_snapshot_clean()

bdrv_unref() requires the AioContext lock because bdrv_flush() uses
BDRV_POLL_WHILE(), which assumes the AioContext is currently held.  If
BDRV_POLL_WHILE() runs without AioContext held the
pthread_mutex_unlock() call in aio_context_release() fails.

This patch moves bdrv_unref() into the AioContext locked region to solve
the following pthread_mutex_unlock() failure:

  #0  0x00007f566181969b in raise () at /lib64/libc.so.6
  #1  0x00007f566181b3b1 in abort () at /lib64/libc.so.6
  #2  0x00005592cd590458 in error_exit (err=<optimized out>, address@hidden 
<__func__.23977> "qemu_mutex_unlock") at util/qemu-thread-posix.c:36
  #3  0x00005592cd96e738 in qemu_mutex_unlock (address@hidden) at 
util/qemu-thread-posix.c:96
  #4  0x00005592cd969b69 in aio_context_release (address@hidden) at 
util/async.c:507
  #5  0x00005592cd8ead78 in bdrv_flush (address@hidden) at block/io.c:2478
  #6  0x00005592cd89df30 in bdrv_close (bs=0x5592cfa87210) at block.c:3207
  #7  0x00005592cd89df30 in bdrv_delete (bs=0x5592cfa87210) at block.c:3395
  #8  0x00005592cd89df30 in bdrv_unref (bs=0x5592cfa87210) at block.c:4418
  #9  0x00005592cd6b7f86 in qmp_transaction (dev_list=<optimized out>, 
has_props=<optimized out>, props=<optimized out>, address@hidden) at 
blockdev.c:2308

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 2d24b60b7747f7bf40fd00b0375b6bd988d4f0d9
      
https://github.com/qemu/qemu/commit/2d24b60b7747f7bf40fd00b0375b6bd988d4f0d9
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M blockdev.c

  Log Message:
  -----------
  block: don't keep AioContext acquired after external_snapshot_prepare()

It is not necessary to hold AioContext across transactions anymore since
bdrv_drained_begin/end() is used to keep the nodes quiesced.  In fact,
using the AioContext lock for this purpose was always buggy.

This patch reduces the scope of AioContext locked regions.  This is not
just a cleanup but also fixes hangs that occur in BDRV_POLL_WHILE()
because it is unware of recursive locking and does not release the
AioContext the necessary number of times to allow progress to be made.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 66d56054bca3c1c45861d18ea97f147f7d376d21
      
https://github.com/qemu/qemu/commit/66d56054bca3c1c45861d18ea97f147f7d376d21
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M blockdev.c

  Log Message:
  -----------
  block: don't keep AioContext acquired after drive_backup_prepare()

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: edd5adeecddf665e7954bc146ff458bb30f178ae
      
https://github.com/qemu/qemu/commit/edd5adeecddf665e7954bc146ff458bb30f178ae
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M blockdev.c

  Log Message:
  -----------
  block: don't keep AioContext acquired after blockdev_backup_prepare()

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: a36e458cdda0196911c1cbe7cfe6f9530f2280e3
      
https://github.com/qemu/qemu/commit/a36e458cdda0196911c1cbe7cfe6f9530f2280e3
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M blockdev.c

  Log Message:
  -----------
  block: don't keep AioContext acquired after internal_snapshot_prepare()

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 5016f21b705152d138395f90219b665ddce89c1b
      
https://github.com/qemu/qemu/commit/5016f21b705152d138395f90219b665ddce89c1b
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M blockdev.c

  Log Message:
  -----------
  block: drop unused BlockDirtyBitmapState->aio_context field

The dirty bitmap actions in qmp_transaction have not used AioContext
since the dirty bitmap locking discipline was introduced in commit
2119882c7eb7e2c612b24fc0c8d86f5887d6f1c3 ("block: introduce
dirty_bitmap_mutex").  Remove the unused field.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: fbcc6923b00c2b468a7470fec7863f0403a65736
      
https://github.com/qemu/qemu/commit/fbcc6923b00c2b468a7470fec7863f0403a65736
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M include/sysemu/iothread.h
    M iothread.c

  Log Message:
  -----------
  iothread: add iothread_by_id() API

Encapsulate IOThread QOM object lookup so that callers don't need to
know how and where IOThread objects live.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: ca00bbb153d03c5338d8c8136812163f463f841e
      
https://github.com/qemu/qemu/commit/ca00bbb153d03c5338d8c8136812163f463f841e
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M blockdev.c
    M qapi/block-core.json

  Log Message:
  -----------
  blockdev: add x-blockdev-set-iothread testing command

Currently there is no easy way for iotests to ensure that a BDS is bound
to a particular IOThread.  Normally the virtio-blk device calls
blk_set_aio_context() when dataplane is enabled during guest driver
initialization.  This never happens in iotests since -machine
accel=qtest means there is no guest activity (including device driver
initialization).

This patch adds a QMP command to explicitly assign IOThreads in test
cases.  See qapi/block-core.json for a description of the command.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 6dd64919ea36db9fd7e754ed394c25ced45ea39a
      
https://github.com/qemu/qemu/commit/6dd64919ea36db9fd7e754ed394c25ced45ea39a
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    A tests/qemu-iotests/202
    A tests/qemu-iotests/202.out
    M tests/qemu-iotests/group

  Log Message:
  -----------
  qemu-iotests: add 202 external snapshots IOThread test

QMP 'transaction' blockdev-snapshot-sync with multiple disks in an
IOThread is an untested code path.  Several bugs have been found in
connection with this command.  This patch adds a test case to prevent
future regressions.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 6040aedddb5f474a9c2304b6a432a652d82b3d3c
      
https://github.com/qemu/qemu/commit/6040aedddb5f474a9c2304b6a432a652d82b3d3c
  Author: Mark Kanda <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M hw/block/virtio-blk.c
    M include/hw/virtio/virtio-blk.h

  Log Message:
  -----------
  virtio-blk: make queue size configurable

Depending on the configuration, it can be beneficial to adjust the virtio-blk
queue size to something other than the current default of 128. Add a new
property to make the queue size configurable.

Signed-off-by: Mark Kanda <address@hidden>
Reviewed-by: Karl Heubaum <address@hidden>
Reviewed-by: Martin K. Petersen <address@hidden>
Reviewed-by: Ameya More <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 0a75b60cdb685fed09ac0c0783bc0d6052a00e5d
      
https://github.com/qemu/qemu/commit/0a75b60cdb685fed09ac0c0783bc0d6052a00e5d
  Author: Mark Kanda <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M hw/block/virtio-blk.c

  Log Message:
  -----------
  virtio-blk: reject configs with logical block size > physical block size

virtio-blk logical block size should never be larger than physical block
size because it doesn't make sense to have such configurations. QEMU doesn't
have a way to effectively express this condition; the best it can do is
report the physical block exponent as 0 - indicating the logical block size
equals the physical block size.

This is identical to commit 3da023b5827543ee4c022986ea2ad9d1274410b2
but applied to virtio-blk (instead of virtio-scsi).

Signed-off-by: Mark Kanda <address@hidden>
Reviewed-by: Konrad Rzeszutek Wilk <address@hidden>
Reviewed-by: Ameya More <address@hidden>
Reviewed-by: Martin K. Petersen <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: bd6458e410c1e7d2912357aeb399fe7d8ee9f9a3
      
https://github.com/qemu/qemu/commit/bd6458e410c1e7d2912357aeb399fe7d8ee9f9a3
  Author: Paolo Bonzini <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M block.c

  Log Message:
  -----------
  block: avoid recursive AioContext acquire in bdrv_inactivate_all()

BDRV_POLL_WHILE() does not support recursive AioContext locking.  It
only releases the AioContext lock once regardless of how many times the
caller has acquired it.  This results in a hang since the IOThread does
not make progress while the AioContext is still locked.

The following steps trigger the hang:

  $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \
                 -object iothread,id=iothread0 \
                 -device virtio-scsi-pci,iothread=iothread0 \
                 -drive if=none,id=drive0,file=test.img,format=raw \
                 -device scsi-hd,drive=drive0 \
                 -drive if=none,id=drive1,file=test.img,format=raw \
                 -device scsi-hd,drive=drive1
  $ qemu-system-x86_64 ...same options... \
                 -incoming tcp::1234
  (qemu) migrate tcp:127.0.0.1:1234
  ...hang...

Tested-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: d02d8dde0c0fe3d77a31046e104a55f2e6c50bf6
      
https://github.com/qemu/qemu/commit/d02d8dde0c0fe3d77a31046e104a55f2e6c50bf6
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M docs/devel/multiple-iothreads.txt

  Log Message:
  -----------
  docs: mark nested AioContext locking as a legacy API

See the patch for why nested AioContext locking is no longer allowed.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 882e9b89af7c1086d97cee11b2437337e756fa00
      
https://github.com/qemu/qemu/commit/882e9b89af7c1086d97cee11b2437337e756fa00
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M blockdev.c
    M qapi/block-core.json

  Log Message:
  -----------
  blockdev: add x-blockdev-set-iothread force boolean

When a node is already associated with a BlockBackend the
x-blockdev-set-iothread command refuses to set the IOThread.  This is to
prevent accidentally changing the IOThread when the nodes are in use.

When the nodes are created with -drive they automatically get a
BlockBackend.  In that case we know nothing is using them yet and it's
safe to set the IOThread.  Add a force boolean to override the check.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: ccc15f7dafff63cbcc3f6a7c51e380025d67f7f4
      
https://github.com/qemu/qemu/commit/ccc15f7dafff63cbcc3f6a7c51e380025d67f7f4
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M tests/qemu-iotests/iotests.py

  Log Message:
  -----------
  iotests: add VM.add_object()

The VM.add_object() method can be used to add IOThreads or memory
backend objects.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 2362a28ea11c145e1a13ae79342d76dc118a72a6
      
https://github.com/qemu/qemu/commit/2362a28ea11c145e1a13ae79342d76dc118a72a6
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    M include/sysemu/iothread.h
    M iothread.c

  Log Message:
  -----------
  iothread: fix iothread_stop() race condition

There is a small chance that iothread_stop() hangs as follows:

  Thread 3 (Thread 0x7f63eba5f700 (LWP 16105)):
  #0  0x00007f64012c09b6 in ppoll () at /lib64/libc.so.6
  #1  0x000055959992eac9 in ppoll (__ss=0x0, __timeout=0x0, __nfds=<optimized 
out>, __fds=<optimized out>) at /usr/include/bits/poll2.h:77
  #2  0x000055959992eac9 in qemu_poll_ns (fds=<optimized out>, nfds=<optimized 
out>, timeout=<optimized out>) at util/qemu-timer.c:322
  #3  0x0000559599930711 in aio_poll (ctx=0x55959bdb83c0, address@hidden) at 
util/aio-posix.c:629
  #4  0x00005595996806fe in iothread_run (opaque=0x55959bd78400) at 
iothread.c:59
  #5  0x00007f640159f609 in start_thread () at /lib64/libpthread.so.0
  #6  0x00007f64012cce6f in clone () at /lib64/libc.so.6

  Thread 1 (Thread 0x7f640b45b280 (LWP 16103)):
  #0  0x00007f64015a0b6d in pthread_join () at /lib64/libpthread.so.0
  #1  0x00005595999332ef in qemu_thread_join (thread=<optimized out>) at 
util/qemu-thread-posix.c:547
  #2  0x00005595996808ae in iothread_stop (iothread=<optimized out>) at 
iothread.c:91
  #3  0x000055959968094d in iothread_stop_iter (object=<optimized out>, 
opaque=<optimized out>) at iothread.c:102
  #4  0x0000559599857d97 in do_object_child_foreach (address@hidden, 
address@hidden <iothread_stop_iter>, address@hidden, address@hidden) at 
qom/object.c:852
  #5  0x0000559599859477 in object_child_foreach (address@hidden, 
address@hidden <iothread_stop_iter>, address@hidden) at qom/object.c:867
  #6  0x0000559599680a6e in iothread_stop_all () at iothread.c:341
  #7  0x000055959955b1d5 in main (argc=<optimized out>, argv=<optimized out>, 
envp=<optimized out>) at vl.c:4913

The relevant code from iothread_run() is:

  while (!atomic_read(&iothread->stopping)) {
      aio_poll(iothread->ctx, true);

and iothread_stop():

  iothread->stopping = true;
  aio_notify(iothread->ctx);
  ...
  qemu_thread_join(&iothread->thread);

The following scenario can occur:

1. IOThread:
  while (!atomic_read(&iothread->stopping)) -> stopping=false

2. Main loop:
  iothread->stopping = true;
  aio_notify(iothread->ctx);

3. IOThread:
  aio_poll(iothread->ctx, true); -> hang

The bug is explained by the AioContext->notify_me doc comments:

  "If this field is 0, everything (file descriptors, bottom halves,
  timers) will be re-evaluated before the next blocking poll(), thus the
  event_notifier_set call can be skipped."

The problem is that "everything" does not include checking
iothread->stopping.  This means iothread_run() will block in aio_poll()
if aio_notify() was called just before aio_poll().

This patch fixes the hang by replacing aio_notify() with
aio_bh_schedule_oneshot().  This makes aio_poll() or g_main_loop_run()
to return.

Implementing this properly required a new bool running flag.  The new
flag prevents races that are tricky if we try to use iothread->stopping.
Now iothread->stopping is purely for iothread_stop() and
iothread->running is purely for the iothread_run() thread.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 7a9dda0d7f9831c2432620dcfefdadbb7ae888dc
      
https://github.com/qemu/qemu/commit/7a9dda0d7f9831c2432620dcfefdadbb7ae888dc
  Author: Stefan Hajnoczi <address@hidden>
  Date:   2017-12-19 (Tue, 19 Dec 2017)

  Changed paths:
    A tests/qemu-iotests/203
    A tests/qemu-iotests/203.out
    M tests/qemu-iotests/group

  Log Message:
  -----------
  qemu-iotests: add 203 savevm with IOThreads test

This test case will prevent future regressions with savevm and
IOThreads.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: f1faf2d59c91a8f1f59a0fc6339154efb749b55d
      
https://github.com/qemu/qemu/commit/f1faf2d59c91a8f1f59a0fc6339154efb749b55d
  Author: Peter Maydell <address@hidden>
  Date:   2017-12-20 (Wed, 20 Dec 2017)

  Changed paths:
    M block.c
    M block/null.c
    M block/sheepdog.c
    M blockdev.c
    M docs/devel/multiple-iothreads.txt
    M hw/block/block.c
    M hw/block/dataplane/virtio-blk.c
    M hw/block/dataplane/virtio-blk.h
    M hw/block/fdc.c
    M hw/block/nvme.c
    M hw/block/virtio-blk.c
    M hw/core/qdev-properties-system.c
    M hw/ide/qdev.c
    M hw/scsi/scsi-disk.c
    M hw/usb/dev-storage.c
    M include/hw/block/block.h
    M include/hw/virtio/virtio-blk.h
    M include/qemu/coroutine.h
    M include/sysemu/iothread.h
    M iothread.c
    M qapi/block-core.json
    A tests/qemu-iotests/202
    A tests/qemu-iotests/202.out
    A tests/qemu-iotests/203
    A tests/qemu-iotests/203.out
    M tests/qemu-iotests/group
    M tests/qemu-iotests/iotests.py
    M util/qemu-coroutine-sleep.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into 
staging

Pull request

v2:
 * Fixed incorrect virtio_blk_data_plane_create() local_err refactoring in
   "hw/block: Use errp directly rather than local_err" that broke virtio-blk
   over virtio-mmio [Peter]

# gpg: Signature made Tue 19 Dec 2017 15:08:14 GMT
# gpg:                using RSA key 0x9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <address@hidden>"
# gpg:                 aka "Stefan Hajnoczi <address@hidden>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/block-pull-request: (23 commits)
  qemu-iotests: add 203 savevm with IOThreads test
  iothread: fix iothread_stop() race condition
  iotests: add VM.add_object()
  blockdev: add x-blockdev-set-iothread force boolean
  docs: mark nested AioContext locking as a legacy API
  block: avoid recursive AioContext acquire in bdrv_inactivate_all()
  virtio-blk: reject configs with logical block size > physical block size
  virtio-blk: make queue size configurable
  qemu-iotests: add 202 external snapshots IOThread test
  blockdev: add x-blockdev-set-iothread testing command
  iothread: add iothread_by_id() API
  block: drop unused BlockDirtyBitmapState->aio_context field
  block: don't keep AioContext acquired after internal_snapshot_prepare()
  block: don't keep AioContext acquired after blockdev_backup_prepare()
  block: don't keep AioContext acquired after drive_backup_prepare()
  block: don't keep AioContext acquired after external_snapshot_prepare()
  blockdev: hold AioContext for bdrv_unref() in external_snapshot_clean()
  qdev: drop unused #include "sysemu/iothread.h"
  dev-storage: Fix the unusual function name
  hw/block: Use errp directly rather than local_err
  ...

Signed-off-by: Peter Maydell <address@hidden>

# Conflicts:
#       hw/core/qdev-properties-system.c


Compare: https://github.com/qemu/qemu/compare/af352675efb7...f1faf2d59c91

reply via email to

[Prev in Thread] Current Thread [Next in Thread]