vdi.c: replace QEMUOptionParameter with QemuOpts

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Chunyan Liu 2014-06-05 17:21:07 +08:00 committed by Stefan Hajnoczi
parent 766181fe57
commit 004b7f2522
1 changed files with 35 additions and 38 deletions

View File

@ -672,8 +672,7 @@ static int vdi_co_write(BlockDriverState *bs,
return ret; return ret;
} }
static int vdi_create(const char *filename, QEMUOptionParameter *options, static int vdi_create(const char *filename, QemuOpts *opts, Error **errp)
Error **errp)
{ {
int fd; int fd;
int result = 0; int result = 0;
@ -688,25 +687,18 @@ static int vdi_create(const char *filename, QEMUOptionParameter *options,
logout("\n"); logout("\n");
/* Read out options. */ /* Read out options. */
while (options && options->name) { bytes = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
bytes = options->value.n;
#if defined(CONFIG_VDI_BLOCK_SIZE) #if defined(CONFIG_VDI_BLOCK_SIZE)
} else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) {
if (options->value.n) {
/* TODO: Additional checks (SECTOR_SIZE * 2^n, ...). */ /* TODO: Additional checks (SECTOR_SIZE * 2^n, ...). */
block_size = options->value.n; block_size = qemu_opt_get_size_del(opts,
} BLOCK_OPT_CLUSTER_SIZE,
DEFAULT_CLUSTER_SIZE);
#endif #endif
#if defined(CONFIG_VDI_STATIC_IMAGE) #if defined(CONFIG_VDI_STATIC_IMAGE)
} else if (!strcmp(options->name, BLOCK_OPT_STATIC)) { if (qemu_opt_get_bool_del(opts, BLOCK_OPT_STATIC, false)) {
if (options->value.n) {
image_type = VDI_TYPE_STATIC; image_type = VDI_TYPE_STATIC;
} }
#endif #endif
}
options++;
}
if (bytes > VDI_DISK_SIZE_MAX) { if (bytes > VDI_DISK_SIZE_MAX) {
result = -ENOTSUP; result = -ENOTSUP;
@ -801,29 +793,34 @@ static void vdi_close(BlockDriverState *bs)
error_free(s->migration_blocker); error_free(s->migration_blocker);
} }
static QEMUOptionParameter vdi_create_options[] = { static QemuOptsList vdi_create_opts = {
.name = "vdi-create-opts",
.head = QTAILQ_HEAD_INITIALIZER(vdi_create_opts.head),
.desc = {
{ {
.name = BLOCK_OPT_SIZE, .name = BLOCK_OPT_SIZE,
.type = OPT_SIZE, .type = QEMU_OPT_SIZE,
.help = "Virtual disk size" .help = "Virtual disk size"
}, },
#if defined(CONFIG_VDI_BLOCK_SIZE) #if defined(CONFIG_VDI_BLOCK_SIZE)
{ {
.name = BLOCK_OPT_CLUSTER_SIZE, .name = BLOCK_OPT_CLUSTER_SIZE,
.type = OPT_SIZE, .type = QEMU_OPT_SIZE,
.help = "VDI cluster (block) size", .help = "VDI cluster (block) size",
.value = { .n = DEFAULT_CLUSTER_SIZE }, .def_value_str = stringify(DEFAULT_CLUSTER_SIZE)
}, },
#endif #endif
#if defined(CONFIG_VDI_STATIC_IMAGE) #if defined(CONFIG_VDI_STATIC_IMAGE)
{ {
.name = BLOCK_OPT_STATIC, .name = BLOCK_OPT_STATIC,
.type = OPT_FLAG, .type = QEMU_OPT_BOOL,
.help = "VDI static (pre-allocated) image" .help = "VDI static (pre-allocated) image",
.def_value_str = "off"
}, },
#endif #endif
/* TODO: An additional option to set UUID values might be useful. */ /* TODO: An additional option to set UUID values might be useful. */
{ NULL } { /* end of list */ }
}
}; };
static BlockDriver bdrv_vdi = { static BlockDriver bdrv_vdi = {
@ -833,7 +830,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_open = vdi_open, .bdrv_open = vdi_open,
.bdrv_close = vdi_close, .bdrv_close = vdi_close,
.bdrv_reopen_prepare = vdi_reopen_prepare, .bdrv_reopen_prepare = vdi_reopen_prepare,
.bdrv_create = vdi_create, .bdrv_create2 = vdi_create,
.bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_has_zero_init = bdrv_has_zero_init_1,
.bdrv_co_get_block_status = vdi_co_get_block_status, .bdrv_co_get_block_status = vdi_co_get_block_status,
.bdrv_make_empty = vdi_make_empty, .bdrv_make_empty = vdi_make_empty,
@ -845,7 +842,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_get_info = vdi_get_info, .bdrv_get_info = vdi_get_info,
.create_options = vdi_create_options, .create_opts = &vdi_create_opts,
.bdrv_check = vdi_check, .bdrv_check = vdi_check,
}; };