1. 04 Jun, 2013 4 commits
    • Wenchao Xia's avatar
      block: move qmp and info dump related code to block/qapi.c · f364ec65
      Wenchao Xia authored
      
      
      This patch is a pure code move patch, except following modification:
      1 get_human_readable_size() is changed to static function.
      2 dump_human_image_info() is renamed to bdrv_image_info_dump().
      3 in qmp_query_block() and qmp_query_blockstats, use bdrv_next(bs)
      instead of direct traverse of global array 'bdrv_states'.
      4 collect_snapshots() and collect_image_info() are renamed, unused parameter
      *fmt in collect_image_info() is removed.
      5 code style fix.
      
      To avoid conflict and tip better, macro in header file is BLOCK_QAPI_H
      instead of QAPI_H. Now block.h and snapshot.h are at the same level in
      include path, block_int.h and qapi.h will both include them.
      Signed-off-by: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      f364ec65
    • Wenchao Xia's avatar
      block: move snapshot code in block.c to block/snapshot.c · de08c606
      Wenchao Xia authored
      
      
      All snapshot related code, except bdrv_snapshot_dump() and
      bdrv_is_snapshot(), is moved to block/snapshot.c. bdrv_snapshot_dump()
      will be moved to another file later. bdrv_is_snapshot() is not related
      with internal snapshot. It also fixes small code style errors reported
      by check script.
      Signed-off-by: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      de08c606
    • Stefan Hajnoczi's avatar
      block: drop bs_snapshots global variable · 29d78271
      Stefan Hajnoczi authored
      
      
      The bs_snapshots global variable points to the BlockDriverState which
      will be used to save vmstate.  This is really a savevm.c concept but was
      moved into block.c:bdrv_snapshots() when it became clear that hotplug
      could result in a dangling pointer.
      
      While auditing the block layer's global state I came upon bs_snapshots
      and realized that a variable is not necessary here.  Simply find the
      first BlockDriverState capable of internal snapshots each time this is
      needed.
      
      The behavior of bdrv_snapshots() is preserved across hotplug because new
      drives are always appended to the bdrv_states list.  This means that
      calling the new find_vmstate_bs() function is idempotent - it returns
      the same BlockDriverState unless it was hot-unplugged.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: default avatarWenchao Xia <xiawenc@linux.vnet.ibm.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      29d78271
    • Fam Zheng's avatar
      block: add block driver read only whitelist · b64ec4e4
      Fam Zheng authored
      
      
      We may want to include a driver in the whitelist for read only tasks
      such as diagnosing or exporting guest data (with libguestfs as a good
      example). This patch introduces a readonly whitelist option, and for
      backward compatibility, the old configure option --block-drv-whitelist
      is now an alias to rw whitelist.
      
      Drivers in readonly list is only permitted to open file readonly, and
      returns -ENOTSUP for RW opening.
      
      E.g. To include vmdk readonly, and others read+write:
          ./configure --target-list=x86_64-softmmu \
                      --block-drv-rw-whitelist=qcow2,raw,file,qed \
                      --block-drv-ro-whitelist=vmdk
      Signed-off-by: default avatarFam Zheng <famz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      b64ec4e4
  2. 24 May, 2013 1 commit
    • Stefan Hajnoczi's avatar
      coroutine: stop using AioContext in CoQueue · 02ffb504
      Stefan Hajnoczi authored
      
      
      qemu_co_queue_next(&queue) arranges that the next queued coroutine is
      run at a later point in time.  This deferred restart is useful because
      the caller may not want to transfer control yet.
      
      This behavior was implemented using QEMUBH in the past, which meant that
      CoQueue (and hence CoMutex and CoRwlock) had a dependency on the
      AioContext event loop.  This hidden dependency causes trouble when we
      move to a world with multiple event loops - now qemu_co_queue_next()
      needs to know which event loop to schedule the QEMUBH in.
      
      After pondering how to stash AioContext I realized the best solution is
      to not use AioContext at all.  This patch implements the deferred
      restart behavior purely in terms of coroutines and no longer uses
      QEMUBH.
      
      Here is how it works:
      
      Each Coroutine has a wakeup queue that starts out empty.  When
      qemu_co_queue_next() is called, the next coroutine is added to our
      wakeup queue.  The wakeup queue is processed when we yield or terminate.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      02ffb504
  3. 03 May, 2013 1 commit
    • Stefan Hajnoczi's avatar
      nbd: support large NBD requests · 2d821488
      Stefan Hajnoczi authored
      
      
      The Linux nbd driver recently increased the maximum supported request
      size up to 32 MB:
      
        commit 078be02b80359a541928c899c2631f39628f56df
        Author: Michal Belczyk <belczyk@bsd.krakow.pl>
        Date:   Tue Apr 30 15:28:28 2013 -0700
      
            nbd: increase default and max request sizes
      
            Raise the default max request size for nbd to 128KB (from 127KB) to get it
            4KB aligned.  This patch also allows the max request size to be increased
            (via /sys/block/nbd<x>/queue/max_sectors_kb) to 32MB.
      
      QEMU's 1 MB buffers are too small to handle these requests.
      
      This patch allocates data buffers dynamically and allows up to 32 MB per
      request.
      Reported-by: default avatarNick Thomas <nick@bytemark.co.uk>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      2d821488
  4. 22 Apr, 2013 2 commits
  5. 15 Apr, 2013 2 commits
  6. 13 Apr, 2013 1 commit
  7. 08 Apr, 2013 1 commit
    • Paolo Bonzini's avatar
      hw: move headers to include/ · 0d09e41a
      Paolo Bonzini authored
      
      
      Many of these should be cleaned up with proper qdev-/QOM-ification.
      Right now there are many catch-all headers in include/hw/ARCH depending
      on cpu.h, and this makes it necessary to compile these files per-target.
      However, fixing this does not belong in these patches.
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0d09e41a
  8. 05 Apr, 2013 2 commits
  9. 22 Mar, 2013 5 commits
  10. 15 Mar, 2013 7 commits
    • Stefan Hajnoczi's avatar
      coroutine: use AioContext for CoQueue BH · 28f08246
      Stefan Hajnoczi authored
      
      
      CoQueue uses a BH to awake coroutines that were made ready to run again
      using qemu_co_queue_next() or qemu_co_queue_restart_all().  The BH
      currently runs in the iothread AioContext and would break coroutines
      that run in a different AioContext.
      
      This is a slightly tricky problem because the lifetime of the BH exceeds
      that of the CoQueue.  This means coroutines can be awoken after CoQueue
      itself has been freed.  Also, there is no qemu_co_queue_destroy()
      function which we could use to handle freeing resources.
      
      Introducing qemu_co_queue_destroy() has a ripple effect of requiring us
      to also add qemu_co_mutex_destroy() and qemu_co_rwlock_destroy(), as
      well as updating all callers.  Avoid doing that.
      
      We also cannot switch from BH to GIdle function because aio_poll() does
      not dispatch GIdle functions.  (GIdle functions make memory management
      slightly easier because they free themselves.)
      
      Finally, I don't want to move unlock_queue and unlock_bh into
      AioContext.  That would break encapsulation - AioContext isn't supposed
      to know about CoQueue.
      
      This patch implements a different solution: each qemu_co_queue_next() or
      qemu_co_queue_restart_all() call creates a new BH and list of coroutines
      to wake up.  Callers tend to invoke qemu_co_queue_next() and
      qemu_co_queue_restart_all() occasionally after blocking I/O, so creating
      a new BH for each call shouldn't be massively inefficient.
      
      Note that this patch does not add an interface for specifying the
      AioContext.  That is left to future patches which will convert CoQueue,
      CoMutex, and CoRwlock to expose AioContext.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      28f08246
    • Stefan Hajnoczi's avatar
      threadpool: drop global thread pool · c4d9d196
      Stefan Hajnoczi authored
      
      
      Now that each AioContext has a ThreadPool and the main loop AioContext
      can be fetched with bdrv_get_aio_context(), we can eliminate the concept
      of a global thread pool from thread-pool.c.
      
      The submit functions must take a ThreadPool* argument.
      
      block/raw-posix.c and block/raw-win32.c use
      aio_get_thread_pool(bdrv_get_aio_context(bs)) to fetch the main loop's
      ThreadPool.
      
      tests/test-thread-pool.c must be updated to reflect the new
      thread_pool_submit() function prototypes.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c4d9d196
    • Stefan Hajnoczi's avatar
      block: add bdrv_get_aio_context() · 85d126f3
      Stefan Hajnoczi authored
      
      
      For now bdrv_get_aio_context() is just a stub that calls
      qemu_aio_get_context() since the block layer is currently tied to the
      main loop AioContext.
      
      Add the stub now so that the block layer can begin accessing its
      AioContext.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      85d126f3
    • Stefan Hajnoczi's avatar
      aio: add a ThreadPool instance to AioContext · 9b34277d
      Stefan Hajnoczi authored
      
      
      This patch adds a ThreadPool to AioContext.  It's possible that some
      AioContext instances will never use the ThreadPool, so defer creation
      until aio_get_thread_pool().
      
      The reason why AioContext should have the ThreadPool is because the
      ThreadPool is bound to a AioContext instance where the work item's
      callback function is invoked.  It doesn't make sense to keep the
      ThreadPool pointer anywhere other than AioContext.  For example,
      block/raw-posix.c can get its AioContext's ThreadPool and submit work.
      
      Special note about headers: I used struct ThreadPool in aio.h because
      there is a circular dependency if aio.h includes thread-pool.h.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9b34277d
    • Stefan Hajnoczi's avatar
      threadpool: add thread_pool_new() and thread_pool_free() · f7311ccc
      Stefan Hajnoczi authored
      
      
      ThreadPool is tied to an AioContext through its event notifier, which
      dictates in which AioContext the work item's callback function will be
      invoked.
      
      In order to support multiple AioContexts we need to support multiple
      ThreadPool instances.
      
      This patch adds the new/free functions.  The free function deserves
      special attention because it quiesces remaining worker threads.  This
      requires a new condition variable and a "stopping" flag to let workers
      know they should terminate once idle.
      
      We never needed to do this before since the global threadpool was not
      explicitly destroyed until process termination.
      
      Also stash the AioContext pointer in ThreadPool so that we can call
      aio_set_event_notifier() in thread_pool_free().  We didn't need to hold
      onto AioContext previously since there was no free function.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f7311ccc
    • Kevin Wolf's avatar
      block: Add options QDict to bdrv_open() prototype · de9c0cec
      Kevin Wolf authored
      
      
      It doesn't do anything yet except storing the options QDict in the
      BlockDriverState.
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      de9c0cec
    • Kevin Wolf's avatar
      1a86938f
  11. 22 Feb, 2013 5 commits
  12. 21 Feb, 2013 1 commit
  13. 01 Feb, 2013 1 commit
  14. 25 Jan, 2013 5 commits
  15. 17 Jan, 2013 1 commit
    • Kevin Wolf's avatar
      aio: Fix return value of aio_poll() · 2ea9b58f
      Kevin Wolf authored
      
      
      aio_poll() must return true if any work is still pending, even if it
      didn't make progress, so that bdrv_drain_all() doesn't stop waiting too
      early. The possibility of stopping early occasionally lead to a failed
      assertion in bdrv_drain_all(), when some in-flight request was missed
      and the function didn't really drain all requests.
      
      In order to make that change, the return value as specified in the
      function comment must change for blocking = false; fortunately, the
      return value of blocking = false callers is only used in test cases, so
      this change shouldn't cause any trouble.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      2ea9b58f
  16. 14 Jan, 2013 1 commit