1. 16 2月, 2015 3 次提交
    • M
      qemu-io: Use BlockBackend · 4c7b7e9b
      Max Reitz 提交于
      qemu-io should behave like a guest, therefore it should use BlockBackend
      to access the block layer.
      
      There are a couple of places where that is infeasible: First, the
      bdrv_debug_* functions could theoretically be mirrored in the
      BlockBackend, but since these are functions internal to the block layer,
      they should not be visible externally (qemu-io as a test tool is exempt
      from this).
      
      Second, bdrv_get_info() and bdrv_get_specific_info() work on a single
      BDS alone, therefore they should stay BDS-specific.
      
      Third, bdrv_is_allocated() mainly works on a single BDS as well. Some
      data may be passed through from the BDS's file (if sectors which are
      apparently allocated in the file are not really allocated there but just
      zero).
      
      [Fixed conflicts around block_acct_start() usage from Fam Zheng's
      "qemu-io: Account IO by aio_read and aio_write" commit.  Use
      BlockBackend and blk_get_stats() instead of BlockDriverState.
      --Stefan]
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 1423162705-32065-14-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      4c7b7e9b
    • M
      qemu-io: Remove "growable" option · 10d9d75c
      Max Reitz 提交于
      Remove "growable" option from the "open" command and from the qemu-io
      command line. qemu-io is about to be converted to BlockBackend which
      will make sure that no request exceeds the image size, so the only way
      to keep "growable" would be to use BlockBackend if it is not given and
      to directly access the BDS if it is.
      
      qemu-io is a debugging tool, therefore removing a rarely used option
      will have only a very small impact, if any. There was only one
      qemu-iotest which used the option; since it is not critical, this patch
      just removes it.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 1423162705-32065-13-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      10d9d75c
    • M
      qemu-io: Use blk_new_open() in openfile() · 1b58b438
      Max Reitz 提交于
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 1423162705-32065-12-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      1b58b438
  2. 10 12月, 2014 1 次提交
  3. 20 10月, 2014 4 次提交
    • M
      block: Make BlockBackend own its BlockDriverState · 9ba10c95
      Markus Armbruster 提交于
      On BlockBackend destruction, unref its BlockDriverState.  Replaces the
      callers' unrefs.
      
      This turns the pointer from BlockBackend to BlockDriverState into a
      strong reference, managed with bdrv_ref() / bdrv_unref().  The
      back-pointer remains weak.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      9ba10c95
    • M
      block: Connect BlockBackend to BlockDriverState · 7e7d56d9
      Markus Armbruster 提交于
      Convenience function blk_new_with_bs() creates a BlockBackend with its
      BlockDriverState.  Callers have to unref both.  The commit after next
      will relieve them of the need to unref the BlockDriverState.
      
      Complication: due to the silly way drive_del works, we need a way to
      hide a BlockBackend, just like bdrv_make_anon().  To emphasize its
      "special" status, give the function a suitably off-putting name:
      blk_hide_on_behalf_of_do_drive_del().  Unfortunately, hiding turns the
      BlockBackend's name into the empty string.  Can't avoid that without
      breaking the blk->bs->device_name equals blk->name invariant.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      7e7d56d9
    • M
      block: New BlockBackend · 26f54e9a
      Markus Armbruster 提交于
      A block device consists of a frontend device model and a backend.
      
      A block backend has a tree of block drivers doing the actual work.
      The tree is managed by the block layer.
      
      We currently use a single abstraction BlockDriverState both for tree
      nodes and the backend as a whole.  Drawbacks:
      
      * Its API includes both stuff that makes sense only at the block
        backend level (root of the tree) and stuff that's only for use
        within the block layer.  This makes the API bigger and more complex
        than necessary.  Moreover, it's not obvious which interfaces are
        meant for device models, and which really aren't.
      
      * Since device models keep a reference to their backend, the backend
        object can't just be destroyed.  But for media change, we need to
        replace the tree.  Our solution is to make the BlockDriverState
        generic, with actual driver state in a separate object, pointed to
        by member opaque.  That lets us replace the tree by deinitializing
        and reinitializing its root.  This special need of the root makes
        the data structure awkward everywhere in the tree.
      
      The general plan is to separate the APIs into "block backend", for use
      by device models, monitor and whatever other code dealing with block
      backends, and "block driver", for use by the block layer and whatever
      other code (if any) dealing with trees and tree nodes.
      
      Code dealing with block backends, device models in particular, should
      become completely oblivious of BlockDriverState.  This should let us
      clean up both APIs, and the tree data structures.
      
      This commit is a first step.  It creates a minimal "block backend"
      API: type BlockBackend and functions to create, destroy and find them.
      
      BlockBackend objects are created and destroyed exactly when root
      BlockDriverState objects are created and destroyed.  "Root" in the
      sense of "in bdrv_states".  They're not yet used for anything; that'll
      come shortly.
      
      A root BlockDriverState is created with bdrv_new_root(), so where to
      create a BlockBackend is obvious.  Where these roots get destroyed
      isn't always as obvious.
      
      It is obvious in qemu-img.c, qemu-io.c and qemu-nbd.c, and in error
      paths of blockdev_init(), blk_connect().  That leaves destruction of
      objects successfully created by blockdev_init() and blk_connect().
      
      blockdev_init() is used only by drive_new() and qmp_blockdev_add().
      Objects created by the latter are currently indestructible (see commit
      48f364dd "blockdev: Refuse to drive_del something added with
      blockdev-add" and commit 2d246f01 "blockdev: Introduce
      DriveInfo.enable_auto_del").  Objects created by the former get
      destroyed by drive_del().
      
      Objects created by blk_connect() get destroyed by blk_disconnect().
      
      BlockBackend is reference-counted.  Its reference count never exceeds
      one so far, but that's going to change.
      
      In drive_del(), the BB's reference count is surely one now.  The BDS's
      reference count is greater than one when something else is holding a
      reference, such as a block job.  In this case, the BB is destroyed
      right away, but the BDS lives on until all extra references get
      dropped.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      26f54e9a
    • M
      block: Split bdrv_new_root() off bdrv_new() · e4e9986b
      Markus Armbruster 提交于
      Creating an anonymous BDS can't fail.  Make that obvious.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NBenoît Canet <benoit.canet@nodalink.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e4e9986b
  4. 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
  5. 10 9月, 2014 1 次提交
  6. 20 8月, 2014 1 次提交
    • M
      block: Use g_new() & friends where that makes obvious sense · 5839e53b
      Markus Armbruster 提交于
      g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
      for two reasons.  One, it catches multiplication overflowing size_t.
      Two, it returns T * rather than void *, which lets the compiler catch
      more type errors.
      
      Patch created with Coccinelle, with two manual changes on top:
      
      * Add const to bdrv_iterate_format() to keep the types straight
      
      * Convert the allocation in bdrv_drop_intermediate(), which Coccinelle
        inexplicably misses
      
      Coccinelle semantic patch:
      
          @@
          type T;
          @@
          -g_malloc(sizeof(T))
          +g_new(T, 1)
          @@
          type T;
          @@
          -g_try_malloc(sizeof(T))
          +g_try_new(T, 1)
          @@
          type T;
          @@
          -g_malloc0(sizeof(T))
          +g_new0(T, 1)
          @@
          type T;
          @@
          -g_try_malloc0(sizeof(T))
          +g_try_new0(T, 1)
          @@
          type T;
          expression n;
          @@
          -g_malloc(sizeof(T) * (n))
          +g_new(T, n)
          @@
          type T;
          expression n;
          @@
          -g_try_malloc(sizeof(T) * (n))
          +g_try_new(T, n)
          @@
          type T;
          expression n;
          @@
          -g_malloc0(sizeof(T) * (n))
          +g_new0(T, n)
          @@
          type T;
          expression n;
          @@
          -g_try_malloc0(sizeof(T) * (n))
          +g_try_new0(T, n)
          @@
          type T;
          expression p, n;
          @@
          -g_realloc(p, sizeof(T) * (n))
          +g_renew(T, p, n)
          @@
          type T;
          expression p, n;
          @@
          -g_try_realloc(p, sizeof(T) * (n))
          +g_try_renew(T, p, n)
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NJeff Cody <jcody@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5839e53b
  7. 09 6月, 2014 1 次提交
    • L
      trace: Multi-backend tracing · 5b808275
      Lluís Vilanova 提交于
      Adds support to compile QEMU with multiple tracing backends at the same time.
      
      For example, you can compile QEMU with:
      
        $ ./configure --enable-trace-backends=ftrace,dtrace
      
      Where 'ftrace' can be handy for having an in-flight record of events, and 'dtrace' can be later used to extract more information from the system.
      
      This patch allows having both available without recompiling QEMU.
      Signed-off-by: NLluís Vilanova <vilanova@ac.upc.edu>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      5b808275
  8. 30 5月, 2014 3 次提交
  9. 22 4月, 2014 1 次提交
    • K
      block: Add errp to bdrv_new() · 98522f63
      Kevin Wolf 提交于
      This patch adds an errp parameter to bdrv_new() and updates all its
      callers. The next patches will make use of this in order to check for
      duplicate IDs. Most of the callers know that their ID is fine, so they
      can simply assert that there is no error.
      
      Behaviour doesn't change with this patch yet as bdrv_new() doesn't
      actually assign errors to errp.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      98522f63
  10. 19 3月, 2014 1 次提交
  11. 13 3月, 2014 1 次提交
  12. 22 2月, 2014 3 次提交
  13. 20 2月, 2014 1 次提交
  14. 01 2月, 2014 1 次提交
  15. 22 1月, 2014 4 次提交
  16. 11 10月, 2013 1 次提交
  17. 12 9月, 2013 1 次提交
  18. 06 9月, 2013 1 次提交
    • F
      block: make bdrv_delete() static · 4f6fd349
      Fam Zheng 提交于
      Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is no
      longer public and should be called by bdrv_unref() if refcnt is
      decreased to 0.
      
      This is an identical change because effectively, there's no multiple
      reference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets
      bs->refcnt to 1, so all bdrv_unref() now actually delete the BDS.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      4f6fd349
  19. 06 8月, 2013 1 次提交
  20. 06 6月, 2013 9 次提交