From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXzyH-0002dK-Jz for qemu-devel@nongnu.org; Tue, 06 Dec 2011 13:42:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXzyG-000058-J0 for qemu-devel@nongnu.org; Tue, 06 Dec 2011 13:42:29 -0500 Received: from verein.lst.de ([213.95.11.211]:35685 helo=newverein.lst.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXzyG-00004u-BD for qemu-devel@nongnu.org; Tue, 06 Dec 2011 13:42:28 -0500 Date: Tue, 6 Dec 2011 19:42:26 +0100 From: Christoph Hellwig Message-ID: <20111206184226.GA18058@lst.de> References: <958CDBC95A3252B592B5E3C9@nimrod.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <958CDBC95A3252B592B5E3C9@nimrod.local> Subject: Re: [Qemu-devel] RFC: raw device support for block device targets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: qemu-devel@nongnu.org On Tue, Dec 06, 2011 at 04:20:56PM +0000, Alex Bligh wrote: > qemu-img convert appears to support block devices as input, but not > as output. That is irritating, as when using qemu-img convert to > convert qcow to raw on a block partition, an intermediate file has > to be used, which slows things down and pointlessly uses disk space. > > The problem is that ftruncate() is being called on the output file > in order ensure it is sufficiently large, and this fails on > block devices. > > I appreciate there may be other calls that fail depending on the > input file format, but these will presumably be error checked > at the time. > > Is it therefore worth skipping the ftruncate() if the block device > is large enough, and at least attempting to proceed further? Something > like the following (not-even compile tested) patch? It probably should share the code with raw_truncate. That is factor a new raw_truncate_common that is equivalent to raw_truncate but takes a file descriptor instead of a block driver state and then use it for both raw_truncate and raw_create.