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

ae23c9
From d0bc458b5072ac0e7ee4d27431d5f614f8dd4328 Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Thu, 6 Dec 2018 17:12:39 +0000
ae23c9
Subject: [PATCH 14/15] block-backend: Set werror/rerror defaults in blk_new()
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20181206171240.5674-15-kwolf@redhat.com>
ae23c9
Patchwork-id: 83291
ae23c9
O-Subject: [RHEL-8.0 qemu-kvm PATCH 14/15] block-backend: Set werror/rerror defaults in blk_new()
ae23c9
Bugzilla: 1657637
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
ae23c9
Currently, the default values for werror and rerror have to be set
ae23c9
explicitly with blk_set_on_error() by the callers of blk_new(). The only
ae23c9
caller actually doing this is blockdev_init(), which is called for
ae23c9
BlockBackends created using -drive.
ae23c9
ae23c9
In particular, anonymous BlockBackends created with
ae23c9
-device ...,drive=<node-name> didn't get the correct default set and
ae23c9
instead defaulted to the integer value 0 (= BLOCKDEV_ON_ERROR_REPORT).
ae23c9
This is the intended default for rerror anyway, but the default for
ae23c9
werror should be BLOCKDEV_ON_ERROR_ENOSPC.
ae23c9
ae23c9
Set the defaults in blk_new() instead so that they apply no matter what
ae23c9
way the BlockBackend was created.
ae23c9
ae23c9
Cc: qemu-stable@nongnu.org
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Reviewed-by: Eric Blake <eblake@redhat.com>
ae23c9
Reviewed-by: Fam Zheng <famz@redhat.com>
ae23c9
(cherry picked from commit cb53460b708db3617ab73248374d071d5552c263)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 block/block-backend.c      | 3 +++
ae23c9
 tests/qemu-iotests/067.out | 1 +
ae23c9
 2 files changed, 4 insertions(+)
ae23c9
ae23c9
diff --git a/block/block-backend.c b/block/block-backend.c
ae23c9
index 91abfe6..7ae5832 100644
ae23c9
--- a/block/block-backend.c
ae23c9
+++ b/block/block-backend.c
ae23c9
@@ -325,6 +325,9 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
ae23c9
     blk->shared_perm = shared_perm;
ae23c9
     blk_set_enable_write_cache(blk, true);
ae23c9
 
ae23c9
+    blk->on_read_error = BLOCKDEV_ON_ERROR_REPORT;
ae23c9
+    blk->on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
ae23c9
+
ae23c9
     block_acct_init(&blk->stats);
ae23c9
 
ae23c9
     notifier_list_init(&blk->remove_bs_notifiers);
ae23c9
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
ae23c9
index 2e71cff..b10c71d 100644
ae23c9
--- a/tests/qemu-iotests/067.out
ae23c9
+++ b/tests/qemu-iotests/067.out
ae23c9
@@ -385,6 +385,7 @@ Testing: -device virtio-scsi -device scsi-cd,id=cd0
ae23c9
 {
ae23c9
     "return": [
ae23c9
         {
ae23c9
+            "io-status": "ok",
ae23c9
             "device": "",
ae23c9
             "locked": false,
ae23c9
             "removable": true,
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9