[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v23 31/32] cleanup QEMUOptionParameter
From: |
Leandro Dorileo |
Subject: |
Re: [Qemu-devel] [PATCH v23 31/32] cleanup QEMUOptionParameter |
Date: |
Tue, 25 Mar 2014 18:02:16 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Fri, Mar 21, 2014 at 06:12:42PM +0800, Chunyan Liu wrote:
> Now that all backend drivers are using QemuOpts, remove all
> QEMUOptionParameter related codes.
>
> Signed-off-by: Dong Xu Wang <address@hidden>
> Signed-off-by: Chunyan Liu <address@hidden>
> ---
> block.c | 85 ++-------
> block/cow.c | 4 +-
> block/gluster.c | 8 +-
> block/iscsi.c | 2 +-
> block/qcow.c | 4 +-
> block/qcow2.c | 6 +-
> block/qed.c | 4 +-
> block/raw-posix.c | 10 +-
> block/raw-win32.c | 2 +-
> block/raw_bsd.c | 4 +-
> block/rbd.c | 2 +-
> block/sheepdog.c | 6 +-
> block/ssh.c | 2 +-
> block/vdi.c | 2 +-
> block/vhdx.c | 4 +-
> block/vmdk.c | 6 +-
> block/vpc.c | 2 +-
> block/vvfat.c | 12 +-
> include/block/block.h | 8 +-
> include/block/block_int.h | 16 +-
> include/qemu/option.h | 48 +-----
> qemu-img.c | 19 +--
> util/qemu-option.c | 427
> +---------------------------------------------
> 23 files changed, 67 insertions(+), 616 deletions(-)
>
> diff --git a/block.c b/block.c
> index 125279c..1f11007 100644
> --- a/block.c
> +++ b/block.c
> @@ -407,7 +407,6 @@ BlockDriver *bdrv_find_whitelisted_format(const char
> *format_name,
> typedef struct CreateCo {
> BlockDriver *drv;
> char *filename;
> - QEMUOptionParameter *options;
> QemuOpts *opts;
> int ret;
> Error *err;
> @@ -420,27 +419,8 @@ static void coroutine_fn bdrv_create_co_entry(void
> *opaque)
>
> CreateCo *cco = opaque;
> assert(cco->drv);
> - assert(!(cco->options && cco->opts));
>
> - if (cco->drv->bdrv_create2) {
> - QemuOptsList *opts_list = NULL;
> - QemuOpts *opts = NULL;
> - if (!cco->opts) {
> - opts_list = params_to_opts(cco->options);
> - cco->opts = opts =
> - qemu_opts_create(opts_list, NULL, 0, &error_abort);
> - }
> - ret = cco->drv->bdrv_create2(cco->filename, cco->opts, &local_err);
> - qemu_opts_del(opts);
> - qemu_opts_free(opts_list);
> - } else {
> - QEMUOptionParameter *options = NULL;
> - if (!cco->options) {
> - cco->options = options = opts_to_params(cco->opts);
> - }
> - ret = cco->drv->bdrv_create(cco->filename, cco->options, &local_err);
> - free_option_parameters(options);
> - }
> + ret = cco->drv->bdrv_create(cco->filename, cco->opts, &local_err);
> if (local_err) {
> error_propagate(&cco->err, local_err);
> }
> @@ -448,7 +428,6 @@ static void coroutine_fn bdrv_create_co_entry(void
> *opaque)
> }
>
> int bdrv_create(BlockDriver *drv, const char* filename,
> - QEMUOptionParameter *options,
> QemuOpts *opts, Error **errp)
> {
> int ret;
> @@ -457,13 +436,12 @@ int bdrv_create(BlockDriver *drv, const char* filename,
> CreateCo cco = {
> .drv = drv,
> .filename = g_strdup(filename),
> - .options = options,
> .opts = opts,
> .ret = NOT_DONE,
> .err = NULL,
> };
>
> - if (!drv->bdrv_create && !drv->bdrv_create2) {
> + if (!drv->bdrv_create) {
> error_setg(errp, "Driver '%s' does not support image creation",
> drv->format_name);
> ret = -ENOTSUP;
> goto out;
> @@ -494,8 +472,7 @@ out:
> return ret;
> }
>
> -int bdrv_create_file(const char* filename, QEMUOptionParameter *options,
> - QemuOpts *opts, Error **errp)
> +int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp)
> {
> BlockDriver *drv;
> Error *local_err = NULL;
> @@ -507,7 +484,7 @@ int bdrv_create_file(const char* filename,
> QEMUOptionParameter *options,
> return -ENOENT;
> }
>
> - ret = bdrv_create(drv, filename, options, opts, &local_err);
> + ret = bdrv_create(drv, filename, opts, &local_err);
> if (local_err) {
> error_propagate(errp, local_err);
> }
> @@ -1270,7 +1247,6 @@ int bdrv_open(BlockDriverState **pbs, const char
> *filename,
> BlockDriverState *bs1;
> int64_t total_size;
> BlockDriver *bdrv_qcow2;
> - QemuOptsList *create_opts = NULL;
> QemuOpts *opts = NULL;
> QDict *snapshot_options;
>
> @@ -1297,20 +1273,12 @@ int bdrv_open(BlockDriverState **pbs, const char
> *filename,
> }
>
> bdrv_qcow2 = bdrv_find_format("qcow2");
> -
> - assert(!(bdrv_qcow2->create_options && bdrv_qcow2->create_opts));
> - if (bdrv_qcow2->create_options) {
> - create_opts = params_to_opts(bdrv_qcow2->create_options);
> - } else {
> - create_opts = bdrv_qcow2->create_opts;
> - }
> - opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
> + opts = qemu_opts_create(bdrv_qcow2->create_opts, NULL, 0,
> + &error_abort);
> qemu_opt_set_number(opts, BLOCK_OPT_SIZE, total_size);
> - ret = bdrv_create(bdrv_qcow2, tmp_filename, NULL, opts, &local_err);
> +
> + ret = bdrv_create(bdrv_qcow2, tmp_filename, opts, &local_err);
> qemu_opts_del(opts);
> - if (bdrv_qcow2->create_options) {
> - qemu_opts_free(create_opts);
> - }
> if (ret < 0) {
> error_setg_errno(errp, -ret, "Could not create temporary overlay
> "
> "'%s': %s", tmp_filename,
> @@ -5311,10 +5279,8 @@ void bdrv_img_create(const char *filename, const char
> *fmt,
> return;
> }
>
> - create_opts = qemu_opts_append(create_opts, drv->create_opts,
> - drv->create_options);
> - create_opts = qemu_opts_append(create_opts, proto_drv->create_opts,
> - proto_drv->create_options);
> + create_opts = qemu_opts_append(create_opts, drv->create_opts);
> + create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
>
> /* Create parameter list with default values */
> opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
> @@ -5407,7 +5373,7 @@ void bdrv_img_create(const char *filename, const char
> *fmt,
> puts("");
> }
>
> - ret = bdrv_create(drv, filename, NULL, opts, &local_err);
> + ret = bdrv_create(drv, filename, opts, &local_err);
>
> if (ret == -EFBIG) {
> /* This is generally a better message than whatever the driver would
> @@ -5443,35 +5409,12 @@ void bdrv_add_before_write_notifier(BlockDriverState
> *bs,
> notifier_with_return_list_add(&bs->before_write_notifiers, notifier);
> }
>
> -int bdrv_amend_options(BlockDriverState *bs, QEMUOptionParameter *options,
> - QemuOpts *opts)
> +int bdrv_amend_options(BlockDriverState *bs, QemuOpts *opts)
> {
> - int ret;
> - assert(!(options && opts));
> -
> - if (!bs->drv->bdrv_amend_options && !bs->drv->bdrv_amend_options2) {
> + if (!bs->drv->bdrv_amend_options) {
> return -ENOTSUP;
> }
> - if (bs->drv->bdrv_amend_options2) {
> - QemuOptsList *tmp_opts_list = NULL;
> - QemuOpts *tmp_opts = NULL;
> - if (options) {
> - tmp_opts_list = params_to_opts(options);
> - opts = tmp_opts =
> - qemu_opts_create(tmp_opts_list, NULL, 0, &error_abort);
> - }
> - ret = bs->drv->bdrv_amend_options2(bs, opts);
> - qemu_opts_del(tmp_opts);
> - qemu_opts_free(tmp_opts_list);
> - } else {
> - QEMUOptionParameter *param = NULL;
> - if (opts) {
> - options = param = opts_to_params(opts);
> - }
> - ret = bs->drv->bdrv_amend_options(bs, options);
> - free_option_parameters(param);
> - }
> - return ret;
> + return bs->drv->bdrv_amend_options(bs, opts);
> }
>
> /* This function will be called by the bdrv_recurse_is_first_non_filter
> method
> diff --git a/block/cow.c b/block/cow.c
> index fb2cd68..d49ed17 100644
> --- a/block/cow.c
> +++ b/block/cow.c
> @@ -338,7 +338,7 @@ static int cow_create(const char *filename, QemuOpts
> *opts, Error **errp)
> image_sectors = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / 512;
> image_filename = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
>
> - ret = bdrv_create_file(filename, NULL, opts, &local_err);
> + ret = bdrv_create_file(filename, opts, &local_err);
> if (ret < 0) {
> error_propagate(errp, local_err);
> goto exit;
> @@ -412,7 +412,7 @@ static BlockDriver bdrv_cow = {
> .bdrv_probe = cow_probe,
> .bdrv_open = cow_open,
> .bdrv_close = cow_close,
> - .bdrv_create2 = cow_create,
> + .bdrv_create = cow_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
>
> .bdrv_read = cow_co_read,
> diff --git a/block/gluster.c b/block/gluster.c
> index c5a519e..b1633e2 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -715,7 +715,7 @@ static BlockDriver bdrv_gluster = {
> .bdrv_reopen_commit = qemu_gluster_reopen_commit,
> .bdrv_reopen_abort = qemu_gluster_reopen_abort,
> .bdrv_close = qemu_gluster_close,
> - .bdrv_create2 = qemu_gluster_create,
> + .bdrv_create = qemu_gluster_create,
> .bdrv_getlength = qemu_gluster_getlength,
> .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size,
> .bdrv_truncate = qemu_gluster_truncate,
> @@ -742,7 +742,7 @@ static BlockDriver bdrv_gluster_tcp = {
> .bdrv_reopen_commit = qemu_gluster_reopen_commit,
> .bdrv_reopen_abort = qemu_gluster_reopen_abort,
> .bdrv_close = qemu_gluster_close,
> - .bdrv_create2 = qemu_gluster_create,
> + .bdrv_create = qemu_gluster_create,
> .bdrv_getlength = qemu_gluster_getlength,
> .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size,
> .bdrv_truncate = qemu_gluster_truncate,
> @@ -769,7 +769,7 @@ static BlockDriver bdrv_gluster_unix = {
> .bdrv_reopen_commit = qemu_gluster_reopen_commit,
> .bdrv_reopen_abort = qemu_gluster_reopen_abort,
> .bdrv_close = qemu_gluster_close,
> - .bdrv_create2 = qemu_gluster_create,
> + .bdrv_create = qemu_gluster_create,
> .bdrv_getlength = qemu_gluster_getlength,
> .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size,
> .bdrv_truncate = qemu_gluster_truncate,
> @@ -796,7 +796,7 @@ static BlockDriver bdrv_gluster_rdma = {
> .bdrv_reopen_commit = qemu_gluster_reopen_commit,
> .bdrv_reopen_abort = qemu_gluster_reopen_abort,
> .bdrv_close = qemu_gluster_close,
> - .bdrv_create2 = qemu_gluster_create,
> + .bdrv_create = qemu_gluster_create,
> .bdrv_getlength = qemu_gluster_getlength,
> .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size,
> .bdrv_truncate = qemu_gluster_truncate,
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 316e1b9..4379d14 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -1467,7 +1467,7 @@ static BlockDriver bdrv_iscsi = {
> .bdrv_needs_filename = true,
> .bdrv_file_open = iscsi_open,
> .bdrv_close = iscsi_close,
> - .bdrv_create2 = iscsi_create,
> + .bdrv_create = iscsi_create,
The iscsi_create function is still expecting QEMUOptionParameter
instead of QemuOpts, and the function implementation is still
expecting an argument named opts instead of options.
> .create_opts = &iscsi_create_opts,
> .bdrv_reopen_prepare = iscsi_reopen_prepare,
>
> diff --git a/block/qcow.c b/block/qcow.c
> index 374e6df..18ce338 100644
> --- a/block/qcow.c
> +++ b/block/qcow.c
> @@ -681,7 +681,7 @@ static int qcow_create(const char *filename, QemuOpts
> *opts, Error **errp)
> flags |= BLOCK_FLAG_ENCRYPT;
> }
>
> - ret = bdrv_create_file(filename, NULL, opts, &local_err);
> + ret = bdrv_create_file(filename, opts, &local_err);
> if (ret < 0) {
> error_propagate(errp, local_err);
> goto cleanup;
> @@ -908,7 +908,7 @@ static BlockDriver bdrv_qcow = {
> .bdrv_open = qcow_open,
> .bdrv_close = qcow_close,
> .bdrv_reopen_prepare = qcow_reopen_prepare,
> - .bdrv_create2 = qcow_create,
> + .bdrv_create = qcow_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
>
> .bdrv_co_readv = qcow_co_readv,
> diff --git a/block/qcow2.c b/block/qcow2.c
> index d8e72a5..28184cc 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -1504,7 +1504,7 @@ static int qcow2_create2(const char *filename, int64_t
> total_size,
> Error *local_err = NULL;
> int ret;
>
> - ret = bdrv_create_file(filename, NULL, opts, &local_err);
> + ret = bdrv_create_file(filename, opts, &local_err);
> if (ret < 0) {
> error_propagate(errp, local_err);
> return ret;
> @@ -2257,7 +2257,7 @@ static BlockDriver bdrv_qcow2 = {
> .bdrv_open = qcow2_open,
> .bdrv_close = qcow2_close,
> .bdrv_reopen_prepare = qcow2_reopen_prepare,
> - .bdrv_create2 = qcow2_create,
> + .bdrv_create = qcow2_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
> .bdrv_co_get_block_status = qcow2_co_get_block_status,
> .bdrv_set_key = qcow2_set_key,
> @@ -2289,7 +2289,7 @@ static BlockDriver bdrv_qcow2 = {
>
> .create_opts = &qcow2_create_opts,
> .bdrv_check = qcow2_check,
> - .bdrv_amend_options2 = qcow2_amend_options,
> + .bdrv_amend_options = qcow2_amend_options,
> };
>
> static void bdrv_qcow2_init(void)
> diff --git a/block/qed.c b/block/qed.c
> index ae7b98f..2dbbcfe 100644
> --- a/block/qed.c
> +++ b/block/qed.c
> @@ -566,7 +566,7 @@ static int qed_create(const char *filename, uint32_t
> cluster_size,
> int ret = 0;
> BlockDriverState *bs;
>
> - ret = bdrv_create_file(filename, NULL, NULL, &local_err);
> + ret = bdrv_create_file(filename, NULL, &local_err);
> if (ret < 0) {
> error_propagate(errp, local_err);
> return ret;
> @@ -1635,7 +1635,7 @@ static BlockDriver bdrv_qed = {
> .bdrv_open = bdrv_qed_open,
> .bdrv_close = bdrv_qed_close,
> .bdrv_reopen_prepare = bdrv_qed_reopen_prepare,
> - .bdrv_create2 = bdrv_qed_create,
> + .bdrv_create = bdrv_qed_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
> .bdrv_co_get_block_status = bdrv_qed_co_get_block_status,
> .bdrv_aio_readv = bdrv_qed_aio_readv,
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index e72f449..f51f31d 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -1430,7 +1430,7 @@ static BlockDriver bdrv_file = {
> .bdrv_reopen_commit = raw_reopen_commit,
> .bdrv_reopen_abort = raw_reopen_abort,
> .bdrv_close = raw_close,
> - .bdrv_create2 = raw_create,
> + .bdrv_create = raw_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
> .bdrv_co_get_block_status = raw_co_get_block_status,
> .bdrv_co_write_zeroes = raw_co_write_zeroes,
> @@ -1827,7 +1827,7 @@ static BlockDriver bdrv_host_device = {
> .bdrv_reopen_prepare = raw_reopen_prepare,
> .bdrv_reopen_commit = raw_reopen_commit,
> .bdrv_reopen_abort = raw_reopen_abort,
> - .bdrv_create2 = hdev_create,
> + .bdrv_create = hdev_create,
> .create_opts = &raw_create_opts,
> .bdrv_co_write_zeroes = hdev_co_write_zeroes,
>
> @@ -1971,7 +1971,7 @@ static BlockDriver bdrv_host_floppy = {
> .bdrv_reopen_prepare = raw_reopen_prepare,
> .bdrv_reopen_commit = raw_reopen_commit,
> .bdrv_reopen_abort = raw_reopen_abort,
> - .bdrv_create2 = hdev_create,
> + .bdrv_create = hdev_create,
> .create_opts = &raw_create_opts,
>
> .bdrv_aio_readv = raw_aio_readv,
> @@ -2096,7 +2096,7 @@ static BlockDriver bdrv_host_cdrom = {
> .bdrv_reopen_prepare = raw_reopen_prepare,
> .bdrv_reopen_commit = raw_reopen_commit,
> .bdrv_reopen_abort = raw_reopen_abort,
> - .bdrv_create2 = hdev_create,
> + .bdrv_create = hdev_create,
> .create_opts = &raw_create_opts,
>
> .bdrv_aio_readv = raw_aio_readv,
> @@ -2227,7 +2227,7 @@ static BlockDriver bdrv_host_cdrom = {
> .bdrv_reopen_prepare = raw_reopen_prepare,
> .bdrv_reopen_commit = raw_reopen_commit,
> .bdrv_reopen_abort = raw_reopen_abort,
> - .bdrv_create2 = hdev_create,
> + .bdrv_create = hdev_create,
> .create_opts = &raw_create_opts,
>
> .bdrv_aio_readv = raw_aio_readv,
> diff --git a/block/raw-win32.c b/block/raw-win32.c
> index b00d7fc..7bc04bd 100644
> --- a/block/raw-win32.c
> +++ b/block/raw-win32.c
> @@ -520,7 +520,7 @@ static BlockDriver bdrv_file = {
> .bdrv_parse_filename = raw_parse_filename,
> .bdrv_file_open = raw_open,
> .bdrv_close = raw_close,
> - .bdrv_create2 = raw_create,
> + .bdrv_create = raw_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
>
> .bdrv_aio_readv = raw_aio_readv,
> diff --git a/block/raw_bsd.c b/block/raw_bsd.c
> index ee797fd..492f58d 100644
> --- a/block/raw_bsd.c
> +++ b/block/raw_bsd.c
> @@ -148,7 +148,7 @@ static int raw_create(const char *filename, QemuOpts
> *opts, Error **errp)
> Error *local_err = NULL;
> int ret;
>
> - ret = bdrv_create_file(filename, NULL, opts, &local_err);
> + ret = bdrv_create_file(filename, opts, &local_err);
> if (local_err) {
> error_propagate(errp, local_err);
> }
> @@ -180,7 +180,7 @@ static BlockDriver bdrv_raw = {
> .bdrv_reopen_prepare = &raw_reopen_prepare,
> .bdrv_open = &raw_open,
> .bdrv_close = &raw_close,
> - .bdrv_create2 = &raw_create,
> + .bdrv_create = &raw_create,
> .bdrv_co_readv = &raw_co_readv,
> .bdrv_co_writev = &raw_co_writev,
> .bdrv_co_write_zeroes = &raw_co_write_zeroes,
> diff --git a/block/rbd.c b/block/rbd.c
> index f878877..f189900 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -917,7 +917,7 @@ static BlockDriver bdrv_rbd = {
> .bdrv_needs_filename = true,
> .bdrv_file_open = qemu_rbd_open,
> .bdrv_close = qemu_rbd_close,
> - .bdrv_create2 = qemu_rbd_create,
> + .bdrv_create = qemu_rbd_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
> .bdrv_get_info = qemu_rbd_getinfo,
> .create_opts = &qemu_rbd_create_opts,
> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index 027a34e..c688b0f 100644
> --- a/block/sheepdog.c
> +++ b/block/sheepdog.c
> @@ -2523,7 +2523,7 @@ static BlockDriver bdrv_sheepdog = {
> .bdrv_needs_filename = true,
> .bdrv_file_open = sd_open,
> .bdrv_close = sd_close,
> - .bdrv_create2 = sd_create,
> + .bdrv_create = sd_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
> .bdrv_getlength = sd_getlength,
> .bdrv_get_allocated_file_size = sd_get_allocated_file_size,
> @@ -2553,7 +2553,7 @@ static BlockDriver bdrv_sheepdog_tcp = {
> .bdrv_needs_filename = true,
> .bdrv_file_open = sd_open,
> .bdrv_close = sd_close,
> - .bdrv_create2 = sd_create,
> + .bdrv_create = sd_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
> .bdrv_getlength = sd_getlength,
> .bdrv_get_allocated_file_size = sd_get_allocated_file_size,
> @@ -2583,7 +2583,7 @@ static BlockDriver bdrv_sheepdog_unix = {
> .bdrv_needs_filename = true,
> .bdrv_file_open = sd_open,
> .bdrv_close = sd_close,
> - .bdrv_create2 = sd_create,
> + .bdrv_create = sd_create,
> .bdrv_has_zero_init = bdrv_has_zero_init_1,
> .bdrv_getlength = sd_getlength,
> .bdrv_get_allocated_file_size = sd_get_allocated_file_size,
> diff --git a/block/ssh.c b/block/ssh.c
> index 3a5eead..a4c7f06 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -1042,7 +1042,7 @@ static BlockDriver bdrv_ssh = {
> .instance_size = sizeof(BDRVSSHState),
> .bdrv_parse_filename = ssh_parse_filename,
> .bdrv_file_open = ssh_file_open,
> - .bdrv_create2 = ssh_create,
> + .bdrv_create = ssh_create,
> .bdrv_close = ssh_close,
> .bdrv_has_zero_init = ssh_has_zero_init,
> .bdrv_co_readv = ssh_co_readv,
> diff --git a/block/vdi.c b/block/vdi.c
> index fc0d5a4..677a88e 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -796,7 +796,7 @@ static BlockDriver bdrv_vdi = {
> .bdrv_open = vdi_open,
> .bdrv_close = vdi_close,
> .bdrv_reopen_prepare = vdi_reopen_prepare,
> - .bdrv_create2 = vdi_create,
> + .bdrv_create = 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,
> diff --git a/block/vhdx.c b/block/vhdx.c
> index d90fe55..26ac780 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -1778,7 +1778,7 @@ static int vhdx_create(const char *filename, QemuOpts
> *opts, Error **errp)
> block_size = block_size > VHDX_BLOCK_SIZE_MAX ? VHDX_BLOCK_SIZE_MAX :
> block_size;
>
> - ret = bdrv_create_file(filename, NULL, opts, &local_err);
> + ret = bdrv_create_file(filename, opts, &local_err);
> if (ret < 0) {
> error_propagate(errp, local_err);
> goto exit;
> @@ -1907,7 +1907,7 @@ static BlockDriver bdrv_vhdx = {
> .bdrv_reopen_prepare = vhdx_reopen_prepare,
> .bdrv_co_readv = vhdx_co_readv,
> .bdrv_co_writev = vhdx_co_writev,
> - .bdrv_create2 = vhdx_create,
> + .bdrv_create = vhdx_create,
> .bdrv_get_info = vhdx_get_info,
> .bdrv_check = vhdx_check,
>
> diff --git a/block/vmdk.c b/block/vmdk.c
> index f9b68a0..97e0432 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -1525,7 +1525,7 @@ static int vmdk_create_extent(const char *filename,
> int64_t filesize,
> uint32_t *gd_buf = NULL;
> int gd_buf_size;
>
> - ret = bdrv_create_file(filename, NULL, NULL, &local_err);
> + ret = bdrv_create_file(filename, NULL, &local_err);
> if (ret < 0) {
> error_propagate(errp, local_err);
> goto exit;
> @@ -1859,7 +1859,7 @@ static int vmdk_create(const char *filename, QemuOpts
> *opts, Error **errp)
> if (!split && !flat) {
> desc_offset = 0x200;
> } else {
> - ret = bdrv_create_file(filename, NULL, opts, &local_err);
> + ret = bdrv_create_file(filename, opts, &local_err);
> if (ret < 0) {
> error_setg_errno(errp, -ret, "Could not create image file");
> goto exit;
> @@ -2113,7 +2113,7 @@ static BlockDriver bdrv_vmdk = {
> .bdrv_write = vmdk_co_write,
> .bdrv_co_write_zeroes = vmdk_co_write_zeroes,
> .bdrv_close = vmdk_close,
> - .bdrv_create2 = vmdk_create,
> + .bdrv_create = vmdk_create,
> .bdrv_co_flush_to_disk = vmdk_co_flush,
> .bdrv_co_get_block_status = vmdk_co_get_block_status,
> .bdrv_get_allocated_file_size = vmdk_get_allocated_file_size,
> diff --git a/block/vpc.c b/block/vpc.c
> index ac85514..111c3c6 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -872,7 +872,7 @@ static BlockDriver bdrv_vpc = {
> .bdrv_open = vpc_open,
> .bdrv_close = vpc_close,
> .bdrv_reopen_prepare = vpc_reopen_prepare,
> - .bdrv_create2 = vpc_create,
> + .bdrv_create = vpc_create,
>
> .bdrv_read = vpc_co_read,
> .bdrv_write = vpc_co_write,
> diff --git a/block/vvfat.c b/block/vvfat.c
> index 82b1521..1ccab39 100644
> --- a/block/vvfat.c
> +++ b/block/vvfat.c
> @@ -2907,7 +2907,6 @@ static BlockDriver vvfat_write_target = {
> static int enable_write_target(BDRVVVFATState *s)
> {
> BlockDriver *bdrv_qcow;
> - QemuOptsList *create_opts;
> QemuOpts *opts;
> Error *local_err = NULL;
> int ret;
> @@ -2923,17 +2922,11 @@ static int enable_write_target(BDRVVVFATState *s)
> }
>
> bdrv_qcow = bdrv_find_format("qcow");
> - assert(!(bdrv_qcow->create_opts && bdrv_qcow->create_options));
> - if (bdrv_qcow->create_options) {
> - create_opts = params_to_opts(bdrv_qcow->create_options);
> - } else {
> - create_opts = bdrv_qcow->create_opts;
> - }
> - opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
> + opts = qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abort);
> qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512);
> qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:");
>
> - ret = bdrv_create(bdrv_qcow, s->qcow_filename, NULL, opts, &local_err);
> + ret = bdrv_create(bdrv_qcow, s->qcow_filename, opts, &local_err);
> if (ret < 0) {
> qerror_report_err(local_err);
> error_free(local_err);
> @@ -2963,7 +2956,6 @@ static int enable_write_target(BDRVVVFATState *s)
>
> err:
> qemu_opts_del(opts);
> - qemu_opts_free(create_opts);
> g_free(s->qcow_filename);
> s->qcow_filename = NULL;
> return ret;
> diff --git a/include/block/block.h b/include/block/block.h
> index 6fc9777..6c0ead2 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -177,9 +177,8 @@ BlockDriver *bdrv_find_format(const char *format_name);
> BlockDriver *bdrv_find_whitelisted_format(const char *format_name,
> bool readonly);
> int bdrv_create(BlockDriver *drv, const char* filename,
> - QEMUOptionParameter *options, QemuOpts *opts, Error **errp);
> -int bdrv_create_file(const char* filename, QEMUOptionParameter *options,
> - QemuOpts *opts, Error **errp);
> + QemuOpts *opts, Error **errp);
> +int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp);
> BlockDriverState *bdrv_new(const char *device_name);
> void bdrv_make_anon(BlockDriverState *bs);
> void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old);
> @@ -283,8 +282,7 @@ typedef enum {
>
> int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode
> fix);
>
> -int bdrv_amend_options(BlockDriverState *bs_new, QEMUOptionParameter
> *options,
> - QemuOpts *opts);
> +int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts);
>
> /* external snapshots */
> bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs,
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index f9d87da..bf5b4ed 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -116,10 +116,7 @@ struct BlockDriver {
> const uint8_t *buf, int nb_sectors);
> void (*bdrv_close)(BlockDriverState *bs);
> void (*bdrv_rebind)(BlockDriverState *bs);
> - int (*bdrv_create)(const char *filename, QEMUOptionParameter *options,
> - Error **errp);
> - /* FIXME: will remove the duplicate and rename back to bdrv_create later
> */
> - int (*bdrv_create2)(const char *filename, QemuOpts *opts, Error **errp);
> + int (*bdrv_create)(const char *filename, QemuOpts *opts, Error **errp);
> int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
> int (*bdrv_make_empty)(BlockDriverState *bs);
> /* aio */
> @@ -218,10 +215,6 @@ struct BlockDriver {
> BlockDriverCompletionFunc *cb, void *opaque);
>
> /* List of options for creating images, terminated by name == NULL */
> - QEMUOptionParameter *create_options;
> - /* FIXME: will replace create_options.
> - * These two fields are mutually exclusive. At most one is non-NULL.
> - */
> QemuOptsList *create_opts;
>
> /*
> @@ -231,12 +224,7 @@ struct BlockDriver {
> int (*bdrv_check)(BlockDriverState* bs, BdrvCheckResult *result,
> BdrvCheckMode fix);
>
> - int (*bdrv_amend_options)(BlockDriverState *bs,
> - QEMUOptionParameter *options);
> - /* FIXME: will remove the duplicate and rename back to
> - * bdrv_amend_options later
> - */
> - int (*bdrv_amend_options2)(BlockDriverState *bs, QemuOpts *opts);
> + int (*bdrv_amend_options)(BlockDriverState *bs, QemuOpts *opts);
>
> void (*bdrv_debug_event)(BlockDriverState *bs, BlkDebugEvent event);
>
> diff --git a/include/qemu/option.h b/include/qemu/option.h
> index 120c998..30533d2 100644
> --- a/include/qemu/option.h
> +++ b/include/qemu/option.h
> @@ -31,25 +31,6 @@
> #include "qapi/error.h"
> #include "qapi/qmp/qdict.h"
>
> -enum QEMUOptionParType {
> - OPT_FLAG,
> - OPT_NUMBER,
> - OPT_SIZE,
> - OPT_STRING,
> -};
> -
> -typedef struct QEMUOptionParameter {
> - const char *name;
> - enum QEMUOptionParType type;
> - union {
> - uint64_t n;
> - char* s;
> - } value;
> - const char *help;
> - bool assigned;
> -} QEMUOptionParameter;
> -
> -
> const char *get_opt_name(char *buf, int buf_size, const char *p, char delim);
> const char *get_opt_value(char *buf, int buf_size, const char *p);
> int get_next_param_value(char *buf, int buf_size,
> @@ -58,32 +39,11 @@ int get_param_value(char *buf, int buf_size,
> const char *tag, const char *str);
>
>
> -/*
> - * The following functions take a parameter list as input. This is a pointer
> to
> - * the first element of a QEMUOptionParameter array which is terminated by an
> - * entry with entry->name == NULL.
> - */
> -
> -QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list,
> - const char *name);
> -int set_option_parameter(QEMUOptionParameter *list, const char *name,
> - const char *value);
> -int set_option_parameter_int(QEMUOptionParameter *list, const char *name,
> - uint64_t value);
> -QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest,
> - QEMUOptionParameter *list);
> -QEMUOptionParameter *parse_option_parameters(const char *param,
> - QEMUOptionParameter *list, QEMUOptionParameter *dest);
> void parse_option_size(const char *name, const char *value,
> uint64_t *ret, Error **errp);
> -void free_option_parameters(QEMUOptionParameter *list);
> -void print_option_parameters(QEMUOptionParameter *list);
> -void print_option_help(QEMUOptionParameter *list);
> bool has_help_option(const char *param);
> bool is_valid_option_list(const char *param);
>
> -/* ------------------------------------------------------------------ */
> -
> typedef struct QemuOpt QemuOpt;
> typedef struct QemuOpts QemuOpts;
> typedef struct QemuOptsList QemuOptsList;
> @@ -173,12 +133,6 @@ int qemu_opts_foreach(QemuOptsList *list,
> qemu_opts_loopfunc func, void *opaque,
> int abort_on_failure);
> void qemu_opts_print_help(QemuOptsList *list);
> void qemu_opts_free(QemuOptsList *list);
> -QEMUOptionParameter *opts_to_params(QemuOpts *opts);
> -QemuOptsList *params_to_opts(QEMUOptionParameter *list);
> -/* FIXME: will remove QEMUOptionParameter after all drivers switch to
> QemuOpts.
> - */
> -QemuOptsList *qemu_opts_append(QemuOptsList *dst,
> - QemuOptsList *list,
> - QEMUOptionParameter *param);
> +QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list);
>
> #endif
> diff --git a/qemu-img.c b/qemu-img.c
> index e78e933..771843f 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -244,16 +244,14 @@ static int print_block_option_help(const char
> *filename, const char *fmt)
> return 1;
> }
>
> - create_opts = qemu_opts_append(create_opts, drv->create_opts,
> - drv->create_options);
> + create_opts = qemu_opts_append(create_opts, drv->create_opts);
> if (filename) {
> proto_drv = bdrv_find_protocol(filename, true);
> if (!proto_drv) {
> error_report("Unknown protocol '%s'", filename);
> return 1;
> }
> - create_opts = qemu_opts_append(create_opts, proto_drv->create_opts,
> - proto_drv->create_options);
> + create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
> }
>
> qemu_opts_print_help(create_opts);
> @@ -1340,10 +1338,8 @@ static int img_convert(int argc, char **argv)
> goto out;
> }
>
> - create_opts = qemu_opts_append(create_opts, drv->create_opts,
> - drv->create_options);
> - create_opts = qemu_opts_append(create_opts, proto_drv->create_opts,
> - proto_drv->create_options);
> + create_opts = qemu_opts_append(create_opts, drv->create_opts);
> + create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
>
> opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
> if (options && qemu_opts_do_parse(opts, options, NULL)) {
> @@ -1396,7 +1392,7 @@ static int img_convert(int argc, char **argv)
>
> if (!skip_create) {
> /* Create the new image */
> - ret = bdrv_create(drv, out_filename, NULL, opts, &local_err);
> + ret = bdrv_create(drv, out_filename, opts, &local_err);
> if (ret < 0) {
> error_report("%s: error while converting %s: %s",
> out_filename, out_fmt, error_get_pretty(local_err));
> @@ -2718,8 +2714,7 @@ static int img_amend(int argc, char **argv)
> goto out;
> }
>
> - create_opts = qemu_opts_append(create_opts, bs->drv->create_opts,
> - bs->drv->create_options);
> + create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
> opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
> if (options && qemu_opts_do_parse(opts, options, NULL)) {
> error_report("Invalid options for file format '%s'", fmt);
> @@ -2727,7 +2722,7 @@ static int img_amend(int argc, char **argv)
> goto out;
> }
>
> - ret = bdrv_amend_options(bs, NULL, opts);
> + ret = bdrv_amend_options(bs, opts);
> if (ret < 0) {
> error_report("Error while amending options: %s", strerror(-ret));
> goto out;
> diff --git a/util/qemu-option.c b/util/qemu-option.c
> index a9c53cd..c98f729 100644
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -123,22 +123,6 @@ int get_param_value(char *buf, int buf_size,
> return get_next_param_value(buf, buf_size, tag, &str);
> }
>
> -/*
> - * Searches an option list for an option with the given name
> - */
> -QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list,
> - const char *name)
> -{
> - while (list && list->name) {
> - if (!strcmp(list->name, name)) {
> - return list;
> - }
> - list++;
> - }
> -
> - return NULL;
> -}
> -
> static void parse_option_bool(const char *name, const char *value, bool *ret,
> Error **errp)
> {
> @@ -226,244 +210,6 @@ void parse_option_size(const char *name, const char
> *value,
> }
> }
>
> -/*
> - * Sets the value of a parameter in a given option list. The parsing of the
> - * value depends on the type of option:
> - *
> - * OPT_FLAG (uses value.n):
> - * If no value is given, the flag is set to 1.
> - * Otherwise the value must be "on" (set to 1) or "off" (set to 0)
> - *
> - * OPT_STRING (uses value.s):
> - * value is strdup()ed and assigned as option value
> - *
> - * OPT_SIZE (uses value.n):
> - * The value is converted to an integer. Suffixes for kilobytes etc. are
> - * allowed (powers of 1024).
> - *
> - * Returns 0 on succes, -1 in error cases
> - */
> -int set_option_parameter(QEMUOptionParameter *list, const char *name,
> - const char *value)
> -{
> - bool flag;
> - Error *local_err = NULL;
> -
> - // Find a matching parameter
> - list = get_option_parameter(list, name);
> - if (list == NULL) {
> - fprintf(stderr, "Unknown option '%s'\n", name);
> - return -1;
> - }
> -
> - // Process parameter
> - switch (list->type) {
> - case OPT_FLAG:
> - parse_option_bool(name, value, &flag, &local_err);
> - if (!local_err) {
> - list->value.n = flag;
> - }
> - break;
> -
> - case OPT_STRING:
> - if (value != NULL) {
> - list->value.s = g_strdup(value);
> - } else {
> - fprintf(stderr, "Option '%s' needs a parameter\n", name);
> - return -1;
> - }
> - break;
> -
> - case OPT_SIZE:
> - parse_option_size(name, value, &list->value.n, &local_err);
> - break;
> -
> - default:
> - fprintf(stderr, "Bug: Option '%s' has an unknown type\n", name);
> - return -1;
> - }
> -
> - if (local_err) {
> - qerror_report_err(local_err);
> - error_free(local_err);
> - return -1;
> - }
> -
> - list->assigned = true;
> -
> - return 0;
> -}
> -
> -/*
> - * Sets the given parameter to an integer instead of a string.
> - * This function cannot be used to set string options.
> - *
> - * Returns 0 on success, -1 in error cases
> - */
> -int set_option_parameter_int(QEMUOptionParameter *list, const char *name,
> - uint64_t value)
> -{
> - // Find a matching parameter
> - list = get_option_parameter(list, name);
> - if (list == NULL) {
> - fprintf(stderr, "Unknown option '%s'\n", name);
> - return -1;
> - }
> -
> - // Process parameter
> - switch (list->type) {
> - case OPT_FLAG:
> - case OPT_NUMBER:
> - case OPT_SIZE:
> - list->value.n = value;
> - break;
> -
> - default:
> - return -1;
> - }
> -
> - list->assigned = true;
> -
> - return 0;
> -}
> -
> -/*
> - * Frees a option list. If it contains strings, the strings are freed as
> well.
> - */
> -void free_option_parameters(QEMUOptionParameter *list)
> -{
> - QEMUOptionParameter *cur = list;
> -
> - while (cur && cur->name) {
> - if (cur->type == OPT_STRING) {
> - g_free(cur->value.s);
> - }
> - cur++;
> - }
> -
> - g_free(list);
> -}
> -
> -/*
> - * Count valid options in list
> - */
> -static size_t count_option_parameters(QEMUOptionParameter *list)
> -{
> - size_t num_options = 0;
> -
> - while (list && list->name) {
> - num_options++;
> - list++;
> - }
> -
> - return num_options;
> -}
> -
> -/*
> - * Append an option list (list) to an option list (dest).
> - *
> - * If dest is NULL, a new copy of list is created.
> - *
> - * Returns a pointer to the first element of dest (or the newly allocated
> copy)
> - */
> -QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest,
> - QEMUOptionParameter *list)
> -{
> - size_t num_options, num_dest_options;
> -
> - num_options = count_option_parameters(dest);
> - num_dest_options = num_options;
> -
> - num_options += count_option_parameters(list);
> -
> - dest = g_realloc(dest, (num_options + 1) * sizeof(QEMUOptionParameter));
> - dest[num_dest_options].name = NULL;
> -
> - while (list && list->name) {
> - if (get_option_parameter(dest, list->name) == NULL) {
> - dest[num_dest_options++] = *list;
> - dest[num_dest_options].name = NULL;
> - }
> - list++;
> - }
> -
> - return dest;
> -}
> -
> -/*
> - * Parses a parameter string (param) into an option list (dest).
> - *
> - * list is the template option list. If dest is NULL, a new copy of list is
> - * created. If list is NULL, this function fails.
> - *
> - * A parameter string consists of one or more parameters, separated by
> commas.
> - * Each parameter consists of its name and possibly of a value. In the latter
> - * case, the value is delimited by an = character. To specify a value which
> - * contains commas, double each comma so it won't be recognized as the end of
> - * the parameter.
> - *
> - * For more details of the parsing see above.
> - *
> - * Returns a pointer to the first element of dest (or the newly allocated
> copy)
> - * or NULL in error cases
> - */
> -QEMUOptionParameter *parse_option_parameters(const char *param,
> - QEMUOptionParameter *list, QEMUOptionParameter *dest)
> -{
> - QEMUOptionParameter *allocated = NULL;
> - char name[256];
> - char value[256];
> - char *param_delim, *value_delim;
> - char next_delim;
> - int i;
> -
> - if (list == NULL) {
> - return NULL;
> - }
> -
> - if (dest == NULL) {
> - dest = allocated = append_option_parameters(NULL, list);
> - }
> -
> - for (i = 0; dest[i].name; i++) {
> - dest[i].assigned = false;
> - }
> -
> - while (*param) {
> -
> - // Find parameter name and value in the string
> - param_delim = strchr(param, ',');
> - value_delim = strchr(param, '=');
> -
> - if (value_delim && (value_delim < param_delim || !param_delim)) {
> - next_delim = '=';
> - } else {
> - next_delim = ',';
> - value_delim = NULL;
> - }
> -
> - param = get_opt_name(name, sizeof(name), param, next_delim);
> - if (value_delim) {
> - param = get_opt_value(value, sizeof(value), param + 1);
> - }
> - if (*param != '\0') {
> - param++;
> - }
> -
> - // Set the parameter
> - if (set_option_parameter(dest, name, value_delim ? value : NULL)) {
> - goto fail;
> - }
> - }
> -
> - return dest;
> -
> -fail:
> - // Only free the list if it was newly allocated
> - free_option_parameters(allocated);
> - return NULL;
> -}
> -
> bool has_help_option(const char *param)
> {
> size_t buflen = strlen(param) + 1;
> @@ -513,46 +259,6 @@ out:
> return result;
> }
>
> -/*
> - * Prints all options of a list that have a value to stdout
> - */
> -void print_option_parameters(QEMUOptionParameter *list)
> -{
> - while (list && list->name) {
> - switch (list->type) {
> - case OPT_STRING:
> - if (list->value.s != NULL) {
> - printf("%s='%s' ", list->name, list->value.s);
> - }
> - break;
> - case OPT_FLAG:
> - printf("%s=%s ", list->name, list->value.n ? "on" : "off");
> - break;
> - case OPT_SIZE:
> - case OPT_NUMBER:
> - printf("%s=%" PRId64 " ", list->name, list->value.n);
> - break;
> - default:
> - printf("%s=(unknown type) ", list->name);
> - break;
> - }
> - list++;
> - }
> -}
> -
> -/*
> - * Prints an overview of all available options
> - */
> -void print_option_help(QEMUOptionParameter *list)
> -{
> - printf("Supported options:\n");
> - while (list && list->name) {
> - printf("%-16s %s\n", list->name,
> - list->help ? list->help : "No description available");
> - list++;
> - }
> -}
> -
> void qemu_opts_print_help(QemuOptsList *list)
> {
> int i;
> @@ -1346,122 +1052,6 @@ static size_t count_opts_list(QemuOptsList *list)
> return num_opts;
> }
>
> -/* Convert QEMUOptionParameter to QemuOpts
> - * FIXME: this function will be removed after all drivers
> - * switch to QemuOpts
> - */
> -QemuOptsList *params_to_opts(QEMUOptionParameter *list)
> -{
> - QemuOptsList *opts = NULL;
> - size_t num_opts, i = 0;
> -
> - if (!list) {
> - return NULL;
> - }
> -
> - num_opts = count_option_parameters(list);
> - opts = g_malloc0(sizeof(QemuOptsList) +
> - (num_opts + 1) * sizeof(QemuOptDesc));
> - QTAILQ_INIT(&opts->head);
> - /* (const char *) members will point to malloced space and need to free
> */
> - opts->mallocd = true;
> -
> - while (list && list->name) {
> - opts->desc[i].name = g_strdup(list->name);
> - opts->desc[i].help = g_strdup(list->help);
> - switch (list->type) {
> - case OPT_FLAG:
> - opts->desc[i].type = QEMU_OPT_BOOL;
> - opts->desc[i].def_value_str =
> - g_strdup(list->value.n ? "on" : "off");
> - break;
> -
> - case OPT_NUMBER:
> - opts->desc[i].type = QEMU_OPT_NUMBER;
> - if (list->value.n) {
> - opts->desc[i].def_value_str =
> - g_strdup_printf("%" PRIu64, list->value.n);
> - }
> - break;
> -
> - case OPT_SIZE:
> - opts->desc[i].type = QEMU_OPT_SIZE;
> - if (list->value.n) {
> - opts->desc[i].def_value_str =
> - g_strdup_printf("%" PRIu64, list->value.n);
> - }
> - break;
> -
> - case OPT_STRING:
> - opts->desc[i].type = QEMU_OPT_STRING;
> - opts->desc[i].def_value_str = g_strdup(list->value.s);
> - break;
> - }
> -
> - i++;
> - list++;
> - opts->desc[i].name = NULL;
> - }
> -
> - return opts;
> -}
> -
> -/* convert QemuOpts to QEMUOptionParamter
> - * Note: result QEMUOptionParameter has shorter lifetime than
> - * input QemuOpts.
> - * FIXME: this function will be removed after all drivers
> - * switch to QemuOpts
> - */
> -QEMUOptionParameter *opts_to_params(QemuOpts *opts)
> -{
> - QEMUOptionParameter *dest = NULL;
> - QemuOptDesc *desc;
> - size_t num_opts, i = 0;
> - const char *tmp;
> -
> - if (!opts || !opts->list || !opts->list->desc) {
> - return NULL;
> - }
> - assert(!opts_accepts_any(opts));
> -
> - num_opts = count_opts_list(opts->list);
> - dest = g_malloc0((num_opts + 1) * sizeof(QEMUOptionParameter));
> -
> - desc = opts->list->desc;
> - while (desc && desc->name) {
> - dest[i].name = desc->name;
> - dest[i].help = desc->help;
> - switch (desc->type) {
> - case QEMU_OPT_STRING:
> - dest[i].type = OPT_STRING;
> - tmp = qemu_opt_get(opts, desc->name);
> - dest[i].value.s = g_strdup(tmp);
> - break;
> -
> - case QEMU_OPT_BOOL:
> - dest[i].type = OPT_FLAG;
> - dest[i].value.n = qemu_opt_get_bool(opts, desc->name, 0) ? 1 : 0;
> - break;
> -
> - case QEMU_OPT_NUMBER:
> - dest[i].type = OPT_NUMBER;
> - dest[i].value.n = qemu_opt_get_number(opts, desc->name, 0);
> - break;
> -
> - case QEMU_OPT_SIZE:
> - dest[i].type = OPT_SIZE;
> - dest[i].value.n = qemu_opt_get_size(opts, desc->name, 0);
> - break;
> - }
> -
> - i++;
> - desc++;
> - dest[i].name = NULL;
> - }
> -
> - return dest;
> -}
> -
> void qemu_opts_free(QemuOptsList *list)
> {
> /* List members point to new malloced space and need to free.
> @@ -1482,28 +1072,20 @@ void qemu_opts_free(QemuOptsList *list)
> g_free(list);
> }
>
> -/* Realloc dst option list and append options either from an option list
> (list)
> - * or an QEMUOptionParameter (param) to it. dst could be NULL or a malloced
> list.
> - * FIXME: will remove QEMUOptionParameter after all drivers switch to
> QemuOpts.
> +/* Realloc dst option list and append options from an option list (list)
> + * to it. dst could be NULL or a malloced list.
> */
> QemuOptsList *qemu_opts_append(QemuOptsList *dst,
> - QemuOptsList *list,
> - QEMUOptionParameter *param)
> + QemuOptsList *list)
> {
> size_t num_opts, num_dst_opts;
> - QemuOptsList *tmp_list = NULL;
> QemuOptDesc *desc;
> bool need_init = false;
>
> - assert(!(list && param));
> - if (!param &&!list) {
> + if (!list) {
> return dst;
> }
>
> - if (param) {
> - list = tmp_list = params_to_opts(param);
> - }
> -
> /* If dst is NULL, after realloc, some area of dst should be initialized
> * before adding options to it.
> */
> @@ -1543,6 +1125,5 @@ QemuOptsList *qemu_opts_append(QemuOptsList *dst,
> }
> }
>
> - g_free(tmp_list);
> return dst;
> }
> --
> 1.7.12.4
>
>
--
Leandro Dorileo
- [Qemu-devel] [PATCH v23 23/32] raw_bsd.c: replace QEMUOptionParameter with QemuOpts, (continued)
- [Qemu-devel] [PATCH v23 23/32] raw_bsd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 24/32] rbd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 28/32] vhdx.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 26/32] ssh.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 29/32] vmdk.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 25/32] sheepdog.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 27/32] vdi.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 22/32] raw-win32.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 30/32] vpc.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/03/21
- [Qemu-devel] [PATCH v23 31/32] cleanup QEMUOptionParameter, Chunyan Liu, 2014/03/21
- Re: [Qemu-devel] [PATCH v23 31/32] cleanup QEMUOptionParameter,
Leandro Dorileo <=
- [Qemu-devel] [PATCH v23 32/32] cleanup tmp 'mallocd' member from QemuOptsList, Chunyan Liu, 2014/03/21
- Re: [Qemu-devel] [PATCH v23 00/32] replace QEMUOptionParameter with QemuOpts, Leandro Dorileo, 2014/03/25