[Qemu-devel] [PATCH] block-backend: Set werror/rerror defaults in blk_new()

Kevin Wolf posted 1 patch 7 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180928091840.8617-1-kwolf@redhat.com
Test docker-clang@ubuntu failed
Test checkpatch passed
block/block-backend.c | 3 +++
1 file changed, 3 insertions(+)
[Qemu-devel] [PATCH] block-backend: Set werror/rerror defaults in blk_new()
Posted by Kevin Wolf 7 years, 1 month ago
Currently, the default values for werror and rerror have to be set
explicitly with blk_set_on_error() by the callers of blk_new(). The only
caller actually doing this is blockdev_init(), which is called for
BlockBackends created using -drive.

In particular, anonymous BlockBackends created with
-device ...,drive=<node-name> didn't get the correct default set and
instead defaulted to the integer value 0 (= BLOCKDEV_ON_ERROR_REPORT).
This is the intended default for rerror anyway, but the default for
werror should be BLOCKDEV_ON_ERROR_ENOSPC.

Set the defaults in blk_new() instead so that they apply no matter what
way the BlockBackend was created.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/block-backend.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/block-backend.c b/block/block-backend.c
index 7b1ec5071b..dc0cd57724 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -325,6 +325,9 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
     blk->shared_perm = shared_perm;
     blk_set_enable_write_cache(blk, true);
 
+    blk->on_read_error = BLOCKDEV_ON_ERROR_REPORT;
+    blk->on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
+
     block_acct_init(&blk->stats);
 
     notifier_list_init(&blk->remove_bs_notifiers);
-- 
2.13.6


Re: [Qemu-devel] [PATCH] block-backend: Set werror/rerror defaults in blk_new()
Posted by Eric Blake 7 years, 1 month ago
On 9/28/18 4:18 AM, Kevin Wolf wrote:
> Currently, the default values for werror and rerror have to be set
> explicitly with blk_set_on_error() by the callers of blk_new(). The only
> caller actually doing this is blockdev_init(), which is called for
> BlockBackends created using -drive.
> 
> In particular, anonymous BlockBackends created with
> -device ...,drive=<node-name> didn't get the correct default set and
> instead defaulted to the integer value 0 (= BLOCKDEV_ON_ERROR_REPORT).
> This is the intended default for rerror anyway, but the default for
> werror should be BLOCKDEV_ON_ERROR_ENOSPC.
> 
> Set the defaults in blk_new() instead so that they apply no matter what
> way the BlockBackend was created.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block/block-backend.c | 3 +++
>   1 file changed, 3 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 7b1ec5071b..dc0cd57724 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -325,6 +325,9 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
>       blk->shared_perm = shared_perm;
>       blk_set_enable_write_cache(blk, true);
>   
> +    blk->on_read_error = BLOCKDEV_ON_ERROR_REPORT;
> +    blk->on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
> +
>       block_acct_init(&blk->stats);
>   
>       notifier_list_init(&blk->remove_bs_notifiers);
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [Qemu-stable] [PATCH] block-backend: Set werror/rerror defaults in blk_new()
Posted by Fam Zheng 7 years, 1 month ago
On Fri, Sep 28, 2018 at 5:32 PM Kevin Wolf <kwolf@redhat.com> wrote:
>
> Currently, the default values for werror and rerror have to be set
> explicitly with blk_set_on_error() by the callers of blk_new(). The only
> caller actually doing this is blockdev_init(), which is called for
> BlockBackends created using -drive.
>
> In particular, anonymous BlockBackends created with
> -device ...,drive=<node-name> didn't get the correct default set and
> instead defaulted to the integer value 0 (= BLOCKDEV_ON_ERROR_REPORT).
> This is the intended default for rerror anyway, but the default for
> werror should be BLOCKDEV_ON_ERROR_ENOSPC.
>
> Set the defaults in blk_new() instead so that they apply no matter what
> way the BlockBackend was created.
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/block-backend.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 7b1ec5071b..dc0cd57724 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -325,6 +325,9 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
>      blk->shared_perm = shared_perm;
>      blk_set_enable_write_cache(blk, true);
>
> +    blk->on_read_error = BLOCKDEV_ON_ERROR_REPORT;
> +    blk->on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
> +
>      block_acct_init(&blk->stats);
>
>      notifier_list_init(&blk->remove_bs_notifiers);
> --
> 2.13.6
>
>

Reviewed-by: Fam Zheng <famz@redhat.com>