mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
Convert all block drivers to new bdrv_create
Now we can make use of the newly introduced option structures. Instead of having bdrv_create carry more and more parameters (which are format specific in most cases), just pass a option structure as defined by the driver itself. bdrv_create2() contains an emulation of the old interface to simplify the transition. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
d3f243676a
commit
0e7e1989f7
12 changed files with 212 additions and 53 deletions
21
block/vpc.c
21
block/vpc.c
|
@ -477,8 +477,7 @@ static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int vpc_create(const char *filename, int64_t total_sectors,
|
||||
const char *backing_file, int flags)
|
||||
static int vpc_create(const char *filename, QEMUOptionParameter *options)
|
||||
{
|
||||
uint8_t buf[1024];
|
||||
struct vhd_footer* footer = (struct vhd_footer*) buf;
|
||||
|
@ -489,10 +488,17 @@ static int vpc_create(const char *filename, int64_t total_sectors,
|
|||
uint8_t heads;
|
||||
uint8_t secs_per_cyl;
|
||||
size_t block_size, num_bat_entries;
|
||||
int64_t total_sectors = 0;
|
||||
|
||||
if (backing_file != NULL)
|
||||
return -ENOTSUP;
|
||||
// Read out options
|
||||
while (options && options->name) {
|
||||
if (!strcmp(options->name, "size")) {
|
||||
total_sectors = options->value.n / 512;
|
||||
}
|
||||
options++;
|
||||
}
|
||||
|
||||
// Create the file
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
|
||||
if (fd < 0)
|
||||
return -EIO;
|
||||
|
@ -587,6 +593,11 @@ static void vpc_close(BlockDriverState *bs)
|
|||
bdrv_delete(s->hd);
|
||||
}
|
||||
|
||||
static QEMUOptionParameter vpc_create_options[] = {
|
||||
{ "size", OPT_SIZE },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static BlockDriver bdrv_vpc = {
|
||||
.format_name = "vpc",
|
||||
.instance_size = sizeof(BDRVVPCState),
|
||||
|
@ -596,6 +607,8 @@ static BlockDriver bdrv_vpc = {
|
|||
.bdrv_write = vpc_write,
|
||||
.bdrv_close = vpc_close,
|
||||
.bdrv_create = vpc_create,
|
||||
|
||||
.create_options = vpc_create_options,
|
||||
};
|
||||
|
||||
static void bdrv_vpc_init(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue