1. 08 3月, 2019 1 次提交
    • A
      block: iterate_format with account of whitelisting · 9ac404c5
      Andrey Shinkevich 提交于
      bdrv_iterate_format (which is currently only used for printing out the
      formats supported by the block layer) doesn't take format whitelisting
      into account.
      
      This creates a problem for tests: they enumerate supported formats to
      decide which tests to enable, but then discover that QEMU doesn't let
      them actually use some of those formats.
      
      To avoid that, exclude formats that are not whitelisted from
      enumeration, if whitelisting is in use.  Since we have separate
      whitelists for r/w and r/o, take this a parameter to
      bdrv_iterate_format, and print two lists of supported formats (r/w and
      r/o) in main qemu.
      Signed-off-by: NRoman Kagan <rkagan@virtuozzo.com>
      Signed-off-by: NAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      9ac404c5
  2. 25 2月, 2019 4 次提交
    • M
      block: bdrv_get_full_backing_filename_from_...'s ret. val. · 645ae7d8
      Max Reitz 提交于
      Make bdrv_get_full_backing_filename_from_filename() return an allocated
      string instead of placing the result in a caller-provided buffer.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20190201192935.18394-11-mreitz@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      645ae7d8
    • M
      block: Use bdrv_refresh_filename() to pull · f30c66ba
      Max Reitz 提交于
      Before this patch, bdrv_refresh_filename() is used in a pushing manner:
      Whenever the BDS graph is modified, the parents of the modified edges
      are supposed to be updated (recursively upwards).  However, that is
      nonviable, considering that we want child changes not to concern
      parents.
      
      Also, in the long run we want a pull model anyway: Here, we would have a
      bdrv_filename() function which returns a BDS's filename, freshly
      constructed.
      
      This patch is an intermediate step.  It adds bdrv_refresh_filename()
      calls before every place a BDS.filename value is used.  The only
      exceptions are protocol drivers that use their own filename, which
      clearly would not profit from refreshing that filename before.
      
      Also, bdrv_get_encrypted_filename() is removed along the way (as a user
      of BDS.filename), since it is completely unused.
      
      In turn, all of the calls to bdrv_refresh_filename() before this patch
      are removed, because we no longer have to call this function on graph
      changes.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20190201192935.18394-2-mreitz@redhat.com
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      f30c66ba
    • D
      qemu-img: fix error reporting for -object · 334c43e2
      Daniel P. Berrangé 提交于
      Error reporting for user_creatable_add_opts_foreach was changed so that
      it no longer called 'error_report_err' in:
      
        commit 7e1e0c11
        Author: Markus Armbruster <armbru@redhat.com>
        Date:   Wed Oct 17 10:26:43 2018 +0200
      
          qom: Clean up error reporting in user_creatable_add_opts_foreach()
      
      Some callers were updated to pass in "&error_fatal" but all the ones in
      qemu-img were left passing NULL. As a result all errors went to
      /dev/null instead of being reported to the user.
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NStefano Garzarella <sgarzare@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      334c43e2
    • D
      block/snapshot: remove bdrv_snapshot_delete_by_id_or_name · 8c04093c
      Daniel Henrique Barboza 提交于
      After the previous patch, the only instance of this function left
      is inside qemu-img.c.
      
      qemu-img is using it inside the 'img_snapshot' function to delete
      snapshots in the SNAPSHOT_DELETE case, based on a "snapshot_name"
      string that refers to the tag, not ID, of the QEMUSnapshotInfo struct.
      This can be verified by checking the SNAPSHOT_CREATE case that
      comes shortly before SNAPSHOT_DELETE. In that case, the same
      "snapshot_name" variable is being strcpy to the 'name' field
      of the QEMUSnapshotInfo struct sn:
      
      pstrcpy(sn.name, sizeof(sn.name), snapshot_name);
      
      Based on that, it is unlikely that "snapshot_name" might contain
      an "id" in SNAPSHOT_DELETE.
      
      This patch changes SNAPSHOT_DELETE to use snapshot_find() and
      snapshot_delete() instead of bdrv_snapshot_delete_by_id_or_name.
      After that, there is no instances left of bdrv_snapshot_delete_by_id_or_name
      in the code, so it is safe to remove it entirely.
      Suggested-by: NMurilo Opsfelder Araujo <muriloo@linux.ibm.com>
      Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8c04093c
  3. 22 2月, 2019 1 次提交
  4. 31 1月, 2019 1 次提交
    • R
      qemu-io: Add generic function for reinitializing optind. · d339d766
      Richard W.M. Jones 提交于
      On FreeBSD 11.2:
      
        $ nbdkit memory size=1M --run './qemu-io -f raw -c "aio_write 0 512" $nbd'
        Parsing error: non-numeric argument, or extraneous/unrecognized suffix -- aio_write
      
      After main option parsing, we reinitialize optind so we can parse each
      command.  However reinitializing optind to 0 does not work on FreeBSD.
      What happens when you do this is optind remains 0 after the option
      parsing loop, and the result is we try to parse argv[optind] ==
      argv[0] == "aio_write" as if it was the first parameter.
      
      The FreeBSD manual page says:
      
        In order to use getopt() to evaluate multiple sets of arguments, or to
        evaluate a single set of arguments multiple times, the variable optreset
        must be set to 1 before the second and each additional set of calls to
        getopt(), and the variable optind must be reinitialized.
      
      (From the rest of the man page it is clear that optind must be
      reinitialized to 1).
      
      The glibc man page says:
      
        A program that scans multiple argument vectors,  or  rescans  the  same
        vector  more than once, and wants to make use of GNU extensions such as
        '+' and '-' at  the  start  of  optstring,  or  changes  the  value  of
        POSIXLY_CORRECT  between scans, must reinitialize getopt() by resetting
        optind to 0, rather than the traditional value of 1.  (Resetting  to  0
        forces  the  invocation  of  an  internal  initialization  routine that
        rechecks POSIXLY_CORRECT and checks for GNU extensions in optstring.)
      
      This commit introduces an OS-portability function called
      qemu_reset_optind which provides a way of resetting optind that works
      on FreeBSD and platforms that use optreset, while keeping it the same
      as now on other platforms.
      
      Note that the qemu codebase sets optind in many other places, but in
      those other places it's setting a local variable and not using getopt.
      This change is only needed in places where we are using getopt and the
      associated global variable optind.
      Signed-off-by: NRichard W.M. Jones <rjones@redhat.com>
      Message-id: 20190118101114.11759-2-rjones@redhat.com
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      d339d766
  5. 21 11月, 2018 2 次提交
  6. 13 11月, 2018 1 次提交
  7. 05 11月, 2018 1 次提交
    • M
      option: Make option help nicer to read · 63898712
      Max Reitz 提交于
      This adds some whitespace into the option help (including indentation)
      and puts angle brackets around the type names.  Furthermore, the list
      name is no longer printed as part of every line, but only once in
      advance, and only if the caller did not print a caption already.
      
      This patch also restores the description alignment we had before commit
      9cbef9d6, just at 24 instead of 16 characters like we used to.
      This increase is because now we have the type and two spaces of
      indentation before the description, and with a usual type name length of
      three chracters, this sums up to eight additional characters -- which
      means that we now need 24 characters to get the same amount of padding
      for most options.  Also, 24 is a third of 80, which makes it kind of a
      round number in terminal terms.
      
      Finally, this patch amends the reference output of iotest 082 to match
      the changes (and thus makes it pass again).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      63898712
  8. 15 8月, 2018 1 次提交
    • D
      qemu-img: fix regression copying secrets during convert · 8d65a3cc
      Daniel P. Berrangé 提交于
      When the convert command is creating an output file that needs
      secrets, we need to ensure those secrets are passed to both the
      blk_new_open and bdrv_create API calls.
      
      This is done by qemu-img extracting all opts matching the name
      suffix "key-secret". Unfortunately the code doing this was run after the
      call to bdrv_create(), which meant the QemuOpts it was extracting
      secrets from was now empty.
      
      Previously this worked by luks as a bug meant the "key-secret"
      parameters were not purged from the QemuOpts. This bug was fixed in
      
        commit b76b4f60
        Author: Kevin Wolf <kwolf@redhat.com>
        Date:   Thu Jan 11 16:18:08 2018 +0100
      
          qcow2: Use visitor for options in qcow2_create()
      
      Exposing the latent bug in qemu-img. This fix simply moves the copying
      of secrets to before the bdrv_create() call.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8d65a3cc
  9. 30 7月, 2018 1 次提交
  10. 23 7月, 2018 1 次提交
    • P
      qemu-img: avoid overflow of min_sparse parameter · 6360ab27
      Peter Lieven 提交于
      the min_sparse convert parameter can overflow (e.g. -S 1024G)
      in the conversion from int64_t to int resulting in a negative
      min_sparse parameter. Avoid this by limiting the valid parameters
      to sane values. In fact anything exceeding the convert buffer size
      is also pointless. While at it also forbid values that are non
      multiple of 512 to avoid undesired behaviour. For instance, values
      between 1 and 511 were legal, but resulted in full allocation.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6360ab27
  11. 13 7月, 2018 1 次提交
    • P
      qemu-img: align result of is_allocated_sectors · 8dcd3c9b
      Peter Lieven 提交于
      We currently don't enforce that the sparse segments we detect during convert are
      aligned. This leads to unnecessary and costly read-modify-write cycles either
      internally in Qemu or in the background on the storage device as nearly all
      modern filesystems or hardware have a 4k alignment internally.
      
      This patch modifies is_allocated_sectors so that its *pnum result will always
      end at an alignment boundary. This way all requests will end at an alignment
      boundary. The start of all requests will also be aligned as long as the results
      of get_block_status do not lead to an unaligned offset.
      
      The number of RMW cycles when converting an example image [1] to a raw device that
      has 4k sector size is about 4600 4k read requests to perform a total of about 15000
      write requests. With this path the additional 4600 read requests are eliminated while
      the number of total write requests stays constant.
      
      [1] https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.vmdkSigned-off-by: NPeter Lieven <pl@kamp.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8dcd3c9b
  12. 10 7月, 2018 1 次提交
  13. 05 7月, 2018 1 次提交
  14. 15 6月, 2018 1 次提交
  15. 11 6月, 2018 8 次提交
  16. 01 6月, 2018 1 次提交
  17. 23 5月, 2018 7 次提交
  18. 20 5月, 2018 1 次提交
  19. 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
  20. 04 5月, 2018 1 次提交
  21. 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
  22. 03 3月, 2018 1 次提交