savevm/delvm: Is it neccesary to perform bdrv_drain_all before savevm and delvm?
Hi,
I noticed that bdrv_drain_all is performed in load_vmstate before bdrv_snapshot_goto, and bdrv_drain_all is performed in qmp_transaction before internal_snapshot_prepare, so is it also neccesary to perform bdrv_drain_all in savevm and delvm?
Thanks,
Zhang Haoyu
Am 20.10.2014 um 15:48 hat Zhang Haoyu geschrieben:
Quoted 5 lines
Hi,
I noticed that
bdrv_drain_allis performed inload_vmstatebeforebdrv_snapshot_goto, andbdrv_drain_allis performed inqmp_transactionbeforeinternal_snapshot_prepare, so is it also neccesary to performbdrv_drain_allin savevm and delvm?
Definitely yes for savevm. do_savevm() calls it indirectly via vm_stop(), so that part looks okay.
delvm doesn't affect the currently running VM, and therefore doesn't interfere with guest requests that are in flight. So I think that a bdrv_drain_all() isn't needed there.
Kevin
Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to perform bdrv_drain_all before savevm and delvm?
Quoted 9 lines
Quoted 5 lines
Hi,
I noticed that
bdrv_drain_allis performed inload_vmstatebeforebdrv_snapshot_goto, andbdrv_drain_allis performed inqmp_transactionbeforeinternal_snapshot_prepare, so is it also neccesary to performbdrv_drain_allin savevm and delvm?Definitely yes for savevm.
do_savevm()calls it indirectly viavm_stop(), so that part looks okay.
Yes, you are right.
Quoted 4 lines
delvm doesn't affect the currently running VM, and therefore doesn't interfere with guest requests that are in flight. So I think that a
bdrv_drain_all()isn't needed there.
I'm worried about that there are still pending IOs while deleting snapshot, then is it possible that there is concurrency problem between the process of deleting snapshot and the coroutine of io read/write(bdrv_co_do_rw) invoked by the pending IOs? This coroutine is also in main thread.
Am I missing something?
Thanks,
Zhang Haoyu
Quoted 1 line
Kevin
Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to perform bdrv_drain_all before savevm and delvm?
Am 20.10.2014 um 17:09 hat Zhang Haoyu geschrieben:
Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
Hi,
I noticed that
bdrv_drain_allis performed inload_vmstatebefore
bdrv_snapshot_goto,Quoted 1 line
Quoted 1 line
and
bdrv_drain_allis performed inqmp_transactionbefore
internal_snapshot_prepare,Quoted 5 lines
Quoted 1 line
so is it also neccesary to perform
bdrv_drain_allin savevm and delvm?Definitely yes for savevm.
do_savevm()calls it indirectly viavm_stop(), so that part looks okay.Yes, you are right.
Quoted 4 lines
delvm doesn't affect the currently running VM, and therefore doesn't interfere with guest requests that are in flight. So I think that a
bdrv_drain_all()isn't needed there.
Quoted 7 lines
I'm worried about that there are still pending IOs while deleting snapshot, then is it possible that there is concurrency problem between the process of deleting snapshot
and the coroutine of io read/write(bdrv_co_do_rw) invoked by the pending IOs?
This coroutine is also in main thread.
Am I missing something?
What kind of concurrency problem are you thinking of?
I do see that there might be a chance of concurrency, but that doesn't automatically mean the requests are conflicting.
Would you feel better with taking s->lock in qcow2_snapshot_delete()? This might actually be a valid concern.
Kevin
Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to perform bdrv_drain_all before savevm and delvm?
Quoted 25 lines
Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
Hi,
I noticed that
bdrv_drain_allis performed inload_vmstatebefore
bdrv_snapshot_goto,Quoted 1 line
Quoted 1 line
and
bdrv_drain_allis performed inqmp_transactionbefore
internal_snapshot_prepare,Quoted 5 lines
Quoted 1 line
so is it also neccesary to perform
bdrv_drain_allin savevm and delvm?Definitely yes for savevm.
do_savevm()calls it indirectly viavm_stop(), so that part looks okay.Yes, you are right.
Quoted 4 lines
delvm doesn't affect the currently running VM, and therefore doesn't interfere with guest requests that are in flight. So I think that a
bdrv_drain_all()isn't needed there.Quoted 7 lines
I'm worried about that there are still pending IOs while deleting snapshot, then is it possible that there is concurrency problem between the process of deleting snapshot
and the coroutine of io read/write(bdrv_co_do_rw) invoked by the pending IOs?
This coroutine is also in main thread.
Am I missing something?
Quoted 2 lines
What kind of concurrency problem are you thinking of?
I have encountered two problem,
1) double-free of Qcow2DiscardRegion in qcow2_process_discards
please see the discussing mail: [PATCH] qcow2: fix double-free of Qcow2DiscardRegion in qcow2_process_discards
2) qcow2 image is truncated to very huge size, but the size shown by qemu-img info is normal
please see the discussing mail:
[question] is it possible that big-endian l1 table offset referenced by other I/O while updating l1 table offset in qcow2_update_snapshot_refcount?
I suspect that both of the two problems are concurrency problem mentioned above, please see the discussing mail.
Quoted 4 lines
I do see that there might be a chance of concurrency, but that doesn't automatically mean the requests are conflicting.
Would you feel better with taking
s->lockinqcow2_snapshot_delete()?
Both deleting snapshot and the coroutine of pending io read/write(bdrv_co_do_rw) are performed in main thread, could BDRVQcowState.lock work?
Thanks,
Zhang Haoyu
Quoted 3 lines
This might actually be a valid concern.
Kevin
Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to perform bdrv_drain_all before savevm and delvm?
Am 21.10.2014 um 03:13 hat Zhang Haoyu geschrieben:
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 3 lines
Quoted 3 lines
Hi,
I noticed that
bdrv_drain_allis performed inload_vmstatebefore
bdrv_snapshot_goto,Quoted 1 line
Quoted 1 line
and
bdrv_drain_allis performed inqmp_transactionbefore
internal_snapshot_prepare,Quoted 5 lines
Quoted 1 line
so is it also neccesary to perform
bdrv_drain_allin savevm and delvm?Definitely yes for savevm.
do_savevm()calls it indirectly viavm_stop(), so that part looks okay.Yes, you are right.
Quoted 4 lines
delvm doesn't affect the currently running VM, and therefore doesn't interfere with guest requests that are in flight. So I think that a
bdrv_drain_all()isn't needed there.I'm worried about that there are still pending IOs while deleting snapshot, then is it possible that there is concurrency problem between the process of deleting snapshot
and the coroutine of io read/write(bdrv_co_do_rw) invoked by the pending IOs?
This coroutine is also in main thread.
Am I missing something?
Quoted 8 lines
Quoted 2 lines
What kind of concurrency problem are you thinking of?
I have encountered two problem,
1) double-free of Qcow2DiscardRegion inqcow2_process_discards
please see the discussing mail: [PATCH] qcow2: fix double-free of Qcow2DiscardRegion inqcow2_process_discards
2) qcow2 image is truncated to very huge size, but the size shown by qemu-img info is normal
please see the discussing mail:
[question] is it possible that big-endian l1 table offset referenced by other I/O while updating l1 table offset inqcow2_update_snapshot_refcount?
Did you verify that the invalid value actually makes sense if byteswapped? For example, that there is no reserved bit set then?
Quoted 10 lines
I suspect that both of the two problems are concurrency problem mentioned above, please see the discussing mail.
Quoted 4 lines
I do see that there might be a chance of concurrency, but that doesn't automatically mean the requests are conflicting.
Would you feel better with taking
s->lockinqcow2_snapshot_delete()?Both deleting snapshot and the coroutine of pending io read/write(bdrv_co_do_rw) are performed in main thread, could BDRVQcowState.lock work?
Yes. s->lock is not a mutex for threads, but a coroutine based one.
The problem, however, is that qcow2_snapshot_delete() isn't execute in a coroutine, so we can't take s->lock here. We would either need to move it into a coroutine or add a bdrv_drain_all() indeed.
This also means that we probably need to review all other cases where non-coroutine callbacks from BlockDriver might interfere with running requests. The original assumption that they are safe as long as they are not running in a coroutine seems to be wrong.
Kevin
Re: [Qemu-devel] [question] savevm/delvm: Is it necessary to performbdrv_drain_all before savevm and delvm?
Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
Quoted 3 lines
Quoted 3 lines
Hi,
I noticed that
bdrv_drain_allis performed inload_vmstatebefore
bdrv_snapshot_goto,Quoted 20 lines
Quoted 1 line
Quoted 1 line
and
bdrv_drain_allis performed inqmp_transactionbefore
internal_snapshot_prepare,Quoted 5 lines
Quoted 1 line
so is it also neccesary to perform
bdrv_drain_allin savevm and delvm?Definitely yes for savevm.
do_savevm()calls it indirectly viavm_stop(), so that part looks okay.Yes, you are right.
Quoted 4 lines
delvm doesn't affect the currently running VM, and therefore doesn't interfere with guest requests that are in flight. So I think that a
bdrv_drain_all()isn't needed there.I'm worried about that there are still pending IOs while deleting snapshot, then is it possible that there is concurrency problem between the process of deleting snapshot
and the coroutine of io read/write(bdrv_co_do_rw) invoked by the pending IOs?
This coroutine is also in main thread.
Am I missing something?Quoted 8 lines
Quoted 2 lines
What kind of concurrency problem are you thinking of?
I have encountered two problem,
1) double-free of Qcow2DiscardRegion inqcow2_process_discards
please see the discussing mail: [PATCH] qcow2: fix double-free of Qcow2DiscardRegion inqcow2_process_discards
2) qcow2 image is truncated to very huge size, but the size shown by qemu-img info is normal
please see the discussing mail:
[question] is it possible that big-endian l1 table offset referenced by other I/O while updating l1 table offset inqcow2_update_snapshot_refcount?
Quoted 3 lines
Did you verify that the invalid value actually makes sense if byteswapped? For example, that there is no reserved bit set then?
Yes, exactly, I have verified that those l2 table offset are invalid value if byte-swapped.
Quoted 4 lines
Quoted 4 lines
I suspect that both of the two problems are concurrency problem mentioned above, please see the discussing mail.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
I do see that there might be a chance of concurrency, but that doesn't automatically mean the requests are conflicting.
Would you feel better with taking
s->lockinqcow2_snapshot_delete()?Both deleting snapshot and the coroutine of pending io read/write(bdrv_co_do_rw) are performed in main thread, could BDRVQcowState.lock work?
Yes.
s->lockis not a mutex for threads, but a coroutine based one.
Yes, you are right.
Quoted 4 lines
The problem, however, is that
qcow2_snapshot_delete()isn't execute in a coroutine, so we can't takes->lockhere. We would either need to move it into a coroutine or add abdrv_drain_all()indeed.
I'm inclined to add bdrv_drain_all(), just keeping consistent with the other snapshot-related operations, like savevm, loadvm, internal_snapshot_prepare, etc.
Thanks,
Zhang Haoyu
Quoted 4 lines
This also means that we probably need to review all other cases where non-coroutine callbacks from BlockDriver might interfere with running requests. The original assumption that they are safe as long as they are not running in a coroutine seems to be wrong.
Agreed.
Quoted 2 lines
Kevin