diff options
Diffstat (limited to 'block/cow.c')
-rw-r--r-- | block/cow.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/block/cow.c b/block/cow.c index 94b3549..41d292a 100644 --- a/block/cow.c +++ b/block/cow.c @@ -202,15 +202,23 @@ static void cow_close(BlockDriverState *bs) close(s->fd); } -static int cow_create(const char *filename, int64_t image_sectors, - const char *image_filename, int flags) +static int cow_create(const char *filename, QEMUOptionParameter *options) { int fd, cow_fd; struct cow_header_v2 cow_header; struct stat st; - - if (flags) - return -ENOTSUP; + int64_t image_sectors = 0; + const char *image_filename = NULL; + + /* Read out options */ + while (options && options->name) { + if (!strcmp(options->name, BLOCK_OPT_SIZE)) { + image_sectors = options->value.n / 512; + } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) { + image_filename = options->value.s; + } + options++; + } cow_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); @@ -253,6 +261,12 @@ static void cow_flush(BlockDriverState *bs) fsync(s->fd); } +static QEMUOptionParameter cow_create_options[] = { + { BLOCK_OPT_SIZE, OPT_SIZE }, + { BLOCK_OPT_BACKING_FILE, OPT_STRING }, + { NULL } +}; + static BlockDriver bdrv_cow = { .format_name = "cow", .instance_size = sizeof(BDRVCowState), @@ -264,6 +278,8 @@ static BlockDriver bdrv_cow = { .bdrv_create = cow_create, .bdrv_flush = cow_flush, .bdrv_is_allocated = cow_is_allocated, + + .create_options = cow_create_options, }; static void bdrv_cow_init(void) |