blockcommit: Reopen base image as RO after abort
PATCH 1/1 blockcommit: Reopen base image as RO after abort
If a blockcommit is aborted the base image remains in RW mode, that leads to a fail of subsequent live migration.
How to reproduce:
$ virsh snapshot-create-as vm snp1 --disk-only
*** write something to the disk ***
$ virsh blockcommit vm vda --active --shallow && virsh blockjob vm vda --abort $ lsof /vzt/vm.qcow2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME qemu-syst 433203 root 45u REG 253,0 1724776448 133 /vzt/vm.qcow2 $ cat /proc/433203/fdinfo/45 pos: 0 flags: 02140002
Reopen the base image in RO mode in mirror_exit_common() if the blockjob is aborted.
--- block/mirror.c | 4 ++++ 1 file changed, 4 insertions(+)
block/mirror.c +4 -0
@@ -789,6 +789,10 @@ static int mirror_exit_common(Job *job)block_job_remove_all_bdrv (bjob);bdrv_replace_node (mirror_top_bs, mirror_top_bs->backing->bs, &error_abort); +if (abort && !bdrv_is_read_only (target_bs)) { +bdrv_reopen_set_read_only (target_bs, true,NULL ); + } + bs_opaque->job =NULL ;bdrv_drained_end (src);
Signature · 1 line
2.39.2
Ping. Could someone please review the code?
Quoted 39 lines · Alexander Ivanov
If a blockcommit is aborted the base image remains in RW mode, that leads to a fail of subsequent live migration.
How to reproduce:
$ virsh snapshot-create-as vm snp1 --disk-only*** write something to the disk ***
$ virsh blockcommit vm vda --active --shallow && virsh blockjob vm vda --abort $ lsof /vzt/vm.qcow2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME qemu-syst 433203 root 45u REG 253,0 1724776448 133 /vzt/vm.qcow2 $ cat /proc/433203/fdinfo/45 pos: 0 flags: 02140002Reopen the base image in RO mode in
mirror_exit_common()if the blockjob is aborted.Signed-off-by Alexander Ivanov <[email protected]>--- block/mirror.c | 4 ++++ 1 file changed, 4 insertions(+)block/mirror.c +4
-0@@ -789,6 +789,10 @@ static int mirror_exit_common(Job *job)block_job_remove_all_bdrv (bjob);bdrv_replace_node (mirror_top_bs, mirror_top_bs->backing->bs, &error_abort); +if (abort && !bdrv_is_read_only (target_bs)) { +bdrv_reopen_set_read_only (target_bs, true,NULL ); + } + bs_opaque->job =NULL ;bdrv_drained_end (src);
Signature · 2 lines
Best regards, Alexander Ivanov
Quoted 29 lines · Alexander Ivanov
If a blockcommit is aborted the base image remains in RW mode, that leads to a fail of subsequent live migration.
How to reproduce:
$ virsh snapshot-create-as vm snp1 --disk-only*** write something to the disk ***
$ virsh blockcommit vm vda --active --shallow && virsh blockjob vm vda --abort $ lsof /vzt/vm.qcow2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME qemu-syst 433203 root 45u REG 253,0 1724776448 133 /vzt/vm.qcow2 $ cat /proc/433203/fdinfo/45 pos: 0 flags: 02140002Reopen the base image in RO mode in
mirror_exit_common()if the blockjob is aborted.Signed-off-by Alexander Ivanov <[email protected]>--- block/mirror.c | 4 ++++ 1 file changed, 4 insertions(+)block/mirror.c +0
-0
block/mirror.c static int mirror_exit_common(Job *job) · line 792
Quoted 4 lines
block/mirror.c +1
-0@@ -789,6 +789,10 @@ static int mirror_exit_common(Job *job)block_job_remove_all_bdrv (bjob);bdrv_replace_node (mirror_top_bs, mirror_top_bs->backing->bs, &error_abort); +if (abort && !bdrv_is_read_only (target_bs)) {
I think, we also should check here, that we did bdrv_reopen_set_read_only(false) at job start (probably we didn't, or we are in mirror job)
Quoted 6 lines
block/mirror.c +3
-0+bdrv_reopen_set_read_only (target_bs, true,NULL ); + } + bs_opaque->job =NULL ;bdrv_drained_end (src);
Signature · 2 lines
Best regards, Vladimir