1. 23 5月, 2018 7 次提交
  2. 20 5月, 2018 1 次提交
  3. 15 5月, 2018 2 次提交
    • M
      qemu-img: Use only string options in img_open_opts · 4615f878
      Max Reitz 提交于
      img_open_opts() takes a QemuOpts and converts them to a QDict, so all
      values therein are strings.  Then it may try to call qdict_get_bool(),
      however, which will fail with a segmentation fault every time:
      
      $ ./qemu-img info -U --image-opts \
          driver=file,filename=/dev/null,force-share=off
      [1]    27869 segmentation fault (core dumped)  ./qemu-img info -U
      --image-opts driver=file,filename=/dev/null,force-share=off
      
      Fix this by using qdict_get_str() and comparing the value as a string.
      Also, when adding a force-share value to the QDict, add it as a string
      so it fits the rest of the dict.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20180502202051.15493-3-mreitz@redhat.com
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      4615f878
    • M
      qemu-img: Check post-truncation size · 5279b303
      Max Reitz 提交于
      Some block drivers (iscsi and file-posix when dealing with device files)
      do not actually support truncation, even though they provide a
      .bdrv_truncate() method and will happily return success when providing a
      new size that does not exceed the current size.  This is because these
      drivers expect the user to resize the image outside of qemu and then
      provide qemu with that information through the block_resize command
      (compare cb1b83e7).
      
      Of course, anyone using qemu-img resize will find that behavior useless.
      So we should check the actual size of the image after the supposedly
      successful truncation took place, emit an error if nothing changed and
      emit a warning if the target size was not met.
      
      Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1523065Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20180421163957.29872-1-mreitz@redhat.com
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      5279b303
  4. 04 5月, 2018 1 次提交
  5. 12 3月, 2018 1 次提交
    • T
      Polish the version strings containing the package version · 7e563bfb
      Thomas Huth 提交于
      Since commit 67a1de0d there is no space anymore between the
      version number and the parentheses when running configure with
      --with-pkgversion=foo :
      
       $ qemu-system-s390x --version
       QEMU emulator version 2.11.50(foo)
      
      But the space is included when building without that option
      when building from a git checkout:
      
       $ qemu-system-s390x --version
       QEMU emulator version 2.11.50 (v2.11.0-1494-gbec9c64e-dirty)
      
      The same confusion exists with the "query-version" QMP command.
      Let's fix this by introducing a proper QEMU_FULL_VERSION definition
      that includes the space and parentheses, while the QEMU_PKGVERSION
      should just cleanly contain the package version string itself.
      Note that this also changes the behavior of the "query-version" QMP
      command (the space and parentheses are not included there anymore),
      but that's supposed to be OK since the strings there are not meant
      to be parsed by other tools.
      
      Fixes: 67a1de0d
      Buglink: https://bugs.launchpad.net/qemu/+bug/1673373Signed-off-by: NThomas Huth <thuth@redhat.com>
      Message-Id: <1518692807-25859-1-git-send-email-thuth@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7e563bfb
  6. 03 3月, 2018 2 次提交
  7. 09 2月, 2018 4 次提交
  8. 08 2月, 2018 1 次提交
  9. 21 11月, 2017 1 次提交
  10. 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
  11. 26 9月, 2017 1 次提交
  12. 04 9月, 2017 3 次提交
  13. 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
  14. 24 7月, 2017 1 次提交
  15. 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
  16. 12 7月, 2017 1 次提交