From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FdEs6-0005s2-HI for qemu-devel@nongnu.org; Mon, 08 May 2006 19:10:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FdEs6-0005rq-4f for qemu-devel@nongnu.org; Mon, 08 May 2006 19:10:34 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FdEs6-0005rn-02 for qemu-devel@nongnu.org; Mon, 08 May 2006 19:10:34 -0400 Received: from [128.8.10.163] (helo=po1.wam.umd.edu) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FdEt1-0002DV-S6 for qemu-devel@nongnu.org; Mon, 08 May 2006 19:11:31 -0400 Received: from jbrown.mylinuxbox.org (jma-box.student.umd.edu [129.2.253.219]) by po1.wam.umd.edu (8.12.11.20060308/8.12.10) with ESMTP id k48NAXZ2006164 for ; Mon, 8 May 2006 19:10:33 -0400 (EDT) Date: Mon, 8 May 2006 19:10:32 -0400 From: "Jim C. Brown" Subject: Re: [Qemu-devel] Re: qemu disk on vfat Message-ID: <20060508231032.GA12871@jbrown.mylinuxbox.org> References: <1147218062.9211.2.camel@localhost> <20060508224846.GA9668@jbrown.mylinuxbox.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <20060508224846.GA9668@jbrown.mylinuxbox.org> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, May 08, 2006 at 06:48:46PM -0400, Jim C. Brown wrote: > On Mon, May 08, 2006 at 11:05:00PM +0100, Michael McConnell wrote: > > IIRC creating a "raw" QEMU disc image makes use of sparse files, a concept > > not supported under FAT16/32. A qcow disc image should work fine. If you > > want to create a raw disc image on a FAT partition, use (from your example) > > dd if=/dev/zero of=/mnt/partitions/windows0/qmeu-disk bs=1024 count=40960 > > > > It'll take a bit longer than qemu-img would but then it's having to write out > > every block in the disc image to the real disc. > > > > Hope that helps. > > > > Here is a patch that fixes the raw block driver. It is able to detect when > creation of a sparse file failed and failback to using the dd method. > > qemu-img works correctly with this patch. > > -- > Infinite complexity begets infinite beauty. > Infinite precision begets infinite perfection. This version doesn't try to continue but just bails out when it is unable to make sparse files. -- Infinite complexity begets infinite beauty. Infinite precision begets infinite perfection. --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="block.patch" --- block.c.orig Mon May 8 18:34:02 2006 +++ block.c Mon May 8 19:07:30 2006 @@ -756,7 +756,8 @@ static int raw_create(const char *filename, int64_t total_size, const char *backing_file, int flags) { - int fd; + int fd, size, i; + unsigned char buf512[512]; if (flags || backing_file) return -ENOTSUP; @@ -767,6 +768,20 @@ return -EIO; ftruncate(fd, total_size * 512); close(fd); + + /* check to see if the filesystem handled sparseness correctly */ + fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE); + if (fd < 0) + return -EIO; // some weird badness happened here + size = lseek(fd, 0LL, SEEK_END); + close(fd); + + if (!size) + { + printf("Error: your filesystem does not appear to support sparse file\n"); + return -EIO; + } + return 0; } --AhhlLboLdkugWU4S--