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@xxxxxxxxxx>
-------------- 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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|