1. 10 7月, 2020 3 次提交
    • M
      error: Reduce unnecessary error propagation · a5f9b9df
      Markus Armbruster 提交于
      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: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200707160613.848843-38-armbru@redhat.com>
      a5f9b9df
    • M
      error: Avoid unnecessary error_propagate() after error_setg() · dcfe4805
      Markus Armbruster 提交于
      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: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20200707160613.848843-34-armbru@redhat.com>
      dcfe4805
    • M
      qemu-option: Use returned bool to check for failure · 235e59cf
      Markus Armbruster 提交于
      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: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir 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
  2. 14 10月, 2019 1 次提交
  3. 12 6月, 2019 1 次提交
  4. 25 2月, 2019 1 次提交
    • M
      block: Add strong_runtime_opts to BlockDriver · 2654267c
      Max Reitz 提交于
      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: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Message-id: 20190201192935.18394-22-mreitz@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      2654267c
  5. 15 6月, 2018 1 次提交
    • M
      block: Add block-specific QDict header · 609f45ea
      Max Reitz 提交于
      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: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-Id: <20180509165530.29561-7-mreitz@redhat.com>
      [Copyright note tweaked, superfluous includes dropped]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      609f45ea
  6. 15 5月, 2018 1 次提交
    • E
      vxhs: Switch to byte-based callbacks · 918889b2
      Eric Blake 提交于
      We are gradually moving away from sector-based interfaces, towards
      byte-based.  Make the change for the last few sector-based callbacks
      in the vxhs driver.
      
      Note that the driver was already using byte-based calls for
      performing actual I/O, so this just gets rid of a round trip
      of scaling; however, as I don't know if VxHS is tolerant of
      non-sector AIO operations, I went with the conservative approach
      of adding .bdrv_refresh_limits to override the block layer
      defaults back to the pre-patch value of 512.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      918889b2
  7. 04 5月, 2018 1 次提交
  8. 09 5月, 2017 1 次提交
  9. 25 4月, 2017 1 次提交