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