From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:45487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF0YL-0002xk-Ar for qemu-devel@nongnu.org; Wed, 27 Apr 2011 04:57:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QF0YG-0003vK-SS for qemu-devel@nongnu.org; Wed, 27 Apr 2011 04:56:57 -0400 Received: from fnarfbargle.com ([93.93.131.67]:50818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QF0YG-0003uf-OB for qemu-devel@nongnu.org; Wed, 27 Apr 2011 04:56:52 -0400 Message-ID: <4DB7DA44.4030008@fnarfbargle.com> Date: Wed, 27 Apr 2011 16:56:36 +0800 From: Brad Campbell MIME-Version: 1.0 References: <4DB7880C.4090302@fnarfbargle.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Qemu-img convert with -B List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Brad Campbell On 27/04/11 16:10, Stefan Hajnoczi wrote: > On Wed, Apr 27, 2011 at 4:05 AM, Brad Campbell > wrote: >> I see there is a bug raised about the behaviour of qemu-img when used to convert using an output backing file. It allocates every sector whether or not it already exists in the output backing file. > Please post the link to the bug report. > Yeah, sorry about that. Not very clever of me. https://bugs.launchpad.net/qemu/+bug/660366 >> Can someone verify these assumptions for me please? >> - I can bdrv_open() a file that has a chain of backing files, and the >> following is true : >> - bdrv_read() returns the most recently allocated sector contents (or >> 0) > Correct. > >> - bdrv_is_allocated() will return false only if that sector is not >> allocated in _any_ of the files in the chain > Incorrect. It returns true if the sector is allocated in the top-most > file, false otherwise. In other words bdrv_is_allocated() is flat, it > does not traverse a chain of backing files. Right. I guess the correct way to do this is to open and traverse all the input and output backing files, but I don't see why that should be necessary as the output file is created O_RDWR. Now as the output file is created with the backing_file option, can I simply bdrv_read() both input and output files, and only write to the output file if the sector differs or != 0? Seems like that would be the logical way to do everything right while leveraging the complexity of the block drivers. It would also allow for maximum "compression" of the output file if the filesystem has all unused space wiped (which is my desired usage case). Brad