qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] 4afeff: blockjob: do not allow coroutine doub


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 4afeff: blockjob: do not allow coroutine double entry or e...
Date: Tue, 21 Nov 2017 09:48:36 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 4afeffc8572f40d8844b946a30c00b10da4442b1
      
https://github.com/qemu/qemu/commit/4afeffc8572f40d8844b946a30c00b10da4442b1
  Author: Jeff Cody <address@hidden>
  Date:   2017-11-21 (Tue, 21 Nov 2017)

  Changed paths:
    M blockjob.c
    M include/block/blockjob_int.h

  Log Message:
  -----------
  blockjob: do not allow coroutine double entry or entry-after-completion

When block_job_sleep_ns() is called, the co-routine is scheduled for
future execution.  If we allow the job to be re-entered prior to the
scheduled time, we present a race condition in which a coroutine can be
entered recursively, or even entered after the coroutine is deleted.

The job->busy flag is used by blockjobs when a coroutine is busy
executing. The function 'block_job_enter()' obeys the busy flag,
and will not enter a coroutine if set.  If we sleep a job, we need to
leave the busy flag set, so that subsequent calls to block_job_enter()
are prevented.

This changes the prior behavior of block_job_cancel() being able to
immediately wake up and cancel a job; in practice, this should not be an
issue, as the coroutine sleep times are generally very small, and the
cancel will occur the next time the coroutine wakes up.

This fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1508708

Signed-off-by: Jeff Cody <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>


  Commit: 6133b39f3c36623425a6ede9e89d93175fde15cd
      
https://github.com/qemu/qemu/commit/6133b39f3c36623425a6ede9e89d93175fde15cd
  Author: Jeff Cody <address@hidden>
  Date:   2017-11-21 (Tue, 21 Nov 2017)

  Changed paths:
    M include/qemu/coroutine_int.h
    M util/async.c
    M util/qemu-coroutine-sleep.c
    M util/qemu-coroutine.c

  Log Message:
  -----------
  coroutine: abort if we try to schedule or enter a pending coroutine

The previous patch fixed a race condition, in which there were
coroutines being executing doubly, or after coroutine deletion.

We can detect common scenarios when this happens, and print an error
message and abort before we corrupt memory / data, or segfault.

This patch will abort if an attempt to enter a coroutine is made while
it is currently pending execution, either in a specific AioContext bh,
or pending execution via a timer.  It will also abort if a coroutine
is scheduled, before a prior scheduled run has occurred.

We cannot rely on the existing co->caller check for recursive re-entry
to catch this, as the coroutine may run and exit with
COROUTINE_TERMINATE before the scheduled coroutine executes.

(This is the scenario that was occurring and fixed in the previous
patch).

This patch also re-orders the Coroutine struct elements in an attempt to
optimize caching.

Signed-off-by: Jeff Cody <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>


  Commit: a2339699c3d35f19253b3b9b51f8a9b8e24f90eb
      
https://github.com/qemu/qemu/commit/a2339699c3d35f19253b3b9b51f8a9b8e24f90eb
  Author: Jeff Cody <address@hidden>
  Date:   2017-11-21 (Tue, 21 Nov 2017)

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

  Log Message:
  -----------
  qemu-iotests: add option in common.qemu for mismatch only

Add option to echo response to QMP / HMP command only on mismatch.

Useful for ignore all normal responses, but catching things like
segfaults.

Signed-off-by: Jeff Cody <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>


  Commit: d975301dc8ae56fb3154348878e47a6211843c0b
      
https://github.com/qemu/qemu/commit/d975301dc8ae56fb3154348878e47a6211843c0b
  Author: Jeff Cody <address@hidden>
  Date:   2017-11-21 (Tue, 21 Nov 2017)

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

  Log Message:
  -----------
  qemu-iotest: add test for blockjob coroutine race condition

Signed-off-by: Jeff Cody <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>


  Commit: 64807cd77938885f681a9a18b5736e923ad50b7c
      
https://github.com/qemu/qemu/commit/64807cd77938885f681a9a18b5736e923ad50b7c
  Author: Peter Maydell <address@hidden>
  Date:   2017-11-21 (Tue, 21 Nov 2017)

  Changed paths:
    M blockjob.c
    M include/block/blockjob_int.h
    M include/qemu/coroutine_int.h
    A tests/qemu-iotests/200
    A tests/qemu-iotests/200.out
    M tests/qemu-iotests/common.qemu
    M tests/qemu-iotests/group
    M util/async.c
    M util/qemu-coroutine-sleep.c
    M util/qemu-coroutine.c

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

# gpg: Signature made Tue 21 Nov 2017 17:01:33 GMT
# gpg:                using RSA key 0xBDBE7B27C0DE3057
# gpg: Good signature from "Jeffrey Cody <address@hidden>"
# gpg:                 aka "Jeffrey Cody <address@hidden>"
# gpg:                 aka "Jeffrey Cody <address@hidden>"
# Primary key fingerprint: 9957 4B4D 3474 90E7 9D98  D624 BDBE 7B27 C0DE 3057

* remotes/cody/tags/block-pull-request:
  qemu-iotest: add test for blockjob coroutine race condition
  qemu-iotests: add option in common.qemu for mismatch only
  coroutine: abort if we try to schedule or enter a pending coroutine
  blockjob: do not allow coroutine double entry or entry-after-completion

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


Compare: https://github.com/qemu/qemu/compare/fc7dbc119e08...64807cd77938

reply via email to

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