Skip to contentSkip to conversation

guest sync and bdrv_co_flush

Qemu-devel lihuiba 2 participants 2 messages Nov 7, 2014 – Nov 10, 2014

lore
Share & tools
lore

lihuiba

author
#0 lore raw

Hi, all

I'm a user of qemu/kvm, and I'm wondering some internals of qemu/kvm, so I'd better post it in this developer's mailing list.

To be specific, I'm wondering how data is flushed to disk. Intuitively, when the guest issues a SYNCHRONIZE CACHE command in the SCSI layer, qemu/kvm should call bdrv_co_flush(), which will eventually call the block driver's bdrv_co_flush_to_os() and bdrv_co_flush_to_disk().

But from simple grep-ing, I didn't find any calling to bdrv_co_flush() is responsible for SYNCHRONIZE CACHE. So, can you tell me how qemu/kvm ensures guest data be written on persistent storage?

Thank you, very much!

#1 lore raw

Am 07.11.2014 um 09:39 hat lihuiba geschrieben:

Quoted 13 lines

Hi, all

I'm a user of qemu/kvm, and I'm wondering some internals of qemu/kvm, so I'd better post it in
this developer's mailing list.

To be specific, I'm wondering how data is flushed to disk. Intuitively, when the guest issues a
SYNCHRONIZE CACHE command in the SCSI layer, qemu/kvm should call bdrv_co_flush (),
which will eventually call the block driver's bdrv_co_flush_to_os() and bdrv_co_flush_to_disk().

Quoted 4 lines

But from simple grep-ing, I didn't find any calling to bdrv_co_flush() is responsible for SYNCHRONIZE
CACHE. So, can you tell me how qemu/kvm ensures guest data be written on persistent storage?

The relevant code is in hw/scsi/scsi-disk.c, in the function scsi_disk_emulate_command(), for 'case SYNCHRONIZE_CACHE:'.

The call chain from there is blk_aio_flush() -> bdrv_aio_flush() -> bdrv_aio_flush_co_entry() -> bdrv_co_flush()

Kevin