diff options
Diffstat (limited to 'hw/xen_disk.c')
-rw-r--r-- | hw/xen_disk.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 7ed6c33..100ef8e 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -107,7 +107,7 @@ struct XenBlkDev { int requests_finished; /* qemu block driver */ - int index; + DriveInfo *dinfo; BlockDriverState *bs; QEMUBH *bh; }; @@ -575,7 +575,7 @@ static void blk_alloc(struct XenDevice *xendev) static int blk_init(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); - int mode, qflags, have_barriers, info = 0; + int index, mode, qflags, have_barriers, info = 0; char *h; /* read xenstore entries */ @@ -622,9 +622,9 @@ static int blk_init(struct XenDevice *xendev) info |= VDISK_CDROM; /* init qemu block driver */ - blkdev->index = (blkdev->xendev.dev - 202 * 256) / 16; - blkdev->index = drive_get_index(IF_XEN, 0, blkdev->index); - if (blkdev->index == -1) { + index = (blkdev->xendev.dev - 202 * 256) / 16; + blkdev->dinfo = drive_get(IF_XEN, 0, index); + if (!blkdev->dinfo) { /* setup via xenbus -> create new block driver instance */ xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n"); blkdev->bs = bdrv_new(blkdev->dev); @@ -640,7 +640,7 @@ static int blk_init(struct XenDevice *xendev) } else { /* setup via qemu cmdline -> already setup for us */ xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n"); - blkdev->bs = drives_table[blkdev->index].bdrv; + blkdev->bs = blkdev->dinfo->bdrv; } blkdev->file_blk = BLOCK_SIZE; blkdev->file_size = bdrv_getlength(blkdev->bs); @@ -729,7 +729,7 @@ static void blk_disconnect(struct XenDevice *xendev) struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); if (blkdev->bs) { - if (blkdev->index == -1) { + if (!blkdev->dinfo) { /* close/delete only if we created it ourself */ bdrv_close(blkdev->bs); bdrv_delete(blkdev->bs); |