Skip to content

Commit

Permalink
block/export: Conditionally ignore set-context error
Browse files Browse the repository at this point in the history
When invoking block-export-add with some iothread and
fixed-iothread=false, and changing the node's iothread fails, the error
is supposed to be ignored.

However, it is still stored in *errp, which is wrong.  If a second error
occurs, the "*errp must be NULL" assertion in error_setv() fails:

  qemu-system-x86_64: ../util/error.c:59: error_setv: Assertion
  `*errp == NULL' failed.

So if fixed-iothread=false, we should ignore the error by passing NULL
to bdrv_try_set_aio_context().

Fixes: f51d23c
       ("block/export: add iothread and fixed-iothread options")
Signed-off-by: Max Reitz <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
XanClic authored and kevmw committed Jul 20, 2021
1 parent 6af7227 commit 8573823
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion block/export/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
if (export->has_iothread) {
IOThread *iothread;
AioContext *new_ctx;
Error **set_context_errp;

iothread = iothread_by_id(export->iothread);
if (!iothread) {
Expand All @@ -120,7 +121,9 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)

new_ctx = iothread_get_aio_context(iothread);

ret = bdrv_try_set_aio_context(bs, new_ctx, errp);
/* Ignore errors with fixed-iothread=false */
set_context_errp = fixed_iothread ? errp : NULL;
ret = bdrv_try_set_aio_context(bs, new_ctx, set_context_errp);
if (ret == 0) {
aio_context_release(ctx);
aio_context_acquire(new_ctx);
Expand Down

0 comments on commit 8573823

Please sign in to comment.