From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpCVY-0006aU-D9 for qemu-devel@nongnu.org; Wed, 19 Jun 2013 03:08:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpCVV-0006Ed-GT for qemu-devel@nongnu.org; Wed, 19 Jun 2013 03:08:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpCVV-0006EI-91 for qemu-devel@nongnu.org; Wed, 19 Jun 2013 03:08:41 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5J78dEO009427 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 19 Jun 2013 03:08:39 -0400 Date: Wed, 19 Jun 2013 15:08:40 +0800 From: Fam Zheng Message-ID: <20130619070840.GA1262@localhost.nay.redhat.com> References: <51BF16B8.6040801@redhat.com> <20130617142605.GD3994@dhcp-200-207.str.redhat.com> <51BF213F.60601@redhat.com> <20130617151238.GF3994@dhcp-200-207.str.redhat.com> <20130618035854.GA17533@localhost.nay.redhat.com> <20130618063256.GB3640@dhcp-200-207.str.redhat.com> <20130618070023.GA1220@localhost.nay.redhat.com> <87obb3h58x.fsf@blackfin.pond.sub.org> <20130619011702.GA3331@localhost.nay.redhat.com> <87ppvir4wl.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ppvir4wl.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH] block: add 'backing' option to drive_add Reply-To: famz@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, stefanha@redhat.com On Wed, 06/19 08:27, Markus Armbruster wrote: > Fam Zheng writes: > > > On Tue, 06/18 16:18, Markus Armbruster wrote: > >> Fam Zheng writes: > >> > >> > On Tue, 06/18 08:32, Kevin Wolf wrote: > >> >> Am 18.06.2013 um 05:58 hat Fam Zheng geschrieben: > >> >> > On Mon, 06/17 17:12, Kevin Wolf wrote: > >> >> > > Am 17.06.2013 um 16:46 hat Paolo Bonzini geschrieben: > >> >> > > > Il 17/06/2013 16:26, Kevin Wolf ha scritto: > >> >> > > > > Am 17.06.2013 um 16:01 hat Paolo Bonzini geschrieben: > >> >> > > > >> Il 17/06/2013 15:52, Kevin Wolf ha scritto: > >> >> > > > >>> It's not a new thought that we need to change the block > >> >> > > > >>> layer so that a > >> >> > > > >>> BlockDriverState can't be "empty", but that one > >> >> > > > >>> BlockDriverState always > >> >> > > > >>> refers to one image. If you change media, you attach a different > >> >> > > > >>> BlockDriverState to the device. Once you have this, you can start > >> >> > > > >>> refcounting BlockDriverStates, so that the backing file > >> >> > > > >>> remains usable > >> >> > > > >>> while the guest device already uses a different image. > >> >> > > > >>> > >> >> > > > >>> Not that it's it easy to get there... > >> >> > > > >> > >> >> > > > >> I'm not sure that is safe to do. > >> >> > > > >> > >> >> > > > >> Consider the case where the guest switches from A to B > >> >> > > > >> during backup, > >> >> > > > >> and then from B to A. You get two BDS for the same file, > >> >> > > > >> which pretty > >> >> > > > >> much means havoc. > >> >> > > > > > >> >> > > > > Well, yes, it means that the management tool needs to > >> >> > > > > know what it's > >> >> > > > > doing. It shouldn't create a second BDS for A, but > >> >> > > > > reattach the still > >> >> > > > > existing one. > >> >> > > > > >> >> > > > How? That would require the management tool to know the > >> >> > > > full chain of > >> >> > > > BDSes that were opened in the past. > >> >> > > > >> >> > > They better know on which files they are operating. It's not like the > >> >> > > management could be unaware of running backup jobs or things like that. > >> >> > > > >> >> > > >> >> > Is there any case that QEMU needs to have two BDS pointing to the same > >> >> > file? > >> >> > >> >> No, I think there's no case where this would make sense. > >> >> > >> >> > If not, can we try to detect such case on opening and try to > >> >> > reuse the bs? > >> >> > >> >> We can't do it reliably, think about symlinks or even hard links, or > >> >> things like /dev/fdset/..., let alone remote protocols that refer to the > >> >> same image file etc. > >> >> > >> >> We can check the obvious cases and error out for them, but that's about > >> >> what we can do. I don't think we should try to fix things automagically > >> >> when we can't do it right. > >> > > >> > It's impossible to know a remote protocol points to the same image with > >> > local file path, that's not in QEMU's scope, but we have a good chance > >> > to detect (strcmp with existing bs->filename) and error out Paolo's > >> > A-B-A problem, don't we? > >> > >> Is comparing bs->filename always a good idea, or only if it's a local > >> image file? > > > > It's never sufficient by comparing filename to tell if they are the > > same, things can be tricky here, but in many cases it can be helpful, > > both local and remote. > > Let me rephrase my question. > > We all understand that different bs->filename can alias the same > resource (which is not necessarily a file). This makes a "same > resource" test based on bs->filename incomplete. > > Does identical bs->filename *always* imply same resource? No, I'm afraid we can't make too much assumption on this. > > If yes, the test is correct but incomplete. That can be useful. > > If no, the test is incorrect and incomplete, thus useless. > > >> If it's a local file, then comparing names to check for aliasing is > >> stupid. Compare device & inode instead. > > > > Device and inode is not something to block layer's knowledge, I think. > > They are one stat(2) or fstat(2) away. > -- Fam