Blame SOURCES/kvm-block-Add-Error-argument-to-bdrv_refresh_limits.patch

05bba0
From 1aac494dfcc4f96e04f3ad8bc14db8f17c48626f Mon Sep 17 00:00:00 2001
05bba0
From: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
Date: Tue, 17 Mar 2015 13:02:48 +0100
05bba0
Subject: [PATCH 13/16] block: Add Error argument to bdrv_refresh_limits()
05bba0
05bba0
Message-id: <1424365599-9801-2-git-send-email-stefanha@redhat.com>
05bba0
Patchwork-id: 63914
05bba0
O-Subject: [RHEL-7.1 qemu-kvm PATCH 1/2] block: Add Error argument to bdrv_refresh_limits()
05bba0
Bugzilla: 1184363
05bba0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
05bba0
RH-Acked-by: John Snow <jsnow@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
05bba0
From: Kevin Wolf <kwolf@redhat.com>
05bba0
05bba0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
05bba0
Reviewed-by: Eric Blake <eblake@redhat.com>
05bba0
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
(cherry picked from commit 3baca891391afba154e250f5a108c6bab6c92cf9)
05bba0
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
05bba0
Conflicts:
05bba0
        block.c
05bba0
05bba0
bdrv_set_backing_hd() does not exist downstream so there are extra
05bba0
bdrv_refresh_limits() occurrences downstream.  They pass a NULL errp
05bba0
argument as bdrv_set_backing_hd() would.
05bba0
05bba0
        block/iscsi.c
05bba0
05bba0
Context conflict, easy to resolve.
05bba0
05bba0
        block/raw_bsd.c
05bba0
05bba0
Does not exist downstream, apply change to block/raw.c instead.
05bba0
---
05bba0
 block.c                   | 35 ++++++++++++++++++++++++-----------
05bba0
 block/iscsi.c             |  4 +---
05bba0
 block/qcow2.c             |  4 +---
05bba0
 block/qed.c               |  4 +---
05bba0
 block/raw-posix.c         |  4 +---
05bba0
 block/raw.c               |  3 +--
05bba0
 block/stream.c            |  2 +-
05bba0
 block/vmdk.c              |  4 +---
05bba0
 include/block/block.h     |  2 +-
05bba0
 include/block/block_int.h |  2 +-
05bba0
 10 files changed, 33 insertions(+), 31 deletions(-)
05bba0
05bba0
diff --git a/block.c b/block.c
05bba0
index 21418a6..89ab829 100644
05bba0
--- a/block.c
05bba0
+++ b/block.c
05bba0
@@ -462,19 +462,24 @@ int bdrv_create_file(const char* filename, QEMUOptionParameter *options,
05bba0
     return ret;
05bba0
 }
05bba0
 
05bba0
-int bdrv_refresh_limits(BlockDriverState *bs)
05bba0
+void bdrv_refresh_limits(BlockDriverState *bs, Error **errp)
05bba0
 {
05bba0
     BlockDriver *drv = bs->drv;
05bba0
+    Error *local_err = NULL;
05bba0
 
05bba0
     memset(&bs->bl, 0, sizeof(bs->bl));
05bba0
 
05bba0
     if (!drv) {
05bba0
-        return 0;
05bba0
+        return;
05bba0
     }
05bba0
 
05bba0
     /* Take some limits from the children as a default */
05bba0
     if (bs->file) {
05bba0
-        bdrv_refresh_limits(bs->file);
05bba0
+        bdrv_refresh_limits(bs->file, &local_err);
05bba0
+        if (local_err) {
05bba0
+            error_propagate(errp, local_err);
05bba0
+            return;
05bba0
+        }
05bba0
         bs->bl.opt_transfer_length = bs->file->bl.opt_transfer_length;
05bba0
         bs->bl.opt_mem_alignment = bs->file->bl.opt_mem_alignment;
05bba0
     } else {
05bba0
@@ -482,7 +487,11 @@ int bdrv_refresh_limits(BlockDriverState *bs)
05bba0
     }
05bba0
 
05bba0
     if (bs->backing_hd) {
05bba0
-        bdrv_refresh_limits(bs->backing_hd);
05bba0
+        bdrv_refresh_limits(bs->backing_hd, &local_err);
05bba0
+        if (local_err) {
05bba0
+            error_propagate(errp, local_err);
05bba0
+            return;
05bba0
+        }
05bba0
         bs->bl.opt_transfer_length =
05bba0
             MAX(bs->bl.opt_transfer_length,
05bba0
                 bs->backing_hd->bl.opt_transfer_length);
05bba0
@@ -493,10 +502,8 @@ int bdrv_refresh_limits(BlockDriverState *bs)
05bba0
 
05bba0
     /* Then let the driver override it */
05bba0
     if (drv->bdrv_refresh_limits) {
05bba0
-        return drv->bdrv_refresh_limits(bs);
05bba0
+        drv->bdrv_refresh_limits(bs, errp);
05bba0
     }
05bba0
-
05bba0
-    return 0;
05bba0
 }
05bba0
 
05bba0
 /*
05bba0
@@ -856,7 +863,13 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
05bba0
         goto free_and_fail;
05bba0
     }
05bba0
 
05bba0
-    bdrv_refresh_limits(bs);
05bba0
+    bdrv_refresh_limits(bs, &local_err);
05bba0
+    if (local_err) {
05bba0
+        error_propagate(errp, local_err);
05bba0
+        ret = -EINVAL;
05bba0
+        goto free_and_fail;
05bba0
+    }
05bba0
+
05bba0
     assert(bdrv_opt_mem_align(bs) != 0);
05bba0
     assert((bs->request_alignment != 0) || bs->sg);
05bba0
 
05bba0
@@ -1048,7 +1061,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
05bba0
     }
05bba0
 
05bba0
     /* Recalculate the BlockLimits with the backing file */
05bba0
-    bdrv_refresh_limits(bs);
05bba0
+    bdrv_refresh_limits(bs, NULL);
05bba0
 
05bba0
     return 0;
05bba0
 }
05bba0
@@ -1483,7 +1496,7 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
05bba0
                                               BDRV_O_CACHE_WB);
05bba0
     reopen_state->bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
05bba0
 
05bba0
-    bdrv_refresh_limits(reopen_state->bs);
05bba0
+    bdrv_refresh_limits(reopen_state->bs, NULL);
05bba0
 }
05bba0
 
05bba0
 /*
05bba0
@@ -2398,7 +2411,7 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,
05bba0
     }
05bba0
     new_top_bs->backing_hd = base_bs;
05bba0
 
05bba0
-    bdrv_refresh_limits(new_top_bs);
05bba0
+    bdrv_refresh_limits(new_top_bs, NULL);
05bba0
 
05bba0
     QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) {
05bba0
         /* so that bdrv_close() does not recursively close the chain */
05bba0
diff --git a/block/iscsi.c b/block/iscsi.c
05bba0
index 3d61dd7..2a4ab22 100644
05bba0
--- a/block/iscsi.c
05bba0
+++ b/block/iscsi.c
05bba0
@@ -1550,7 +1550,7 @@ static void iscsi_close(BlockDriverState *bs)
05bba0
     memset(iscsilun, 0, sizeof(IscsiLun));
05bba0
 }
05bba0
 
05bba0
-static int iscsi_refresh_limits(BlockDriverState *bs)
05bba0
+static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)
05bba0
 {
05bba0
     IscsiLun *iscsilun = bs->opaque;
05bba0
 
05bba0
@@ -1576,8 +1576,6 @@ static int iscsi_refresh_limits(BlockDriverState *bs)
05bba0
         bs->bl.opt_transfer_length = sector_lun2qemu(iscsilun->bl.opt_xfer_len,
05bba0
                                                      iscsilun);
05bba0
     }
05bba0
-
05bba0
-    return 0;
05bba0
 }
05bba0
 
05bba0
 /* We have nothing to do for iSCSI reopen, stub just returns
05bba0
diff --git a/block/qcow2.c b/block/qcow2.c
05bba0
index 43e54d6..005d513 100644
05bba0
--- a/block/qcow2.c
05bba0
+++ b/block/qcow2.c
05bba0
@@ -848,13 +848,11 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
05bba0
     return ret;
05bba0
 }
05bba0
 
05bba0
-static int qcow2_refresh_limits(BlockDriverState *bs)
05bba0
+static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp)
05bba0
 {
05bba0
     BDRVQcowState *s = bs->opaque;
05bba0
 
05bba0
     bs->bl.write_zeroes_alignment = s->cluster_sectors;
05bba0
-
05bba0
-    return 0;
05bba0
 }
05bba0
 
05bba0
 static int qcow2_set_key(BlockDriverState *bs, const char *key)
05bba0
diff --git a/block/qed.c b/block/qed.c
05bba0
index d1de0a2..5793fca 100644
05bba0
--- a/block/qed.c
05bba0
+++ b/block/qed.c
05bba0
@@ -507,13 +507,11 @@ out:
05bba0
     return ret;
05bba0
 }
05bba0
 
05bba0
-static int bdrv_qed_refresh_limits(BlockDriverState *bs)
05bba0
+static void bdrv_qed_refresh_limits(BlockDriverState *bs, Error **errp)
05bba0
 {
05bba0
     BDRVQEDState *s = bs->opaque;
05bba0
 
05bba0
     bs->bl.write_zeroes_alignment = s->header.cluster_size >> BDRV_SECTOR_BITS;
05bba0
-
05bba0
-    return 0;
05bba0
 }
05bba0
 
05bba0
 /* We have nothing to do for QED reopen, stubs just return
05bba0
diff --git a/block/raw-posix.c b/block/raw-posix.c
05bba0
index af526ca..46b941b 100644
05bba0
--- a/block/raw-posix.c
05bba0
+++ b/block/raw-posix.c
05bba0
@@ -588,14 +588,12 @@ static void raw_reopen_abort(BDRVReopenState *state)
05bba0
     state->opaque = NULL;
05bba0
 }
05bba0
 
05bba0
-static int raw_refresh_limits(BlockDriverState *bs)
05bba0
+static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
05bba0
 {
05bba0
     BDRVRawState *s = bs->opaque;
05bba0
 
05bba0
     raw_probe_alignment(bs, s->fd, errp);
05bba0
     bs->bl.opt_mem_alignment = s->buf_align;
05bba0
-
05bba0
-    return 0;
05bba0
 }
05bba0
 
05bba0
 static ssize_t handle_aiocb_ioctl(RawPosixAIOData *aiocb)
05bba0
diff --git a/block/raw.c b/block/raw.c
05bba0
index eeadba5..a750359 100644
05bba0
--- a/block/raw.c
05bba0
+++ b/block/raw.c
05bba0
@@ -58,10 +58,9 @@ static int64_t raw_getlength(BlockDriverState *bs)
05bba0
     return bdrv_getlength(bs->file);
05bba0
 }
05bba0
 
05bba0
-static int raw_refresh_limits(BlockDriverState *bs)
05bba0
+static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
05bba0
 {
05bba0
     bs->bl = bs->file->bl;
05bba0
-    return 0;
05bba0
 }
05bba0
 
05bba0
 static int raw_truncate(BlockDriverState *bs, int64_t offset)
05bba0
diff --git a/block/stream.c b/block/stream.c
05bba0
index 367120d..4e4436c 100644
05bba0
--- a/block/stream.c
05bba0
+++ b/block/stream.c
05bba0
@@ -72,7 +72,7 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base,
05bba0
     }
05bba0
     top->backing_hd = base;
05bba0
 
05bba0
-    bdrv_refresh_limits(top);
05bba0
+    bdrv_refresh_limits(top, NULL);
05bba0
 }
05bba0
 
05bba0
 static void coroutine_fn stream_run(void *opaque)
05bba0
diff --git a/block/vmdk.c b/block/vmdk.c
05bba0
index cfcaa84..24e9458 100644
05bba0
--- a/block/vmdk.c
05bba0
+++ b/block/vmdk.c
05bba0
@@ -954,7 +954,7 @@ fail:
05bba0
 }
05bba0
 
05bba0
 
05bba0
-static int vmdk_refresh_limits(BlockDriverState *bs)
05bba0
+static void vmdk_refresh_limits(BlockDriverState *bs, Error **errp)
05bba0
 {
05bba0
     BDRVVmdkState *s = bs->opaque;
05bba0
     int i;
05bba0
@@ -966,8 +966,6 @@ static int vmdk_refresh_limits(BlockDriverState *bs)
05bba0
                     s->extents[i].cluster_sectors);
05bba0
         }
05bba0
     }
05bba0
-
05bba0
-    return 0;
05bba0
 }
05bba0
 
05bba0
 /**
05bba0
diff --git a/include/block/block.h b/include/block/block.h
05bba0
index c79a1e1..3170cbc 100644
05bba0
--- a/include/block/block.h
05bba0
+++ b/include/block/block.h
05bba0
@@ -254,7 +254,7 @@ int64_t bdrv_nb_sectors(BlockDriverState *bs);
05bba0
 int64_t bdrv_getlength(BlockDriverState *bs);
05bba0
 int64_t bdrv_get_allocated_file_size(BlockDriverState *bs);
05bba0
 void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
05bba0
-int bdrv_refresh_limits(BlockDriverState *bs);
05bba0
+void bdrv_refresh_limits(BlockDriverState *bs, Error **errp);
05bba0
 int bdrv_commit(BlockDriverState *bs);
05bba0
 int bdrv_commit_all(void);
05bba0
 int bdrv_change_backing_file(BlockDriverState *bs,
05bba0
diff --git a/include/block/block_int.h b/include/block/block_int.h
05bba0
index e6874b4..3f86649 100644
05bba0
--- a/include/block/block_int.h
05bba0
+++ b/include/block/block_int.h
05bba0
@@ -213,7 +213,7 @@ struct BlockDriver {
05bba0
     int (*bdrv_debug_resume)(BlockDriverState *bs, const char *tag);
05bba0
     bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag);
05bba0
 
05bba0
-    int (*bdrv_refresh_limits)(BlockDriverState *bs);
05bba0
+    void (*bdrv_refresh_limits)(BlockDriverState *bs, Error **errp);
05bba0
 
05bba0
     /*
05bba0
      * Returns 1 if newly created images are guaranteed to contain only
05bba0
-- 
05bba0
1.8.3.1
05bba0