chenjunb@Lenovo.com
2006-Apr-27 08:54 UTC
[Xen-devel] [patch] fix the cdrom is not bootable, but boot device is cdrom.
When boot device is cdrom but the cdrom is not bootable, the guest appears to hang. This patch fixes this. Signed-off by: Chen Jun <chenjunb@lenovo.com> -------------- next part -------------- diff -r 4d83bf50673d -r b2ce4ef06bb8 tools/ioemu/vl.c --- a/tools/ioemu/vl.c Wed Apr 26 17:44:46 2006 +0100 +++ b/tools/ioemu/vl.c Thu Apr 27 14:40:36 2006 +0800 @@ -3243,17 +3243,34 @@ int main(int argc, char **argv) /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); if (has_cdrom) { - int fd; + int fd, ret; + char bootsig[32]; + char bootcdrom[32] = { 0x00,0x43,0x44,0x30,0x30,0x31,0x01,0x45, \ + 0x4c,0x20,0x54,0x4f,0x52,0x49,0x54,0x4f,\ + 0x20,0x53,0x50,0x45,0x43,0x49,0x46,0x49,\ + 0x43,0x41,0x54,0x49,0x4f,0x4e,0x00,0x00 \ + }; if ( (fd = open(hd_filename[2], O_RDONLY | O_BINARY)) < 0) { - hd_filename[2]=NULL; - bs_table[2]=NULL; - fprintf(logfile, "Could not open CD %s.\n", hd_filename[i]); + hd_filename[2] = NULL; + bs_table[2] = NULL; + if (boot_device == ''d'') + boot_device = ''c''; + fprintf(logfile, "Could not open CD %s.\n", hd_filename[i]); } else { - close(fd); - bs_table[2] = bdrv_new("cdrom"); - bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); - } + if (boot_device == ''d'') { + lseek(fd, 0x8800, SEEK_SET); + ret = read(fd, bootsig, 32); + if (ret > 0) + if( memcmp(bootsig, bootcdrom, 32) != 0 ) + boot_device = ''c''; + else + boot_device = ''c''; + } + close(fd); + bs_table[2] = bdrv_new("cdrom"); + bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); + } } /* open the virtual block devices */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-Apr-27 09:14 UTC
Re: [Xen-devel] [patch] fix the cdrom is not bootable, but boot device is cdrom.
On 27 Apr 2006, at 09:54, chenjunb@Lenovo.com wrote:> When boot device is cdrom but the cdrom is not bootable, the guest > appears > to hang. This patch fixes this. > > Signed-off by: Chen Jun <chenjunb@lenovo.com>Doesn''t the BIOS check for bootable media and fall back to a lower-priority boot device if it''s not present? Maybe it''s trying to do that but ioemu is not filling in second and third boot device entries? -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
chenjunb@Lenovo.com
2006-Apr-28 02:20 UTC
Re: [Xen-devel] [patch] fix the cdrom is not bootable, but boot device is cdrom.
>> When boot device is cdrom but the cdrom is not bootable, the guest >> appears >> to hang. This patch fixes this. >> >> Signed-off by: Chen Jun <chenjunb@lenovo.com>>Doesn''t the BIOS check for bootable media and fall back to a >lower-priority boot device if it''s not present? Maybe it''s trying to do >that but ioemu is not filling in second and third boot device entries?> -- KeirYes, you are right, the second and third boot device entries are not filled by ioemu, so there is a easy way to solve this problem. The below patch is following your advice, but it''s better to specify the boot sequence in the python configue file. Signed-off by: Chen Jun <chenjunb@lenovo.com> -------------- next part -------------- diff -r 4d83bf50673d tools/ioemu/hw/pc.c --- a/tools/ioemu/hw/pc.c Wed Apr 26 17:44:46 2006 +0100 +++ b/tools/ioemu/hw/pc.c Fri Apr 28 10:10:09 2006 +0800 @@ -167,14 +167,20 @@ static void cmos_init(uint64_t ram_size, switch(boot_device) { case ''a'': case ''b'': - rtc_set_memory(s, 0x3d, 0x01); /* floppy boot */ + //rtc_set_memory(s, 0x3d, 0x01); /* floppy boot */ + rtc_set_memory(s, 0x3d, 0x21); /* a->c->d */ + rtc_set_memory(s, 0x38, 0x30); break; default: case ''c'': - rtc_set_memory(s, 0x3d, 0x02); /* hard drive boot */ + //rtc_set_memory(s, 0x3d, 0x02); /* hard drive boot */ + rtc_set_memory(s, 0x3d, 0x32); /* c->d->a */ + rtc_set_memory(s, 0x38, 0x10); break; case ''d'': - rtc_set_memory(s, 0x3d, 0x03); /* CD-ROM boot */ + //rtc_set_memory(s, 0x3d, 0x03); /* CD-ROM boot */ + rtc_set_memory(s, 0x3d, 0x23); /* d->c->a */ + rtc_set_memory(s, 0x38, 0x10); break; } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel