[Sheepdog] VDI locking, migration and qemu

Chris Webb chris at arachsys.com
Mon Nov 23 14:06:11 CET 2009


I've been reading the qemu/block/sheepdog.c and the sheepdog code, and have
been thinking about the locking/migration problem mentioned in the FAQ.

During migration, we go through three phases: firstly the source guest is
running with the destination stopped, then both guests are stopped, and
finally only the destination guest is running with the source still stopped
and eventually exiting. If the VDI lock is only held when the guest is
actually running (not when it is stopped), there's no conflict or
difficulty.

Unfortunately, qemu's block interface doesn't give us hooks for this, just
bdrv_open and bdrv_close. It feels like the right thing to do might be to
introduce bdrv_claim and bdrv_release hooks with corresponding
bdrv_claim_all() and bdrv_release_all() functions in block.c. We could then
call bdrv_claim_all at the beginning of vm_start() and bdrv_release at the
end of do_vm_stop().

Quite apart from sheepdog, this would also enable things like fcntl locking
qcow2 files to prevent accidental corruption by concurrent qemu access
without breaking migration of guests using them.

Does this sound like a sane approach? If so, I'll have a go at producing a
patch for qemu.

Cheers,

Chris.



More information about the sheepdog mailing list