From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuLA3-0004JP-Nd for qemu-devel@nongnu.org; Thu, 26 Jul 2012 06:19:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SuL9z-0003yJ-Bq for qemu-devel@nongnu.org; Thu, 26 Jul 2012 06:19:15 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:45557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuL9y-0003xe-QH for qemu-devel@nongnu.org; Thu, 26 Jul 2012 06:19:11 -0400 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Jul 2012 20:18:52 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6QAAr7010027264 for ; Thu, 26 Jul 2012 20:10:53 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6QAJ2WU011434 for ; Thu, 26 Jul 2012 20:19:02 +1000 Message-ID: <50111994.9060506@linux.vnet.ibm.com> Date: Thu, 26 Jul 2012 18:19:00 +0800 From: Bing Bu Cao MIME-Version: 1.0 References: <5010B0CE.2050900@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] How to share disk image between two kvm guests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: aliguori@us.ibm.com, QEMU Developers On 07/26/2012 05:30 PM, Stefan Hajnoczi wrote: > On Thu, Jul 26, 2012 at 3:51 AM, 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? > > 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