block: Add BlockBackend.ctx
This adds a new parameter to blk_new() which requires its callers to declare from which AioContext this BlockBackend is going to be used (or the locks of which AioContext need to be taken anyway). The given context is only stored and kept up to date when changing AioContexts. Actually applying the stored AioContext to the root node is saved for another commit. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
97896a4887
commit
d861ab3acf
2
block.c
2
block.c
@ -2884,7 +2884,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
|||||||
/* Not requesting BLK_PERM_CONSISTENT_READ because we're only
|
/* Not requesting BLK_PERM_CONSISTENT_READ because we're only
|
||||||
* looking at the header to guess the image format. This works even
|
* looking at the header to guess the image format. This works even
|
||||||
* in cases where a guest would not see a consistent state. */
|
* in cases where a guest would not see a consistent state. */
|
||||||
file = blk_new(0, BLK_PERM_ALL);
|
file = blk_new(bdrv_get_aio_context(file_bs), 0, BLK_PERM_ALL);
|
||||||
blk_insert_bs(file, file_bs, &local_err);
|
blk_insert_bs(file, file_bs, &local_err);
|
||||||
bdrv_unref(file_bs);
|
bdrv_unref(file_bs);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
|
@ -627,7 +627,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The target must match the source in size, so no resize here either */
|
/* The target must match the source in size, so no resize here either */
|
||||||
job->target = blk_new(BLK_PERM_WRITE,
|
job->target = blk_new(job->common.job.aio_context,
|
||||||
|
BLK_PERM_WRITE,
|
||||||
BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE |
|
BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE |
|
||||||
BLK_PERM_WRITE_UNCHANGED | BLK_PERM_GRAPH_MOD);
|
BLK_PERM_WRITE_UNCHANGED | BLK_PERM_GRAPH_MOD);
|
||||||
ret = blk_insert_bs(job->target, target, errp);
|
ret = blk_insert_bs(job->target, target, errp);
|
||||||
|
@ -42,6 +42,7 @@ struct BlockBackend {
|
|||||||
char *name;
|
char *name;
|
||||||
int refcnt;
|
int refcnt;
|
||||||
BdrvChild *root;
|
BdrvChild *root;
|
||||||
|
AioContext *ctx;
|
||||||
DriveInfo *legacy_dinfo; /* null unless created by drive_new() */
|
DriveInfo *legacy_dinfo; /* null unless created by drive_new() */
|
||||||
QTAILQ_ENTRY(BlockBackend) link; /* for block_backends */
|
QTAILQ_ENTRY(BlockBackend) link; /* for block_backends */
|
||||||
QTAILQ_ENTRY(BlockBackend) monitor_link; /* for monitor_block_backends */
|
QTAILQ_ENTRY(BlockBackend) monitor_link; /* for monitor_block_backends */
|
||||||
@ -322,12 +323,13 @@ static const BdrvChildRole child_root = {
|
|||||||
*
|
*
|
||||||
* Return the new BlockBackend on success, null on failure.
|
* Return the new BlockBackend on success, null on failure.
|
||||||
*/
|
*/
|
||||||
BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
|
BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm)
|
||||||
{
|
{
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
|
|
||||||
blk = g_new0(BlockBackend, 1);
|
blk = g_new0(BlockBackend, 1);
|
||||||
blk->refcnt = 1;
|
blk->refcnt = 1;
|
||||||
|
blk->ctx = ctx;
|
||||||
blk->perm = perm;
|
blk->perm = perm;
|
||||||
blk->shared_perm = shared_perm;
|
blk->shared_perm = shared_perm;
|
||||||
blk_set_enable_write_cache(blk, true);
|
blk_set_enable_write_cache(blk, true);
|
||||||
@ -347,6 +349,7 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates a new BlockBackend, opens a new BlockDriverState, and connects both.
|
* Creates a new BlockBackend, opens a new BlockDriverState, and connects both.
|
||||||
|
* The new BlockBackend is in the main AioContext.
|
||||||
*
|
*
|
||||||
* Just as with bdrv_open(), after having called this function the reference to
|
* Just as with bdrv_open(), after having called this function the reference to
|
||||||
* @options belongs to the block layer (even on failure).
|
* @options belongs to the block layer (even on failure).
|
||||||
@ -382,7 +385,7 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
|
|||||||
perm |= BLK_PERM_RESIZE;
|
perm |= BLK_PERM_RESIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(perm, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), perm, BLK_PERM_ALL);
|
||||||
bs = bdrv_open(filename, reference, options, flags, errp);
|
bs = bdrv_open(filename, reference, options, flags, errp);
|
||||||
if (!bs) {
|
if (!bs) {
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
@ -1856,7 +1859,15 @@ void blk_op_unblock_all(BlockBackend *blk, Error *reason)
|
|||||||
|
|
||||||
AioContext *blk_get_aio_context(BlockBackend *blk)
|
AioContext *blk_get_aio_context(BlockBackend *blk)
|
||||||
{
|
{
|
||||||
return bdrv_get_aio_context(blk_bs(blk));
|
BlockDriverState *bs = blk_bs(blk);
|
||||||
|
|
||||||
|
/* FIXME The AioContext of bs and blk can be inconsistent. For the moment,
|
||||||
|
* we prefer the one of bs for compatibility. */
|
||||||
|
if (bs) {
|
||||||
|
return bdrv_get_aio_context(blk_bs(blk));
|
||||||
|
}
|
||||||
|
|
||||||
|
return blk->ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)
|
static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)
|
||||||
@ -1888,6 +1899,7 @@ static int blk_do_set_aio_context(BlockBackend *blk, AioContext *new_context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blk->ctx = new_context;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,8 @@ void commit_start(const char *job_id, BlockDriverState *bs,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->base = blk_new(BLK_PERM_CONSISTENT_READ
|
s->base = blk_new(s->common.job.aio_context,
|
||||||
|
BLK_PERM_CONSISTENT_READ
|
||||||
| BLK_PERM_WRITE
|
| BLK_PERM_WRITE
|
||||||
| BLK_PERM_RESIZE,
|
| BLK_PERM_RESIZE,
|
||||||
BLK_PERM_CONSISTENT_READ
|
BLK_PERM_CONSISTENT_READ
|
||||||
@ -351,7 +352,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
|
|||||||
s->base_bs = base;
|
s->base_bs = base;
|
||||||
|
|
||||||
/* Required permissions are already taken with block_job_add_bdrv() */
|
/* Required permissions are already taken with block_job_add_bdrv() */
|
||||||
s->top = blk_new(0, BLK_PERM_ALL);
|
s->top = blk_new(s->common.job.aio_context, 0, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(s->top, top, errp);
|
ret = blk_insert_bs(s->top, top, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -395,6 +396,7 @@ int bdrv_commit(BlockDriverState *bs)
|
|||||||
BlockDriverState *backing_file_bs = NULL;
|
BlockDriverState *backing_file_bs = NULL;
|
||||||
BlockDriverState *commit_top_bs = NULL;
|
BlockDriverState *commit_top_bs = NULL;
|
||||||
BlockDriver *drv = bs->drv;
|
BlockDriver *drv = bs->drv;
|
||||||
|
AioContext *ctx;
|
||||||
int64_t offset, length, backing_length;
|
int64_t offset, length, backing_length;
|
||||||
int ro;
|
int ro;
|
||||||
int64_t n;
|
int64_t n;
|
||||||
@ -422,8 +424,9 @@ int bdrv_commit(BlockDriverState *bs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
src = blk_new(BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL);
|
ctx = bdrv_get_aio_context(bs);
|
||||||
backing = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
src = blk_new(ctx, BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL);
|
||||||
|
backing = blk_new(ctx, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
|
|
||||||
ret = blk_insert_bs(src, bs, &local_err);
|
ret = blk_insert_bs(src, bs, &local_err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -257,7 +257,8 @@ static int block_crypto_co_create_generic(BlockDriverState *bs,
|
|||||||
QCryptoBlock *crypto = NULL;
|
QCryptoBlock *crypto = NULL;
|
||||||
struct BlockCryptoCreateData data;
|
struct BlockCryptoCreateData data;
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
|
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -1584,7 +1584,8 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs,
|
|||||||
* We can allow anything except resize there.*/
|
* We can allow anything except resize there.*/
|
||||||
target_is_backing = bdrv_chain_contains(bs, target);
|
target_is_backing = bdrv_chain_contains(bs, target);
|
||||||
target_graph_mod = (backing_mode != MIRROR_LEAVE_BACKING_CHAIN);
|
target_graph_mod = (backing_mode != MIRROR_LEAVE_BACKING_CHAIN);
|
||||||
s->target = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE |
|
s->target = blk_new(s->common.job.aio_context,
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE |
|
||||||
(target_graph_mod ? BLK_PERM_GRAPH_MOD : 0),
|
(target_graph_mod ? BLK_PERM_GRAPH_MOD : 0),
|
||||||
BLK_PERM_WRITE_UNCHANGED |
|
BLK_PERM_WRITE_UNCHANGED |
|
||||||
(target_is_backing ? BLK_PERM_CONSISTENT_READ |
|
(target_is_backing ? BLK_PERM_CONSISTENT_READ |
|
||||||
|
@ -554,7 +554,8 @@ static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -844,7 +844,8 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
qcow_blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
qcow_blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(qcow_blk, bs, errp);
|
ret = blk_insert_bs(qcow_blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -3174,7 +3174,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create BlockBackend to write to the image */
|
/* Create BlockBackend to write to the image */
|
||||||
blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
@ -5006,7 +5007,8 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (new_size) {
|
if (new_size) {
|
||||||
BlockBackend *blk = blk_new(BLK_PERM_RESIZE, BLK_PERM_ALL);
|
BlockBackend *blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
|
@ -649,7 +649,8 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1800,7 +1800,8 @@ static int sd_prealloc(BlockDriverState *bs, int64_t old_size, int64_t new_size,
|
|||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_RESIZE,
|
blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_RESIZE,
|
||||||
BLK_PERM_ALL);
|
BLK_PERM_ALL);
|
||||||
|
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
|
@ -803,7 +803,8 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
blk = blk_new(bdrv_get_aio_context(bs_file),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs_file, errp);
|
ret = blk_insert_bs(blk, bs_file, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -1900,7 +1900,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto delete_and_exit;
|
goto delete_and_exit;
|
||||||
|
@ -2356,7 +2356,8 @@ static BlockBackend *vmdk_co_create_cb(int64_t size, int idx,
|
|||||||
if (!bs) {
|
if (!bs) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
blk = blk_new(BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_RESIZE,
|
blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_RESIZE,
|
||||||
BLK_PERM_ALL);
|
BLK_PERM_ALL);
|
||||||
if (blk_insert_bs(blk, bs, errp)) {
|
if (blk_insert_bs(blk, bs, errp)) {
|
||||||
bdrv_unref(bs);
|
bdrv_unref(bs);
|
||||||
|
@ -1011,7 +1011,8 @@ static int coroutine_fn vpc_co_create(BlockdevCreateOptions *opts,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -574,7 +574,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
|
|||||||
if ((!file || !*file) && !qdict_size(bs_opts)) {
|
if ((!file || !*file) && !qdict_size(bs_opts)) {
|
||||||
BlockBackendRootState *blk_rs;
|
BlockBackendRootState *blk_rs;
|
||||||
|
|
||||||
blk = blk_new(0, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
blk_rs = blk_get_root_state(blk);
|
blk_rs = blk_get_root_state(blk);
|
||||||
blk_rs->open_flags = bdrv_flags;
|
blk_rs->open_flags = bdrv_flags;
|
||||||
blk_rs->read_only = read_only;
|
blk_rs->read_only = read_only;
|
||||||
@ -3154,7 +3154,7 @@ void qmp_block_resize(bool has_device, const char *device,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_RESIZE, BLK_PERM_ALL);
|
blk = blk_new(bdrv_get_aio_context(bs), BLK_PERM_RESIZE, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -392,7 +392,7 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
|
|||||||
job_id = bdrv_get_device_name(bs);
|
job_id = bdrv_get_device_name(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(perm, shared_perm);
|
blk = blk_new(bdrv_get_aio_context(bs), perm, shared_perm);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
|
3
hmp.c
3
hmp.c
@ -2560,7 +2560,8 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
|
|||||||
if (!blk) {
|
if (!blk) {
|
||||||
BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
|
BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err);
|
||||||
if (bs) {
|
if (bs) {
|
||||||
blk = local_blk = blk_new(0, BLK_PERM_ALL);
|
blk = local_blk = blk_new(bdrv_get_aio_context(bs),
|
||||||
|
0, BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk, bs, &err);
|
ret = blk_insert_bs(blk, bs, &err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -538,7 +538,7 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
|
|||||||
|
|
||||||
if (!dev->conf.blk) {
|
if (!dev->conf.blk) {
|
||||||
/* Anonymous BlockBackend for an empty drive */
|
/* Anonymous BlockBackend for an empty drive */
|
||||||
dev->conf.blk = blk_new(0, BLK_PERM_ALL);
|
dev->conf.blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
ret = blk_attach_dev(dev->conf.blk, qdev);
|
ret = blk_attach_dev(dev->conf.blk, qdev);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
}
|
}
|
||||||
|
@ -609,7 +609,7 @@ static void xen_cdrom_realize(XenBlockDevice *blockdev, Error **errp)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Set up an empty drive */
|
/* Set up an empty drive */
|
||||||
conf->blk = blk_new(0, BLK_PERM_ALL);
|
conf->blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
|
|
||||||
rc = blk_attach_dev(conf->blk, DEVICE(blockdev));
|
rc = blk_attach_dev(conf->blk, DEVICE(blockdev));
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
|
@ -80,7 +80,9 @@ static void parse_drive(DeviceState *dev, const char *str, void **ptr,
|
|||||||
if (!blk) {
|
if (!blk) {
|
||||||
BlockDriverState *bs = bdrv_lookup_bs(NULL, str, NULL);
|
BlockDriverState *bs = bdrv_lookup_bs(NULL, str, NULL);
|
||||||
if (bs) {
|
if (bs) {
|
||||||
blk = blk_new(0, BLK_PERM_ALL);
|
/* BlockBackends of devices start in the main context and are only
|
||||||
|
* later moved into another context if the device supports that. */
|
||||||
|
blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
blk_created = true;
|
blk_created = true;
|
||||||
|
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
|
@ -168,7 +168,7 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp)
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
/* Anonymous BlockBackend for an empty drive */
|
/* Anonymous BlockBackend for an empty drive */
|
||||||
dev->conf.blk = blk_new(0, BLK_PERM_ALL);
|
dev->conf.blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
|
ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
}
|
}
|
||||||
|
@ -2417,7 +2417,7 @@ static void scsi_cd_realize(SCSIDevice *dev, Error **errp)
|
|||||||
if (!dev->conf.blk) {
|
if (!dev->conf.blk) {
|
||||||
/* Anonymous BlockBackend for an empty drive. As we put it into
|
/* Anonymous BlockBackend for an empty drive. As we put it into
|
||||||
* dev->conf, qdev takes care of detaching on unplug. */
|
* dev->conf, qdev takes care of detaching on unplug. */
|
||||||
dev->conf.blk = blk_new(0, BLK_PERM_ALL);
|
dev->conf.blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
|
ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ typedef struct BlockBackendPublic {
|
|||||||
ThrottleGroupMember throttle_group_member;
|
ThrottleGroupMember throttle_group_member;
|
||||||
} BlockBackendPublic;
|
} BlockBackendPublic;
|
||||||
|
|
||||||
BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm);
|
BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm);
|
||||||
BlockBackend *blk_new_open(const char *filename, const char *reference,
|
BlockBackend *blk_new_open(const char *filename, const char *reference,
|
||||||
QDict *options, int flags, Error **errp);
|
QDict *options, int flags, Error **errp);
|
||||||
int blk_get_refcnt(BlockBackend *blk);
|
int blk_get_refcnt(BlockBackend *blk);
|
||||||
|
@ -417,7 +417,8 @@ static int init_blk_migration(QEMUFile *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bmds = g_new0(BlkMigDevState, 1);
|
bmds = g_new0(BlkMigDevState, 1);
|
||||||
bmds->blk = blk_new(BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL);
|
bmds->blk = blk_new(qemu_get_aio_context(),
|
||||||
|
BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL);
|
||||||
bmds->blk_name = g_strdup(bdrv_get_device_name(bs));
|
bmds->blk_name = g_strdup(bdrv_get_device_name(bs));
|
||||||
bmds->bulk_completed = 0;
|
bmds->bulk_completed = 0;
|
||||||
bmds->total_sectors = sectors;
|
bmds->total_sectors = sectors;
|
||||||
|
@ -1484,8 +1484,9 @@ NBDExport *nbd_export_new(BlockDriverState *bs, uint64_t dev_offset,
|
|||||||
if ((nbdflags & NBD_FLAG_READ_ONLY) == 0) {
|
if ((nbdflags & NBD_FLAG_READ_ONLY) == 0) {
|
||||||
perm |= BLK_PERM_WRITE;
|
perm |= BLK_PERM_WRITE;
|
||||||
}
|
}
|
||||||
blk = blk_new(perm, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED |
|
blk = blk_new(bdrv_get_aio_context(bs), perm,
|
||||||
BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD);
|
BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED |
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD);
|
||||||
ret = blk_insert_bs(blk, bs, errp);
|
ret = blk_insert_bs(blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -3313,7 +3313,8 @@ static int img_rebase(int argc, char **argv)
|
|||||||
BlockDriverState *base_bs = backing_bs(bs);
|
BlockDriverState *base_bs = backing_bs(bs);
|
||||||
|
|
||||||
if (base_bs) {
|
if (base_bs) {
|
||||||
blk_old_backing = blk_new(BLK_PERM_CONSISTENT_READ,
|
blk_old_backing = blk_new(qemu_get_aio_context(),
|
||||||
|
BLK_PERM_CONSISTENT_READ,
|
||||||
BLK_PERM_ALL);
|
BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk_old_backing, base_bs,
|
ret = blk_insert_bs(blk_old_backing, base_bs,
|
||||||
&local_err);
|
&local_err);
|
||||||
@ -3360,7 +3361,8 @@ static int img_rebase(int argc, char **argv)
|
|||||||
prefix_chain_bs = bdrv_find_backing_image(bs, out_real_path);
|
prefix_chain_bs = bdrv_find_backing_image(bs, out_real_path);
|
||||||
if (prefix_chain_bs) {
|
if (prefix_chain_bs) {
|
||||||
g_free(out_real_path);
|
g_free(out_real_path);
|
||||||
blk_new_backing = blk_new(BLK_PERM_CONSISTENT_READ,
|
blk_new_backing = blk_new(qemu_get_aio_context(),
|
||||||
|
BLK_PERM_CONSISTENT_READ,
|
||||||
BLK_PERM_ALL);
|
BLK_PERM_ALL);
|
||||||
ret = blk_insert_bs(blk_new_backing, prefix_chain_bs,
|
ret = blk_insert_bs(blk_new_backing, prefix_chain_bs,
|
||||||
&local_err);
|
&local_err);
|
||||||
|
@ -206,7 +206,7 @@ static void test_drv_cb_common(enum drain_type drain_type, bool recursive)
|
|||||||
|
|
||||||
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, 0);
|
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, NULL, 0);
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
|
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
s = bs->opaque;
|
s = bs->opaque;
|
||||||
@ -290,7 +290,7 @@ static void test_quiesce_common(enum drain_type drain_type, bool recursive)
|
|||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
BlockDriverState *bs, *backing;
|
BlockDriverState *bs, *backing;
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
|
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
blk_insert_bs(blk, bs, &error_abort);
|
blk_insert_bs(blk, bs, &error_abort);
|
||||||
@ -353,7 +353,7 @@ static void test_nested(void)
|
|||||||
BDRVTestState *s, *backing_s;
|
BDRVTestState *s, *backing_s;
|
||||||
enum drain_type outer, inner;
|
enum drain_type outer, inner;
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
|
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
s = bs->opaque;
|
s = bs->opaque;
|
||||||
@ -402,13 +402,13 @@ static void test_multiparent(void)
|
|||||||
BlockDriverState *bs_a, *bs_b, *backing;
|
BlockDriverState *bs_a, *bs_b, *backing;
|
||||||
BDRVTestState *a_s, *b_s, *backing_s;
|
BDRVTestState *a_s, *b_s, *backing_s;
|
||||||
|
|
||||||
blk_a = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk_a = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
|
bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
a_s = bs_a->opaque;
|
a_s = bs_a->opaque;
|
||||||
blk_insert_bs(blk_a, bs_a, &error_abort);
|
blk_insert_bs(blk_a, bs_a, &error_abort);
|
||||||
|
|
||||||
blk_b = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk_b = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
|
bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
b_s = bs_b->opaque;
|
b_s = bs_b->opaque;
|
||||||
@ -475,13 +475,13 @@ static void test_graph_change_drain_subtree(void)
|
|||||||
BlockDriverState *bs_a, *bs_b, *backing;
|
BlockDriverState *bs_a, *bs_b, *backing;
|
||||||
BDRVTestState *a_s, *b_s, *backing_s;
|
BDRVTestState *a_s, *b_s, *backing_s;
|
||||||
|
|
||||||
blk_a = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk_a = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
|
bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
a_s = bs_a->opaque;
|
a_s = bs_a->opaque;
|
||||||
blk_insert_bs(blk_a, bs_a, &error_abort);
|
blk_insert_bs(blk_a, bs_a, &error_abort);
|
||||||
|
|
||||||
blk_b = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk_b = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
|
bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
b_s = bs_b->opaque;
|
b_s = bs_b->opaque;
|
||||||
@ -555,7 +555,7 @@ static void test_graph_change_drain_all(void)
|
|||||||
BDRVTestState *a_s, *b_s;
|
BDRVTestState *a_s, *b_s;
|
||||||
|
|
||||||
/* Create node A with a BlockBackend */
|
/* Create node A with a BlockBackend */
|
||||||
blk_a = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk_a = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
|
bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
a_s = bs_a->opaque;
|
a_s = bs_a->opaque;
|
||||||
@ -571,7 +571,7 @@ static void test_graph_change_drain_all(void)
|
|||||||
g_assert_cmpint(a_s->drain_count, ==, 1);
|
g_assert_cmpint(a_s->drain_count, ==, 1);
|
||||||
|
|
||||||
/* Create node B with a BlockBackend */
|
/* Create node B with a BlockBackend */
|
||||||
blk_b = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk_b = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
|
bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
b_s = bs_b->opaque;
|
b_s = bs_b->opaque;
|
||||||
@ -672,7 +672,7 @@ static void test_iothread_common(enum drain_type drain_type, int drain_thread)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
|
bs = bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
s = bs->opaque;
|
s = bs->opaque;
|
||||||
@ -883,7 +883,7 @@ static void test_blockjob_common_drain_node(enum drain_type drain_type,
|
|||||||
bdrv_set_backing_hd(src, src_backing, &error_abort);
|
bdrv_set_backing_hd(src, src_backing, &error_abort);
|
||||||
bdrv_unref(src_backing);
|
bdrv_unref(src_backing);
|
||||||
|
|
||||||
blk_src = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk_src = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
blk_insert_bs(blk_src, src_overlay, &error_abort);
|
blk_insert_bs(blk_src, src_overlay, &error_abort);
|
||||||
|
|
||||||
switch (drain_node) {
|
switch (drain_node) {
|
||||||
@ -910,7 +910,7 @@ static void test_blockjob_common_drain_node(enum drain_type drain_type,
|
|||||||
|
|
||||||
target = bdrv_new_open_driver(&bdrv_test, "target", BDRV_O_RDWR,
|
target = bdrv_new_open_driver(&bdrv_test, "target", BDRV_O_RDWR,
|
||||||
&error_abort);
|
&error_abort);
|
||||||
blk_target = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk_target = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
blk_insert_bs(blk_target, target, &error_abort);
|
blk_insert_bs(blk_target, target, &error_abort);
|
||||||
|
|
||||||
aio_context_acquire(ctx);
|
aio_context_acquire(ctx);
|
||||||
@ -1205,7 +1205,7 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete,
|
|||||||
&error_abort);
|
&error_abort);
|
||||||
bdrv_attach_child(bs, null_bs, "null-child", &child_file, &error_abort);
|
bdrv_attach_child(bs, null_bs, "null-child", &child_file, &error_abort);
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
blk_insert_bs(blk, bs, &error_abort);
|
blk_insert_bs(blk, bs, &error_abort);
|
||||||
|
|
||||||
/* Referenced by blk now */
|
/* Referenced by blk now */
|
||||||
@ -1368,7 +1368,7 @@ static void test_detach_indirect(bool by_parent_cb)
|
|||||||
c = bdrv_new_open_driver(&bdrv_test, "c", BDRV_O_RDWR, &error_abort);
|
c = bdrv_new_open_driver(&bdrv_test, "c", BDRV_O_RDWR, &error_abort);
|
||||||
|
|
||||||
/* blk is a BB for parent-a */
|
/* blk is a BB for parent-a */
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
blk_insert_bs(blk, parent_a, &error_abort);
|
blk_insert_bs(blk, parent_a, &error_abort);
|
||||||
bdrv_unref(parent_a);
|
bdrv_unref(parent_a);
|
||||||
|
|
||||||
@ -1460,7 +1460,7 @@ static void test_append_to_drained(void)
|
|||||||
BlockDriverState *base, *overlay;
|
BlockDriverState *base, *overlay;
|
||||||
BDRVTestState *base_s, *overlay_s;
|
BDRVTestState *base_s, *overlay_s;
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
base = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
|
base = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
|
||||||
base_s = base->opaque;
|
base_s = base->opaque;
|
||||||
blk_insert_bs(blk, base, &error_abort);
|
blk_insert_bs(blk, base, &error_abort);
|
||||||
|
@ -102,7 +102,8 @@ static void test_update_perm_tree(void)
|
|||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
BlockBackend *root = blk_new(BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ,
|
BlockBackend *root = blk_new(qemu_get_aio_context(),
|
||||||
|
BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ,
|
||||||
BLK_PERM_ALL & ~BLK_PERM_WRITE);
|
BLK_PERM_ALL & ~BLK_PERM_WRITE);
|
||||||
BlockDriverState *bs = no_perm_node("node");
|
BlockDriverState *bs = no_perm_node("node");
|
||||||
BlockDriverState *filter = pass_through_node("filter");
|
BlockDriverState *filter = pass_through_node("filter");
|
||||||
@ -165,7 +166,7 @@ static void test_update_perm_tree(void)
|
|||||||
*/
|
*/
|
||||||
static void test_should_update_child(void)
|
static void test_should_update_child(void)
|
||||||
{
|
{
|
||||||
BlockBackend *root = blk_new(0, BLK_PERM_ALL);
|
BlockBackend *root = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
BlockDriverState *bs = no_perm_node("node");
|
BlockDriverState *bs = no_perm_node("node");
|
||||||
BlockDriverState *filter = no_perm_node("filter");
|
BlockDriverState *filter = no_perm_node("filter");
|
||||||
BlockDriverState *target = no_perm_node("target");
|
BlockDriverState *target = no_perm_node("target");
|
||||||
|
@ -37,7 +37,8 @@ static void test_drain_aio_error_flush_cb(void *opaque, int ret)
|
|||||||
|
|
||||||
static void test_drain_aio_error(void)
|
static void test_drain_aio_error(void)
|
||||||
{
|
{
|
||||||
BlockBackend *blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
BlockBackend *blk = blk_new(qemu_get_aio_context(),
|
||||||
|
BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
BlockAIOCB *acb;
|
BlockAIOCB *acb;
|
||||||
bool completed = false;
|
bool completed = false;
|
||||||
|
|
||||||
@ -53,7 +54,8 @@ static void test_drain_aio_error(void)
|
|||||||
|
|
||||||
static void test_drain_all_aio_error(void)
|
static void test_drain_all_aio_error(void)
|
||||||
{
|
{
|
||||||
BlockBackend *blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
BlockBackend *blk = blk_new(qemu_get_aio_context(),
|
||||||
|
BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
BlockAIOCB *acb;
|
BlockAIOCB *acb;
|
||||||
bool completed = false;
|
bool completed = false;
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ static void test_sync_op(const void *opaque)
|
|||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
BdrvChild *c;
|
BdrvChild *c;
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
|
bs = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
|
||||||
bs->total_sectors = 65536 / BDRV_SECTOR_SIZE;
|
bs->total_sectors = 65536 / BDRV_SECTOR_SIZE;
|
||||||
blk_insert_bs(blk, bs, &error_abort);
|
blk_insert_bs(blk, bs, &error_abort);
|
||||||
@ -415,7 +415,7 @@ static void test_attach_blockjob(void)
|
|||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
TestBlockJob *tjob;
|
TestBlockJob *tjob;
|
||||||
|
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
|
bs = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
|
||||||
blk_insert_bs(blk, bs, &error_abort);
|
blk_insert_bs(blk, bs, &error_abort);
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ static void test_propagate_basic(void)
|
|||||||
QDict *options;
|
QDict *options;
|
||||||
|
|
||||||
/* Create bs_a and its BlockBackend */
|
/* Create bs_a and its BlockBackend */
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
bs_a = bdrv_new_open_driver(&bdrv_test, "bs_a", BDRV_O_RDWR, &error_abort);
|
bs_a = bdrv_new_open_driver(&bdrv_test, "bs_a", BDRV_O_RDWR, &error_abort);
|
||||||
blk_insert_bs(blk, bs_a, &error_abort);
|
blk_insert_bs(blk, bs_a, &error_abort);
|
||||||
|
|
||||||
@ -561,7 +561,7 @@ static void test_propagate_diamond(void)
|
|||||||
qdict_put_str(options, "raw", "bs_c");
|
qdict_put_str(options, "raw", "bs_c");
|
||||||
|
|
||||||
bs_verify = bdrv_open(NULL, NULL, options, BDRV_O_RDWR, &error_abort);
|
bs_verify = bdrv_open(NULL, NULL, options, BDRV_O_RDWR, &error_abort);
|
||||||
blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
|
||||||
blk_insert_bs(blk, bs_verify, &error_abort);
|
blk_insert_bs(blk, bs_verify, &error_abort);
|
||||||
|
|
||||||
/* Switch the AioContext */
|
/* Switch the AioContext */
|
||||||
@ -628,7 +628,7 @@ static void test_propagate_mirror(void)
|
|||||||
g_assert(bdrv_get_aio_context(filter) == main_ctx);
|
g_assert(bdrv_get_aio_context(filter) == main_ctx);
|
||||||
|
|
||||||
/* With a BlockBackend on src, changing target must fail */
|
/* With a BlockBackend on src, changing target must fail */
|
||||||
blk = blk_new(0, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
blk_insert_bs(blk, src, &error_abort);
|
blk_insert_bs(blk, src, &error_abort);
|
||||||
|
|
||||||
bdrv_try_set_aio_context(target, ctx, &local_err);
|
bdrv_try_set_aio_context(target, ctx, &local_err);
|
||||||
|
@ -68,7 +68,7 @@ static BlockJob *do_test_id(BlockBackend *blk, const char *id,
|
|||||||
static BlockBackend *create_blk(const char *name)
|
static BlockBackend *create_blk(const char *name)
|
||||||
{
|
{
|
||||||
/* No I/O is performed on this device */
|
/* No I/O is performed on this device */
|
||||||
BlockBackend *blk = blk_new(0, BLK_PERM_ALL);
|
BlockBackend *blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
|
|
||||||
bs = bdrv_open("null-co://", NULL, NULL, 0, &error_abort);
|
bs = bdrv_open("null-co://", NULL, NULL, 0, &error_abort);
|
||||||
|
@ -675,9 +675,9 @@ static void test_groups(void)
|
|||||||
ThrottleGroupMember *tgm1, *tgm2, *tgm3;
|
ThrottleGroupMember *tgm1, *tgm2, *tgm3;
|
||||||
|
|
||||||
/* No actual I/O is performed on these devices */
|
/* No actual I/O is performed on these devices */
|
||||||
blk1 = blk_new(0, BLK_PERM_ALL);
|
blk1 = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
blk2 = blk_new(0, BLK_PERM_ALL);
|
blk2 = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
blk3 = blk_new(0, BLK_PERM_ALL);
|
blk3 = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
|
|
||||||
blkp1 = blk_get_public(blk1);
|
blkp1 = blk_get_public(blk1);
|
||||||
blkp2 = blk_get_public(blk2);
|
blkp2 = blk_get_public(blk2);
|
||||||
|
Loading…
Reference in New Issue
Block a user