1. 03 11月, 2016 1 次提交
    • F
      iothread: Stop threads before main() quits · 316c2c94
      Fam Zheng 提交于
      Right after main_loop ends, we release various things but keep iothread
      alive. The latter is not prepared to the sudden change of resources.
      
      Specifically, after bdrv_close_all(), virtio-scsi dataplane get a
      surprise at the empty BlockBackend:
      
      (gdb) bt
          at /usr/src/debug/qemu-2.6.0/hw/scsi/virtio-scsi.c:543
          at /usr/src/debug/qemu-2.6.0/hw/scsi/virtio-scsi.c:577
      
      It is because the d->conf.blk->root is set to NULL, then
      blk_get_aio_context() returns qemu_aio_context, whereas s->ctx is still
      pointing to the iothread:
      
          hw/scsi/virtio-scsi.c:543:
      
          if (s->dataplane_started) {
              assert(blk_get_aio_context(d->conf.blk) == s->ctx);
          }
      
      To fix this, let's stop iothreads before doing bdrv_close_all().
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1473326931-9699-1-git-send-email-famz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      (cherry picked from commit dce8921b)
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      316c2c94
  2. 05 2月, 2016 1 次提交
    • P
      all: Clean up includes · d38ea87a
      Peter Maydell 提交于
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  3. 03 12月, 2015 1 次提交
  4. 24 7月, 2015 1 次提交
  5. 20 6月, 2015 1 次提交
  6. 12 6月, 2015 1 次提交
  7. 08 5月, 2015 1 次提交
  8. 28 4月, 2015 1 次提交
  9. 22 9月, 2014 1 次提交
    • C
      async: aio_context_new(): Handle event_notifier_init failure · 2f78e491
      Chrysostomos Nanakos 提交于
      On a system with a low limit of open files the initialization
      of the event notifier could fail and QEMU exits without printing any
      error information to the user.
      
      The problem can be easily reproduced by enforcing a low limit of open
      files and start QEMU with enough I/O threads to hit this limit.
      
      The same problem raises, without the creation of I/O threads, while
      QEMU initializes the main event loop by enforcing an even lower limit of
      open files.
      
      This commit adds an error message on failure:
      
       # qemu [...] -object iothread,id=iothread0 -object iothread,id=iothread1
       qemu: Failed to initialize event notifier: Too many open files in system
      Signed-off-by: NChrysostomos Nanakos <cnanakos@grnet.gr>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      2f78e491
  10. 14 7月, 2014 1 次提交
    • P
      AioContext: do not rely on aio_poll(ctx, true) result to end a loop · acfb23ad
      Paolo Bonzini 提交于
      Currently, whenever aio_poll(ctx, true) has completed all pending
      work it returns true *and* the next call to aio_poll(ctx, true)
      will not block.
      
      This invariant has its roots in qemu_aio_flush()'s implementation
      as "while (qemu_aio_wait()) {}".  However, qemu_aio_flush() does
      not exist anymore and bdrv_drain_all() is implemented differently;
      and this invariant is complicated to maintain and subtly different
      from the return value of GMainLoop's g_main_context_iteration.
      
      All calls to aio_poll(ctx, true) except one are guarded by a
      while() loop checking for a request to be incomplete, or a
      BlockDriverState to be idle.  The one remaining call (in
      iothread.c) uses this to delay the aio_context_release/acquire
      pair until the AioContext is quiescent, however:
      
      - we can do the same just by using non-blocking aio_poll,
        similar to how vl.c invokes main_loop_wait
      
      - it is buggy, because it does not ensure that the AioContext
        is released between an aio_notify and the next time the
        iothread goes to sleep.  This leads to hangs when stopping
        the dataplane thread.
      
      In the end, these semantics are a bad match for the current
      users of AioContext.  So modify that one exception in iothread.c,
      which also fixes the hangs, as well as the testcase so that
      it use the same idiom as the actual QEMU code.
      Reported-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Tested-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      acfb23ad
  11. 05 4月, 2014 1 次提交
  12. 13 3月, 2014 3 次提交
    • S
      qmp: add query-iothreads command · dc3dd0d2
      Stefan Hajnoczi 提交于
      The "query-iothreads" command returns a list of information about
      iothreads.  See the patch for API documentation.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      dc3dd0d2
    • S
      iothread: stash thread ID away · 88eb7c29
      Stefan Hajnoczi 提交于
      Keep the thread ID around so we can report it via QMP.
      
      There's only one problem: qemu_get_thread_id() (gettid() wrapper on
      Linux) must be called from the thread itself.  There is no way to get
      the thread ID outside the thread.
      
      This patch uses a condvar to wait for iothread_run() to populate the
      thread_id inside the thread.
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      88eb7c29
    • S
      iothread: add I/O thread object · be8d8537
      Stefan Hajnoczi 提交于
      This is a stand-in for Michael Roth's QContext.  I expect this to be
      replaced once QContext is completed.
      
      The IOThread object is an AioContext event loop thread.  This patch adds
      the concept of multiple event loop threads, allowing users to define
      them.
      
      When SMP guests run on SMP hosts it makes sense to instantiate multiple
      IOThreads.  This spreads event loop processing across multiple cores.
      Note that additional patches are required to actually bind a device to
      an IOThread.
      
      [Andreas Färber <afaerber@suse.de> pointed out that the embedded parent
      object instance should be called "parent_obj" and have a newline
      afterwards.  This patch has been changed to reflect this.
      -- Stefan]
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      be8d8537