qemu-kvm/SOURCES/kvm-block-backend-Set-werror-rerror-defaults-in-blk_new.patch

70 lines
2.5 KiB
Diff

From d0bc458b5072ac0e7ee4d27431d5f614f8dd4328 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Thu, 6 Dec 2018 17:12:39 +0000
Subject: [PATCH 14/15] block-backend: Set werror/rerror defaults in blk_new()
RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <20181206171240.5674-15-kwolf@redhat.com>
Patchwork-id: 83291
O-Subject: [RHEL-8.0 qemu-kvm PATCH 14/15] block-backend: Set werror/rerror defaults in blk_new()
Bugzilla: 1657637
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: John Snow <jsnow@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
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>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
(cherry picked from commit cb53460b708db3617ab73248374d071d5552c263)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
block/block-backend.c | 3 +++
tests/qemu-iotests/067.out | 1 +
2 files changed, 4 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index 91abfe6..7ae5832 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);
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
index 2e71cff..b10c71d 100644
--- a/tests/qemu-iotests/067.out
+++ b/tests/qemu-iotests/067.out
@@ -385,6 +385,7 @@ Testing: -device virtio-scsi -device scsi-cd,id=cd0
{
"return": [
{
+ "io-status": "ok",
"device": "",
"locked": false,
"removable": true,
--
1.8.3.1