1. 09 2月, 2018 1 次提交
  2. 08 2月, 2018 1 次提交
  3. 21 11月, 2017 1 次提交
  4. 26 10月, 2017 12 次提交
    • E
      qemu-img: Change img_compare() to be byte-based · 033d9fc2
      Eric Blake 提交于
      In the continuing quest to make more things byte-based, change
      the internal iteration of img_compare().  We can finally drop the
      TODO assertions added earlier, now that the entire algorithm is
      byte-based and no longer has to shift from bytes to sectors.
      
      Most of the change is mechanical ('total_sectors' becomes
      'total_size', 'sector_num' becomes 'offset', 'nb_sectors' becomes
      'chunk', 'progress_base' goes from sectors to bytes); some of it
      is also a cleanup (sectors_to_bytes() is now unused, loss of
      variable 'count' added earlier in commit 51b0a488).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      033d9fc2
    • E
      qemu-img: Change img_rebase() to be byte-based · 41536287
      Eric Blake 提交于
      In the continuing quest to make more things byte-based, change
      the internal iteration of img_rebase().  We can finally drop the
      TODO assertion added earlier, now that the entire algorithm is
      byte-based and no longer has to shift from bytes to sectors.
      
      Most of the change is mechanical ('num_sectors' becomes 'size',
      'sector' becomes 'offset', 'n' goes from sectors to bytes); some
      of it is also a cleanup (use of MIN() instead of open-coding,
      loss of variable 'count' added earlier in commit d6a644bb).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      41536287
    • E
      qemu-img: Change compare_sectors() to be byte-based · dc61cd3b
      Eric Blake 提交于
      In the continuing quest to make more things byte-based, change
      compare_sectors(), renaming it to compare_buffers() in the
      process.  Note that one caller (qemu-img compare) only cares
      about the first difference, while the other (qemu-img rebase)
      cares about how many consecutive sectors have the same
      equal/different status; however, this patch does not bother to
      micro-optimize the compare case to avoid the comparisons of
      sectors beyond the first mismatch.  Both callers are always
      passing valid buffers in, so the initial check for buffer size
      can be turned into an assertion.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      dc61cd3b
    • E
      qemu-img: Change check_empty_sectors() to byte-based · c41508ed
      Eric Blake 提交于
      Continue on the quest to make more things byte-based instead of
      sector-based.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c41508ed
    • E
      qemu-img: Drop redundant error message in compare · 0608e40e
      Eric Blake 提交于
      If a read error is encountered during 'qemu-img compare', we
      were printing the "Error while reading offset ..." message twice;
      this was because our helper function was awkward, printing output
      on some but not all paths.  Fix it to consistently report errors
      on all paths, so that the callers do not risk a redundant message,
      and update the testsuite for the improved output.
      
      Further simplify the code by hoisting the conversion from an error
      message to an exit code into the helper function, rather than
      repeating that logic at all callers (yes, the helper function is
      now less generic, but it's a net win in lines of code).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0608e40e
    • E
      qemu-img: Add find_nonzero() · debb38a4
      Eric Blake 提交于
      During 'qemu-img compare', when we are checking that an allocated
      portion of one file is all zeros, we don't need to waste time
      computing how many additional sectors after the first non-zero
      byte are also non-zero.  Create a new helper find_nonzero() to do
      the check for a first non-zero sector, and rebase
      check_empty_sectors() to use it.
      
      The new interface intentionally uses bytes in its interface, even
      though it still crawls the buffer a sector at a time; it is robust
      to a partial sector at the end of the buffer.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      debb38a4
    • E
      qemu-img: Speed up compare on pre-allocated larger file · 391cb1aa
      Eric Blake 提交于
      Compare the following images with all-zero contents:
      $ truncate --size 1M A
      $ qemu-img create -f qcow2 -o preallocation=off B 1G
      $ qemu-img create -f qcow2 -o preallocation=metadata C 1G
      
      On my machine, the difference is noticeable for pre-patch speeds,
      with more than an order of magnitude in difference caused by the
      choice of preallocation in the qcow2 file:
      
      $ time ./qemu-img compare -f raw -F qcow2 A B
      Warning: Image size mismatch!
      Images are identical.
      
      real	0m0.014s
      user	0m0.007s
      sys	0m0.007s
      
      $ time ./qemu-img compare -f raw -F qcow2 A C
      Warning: Image size mismatch!
      Images are identical.
      
      real	0m0.341s
      user	0m0.144s
      sys	0m0.188s
      
      Why? Because bdrv_is_allocated() returns false for image B but
      true for image C, throwing away the fact that both images know
      via lseek(SEEK_HOLE) that the entire image still reads as zero.
      From there, qemu-img ends up calling bdrv_pread() for every byte
      of the tail, instead of quickly looking for the next allocation.
      The solution: use block_status instead of is_allocated, giving:
      
      $ time ./qemu-img compare -f raw -F qcow2 A C
      Warning: Image size mismatch!
      Images are identical.
      
      real	0m0.014s
      user	0m0.011s
      sys	0m0.003s
      
      which is on par with the speeds for no pre-allocation.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      391cb1aa
    • E
      qemu-img: Simplify logic in img_compare() · 7daddc61
      Eric Blake 提交于
      As long as we are querying the status for a chunk smaller than
      the known image size, we are guaranteed that a successful return
      will have set pnum to a non-zero size (pnum is zero only for
      queries beyond the end of the file).  Use that to slightly
      simplify the calculation of the current chunk size being compared.
      Likewise, we don't have to shrink the amount of data operated on
      until we know we have to read the file, and therefore have to fit
      in the bounds of our buffer.  Also, note that 'total_sectors_over'
      is equivalent to 'progress_base'.
      
      With these changes in place, sectors_to_process() is now dead code,
      and can be removed.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      7daddc61
    • E
      block: Convert bdrv_get_block_status_above() to bytes · 31826642
      Eric Blake 提交于
      We are gradually moving away from sector-based interfaces, towards
      byte-based.  In the common case, allocation is unlikely to ever use
      values that are not naturally sector-aligned, but it is possible
      that byte-based values will let us be more precise about allocation
      at the end of an unaligned file that can do byte-based access.
      
      Changing the name of the function from bdrv_get_block_status_above()
      to bdrv_block_status_above() ensures that the compiler enforces that
      all callers are updated.  Likewise, since it a byte interface allows
      an offset mapping that might not be sector aligned, split the mapping
      out of the return value and into a pass-by-reference parameter.  For
      now, the io.c layer still assert()s that all uses are sector-aligned,
      but that can be relaxed when a later patch implements byte-based
      block status in the drivers.
      
      For the most part this patch is just the addition of scaling at the
      callers followed by inverse scaling at bdrv_block_status(), plus
      updates for the new split return interface.  But some code,
      particularly bdrv_block_status(), gets a lot simpler because it no
      longer has to mess with sectors.  Likewise, mirror code no longer
      computes s->granularity >> BDRV_SECTOR_BITS, and can therefore drop
      an assertion about alignment because the loop no longer depends on
      alignment (never mind that we don't really have a driver that
      reports sub-sector alignments, so it's not really possible to test
      the effect of sub-sector mirroring).  Fix a neighboring assertion to
      use is_power_of_2 while there.
      
      For ease of review, bdrv_get_block_status() was tackled separately.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      31826642
    • E
      block: Convert bdrv_get_block_status() to bytes · 237d78f8
      Eric Blake 提交于
      We are gradually moving away from sector-based interfaces, towards
      byte-based.  In the common case, allocation is unlikely to ever use
      values that are not naturally sector-aligned, but it is possible
      that byte-based values will let us be more precise about allocation
      at the end of an unaligned file that can do byte-based access.
      
      Changing the name of the function from bdrv_get_block_status() to
      bdrv_block_status() ensures that the compiler enforces that all
      callers are updated.  For now, the io.c layer still assert()s that
      all callers are sector-aligned, but that can be relaxed when a later
      patch implements byte-based block status in the drivers.
      
      There was an inherent limitation in returning the offset via the
      return value: we only have room for BDRV_BLOCK_OFFSET_MASK bits, which
      means an offset can only be mapped for sector-aligned queries (or,
      if we declare that non-aligned input is at the same relative position
      modulo 512 of the answer), so the new interface also changes things to
      return the offset via output through a parameter by reference rather
      than mashed into the return value.  We'll have some glue code that
      munges between the two styles until we finish converting all uses.
      
      For the most part this patch is just the addition of scaling at the
      callers followed by inverse scaling at bdrv_block_status(), coupled
      with the tweak in calling convention.  But some code, particularly
      bdrv_is_allocated(), gets a lot simpler because it no longer has to
      mess with sectors.
      
      For ease of review, bdrv_get_block_status_above() will be tackled
      separately.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      237d78f8
    • E
      qemu-img: Switch get_block_status() to byte-based · 5e344dd8
      Eric Blake 提交于
      We are gradually converting to byte-based interfaces, as they are
      easier to reason about than sector-based.  Continue by converting
      an internal function (no semantic change), and simplifying its
      caller accordingly.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5e344dd8
    • E
      block: Allow NULL file for bdrv_get_block_status() · 298a1665
      Eric Blake 提交于
      Not all callers care about which BDS owns the mapping for a given
      range of the file.  This patch merely simplifies the callers by
      consolidating the logic in the common call point, while guaranteeing
      a non-NULL file to all the driver callbacks, for no semantic change.
      The only caller that does not care about pnum is bdrv_is_allocated,
      as invoked by vvfat; we can likewise add assertions that the rest
      of the stack does not have to worry about a NULL pnum.
      
      Furthermore, this will also set the stage for a future cleanup: when
      a caller does not care about which BDS owns an offset, it would be
      nice to allow the driver to optimize things to not have to return
      BDRV_BLOCK_OFFSET_VALID in the first place.  In the case of fragmented
      allocation (for example, it's fairly easy to create a qcow2 image
      where consecutive guest addresses are not at consecutive host
      addresses), the current contract requires bdrv_get_block_status()
      to clamp *pnum to the limit where host addresses are no longer
      consecutive, but allowing a NULL file means that *pnum could be
      set to the full length of known-allocated data.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      298a1665
  5. 26 9月, 2017 1 次提交
  6. 04 9月, 2017 3 次提交
  7. 08 8月, 2017 1 次提交
    • E
      maint: Include bug-reporting info in --help output · f5048cb7
      Eric Blake 提交于
      These days, many programs are including a bug-reporting address,
      or better yet, a link to the project web site, at the tail of
      their --help output.  However, we were not very consistent at
      doing so: only qemu-nbd and qemu-qa mentioned anything, with the
      latter pointing to an individual person instead of the project.
      
      Add a new #define that sets up a uniform string, mentioning both
      bug reporting instructions and overall project details, and which
      a downstream vendor could tweak if they want bugs to go to a
      downstream database.  Then use it in all of our binaries which
      have --help output.
      
      The canned text intentionally references http:// instead of https://
      because our https website currently causes certificate errors in
      some browsers.  That can be tweaked later once we have resolved the
      web site issued.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Message-Id: <20170803163353.19558-5-eblake@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f5048cb7
  8. 24 7月, 2017 1 次提交
  9. 18 7月, 2017 1 次提交
    • J
      qemu-img: Check for backing image if specified during create · 6e6e55f5
      John Snow 提交于
      Or, rather, force the open of a backing image if one was specified
      for creation. Using a similar -unsafe option as rebase, allow qemu-img
      to ignore the backing file validation if possible.
      
      It may not always be possible, as in the existing case when a filesize
      for the new image was not specified.
      
      This is accomplished by shifting around the conditionals in
      bdrv_img_create, such that a backing file is always opened unless we
      provide BDRV_O_NO_BACKING. qemu-img is adjusted to pass this new flag
      when -u is provided to create.
      
      Sorry for the heinous looking diffstat, but it's mostly whitespace.
      
      Inspired by: https://bugzilla.redhat.com/show_bug.cgi?id=1213786Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6e6e55f5
  10. 12 7月, 2017 1 次提交
  11. 11 7月, 2017 5 次提交
  12. 10 7月, 2017 3 次提交
    • E
      block: Make bdrv_is_allocated_above() byte-based · 51b0a488
      Eric Blake 提交于
      We are gradually moving away from sector-based interfaces, towards
      byte-based.  In the common case, allocation is unlikely to ever use
      values that are not naturally sector-aligned, but it is possible
      that byte-based values will let us be more precise about allocation
      at the end of an unaligned file that can do byte-based access.
      
      Changing the signature of the function to use int64_t *pnum ensures
      that the compiler enforces that all callers are updated.  For now,
      the io.c layer still assert()s that all callers are sector-aligned,
      but that can be relaxed when a later patch implements byte-based
      block status.  Therefore, for the most part this patch is just the
      addition of scaling at the callers followed by inverse scaling at
      bdrv_is_allocated().  But some code, particularly stream_run(),
      gets a lot simpler because it no longer has to mess with sectors.
      Leave comments where we can further simplify by switching to
      byte-based iterations, once later patches eliminate the need for
      sector-aligned operations.
      
      For ease of review, bdrv_is_allocated() was tackled separately.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      51b0a488
    • E
      block: Make bdrv_is_allocated() byte-based · d6a644bb
      Eric Blake 提交于
      We are gradually moving away from sector-based interfaces, towards
      byte-based.  In the common case, allocation is unlikely to ever use
      values that are not naturally sector-aligned, but it is possible
      that byte-based values will let us be more precise about allocation
      at the end of an unaligned file that can do byte-based access.
      
      Changing the signature of the function to use int64_t *pnum ensures
      that the compiler enforces that all callers are updated.  For now,
      the io.c layer still assert()s that all callers are sector-aligned
      on input and that *pnum is sector-aligned on return to the caller,
      but that can be relaxed when a later patch implements byte-based
      block status.  Therefore, this code adds usages like
      DIV_ROUND_UP(,BDRV_SECTOR_SIZE) to callers that still want aligned
      values, where the call might reasonbly give non-aligned results
      in the future; on the other hand, no rounding is needed for callers
      that should just continue to work with byte alignment.
      
      For the most part this patch is just the addition of scaling at the
      callers followed by inverse scaling at bdrv_is_allocated().  But
      some code, particularly bdrv_commit(), gets a lot simpler because it
      no longer has to mess with sectors; also, it is now possible to pass
      NULL if the caller does not care how much of the image is allocated
      beyond the initial offset.  Leave comments where we can further
      simplify once a later patch eliminates the need for sector-aligned
      requests through bdrv_is_allocated().
      
      For ease of review, bdrv_is_allocated_above() will be tackled
      separately.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d6a644bb
    • D
      qemu-img: drop -e and -6 options from the 'create' & 'convert' commands · 6b4df548
      Daniel P. Berrange 提交于
      The '-e' and '-6' options to the 'create' & 'convert' commands were
      "deprecated" in favour of the more generic '-o' option many years ago:
      
        commit eec77d9e
        Author: Jes Sorensen <Jes.Sorensen@redhat.com>
        Date:   Tue Dec 7 17:44:34 2010 +0100
      
          qemu-img: Deprecate obsolete -6 and -e options
      
      Except this was never actually a deprecation, which would imply giving
      the user a warning while the functionality continues to work for a
      number of releases before eventual removal. Instead the options were
      immediately turned into an error + exit. Given that the functionality
      is already broken, there's no point in keeping these psuedo-deprecation
      messages around any longer.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6b4df548
  13. 26 6月, 2017 2 次提交
  14. 29 5月, 2017 5 次提交
  15. 23 5月, 2017 1 次提交
  16. 11 5月, 2017 1 次提交