Commit 5efa9d5a authored by Anthony Liguori's avatar Anthony Liguori
Browse files

Convert block infrastructure to use new module init functionality

parent 0bfe3ca5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
 */
#include "qemu-common.h"
#include "block_int.h"
#include "module.h"

/**************************************************************/

@@ -241,7 +242,7 @@ static void bochs_close(BlockDriverState *bs)
    close(s->fd);
}

BlockDriver bdrv_bochs = {
static BlockDriver bdrv_bochs = {
    .format_name	= "bochs",
    .instance_size	= sizeof(BDRVBochsState),
    .bdrv_probe		= bochs_probe,
@@ -249,3 +250,10 @@ BlockDriver bdrv_bochs = {
    .bdrv_read		= bochs_read,
    .bdrv_close		= bochs_close,
};

static void bdrv_bochs_init(void)
{
    bdrv_register(&bdrv_bochs);
}

block_init(bdrv_bochs_init);
+9 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
 */
#include "qemu-common.h"
#include "block_int.h"
#include "module.h"
#include <zlib.h>

typedef struct BDRVCloopState {
@@ -153,7 +154,7 @@ static void cloop_close(BlockDriverState *bs)
    inflateEnd(&s->zstream);
}

BlockDriver bdrv_cloop = {
static BlockDriver bdrv_cloop = {
    .format_name	= "cloop",
    .instance_size	= sizeof(BDRVCloopState),
    .bdrv_probe		= cloop_probe,
@@ -161,3 +162,10 @@ BlockDriver bdrv_cloop = {
    .bdrv_read		= cloop_read,
    .bdrv_close		= cloop_close,
};

static void bdrv_cloop_init(void)
{
    bdrv_register(&bdrv_cloop);
}

block_init(bdrv_cloop_init);
+9 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#ifndef _WIN32
#include "qemu-common.h"
#include "block_int.h"
#include "module.h"
#include <sys/mman.h>

/**************************************************************/
@@ -252,7 +253,7 @@ static void cow_flush(BlockDriverState *bs)
    fsync(s->fd);
}

BlockDriver bdrv_cow = {
static BlockDriver bdrv_cow = {
    .format_name	= "cow",
    .instance_size	= sizeof(BDRVCowState),
    .bdrv_probe		= cow_probe,
@@ -264,4 +265,11 @@ BlockDriver bdrv_cow = {
    .bdrv_flush		= cow_flush,
    .bdrv_is_allocated	= cow_is_allocated,
};

static void bdrv_cow_init(void)
{
    bdrv_register(&bdrv_cow);
}

block_init(bdrv_cow_init);
#endif
+10 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include "qemu-common.h"
#include "block_int.h"
#include "bswap.h"
#include "module.h"
#include <zlib.h>

typedef struct BDRVDMGState {
@@ -92,7 +93,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
dmg_close:
	close(s->fd);
	/* open raw instead */
	bs->drv=&bdrv_raw;
	bs->drv=bdrv_find_format("raw");
	return bs->drv->bdrv_open(bs, filename, flags);
    }
    info_begin=read_off(s->fd);
@@ -283,7 +284,7 @@ static void dmg_close(BlockDriverState *bs)
    inflateEnd(&s->zstream);
}

BlockDriver bdrv_dmg = {
static BlockDriver bdrv_dmg = {
    .format_name	= "dmg",
    .instance_size	= sizeof(BDRVDMGState),
    .bdrv_probe		= dmg_probe,
@@ -291,3 +292,10 @@ BlockDriver bdrv_dmg = {
    .bdrv_read		= dmg_read,
    .bdrv_close		= dmg_close,
};

static void bdrv_dmg_init(void)
{
    bdrv_register(&bdrv_dmg);
}

block_init(bdrv_dmg_init);
+9 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@

#include "qemu-common.h"
#include "nbd.h"
#include "module.h"

#include <sys/types.h>
#include <unistd.h>
@@ -176,7 +177,7 @@ static int64_t nbd_getlength(BlockDriverState *bs)
    return s->size;
}

BlockDriver bdrv_nbd = {
static BlockDriver bdrv_nbd = {
    .format_name	= "nbd",
    .instance_size	= sizeof(BDRVNBDState),
    .bdrv_open		= nbd_open,
@@ -186,3 +187,10 @@ BlockDriver bdrv_nbd = {
    .bdrv_getlength	= nbd_getlength,
    .protocol_name	= "nbd",
};

static void bdrv_nbd_init(void)
{
    bdrv_register(&bdrv_nbd);
}

block_init(bdrv_nbd_init);
Loading