[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v25 29/31] vpc.c: replace QEMUOptionParameter with Q
From: |
Chunyan Liu |
Subject: |
[Qemu-devel] [PATCH v25 29/31] vpc.c: replace QEMUOptionParameter with QemuOpts |
Date: |
Fri, 11 Apr 2014 01:54:25 +0800 |
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Dong Xu Wang <address@hidden>
Signed-off-by: Chunyan Liu <address@hidden>
---
block/vpc.c | 62 +++++++++++++++++++++++++++++++++----------------------------
1 file changed, 34 insertions(+), 28 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index 2e25f57..8ebf424 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -738,12 +738,11 @@ static int create_fixed_disk(int fd, uint8_t *buf,
int64_t total_size)
return ret;
}
-static int vpc_create(const char *filename, QEMUOptionParameter *options,
- Error **errp)
+static int vpc_create(const char *filename, QemuOpts *opts, Error **errp)
{
uint8_t buf[1024];
VHDFooter *footer = (VHDFooter *) buf;
- QEMUOptionParameter *disk_type_param;
+ char *disk_type_param;
int fd, i;
uint16_t cyls = 0;
uint8_t heads = 0;
@@ -754,16 +753,16 @@ static int vpc_create(const char *filename,
QEMUOptionParameter *options,
int ret = -EIO;
/* Read out options */
- total_size = get_option_parameter(options, BLOCK_OPT_SIZE)->value.n;
-
- disk_type_param = get_option_parameter(options, BLOCK_OPT_SUBFMT);
- if (disk_type_param && disk_type_param->value.s) {
- if (!strcmp(disk_type_param->value.s, "dynamic")) {
+ total_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
+ disk_type_param = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT);
+ if (disk_type_param) {
+ if (!strcmp(disk_type_param, "dynamic")) {
disk_type = VHD_DYNAMIC;
- } else if (!strcmp(disk_type_param->value.s, "fixed")) {
+ } else if (!strcmp(disk_type_param, "fixed")) {
disk_type = VHD_FIXED;
} else {
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
} else {
disk_type = VHD_DYNAMIC;
@@ -772,7 +771,8 @@ static int vpc_create(const char *filename,
QEMUOptionParameter *options,
/* Create the file */
fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (fd < 0) {
- return -EIO;
+ ret = -EIO;
+ goto out;
}
/*
@@ -837,8 +837,10 @@ static int vpc_create(const char *filename,
QEMUOptionParameter *options,
ret = create_fixed_disk(fd, buf, total_size);
}
- fail:
+fail:
qemu_close(fd);
+out:
+ g_free(disk_type_param);
return ret;
}
@@ -866,20 +868,24 @@ static void vpc_close(BlockDriverState *bs)
error_free(s->migration_blocker);
}
-static QEMUOptionParameter vpc_create_options[] = {
- {
- .name = BLOCK_OPT_SIZE,
- .type = OPT_SIZE,
- .help = "Virtual disk size"
- },
- {
- .name = BLOCK_OPT_SUBFMT,
- .type = OPT_STRING,
- .help =
- "Type of virtual hard disk format. Supported formats are "
- "{dynamic (default) | fixed} "
- },
- { NULL }
+static QemuOptsList vpc_create_opts = {
+ .name = "vpc-create-opts",
+ .head = QTAILQ_HEAD_INITIALIZER(vpc_create_opts.head),
+ .desc = {
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ {
+ .name = BLOCK_OPT_SUBFMT,
+ .type = QEMU_OPT_STRING,
+ .help =
+ "Type of virtual hard disk format. Supported formats are "
+ "{dynamic (default) | fixed} "
+ },
+ { /* end of list */ }
+ }
};
static BlockDriver bdrv_vpc = {
@@ -890,14 +896,14 @@ static BlockDriver bdrv_vpc = {
.bdrv_open = vpc_open,
.bdrv_close = vpc_close,
.bdrv_reopen_prepare = vpc_reopen_prepare,
- .bdrv_create = vpc_create,
+ .bdrv_create2 = vpc_create,
.bdrv_read = vpc_co_read,
.bdrv_write = vpc_co_write,
.bdrv_get_info = vpc_get_info,
- .create_options = vpc_create_options,
+ .create_opts = &vpc_create_opts,
.bdrv_has_zero_init = vpc_has_zero_init,
};
--
1.7.12.4
- [Qemu-devel] [PATCH v25 20/31] raw-posix.c: replace QEMUOptionParameter with QemuOpts, (continued)
- [Qemu-devel] [PATCH v25 20/31] raw-posix.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 18/31] qcow2.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 21/31] raw-win32.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 22/31] raw_bsd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 27/31] vhdx.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 25/31] ssh.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 24/31] sheepdog.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 23/31] rbd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 26/31] vdi.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 28/31] vmdk.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 29/31] vpc.c: replace QEMUOptionParameter with QemuOpts,
Chunyan Liu <=
- [Qemu-devel] [PATCH v25 31/31] QemuOpts: cleanup tmp 'allocated' member from QemuOptsList, Chunyan Liu, 2014/04/11
- [Qemu-devel] [PATCH v25 30/31] cleanup QEMUOptionParameter, Chunyan Liu, 2014/04/11
- Re: [Qemu-devel] [PATCH v25 00/31] replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/04/25
- Re: [Qemu-devel] [PATCH v25 00/31] replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/21