* [Qemu-devel] [patch]Fix block device read for some SLOW file
@ 2005-07-27 11:10 lepton
2005-07-27 12:55 ` Johannes Schindelin
2005-07-27 13:18 ` [Qemu-devel] " Jani Monoses
0 siblings, 2 replies; 3+ messages in thread
From: lepton @ 2005-07-27 11:10 UTC (permalink / raw)
To: qemu-devel
Hi, I found when I am using qemu, I can't boot from emulated cdrom.
After some debug, I found the reason is that my iso file is in a samba
file system. When qemu read data from my samba file system. read will be
interrupted by signal alarm. So qemu won't boot from it.
The follwing patch will fix it.
--- qemu-0.7.1/block.c 2005-07-25 02:52:08.000000000 +0800
+++ qemu-0.7.1-lepton/block.c 2005-07-27 18:57:21.000000000 +0800
@@ -591,10 +591,16 @@ static int raw_read(BlockDriverState *bs
int ret;
lseek(s->fd, sector_num * 512, SEEK_SET);
- ret = read(s->fd, buf, nb_sectors * 512);
- if (ret != nb_sectors * 512)
- return -1;
- return 0;
+ while(1){
+ ret = read(s->fd, buf, nb_sectors * 512);
+ if (ret != nb_sectors * 512) {
+ if(ret==-1 && errno==EINTR)
+ continue;
+ else
+ return -1;
+ }
+ return 0;
+ }
}
static int raw_write(BlockDriverState *bs, int64_t sector_num,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [patch]Fix block device read for some SLOW file
2005-07-27 11:10 [Qemu-devel] [patch]Fix block device read for some SLOW file lepton
@ 2005-07-27 12:55 ` Johannes Schindelin
2005-07-27 13:18 ` [Qemu-devel] " Jani Monoses
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2005-07-27 12:55 UTC (permalink / raw)
To: qemu-devel
Hi,
On Wed, 27 Jul 2005, lepton wrote:
> + while(1){
> + ret = read(s->fd, buf, nb_sectors * 512);
> + if (ret != nb_sectors * 512) {
> + if(ret==-1 && errno==EINTR)
> + continue;
> + else
> + return -1;
> + }
> + return 0;
> + }
Why not
do {
ret = read(s->fd, buf, nb_sectors * 512);
} while(ret==-1 && errno=EINTR);
if (ret != nb_sectors * 512)
return -1;
return 0;
Ciao,
Dscho
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [patch]Fix block device read for some SLOW file
2005-07-27 11:10 [Qemu-devel] [patch]Fix block device read for some SLOW file lepton
2005-07-27 12:55 ` Johannes Schindelin
@ 2005-07-27 13:18 ` Jani Monoses
1 sibling, 0 replies; 3+ messages in thread
From: Jani Monoses @ 2005-07-27 13:18 UTC (permalink / raw)
To: qemu-devel
lepton wrote:
> Hi, I found when I am using qemu, I can't boot from emulated cdrom.
> After some debug, I found the reason is that my iso file is in a samba
> file system. When qemu read data from my samba file system. read will be
> interrupted by signal alarm. So qemu won't boot from it.
>
> The follwing patch will fix it.
>
> --- qemu-0.7.1/block.c 2005-07-25 02:52:08.000000000 +0800
> +++ qemu-0.7.1-lepton/block.c 2005-07-27 18:57:21.000000000 +0800
> @@ -591,10 +591,16 @@ static int raw_read(BlockDriverState *bs
> int ret;
>
> lseek(s->fd, sector_num * 512, SEEK_SET);
> - ret = read(s->fd, buf, nb_sectors * 512);
> - if (ret != nb_sectors * 512)
> - return -1;
> - return 0;
There's another error related to this code: qemu won't boot floppy images whose size isn't
a multiple of 512, it will drop the last incomplete sector, as the last read will not give
512 bytes.
a good testcase is the asmutils linux floppy image.
Jani
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-07-27 13:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-27 11:10 [Qemu-devel] [patch]Fix block device read for some SLOW file lepton
2005-07-27 12:55 ` Johannes Schindelin
2005-07-27 13:18 ` [Qemu-devel] " Jani Monoses
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).