Study KVM internal 4
Part 1: Study KVM block drivers’ code.
- bdrv_read()
Read data file from disk. First check BlockDriver, If BlockDriver not exists return –ENOMEDIUM;. Next, check length and accuracy of offset in ‘check byte request’ otherwise return –EIO. Finally, call drv->bdrv_read() read data from disk and store at buffer.
- bdrv_write()
Write data file onto disk. Check BlockDriver and ‘check byte request’ as bdrv_read(). If read_only return -EACCES;. Next, check if dirty bitmap exist, set dirty bitmap. Finally, call drv->bdrv_write()
- do_commit() and bdrv_commit()
Commit is an action of merge file from overlay image to base image. In this stage virtual machine shall must stop running before commit process. ‘do_commit’ use all drivers to commit in bdrv_commit(). ‘bdrv_commit()’ compares change in each sector on overlay with base image. If any a sector on base image will be overwrite with data from the same sector of overlay image.
Part 2: Virtual Machine migration.
Use ubuntu base image file created in previous Ex as a test source.
Assign base OS image as host, copy base OS image as agent.
We will migrate the agent.
Run bolt VM. We can notice that each VM has the same data.
Create in_BASE_HOST.txt file on base_host to test migration process.
Stop agent VM and re-run again with…
$kvm –m 512 –had base_host.img –incoming tcp://0:<port>
to let agent VM in waiting state at <assigned port>
Press Ctrl+Alt+2 in base_host window to switch in cmd mode.
Migrate with… command.
(qemu) migrate –d tcp://127.0.0.1:<agent waiting port>
*127.0.0.1 is localhost.
*‘(qemu) info migrate’ to view migration status.
Close agent VM after finished migration.
Run agent VM in normal mode again. We will notice that ‘in_BASE_HOST.txt’ has been existed in agent VM.
Reference :
http://www.linux-kvm.org/page/Migration
http://www.puysoft.com/kvm/p2.php
Salisa







































