From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKN0u-0002Go-O4 for qemu-devel@nongnu.org; Wed, 29 Jul 2015 04:47:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKN0q-0006E3-Km for qemu-devel@nongnu.org; Wed, 29 Jul 2015 04:47:00 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:34969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKN0q-0006Dk-EC for qemu-devel@nongnu.org; Wed, 29 Jul 2015 04:46:56 -0400 Received: by wibxm9 with SMTP id xm9so190615749wib.0 for ; Wed, 29 Jul 2015 01:46:55 -0700 (PDT) Date: Wed, 29 Jul 2015 09:46:53 +0100 From: Stefan Hajnoczi Message-ID: <20150729084653.GB10617@stefanha-thinkpad.redhat.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gatW/ieO32f1wygP" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] Using the one disk image file on 2 virtual machines at the same time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Manjong Han Cc: qemu-devel@nongnu.org --gatW/ieO32f1wygP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 29, 2015 at 12:57:30AM +0900, Manjong Han wrote: > I was facing a weird behavior when I used the one disk image file on 2 > virtual machines at the same time. >=20 > I made the instance of a virtual machine, using the below command. > $ qemu-system-x86_64 -smp 2 -m 1024 -hda 10G.qcow2 -enable-kvm >=20 > When the OS(Ubuntu 14.04 64bit) was booted up, I made an another one, usi= ng > same command. > $ qemu-system-x86_64 -smp 2 -m 1024 -hda 10G.qcow2 -enable-kvm >=20 > Then, I had 2 virtual machines, using same disk image file. This configuration is invalid. It's similar to using the same physical disk or iSCSI LUN from two machines at the same time. Standard file systems (ext4, xfs) and volume managers (LVM) are not cluster-aware by default. They must only be accessed from one machine at a time. Otherwise you risk data corruption. You should probably use qcow2 backing files instead: 10G.qcow2 <-- vm001.qcow2 ^-- vm002.qcow2 The command to create these files is: qemu-img create -f qcow2 -o backing_file=3D10G.qcow2 vm001.qcow2. Both VMs share the data in 10G.qcow2. All writes go to vm001.qcow2 or vm002.qcow2, respectively, so they don't corrupt each other. Stefan --gatW/ieO32f1wygP Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVuJL9AAoJEJykq7OBq3PIX7MIAKDs7m1wKdtr/cZdZdDC5Y7B M4bRjDnl4Ok0dPESPH0D2EXuXeHauIqUxEw/PhT/OBFEnpri06DnwDizsFh772Xn 8HGIyLKufBR791h36LAtqtyo1z531cqe4dWre3qG06x//jZTFoE+O7JUO9oryk1b 87wRfGcahLoWWbTDMclMssFHMvbzpoiGjSCESkNQ4jad0oDKAA0cQk2JfvdnnAqe KnaCT+khkzAchYn0nu7k6gx25yUmIpsjANVmUFBBQazmIVolJK0i5hNPQGNWE8e0 lvB/ED2xmP/vuNQ3yTA6Pqi0DlFGELIprnom7YhguyL3w/D/hrFBicllvqHMV/4= =pozS -----END PGP SIGNATURE----- --gatW/ieO32f1wygP--