WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [patch] fix the cdrom is not bootable, but boot device is cd

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [patch] fix the cdrom is not bootable, but boot device is cdrom.
From: chenjunb@xxxxxxxxxx
Date: Thu, 27 Apr 2006 16:54:08 +0800
Delivery-date: Thu, 27 Apr 2006 01:55:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <E1FTV7y-0008O3-Dd@host-192-168-0-1-bcn-london>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>