aboutsummaryrefslogtreecommitdiff
path: root/block/blkdebug.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2010-04-14 14:17:38 +0200
committerKevin Wolf <kwolf@redhat.com>2010-05-03 10:07:30 +0200
commit66f82ceed6781261c09e65fb440ca76842fd0500 (patch)
tree138160d48093543a87d4db02b94267d564e2d258 /block/blkdebug.c
parent579153325158d944be544ced96c6218e7d48802a (diff)
block: Open the underlying image file in generic code
Format drivers shouldn't need to bother with things like file names, but rather just get an open BlockDriverState for the underlying protocol. This patch introduces this behaviour for bdrv_open implementation. For protocols which need to access the filename to open their file/device/connection/... a new callback bdrv_file_open is introduced which doesn't get an underlying file opened. For now, also some of the more obscure formats use bdrv_file_open because they open() the file themselves instead of using the block.c functions. They need to be fixed in later patches. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/blkdebug.c')
-rw-r--r--block/blkdebug.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 643c3978f8..bb4a91abc7 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -44,7 +44,6 @@ typedef struct BlkdebugVars {
} BlkdebugVars;
typedef struct BDRVBlkdebugState {
- BlockDriverState *hd;
BlkdebugVars vars;
QLIST_HEAD(list, BlkdebugRule) rules[BLKDBG_EVENT_MAX];
} BDRVBlkdebugState;
@@ -303,7 +302,7 @@ static int blkdebug_open(BlockDriverState *bs, const char *filename, int flags)
filename = c + 1;
/* Open the backing file */
- ret = bdrv_file_open(&s->hd, filename, flags);
+ ret = bdrv_file_open(&bs->file, filename, flags);
if (ret < 0) {
return ret;
}
@@ -362,7 +361,7 @@ static BlockDriverAIOCB *blkdebug_aio_readv(BlockDriverState *bs,
}
BlockDriverAIOCB *acb =
- bdrv_aio_readv(s->hd, sector_num, qiov, nb_sectors, cb, opaque);
+ bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
return acb;
}
@@ -377,7 +376,7 @@ static BlockDriverAIOCB *blkdebug_aio_writev(BlockDriverState *bs,
}
BlockDriverAIOCB *acb =
- bdrv_aio_writev(s->hd, sector_num, qiov, nb_sectors, cb, opaque);
+ bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
return acb;
}
@@ -393,21 +392,17 @@ static void blkdebug_close(BlockDriverState *bs)
qemu_free(rule);
}
}
-
- bdrv_delete(s->hd);
}
static void blkdebug_flush(BlockDriverState *bs)
{
- BDRVBlkdebugState *s = bs->opaque;
- bdrv_flush(s->hd);
+ bdrv_flush(bs->file);
}
static BlockDriverAIOCB *blkdebug_aio_flush(BlockDriverState *bs,
BlockDriverCompletionFunc *cb, void *opaque)
{
- BDRVBlkdebugState *s = bs->opaque;
- return bdrv_aio_flush(s->hd, cb, opaque);
+ return bdrv_aio_flush(bs->file, cb, opaque);
}
static void process_rule(BlockDriverState *bs, struct BlkdebugRule *rule,
@@ -456,7 +451,7 @@ static BlockDriver bdrv_blkdebug = {
.instance_size = sizeof(BDRVBlkdebugState),
- .bdrv_open = blkdebug_open,
+ .bdrv_file_open = blkdebug_open,
.bdrv_close = blkdebug_close,
.bdrv_flush = blkdebug_flush,