[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 34/39] vdi.c: replace QEMUOptionParameter with QemuOp
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 34/39] vdi.c: replace QEMUOptionParameter with QemuOpts |
Date: |
Mon, 16 Jun 2014 19:23:58 +0800 |
From: Chunyan Liu <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Dong Xu Wang <address@hidden>
Signed-off-by: Chunyan Liu <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/vdi.c | 73 +++++++++++++++++++++++++++++--------------------------------
1 file changed, 35 insertions(+), 38 deletions(-)
diff --git a/block/vdi.c b/block/vdi.c
index 1b2be1a..31d9b3c 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -672,8 +672,7 @@ static int vdi_co_write(BlockDriverState *bs,
return ret;
}
-static int vdi_create(const char *filename, QEMUOptionParameter *options,
- Error **errp)
+static int vdi_create(const char *filename, QemuOpts *opts, Error **errp)
{
int fd;
int result = 0;
@@ -688,25 +687,18 @@ static int vdi_create(const char *filename,
QEMUOptionParameter *options,
logout("\n");
/* Read out options. */
- while (options && options->name) {
- if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
- bytes = options->value.n;
+ bytes = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
#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, ...). */
- block_size = options->value.n;
- }
+ /* TODO: Additional checks (SECTOR_SIZE * 2^n, ...). */
+ block_size = qemu_opt_get_size_del(opts,
+ BLOCK_OPT_CLUSTER_SIZE,
+ DEFAULT_CLUSTER_SIZE);
#endif
#if defined(CONFIG_VDI_STATIC_IMAGE)
- } else if (!strcmp(options->name, BLOCK_OPT_STATIC)) {
- if (options->value.n) {
- image_type = VDI_TYPE_STATIC;
- }
-#endif
- }
- options++;
+ if (qemu_opt_get_bool_del(opts, BLOCK_OPT_STATIC, false)) {
+ image_type = VDI_TYPE_STATIC;
}
+#endif
if (bytes > VDI_DISK_SIZE_MAX) {
result = -ENOTSUP;
@@ -801,29 +793,34 @@ static void vdi_close(BlockDriverState *bs)
error_free(s->migration_blocker);
}
-static QEMUOptionParameter vdi_create_options[] = {
- {
- .name = BLOCK_OPT_SIZE,
- .type = OPT_SIZE,
- .help = "Virtual disk size"
- },
+static QemuOptsList vdi_create_opts = {
+ .name = "vdi-create-opts",
+ .head = QTAILQ_HEAD_INITIALIZER(vdi_create_opts.head),
+ .desc = {
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Virtual disk size"
+ },
#if defined(CONFIG_VDI_BLOCK_SIZE)
- {
- .name = BLOCK_OPT_CLUSTER_SIZE,
- .type = OPT_SIZE,
- .help = "VDI cluster (block) size",
- .value = { .n = DEFAULT_CLUSTER_SIZE },
- },
+ {
+ .name = BLOCK_OPT_CLUSTER_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "VDI cluster (block) size",
+ .def_value_str = stringify(DEFAULT_CLUSTER_SIZE)
+ },
#endif
#if defined(CONFIG_VDI_STATIC_IMAGE)
- {
- .name = BLOCK_OPT_STATIC,
- .type = OPT_FLAG,
- .help = "VDI static (pre-allocated) image"
- },
+ {
+ .name = BLOCK_OPT_STATIC,
+ .type = QEMU_OPT_BOOL,
+ .help = "VDI static (pre-allocated) image",
+ .def_value_str = "off"
+ },
#endif
- /* TODO: An additional option to set UUID values might be useful. */
- { NULL }
+ /* TODO: An additional option to set UUID values might be useful. */
+ { /* end of list */ }
+ }
};
static BlockDriver bdrv_vdi = {
@@ -833,7 +830,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_open = vdi_open,
.bdrv_close = vdi_close,
.bdrv_reopen_prepare = vdi_reopen_prepare,
- .bdrv_create = vdi_create,
+ .bdrv_create2 = vdi_create,
.bdrv_has_zero_init = bdrv_has_zero_init_1,
.bdrv_co_get_block_status = vdi_co_get_block_status,
.bdrv_make_empty = vdi_make_empty,
@@ -845,7 +842,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_get_info = vdi_get_info,
- .create_options = vdi_create_options,
+ .create_opts = &vdi_create_opts,
.bdrv_check = vdi_check,
};
--
1.9.3
- [Qemu-devel] [PULL 24/39] qcow.c: replace QEMUOptionParameter with QemuOpts, (continued)
- [Qemu-devel] [PULL 24/39] qcow.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 25/39] QemuOpts: export qemu_opt_find, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 26/39] qcow2.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 27/39] qed.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 28/39] raw-posix.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 29/39] raw-win32.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 30/39] raw_bsd.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 31/39] rbd.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 32/39] sheepdog.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 33/39] ssh.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 34/39] vdi.c: replace QEMUOptionParameter with QemuOpts,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 35/39] vhdx.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 37/39] vpc.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 38/39] cleanup QEMUOptionParameter, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 39/39] QemuOpts: cleanup tmp 'allocated' member from QemuOptsList, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 36/39] vmdk.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- Re: [Qemu-devel] [PULL 00/39] Block patches, Peter Maydell, 2014/06/16