From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui2HZ-0000bZ-9k for qemu-devel@nongnu.org; Thu, 30 May 2013 08:48:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ui2HS-0003YL-Sd for qemu-devel@nongnu.org; Thu, 30 May 2013 08:48:41 -0400 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:52298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui2HS-0003YG-MG for qemu-devel@nongnu.org; Thu, 30 May 2013 08:48:34 -0400 Received: by mail-wg0-f47.google.com with SMTP id e11so194718wgh.14 for ; Thu, 30 May 2013 05:48:34 -0700 (PDT) Date: Thu, 30 May 2013 14:48:30 +0200 From: Stefan Hajnoczi Message-ID: <20130530124830.GA6169@stefanha-thinkpad.redhat.com> References: <51A72673.7090300@linux.vnet.ibm.com> <51A74210.3000302@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51A74210.3000302@redhat.com> Subject: Re: [Qemu-devel] [RFC] Check backing_file chain's loop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: "kwolf@redhat.com" , Dongxu Wang , qemu-devel@nongnu.org, stefanha@redhat.com On Thu, May 30, 2013 at 06:12:00AM -0600, Eric Blake wrote: > On 05/30/2013 04:14 AM, Dongxu Wang wrote: > > Hi, > > > > Now block layer does not check whether backing_file chain can be a > > circle, do you think it is necessary to do a check? > > > > For example, 1.qcow2's backing_file is 2.qcow2 and 2.qcow2's > > backing_file is 1.qcow2, then any IO operation will be a fault. > > > > If necessary, I will post a patch to fix. > > Yes, it's worth patching. > > > > > [$] qemu-img create -f qcow2 1.qcow2 > > qemu-img: Image creation needs a size parameter > > [$] qemu-img create -f qcow2 1.qcow2 8M > > Formatting '1.qcow2', fmt=qcow2 size=8388608 encryption=off > > cluster_size=65536 lazy_refcounts=off > > [$] qemu-img create -f qcow2 2.qcow2 -o backing_file=1.qcow2 > > Formatting '2.qcow2', fmt=qcow2 size=8388608 backing_file='1.qcow2' > > encryption=off cluster_size=65536 lazy_refcounts=off > > [$] qemu-img create -f qcow2 1.qcow2 -o backing_file=2.qcow2 > > Formatting '1.qcow2', fmt=qcow2 size=8388608 backing_file='2.qcow2' > > encryption=off cluster_size=65536 lazy_refcounts=off > > [$] qemu-io -c "read -v 0 512" 1.qcow2 > > ^CSegmentation fault (core dumped) > > Also make sure that 'qemu-img info 1.qcow2' and 'qemu-img info > --backing-chain 1.qcow2' don't crash. qemu-img info --backing-chain detects cycles and returns an error, see the hash table in collect_image_info_list(). We should protect bdrv_open() too. Stefan