Skip to content
Snippets Groups Projects
  1. Sep 29, 2021
    • Vladimir Sementsov-Ogievskiy's avatar
      block: use int64_t instead of uint64_t in driver read handlers · f7ef38dd
      Vladimir Sementsov-Ogievskiy authored
      
      We are generally moving to int64_t for both offset and bytes parameters
      on all io paths.
      
      Main motivation is realization of 64-bit write_zeroes operation for
      fast zeroing large disk chunks, up to the whole disk.
      
      We chose signed type, to be consistent with off_t (which is signed) and
      with possibility for signed return type (where negative value means
      error).
      
      So, convert driver read handlers parameters which are already 64bit to
      signed type.
      
      While being here, convert also flags parameter to be BdrvRequestFlags.
      
      Now let's consider all callers. Simple
      
        git grep '\->bdrv_\(aio\|co\)_preadv\(_part\)\?'
      
      shows that's there three callers of driver function:
      
       bdrv_driver_preadv() in block/io.c, passes int64_t, checked by
         bdrv_check_qiov_request() to be non-negative.
      
       qcow2_load_vmstate() does bdrv_check_qiov_request().
      
       do_perform_cow_read() has uint64_t argument. And a lot of things in
       qcow2 driver are uint64_t, so converting it is big job. But we must
       not work with requests that don't satisfy bdrv_check_qiov_request(),
       so let's just assert it here.
      
      Still, the functions may be called directly, not only by drv->...
      Let's check:
      
      git grep '\.bdrv_\(aio\|co\)_preadv\(_part\)\?\s*=' | \
      awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \
      while read func; do git grep "$func(" | \
      grep -v "$func(BlockDriverState"; done
      
      The only one such caller:
      
          QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, &data, 1);
          ...
          ret = bdrv_replace_test_co_preadv(bs, 0, 1, &qiov, 0);
      
      in tests/unit/test-bdrv-drain.c, and it's OK obviously.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20210903102807.27127-4-vsementsov@virtuozzo.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      [eblake: fix typos]
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      f7ef38dd
  2. Nov 09, 2020
  3. May 18, 2020
  4. Sep 16, 2019
  5. Jun 12, 2019
    • Markus Armbruster's avatar
      Include qemu-common.h exactly where needed · a8d25326
      Markus Armbruster authored
      
      No header includes qemu-common.h after this commit, as prescribed by
      qemu-common.h's file comment.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-5-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c
      block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c
      target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h
      target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h
      target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h
      target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and
      net/tap-bsd.c fixed up]
      a8d25326
  6. Jan 04, 2019
  7. Dec 14, 2018
  8. Nov 05, 2018
    • Kevin Wolf's avatar
      block: Require auto-read-only for existing fallbacks · eaa2410f
      Kevin Wolf authored
      
      Some block drivers have traditionally changed their node to read-only
      mode without asking the user. This behaviour has been marked deprecated
      since 2.11, expecting users to provide an explicit read-only=on option.
      
      Now that we have auto-read-only=on, enable these drivers to make use of
      the option.
      
      This is the only use of bdrv_set_read_only(), so we can make it a bit
      more specific and turn it into a bdrv_apply_auto_read_only() that is
      more convenient for drivers to use.
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      eaa2410f
  9. Nov 17, 2017
    • Kevin Wolf's avatar
      block: Deprecate bdrv_set_read_only() and users · 398e6ad0
      Kevin Wolf authored
      
      bdrv_set_read_only() is used by some block drivers to override the
      read-only option given by the user. This is not how read-only images
      generally work in QEMU: Instead of second guessing what the user really
      meant (which currently includes making an image read-only even if the
      user didn't only use the default, but explicitly said read-only=off), we
      should error out if we can't provide what the user requested.
      
      This adds deprecation warnings to all callers of bdrv_set_read_only() so
      that the behaviour can be corrected after the usual deprecation period.
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      398e6ad0
  10. Aug 31, 2017
  11. Apr 24, 2017
    • Jeff Cody's avatar
      block: do not set BDS read_only if copy_on_read enabled · e2b8247a
      Jeff Cody authored
      
      A few block drivers will set the BDS read_only flag from their
      .bdrv_open() function.  This means the bs->read_only flag could
      be set after we enable copy_on_read, as the BDRV_O_COPY_ON_READ
      flag check occurs prior to the call to bdrv->bdrv_open().
      
      This adds an error return to bdrv_set_read_only(), and an error will be
      return if we try to set the BDS to read_only while copy_on_read is
      enabled.
      
      This patch also changes the behavior of vvfat.  Before, vvfat could
      override the drive 'readonly' flag with its own, internal 'rw' flag.
      
      For instance, this -drive parameter would result in a writable image:
      
      "-drive format=vvfat,dir=/tmp/vvfat,rw,if=virtio,readonly=on"
      
      This is not correct.  Now, attempting to use the above -drive parameter
      will result in an error (i.e., 'rw' is incompatible with 'readonly=on').
      
      Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
      Message-id: 0c5b4c1cc2c651471b131f21376dfd5ea24d2196.1491597120.git.jcody@redhat.com
      e2b8247a
    • Jeff Cody's avatar
      block: add bdrv_set_read_only() helper function · fe5241bf
      Jeff Cody authored
      
      We have a helper wrapper for checking for the BDS read_only flag,
      add a helper wrapper to set the read_only flag as well.
      
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
      Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
      Message-id: 9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120.git.jcody@redhat.com
      fe5241bf
  12. Feb 28, 2017
  13. Feb 24, 2017
    • Kevin Wolf's avatar
      block: Attach bs->file only during .bdrv_open() · 4e4bf5c4
      Kevin Wolf authored
      
      The way that attaching bs->file worked was a bit unusual in that it was
      the only child that would be attached to a node which is not opened yet.
      Because of this, the block layer couldn't know yet which permissions the
      driver would eventually need.
      
      This patch moves the point where bs->file is attached to the beginning
      of the individual .bdrv_open() implementations, so drivers already know
      what they are going to do with the child. This is also more consistent
      with how driver-specific children work.
      
      For a moment, bdrv_open() gets its own BdrvChild to perform image
      probing, but instead of directly assigning this BdrvChild to the BDS, it
      becomes a temporary one and the node name is passed as an option to the
      drivers, so that they can simply use bdrv_open_child() to create another
      reference for their own use.
      
      This duplicated child for (the not opened yet) bs is not the final
      state, a follow-up patch will change the image probing code to use a
      BlockBackend, which is completely independent of bs.
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      4e4bf5c4
  14. Oct 07, 2016
    • Fam Zheng's avatar
      dmg: Move libbz2 code to dmg-bz2.so · 27685a8d
      Fam Zheng authored
      
      dmg.o was moved to block-obj-m in 5505e8b7 to become a separate module,
      so that its reference to libbz2, since 6b383c08, doesn't add an extra
      library to the main executable.
      
      Until recently, commit 06e60f70a (blockdev: Add dynamic module loading
      for block drivers) moved it back to block-obj-y to simplify the design
      of dynamic loading of block modules. But we don't want to lose the
      feature of less library dependency on the main executable.
      
      The solution here is to move only the bz2 related code to a separate
      DSO file, and load it when dmg_open is called.
      
      dmg_probe doesn't depend on bz2 support to work, and is the only code in
      this file which can run before dmg_open.
      
      While we are at it, fix the unhelpful cast of last argument passed to
      dmg_uncompress_bz2.
      
      Signed-off-by: default avatarFam Zheng <famz@redhat.com>
      Message-id: 1473043845-13197-4-git-send-email-famz@redhat.com
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      27685a8d
  15. Jul 05, 2016
  16. Jun 07, 2016
  17. May 12, 2016
  18. Mar 22, 2016
    • Markus Armbruster's avatar
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster authored
      
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  19. Jan 20, 2016
  20. Oct 16, 2015
  21. Jun 22, 2015
  22. Feb 06, 2015
Loading