qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] How to share disk image between two kvm guests


From: Mike Lovell
Subject: Re: [Qemu-discuss] How to share disk image between two kvm guests
Date: Fri, 27 Jul 2012 15:58:37 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0

On 07/24/2012 11:20 PM, Bing Bu Cao wrote:
Hi,all

I want to use qemu-nbd to share disk between two kvm guests.

I.
# qemu-nbd -p 1024 -e 2 -n my-disk.qcow2
# nbd-client localhost 1024 /dev/nbd0
# nbd-client localhost 1024 /dev/nbd1

II.
guest1:
# /usr/local/bin/qemu -enable-kvm -m 1024 -drive file=ubuntu.img -drive file=/dev/nbd0,cache=none -net user -net nic,model=virtio -chardev stdio,id=mon0 -mon chardev=mon0 -usb -device usb-tablet

guest2:
# /usr/local/bin/qemu -enable-kvm -m 1024 -drive file=ubuntu.img -drive file=/dev/nbd0,cache=none -net user -net nic,model=virtio -chardev stdio,id=mon0 -mon chardev=mon0 -usb -device usb-tablet

Found one problem:
No disk r/w sync between 2 virtual hosts.
One write/change on the shared disk,
another virtual host must remount the disk and can see the update from the other virtual host.

For example,a simply test:
In the guest1,mount the disk and create on text file add some line to it.
In the guest2,mount the same disk and print the text file and found the content is not updated.
But after after I remount the disk, the content will be updated.

Is it a issue of guest OS or qemu-nbd? Can you help me?

i'm guessing that you are mounting the 'shared disk' in both guests using a non-cluster aware filesystem. i.e. ext2/3/4, reiserfs, xfs, jfs, etc. these file systems are assumed that the system mounting the disk is the only system thats going to be writing to the disk. if two systems mounted the same disk as writable, each system could end up writing different data to the same blocks of storage or changing the metadata that is written and the other system is not expecting those changes to happen. this can very easily and quickly lead to data corruption in the filesystem. if you plan on mounting the same shared block device in multiple guests, you are going to need to use a cluster aware file system such as ocfs2 or gfs.

mike



reply via email to

[Prev in Thread] Current Thread [Next in Thread]