aboutsummaryrefslogtreecommitdiff
path: root/block/vpc.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2009-05-18 16:42:10 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-22 10:50:31 -0500
commit0e7e1989f7fced8e39f140e1958f0557b60d4532 (patch)
tree76bbcc1c26a05f4f6e430f9f844f9b3b350c13ba /block/vpc.c
parentd3f243676addaef6c8d818934565292c698f91cc (diff)
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>
Diffstat (limited to 'block/vpc.c')
-rw-r--r--block/vpc.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/block/vpc.c b/block/vpc.c
index 211ae5c72f..662a6f6cf8 100644
--- a/block/vpc.c
+++ b/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)