Skip to content
Snippets Groups Projects
  1. Jun 02, 2021
  2. Mar 08, 2021
  3. Dec 18, 2020
    • Alberto Garcia's avatar
      quorum: Implement bdrv_co_pwrite_zeroes() · 5cddb2e9
      Alberto Garcia authored
      
      This simply calls bdrv_co_pwrite_zeroes() in all children.
      
      bs->supported_zero_flags is also set to the flags that are supported
      by all children.
      
      Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
      Message-Id: <2f09c842781fe336b4c2e40036bba577b7430190.1605286097.git.berto@igalia.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      5cddb2e9
    • Alberto Garcia's avatar
      quorum: Implement bdrv_co_block_status() · ef9bba14
      Alberto Garcia authored
      
      The quorum driver does not implement bdrv_co_block_status() and
      because of that it always reports to contain data even if all its
      children are known to be empty.
      
      One consequence of this is that if we for example create a quorum with
      a size of 10GB and we mirror it to a new image the operation will
      write 10GB of actual zeroes to the destination image wasting a lot of
      time and disk space.
      
      Since a quorum has an arbitrary number of children of potentially
      different formats there is no way to report all possible allocation
      status flags in a way that makes sense, so this implementation only
      reports when a given region is known to contain zeroes
      (BDRV_BLOCK_ZERO) or not (BDRV_BLOCK_DATA).
      
      If all children agree that a region contains zeroes then we can return
      BDRV_BLOCK_ZERO using the smallest size reported by the children
      (because all agree that a region of at least that size contains
      zeroes).
      
      If at least one child disagrees we have to return BDRV_BLOCK_DATA.
      In this case we use the largest of the sizes reported by the children
      that didn't return BDRV_BLOCK_ZERO (because we know that there won't
      be an agreement for at least that size).
      
      Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
      Tested-by: default avatarTao Xu <tao3.xu@intel.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <db83149afcf0f793effc8878089d29af4c46ffe1.1605286097.git.berto@igalia.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      ef9bba14
  4. Dec 10, 2020
  5. Nov 17, 2020
  6. Sep 15, 2020
  7. Jul 10, 2020
    • Markus Armbruster's avatar
      error: Reduce unnecessary error propagation · a5f9b9df
      Markus Armbruster authored
      
      When all we do with an Error we receive into a local variable is
      propagating to somewhere else, we can just as well receive it there
      right away, even when we need to keep error_propagate() for other
      error paths.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20200707160613.848843-38-armbru@redhat.com>
      a5f9b9df
    • Markus Armbruster's avatar
      error: Avoid unnecessary error_propagate() after error_setg() · dcfe4805
      Markus Armbruster authored
      
      Replace
      
          error_setg(&err, ...);
          error_propagate(errp, err);
      
      by
      
          error_setg(errp, ...);
      
      Related pattern:
      
          if (...) {
              error_setg(&err, ...);
              goto out;
          }
          ...
       out:
          error_propagate(errp, err);
          return;
      
      When all paths to label out are that way, replace by
      
          if (...) {
              error_setg(errp, ...);
              return;
          }
      
      and delete the label along with the error_propagate().
      
      When we have at most one other path that actually needs to propagate,
      and maybe one at the end that where propagation is unnecessary, e.g.
      
          foo(..., &err);
          if (err) {
              goto out;
          }
          ...
          bar(..., &err);
       out:
          error_propagate(errp, err);
          return;
      
      move the error_propagate() to where it's needed, like
      
          if (...) {
              foo(..., &err);
              error_propagate(errp, err);
              return;
          }
          ...
          bar(..., errp);
          return;
      
      and transform the error_setg() as above.
      
      In some places, the transformation results in obviously unnecessary
      error_propagate().  The next few commits will eliminate them.
      
      Bonus: the elimination of gotos will make later patches in this series
      easier to review.
      
      Candidates for conversion tracked down with this Coccinelle script:
      
          @@
          identifier err, errp;
          expression list args;
          @@
          -    error_setg(&err, args);
          +    error_setg(errp, args);
               ... when != err
               error_propagate(errp, err);
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20200707160613.848843-34-armbru@redhat.com>
      dcfe4805
    • Markus Armbruster's avatar
      qemu-option: Use returned bool to check for failure · 235e59cf
      Markus Armbruster authored
      
      The previous commit enables conversion of
      
          foo(..., &err);
          if (err) {
              ...
          }
      
      to
      
          if (!foo(..., &err)) {
              ...
          }
      
      for QemuOpts functions that now return true / false on success /
      error.  Coccinelle script:
      
          @@
          identifier fun = {
              opts_do_parse, parse_option_bool, parse_option_number,
              parse_option_size, qemu_opt_parse, qemu_opt_rename, qemu_opt_set,
              qemu_opt_set_bool, qemu_opt_set_number, qemu_opts_absorb_qdict,
              qemu_opts_do_parse, qemu_opts_from_qdict_entry, qemu_opts_set,
              qemu_opts_validate
          };
          expression list args, args2;
          typedef Error;
          Error *err;
          @@
          -    fun(args, &err, args2);
          -    if (err)
          +    if (!fun(args, &err, args2))
               {
                   ...
               }
      
      A few line breaks tidied up manually.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20200707160613.848843-15-armbru@redhat.com>
      [Conflict with commit 0b6786a9 "block/amend: refactor qcow2 amend
      options" resolved by rerunning Coccinelle on master's version]
      235e59cf
  8. May 18, 2020
  9. Feb 18, 2020
  10. Jun 12, 2019
  11. May 28, 2019
    • Alberto Garcia's avatar
      block: Make bdrv_root_attach_child() unref child_bs on failure · b441dc71
      Alberto Garcia authored
      
      A consequence of the previous patch is that bdrv_attach_child()
      transfers the reference to child_bs from the caller to parent_bs,
      which will drop it on bdrv_close() or when someone calls
      bdrv_unref_child().
      
      But this only happens when bdrv_attach_child() succeeds. If it fails
      then the caller is responsible for dropping the reference to child_bs.
      
      This patch makes bdrv_attach_child() take the reference also when
      there is an error, freeing the caller for having to do it.
      
      A similar situation happens with bdrv_root_attach_child(), so the
      changes on this patch affect both functions.
      
      Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
      Message-id: 20dfb3d9ccec559cdd1a9690146abad5d204a186.1557754872.git.berto@igalia.com
      [mreitz: Removed now superfluous BdrvChild * variable in
               bdrv_open_child()]
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      b441dc71
  12. Feb 25, 2019
    • Hanna Reitz's avatar
      block: Purify .bdrv_refresh_filename() · 998b3a1e
      Hanna Reitz authored
      
      Currently, BlockDriver.bdrv_refresh_filename() is supposed to both
      refresh the filename (BDS.exact_filename) and set BDS.full_open_options.
      Now that we have generic code in the central bdrv_refresh_filename() for
      creating BDS.full_open_options, we can drop the latter part from all
      BlockDriver.bdrv_refresh_filename() implementations.
      
      This also means that we can drop all of the existing default code for
      this from the global bdrv_refresh_filename() itself.
      
      Furthermore, we now have to call BlockDriver.bdrv_refresh_filename()
      after having set BDS.full_open_options, because the block driver's
      implementation should now be allowed to depend on BDS.full_open_options
      being set correctly.
      
      Finally, with this patch we can drop the @options parameter from
      BlockDriver.bdrv_refresh_filename(); also, add a comment on this
      function's purpose in block/block_int.h while touching its interface.
      
      This completely obsoletes blklogwrite's implementation of
      .bdrv_refresh_filename().
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20190201192935.18394-25-mreitz@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      998b3a1e
    • Hanna Reitz's avatar
      block: Add BlockDriver.bdrv_gather_child_options · abc521a9
      Hanna Reitz authored
      
      Some follow-up patches will rework the way bs->full_open_options is
      refreshed in bdrv_refresh_filename(). The new implementation will remove
      the need for the block drivers' bdrv_refresh_filename() implementations
      to set bs->full_open_options; instead, it will be generic and use static
      information from each block driver.
      
      However, by implementing bdrv_gather_child_options(), block drivers will
      still be able to override the way the full_open_options of their
      children are incorporated into their own.
      
      We need to implement this function for VMDK because we have to prevent
      the generic implementation from gathering the options of all children:
      It is not possible to specify options for the extents through the
      runtime options.
      
      For quorum, the child names that would be used by the generic
      implementation and the ones that we actually (currently) want to use
      differ. See quorum_gather_child_options() for more information.
      
      Note that both of these are cases which are not ideal: In case of VMDK
      it would probably be nice to be able to specify options for all extents.
      In case of quorum, the current runtime option structure is simply broken
      and needs to be fixed (but that is left for another patch).
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
      Message-id: 20190201192935.18394-23-mreitz@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      abc521a9
    • Hanna Reitz's avatar
      block: Add strong_runtime_opts to BlockDriver · 2654267c
      Hanna Reitz authored
      
      This new field can be set by block drivers to list the runtime options
      they accept that may influence the contents of the respective BDS. As of
      a follow-up patch, this list will be used by the common
      bdrv_refresh_filename() implementation to decide which options to put
      into BDS.full_open_options (and consequently whether a JSON filename has
      to be created), thus freeing the drivers of having to implement that
      logic themselves.
      
      Additionally, this patch adds the field to all of the block drivers that
      need it and sets it accordingly.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
      Message-id: 20190201192935.18394-22-mreitz@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      2654267c
    • Hanna Reitz's avatar
      quorum: Make bdrv_dirname() return NULL · f3037bd2
      Hanna Reitz authored
      
      While the common implementation for bdrv_dirname() should return NULL
      for quorum BDSs already (because they do not have a file node and their
      exact_filename field should be empty), there is no reason not to make
      that explicit.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
      Message-id: 20190201192935.18394-17-mreitz@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      f3037bd2
    • Hanna Reitz's avatar
      block: Use children list in bdrv_refresh_filename · e24518e3
      Hanna Reitz authored
      
      bdrv_refresh_filename() should invoke itself recursively on all
      children, not just on file.
      
      With that change, we can remove the manual invocations in blkverify,
      quorum, commit, mirror, and blklogwrites.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
      Message-id: 20190201192935.18394-3-mreitz@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      e24518e3
  13. Nov 05, 2018
  14. Aug 28, 2018
  15. Jun 15, 2018
    • Hanna Reitz's avatar
      block: Add block-specific QDict header · 609f45ea
      Hanna Reitz authored
      
      There are numerous QDict functions that have been introduced for and are
      used only by the block layer.  Move their declarations into an own
      header file to reflect that.
      
      While qdict_extract_subqdict() is in fact used outside of the block
      layer (in util/qemu-config.c), it is still a function related very
      closely to how the block layer works with nested QDicts, namely by
      sometimes flattening them.  Therefore, its declaration is put into this
      header as well and util/qemu-config.c includes it with a comment stating
      exactly which function it needs.
      
      Suggested-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <20180509165530.29561-7-mreitz@redhat.com>
      [Copyright note tweaked, superfluous includes dropped]
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      609f45ea
  16. May 20, 2018
  17. May 15, 2018
  18. May 04, 2018
  19. Mar 26, 2018
  20. Mar 02, 2018
  21. Feb 09, 2018
Loading