qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] How to share disk image between two kvm guests
@ 2012-07-26  2:51 Bing Bu Cao
  2012-07-26  9:30 ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Bing Bu Cao @ 2012-07-26  2:51 UTC (permalink / raw)
  To: QEMU Developers, aliguori; +Cc: Bing Bu Cao

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?



-- 
Best Regards,
Bing Bu Cao

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] How to share disk image between two kvm guests
  2012-07-26  2:51 [Qemu-devel] How to share disk image between two kvm guests Bing Bu Cao
@ 2012-07-26  9:30 ` Stefan Hajnoczi
  2012-07-26 10:19   ` Bing Bu Cao
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-07-26  9:30 UTC (permalink / raw)
  To: Bing Bu Cao; +Cc: aliguori, QEMU Developers

On Thu, Jul 26, 2012 at 3:51 AM, Bing Bu Cao <mars@linux.vnet.ibm.com> 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?

It's a guest OS issue.  If you want to share the same disk between
multiple machines you need to use a cluster file system.  If you are
using something like ext4 which is not a cluster file system then
mounting it from two or more machines simultaneously may corrupt the
file system or at least give an inconsistent view.

Which file system are you using inside the guest?

Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] How to share disk image between two kvm guests
  2012-07-26  9:30 ` Stefan Hajnoczi
@ 2012-07-26 10:19   ` Bing Bu Cao
  0 siblings, 0 replies; 3+ messages in thread
From: Bing Bu Cao @ 2012-07-26 10:19 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: aliguori, QEMU Developers

On 07/26/2012 05:30 PM, Stefan Hajnoczi wrote:
> On Thu, Jul 26, 2012 at 3:51 AM, Bing Bu Cao<mars@linux.vnet.ibm.com>  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?
>
> It's a guest OS issue.  If you want to share the same disk between
> multiple machines you need to use a cluster file system.  If you are
> using something like ext4 which is not a cluster file system then
> mounting it from two or more machines simultaneously may corrupt the
> file system or at least give an inconsistent view.
>
> Which file system are you using inside the guest?
Now using ext4 as file system inside the both guests.
Got it.
Thank you,Stefan.
>
> Stefan
>


-- 
Best Regards,
Bing Bu Cao

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-26 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-26  2:51 [Qemu-devel] How to share disk image between two kvm guests Bing Bu Cao
2012-07-26  9:30 ` Stefan Hajnoczi
2012-07-26 10:19   ` Bing Bu Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).