mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-09 08:17:53 -06:00
blockdev: drain while unlocked in external_snapshot_action()
This is in preparation to mark bdrv_drained_begin() as GRAPH_UNLOCKED. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Message-ID: <20250530151125.955508-19-f.ebner@proxmox.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
6f101614f9
commit
195a8a946a
1 changed files with 16 additions and 1 deletions
17
blockdev.c
17
blockdev.c
|
@ -1377,9 +1377,10 @@ static void external_snapshot_action(TransactionAction *action,
|
||||||
const char *new_image_file;
|
const char *new_image_file;
|
||||||
ExternalSnapshotState *state = g_new0(ExternalSnapshotState, 1);
|
ExternalSnapshotState *state = g_new0(ExternalSnapshotState, 1);
|
||||||
uint64_t perm, shared;
|
uint64_t perm, shared;
|
||||||
|
BlockDriverState *check_bs;
|
||||||
|
|
||||||
/* TODO We'll eventually have to take a writer lock in this function */
|
/* TODO We'll eventually have to take a writer lock in this function */
|
||||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
bdrv_graph_rdlock_main_loop();
|
||||||
|
|
||||||
tran_add(tran, &external_snapshot_drv, state);
|
tran_add(tran, &external_snapshot_drv, state);
|
||||||
|
|
||||||
|
@ -1412,11 +1413,25 @@ static void external_snapshot_action(TransactionAction *action,
|
||||||
|
|
||||||
state->old_bs = bdrv_lookup_bs(device, node_name, errp);
|
state->old_bs = bdrv_lookup_bs(device, node_name, errp);
|
||||||
if (!state->old_bs) {
|
if (!state->old_bs) {
|
||||||
|
bdrv_graph_rdunlock_main_loop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Need to drain while unlocked. */
|
||||||
|
bdrv_graph_rdunlock_main_loop();
|
||||||
/* Paired with .clean() */
|
/* Paired with .clean() */
|
||||||
bdrv_drained_begin(state->old_bs);
|
bdrv_drained_begin(state->old_bs);
|
||||||
|
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||||
|
|
||||||
|
/* Make sure the associated bs did not change with the drain. */
|
||||||
|
check_bs = bdrv_lookup_bs(device, node_name, errp);
|
||||||
|
if (state->old_bs != check_bs) {
|
||||||
|
if (check_bs) {
|
||||||
|
error_setg(errp, "Block node of device '%s' unexpectedly changed",
|
||||||
|
device);
|
||||||
|
} /* else errp is already set */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!bdrv_is_inserted(state->old_bs)) {
|
if (!bdrv_is_inserted(state->old_bs)) {
|
||||||
error_setg(errp, "Device '%s' has no medium",
|
error_setg(errp, "Device '%s' has no medium",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue