Skip to content
Snippets Groups Projects
  1. Oct 12, 2023
  2. Sep 29, 2023
  3. Feb 23, 2023
  4. Feb 01, 2023
    • Emanuele Giuseppe Esposito's avatar
      block: Convert bdrv_get_info() to co_wrapper_mixed · 3d47eb0a
      Emanuele Giuseppe Esposito authored
      
      bdrv_get_info() is categorized as an I/O function, and it currently
      doesn't run in a coroutine. We should let it take a graph rdlock since
      it traverses the block nodes graph, which however is only possible in a
      coroutine.
      
      Therefore turn it into a co_wrapper to move the actual function into a
      coroutine where the lock can be taken.
      
      Signed-off-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <20230113204212.359076-11-kwolf@redhat.com>
      Reviewed-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      3d47eb0a
    • Emanuele Giuseppe Esposito's avatar
      block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed · c86422c5
      Emanuele Giuseppe Esposito authored
      
      BlockDriver->bdrv_getlength is categorized as IO callback, and it
      currently doesn't run in a coroutine. We should let it take a graph
      rdlock since the callback traverses the block nodes graph, which however
      is only possible in a coroutine.
      
      Therefore turn it into a co_wrapper to move the actual function into a
      coroutine where the lock can be taken.
      
      Because now this function creates a new coroutine and polls, we need to
      take the AioContext lock where it is missing, for the only reason that
      internally co_wrapper calls AIO_WAIT_WHILE and it expects to release the
      AioContext lock.
      
      This is especially messy when a co_wrapper creates a coroutine and polls
      in bdrv_open_driver, because this function has so many callers in so
      many context that it can easily lead to deadlocks. Therefore the new
      rule for bdrv_open_driver is that the caller must always hold the
      AioContext lock of the given bs (except if it is a coroutine), because
      the function calls bdrv_refresh_total_sectors() which is now a
      co_wrapper.
      
      Once the rwlock is ultimated and placed in every place it needs to be,
      we will poll using AIO_WAIT_WHILE_UNLOCKED and remove the AioContext
      lock.
      
      Signed-off-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <20230113204212.359076-7-kwolf@redhat.com>
      Reviewed-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      c86422c5
  5. Jan 20, 2023
    • Markus Armbruster's avatar
      include/block: Untangle inclusion loops · e2c1c34f
      Markus Armbruster authored
      
      We have two inclusion loops:
      
             block/block.h
          -> block/block-global-state.h
          -> block/block-common.h
          -> block/blockjob.h
          -> block/block.h
      
             block/block.h
          -> block/block-io.h
          -> block/block-common.h
          -> block/blockjob.h
          -> block/block.h
      
      I believe these go back to Emanuele's reorganization of the block API,
      merged a few months ago in commit d7e2fe4a.
      
      Fortunately, breaking them is merely a matter of deleting unnecessary
      includes from headers, and adding them back in places where they are
      now missing.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20221221133551.3967339-2-armbru@redhat.com>
      e2c1c34f
  6. Dec 14, 2022
    • Markus Armbruster's avatar
      qapi block: Elide redundant has_FOO in generated C · 54fde4ff
      Markus Armbruster authored
      
      The has_FOO for pointer-valued FOO are redundant, except for arrays.
      They are also a nuisance to work with.  Recent commit "qapi: Start to
      elide redundant has_FOO in generated C" provided the means to elide
      them step by step.  This is the step for qapi/block*.json.
      
      Said commit explains the transformation in more detail.
      
      There is one instance of the invariant violation mentioned there:
      qcow2_signal_corruption() passes false, "" when node_name is an empty
      string.  Take care to pass NULL then.
      
      The previous two commits cleaned up two more.
      
      Additionally, helper bdrv_latency_histogram_stats() loses its output
      parameters and returns a value instead.
      
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Hanna Reitz <hreitz@redhat.com>
      Cc: qemu-block@nongnu.org
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20221104160712.3005652-11-armbru@redhat.com>
      [Fixes for #ifndef LIBRBD_SUPPORTS_ENCRYPTION and MacOS squashed in]
      54fde4ff
  7. Jun 24, 2022
    • Stefano Garzarella's avatar
      block/rbd: report a better error when namespace does not exist · 66dc5f96
      Stefano Garzarella authored
      
      If the namespace does not exist, rbd_create() fails with -ENOENT and
      QEMU reports a generic "error rbd create: No such file or directory":
      
          $ qemu-img create rbd:rbd/namespace/image 1M
          Formatting 'rbd:rbd/namespace/image', fmt=raw size=1048576
          qemu-img: rbd:rbd/namespace/image: error rbd create: No such file or directory
      
      Unfortunately rados_ioctx_set_namespace() does not fail if the namespace
      does not exist, so let's use rbd_namespace_exists() in qemu_rbd_connect()
      to check if the namespace exists, reporting a more understandable error:
      
          $ qemu-img create rbd:rbd/namespace/image 1M
          Formatting 'rbd:rbd/namespace/image', fmt=raw size=1048576
          qemu-img: rbd:rbd/namespace/image: namespace 'namespace' does not exist
      
      Reported-by: default avatarTingting Mao <timao@redhat.com>
      Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20220517071012.6120-1-sgarzare@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      66dc5f96
  8. Mar 22, 2022
  9. Feb 01, 2022
  10. Nov 02, 2021
    • Peter Lieven's avatar
      block/rbd: implement bdrv_co_block_status · 0347a8fd
      Peter Lieven authored
      
      the qemu rbd driver currently lacks support for bdrv_co_block_status.
      This results mainly in incorrect progress during block operations (e.g.
      qemu-img convert with an rbd image as source).
      
      This patch utilizes the rbd_diff_iterate2 call from librbd to detect
      allocated and unallocated (all zero areas).
      
      To avoid querying the ceph OSDs for the answer this is only done if
      the image has the fast-diff feature which depends on the object-map and
      exclusive-lock features. In this case it is guaranteed that the information
      is present in memory in the librbd client and thus very fast.
      
      If fast-diff is not available all areas are reported to be allocated
      which is the current behaviour if bdrv_co_block_status is not implemented.
      
      Signed-off-by: default avatarPeter Lieven <pl@kamp.de>
      Message-Id: <20211012152231.24868-1-pl@kamp.de>
      Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      0347a8fd
  11. Sep 29, 2021
    • Vladimir Sementsov-Ogievskiy's avatar
      block: use int64_t instead of int in driver discard handlers · 0c802287
      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 discard handlers bytes parameter to int64_t.
      
      The only caller of all updated function is bdrv_co_pdiscard in
      block/io.c. It is already prepared to work with 64bit requests, but
      pass at most max(bs->bl.max_pdiscard, INT_MAX) to the driver.
      
      Let's look at all updated functions:
      
      blkdebug: all calculations are still OK, thanks to
        bdrv_check_qiov_request().
        both rule_check and bdrv_co_pdiscard are 64bit
      
      blklogwrites: pass to blk_loc_writes_co_log which is 64bit
      
      blkreplay, copy-on-read, filter-compress: pass to bdrv_co_pdiscard, OK
      
      copy-before-write: pass to bdrv_co_pdiscard which is 64bit and to
        cbw_do_copy_before_write which is 64bit
      
      file-posix: one handler calls raw_account_discard() is 64bit and both
        handlers calls raw_do_pdiscard(). Update raw_do_pdiscard, which pass
        to RawPosixAIOData::aio_nbytes, which is 64bit (and calls
        raw_account_discard())
      
      gluster: somehow, third argument of glfs_discard_async is size_t.
        Let's set max_pdiscard accordingly.
      
      iscsi: iscsi_allocmap_set_invalid is 64bit,
        !is_byte_request_lun_aligned is 64bit.
        list.num is uint32_t. Let's clarify max_pdiscard and
        pdiscard_alignment.
      
      mirror_top: pass to bdrv_mirror_top_do_write() which is
        64bit
      
      nbd: protocol limitation. max_pdiscard is alredy set strict enough,
        keep it as is for now.
      
      nvme: buf.nlb is uint32_t and we do shift. So, add corresponding limits
        to nvme_refresh_limits().
      
      preallocate: pass to bdrv_co_pdiscard() which is 64bit.
      
      rbd: pass to qemu_rbd_start_co() which is 64bit.
      
      qcow2: calculations are still OK, thanks to bdrv_check_qiov_request(),
        qcow2_cluster_discard() is 64bit.
      
      raw-format: raw_adjust_offset() is 64bit, bdrv_co_pdiscard too.
      
      throttle: pass to bdrv_co_pdiscard() which is 64bit and to
        throttle_group_co_io_limits_intercept() which is 64bit as well.
      
      test-block-iothread: bytes argument is unused
      
      Great! Now all drivers are prepared to handle 64bit discard requests,
      or else have explicit max_pdiscard limits.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20210903102807.27127-11-vsementsov@virtuozzo.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      0c802287
    • Vladimir Sementsov-Ogievskiy's avatar
      block: use int64_t instead of int in driver write_zeroes handlers · f34b2bcf
      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 write_zeroes handlers bytes parameter to int64_t.
      
      The only caller of all updated function is bdrv_co_do_pwrite_zeroes().
      
      bdrv_co_do_pwrite_zeroes() itself is of course OK with widening of
      callee parameter type. Also, bdrv_co_do_pwrite_zeroes()'s
      max_write_zeroes is limited to INT_MAX. So, updated functions all are
      safe, they will not get "bytes" larger than before.
      
      Still, let's look through all updated functions, and add assertions to
      the ones which are actually unprepared to values larger than INT_MAX.
      For these drivers also set explicit max_pwrite_zeroes limit.
      
      Let's go:
      
      blkdebug: calculations can't overflow, thanks to
        bdrv_check_qiov_request() in generic layer. rule_check() and
        bdrv_co_pwrite_zeroes() both have 64bit argument.
      
      blklogwrites: pass to blk_log_writes_co_log() with 64bit argument.
      
      blkreplay, copy-on-read, filter-compress: pass to
        bdrv_co_pwrite_zeroes() which is OK
      
      copy-before-write: Calls cbw_do_copy_before_write() and
        bdrv_co_pwrite_zeroes, both have 64bit argument.
      
      file-posix: both handler calls raw_do_pwrite_zeroes, which is updated.
        In raw_do_pwrite_zeroes() calculations are OK due to
        bdrv_check_qiov_request(), bytes go to RawPosixAIOData::aio_nbytes
        which is uint64_t.
        Check also where that uint64_t gets handed:
        handle_aiocb_write_zeroes_block() passes a uint64_t[2] to
        ioctl(BLKZEROOUT), handle_aiocb_write_zeroes() calls do_fallocate()
        which takes off_t (and we compile to always have 64-bit off_t), as
        does handle_aiocb_write_zeroes_unmap. All look safe.
      
      gluster: bytes go to GlusterAIOCB::size which is int64_t and to
        glfs_zerofill_async works with off_t.
      
      iscsi: Aha, here we deal with iscsi_writesame16_task() that has
        uint32_t num_blocks argument and iscsi_writesame16_task() has
        uint16_t argument. Make comments, add assertions and clarify
        max_pwrite_zeroes calculation.
        iscsi_allocmap_() functions already has int64_t argument
        is_byte_request_lun_aligned is simple to update, do it.
      
      mirror_top: pass to bdrv_mirror_top_do_write which has uint64_t
        argument
      
      nbd: Aha, here we have protocol limitation, and NBDRequest::len is
        uint32_t. max_pwrite_zeroes is cleanly set to 32bit value, so we are
        OK for now.
      
      nvme: Again, protocol limitation. And no inherent limit for
        write-zeroes at all. But from code that calculates cdw12 it's obvious
        that we do have limit and alignment. Let's clarify it. Also,
        obviously the code is not prepared to handle bytes=0. Let's handle
        this case too.
        trace events already 64bit
      
      preallocate: pass to handle_write() and bdrv_co_pwrite_zeroes(), both
        64bit.
      
      rbd: pass to qemu_rbd_start_co() which is 64bit.
      
      qcow2: offset + bytes and alignment still works good (thanks to
        bdrv_check_qiov_request()), so tail calculation is OK
        qcow2_subcluster_zeroize() has 64bit argument, should be OK
        trace events updated
      
      qed: qed_co_request wants int nb_sectors. Also in code we have size_t
        used for request length which may be 32bit. So, let's just keep
        INT_MAX as a limit (aligning it down to pwrite_zeroes_alignment) and
        don't care.
      
      raw-format: Is OK. raw_adjust_offset and bdrv_co_pwrite_zeroes are both
        64bit.
      
      throttle: Both throttle_group_co_io_limits_intercept() and
        bdrv_co_pwrite_zeroes() are 64bit.
      
      vmdk: pass to vmdk_pwritev which is 64bit
      
      quorum: pass to quorum_co_pwritev() which is 64bit
      
      Hooray!
      
      At this point all block drivers are prepared to support 64bit
      write-zero requests, or have explicitly set max_pwrite_zeroes.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20210903102807.27127-8-vsementsov@virtuozzo.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      [eblake: use <= rather than < in assertions relying on max_pwrite_zeroes]
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      f34b2bcf
    • Vladimir Sementsov-Ogievskiy's avatar
      block: use int64_t instead of uint64_t in driver write handlers · e75abeda
      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 write 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\)_pwritev\(_part\)\?'
      
      shows that's there three callers of driver function:
      
       bdrv_driver_pwritev() and bdrv_driver_pwritev_compressed() in
       block/io.c, both pass int64_t, checked by bdrv_check_qiov_request() to
       be non-negative.
      
       qcow2_save_vmstate() does bdrv_check_qiov_request().
      
      Still, the functions may be called directly, not only by drv->...
      Let's check:
      
      git grep '\.bdrv_\(aio\|co\)_pwritev\(_part\)\?\s*=' | \
      awk '{print $4}' | sed 's/,//' | sed 's/&//' | sort | uniq | \
      while read func; do git grep "$func(" | \
      grep -v "$func(BlockDriverState"; done
      
      shows several callers:
      
      qcow2:
        qcow2_co_truncate() write at most up to @offset, which is checked in
          generic qcow2_co_truncate() by bdrv_check_request().
        qcow2_co_pwritev_compressed_task() pass the request (or part of the
          request) that already went through normal write path, so it should
          be OK
      
      qcow:
        qcow_co_pwritev_compressed() pass int64_t, it's updated by this patch
      
      quorum:
        quorum_co_pwrite_zeroes() pass int64_t and int - OK
      
      throttle:
        throttle_co_pwritev_compressed() pass int64_t, it's updated by this
        patch
      
      vmdk:
        vmdk_co_pwritev_compressed() pass int64_t, it's updated by this
        patch
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20210903102807.27127-5-vsementsov@virtuozzo.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      e75abeda
    • 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
  12. Jul 09, 2021
  13. May 14, 2021
    • Connor Kuehl's avatar
      block/rbd: Add an escape-aware strchr helper · 2b99cfce
      Connor Kuehl authored
      
      Sometimes the parser needs to further split a token it has collected
      from the token input stream. Right now, it does a cursory check to see
      if the relevant characters appear in the token to determine if it should
      break it down further.
      
      However, qemu_rbd_next_tok() will escape characters as it removes tokens
      from the token stream and plain strchr() won't. This can make the
      initial strchr() check slightly misleading since it implies
      qemu_rbd_next_tok() will find the token and split on it, except the
      reality is that qemu_rbd_next_tok() will pass over it if it is escaped.
      
      Use a custom strchr to avoid mixing escaped and unescaped string
      operations. Furthermore, this code is identical to how
      qemu_rbd_next_tok() seeks its next token, so incorporate this custom
      strchr into the body of that function to reduce duplication.
      
      Reported-by: default avatarHan Han <hhan@redhat.com>
      Fixes: https://bugzilla.redhat.com/1873913
      
      
      Signed-off-by: default avatarConnor Kuehl <ckuehl@redhat.com>
      Message-Id: <20210421212343.85524-3-ckuehl@redhat.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      2b99cfce
  14. Apr 09, 2021
    • Stefano Garzarella's avatar
      block/rbd: fix memory leak in qemu_rbd_co_create_opts() · b084b420
      Stefano Garzarella authored
      
      When we allocate 'q_namespace', we forgot to set 'has_q_namespace'
      to true. This can cause several issues, including a memory leak,
      since qapi_free_BlockdevCreateOptions() does not deallocate that
      memory, as reported by valgrind:
      
        13 bytes in 1 blocks are definitely lost in loss record 7 of 96
           at 0x4839809: malloc (vg_replace_malloc.c:307)
           by 0x48CEBB8: g_malloc (in /usr/lib64/libglib-2.0.so.0.6600.8)
           by 0x48E3FE3: g_strdup (in /usr/lib64/libglib-2.0.so.0.6600.8)
           by 0x180010: qemu_rbd_co_create_opts (rbd.c:446)
           by 0x1AE72C: bdrv_create_co_entry (block.c:492)
           by 0x241902: coroutine_trampoline (coroutine-ucontext.c:173)
           by 0x57530AF: ??? (in /usr/lib64/libc-2.32.so)
           by 0x1FFEFFFA6F: ???
      
      Fix setting 'has_q_namespace' to true when we allocate 'q_namespace'.
      
      Fixes: 19ae9ae0 ("block/rbd: Add support for ceph namespaces")
      Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20210329150129.121182-3-sgarzare@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      b084b420
    • Stefano Garzarella's avatar
      block/rbd: fix memory leak in qemu_rbd_connect() · c1c1f6cf
      Stefano Garzarella authored
      
      In qemu_rbd_connect(), 'mon_host' is allocated by qemu_rbd_mon_host()
      using g_strjoinv(), but it's only freed in the error path, leaking
      memory in the success path as reported by valgrind:
      
        80 bytes in 4 blocks are definitely lost in loss record 5,028 of 6,516
           at 0x4839809: malloc (vg_replace_malloc.c:307)
           by 0x5315BB8: g_malloc (in /usr/lib64/libglib-2.0.so.0.6600.8)
           by 0x532B6FF: g_strjoinv (in /usr/lib64/libglib-2.0.so.0.6600.8)
           by 0x87D07E: qemu_rbd_mon_host (rbd.c:538)
           by 0x87D07E: qemu_rbd_connect (rbd.c:562)
           by 0x87E1CE: qemu_rbd_open (rbd.c:740)
           by 0x840EB1: bdrv_open_driver (block.c:1528)
           by 0x8453A9: bdrv_open_common (block.c:1802)
           by 0x8453A9: bdrv_open_inherit (block.c:3444)
           by 0x8464C2: bdrv_open (block.c:3537)
           by 0x8108CD: qmp_blockdev_add (blockdev.c:3569)
           by 0x8EA61B: qmp_marshal_blockdev_add (qapi-commands-block-core.c:1086)
           by 0x90B528: do_qmp_dispatch_bh (qmp-dispatch.c:131)
           by 0x907EA4: aio_bh_poll (async.c:164)
      
      Fix freeing 'mon_host' also when qemu_rbd_connect() ends correctly.
      
      Fixes: 0a55679b
      Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20210329150129.121182-2-sgarzare@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      c1c1f6cf
  15. Dec 19, 2020
    • Markus Armbruster's avatar
      qobject: Change qobject_to_json()'s value to GString · eab3a467
      Markus Armbruster authored
      
      qobject_to_json() and qobject_to_json_pretty() build a GString, then
      covert it to QString.  Just one of the callers actually needs a
      QString: qemu_rbd_parse_filename().  A few others need a string they
      can modify: qmp_send_response(), qga's send_response(), to_json_str(),
      and qmp_fd_vsend_fds().  The remainder just need a string.
      
      Change qobject_to_json() and qobject_to_json_pretty() to return the
      GString.
      
      qemu_rbd_parse_filename() now has to convert to QString.  All others
      save a QString temporary.  to_json_str() actually becomes a bit
      simpler, because GString provides more convenient modification
      functions.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-6-armbru@redhat.com>
      eab3a467
  16. Sep 15, 2020
  17. Jul 10, 2020
  18. May 08, 2020
  19. Apr 30, 2020
  20. Mar 26, 2020
  21. Mar 06, 2020
    • Florian Florensa's avatar
      block/rbd: Add support for ceph namespaces · 19ae9ae0
      Florian Florensa authored
      
      Starting from ceph Nautilus, RBD has support for namespaces, allowing
      for finer grain ACLs on images inside a pool, and tenant isolation.
      
      In the rbd cli tool documentation, the new image-spec and snap-spec are :
       - [pool-name/[namespace-name/]]image-name
       - [pool-name/[namespace-name/]]image-name@snap-name
      
      When using an non namespace's enabled qemu, it complains about not
      finding the image called namespace-name/image-name, thus we only need to
      parse the image once again to find if there is a '/' in its name, and if
      there is, use what is before it as the name of the namespace to later
      pass it to rados_ioctx_set_namespace.
      rados_ioctx_set_namespace if called with en empty string or a null
      pointer as the namespace parameters pretty much does nothing, as it then
      defaults to the default namespace.
      
      The namespace is extracted inside qemu_rbd_parse_filename, stored in the
      qdict, and used in qemu_rbd_connect to make it work with both qemu-img,
      and qemu itself.
      
      Signed-off-by: default avatarFlorian Florensa <fflorensa@online.net>
      Message-Id: <20200110111513.321728-2-fflorensa@online.net>
      Reviewed-by: default avatarJason Dillaman <dillaman@redhat.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      19ae9ae0
  22. Oct 28, 2019
    • Hanna Reitz's avatar
      block: Add @exact parameter to bdrv_co_truncate() · c80d8b06
      Hanna Reitz authored
      
      We have two drivers (iscsi and file-posix) that (in some cases) return
      success from their .bdrv_co_truncate() implementation if the block
      device is larger than the requested offset, but cannot be shrunk.  Some
      callers do not want that behavior, so this patch adds a new parameter
      that they can use to turn off that behavior.
      
      This patch just adds the parameter and lets the block/io.c and
      block/block-backend.c functions pass it around.  All other callers
      always pass false and none of the implementations evaluate it, so that
      this patch does not change existing behavior.  Future patches take care
      of that.
      
      Suggested-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20190918095144.955-5-mreitz@redhat.com
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      c80d8b06
Loading