1. 23 9月, 2016 1 次提交
    • F
      util: Add UUID API · cea25275
      Fam Zheng 提交于
      A number of different places across the code base use CONFIG_UUID. Some
      of them are soft dependency, some are not built if libuuid is not
      available, some come with dummy fallback, some throws runtime error.
      
      It is hard to maintain, and hard to reason for users.
      
      Since UUID is a simple standard with only a small number of operations,
      it is cleaner to have a central support in libqemuutil. This patch adds
      qemu_uuid_* functions that all uuid users in the code base can
      rely on. Except for qemu_uuid_generate which is new code, all other
      functions are just copy from existing fallbacks from other files.
      
      Note that qemu_uuid_parse is moved without updating the function
      signature to use QemuUUID, to keep this patch simple.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJeff Cody <jcody@redhat.com>
      Message-Id: <1474432046-325-2-git-send-email-famz@redhat.com>
      cea25275
  2. 21 9月, 2016 1 次提交
  3. 20 7月, 2016 2 次提交
  4. 19 7月, 2016 2 次提交
    • P
      block/iscsi: allow caching of the allocation map · e1123a3b
      Peter Lieven 提交于
      until now the allocation map was used only as a hint if a cluster
      is allocated or not. If a block was not allocated (or Qemu had
      no info about the allocation status) a get_block_status call was
      issued to check the allocation status and possibly avoid
      a subsequent read of unallocated sectors. If a block known to be
      allocated the get_block_status call was omitted. In the other case
      a get_block_status call was issued before every read to avoid
      the necessity for a consistent allocation map. To avoid the
      potential overhead of calling get_block_status for each and
      every read request this took only place for the bigger requests.
      
      This patch enhances this mechanism to cache the allocation
      status and avoid calling get_block_status for blocks where
      the allocation status has been queried before. This allows
      for bypassing the read request even for smaller requests and
      additionally omits calling get_block_status for known to be
      unallocated blocks.
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Message-Id: <1468831940-15556-3-git-send-email-pl@kamp.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e1123a3b
    • P
      block/iscsi: fix rounding in iscsi_allocationmap_set · eb36b953
      Peter Lieven 提交于
      when setting clusters as alloacted the boundaries have
      to be expanded. As Paolo pointed out the calculation of
      the number of clusters is wrong:
      
      Suppose cluster_sectors is 2, sector_num = 1, nb_sectors = 6:
      
      In the "mark allocated" case, you want to set 0..8, i.e.
      cluster_num=0, nb_clusters=4.
      
         0--.--2--.--4--.--6--.--8
         <--|_________________|-->  (<--> = expanded)
      
      Instead you are setting nb_clusters=3, so that 6..8 is not marked.
      
         0--.--2--.--4--.--6--.--8
         <--|______________|!!!     (! = wrong)
      
      Cc: qemu-stable@nongnu.org
      Reported-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Message-Id: <1468831940-15556-2-git-send-email-pl@kamp.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      eb36b953
  5. 13 7月, 2016 1 次提交
    • P
      coroutine: move entry argument to qemu_coroutine_create · 0b8b8753
      Paolo Bonzini 提交于
      In practice the entry argument is always known at creation time, and
      it is confusing that sometimes qemu_coroutine_enter is used with a
      non-NULL argument to re-enter a coroutine (this happens in
      block/sheepdog.c and tests/test-coroutine.c).  So pass the opaque value
      at creation time, for consistency with e.g. aio_bh_new.
      
      Mostly done with the following semantic patch:
      
      @ entry1 @
      expression entry, arg, co;
      @@
      - co = qemu_coroutine_create(entry);
      + co = qemu_coroutine_create(entry, arg);
        ...
      - qemu_coroutine_enter(co, arg);
      + qemu_coroutine_enter(co);
      
      @ entry2 @
      expression entry, arg;
      identifier co;
      @@
      - Coroutine *co = qemu_coroutine_create(entry);
      + Coroutine *co = qemu_coroutine_create(entry, arg);
        ...
      - qemu_coroutine_enter(co, arg);
      + qemu_coroutine_enter(co);
      
      @ entry3 @
      expression entry, arg;
      @@
      - qemu_coroutine_enter(qemu_coroutine_create(entry), arg);
      + qemu_coroutine_enter(qemu_coroutine_create(entry, arg));
      
      @ reentry @
      expression co;
      @@
      - qemu_coroutine_enter(co, NULL);
      + qemu_coroutine_enter(co);
      
      except for the aforementioned few places where the semantic patch
      stumbled (as expected) and for test_co_queue, which would otherwise
      produce an uninitialized variable warning.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0b8b8753
  6. 12 7月, 2016 1 次提交
  7. 05 7月, 2016 6 次提交
  8. 29 6月, 2016 1 次提交
  9. 08 6月, 2016 3 次提交
    • E
      iscsi: Convert to bdrv_co_pwrite_zeroes() · 94d047a3
      Eric Blake 提交于
      Another step on our continuing quest to switch to byte-based
      interfaces.
      
      As this is the first byte-based iscsi interface, convert
      is_request_lun_aligned() into two versions, one for sectors
      and one for bytes.  Also, change from outright -EINVAL failure
      on an unaligned request, to instead failing with -ENOTSUP to
      trigger a read-modify-write fallback, particularly since the
      block layer should be honoring bs->request_alignment to avoid
      -EINVAL on read/write requests.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      94d047a3
    • E
      block: Track write zero limits in bytes · cf081fca
      Eric Blake 提交于
      Another step towards removing sector-based interfaces: convert
      the maximum write and minimum alignment values from sectors to
      bytes.  Rename the variables to let the compiler check that all
      users are converted to the new semantics.
      
      The maximum remains an int as long as BDRV_REQUEST_MAX_SECTORS
      is constrained by INT_MAX (this means that we can't even
      support a 2G write_zeroes, but just under it) - changing
      operation lengths to unsigned or to 64-bits is a much bigger
      audit, and debatable if we even want to do it (since at the
      core, a 32-bit platform will still have ssize_t as its
      underlying limit on write()).
      
      Meanwhile, alignment is changed to 'uint32_t', since it makes no
      sense to have an alignment larger than the maximum write, and
      less painful to use an unsigned type with well-defined behavior
      in bit operations than to have to worry about what happens if
      a driver mistakenly supplies a negative alignment.
      
      Add an assert that no one was trying to use sectors to get a
      write zeroes larger than 2G, and therefore that a later conversion
      to bytes won't be impacted by keeping the limit at 32 bits.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      cf081fca
    • E
      iscsi: Use block size as minimum zero/discard alignment · 8b184744
      Eric Blake 提交于
      If hardware does not advertise a minimum zero/discard
      alignment, we still want to guarantee that the block layer
      will align requests to our blocks, rather than the arbitrary
      512-byte BDRV sector size.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8b184744
  10. 29 5月, 2016 1 次提交
  11. 23 5月, 2016 1 次提交
  12. 12 5月, 2016 3 次提交
    • E
      block: Honor BDRV_REQ_FUA during write_zeroes · 465fe887
      Eric Blake 提交于
      The block layer has a couple of cases where it can lose
      Force Unit Access semantics when writing a large block of
      zeroes, such that the request returns before the zeroes
      have been guaranteed to land on underlying media.
      
      SCSI does not support FUA during WRITESAME(10/16); FUA is only
      supported if it falls back to WRITE(10/16).  But where the
      underlying device is new enough to not need a fallback, it
      means that any upper layer request with FUA semantics was
      silently ignoring BDRV_REQ_FUA.
      
      Conversely, NBD has situations where it can support FUA but not
      ZERO_WRITE; when that happens, the generic block layer fallback
      to bdrv_driver_pwritev() (or the older bdrv_co_writev() in qemu
      2.6) was losing the FUA flag.
      
      The problem of losing flags unrelated to ZERO_WRITE has been
      latent in bdrv_co_do_write_zeroes() since commit aa7bfbff, but
      back then, it did not matter because there was no FUA flag.  It
      became observable when commit 93f5e6d8 paved the way for flags
      that can impact correctness, when we should have been using
      bdrv_co_writev_flags() with modified flags.  Compare to commit
      9eeb6dd1, which got flag manipulation right in
      bdrv_co_do_zero_pwritev().
      
      Symptoms: I tested with qemu-io with default writethrough cache
      (which is supposed to use FUA semantics on every write), and
      targetted an NBD client connected to a server that intentionally
      did not advertise NBD_FLAG_SEND_FUA.  When doing 'write 0 512',
      the NBD client sent two operations (NBD_CMD_WRITE then
      NBD_CMD_FLUSH) to get the fallback FUA semantics; but when doing
      'write -z 0 512', the NBD client sent only NBD_CMD_WRITE.
      
      The fix is do to a cleanup bdrv_co_flush() at the end of the
      operation if any step in the middle relied on a BDS that does
      not natively support FUA for that step (note that we don't
      need to flush after every operation, if the operation is broken
      into chunks based on bounce-buffer sizing).  Each BDS gains a
      new flag .supported_zero_flags, which parallels the use of
      .supported_write_flags but only when accessing a zero write
      operation (the flags MUST be different, because of SCSI having
      different semantics based on WRITE vs. WRITESAME; and also
      because BDRV_REQ_MAY_UNMAP only makes sense on zero writes).
      
      Also fix some documentation to describe -ENOTSUP semantics,
      particularly since iscsi depends on those semantics.
      
      Down the road, we may want to add a driver where its
      .bdrv_co_pwritev() honors all three of BDRV_REQ_FUA,
      BDRV_REQ_ZERO_WRITE, and BDRV_REQ_MAY_UNMAP, and advertise
      this via bs->supported_write_flags for blocks opened by that
      driver; such a driver should NOT supply .bdrv_co_write_zeroes
      nor .supported_zero_flags.  But none of the drivers touched
      in this patch want to do that (the act of writing zeroes is
      different enough from normal writes to deserve a second
      callback).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      465fe887
    • E
      block: Make supported_write_flags a per-bds property · 4df863f3
      Eric Blake 提交于
      Pre-patch, .supported_write_flags lives at the driver level, which
      means we are blindly declaring that all block devices using a
      given driver will either equally support FUA, or that we need a
      fallback at the block layer.  But there are drivers where FUA
      support is a per-block decision: the NBD block driver is dependent
      on the remote server advertising NBD_FLAG_SEND_FUA (and has
      fallback code to duplicate the flush that the block layer would do
      if NBD had not set .supported_write_flags); and the iscsi block
      driver is dependent on the mode sense bits advertised by the
      underlying device (and is currently silently ignoring FUA requests
      if the underlying device does not support FUA).
      
      The fix is to make supported flags as a per-BDS option, set during
      .bdrv_open().  This patch moves the variable and fixes NBD and iscsi
      to set it only conditionally; later patches will then further
      simplify the NBD driver to quit duplicating work done at the block
      layer, as well as tackle the fact that SCSI does not support FUA
      semantics on WRITESAME(10/16) but only on WRITE(10/16).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      4df863f3
    • K
      block: Introduce bdrv_driver_pwritev() · 78a07294
      Kevin Wolf 提交于
      This is a function that simply calls into the block driver for doing a
      write, providing the byte granularity interface we want to eventually
      have everywhere, and using whatever interface that driver supports.
      
      This one is a bit more interesting than the version for reads: It adds
      support for .bdrv_co_writev_flags() everywhere, so that drivers
      implementing this function can drop .bdrv_co_writev() now.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      78a07294
  13. 30 3月, 2016 2 次提交
  14. 01 3月, 2016 1 次提交
  15. 03 2月, 2016 2 次提交
  16. 20 1月, 2016 1 次提交
  17. 16 1月, 2016 1 次提交
    • Z
      iscsi: send readcapacity10 when readcapacity16 failed · 1cb6d137
      Zhu Lingshan 提交于
      When play with Dell MD3000 target, for sure it
      is a TYPE_DISK, but readcapacity16 would fail.
      Then we find that readcapacity10 succeeded. It
      looks like the target just support readcapacity10
      even through it is a TYPE_DISK or have some
      TYPE_ROM characteristics.
      
      This patch can give a chance to send
      readcapacity16 when readcapacity10 failed.
      This patch is not harmful to original pathes
      Signed-off-by: NZhu Lingshan <lszhu@suse.com>
      Message-Id: <1451359934-9236-1-git-send-email-lszhu@suse.com>
      [Don't fall through on UNIT ATTENTION. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      1cb6d137
  18. 11 1月, 2016 1 次提交
  19. 12 11月, 2015 2 次提交
  20. 05 11月, 2015 1 次提交
    • F
      iscsi: Translate scsi sense into error code · e01dd3da
      Fam Zheng 提交于
      Previously we return -EIO blindly when anything goes wrong. Add a helper
      function to parse sense fields and try to make the return code more
      meaningful.
      
      This also fixes the default werror configuration (enospc) when we're
      using qcow2 on an iscsi lun. The old -EIO not being treated as out of
      space error failed to trigger vm stop.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Message-Id: <1446699609-11376-1-git-send-email-famz@redhat.com>
      [libiscsi 1.9 compatibility - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e01dd3da
  21. 24 10月, 2015 1 次提交
  22. 08 9月, 2015 1 次提交
  23. 02 7月, 2015 2 次提交
    • P
      block/iscsi: restore compatiblity with libiscsi 1.9.0 · 9049736e
      Peter Lieven 提交于
      RHEL7 and others are stuck with libiscsi 1.9.0 since there
      unfortunately was an ABI breakage after that release.
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1435313881-19366-1-git-send-email-pl@kamp.de
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      9049736e
    • P
      block/iscsi: add support for request timeouts · 5dd7a535
      Peter Lieven 提交于
      libiscsi starting with 1.15 will properly support timeout of iscsi
      commands. The default will remain no timeout, but this can
      be changed via cmdline parameters, e.g.:
      
      qemu -iscsi timeout=30 -drive file=iscsi://...
      
      If a timeout occurs a reconnect is scheduled and the timed out command
      will be requeued for processing after a successful reconnect.
      
      The required API call iscsi_set_timeout is present since libiscsi
      1.10 which was released in October 2013. However, due to some bugs
      in the libiscsi code the use is not recommended before version 1.15.
      
      Please note that this patch bumps the libiscsi requirement to 1.10
      to have all function and macros defined. The patch fixes also a
      off-by-one error in the NOP timeout calculation which was fixed
      while touching these code parts.
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Message-id: 1434455107-19328-1-git-send-email-pl@kamp.de
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      5dd7a535
  24. 23 6月, 2015 2 次提交