From: "Jim C. Brown" <jma5@umd.edu>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: qemu disk on vfat
Date: Mon, 8 May 2006 18:48:46 -0400 [thread overview]
Message-ID: <20060508224846.GA9668@jbrown.mylinuxbox.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0605082301510.18524-100000@zeskia.int.eridani.co.uk>
[-- Attachment #1: Type: text/plain, Size: 821 bytes --]
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.
[-- Attachment #2: block.patch --]
[-- Type: text/plain, Size: 1211 bytes --]
--- block.c.orig Mon May 8 18:34:02 2006
+++ block.c Mon May 8 18:44:18 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,27 @@
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)
+ return 0;
+ printf("Warning: your filesystem does not appear to support sparse file\nFalling back to pseudo-/dev/zero method\nSit back and enjoy a cup of coffee... This may take a while.\n");
+
+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
+ 0644);
+ if (fd < 0)
+ return -EIO;
+ memset(buf512, 0, 512);
+ for (i = 0; i < total_size; i++)
+ write(fd, buf512, 512);
+ close(fd);
+
return 0;
}
next prev parent reply other threads:[~2006-05-08 22:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-08 10:04 [Qemu-devel] qemu disk on vfat Yann Le Doaré
2006-05-07 8:44 ` André Braga
2006-05-08 10:41 ` Yann Le Doaré
2006-05-07 15:50 ` [Qemu-devel] " Alex
2006-05-07 11:00 ` [Qemu-devel] " NyOS
2006-05-07 13:47 ` Jernej Simončič
2006-05-08 19:44 ` Yann Le Doaré
2006-05-08 14:57 ` Jan Marten Simons
2006-05-09 21:05 ` Yann Le Doaré
2006-05-07 11:21 ` Johannes Schindelin
2006-05-08 21:12 ` [Qemu-devel] " Anthony Liguori
2006-05-09 23:41 ` Yann Le Doaré
2006-05-08 22:05 ` Michael McConnell
2006-05-08 22:48 ` Jim C. Brown [this message]
2006-05-08 23:10 ` Jim C. Brown
2006-05-08 23:50 ` Jim C. Brown
2006-05-09 1:36 ` Anthony Liguori
2006-05-09 2:11 ` Paul Brook
2006-05-16 17:21 ` Jim C. Brown
2006-05-08 22:23 ` Ian C. Blenke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060508224846.GA9668@jbrown.mylinuxbox.org \
--to=jma5@umd.edu \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).