Patch 1 add def_value_str and use it in qemu_opts_print. Patch 2 Create functions to pair with QEMUOptionParameter parser.
Patch 3 Use QemuOpts parser in Block. Patch 4 Remove QEMUOptionParameter parser related code. def_value_str is not real default value string now, we have to use it like this: cluster_size = qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZE, DEFAULT_CLUSTER_SIZE); qemu_opt_get_size has many consumers now, so I did not change it in this patch series. Checking whether opts is NULL is useless in block format drivers, but it is needed in block protocols, I think formats and protocols should share the same code style, so I checked opts in block format drivers. V10-V11: 1) print all values that have actually been assigned while accept-any cases. 2) qed.h move QED_DEFAULT_CLUSTER_SIZE from enum to macro, or qemu_opts_print produce un-expanded cluster_size. 3) In qcow2.c and qcow.c, bdrv_create_file(filename, NULL), NULL -> opts, or while using protocol, there will be an error. V9->V10: 1) Fix compile error on patch 3. v8->v9: 1) add qemu_ prefix to gluster_create_opts. 2) fix bug: bdrv_gluster_unix and bdrv_gluster_rdma should also be converted. v7->v8: 1) print "elements => accept any params" while opts_accepts_any() == true. 2) since def_print_str is the default value if an option isn't set, so rename it to def_value_str. 3) rebase to upstream source tree. 4) add gluster.c, raw-win32.c, and rbd.c. v6->v7: 1) Fix typo: enouth->enough. 2) use osdep.h:stringify(), not redefining new macro. 3) preserve TODO comment. 4) fix typo: BLOCK_OPT_ENCRYPT->BLOCK_OPT_STATIC. 5) initialize disk_type even when opts is NULL. v5->v6: 1) allocate enough space in append_opts_list function. 2) judge if opts == NULL in block layer create functions. 3) use bdrv_create_file(filename, NULL) in qcow_create funtion. 4) made more readable while using qemu_opt_get_number funtion. v4->v5: 1) Rewrite qemu_opts_create_nofail function based on Peter Maydell's comments. 2) Use g_strdup_printf in qemu_opt_set_number. 3) Rewrite qemu_opts_print. 4) .bdrv_create_options returns pointer directly. Fix a bug about "encryption". 5) Check qemu_opt_get_number in raw-posix.c. v3->v4: 1) Rebased to the newest source tree. 2) Remove redundant "#include "block-cache.h" 3) Other small changes. v2->v3: 1) rewrite qemu_opt_set_bool and qemu_opt_set_number according Paolo's coments. 2) split patches to make review easier. v1->v2: 1) add Luiz's patches. 2) create qemu_opt_set_number() and qemu_opts_create_nofail() functions. 3) add QemuOptsList map to drivers. 4) use original opts parser, not creating new ones. 5) fix other bugs. Dong Xu Wang (4): add def_value_str and use it in qemu_opts_print Create four opts list related functions Use QemuOpts support in block layer remove QEMUOptionParameter related functions and struct block.c | 91 +++++------ block/cow.c | 46 +++--- block/gluster.c | 37 ++--- block/qcow.c | 60 +++---- block/qcow2.c | 171 ++++++++++---------- block/qed.c | 86 +++++----- block/qed.h | 2 +- block/raw-posix.c | 59 ++++--- block/raw-win32.c | 30 ++-- block/raw.c | 30 ++-- block/rbd.c | 62 +++---- block/sheepdog.c | 75 +++++---- block/vdi.c | 69 ++++---- block/vmdk.c | 74 ++++----- block/vpc.c | 67 ++++---- block/vvfat.c | 11 +- include/block/block.h | 4 +- include/block/block_int.h | 6 +- include/qemu/option.h | 37 +---- qemu-img.c | 61 ++++--- util/qemu-option.c | 405 +++++++++++++--------------------------------- 21 files changed, 639 insertions(+), 844 deletions(-) -- 1.7.11.7