* Re: [Qemu-devel] qemu disk on vfat
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 11:00 ` [Qemu-devel] " NyOS
` (2 subsequent siblings)
3 siblings, 1 reply; 20+ messages in thread
From: André Braga @ 2006-05-07 8:44 UTC (permalink / raw)
To: qemu-devel
It's more likely a typo in your command line. "qmeu"-disk?
On 5/8/06, Yann Le Doaré <yledoare@linuxconsole.org> wrote:
> Hi,
>
> It seems like qemu 0.8.0 does not accept image file from a vfat
> partition. Is it a bug ?
>
> Greetings.
>
> Yann Le Doaré.
>
>
> strace :
>
> open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> read(7, "", 1024) = 0
> close(7) = 0
> open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> _llseek(7, 128, [128], SEEK_SET) = 0
> read(7, "", 4) = 0
> close(7) = 0
> write(2, "qemu: could not open hard disk i"..., 74qemu: could not open
> hard disk image '/mnt/partitions/windows0/qmeu-disk'
> ) = 74
> exit_group(1) = ?
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] qemu disk on vfat
2006-05-08 10:04 [Qemu-devel] qemu disk on vfat Yann Le Doaré
2006-05-07 8:44 ` André Braga
@ 2006-05-07 11:00 ` NyOS
2006-05-07 13:47 ` Jernej Simončič
2006-05-08 19:44 ` Yann Le Doaré
2006-05-07 11:21 ` Johannes Schindelin
2006-05-08 21:12 ` [Qemu-devel] " Anthony Liguori
3 siblings, 2 replies; 20+ messages in thread
From: NyOS @ 2006-05-07 11:00 UTC (permalink / raw)
To: qemu-devel
On Mon, 08 May 2006 12:04:50 +0200, Yann Le Doaré
<yledoare@linuxconsole.org> wrote:
> Hi,
>
> It seems like qemu 0.8.0 does not accept image file from a vfat
> partition. Is it a bug ?
>
> Greetings.
>
> Yann Le Doaré.
>
>
> strace :
>
> open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> read(7, "", 1024) = 0
> close(7) = 0
> open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> _llseek(7, 128, [128], SEEK_SET) = 0
> read(7, "", 4) = 0
> close(7) = 0
> write(2, "qemu: could not open hard disk i"..., 74qemu: could not open
> hard disk image '/mnt/partitions/windows0/qmeu-disk'
> ) = 74
> exit_group(1) = ?
>
>
>
>
Hi!
What size is it? Linux only supports vfat (FAT32) partitions with at most
4GB files. A disc image can easily reach that.
If the problem is that, the bug is in the kernel, not in qemu. (Just try
to copy it an ext2/3 partition. If is isn't possible, or its size differs,
the bug has nothing to do with qemu.)
Miklos Gyozo
ps. ext2/3 is surely better than vfat for disc images, cause it supports
holes
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] qemu disk on vfat
2006-05-08 10:04 [Qemu-devel] qemu disk on vfat Yann Le Doaré
2006-05-07 8:44 ` André Braga
2006-05-07 11:00 ` [Qemu-devel] " NyOS
@ 2006-05-07 11:21 ` Johannes Schindelin
2006-05-08 21:12 ` [Qemu-devel] " Anthony Liguori
3 siblings, 0 replies; 20+ messages in thread
From: Johannes Schindelin @ 2006-05-07 11:21 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 235 bytes --]
Hi,
On Mon, 8 May 2006, Yann Le Doaré wrote:
> It seems like qemu 0.8.0 does not accept image file from a vfat
> partition. Is it a bug ?
No.
You cannot emulate a whole disk by providing only a partition.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] qemu disk on vfat
2006-05-07 11:00 ` [Qemu-devel] " NyOS
@ 2006-05-07 13:47 ` Jernej Simončič
2006-05-08 19:44 ` Yann Le Doaré
1 sibling, 0 replies; 20+ messages in thread
From: Jernej Simončič @ 2006-05-07 13:47 UTC (permalink / raw)
To: NyOS on [qemu-devel]
On Sunday, May 7, 2006, 13:00:32, NyOS wrote:
> What size is it? Linux only supports vfat (FAT32) partitions with at most
> 4GB files. A disc image can easily reach that.
4GB per file is actually a FAT32 limitation - it can't store larger files
(and there's nothing you can do about it).
--
< Jernej Simončič ><><><><>< http://deepthought.ena.si/ >
Life is what happens to you while you are making other plans.
-- Knight's Law
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] Re: qemu disk on vfat
2006-05-08 10:41 ` Yann Le Doaré
@ 2006-05-07 15:50 ` Alex
0 siblings, 0 replies; 20+ messages in thread
From: Alex @ 2006-05-07 15:50 UTC (permalink / raw)
To: qemu-devel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]
Are you sure coreect spelling is "qmeu-disk", not "qemu-disk"?
--
Alex.
"Yann Le Doaré" <yledoare@linuxconsole.org> wrote in message
news:1147084877.5817.25.camel@localhost...
my option is "-hda /mnt/partitions/windows0/qmeu-disk"
Le dimanche 07 mai 2006 à 05:44 -0300, André Braga a écrit :
> It's more likely a typo in your command line. "qmeu"-disk?
>
> On 5/8/06, Yann Le Doaré <yledoare@linuxconsole.org> wrote:
> > Hi,
> >
> > It seems like qemu 0.8.0 does not accept image file from a vfat
> > partition. Is it a bug ?
> >
> > Greetings.
> >
> > Yann Le Doaré.
> >
> >
> > strace :
> >
> > open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> > read(7, "", 1024) = 0
> > close(7) = 0
> > open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> > _llseek(7, 128, [128], SEEK_SET) = 0
> > read(7, "", 4) = 0
> > close(7) = 0
> > write(2, "qemu: could not open hard disk i"..., 74qemu: could not open
> > hard disk image '/mnt/partitions/windows0/qmeu-disk'
> > ) = 74
> > exit_group(1) = ?
> >
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] qemu disk on vfat
@ 2006-05-08 10:04 Yann Le Doaré
2006-05-07 8:44 ` André Braga
` (3 more replies)
0 siblings, 4 replies; 20+ messages in thread
From: Yann Le Doaré @ 2006-05-08 10:04 UTC (permalink / raw)
To: qemu-devel
Hi,
It seems like qemu 0.8.0 does not accept image file from a vfat
partition. Is it a bug ?
Greetings.
Yann Le Doaré.
strace :
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
read(7, "", 1024) = 0
close(7) = 0
open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
_llseek(7, 128, [128], SEEK_SET) = 0
read(7, "", 4) = 0
close(7) = 0
write(2, "qemu: could not open hard disk i"..., 74qemu: could not open
hard disk image '/mnt/partitions/windows0/qmeu-disk'
) = 74
exit_group(1) = ?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] qemu disk on vfat
2006-05-07 8:44 ` André Braga
@ 2006-05-08 10:41 ` Yann Le Doaré
2006-05-07 15:50 ` [Qemu-devel] " Alex
0 siblings, 1 reply; 20+ messages in thread
From: Yann Le Doaré @ 2006-05-08 10:41 UTC (permalink / raw)
To: qemu-devel
my option is "-hda /mnt/partitions/windows0/qmeu-disk"
Le dimanche 07 mai 2006 à 05:44 -0300, André Braga a écrit :
> It's more likely a typo in your command line. "qmeu"-disk?
>
> On 5/8/06, Yann Le Doaré <yledoare@linuxconsole.org> wrote:
> > Hi,
> >
> > It seems like qemu 0.8.0 does not accept image file from a vfat
> > partition. Is it a bug ?
> >
> > Greetings.
> >
> > Yann Le Doaré.
> >
> >
> > strace :
> >
> > open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> > read(7, "", 1024) = 0
> > close(7) = 0
> > open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> > _llseek(7, 128, [128], SEEK_SET) = 0
> > read(7, "", 4) = 0
> > close(7) = 0
> > write(2, "qemu: could not open hard disk i"..., 74qemu: could not open
> > hard disk image '/mnt/partitions/windows0/qmeu-disk'
> > ) = 74
> > exit_group(1) = ?
> >
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] qemu disk on vfat
2006-05-08 19:44 ` Yann Le Doaré
@ 2006-05-08 14:57 ` Jan Marten Simons
2006-05-09 21:05 ` Yann Le Doaré
0 siblings, 1 reply; 20+ messages in thread
From: Jan Marten Simons @ 2006-05-08 14:57 UTC (permalink / raw)
To: qemu-devel
Am Montag, 8. Mai 2006 21:44 schrieb Yann Le Doaré:
> With :
>
> qemu-img create /mnt/partitions/windows0/qmeu-disk 4M
> qemu -hda /mnt/partitions/windows0/qmeu-disk
>
> qemu: could not open hard disk image'/mnt/partitions/windows0/qmeu-disk'
>
> but with on ext3/ext2 or tmpfs, there is no problem.
>
Did you check, if the permissions of the mounted vfat filesystem are ok? What
happens when you try qemu -hda /mnt/partitions/windows0/qmeu-disk -snapshot?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] qemu disk on vfat
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
1 sibling, 1 reply; 20+ messages in thread
From: Yann Le Doaré @ 2006-05-08 19:44 UTC (permalink / raw)
To: qemu-devel
With :
qemu-img create /mnt/partitions/windows0/qmeu-disk 4M
qemu -hda /mnt/partitions/windows0/qmeu-disk
qemu: could not open hard disk image'/mnt/partitions/windows0/qmeu-disk'
but with on ext3/ext2 or tmpfs, there is no problem.
Le dimanche 07 mai 2006 à 13:00 +0200, NyOS a écrit :
> On Mon, 08 May 2006 12:04:50 +0200, Yann Le Doaré
> <yledoare@linuxconsole.org> wrote:
>
> > Hi,
> >
> > It seems like qemu 0.8.0 does not accept image file from a vfat
> > partition. Is it a bug ?
> >
> > Greetings.
> >
> > Yann Le Doaré.
> >
> >
> > strace :
> >
> > open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> > read(7, "", 1024) = 0
> > close(7) = 0
> > open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> > _llseek(7, 128, [128], SEEK_SET) = 0
> > read(7, "", 4) = 0
> > close(7) = 0
> > write(2, "qemu: could not open hard disk i"..., 74qemu: could not open
> > hard disk image '/mnt/partitions/windows0/qmeu-disk'
> > ) = 74
> > exit_group(1) = ?
> >
> >
> >
> >
>
> Hi!
>
> What size is it? Linux only supports vfat (FAT32) partitions with at most
> 4GB files. A disc image can easily reach that.
> If the problem is that, the bug is in the kernel, not in qemu. (Just try
> to copy it an ext2/3 partition. If is isn't possible, or its size differs,
> the bug has nothing to do with qemu.)
>
> Miklos Gyozo
>
> ps. ext2/3 is surely better than vfat for disc images, cause it supports
> holes
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] Re: qemu disk on vfat
2006-05-08 10:04 [Qemu-devel] qemu disk on vfat Yann Le Doaré
` (2 preceding siblings ...)
2006-05-07 11:21 ` Johannes Schindelin
@ 2006-05-08 21:12 ` Anthony Liguori
2006-05-09 23:41 ` Yann Le Doaré
3 siblings, 1 reply; 20+ messages in thread
From: Anthony Liguori @ 2006-05-08 21:12 UTC (permalink / raw)
To: qemu-devel
On Sun, 07 May 2006 08:13:01 +0000, Yann Le Doaré wrote:
> Hi,
>
> It seems like qemu 0.8.0 does not accept image file from a vfat partition.
> Is it a bug ?
>
> Greetings.
>
> Yann Le Doaré.
>
>
> strace :
>
> open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> read(7, "", 1024) = 0 close(7)
> = 0 open("/mnt/partitions/windows0/qmeu-disk",
> O_RDONLY|O_LARGEFILE) = 7 _llseek(7, 128, [128], SEEK_SET) = 0
> read(7, "", 4) = 0 close(7)
> = 0 write(2, "qemu: could not open hard disk i"..., 74qemu: could
> not open hard disk image '/mnt/partitions/windows0/qmeu-disk' ) = 74
> exit_group(1) = ?
It's pretty clear that what's happening is that qemu opening the file and
the filesystem is claiming it's an empty file.
So, I recommend you do the following:
First:
du -sh /mnt/partitions/windows0/qmeu-disk
ls -al /mnt/partitions/windows0/qmeu-disk
And make sure both report a non-zero result. If either reports 0 as the
size, then you screwed up copying the file to your vfat partition.
Second:
In vl.h, change:
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
To:
#ifdef O_LARGEFILE
#undef O_LARGEFILE
#endif
#define O_LARGEFILE 0
And if that fixes your problem, then vfat is broken when open()'d with
O_LARGEFILE. If that's the case, you should report it as a vfat bug.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
2006-05-09 23:41 ` Yann Le Doaré
@ 2006-05-08 22:05 ` Michael McConnell
2006-05-08 22:48 ` Jim C. Brown
2006-05-08 22:23 ` Ian C. Blenke
1 sibling, 1 reply; 20+ messages in thread
From: Michael McConnell @ 2006-05-08 22:05 UTC (permalink / raw)
To: qemu-devel
On Tue, 9 May 2006, Yann Le Doaré wrote:
> You are right ! :
>
> sh-2.05b# qemu-img create /mnt/partitions/windows0/qmeu-disk 4M
> Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=4096 kB
> sh-2.05b# ls -al /mnt/partitions/windows0/qmeu-disk
> -rwxr-xr-x 1 root root 0 2006-05-09
> 23:37 /mnt/partitions/windows0/qmeu-disk
> sh-2.05b# qemu-img create /mnt/partitions/windows0/qmeu-disk 40M
> Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=40960 kB
> sh-2.05b# ls -al /mnt/partitions/windows0/qmeu-disk
> -rwxr-xr-x 1 root root 0 2006-05-09
> 23:38 /mnt/partitions/windows0
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.
> Le lundi 08 mai 2006 à 16:12 -0500, Anthony Liguori a écrit :
> > On Sun, 07 May 2006 08:13:01 +0000, Yann Le Doaré wrote:
> >
> > > Hi,
> > >
> > > It seems like qemu 0.8.0 does not accept image file from a vfat partition.
> > > Is it a bug ?
> > >
> > > Greetings.
> > >
> > > Yann Le Doaré.
> > >
> > >
> > > strace :
> > >
> > > open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> > > read(7, "", 1024) = 0 close(7)
> > > = 0 open("/mnt/partitions/windows0/qmeu-disk",
> > > O_RDONLY|O_LARGEFILE) = 7 _llseek(7, 128, [128], SEEK_SET) = 0
> > > read(7, "", 4) = 0 close(7)
> > > = 0 write(2, "qemu: could not open hard disk i"..., 74qemu: could
> > > not open hard disk image '/mnt/partitions/windows0/qmeu-disk' ) = 74
> > > exit_group(1) = ?
> >
> > It's pretty clear that what's happening is that qemu opening the file and
> > the filesystem is claiming it's an empty file.
> >
> > So, I recommend you do the following:
> >
> > First:
> >
> > du -sh /mnt/partitions/windows0/qmeu-disk
> > ls -al /mnt/partitions/windows0/qmeu-disk
> >
> > And make sure both report a non-zero result. If either reports 0 as the
> > size, then you screwed up copying the file to your vfat partition.
> >
> > Second:
> >
> > In vl.h, change:
> >
> > #ifndef O_LARGEFILE
> > #define O_LARGEFILE 0
> > #endif
> >
> > To:
> >
> > #ifdef O_LARGEFILE
> > #undef O_LARGEFILE
> > #endif
> > #define O_LARGEFILE 0
> >
> > And if that fixes your problem, then vfat is broken when open()'d with
> > O_LARGEFILE. If that's the case, you should report it as a vfat bug.
> >
> > Regards,
> >
> > Anthony Liguori
> >
> >
> >
> > _______________________________________________
> > Qemu-devel mailing list
> > Qemu-devel@nongnu.org
> > http://lists.nongnu.org/mailman/listinfo/qemu-devel
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>
-- Michael "Soruk" McConnell
Eridani Star System
MailStripper - http://www.MailStripper.eu/ - SMTP spam filter
Mail Me Anywhere - http://www.MailMeAnywhere.com/ - Mobile email
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
2006-05-09 23:41 ` Yann Le Doaré
2006-05-08 22:05 ` Michael McConnell
@ 2006-05-08 22:23 ` Ian C. Blenke
1 sibling, 0 replies; 20+ messages in thread
From: Ian C. Blenke @ 2006-05-08 22:23 UTC (permalink / raw)
To: qemu-devel
Yann Le Doaré wrote:
>You are right ! :
>
>sh-2.05b# qemu-img create /mnt/partitions/windows0/qmeu-disk 4M
>Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=4096 kB
>sh-2.05b# ls -al /mnt/partitions/windows0/qmeu-disk
>-rwxr-xr-x 1 root root 0 2006-05-09
>23:37 /mnt/partitions/windows0/qmeu-disk
>sh-2.05b# qemu-img create /mnt/partitions/windows0/qmeu-disk 40M
>Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=40960 kB
>sh-2.05b# ls -al /mnt/partitions/windows0/qmeu-disk
>-rwxr-xr-x 1 root root 0 2006-05-09
>23:38 /mnt/partitions/windows0
>
>
FAT filesystems don't do sparse files (files with "holes" in them).
The qemu-img "raw" option attempts to create sparse disk images.
Create the image on a filesystem that does support sparse files and then
_copy_ those sparse files to a FAT filesystem and they'll work just fine.
- Ian C. Blenke <ian@blenke.com> http://ian.blenke.com/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
2006-05-08 22:05 ` Michael McConnell
@ 2006-05-08 22:48 ` Jim C. Brown
2006-05-08 23:10 ` Jim C. Brown
0 siblings, 1 reply; 20+ messages in thread
From: Jim C. Brown @ 2006-05-08 22:48 UTC (permalink / raw)
To: qemu-devel
[-- 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;
}
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
2006-05-08 22:48 ` Jim C. Brown
@ 2006-05-08 23:10 ` Jim C. Brown
2006-05-08 23:50 ` Jim C. Brown
0 siblings, 1 reply; 20+ messages in thread
From: Jim C. Brown @ 2006-05-08 23:10 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]
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.
[-- Attachment #2: block.patch --]
[-- Type: text/plain, Size: 868 bytes --]
--- 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;
}
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
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-16 17:21 ` Jim C. Brown
0 siblings, 2 replies; 20+ messages in thread
From: Jim C. Brown @ 2006-05-08 23:50 UTC (permalink / raw)
To: qemu-devel
Aactually, the bug is in vfat not in qemu-img.
qemu-img correctly uses ftruncate() which is suppose to make the file sparse
if the underlying filesystem supports it, but it should fall back to adding zeros
to the end of the file. On vfat you aren't able to seek past the end of a file
period, so this doesn't work.
Probably qemu-img should just bail out in this case (as the other disk formats
should work fine and you can always use dd). The 2nd patch I released does
this - the error message just needs to be made more accurate.
--
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
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
1 sibling, 1 reply; 20+ messages in thread
From: Anthony Liguori @ 2006-05-09 1:36 UTC (permalink / raw)
To: qemu-devel
Jim C. Brown wrote:
> Aactually, the bug is in vfat not in qemu-img.
>
Not really. POSIX doesn't mandate that ftruncate() increase a file
size. This is a Linux-ism and is only valid for filesystems that
support holes (which vfat doesn't).
Regards,
Anthony Liguori
> qemu-img correctly uses ftruncate() which is suppose to make the file sparse
> if the underlying filesystem supports it, but it should fall back to adding zeros
> to the end of the file. On vfat you aren't able to seek past the end of a file
> period, so this doesn't work.
>
> Probably qemu-img should just bail out in this case (as the other disk formats
> should work fine and you can always use dd). The 2nd patch I released does
> this - the error message just needs to be made more accurate.
>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
2006-05-09 1:36 ` Anthony Liguori
@ 2006-05-09 2:11 ` Paul Brook
0 siblings, 0 replies; 20+ messages in thread
From: Paul Brook @ 2006-05-09 2:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori
On Tuesday 09 May 2006 02:36, Anthony Liguori wrote:
> Jim C. Brown wrote:
> > Aactually, the bug is in vfat not in qemu-img.
>
> Not really. POSIX doesn't mandate that ftruncate() increase a file
> size. This is a Linux-ism and is only valid for filesystems that
> support holes (which vfat doesn't).
Actually it isn't a Linux-ism, it's very common unix behavior. Both HPUX and
Solaris extend the file, and are documented to do so.
The linux manpages also document that the file is padded with zeros. It's only
if you dig into the glibc documentation that you discover this is a lie.
Paul
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] qemu disk on vfat
2006-05-08 14:57 ` Jan Marten Simons
@ 2006-05-09 21:05 ` Yann Le Doaré
0 siblings, 0 replies; 20+ messages in thread
From: Yann Le Doaré @ 2006-05-09 21:05 UTC (permalink / raw)
To: qemu-devel
with -snapshot I have the same error.
vfat options are :
rw,nodiratime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1
It can use my ext3 partitions, so it is not a problem for me.
Thanks for you responses.
Le lundi 08 mai 2006 à 16:57 +0200, Jan Marten Simons a écrit :
> Am Montag, 8. Mai 2006 21:44 schrieb Yann Le Doaré:
> > With :
> >
> > qemu-img create /mnt/partitions/windows0/qmeu-disk 4M
> > qemu -hda /mnt/partitions/windows0/qmeu-disk
> >
> > qemu: could not open hard disk image'/mnt/partitions/windows0/qmeu-disk'
> >
> > but with on ext3/ext2 or tmpfs, there is no problem.
> >
>
> Did you check, if the permissions of the mounted vfat filesystem are ok? What
> happens when you try qemu -hda /mnt/partitions/windows0/qmeu-disk -snapshot?
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
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:23 ` Ian C. Blenke
0 siblings, 2 replies; 20+ messages in thread
From: Yann Le Doaré @ 2006-05-09 23:41 UTC (permalink / raw)
To: qemu-devel
You are right ! :
sh-2.05b# qemu-img create /mnt/partitions/windows0/qmeu-disk 4M
Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=4096 kB
sh-2.05b# ls -al /mnt/partitions/windows0/qmeu-disk
-rwxr-xr-x 1 root root 0 2006-05-09
23:37 /mnt/partitions/windows0/qmeu-disk
sh-2.05b# qemu-img create /mnt/partitions/windows0/qmeu-disk 40M
Formating '/mnt/partitions/windows0/qmeu-disk', fmt=raw, size=40960 kB
sh-2.05b# ls -al /mnt/partitions/windows0/qmeu-disk
-rwxr-xr-x 1 root root 0 2006-05-09
23:38 /mnt/partitions/windows0
Le lundi 08 mai 2006 à 16:12 -0500, Anthony Liguori a écrit :
> On Sun, 07 May 2006 08:13:01 +0000, Yann Le Doaré wrote:
>
> > Hi,
> >
> > It seems like qemu 0.8.0 does not accept image file from a vfat partition.
> > Is it a bug ?
> >
> > Greetings.
> >
> > Yann Le Doaré.
> >
> >
> > strace :
> >
> > open("/mnt/partitions/windows0/qmeu-disk", O_RDONLY|O_LARGEFILE) = 7
> > read(7, "", 1024) = 0 close(7)
> > = 0 open("/mnt/partitions/windows0/qmeu-disk",
> > O_RDONLY|O_LARGEFILE) = 7 _llseek(7, 128, [128], SEEK_SET) = 0
> > read(7, "", 4) = 0 close(7)
> > = 0 write(2, "qemu: could not open hard disk i"..., 74qemu: could
> > not open hard disk image '/mnt/partitions/windows0/qmeu-disk' ) = 74
> > exit_group(1) = ?
>
> It's pretty clear that what's happening is that qemu opening the file and
> the filesystem is claiming it's an empty file.
>
> So, I recommend you do the following:
>
> First:
>
> du -sh /mnt/partitions/windows0/qmeu-disk
> ls -al /mnt/partitions/windows0/qmeu-disk
>
> And make sure both report a non-zero result. If either reports 0 as the
> size, then you screwed up copying the file to your vfat partition.
>
> Second:
>
> In vl.h, change:
>
> #ifndef O_LARGEFILE
> #define O_LARGEFILE 0
> #endif
>
> To:
>
> #ifdef O_LARGEFILE
> #undef O_LARGEFILE
> #endif
> #define O_LARGEFILE 0
>
> And if that fixes your problem, then vfat is broken when open()'d with
> O_LARGEFILE. If that's the case, you should report it as a vfat bug.
>
> Regards,
>
> Anthony Liguori
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] Re: qemu disk on vfat
2006-05-08 23:50 ` Jim C. Brown
2006-05-09 1:36 ` Anthony Liguori
@ 2006-05-16 17:21 ` Jim C. Brown
1 sibling, 0 replies; 20+ messages in thread
From: Jim C. Brown @ 2006-05-16 17:21 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]
On Mon, May 08, 2006 at 08:36:15PM -0500, Anthony Liguori wrote:
> Jim C. Brown wrote:
> >Aactually, the bug is in vfat not in qemu-img.
> >
>
> Not really. POSIX doesn't mandate that ftruncate() increase a file
> size. This is a Linux-ism and is only valid for filesystems that
> support holes (which vfat doesn't).
>
> Regards,
>
> Anthony Liguori
>
Ok, so in that case this is something qemu-img should handle on its own then.
(Since we're not likely to see a "fix" in either glibc or the kernel for this,
and it has the potential to be a portability issue.)
On Mon, May 08, 2006 at 07:50:24PM -0400, Jim C. Brown wrote:
> qemu-img correctly uses ftruncate() which is suppose to make the file sparse
> if the underlying filesystem supports it, but it should fall back to adding zeros
> to the end of the file. On vfat you aren't able to seek past the end of a file
> period, so this doesn't work.
Turns out I was wrong about this too.
http://www.mail-archive.com/bug-tar@gnu.org/msg00556.html
Here is a patch that silently handles the Linux/vfat case using lseek().
--
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.
[-- Attachment #2: block.patch --]
[-- Type: text/plain, Size: 809 bytes --]
--- block.c Tue May 16 13:06:15 2006
+++ block.c Tue May 16 13:07:51 2006
@@ -753,6 +753,20 @@
close(s->fd);
}
+int qemu_ftruncate(int fd, off_t length)
+/* ftruncate() isn't guarranteed to grow a file, according to POSIX. **
+** This is. */
+{
+ int res = ftruncate(fd, length);
+ if (res && (errno == EPERM))
+ {
+ if ((lseek( fd, length - 1, SEEK_SET) == (off_t)-1) ||
+ (write(fd, "\0", 1) == -1))
+ return -1;
+ }
+ return res;
+}
+
static int raw_create(const char *filename, int64_t total_size,
const char *backing_file, int flags)
{
@@ -765,7 +779,7 @@
0644);
if (fd < 0)
return -EIO;
- ftruncate(fd, total_size * 512);
+ qemu_ftruncate(fd, total_size * 512);
close(fd);
return 0;
}
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2006-05-16 17:21 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).