ia64/xen-unstable

changeset 10066:df1521633fb5

Prevent an oops in Dom0 that occurs when a CD device, specified as one
of the 'hardrives' in the 'disk=' line of a para-virtualized guest's
def file, has no media when the guest is started.

The oops occurs in vbd.c when vbd_size() is called from connect() (in
xenbus.c) and the vbd pointer is really an error code that comes from
the failed open that occurred in vbd_create().

Based on a patch from Ross Maxfield at Novell.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue May 16 09:40:38 2006 +0100 (2006-05-16)
parents c5551469f00e
children bc7d49df1651
files linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c	Tue May 16 09:21:33 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c	Tue May 16 09:40:38 2006 +0100
     1.3 @@ -55,6 +55,7 @@ int vbd_create(blkif_t *blkif, blkif_vde
     1.4  	       unsigned minor, int readonly)
     1.5  {
     1.6  	struct vbd *vbd;
     1.7 +	struct block_device *bdev;
     1.8  
     1.9  	vbd = &blkif->vbd;
    1.10  	vbd->handle   = handle; 
    1.11 @@ -63,15 +64,17 @@ int vbd_create(blkif_t *blkif, blkif_vde
    1.12  
    1.13  	vbd->pdevice  = MKDEV(major, minor);
    1.14  
    1.15 -	vbd->bdev = open_by_devnum(
    1.16 -		vbd->pdevice,
    1.17 -		vbd->readonly ? FMODE_READ : FMODE_WRITE);
    1.18 -	if (IS_ERR(vbd->bdev)) {
    1.19 -		DPRINTK("vbd_creat: device %08x doesn't exist.\n",
    1.20 +	bdev = open_by_devnum(vbd->pdevice,
    1.21 +			      vbd->readonly ? FMODE_READ : FMODE_WRITE);
    1.22 +
    1.23 +	if (IS_ERR(bdev)) {
    1.24 +		DPRINTK("vbd_creat: device %08x could not be opened.\n",
    1.25  			vbd->pdevice);
    1.26  		return -ENOENT;
    1.27  	}
    1.28  
    1.29 +	vbd->bdev = bdev;
    1.30 +
    1.31  	if (vbd->bdev->bd_disk == NULL) {
    1.32  		DPRINTK("vbd_creat: device %08x doesn't exist.\n",
    1.33  			vbd->pdevice);