1. 20 Oct, 2014 9 commits
    • Markus Armbruster's avatar
    • Markus Armbruster's avatar
      block: Connect BlockBackend and DriveInfo · 18e46a03
      Markus Armbruster authored
      Make the BlockBackend own the DriveInfo.  Change blockdev_init() to
      return the BlockBackend instead of the DriveInfo.
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      18e46a03
    • Markus Armbruster's avatar
      block: Connect BlockBackend to BlockDriverState · 7e7d56d9
      Markus Armbruster authored
      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: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      7e7d56d9
    • Markus Armbruster's avatar
      block: New BlockBackend · 26f54e9a
      Markus Armbruster authored
      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: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      26f54e9a
    • Markus Armbruster's avatar
      block: Split bdrv_new_root() off bdrv_new() · e4e9986b
      Markus Armbruster authored
      Creating an anonymous BDS can't fail.  Make that obvious.
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarBenoît Canet <benoit.canet@nodalink.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      e4e9986b
    • Max Reitz's avatar
      nbd: Fix filename generation · ec0de768
      Max Reitz authored
      Export names may be used with nbd+unix, too, fix nbd_refresh_filename()
      accordingly. Also, for nbd+tcp, the documented path schema is
      "nbd://host[:port]/export", so use it. Furthermore, as can be seen from
      that schema, the port is optional.
      
      That makes six single cases for how the filename can be formatted; it is
      not easy to generalize these cases without the resulting statement being
      completely unreadable, thus there is simply one snprintf() per case.
      
      Finally, taking the options from BDRVNBDState::socket_opts is wrong,
      because those will not contain the export name. Just use
      BlockDriverState::options instead.
      Reported-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      ec0de768
    • Tony Breeds's avatar
      block/raw-posix: use seek_hole ahead of fiemap · 7c159037
      Tony Breeds authored
      try_fiemap() uses FIEMAP_FLAG_SYNC which has a significant performance
      impact.
      
      Prefer seek_hole() over fiemap() to avoid this impact where possible.
      seek_hole is more widely used and, arguably, has potential to be
      optimised in the kernel.
      Reported-By: default avatarMichael Steffens <michael_steffens@posteo.de>
      Signed-off-by: default avatarTony Breeds <tony@bakeyournoodle.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: Pádraig Brady <pbrady@redhat.com>
      Cc: Eric Blake <eblake@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      7c159037
    • Tony Breeds's avatar
      block/raw-posix: Fix disk corruption in try_fiemap · 38c4d0ae
      Tony Breeds authored
      Using fiemap without FIEMAP_FLAG_SYNC is a known corrupter.
      
      Add the FIEMAP_FLAG_SYNC flag to the FS_IOC_FIEMAP ioctl.  This has
      the downside of significantly reducing performance.
      Reported-By: default avatarMichael Steffens <michael_steffens@posteo.de>
      Signed-off-by: default avatarTony Breeds <tony@bakeyournoodle.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: Pádraig Brady <pbrady@redhat.com>
      Cc: Eric Blake <eblake@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      38c4d0ae
    • Zhang Haoyu's avatar
      qcow2: fix leak of Qcow2DiscardRegion in update_refcount_discard · d8bb71b6
      Zhang Haoyu authored
      When the Qcow2DiscardRegion is adjacent to another one referenced by "d",
      free this Qcow2DiscardRegion metadata referenced by "p" after
      it was removed from s->discards queue.
      Signed-off-by: default avatarZhang Haoyu <zhanghy@sangfor.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      d8bb71b6
  2. 16 Oct, 2014 3 commits
    • Gonglei's avatar
      glib: add compatibility interface for g_strcmp0() · 5f77ef69
      Gonglei authored
      This patch fixes compilation errors when building against glib < 2.16.0
      due to the missing g_strcmp0() function.
      Suggested-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: default avatarGonglei <arei.gonglei@huawei.com>
      Message-id: 1413457177-10132-1-git-send-email-arei.gonglei@huawei.com
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      5f77ef69
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20141015-1' into staging · 8a2c2636
      Peter Maydell authored
      vga-pci: add qext region to mmio
      vga: Remove unused arrays dmask4 and dmask16
      
      # gpg: Signature made Wed 15 Oct 2014 10:12:06 BST using RSA key ID D3E87138
      # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
      # gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
      # gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
      
      * remotes/kraxel/tags/pull-vga-20141015-1:
        hw/display/vga: Remove unused arrays dmask4 and dmask16
        vga-pci: add qext region to mmio
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      8a2c2636
    • Peter Maydell's avatar
      Merge remote-tracking branch 'remotes/kraxel/tags/pull-bootindex-20141015-1' into staging · 605c690b
      Peter Maydell authored
      allow changing bootorder via monitor at runtime,
      by making bootindex a writable qom property.
      
      * remotes/kraxel/tags/pull-bootindex-20141015-1: (34 commits)
        bootindex: change fprintf to error_report
        bootindex: delete bootindex when device is removed
        bootindex: move calling add_boot_device_patch to bootindex setter function
        ide: add calling add_boot_device_patch in bootindex setter function
        nvma: ide: add bootindex to qom property
        usb-storage: add bootindex to qom property
        virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390
        block: remove bootindex property from qdev to qom
        virtio-blk: add bootindex to qom property
        ide: add bootindex to qom property
        scsi: add bootindex to qom property
        isa-fdc: remove bootindexA/B property from qdev to qom
        redirect: remove bootindex property from qdev to qom
        vfio: remove bootindex property from qdev to qom
        pci-assign: remove bootindex property from qdev to qom
        host-libusb: remove bootindex property from qdev to qom
        virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390
        net: remove bootindex property from qdev to qom
        usb-net: add bootindex to qom property
        vmxnet3: add bootindex to qom property
        ...
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      605c690b
  3. 15 Oct, 2014 28 commits