mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
block: Take graph lock for most of .bdrv_open
Most implementations of .bdrv_open first open their file child (which is an operation that internally takes the write lock and therefore we shouldn't hold the graph lock while calling it), and afterwards many operations that require holding the graph lock, e.g. for accessing bs->file. This changes block drivers that follow this pattern to take the graph lock after opening the child node. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20231027155333.420094-24-kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
65ff757df0
commit
a4b740db5e
16 changed files with 60 additions and 20 deletions
11
block/qcow.c
11
block/qcow.c
|
@ -124,9 +124,11 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
|
|||
|
||||
ret = bdrv_open_file_child(NULL, options, "file", bs, errp);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
goto fail_unlocked;
|
||||
}
|
||||
|
||||
bdrv_graph_rdlock_main_loop();
|
||||
|
||||
ret = bdrv_pread(bs->file, 0, sizeof(header), &header, 0);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
|
@ -301,11 +303,9 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
|
|||
}
|
||||
|
||||
/* Disable migration when qcow images are used */
|
||||
bdrv_graph_rdlock_main_loop();
|
||||
error_setg(&s->migration_blocker, "The qcow format used by node '%s' "
|
||||
"does not support live migration",
|
||||
bdrv_get_device_or_node_name(bs));
|
||||
bdrv_graph_rdunlock_main_loop();
|
||||
|
||||
ret = migrate_add_blocker_normal(&s->migration_blocker, errp);
|
||||
if (ret < 0) {
|
||||
|
@ -315,9 +315,12 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
|
|||
qobject_unref(encryptopts);
|
||||
qapi_free_QCryptoBlockOpenOptions(crypto_opts);
|
||||
qemu_co_mutex_init(&s->lock);
|
||||
bdrv_graph_rdunlock_main_loop();
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
bdrv_graph_rdunlock_main_loop();
|
||||
fail_unlocked:
|
||||
g_free(s->l1_table);
|
||||
qemu_vfree(s->l2_cache);
|
||||
g_free(s->cluster_cache);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue