Skip to content
Snippets Groups Projects
  1. Dec 19, 2020
    • Markus Armbruster's avatar
      block: Use GString instead of QString to build filenames · 18cf67c5
      Markus Armbruster authored
      
      QString supports modifying its string, but it's quite limited: you can
      only append.  Just one caller remains:
      bdrv_parse_filename_strip_prefix() uses it just for building an
      initial string.
      
      Change it to do build the initial string with GString.  This is
      another step towards making QString immutable.
      
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: qemu-block@nongnu.org
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-20-armbru@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      18cf67c5
    • Markus Armbruster's avatar
      block: Avoid qobject_get_try_str() · 410f44f5
      Markus Armbruster authored
      
      I'm about to remove qobject_get_try_str().  Use qstring_get_str()
      instead.  Safe because the argument is known to be a QString here.
      
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: qemu-block@nongnu.org
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-11-armbru@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      410f44f5
    • Markus Armbruster's avatar
      qobject: Change qobject_to_json()'s value to GString · eab3a467
      Markus Armbruster authored
      
      qobject_to_json() and qobject_to_json_pretty() build a GString, then
      covert it to QString.  Just one of the callers actually needs a
      QString: qemu_rbd_parse_filename().  A few others need a string they
      can modify: qmp_send_response(), qga's send_response(), to_json_str(),
      and qmp_fd_vsend_fds().  The remainder just need a string.
      
      Change qobject_to_json() and qobject_to_json_pretty() to return the
      GString.
      
      qemu_rbd_parse_filename() now has to convert to QString.  All others
      save a QString temporary.  to_json_str() actually becomes a bit
      simpler, because GString provides more convenient modification
      functions.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-6-armbru@redhat.com>
      eab3a467
  2. Dec 18, 2020
  3. Dec 11, 2020
    • Vladimir Sementsov-Ogievskiy's avatar
      block: introduce BDRV_MAX_LENGTH · 8b117001
      Vladimir Sementsov-Ogievskiy authored
      
      We are going to modify block layer to work with 64bit requests. And
      first step is moving to int64_t type for both offset and bytes
      arguments in all block request related functions.
      
      It's mostly safe (when widening signed or unsigned int to int64_t), but
      switching from uint64_t is questionable.
      
      So, let's first establish the set of requests we want to work with.
      First signed int64_t should be enough, as off_t is signed anyway. Then,
      obviously offset + bytes should not overflow.
      
      And most interesting: (offset + bytes) being aligned up should not
      overflow as well. Aligned to what alignment? First thing that comes in
      mind is bs->bl.request_alignment, as we align up request to this
      alignment. But there is another thing: look at
      bdrv_mark_request_serialising(). It aligns request up to some given
      alignment. And this parameter may be bdrv_get_cluster_size(), which is
      often a lot greater than bs->bl.request_alignment.
      Note also, that bdrv_mark_request_serialising() uses signed int64_t for
      calculations. So, actually, we already depend on some restrictions.
      
      Happily, bdrv_get_cluster_size() returns int and
      bs->bl.request_alignment has 32bit unsigned type, but defined to be a
      power of 2 less than INT_MAX. So, we may establish, that INT_MAX is
      absolute maximum for any kind of alignment that may occur with the
      request.
      
      Note, that bdrv_get_cluster_size() is not documented to return power
      of 2, still bdrv_mark_request_serialising() behaves like it is.
      Also, backup uses bdi.cluster_size and is not prepared to it not being
      power of 2.
      So, let's establish that Qemu supports only power-of-2 clusters and
      alignments.
      
      So, alignment can't be greater than 2^30.
      
      Finally to be safe with calculations, to not calculate different
      maximums for different nodes (depending on cluster size and
      request_alignment), let's simply set QEMU_ALIGN_DOWN(INT64_MAX, 2^30)
      as absolute maximum bytes length for Qemu. Actually, it's not much less
      than INT64_MAX.
      
      OK, then, let's apply it to block/io.
      
      Let's consider all block/io entry points of offset/bytes:
      
      4 bytes/offset interface functions: bdrv_co_preadv_part(),
      bdrv_co_pwritev_part(), bdrv_co_copy_range_internal() and
      bdrv_co_pdiscard() and we check them all with bdrv_check_request().
      
      We also have one entry point with only offset: bdrv_co_truncate().
      Check the offset.
      
      And one public structure: BdrvTrackedRequest. Happily, it has only
      three external users:
      
       file-posix.c: adopted by this patch
       write-threshold.c: only read fields
       test-write-threshold.c: sets obviously small constant values
      
      Better is to make the structure private and add corresponding
      interfaces.. Still it's not obvious what kind of interface is needed
      for file-posix.c. Let's keep it public but add corresponding
      assertions.
      
      After this patch we'll convert functions in block/io.c to int64_t bytes
      and offset parameters. We can assume that offset/bytes pair always
      satisfy new restrictions, and make
      corresponding assertions where needed. If we reach some offset/bytes
      point in block/io.c missing bdrv_check_request() it is considered a
      bug. As well, if block/io.c modifies a offset/bytes request, expanding
      it more then aligning up to request_alignment, it's a bug too.
      
      For all io requests except for discard we keep for now old restriction
      of 32bit request length.
      
      iotest 206 output error message changed, as now test disk size is
      larger than new limit. Add one more test case with new maximum disk
      size to cover too-big-L1 case.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20201203222713.13507-5-vsementsov@virtuozzo.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      8b117001
    • Hanna Reitz's avatar
      fuse: Allow exporting BDSs via FUSE · 0c9b70d5
      Hanna Reitz authored
      
      block-export-add type=fuse allows mounting block graph nodes via FUSE on
      some existing regular file.  That file should then appears like a raw
      disk image, and accesses to it result in accesses to the exported BDS.
      
      Right now, we only implement the necessary block export functions to set
      it up and shut it down.  We do not implement any access functions, so
      accessing the mount point only results in errors.  This will be
      addressed by a followup patch.
      
      We keep a hash table of exported mount points, because we want to be
      able to detect when users try to use a mount point twice.  This is
      because we invoke stat() to check whether the given mount point is a
      regular file, but if that file is served by ourselves (because it is
      already used as a mount point), then this stat() would have to be served
      by ourselves, too, which is impossible to do while we (as the caller)
      are waiting for it to settle.  Therefore, keep track of mount point
      paths to at least catch the most obvious instances of that problem.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <20201027190600.192171-3-mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      0c9b70d5
  4. Nov 09, 2020
  5. Oct 30, 2020
    • Eric Blake's avatar
      qapi: Add QAPI_LIST_PREPEND() macro · 9812e712
      Eric Blake authored
      
      block.c has a useful macro QAPI_LIST_ADD() for inserting at the front
      of any QAPI-generated list; move it from block.c to qapi/util.h so
      more places can use it, including one earlier place in block.c, and
      rename it to something more obvious (since we also have a lot of
      places that append, rather than prepend, to a list).
      
      There are many more places in the codebase that can benefit from using
      the macro, but converting them will be left to later patches.
      
      In theory, all QAPI list types are child classes of GenericList; but
      in practice, that relationship is not explicitly spelled out in the C
      type declarations (rather, it is something that happens implicitly due
      to C compatible layouts), and the macro does not actually depend on
      the GenericList type.  We considered moving GenericList from visitor.h
      into util.h to group related code; however, such a move would be
      awkward if we do not also move GenericAlternate.  Unfortunately,
      moving GenericAlternate would introduce its own problems of
      declaration circularity (qapi-builtin-types.h needs a complete
      definition of QEnumLookup from util.h, but GenericAlternate needs a
      complete definition of QType from qapi-builtin-types.h).
      
      Suggested-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201027050556.269064-3-eblake@redhat.com>
      [eblake: s/ADD/PREPEND/ per suggestion by Markus]
      9812e712
    • Eric Blake's avatar
      block: Simplify QAPI_LIST_ADD · 159f8442
      Eric Blake authored
      
      There is no need to rely on the verbosity of the gcc/clang compiler
      extension of g_new(typeof(X), 1) when we can instead use the standard
      g_malloc(sizeof(X)).  In general, we like g_new over g_malloc for
      returning type X rather than void* to let the compiler catch more
      potential typing mistakes, but in this particular macro, our other use
      of typeof on the same line already ensures we are getting correct
      results.
      
      Suggested-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20201027050556.269064-2-eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      159f8442
  6. Oct 27, 2020
    • Greg Kurz's avatar
      block: End quiescent sections when a BDS is deleted · 1a6d3bd2
      Greg Kurz authored
      If a BDS gets deleted during blk_drain_all(), it might miss a
      call to bdrv_do_drained_end(). This means missing a call to
      aio_enable_external() and the AIO context remains disabled for
      ever. This can cause a device to become irresponsive and to
      disrupt the guest execution, ie. hang, loop forever or worse.
      
      This scenario is quite easy to encounter with virtio-scsi
      on POWER when punching multiple blockdev-create QMP commands
      while the guest is booting and it is still running the SLOF
      firmware. This happens because SLOF disables/re-enables PCI
      devices multiple times via IO/MEM/MASTER bits of PCI_COMMAND
      register after the initial probe/feature negotiation, as it
      tends to work with a single device at a time at various stages
      like probing and running block/network bootloaders without
      doing a full reset in-between. This naturally generates many
      dataplane stops and starts, and thus many drain sections that
      can race with blockdev_create_run(). In the end, SLOF bails
      out.
      
      It is somehow reproducible on x86 but it requires to generate
      articial dataplane start/stop activity with stop/cont QMP
      commands. In this case, seabios ends up looping for ever,
      waiting for the virtio-scsi device to send a response to
      a command it never received.
      
      Add a helper that pairs all previously called bdrv_do_drained_begin()
      with a bdrv_do_drained_end() and call it from bdrv_close().
      While at it, update the "/bdrv-drain/graph-change/drain_all"
      test in test-bdrv-drain so that it can catch the issue.
      
      BugId: https://bugzilla.redhat.com/show_bug.cgi?id=1874441
      
      
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <160346526998.272601.9045392804399803158.stgit@bahia.lan>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      1a6d3bd2
  7. Oct 09, 2020
  8. Oct 05, 2020
  9. Oct 02, 2020
  10. Sep 23, 2020
    • Stefan Hajnoczi's avatar
      qemu/atomic.h: rename atomic_ to qatomic_ · d73415a3
      Stefan Hajnoczi authored
      
      clang's C11 atomic_fetch_*() functions only take a C11 atomic type
      pointer argument. QEMU uses direct types (int, etc) and this causes a
      compiler error when a QEMU code calls these functions in a source file
      that also included <stdatomic.h> via a system header file:
      
        $ CC=clang CXX=clang++ ./configure ... && make
        ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
      
      Avoid using atomic_*() names in QEMU's atomic.h since that namespace is
      used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h
      and <stdatomic.h> can co-exist. I checked /usr/include on my machine and
      searched GitHub for existing "qatomic_" users but there seem to be none.
      
      This patch was generated using:
      
        $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \
          sort -u >/tmp/changed_identifiers
        $ for identifier in $(</tmp/changed_identifiers); do
              sed -i "s%\<$identifier\>%q$identifier%g" \
                  $(git grep -I -l "\<$identifier\>")
          done
      
      I manually fixed line-wrap issues and misaligned rST tables.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
      d73415a3
  11. Sep 17, 2020
  12. Sep 07, 2020
    • Hanna Reitz's avatar
      block: Leave BDS.backing_{file,format} constant · 0b877d09
      Hanna Reitz authored
      
      Parts of the block layer treat BDS.backing_file as if it were whatever
      the image header says (i.e., if it is a relative path, it is relative to
      the overlay), other parts treat it like a cache for
      bs->backing->bs->filename (relative paths are relative to the CWD).
      Considering bs->backing->bs->filename exists, let us make it mean the
      former.
      
      Among other things, this now allows the user to specify a base when
      using qemu-img to commit an image file in a directory that is not the
      CWD (assuming, everything uses relative filenames).
      
      Before this patch:
      
      $ ./qemu-img create -f qcow2 foo/bot.qcow2 1M
      $ ./qemu-img create -f qcow2 -b bot.qcow2 foo/mid.qcow2
      $ ./qemu-img create -f qcow2 -b mid.qcow2 foo/top.qcow2
      $ ./qemu-img commit -b mid.qcow2 foo/top.qcow2
      qemu-img: Did not find 'mid.qcow2' in the backing chain of 'foo/top.qcow2'
      $ ./qemu-img commit -b foo/mid.qcow2 foo/top.qcow2
      qemu-img: Did not find 'foo/mid.qcow2' in the backing chain of 'foo/top.qcow2'
      $ ./qemu-img commit -b $PWD/foo/mid.qcow2 foo/top.qcow2
      qemu-img: Did not find '[...]/foo/mid.qcow2' in the backing chain of 'foo/top.qcow2'
      
      After this patch:
      
      $ ./qemu-img commit -b mid.qcow2 foo/top.qcow2
      Image committed.
      $ ./qemu-img commit -b foo/mid.qcow2 foo/top.qcow2
      qemu-img: Did not find 'foo/mid.qcow2' in the backing chain of 'foo/top.qcow2'
      $ ./qemu-img commit -b $PWD/foo/mid.qcow2 foo/top.qcow2
      Image committed.
      
      With this change, bdrv_find_backing_image() must look at whether the
      user has overridden a BDS's backing file.  If so, it can no longer use
      bs->backing_file, but must instead compare the given filename against
      the backing node's filename directly.
      
      Note that this changes the QAPI output for a node's backing_file.  We
      had very inconsistent output there (sometimes what the image header
      said, sometimes the actual filename of the backing image).  This
      inconsistent output was effectively useless, so we have to decide one
      way or the other.  Considering that bs->backing_file usually at runtime
      contained the path to the image relative to qemu's CWD (or absolute),
      this patch changes QAPI's backing_file to always report the
      bs->backing->bs->filename from now on.  If you want to receive the image
      header information, you have to refer to full-backing-filename.
      
      This necessitates a change to iotest 228.  The interesting information
      it really wanted is the image header, and it can get that now, but it
      has to use full-backing-filename instead of backing_file.  Because of
      this patch's changes to bs->backing_file's behavior, we also need some
      reference output changes.
      
      Along with the changes to bs->backing_file, stop updating
      BDS.backing_format in bdrv_backing_attach() as well.  This way,
      ImageInfo's backing-filename and backing-filename-format fields will
      represent what the image header says and nothing else.
      
      iotest 245 changes in behavior: With the backing node no longer
      overriding the parent node's backing_file string, you can now omit the
      @backing option when reopening a node with neither a default nor a
      current backing file even if it used to have a backing node at some
      point.
      
      273 also changes: The base image is opened without a format layer, so
      ImageInfo.backing-filename-format used to report "file" for the base
      image's overlay after blockdev-snapshot.  However, the image header
      never says "file" anywhere, so it now reports $IMGFMT.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      0b877d09
    • Hanna Reitz's avatar
      block: Improve get_allocated_file_size's default · 081e4650
      Hanna Reitz authored
      
      There are two practical problems with bdrv_get_allocated_file_size()'s
      default right now:
      (1) For drivers with children, we should generally sum all their sizes
          instead of just passing the request through to bs->file.  The latter
          is good for filters, but not so much for format drivers.
      
      (2) Filters need not have bs->file, so we should actually go to the
          filtered child instead of hard-coding bs->file.
      
      Fix this by splitting the default implementation into three branches:
      (1) For filter drivers: Return the size of the filtered child
      (2) For protocol drivers: Return -ENOTSUP, because the default
          implementation cannot make a guess
      (3) For other drivers: Sum all data-bearing children's sizes
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      081e4650
    • Hanna Reitz's avatar
      block: Use CAFs for debug breakpoints · f706a92f
      Hanna Reitz authored
      
      When looking for a blkdebug node (which implements debug breakpoints),
      use bdrv_primary_bs() to iterate through the graph, because that is
      where a blkdebug node would be.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      f706a92f
    • Hanna Reitz's avatar
      block: Use CAFs in bdrv_refresh_filename() · 52f72d6f
      Hanna Reitz authored
      
      bdrv_refresh_filename() and the kind of related bdrv_dirname() should
      look to the primary child when they wish to copy the underlying file's
      filename.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      52f72d6f
    • Hanna Reitz's avatar
      block: Re-evaluate backing file handling in reopen · 1d42f48c
      Hanna Reitz authored
      
      Reopening a node's backing child needs a bit of special handling because
      the "backing" child has different defaults than all other children
      (among other things).  Adding filter support here is a bit more
      difficult than just using the child access functions.  In fact, we often
      have to directly use bs->backing because these functions are about the
      "backing" child (which may or may not be the COW backing file).
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      1d42f48c
    • Hanna Reitz's avatar
      block: Use CAFs when working with backing chains · dcf3f9b2
      Hanna Reitz authored
      
      Use child access functions when iterating through backing chains so
      filters do not break the chain.
      
      In addition, bdrv_find_overlay() will now always return the actual
      overlay; that is, it will never return a filter node but only one with a
      COW backing file (there may be filter nodes between that node and @bs).
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      dcf3f9b2
    • Hanna Reitz's avatar
      block: Use bdrv_filter_(bs|child) where obvious · 93393e69
      Hanna Reitz authored
      
      Places that use patterns like
      
          if (bs->drv->is_filter && bs->file) {
              ... something about bs->file->bs ...
          }
      
      should be
      
          BlockDriverState *filtered = bdrv_filter_bs(bs);
          if (filtered) {
              ... something about @filtered ...
          }
      
      instead.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      93393e69
    • Hanna Reitz's avatar
      block: Add bdrv_supports_compressed_writes() · ae23f786
      Hanna Reitz authored
      
      Filters cannot compress data themselves but they have to implement
      .bdrv_co_pwritev_compressed() still (or they cannot forward compressed
      writes).  Therefore, checking whether
      bs->drv->bdrv_co_pwritev_compressed is non-NULL is not sufficient to
      know whether the node can actually handle compressed writes.  This
      function looks down the filter chain to see whether there is a
      non-filter that can actually convert the compressed writes into
      compressed data (and thus normal writes).
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      ae23f786
    • Hanna Reitz's avatar
      block: Drop bdrv_is_encrypted() · 8b8277cd
      Hanna Reitz authored
      
      The original purpose of bdrv_is_encrypted() was to inquire whether a BDS
      can be used without the user entering a password or not.  It has not
      been used for that purpose for quite some time.
      
      Actually, it is not even fit for that purpose, because to answer that
      question, it would have recursively query all of the given node's
      children.
      
      So now we have to decide in which direction we want to fix
      bdrv_is_encrypted(): Recursively query all children, or drop it and just
      use bs->encrypted to get the current node's status?
      
      Nowadays, its only purpose is to report through bdrv_query_image_info()
      whether the given image is encrypted or not.  For this purpose, it is
      probably more interesting to see whether a given node itself is
      encrypted or not (otherwise, a management application cannot discern for
      certain which nodes are really encrypted and which just have encrypted
      children).
      
      Suggested-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      8b8277cd
    • Hanna Reitz's avatar
      block: Include filters when freezing backing chain · 7b99a266
      Hanna Reitz authored
      
      In order to make filters work in backing chains, the associated
      functions must be able to deal with them and freeze both COW and filter
      child links.
      
      While at it, add some comments that note which functions require their
      caller to ensure that a given child link is not frozen, and how the
      callers do so.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      7b99a266
    • Hanna Reitz's avatar
      block: bdrv_set_backing_hd() is about bs->backing · 9ee413cb
      Hanna Reitz authored
      
      bdrv_set_backing_hd() is a function that explicitly cares about the
      bs->backing child.  Highlight that in its description and use
      child_bs(bs->backing) instead of backing_bs(bs) to make it more obvious.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      9ee413cb
    • Hanna Reitz's avatar
      block: bdrv_cow_child() for bdrv_has_zero_init() · 34778172
      Hanna Reitz authored
      
      bdrv_has_zero_init() should use bdrv_cow_child() if it wants to check
      whether the given BDS has a COW backing file.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      34778172
    • Hanna Reitz's avatar
      block: Add chain helper functions · d38d7eb8
      Hanna Reitz authored
      
      Add some helper functions for skipping filters in a chain of block
      nodes.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      d38d7eb8
    • Hanna Reitz's avatar
      block: Add child access functions · 9a6fc887
      Hanna Reitz authored
      
      There are BDS children that the general block layer code can access,
      namely bs->file and bs->backing.  Since the introduction of filters and
      external data files, their meaning is not quite clear.  bs->backing can
      be a COW source, or it can be a filtered child; bs->file can be a
      filtered child, it can be data and metadata storage, or it can be just
      metadata storage.
      
      This overloading really is not helpful.  This patch adds functions that
      retrieve the correct child for each exact purpose.  Later patches in
      this series will make use of them.  Doing so will allow us to handle
      filter nodes in a meaningful way.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      9a6fc887
    • Connor Kuehl's avatar
      block: Raise an error when backing file parameter is an empty string · 975a7bd2
      Connor Kuehl authored
      
      Providing an empty string for the backing file parameter like so:
      
      	qemu-img create -f qcow2 -b '' /tmp/foo
      
      allows the flow of control to reach and subsequently fail an assert
      statement because passing an empty string to
      
      	bdrv_get_full_backing_filename_from_filename()
      
      simply results in NULL being returned without an error being raised.
      
      To fix this, let's check for an empty string when getting the value from
      the opts list.
      
      Reported-by: default avatarAttila Fazekas <afazekas@redhat.com>
      Fixes: https://bugzilla.redhat.com/1809553
      
      
      Signed-off-by: default avatarConnor Kuehl <ckuehl@redhat.com>
      Message-Id: <20200813134722.802180-1-ckuehl@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      975a7bd2
Loading