replace QEMUOptionParameter with QemuOpts
v20 cover replace QEMUOptionParameter with QemuOpts
This patch series is to replace QEMUOptionParameter with QemuOpts, so that only one Qemu Option structure is kept in QEMU code.
---
Changes to v19:
* fix format issue
* according to Kevin's comments, add convert functions (params_to_opts and opts_to_params) to simplify the block layer patch (patch 06/25), so that it could be easier for review
* add patch to remove assertion in qemu_opts_get function to fix vvfat issue
* rebase to latest code
* v19 is here:
https://lists.endsoftwarepatents.org/archive/html/qemu-devel/2014-01/msg02409.html
Chunyan Liu (26):
add def_value_str to QemuOptDesc
qapi: output def_value_str when query command line options improve some functions in qemu-option.c
add some QemuOpts functions for replace work
remove assertion of qemu_opt_get functions
change block layer to support both QemuOpts and QEMUOptionParameter cow.c: replace QEMUOptionParameter with QemuOpts gluster.c: replace QEMUOptionParameter with QemuOpts iscsi.c: replace QEMUOptionParameter with QemuOpts qcow.c: replace QEMUOptionParameter with QemuOpts qcow2.c: replace QEMUOptionParameter with QemuOpts in create qcow2.c: replace QEMUOptionParameter with QemuOpts in amend options qed.c: replace QEMUOptionParameter with QemuOpts raw-posix.c: replace QEMUOptionParameter with QemuOpts raw-win32.c: replace QEMUOptionParameter with QemuOpts raw_bsd.c: replace QEMUOptionParameter with QemuOpts rbd.c: replace QEMUOptionParameter with QemuOpts sheepdog.c: replace QEMUOptionParameter with QemuOpts ssh.c: replace QEMUOptionParameter with QemuOpts
vdi.c: replace QEMUOptionParameter with QemuOpts
vmdk.c: replace QEMUOptionParameter with QemuOpts
vpc.c: replace QEMUOptionParameter with QemuOpts
vhdx.c: replace QEMUOptionParameter with QemuOpts vvfat.c: replace QEMUOptionParameter with QemuOpts cleanup QEMUOptionParameter
change back to original name from bdrv_create2 to bdrv_create
block.c | 95 ++++---- block/cow.c | 44 ++-- block/gluster.c | 78 ++++--- block/iscsi.c | 29 ++-- block/qcow.c | 61 +++--- block/qcow2.c | 262 +++++++++++----------- block/qed.c | 89 ++++---- block/qed.h | 3 +- block/raw-posix.c | 48 ++--- block/raw-win32.c | 33 ++-- block/raw_bsd.c | 27 ++- block/rbd.c | 63 +++--- block/sheepdog.c | 101 ++++----- block/ssh.c | 31 ++-- block/vdi.c | 69 +++--- block/vhdx.c | 93 ++++---- block/vhdx.h | 1 + block/vmdk.c | 109 +++++----- block/vpc.c | 52 +++-- block/vvfat.c | 10 +- include/block/block.h | 8 +- include/block/block_int.h | 7 +- include/qemu/option.h | 47 +--- qapi-schema.json | 8 +- qemu-img.c | 89 ++++---- qmp-commands.hx | 2 + util/qemu-config.c | 4 + util/qemu-option.c | 547 ++++++++++++++++++++------------------------- 28 files changed, 955 insertions(+), 1055 deletions(-)
PATCH v20 1/26 add def_value_str to QemuOptDesc
Add def_value_str (default value) to QemuOptDesc, to replace function of the default value in QEMUOptionParameter. And improved related functions.
--- include/qemu/option.h | 3 +- util/qemu-option.c | 76 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 11 deletions(-)
include/qemu/option.h +2 -1
@@ -97,6 +97,7 @@ typedef struct QemuOptDesc {const char *name;enum QemuOptType type;const char *help; +const char *def_value_str; } QemuOptDesc;struct QemuOptsList {
@@ -154,7 +155,7 @@ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict);void qemu_opts_absorb_qdict (QemuOpts *opts,QDict *qdict,Error **errp);typedef int (*qemu_opts_loopfunc )(QemuOpts *opts,void *opaque); -int qemu_opts_print (QemuOpts *opts,void *dummy); +void qemu_opts_print (QemuOpts *opts);int qemu_opts_foreach (QemuOptsList *list,qemu_opts_loopfunc func,void *opaque,int abort_on_failure);
util/qemu-option.c +66 -10
122 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 01/26] add def_value_str to QemuOptDesc
Quoted 11 lines · Chunyan Liu
Add
def_value_str(default value) to QemuOptDesc, to replace function of the default value in QEMUOptionParameter. And improved related functions.Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- include/qemu/option.h | 3 +- util/qemu-option.c | 76 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 11 deletions(-)
util/qemu-option.c line 38
Quoted 3 lines
util/qemu-option.c +3
-0+static const QemuOptDesc *find_desc_by_name (const QemuOptDesc *desc, +const char *name); +
Is this a situation where a topological sort would avoid the need for a forward declaration? But that's not the end of the world.
util/qemu-option.c static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) · line 515
Quoted 6 lines
const char *qemu_opt_get(QemuOpts *opts, const char *name)
{ QemuOpt *opt = qemu_opt_find(opts, name);util/qemu-option.c +3
-0+const QemuOptDesc *desc; + +if (!opt) {
If you wanted, you could sink the scope of desc to inside the if block.
But I'm also fine with it as-is.
Review
Quoted 5 lines
bool
qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval){ QemuOpt *opt = qemu_opt_find(opts, name);(quoted diff) +2
-0+ const QemuOptDesc *desc; + Error *local_err = NULL;
Drop this,
util/qemu-option.c bool qemu_opt_has_help_opt(QemuOpts *opts) · line 546
Quoted 7 lines
util/qemu-option.c +5
-1-if (opt ==NULL ) +if (opt ==NULL ) { + desc =find_desc_by_name (opts->list->desc, name); +if (desc && desc->def_value_str) { +parse_option_bool (name, desc->def_value_str, &defval, &local_err); +assert (!local_err);
and change this to use error_abort instead of local_err.
Likewise to all the other qemu_opt_get_ functions.
util/qemu-option.c void qemu_opts_del(QemuOpts *opts) · line 891
Quoted 13 lines
util/qemu-option.c +5
-5-int qemu_opts_print (QemuOpts *opts,void *dummy) +void qemu_opts_print (QemuOpts *opts) {QemuOpt *opt; +QemuOptDesc *desc = opts->list->desc; -fprintf (stderr,"%s: %s:" , opts->list->name, - opts->id ? opts->id :"<noid>" ); - QTAILQ_FOREACH(opt, &opts->head, next) { -fprintf (stderr," %s=\"%s\"" , opt->name, opt->str); +if (desc[0 ].name ==NULL ) { + QTAILQ_FOREACH(opt, &opts->head, next) { +printf ("%s=\"%s\" " , opt->name, opt->str);
Why the swap from stderr to stdout?
util/qemu-option.c void qemu_opts_del(QemuOpts *opts) · line 899
Quoted 8 lines
util/qemu-option.c +8
-0+ } +return ; + } +for (; desc && desc->name; desc++) { +const char *value = desc->def_value_str; +QemuOpt *opt; + + opt =qemu_opt_find (opts, desc->name);
Is this a needless case of O(n^2) complexity?
Quoted 7 lines
util/qemu-option.c +7
-0+if (opt) { + value = opt->str; + } + +if (!value) { +continue ; + }
util/qemu-option.c void qemu_opts_del(QemuOpts *opts) · line 858
Quoted 10 lines
util/qemu-option.c +8
-1+ +if (desc->type ==QEMU_OPT_STRING ) { +printf ("%s='%s' " , desc->name, value); + }else if (desc->type ==QEMU_OPT_SIZE && opt) { +printf ("%s=%" PRIu64" " , desc->name, opt->value.uint); + }else { +printf ("%s=%s " , desc->name, value); + } } -fprintf (stderr,"\n" );
Why the lost newline at the end of the loop?
Quoted 5 lines
- return 0;
}static int opts_do_parse(QemuOpts *opts, const char *params,
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v20 01/26] add def_value_str to QemuOptDesc
2014-02-13 7:00 GMT+08:00 Eric Blake <[email protected]>:
Quoted 60 lines · Chunyan Liu
Quoted 1 line
Add
def_value_str(default value) to QemuOptDesc, to replace function ofthe
Quoted 7 lines
default value in QEMUOptionParameter. And improved related functions.
Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- include/qemu/option.h | 3 +- util/qemu-option.c | 76++++++++++++++++++++++++++++++++++++++++++------
util/qemu-option.c line 38
Quoted 6 lines
2 files changed, 68 insertions(+), 11 deletions(-)util/qemu-option.c +3
-0+static const QemuOptDesc *find_desc_by_name (const QemuOptDesc *desc, +const char *name); +Is this a situation where a topological sort would avoid the need for a forward declaration? But that's not the end of the world.
Just for easier review. Could sort too.
const char *qemu_opt_get(QemuOpts *opts, const char *name)
util/qemu-option.c static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) · line 515
Quoted 5 lines
{ QemuOpt *opt = qemu_opt_find(opts, name);util/qemu-option.c +3
-0+const QemuOptDesc *desc; + +if (!opt) {If you wanted, you could sink the scope of desc to inside the if block.
But I'm also fine with it as-is.Review
Quoted 5 lines
bool
qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval){ QemuOpt *opt = qemu_opt_find(opts, name);(quoted diff) +2
-0+ const QemuOptDesc *desc; + Error *local_err = NULL;Drop this,
util/qemu-option.c bool qemu_opt_has_help_opt(QemuOpts *opts)
Quoted 6 lines
util/qemu-option.c +4
-1-if (opt ==NULL ) +if (opt ==NULL ) { + desc =find_desc_by_name (opts->list->desc, name); +if (desc && desc->def_value_str) { + parse_option_bool(name, desc->def_value_str, &defval,
&local_err);Quoted 1 line
+
assert(!local_err);and change this to use
error_abortinstead oflocal_err.Likewise to all the other
qemu_opt_get_functions.Quoted 6 lines
util/qemu-option.c +2
-1-int qemu_opts_print (QemuOpts *opts,void *dummy) +void qemu_opts_print (QemuOpts *opts) {QemuOpt *opt; +QemuOptDesc *desc = opts->list->desc;
Quoted 10 lines
util/qemu-option.c void qemu_opts_del(QemuOpts *opts) · line 891
Quoted 7 lines
util/qemu-option.c +3
-4-fprintf (stderr,"%s: %s:" , opts->list->name, - opts->id ? opts->id :"<noid>" ); - QTAILQ_FOREACH(opt, &opts->head, next) { -fprintf (stderr," %s=\"%s\"" , opt->name, opt->str); +if (desc[0 ].name ==NULL ) { + QTAILQ_FOREACH(opt, &opts->head, next) { +printf ("%s=\"%s\" " , opt->name, opt->str);Why the swap from stderr to stdout?
It's there since DongXu's v7~v18 :) Will correct that.
Quoted 10 lines
util/qemu-option.c void qemu_opts_del(QemuOpts *opts) · line 899
Quoted 9 lines
util/qemu-option.c +8
-0+ } +return ; + } +for (; desc && desc->name; desc++) { +const char *value = desc->def_value_str; +QemuOpt *opt; + + opt =qemu_opt_find (opts, desc->name);
Quoted 2 lines
Is this a needless case of O(n^2) complexity?
Sorry, I couldn't see it's needless. In a logic: to list all options, if the opt
is set (qemu_opt_find could find it), then use opt->str; otherwise, if there is def_value_str, use default value; it both not, skip it. It seems right.
Quoted 32 lines
Quoted 8 lines
util/qemu-option.c +7
-0+if (opt) { + value = opt->str; + } + +if (!value) { +continue ; + }util/qemu-option.c void qemu_opts_del(QemuOpts *opts) · line 858
Quoted 10 lines
util/qemu-option.c +8
-1+ +if (desc->type ==QEMU_OPT_STRING ) { +printf ("%s='%s' " , desc->name, value); + }else if (desc->type ==QEMU_OPT_SIZE && opt) { +printf ("%s=%" PRIu64" " , desc->name, opt->value.uint); + }else { +printf ("%s=%s " , desc->name, value); + } } -fprintf (stderr,"\n" );Why the lost newline at the end of the loop?
Quoted 5 lines
- return 0;
}static int opts_do_parse(QemuOpts *opts, const char *params,
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v20 2/26 qapi: output def_value_str when query command line options
In reply to Chunyan LiuChange qapi interfaces to output the newly added def_value_str when query command line options.
--- qapi-schema.json | 8 ++++++-- qmp-commands.hx | 2 ++ util/qemu-config.c | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-)
qapi-schema.json +6 -2
@@ -3930,12 +3930,16 @@ # # @help: #optional human readable text string, not suitable for parsing. # -# Since 1.5 +# @default: #optional string representation of the default used +# if the option is omitted. +# +# Since 1.6 ## { 'type': 'CommandLineParameterInfo', 'data': { 'name': 'str', 'type': 'CommandLineParameterType', - '*help': 'str' } } + '*help': 'str', + '*default': 'str'} } ## # @CommandLineOptionInfo:
qmp-commands.hx +2 -0
@@ -2792,6 +2792,8 @@ Each array entry contains the following: or 'size') - "help": human readable description of the parameter (json-string, optional) + - "default": default value string for the parameter + (json-string, optional) Example:
util/qemu-config.c +4 -0
@@ -68,6 +68,10 @@ static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc) info->has_help = true; info->help =g_strdup (desc[i].help); } +if (desc[i].def_value_str) { + info->has_q_default = true; + info->q_default =g_strdup (desc[i].def_value_str); + } entry =g_malloc0 (sizeof (*entry)); entry->value = info;
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 02/26] qapi: output def_value_str when query command line options
Quoted 1 line · Chunyan Liu
Change qapi interfaces to output the newly added
def_value_strwhen query
s/query/querying/
Quoted 8 lines
command line options.
Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>---
+++
b/qapi-schema.json
qapi-schema.json line 3936
Quoted 8 lines
qapi-schema.json +4
-1@@ -3930,12 +3930,16 @@ # # @help: #optional human readable text string, not suitable for parsing. # -# Since 1.5 +# @default: #optional string representation of the default used +# if the option is omitted. +# +# Since 1.6
Changing the Since line is wrong. The @default line needs a "(since 2.0)" designation added.
But the schema addition itself is appropriate.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 3/26 improve some functions in qemu-option.c
In reply to Chunyan LiuImprove opt_get and opt_set group of functions. For opt_get, check and handle NUlL input; for opt_set, when set to an existing option, rewrite the option with new value.
--- util/qemu-option.c | 84 +++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 70 insertions(+), 14 deletions(-)
util/qemu-option.c +70 -14
@@ -499,6 +499,9 @@ static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) {QemuOpt *opt; +if (!opts) +return NULL ; + QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) {if (strcmp (opt->name, name) !=0 )continue ;
@@ -509,9 +512,14 @@ static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name)const char *qemu_opt_get (QemuOpts *opts,const char *name) { -QemuOpt *opt =qemu_opt_find (opts, name); +QemuOpt *opt;const QemuOptDesc *desc; +if (!opts) { +return NULL ; + } + + opt =qemu_opt_find (opts, name);if (!opt) { desc =find_desc_by_name (opts->list->desc, name);if (desc && desc->def_value_str) {
@@ -535,10 +543,16 @@ bool qemu_opt_has_help_opt(QemuOpts *opts)bool qemu_opt_get_bool (QemuOpts *opts,const char *name,bool defval) { -QemuOpt *opt =qemu_opt_find (opts, name); +QemuOpt *opt;const QemuOptDesc *desc;Error *local_err =NULL ; +if (!opts) { +return defval; + } + + opt =qemu_opt_find (opts, name); +if (opt ==NULL ) { desc =find_desc_by_name (opts->list->desc, name);if (desc && desc->def_value_str) {
@@ -553,10 +567,16 @@ bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval)uint64_t qemu_opt_get_number (QemuOpts *opts,const char *name,uint64_t defval) { -QemuOpt *opt =qemu_opt_find (opts, name); +QemuOpt *opt;const QemuOptDesc *desc;Error *local_err =NULL ; +if (!opts) { +return defval; + } + + opt =qemu_opt_find (opts, name); +if (opt ==NULL ) { desc =find_desc_by_name (opts->list->desc, name);if (desc && desc->def_value_str) {
@@ -571,10 +591,15 @@ uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval)uint64_t qemu_opt_get_size (QemuOpts *opts,const char *name,uint64_t defval) { -QemuOpt *opt =qemu_opt_find (opts, name); +QemuOpt *opt;const QemuOptDesc *desc;Error *local_err =NULL ; +if (!opts) { +return defval; + } + + opt =qemu_opt_find (opts, name);if (opt ==NULL ) { desc =find_desc_by_name (opts->list->desc, name);if (desc && desc->def_value_str) {
@@ -612,6 +637,10 @@ static void qemu_opt_parse(QemuOpt *opt, Error **errp)static void qemu_opt_del (QemuOpt *opt) { +if (!opt) { +return ; + } +QTAILQ_REMOVE (&opt->opts->head, opt, next);g_free ((/* !const */ char *)opt->name);g_free ((/* !const */ char *)opt->str);
@@ -664,6 +693,13 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,return ; } + opt =qemu_opt_find (opts, name); +if (opt) { +g_free ((char *)opt->str); + opt->str =g_strdup (value); +return ; + } + opt =g_malloc0 (sizeof (*opt)); opt->name =g_strdup (name); opt->opts = opts;
@@ -704,16 +740,24 @@ void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value,int qemu_opt_set_bool (QemuOpts *opts,const char *name,bool val) {QemuOpt *opt; -const QemuOptDesc *desc = opts->list->desc; +const QemuOptDesc *desc; - opt =g_malloc0 (sizeof (*opt)); - opt->desc =find_desc_by_name (desc, name); -if (!opt->desc && !opts_accepts_any (opts)) { + desc =find_desc_by_name (opts->list->desc, name); +if (!desc && !opts_accepts_any (opts)) {qerror_report (QERR_INVALID_PARAMETER , name); -g_free (opt);return -1 ; } + opt =qemu_opt_find (opts, name); +if (opt) { +g_free ((char *)opt->str); + opt->value.boolean = val; + opt->str =g_strdup (val ?"on" :"off" ); +return 0 ; + } + + opt =g_malloc0 (sizeof (*opt)); + opt->desc = desc; opt->name =g_strdup (name); opt->opts = opts; opt->value.boolean = !!val;
@@ -726,16 +770,24 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)int qemu_opt_set_number (QemuOpts *opts,const char *name,int64_t val) {QemuOpt *opt; -const QemuOptDesc *desc = opts->list->desc; +const QemuOptDesc *desc; - opt =g_malloc0 (sizeof (*opt)); - opt->desc =find_desc_by_name (desc, name); -if (!opt->desc && !opts_accepts_any (opts)) { + desc =find_desc_by_name (opts->list->desc, name); +if (!desc && !opts_accepts_any (opts)) {qerror_report (QERR_INVALID_PARAMETER , name); -g_free (opt);return -1 ; } + opt =qemu_opt_find (opts, name); +if (opt) { +g_free ((char *)opt->str); + opt->value.uint = val; + opt->str =g_strdup_printf ("%" PRId64, val); +return 0 ; + } + + opt =g_malloc0 (sizeof (*opt)); + opt->desc = desc; opt->name =g_strdup (name); opt->opts = opts; opt->value.uint = val;
@@ -870,6 +922,10 @@ void qemu_opts_del(QemuOpts *opts) {QemuOpt *opt; +if (!opts) { +return ; + } +for (;;) { opt =QTAILQ_FIRST (&opts->head);if (opt ==NULL )
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 03/26] improve some functions in qemu-option.c
Quoted 2 lines · Chunyan Liu
Improve
opt_getandopt_setgroup of functions. Foropt_get, check and handle NUlL input; foropt_set, when set to an existing option, rewrite the option
s/NUlL/NULL/
Quoted 13 lines
with new value.
Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- util/qemu-option.c | 84 +++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 70 insertions(+), 14 deletions(-)util/qemu-option.c +0
-0
util/qemu-option.c static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) · line 504
Quoted 6 lines
util/qemu-option.c +3
-0@@ -499,6 +499,9 @@ static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) {QemuOpt *opt; +if (!opts) +return NULL ; +
Why not just 'assert(opts);'? In other words, what caller is planning on passing a NULL opts, since I couldn't find any existing caller that did that? Please update the commit message with justification of how this can simplify a caller in a later patch, if that is your plan; but without that justification, I'm going solely off the diffstat and the fact that no existing caller passes NULL, and concluding that this change is bloat.
util/qemu-option.c bool qemu_opt_has_help_opt(QemuOpts *opts) · line 556
Quoted 7 lines
util/qemu-option.c +4
-0+ opt =qemu_opt_find (opts, name);if (!opt) { + + opt =qemu_opt_find (opts, name); +if (opt ==NULL ) {
Inconsistent styles here; might be worth making them all look alike while touching them, if we keep this patch.
util/qemu-option.c static void opt_set(QemuOpts *opts, const char *name, const char *value, · line 699
Quoted 8 lines
util/qemu-option.c +4
-0@@ -664,6 +693,13 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,return ; } + opt =qemu_opt_find (opts, name); +if (opt) { +g_free ((char *)opt->str); + opt->str =g_strdup (value);
Ugg. Why did the struct declare things as const char *str if we are going to be strdup'ing into it? I worry about attempting to free non-malloc'd memory any time I see a cast to lose a const. Is this just a case of someone incorrectly trying to be const-correct, and now you have to work around it? If you drop the 'const' from option_int.h, do things still compile?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v20 03/26] improve some functions in qemu-option.c
2014-02-13 7:22 GMT+08:00 Eric Blake <[email protected]>:
Quoted 30 lines · Chunyan Liu
Quoted 1 line
Improve
opt_getandopt_setgroup of functions. Foropt_get, check andhandle
Quoted 1 line
NUlL input; for
opt_set, when set to an existing option, rewrite theoption
s/NUlL/NULL/
Quoted 6 lines
with new value.
Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- util/qemu-option.c | 84+++++++++++++++++++++++++++++++++++++++++++--------
util/qemu-option.c static QemuOpt *qemu_opt_find(QemuOpts *opts, const
Quoted 7 lines
1 files changed, 70 insertions(+), 14 deletions(-)util/qemu-option.c +0
-0@@ -499,6 +499,9 @@ static QemuOpt *qemu_opt_find(QemuOpts *opts, constchar *name)
util/qemu-option.c static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) · line 504
Quoted 6 lines
util/qemu-option.c +3
-0{QemuOpt *opt; +if (!opts) +return NULL ; +
Quoted 9 lines
Why not just 'assert(opts);'? In other words, what caller is planning on passing a NULL opts, since I couldn't find any existing caller that did that? Please update the commit message with justification of how this can simplify a caller in a later patch, if that is your plan; but without that justification, I'm going solely off the diffstat and the fact that no existing caller passes NULL, and concluding that this change is bloat.
In existing code, qemu_opt_get* and qemu_opt_unset are calling it, both directly call qemu_opt_find without checking opts==NULL case. For these patch
series, after adding opts check in qemu_opt_get, I can remove that from qemu_opt_find, no problem. I just thought it would be safer to add a check.
Quoted 21 lines
util/qemu-option.c bool qemu_opt_has_help_opt(QemuOpts *opts) · line 556
Quoted 7 lines
util/qemu-option.c +4
-0+ opt =qemu_opt_find (opts, name);if (!opt) { + + opt =qemu_opt_find (opts, name); +if (opt ==NULL ) {Inconsistent styles here; might be worth making them all look alike while touching them, if we keep this patch.
util/qemu-option.c static void opt_set(QemuOpts *opts, const char
Quoted 1 line
util/qemu-option.c +0
-0@@ -664,6 +693,13 @@ static void opt_set(QemuOpts *opts, const char*name, const char *value,
util/qemu-option.c static void opt_set(QemuOpts *opts, const char *name, const char *value, · line 699
Quoted 7 lines
util/qemu-option.c +4
-0return ; } + opt =qemu_opt_find (opts, name); +if (opt) { +g_free ((char *)opt->str); + opt->str =g_strdup (value);
Quoted 8 lines
Ugg. Why did the struct declare things as const char *str if we are going to be strdup'ing into it? I worry about attempting to free non-malloc'd memory any time I see a cast to lose a const. Is this just a case of someone incorrectly trying to be const-correct, and now you have to work around it? If you drop the 'const' from
option_int.h, do things still compile?I followed existing code (incorrectly using). Will remove "const" (still
compile).
Thanks.
Quoted 5 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v20 4/26 add some QemuOpts functions for replace work
In reply to Chunyan LiuAdd some qemu_opt functions to replace the same functionality of QEMUOptionParameter handling.
--- include/qemu/option.h | 9 +++ util/qemu-option.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 0 deletions(-)
include/qemu/option.h +9 -0
@@ -109,6 +109,7 @@ struct QemuOptsList { };const char *qemu_opt_get (QemuOpts *opts,const char *name); +const char *qemu_opt_get_del (QemuOpts *opts,const char *name);/** * qemu_opt_has_help_opt: * @opts: options to search for a help request
@@ -124,6 +125,11 @@ bool qemu_opt_has_help_opt(QemuOpts *opts);bool qemu_opt_get_bool (QemuOpts *opts,const char *name,bool defval);uint64_t qemu_opt_get_number (QemuOpts *opts,const char *name,uint64_t defval);uint64_t qemu_opt_get_size (QemuOpts *opts,const char *name,uint64_t defval); +bool qemu_opt_get_bool_del (QemuOpts *opts,const char *name,bool defval); +uint64_t qemu_opt_get_number_del (QemuOpts *opts,const char *name, +uint64_t defval); +uint64_t qemu_opt_get_size_del (QemuOpts *opts,const char *name, +uint64_t defval);int qemu_opt_unset (QemuOpts *opts,const char *name);int qemu_opt_set (QemuOpts *opts,const char *name,const char *value); void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value,
@@ -159,4 +165,7 @@ void qemu_opts_print(QemuOpts *opts);int qemu_opts_foreach (QemuOptsList *list,qemu_opts_loopfunc func,void *opaque,int abort_on_failure); +QemuOptsList *qemu_opts_append (QemuOptsList *dst,QemuOptsList *list); +void qemu_opts_free (QemuOptsList *list); +void qemu_opts_print_help (QemuOptsList *list);#endif
util/qemu-option.c +134 -0
167 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 04/26] add some QemuOpts functions for replace work
Quoted 11 lines · Chunyan Liu
Add some
qemu_optfunctions to replace the same functionality of QEMUOptionParameter handling.Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- include/qemu/option.h | 9 +++ util/qemu-option.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 0 deletions(-)
util/qemu-option.c const char *qemu_opt_get(QemuOpts *opts, const char *name) · line 607
Quoted 8 lines
util/qemu-option.c +8
-0+static void qemu_opt_del (QemuOpt *opt); + +const char *qemu_opt_get_del (QemuOpts *opts,const char *name) +{ +const char *str =qemu_opt_get (opts, name); +QemuOpt *opt =qemu_opt_find (opts, name); +if (opt) { +qemu_opt_del (opt);
Is it any more efficient to reduce the number of times you crawl through the list? For example, instead of crawling the list with qemu_opt_get, why not get teh string directly from the result of qemu_opt_find? Also, you crawl again for qemu_opt_del. Maybe it's unavoidable, and certainly still O(n), so not the end of the world, but worth thinking about.
util/qemu-option.c int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, · line 1395
Quoted 4 lines
util/qemu-option.c +4
-0+void qemu_opts_print_help (QemuOptsList *list) +{ +int i; +printf ("Supported options:\n" );
Why printf? Might there be callers that want to print to somewhere other than stdout?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v20 04/26] add some QemuOpts functions for replace work
2014-02-13 7:31 GMT+08:00 Eric Blake <[email protected]>:
Quoted 13 lines · Chunyan Liu
Quoted 8 lines
Add some
qemu_optfunctions to replace the same functionality of QEMUOptionParameter handling.Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- include/qemu/option.h | 9 +++ util/qemu-option.c | 134+++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 2 lines
2 files changed, 143 insertions(+), 0 deletions(-)
Quoted 15 lines
util/qemu-option.c const char *qemu_opt_get(QemuOpts *opts, const char *name) · line 607
Quoted 8 lines
util/qemu-option.c +8
-0+static void qemu_opt_del (QemuOpt *opt); + +const char *qemu_opt_get_del (QemuOpts *opts,const char *name) +{ +const char *str =qemu_opt_get (opts, name); +QemuOpt *opt =qemu_opt_find (opts, name); +if (opt) { +qemu_opt_del (opt);Is it any more efficient to reduce the number of times you crawl through the list? For example, instead of crawling the list with
qemu_opt_get, why not get teh string directly from the result ofqemu_opt_find? Also, you crawl again forqemu_opt_del. Maybe it's unavoidable, and certainly still O(n), so not the end of the world, but worth thinking about.
In previous Dong Xu's patch, it's commented that there is too much code duplication in qemu_opt_get and qemu_opt_get_del, could using qemu_opt_get directly. Well, I'll improve that. Add "remove" flag to _qemu_opt_get to handle
delete or not, and then wrapper _qemu_opt_get to generate qemu_opt_get and qemu_opt_get_del.
Quoted 8 lines
+void
qemu_opts_print_help(QemuOptsList *list)util/qemu-option.c int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, · line 1395
Quoted 3 lines
util/qemu-option.c +3
-0+{ +int i; +printf ("Supported options:\n" );Why printf? Might there be callers that want to print to somewhere other than stdout?
Just followed print_option_help. Existing print_option_help uses printf. Could improve of course.
Quoted 6 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v20 5/26 remove assertion of qemu_opt_get functions
In reply to Chunyan LiuIn qemu_opt_set functions, if desc doen't exist but opts_accepts_any is true, it won't report error, but can still alloc an opt for the option and save it. However, after that, when doing qemu_opt_get, this option could be found in opts but opt->desc is NULL. This is correct, should not be treated as error.
This patch would fix vvfat issue after changing to QemuOpts.
--- util/qemu-option.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
util/qemu-option.c +0 -3
@@ -641,7 +641,6 @@ bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval) }return defval; } -assert (opt->desc && opt->desc->type ==QEMU_OPT_BOOL );return opt->value.boolean; }
@@ -675,7 +674,6 @@ uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval) }return defval; } -assert (opt->desc && opt->desc->type ==QEMU_OPT_NUMBER );return opt->value.uint; }
@@ -710,7 +708,6 @@ uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval) }return defval; } -assert (opt->desc && opt->desc->type ==QEMU_OPT_SIZE );return opt->value.uint; }
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 05/26] remove assertion of qemu_opt_get functions
Quoted 1 line · Chunyan Liu
In
qemu_opt_setfunctions, if desc doen't exist butopts_accepts_anyis true, it
s/doen't/doesn't/
Quoted 16 lines
won't report error, but can still alloc an opt for the option and save it. However, after that, when doing
qemu_opt_get, this option could be found in opts butopt->descis NULL. This is correct, should not be treated as error.This patch would fix vvfat issue after changing to QemuOpts.
Signed-off-by Chunyan Liu <[email protected]>--- util/qemu-option.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)util/qemu-option.c +0
-0
util/qemu-option.c bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval) · line 644
Quoted 4 lines
util/qemu-option.c +0
-1@@ -641,7 +641,6 @@ bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval) }return defval; } -assert (opt->desc && opt->desc->type ==QEMU_OPT_BOOL );
I'd still rather see:
if (opt->desc) {
assert(opt->desc->type == QEMU_OPT_BOOL);
}That is, weaken but don't eliminate the assertion. Same for the other two sites.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 6/26 change block layer to support both QemuOpts and QEMUOptionParameter
In reply to Chunyan LiuChange block layer to support both QemuOpts and QEMUOptionParameter. After this patch, it will change backend drivers one by one. At the end, QEMUOptionParameter will be removed and only QemuOpts is kept.
--- block.c | 110 ++++++++++++++++++++++++++++---------------- block/cow.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/raw_bsd.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 4 +- block/vvfat.c | 2 +- include/block/block.h | 4 +- include/block/block_int.h | 4 +- include/qemu/option.h | 2 + qemu-img.c | 87 +++++++++++++++++++++-------------- util/qemu-option.c | 111 +++++++++++++++++++++++++++++++++++++++++++++ 14 files changed, 250 insertions(+), 86 deletions(-)
block.c +70 -40
@@ -408,6 +408,7 @@ typedef struct CreateCo {BlockDriver *drv;char *filename;QEMUOptionParameter *options; +QemuOpts *opts;int ret;Error *err; } CreateCo;
@@ -420,7 +421,11 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)CreateCo *cco = opaque;assert (cco->drv); - ret = cco->drv->bdrv_create (cco->filename, cco->options, &local_err); +if (cco->drv->bdrv_create2) { + ret = cco->drv->bdrv_create2 (cco->filename, cco->opts, &local_err); + }else { + ret = cco->drv->bdrv_create (cco->filename, cco->options, &local_err); + }if (error_is_set (&local_err)) {error_propagate (&cco->err, local_err); }
@@ -428,7 +433,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque) }int bdrv_create (BlockDriver *drv,const char * filename, -QEMUOptionParameter *options,Error **errp) +QEMUOptionParameter *options,QemuOpts *opts,Error **errp) {int ret;
@@ -437,11 +442,12 @@ int bdrv_create(BlockDriver *drv, const char* filename, .drv = drv, .filename = g_strdup(filename), .options = options, + .opts = opts, .ret = NOT_DONE, .err = NULL, }; -if (!drv->bdrv_create) { +if (!drv->bdrv_create && !drv->bdrv_create2) {error_setg (errp,"Driver '%s' does not support image creation" , drv->format_name); ret = -ENOTSUP ; goto out;
@@ -473,7 +479,7 @@ out: }int bdrv_create_file (const char * filename,QEMUOptionParameter *options, -Error **errp) +QemuOpts *opts,Error **errp) {BlockDriver *drv;Error *local_err =NULL ;
@@ -485,7 +491,7 @@ int bdrv_create_file(const char* filename, QEMUOptionParameter *options,return -ENOENT ; } - ret =bdrv_create (drv, filename, options, &local_err); + ret =bdrv_create (drv, filename, options, opts, &local_err);if (error_is_set (&local_err)) {error_propagate (errp, local_err); }
@@ -1246,7 +1252,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,BlockDriverState *bs1;int64_t total_size;BlockDriver *bdrv_qcow2; -QEMUOptionParameter *create_options; +QEMUOptionParameter *create_options =NULL ; +QemuOpts *opts =NULL ;QDict *snapshot_options;/* if snapshot, we create a temporary backing file and open it
@@ -1273,13 +1280,21 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, } bdrv_qcow2 =bdrv_find_format ("qcow2" ); - create_options =parse_option_parameters ("" , bdrv_qcow2->create_options, -NULL ); - -set_option_parameter_int (create_options,BLOCK_OPT_SIZE , total_size); +if (bdrv_qcow2->bdrv_create2) { + opts =qemu_opts_create (bdrv_qcow2->create_opts,NULL ,0 , + &error_abort); +qemu_opt_set_number (opts,BLOCK_OPT_SIZE , total_size); + }else { + create_options = +parse_option_parameters ("" , bdrv_qcow2->create_options,NULL ); +set_option_parameter_int (create_options,BLOCK_OPT_SIZE , + total_size); + } - ret =bdrv_create (bdrv_qcow2, tmp_filename, create_options, &local_err); + ret =bdrv_create (bdrv_qcow2, tmp_filename, create_options, opts, + &local_err);free_option_parameters (create_options); +qemu_opts_del (opts);if (ret <0 ) { error_setg_errno(errp, -ret, "Could not create temporary overlay " "'%s': %s", tmp_filename,
@@ -5197,7 +5212,10 @@ void bdrv_img_create(const char *filename, const char *fmt, Error **errp, bool quiet) {QEMUOptionParameter *param =NULL , *create_options =NULL ; -QEMUOptionParameter *backing_fmt, *backing_file, *size; +QemuOptsList *create_opts =NULL ; +QemuOpts *opts =NULL ; +const char *backing_fmt, *backing_file; +int64_t size;BlockDriver *drv, *proto_drv;BlockDriver *backing_drv =NULL ;Error *local_err =NULL ;
@@ -5216,28 +5234,31 @@ void bdrv_img_create(const char *filename, const char *fmt,return ; } - create_options =append_option_parameters (create_options, - drv->create_options); - create_options =append_option_parameters (create_options, - proto_drv->create_options); +if (drv->bdrv_create2) { + create_opts =qemu_opts_append (create_opts, drv->create_opts); + create_opts =qemu_opts_append (create_opts, proto_drv->create_opts); + }else { + create_options =append_option_parameters (create_options, + drv->create_options); + create_options =append_option_parameters (create_options, + proto_drv->create_options); + create_opts =params_to_opts (create_options); + }/* Create parameter list with default values */ - param =parse_option_parameters ("" , create_options, param); - -set_option_parameter_int (param,BLOCK_OPT_SIZE , img_size); + opts =qemu_opts_create (create_opts,NULL ,0 , &error_abort); +qemu_opt_set_number (opts,BLOCK_OPT_SIZE , img_size);/* Parse -o options */ if (options) { - param =parse_option_parameters (options, create_options, param); -if (param ==NULL ) { +if (qemu_opts_do_parse (opts, options,NULL ) !=0 ) {error_setg (errp,"Invalid options for file format '%s'." , fmt); goto out; } }if (base_filename) { -if (set_option_parameter (param,BLOCK_OPT_BACKING_FILE , - base_filename)) { +if (qemu_opt_set (opts,BLOCK_OPT_BACKING_FILE , base_filename)) {error_setg (errp,"Backing file not supported for file format '%s'" , fmt); goto out;
@@ -5245,37 +5266,37 @@ void bdrv_img_create(const char *filename, const char *fmt, }if (base_fmt) { -if (set_option_parameter (param,BLOCK_OPT_BACKING_FMT , base_fmt)) { +if (qemu_opt_set (opts,BLOCK_OPT_BACKING_FMT , base_fmt)) {error_setg (errp,"Backing file format not supported for file " "format '%s'" , fmt); goto out; } } - backing_file =get_option_parameter (param,BLOCK_OPT_BACKING_FILE ); -if (backing_file && backing_file->value.s) { -if (!strcmp (filename, backing_file->value.s)) { + backing_file =qemu_opt_get (opts,BLOCK_OPT_BACKING_FILE ); +if (backing_file) { +if (!strcmp (filename, backing_file)) {error_setg (errp,"Error: Trying to create an image with the " "same filename as the backing file" ); goto out; } } - backing_fmt =get_option_parameter (param,BLOCK_OPT_BACKING_FMT ); -if (backing_fmt && backing_fmt->value.s) { - backing_drv =bdrv_find_format (backing_fmt->value.s); + backing_fmt =qemu_opt_get (opts,BLOCK_OPT_BACKING_FMT ); +if (backing_fmt) { + backing_drv =bdrv_find_format (backing_fmt);if (!backing_drv) {error_setg (errp,"Unknown backing file format '%s'" , - backing_fmt->value.s); + backing_fmt); goto out; } }// The size for the image must always be specified, with one exception: // If we are using a backing file, we can obtain the size from there - size =get_option_parameter (param,BLOCK_OPT_SIZE ); -if (size && size->value.n ==-1 ) { -if (backing_file && backing_file->value.s) { + size =qemu_opt_get_size (opts,BLOCK_OPT_SIZE ,0 ); +if (size ==-1 ) { +if (backing_file) {BlockDriverState *bs;uint64_t size;char buf[32 ];
@@ -5287,11 +5308,11 @@ void bdrv_img_create(const char *filename, const char *fmt, bs =bdrv_new ("" ); - ret =bdrv_open (bs, backing_file->value.s,NULL , back_flags, + ret =bdrv_open (bs, backing_file,NULL , back_flags, backing_drv, &local_err);if (ret <0 ) {error_setg_errno (errp, -ret,"Could not open '%s': %s" , - backing_file->value.s, + backing_file,error_get_pretty (local_err));error_free (local_err); local_err =NULL ;
@@ -5302,7 +5323,7 @@ void bdrv_img_create(const char *filename, const char *fmt, size *=512 ;snprintf (buf,sizeof (buf),"%" PRId64, size); -set_option_parameter (param,BLOCK_OPT_SIZE , buf); +qemu_opt_set_number (opts,BLOCK_OPT_SIZE , size);bdrv_unref (bs); }else {
@@ -5313,16 +5334,23 @@ void bdrv_img_create(const char *filename, const char *fmt,if (!quiet) {printf ("Formatting '%s', fmt=%s " , filename, fmt); -print_option_parameters (param); +qemu_opts_print (opts);puts ("" ); } - ret =bdrv_create (drv, filename, param, &local_err); + +if (drv->bdrv_create2) { + ret =bdrv_create (drv, filename,NULL , opts, &local_err); + }else { + param =opts_to_params (opts); + ret =bdrv_create (drv, filename, param,NULL , &local_err); + } +if (ret == -EFBIG ) {/* This is generally a better message than whatever the driver would * deliver (especially because of the cluster_size_hint), since that * is most probably not much different from "image too large". */ const char *cluster_size_hint ="" ; -if (get_option_parameter (create_options,BLOCK_OPT_CLUSTER_SIZE )) { +if (qemu_opt_get_size (opts,BLOCK_OPT_CLUSTER_SIZE ,0 )) { cluster_size_hint =" (try using a larger cluster size)" ; } error_setg(errp, "The image size is too large for file format '%s'"
@@ -5335,6 +5363,8 @@ out:free_option_parameters (create_options);free_option_parameters (param); +qemu_opts_del (opts); +qemu_opts_free (create_opts);if (error_is_set (&local_err)) {error_propagate (errp, local_err); }
block/cow.c +1 -1
@@ -344,7 +344,7 @@ static int cow_create(const char *filename, QEMUOptionParameter *options, options++; } - ret =bdrv_create_file (filename, options, &local_err); + ret =bdrv_create_file (filename, options,NULL , &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
block/qcow.c +1 -1
@@ -684,7 +684,7 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options, options++; } - ret =bdrv_create_file (filename, options, &local_err); + ret =bdrv_create_file (filename, options,NULL , &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
block/qcow2.c +1 -1
@@ -1485,7 +1485,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,Error *local_err =NULL ;int ret; - ret =bdrv_create_file (filename, options, &local_err); + ret =bdrv_create_file (filename, options,NULL , &local_err);if (ret <0 ) {error_propagate (errp, local_err);return ret;
block/qed.c +1 -1
@@ -564,7 +564,7 @@ static int qed_create(const char *filename, uint32_t cluster_size,int ret =0 ;BlockDriverState *bs =NULL ; - ret =bdrv_create_file (filename,NULL , &local_err); + ret =bdrv_create_file (filename,NULL ,NULL , &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
block/raw_bsd.c +1 -1
@@ -139,7 +139,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options,Error *local_err =NULL ;int ret; - ret =bdrv_create_file (filename, options, &local_err); + ret =bdrv_create_file (filename, options,NULL , &local_err);if (error_is_set (&local_err)) {error_propagate (errp, local_err); }
block/vhdx.c +1 -1
@@ -1791,7 +1791,7 @@ static int vhdx_create(const char *filename, QEMUOptionParameter *options, block_size = block_size >VHDX_BLOCK_SIZE_MAX ?VHDX_BLOCK_SIZE_MAX : block_size; - ret =bdrv_create_file (filename, options, &local_err); + ret =bdrv_create_file (filename, options,NULL , &local_err);if (ret <0 ) {error_propagate (errp, local_err); goto exit;
block/vmdk.c +2 -2
@@ -1487,7 +1487,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 , &local_err); + ret =bdrv_create_file (filename,NULL ,NULL , &local_err);if (ret <0 ) {error_propagate (errp, local_err); goto exit;
@@ -1825,7 +1825,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,if (!split && !flat) { desc_offset =0x200 ; }else { - ret =bdrv_create_file (filename, options, &local_err); + ret =bdrv_create_file (filename, options,NULL , &local_err);if (ret <0 ) {error_setg_errno (errp, -ret,"Could not create image file" ); goto exit;
block/vvfat.c +1 -1
@@ -2929,7 +2929,7 @@ static int enable_write_target(BDRVVVFATState *s)set_option_parameter_int (options,BLOCK_OPT_SIZE , s->sector_count *512 );set_option_parameter (options,BLOCK_OPT_BACKING_FILE ,"fat:" ); - ret =bdrv_create (bdrv_qcow, s->qcow_filename, options, &local_err); + ret =bdrv_create (bdrv_qcow, s->qcow_filename, options,NULL , &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
include/block/block.h +2 -2
@@ -174,9 +174,9 @@ 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,Error **errp); +QEMUOptionParameter *options,QemuOpts *opts,Error **errp);int bdrv_create_file (const char * filename,QEMUOptionParameter *options, -Error **errp); +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);
include/block/block_int.h +3 -1
@@ -118,6 +118,8 @@ struct BlockDriver {void (*bdrv_rebind)(BlockDriverState *bs);int (*bdrv_create)(const char *filename,QEMUOptionParameter *options,Error **errp); +int (*bdrv_create2)(const char *filename,QemuOpts *opts, +Error **errp);int (*bdrv_set_key)(BlockDriverState *bs,const char *key);int (*bdrv_make_empty)(BlockDriverState *bs);/* aio */
@@ -217,7 +219,7 @@ struct BlockDriver {/* List of options for creating images, terminated by name == NULL */ QEMUOptionParameter *create_options; - +QemuOptsList *create_opts;/* * Returns 0 for completed check, -errno for internal errors.
include/qemu/option.h +2 -0
@@ -168,4 +168,6 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,QemuOptsList *qemu_opts_append (QemuOptsList *dst,QemuOptsList *list);void qemu_opts_free (QemuOptsList *list);void qemu_opts_print_help (QemuOptsList *list); +QEMUOptionParameter *opts_to_params (QemuOpts *opts); +QemuOptsList *params_to_opts (QEMUOptionParameter *list);#endif
qemu-img.c +53 -34
165 lines not on this page · raw message
util/qemu-option.c +111 -0
114 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 06/26] change block layer to support both QemuOpts and QEMUOptionParameter
Quoted 25 lines · Chunyan Liu
Change block layer to support both QemuOpts and QEMUOptionParameter. After this patch, it will change backend drivers one by one. At the end, QEMUOptionParameter will be removed and only QemuOpts is kept.
Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block.c | 110 ++++++++++++++++++++++++++++---------------- block/cow.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/raw_bsd.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 4 +- block/vvfat.c | 2 +- include/block/block.h | 4 +- include/block/block_int.h | 4 +- include/qemu/option.h | 2 + qemu-img.c | 87 +++++++++++++++++++++-------------- util/qemu-option.c | 111 +++++++++++++++++++++++++++++++++++++++++++++ 14 files changed, 250 insertions(+), 86 deletions(-)+++
b/include/block/block_int.h
include/block/block_int.h struct BlockDriver { · line 122
Quoted 5 lines
include/block/block_int.h +2
-0@@ -118,6 +118,8 @@ struct BlockDriver {void (*bdrv_rebind)(BlockDriverState *bs);int (*bdrv_create)(const char *filename,QEMUOptionParameter *options,Error **errp); +int (*bdrv_create2)(const char *filename,QemuOpts *opts, +Error **errp);
Maybe a FIXME comment that shows we plan on removing the duplicate and renaming back to a single sane name in a few more commits.
include/qemu/option.h int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, · line 172
Quoted 7 lines
include/qemu/option.h +3
-0+++ b/include/qemu/option.h@@ -168,4 +168,6 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,QemuOptsList *qemu_opts_append (QemuOptsList *dst,QemuOptsList *list);void qemu_opts_free (QemuOptsList *list);void qemu_opts_print_help (QemuOptsList *list); +QEMUOptionParameter *opts_to_params (QemuOpts *opts); +QemuOptsList *params_to_opts (QEMUOptionParameter *list);
I'd split this commit into two - one that adds these two conversion functions, then the other that adds the create2 callback.
Quoted 9 lines
util/qemu-option.c +5
-0+++ b/util/qemu-option.c@@ -1396,3 +1396,114 @@ void qemu_opts_print_help(QemuOptsList *list) list->desc[i].help : ""); } } + +/* convert QEMUOptionParameter to QemuOpts */ +QemuOptsList *params_to_opts (QEMUOptionParameter *list) +{
util/qemu-option.c void qemu_opts_print_help(QemuOptsList *list) · line 1412
Quoted 10 lines
util/qemu-option.c +10
-0+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));
Indentation looks off.
Quoted 8 lines
util/qemu-option.c +8
-0+QTAILQ_INIT (&opts->head); + opts->desc[i].name =NULL ; + +while (list && list->name) { + opts->desc[i].name =strdup (list->name); + opts->desc[i].help =strdup (list->help); +switch (list->type) { +case OPT_FLAG :
util/qemu-option.c void qemu_opts_print_help(QemuOptsList *list) · line 1430
Quoted 10 lines
util/qemu-option.c +10
-0+ opts->desc[i].type =QEMU_OPT_BOOL ; + opts->desc[i].def_value_str = list->value.n ?"on" :"off" ; +break ; + +case OPT_NUMBER : + opts->desc[i].type =QEMU_OPT_NUMBER ; +if (list->value.n) { +char tmp[100 ]; +sprintf (tmp,"%" PRIu64, list->value.n); + opts->desc[i].def_value_str =strdup (tmp);
Eww. Just use g_strdup_printf and avoid tmp[] altogether.
util/qemu-option.c void qemu_opts_print_help(QemuOptsList *list) · line 1439
Quoted 9 lines
util/qemu-option.c +9
-0+ } +break ; + +case OPT_SIZE : + opts->desc[i].type =QEMU_OPT_SIZE ; +if (list->value.n) { +char tmp[100 ]; +sprintf (tmp,"%" PRIu64, list->value.n); + opts->desc[i].def_value_str =strdup (tmp);
and again
util/qemu-option.c void qemu_opts_print_help(QemuOptsList *list) · line 1446
Quoted 7 lines
util/qemu-option.c +7
-0+ } +break ; + +case OPT_STRING : + opts->desc[i].type =QEMU_OPT_STRING ; +if (list->value.s) { + opts->desc[i].def_value_str =strdup (list->value.s);
This is a lot of use of strdup() without checking for malloc failure; wouldn't it be better to use g_strdup (which can't fail, and which gracefully handles NULL so you can also drop the 'if') and fixing the counterpart free to use g_free?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v20 06/26] change block layer to support both QemuOpts and QEMUOptionParameter
2014-02-13 8:12 GMT+08:00 Eric Blake <[email protected]>:
Quoted 126 lines · Chunyan Liu
Quoted 8 lines
Change block layer to support both QemuOpts and QEMUOptionParameter. After this patch, it will change backend drivers one by one. At the end, QEMUOptionParameter will be removed and only QemuOpts is kept.
Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block.c | 110++++++++++++++++++++++++++++----------------
Quoted 5 lines
block/cow.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/raw_bsd.c | 2 +-Quoted 8 lines
block/vhdx.c | 2 +- block/vmdk.c | 4 +- block/vvfat.c | 2 +- include/block/block.h | 4 +- include/block/block_int.h | 4 +- include/qemu/option.h | 2 + qemu-img.c | 87 +++++++++++++++++++++-------------- util/qemu-option.c | 111+++++++++++++++++++++++++++++++++++++++++++++
Review struct BlockDriver { · line 119
Quoted 6 lines
14 files changed, 250 insertions(+), 86 deletions(-)+++
b/include/block/block_int.h(quoted diff) +0
-0@@ -118,6 +118,8 @@ struct BlockDriver { void (*bdrv_rebind)(BlockDriverState *bs); int (*bdrv_create)(const char *filename, QEMUOptionParameter*options,
include/block/block_int.h struct BlockDriver { · line 122
Quoted 3 lines
include/block/block_int.h +2
-0Error **errp); +int (*bdrv_create2)(const char *filename,QemuOpts *opts, +Error **errp);Maybe a FIXME comment that shows we plan on removing the duplicate and renaming back to a single sane name in a few more commits.
Review int qemu_opts_foreach(QemuOptsList *list,
Quoted 2 lines
(quoted diff) +1
-0+++ b/include/qemu/option.h@@ -168,4 +168,6 @@ int qemu_opts_foreach(QemuOptsList *list,
qemu_opts_loopfuncfunc, void *opaque,include/qemu/option.h int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, · line 172
Quoted 5 lines
include/qemu/option.h +2
-0QemuOptsList *qemu_opts_append (QemuOptsList *dst,QemuOptsList *list);void qemu_opts_free (QemuOptsList *list);void qemu_opts_print_help (QemuOptsList *list); +QEMUOptionParameter *opts_to_params (QemuOpts *opts); +QemuOptsList *params_to_opts (QEMUOptionParameter *list);I'd split this commit into two - one that adds these two conversion functions, then the other that adds the create2 callback.
Quoted 9 lines
util/qemu-option.c +5
-0+++ b/util/qemu-option.c@@ -1396,3 +1396,114 @@ void qemu_opts_print_help(QemuOptsList *list) list->desc[i].help : ""); } } + +/* convert QEMUOptionParameter to QemuOpts */ +QemuOptsList *params_to_opts (QEMUOptionParameter *list) +{util/qemu-option.c void qemu_opts_print_help(QemuOptsList *list) · line 1412
Quoted 10 lines
util/qemu-option.c +10
-0+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));Indentation looks off.
Quoted 8 lines
util/qemu-option.c +8
-0+QTAILQ_INIT (&opts->head); + opts->desc[i].name =NULL ; + +while (list && list->name) { + opts->desc[i].name =strdup (list->name); + opts->desc[i].help =strdup (list->help); +switch (list->type) { +case OPT_FLAG :util/qemu-option.c void qemu_opts_print_help(QemuOptsList *list) · line 1430
Quoted 10 lines
util/qemu-option.c +10
-0+ opts->desc[i].type =QEMU_OPT_BOOL ; + opts->desc[i].def_value_str = list->value.n ?"on" :"off" ; +break ; + +case OPT_NUMBER : + opts->desc[i].type =QEMU_OPT_NUMBER ; +if (list->value.n) { +char tmp[100 ]; +sprintf (tmp,"%" PRIu64, list->value.n); + opts->desc[i].def_value_str =strdup (tmp);Eww. Just use
g_strdup_printfand avoid tmp[] altogether.util/qemu-option.c void qemu_opts_print_help(QemuOptsList *list) · line 1439
Quoted 9 lines
util/qemu-option.c +9
-0+ } +break ; + +case OPT_SIZE : + opts->desc[i].type =QEMU_OPT_SIZE ; +if (list->value.n) { +char tmp[100 ]; +sprintf (tmp,"%" PRIu64, list->value.n); + opts->desc[i].def_value_str =strdup (tmp);and again
util/qemu-option.c void qemu_opts_print_help(QemuOptsList *list) · line 1446
Quoted 7 lines
util/qemu-option.c +7
-0+ } +break ; + +case OPT_STRING : + opts->desc[i].type =QEMU_OPT_STRING ; +if (list->value.s) { + opts->desc[i].def_value_str =strdup (list->value.s);This is a lot of use of
strdup()without checking for malloc failure; wouldn't it be better to useg_strdup(which can't fail, and which gracefully handles NULL so you can also drop the 'if') and fixing the counterpart free to useg_free?Will correct. Thanks.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v20 7/26 cow.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liucow.c: replace QEMUOptionParameter with QemuOpts
--- block/cow.c | 46 ++++++++++++++++++++++------------------------ 1 files changed, 22 insertions(+), 24 deletions(-)
block/cow.c +22 -24
@@ -323,7 +323,7 @@ static void cow_close(BlockDriverState *bs) { } -static int cow_create (const char *filename,QEMUOptionParameter *options, +static int cow_create (const char *filename,QemuOpts *opts,Error **errp) {struct cow_header_v2 cow_header;
@@ -335,16 +335,10 @@ static int cow_create(const char *filename, QEMUOptionParameter *options,BlockDriverState *cow_bs;/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - image_sectors = options->value.n /512 ; - }else if (!strcmp (options->name,BLOCK_OPT_BACKING_FILE )) { - image_filename = options->value.s; - } - options++; - } + 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, options,NULL , &local_err); + ret =bdrv_create_file (filename,NULL , opts, &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
@@ -393,18 +387,22 @@ exit:return ret; } -static QEMUOptionParameter cow_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - { - .name =BLOCK_OPT_BACKING_FILE , - .type =OPT_STRING , - .help ="File name of a base image" - }, - {NULL } +static QemuOptsList cow_create_opts = { + .name ="cow-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (cow_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + { + .name =BLOCK_OPT_BACKING_FILE , + .type =QEMU_OPT_STRING , + .help ="File name of a base image" + }, + {/* end of list */ } + } };static BlockDriver bdrv_cow = {
@@ -414,14 +412,14 @@ static BlockDriver bdrv_cow = { .bdrv_probe = cow_probe, .bdrv_open = cow_open, .bdrv_close = cow_close, - .bdrv_create = cow_create, + .bdrv_create2 = cow_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_read = cow_co_read, .bdrv_write = cow_co_write, .bdrv_co_get_block_status = cow_co_get_block_status, - .create_options = cow_create_options, + .create_opts = &cow_create_opts, };static void bdrv_cow_init (void )
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 07/26] cow.c: replace QEMUOptionParameter with QemuOpts
Quoted 9 lines · Chunyan Liu
cow.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/cow.c | 46 ++++++++++++++++++++++------------------------ 1 files changed, 22 insertions(+), 24 deletions(-)
block/cow.c exit: · line 397
Quoted 8 lines
block/cow.c +8
-0+static QemuOptsList cow_create_opts = { + .name ="cow-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (cow_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size"
Oh, these QemuOpts really ARE constant strings in the general case, and passing these strings to free() could be a disaster. I hope we're okay in what we do; in fact, maybe it's worth a patch to QemuOptsList that adds a bool record of whether the list is dynamically allocated (false by default for all static initialization, and true when malloc'ing a list) and then asserting that attempts to free (parts of) a list are only done on a dynamically allocated list.
block/cow.c static BlockDriver bdrv_cow = { · line 415
Quoted 6 lines
block/cow.c +1
-1@@ -414,14 +412,14 @@ static BlockDriver bdrv_cow = { .bdrv_probe = cow_probe, .bdrv_open = cow_open, .bdrv_close = cow_close, - .bdrv_create = cow_create, + .bdrv_create2 = cow_create,
Might as well keep alignment looking nice.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v20 07/26] cow.c: replace QEMUOptionParameter with QemuOpts
2014-02-13 8:19 GMT+08:00 Eric Blake <[email protected]>:
Quoted 27 lines · Chunyan Liu
Quoted 9 lines
cow.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/cow.c | 46 ++++++++++++++++++++++------------------------ 1 files changed, 22 insertions(+), 24 deletions(-)block/cow.c exit: · line 397
Quoted 8 lines
block/cow.c +8
-0+static QemuOptsList cow_create_opts = { + .name ="cow-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (cow_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" Oh, these QemuOpts really ARE constant strings in the general case, and passing these strings to
free()could be a disaster. I hope we're okay in what we do; in fact, maybe it's worth a patch to QemuOptsList that adds a bool record of whether the list is dynamically allocated (false by default for all static initialization, and true when malloc'ing a list) and then asserting that attempts to free (parts of) a list are only done on a dynamically allocated list.
Quoted 1 line
Well,
create_optsspecified here won't be freed byfree()in existing code
I thi
nk. Those using it would malloc and memcpy from it, and that would be freed. The
same way as existing create_options handling.
Quoted 14 lines
block/cow.c static BlockDriver bdrv_cow = { · line 415
Quoted 6 lines
block/cow.c +1
-1@@ -414,14 +412,14 @@ static BlockDriver bdrv_cow = { .bdrv_probe = cow_probe, .bdrv_open = cow_open, .bdrv_close = cow_close, - .bdrv_create = cow_create, + .bdrv_create2 = cow_create,Might as well keep alignment looking nice.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v20 8/26 gluster.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liugluster.c: replace QEMUOptionParameter with QemuOpts
--- block/gluster.c | 80 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 41 insertions(+), 39 deletions(-)
block/gluster.c +41 -39
@@ -380,13 +380,14 @@ static inline int qemu_gluster_zerofill(struct glfs_fd *fd, int64_t offset,#endif static int qemu_gluster_create (const char *filename, -QEMUOptionParameter *options,Error **errp) +QemuOpts *opts,Error **errp) {struct glfs *glfs;struct glfs_fd *fd;int ret =0 ;int prealloc =0 ;int64_t total_size =0 ; +const char *tmp;GlusterConf *gconf =g_malloc0 (sizeof (GlusterConf)); glfs =qemu_gluster_init (gconf, filename);
@@ -395,24 +396,21 @@ static int qemu_gluster_create(const char *filename, goto out; } -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - total_size = options->value.n /BDRV_SECTOR_SIZE ; - }else if (!strcmp (options->name,BLOCK_OPT_PREALLOC )) { -if (!options->value.s || !strcmp (options->value.s,"off" )) { - prealloc =0 ; - }else if (!strcmp (options->value.s,"full" ) && -gluster_supports_zerofill ()) { - prealloc =1 ; - }else { -error_setg (errp,"Invalid preallocation mode: '%s'" -" or GlusterFS doesn't support zerofill API" , - options->value.s); - ret = -EINVAL ; - goto out; - } - } - options++; + total_size = +qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /BDRV_SECTOR_SIZE ; + + tmp =qemu_opt_get (opts,BLOCK_OPT_PREALLOC ); +if (!tmp || !strcmp (tmp,"off" )) { + prealloc =0 ; + }else if (!strcmp (tmp,"full" ) && +gluster_supports_zerofill ()) { + prealloc =1 ; + }else { +error_setg (errp,"Invalid preallocation mode: '%s'" +" or GlusterFS doesn't support zerofill API" , + tmp); + ret = -EINVAL ; + goto out; } fd = glfs_creat(glfs, gconf->image,
@@ -597,18 +595,22 @@ static int qemu_gluster_has_zero_init(BlockDriverState *bs)return 0 ; } -static QEMUOptionParameter qemu_gluster_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - { - .name =BLOCK_OPT_PREALLOC , - .type =OPT_STRING , - .help ="Preallocation mode (allowed values: off, full)" - }, - {NULL } +static QemuOptsList qemu_gluster_create_opts = { + .name ="qemu-gluster-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (qemu_gluster_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + { + .name =BLOCK_OPT_PREALLOC , + .type =OPT_STRING , + .help ="Preallocation mode (allowed values: off, full)" + }, + {/* end of list */ } + } };static BlockDriver bdrv_gluster = {
@@ -618,7 +620,7 @@ static BlockDriver bdrv_gluster = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .bdrv_close = qemu_gluster_close, - .bdrv_create = qemu_gluster_create, + .bdrv_create2 = qemu_gluster_create, .bdrv_getlength = qemu_gluster_getlength, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, .bdrv_truncate = qemu_gluster_truncate,
@@ -632,7 +634,7 @@ static BlockDriver bdrv_gluster = { #ifdef CONFIG_GLUSTERFS_ZEROFILL .bdrv_co_write_zeroes = qemu_gluster_co_write_zeroes, #endif - .create_options = qemu_gluster_create_options, + .create_opts = qemu_gluster_create_opts, }; static BlockDriver bdrv_gluster_tcp = {
@@ -642,7 +644,7 @@ static BlockDriver bdrv_gluster_tcp = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .bdrv_close = qemu_gluster_close, - .bdrv_create = qemu_gluster_create, + .bdrv_create2 = qemu_gluster_create, .bdrv_getlength = qemu_gluster_getlength, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, .bdrv_truncate = qemu_gluster_truncate,
@@ -656,7 +658,7 @@ static BlockDriver bdrv_gluster_tcp = { #ifdef CONFIG_GLUSTERFS_ZEROFILL .bdrv_co_write_zeroes = qemu_gluster_co_write_zeroes, #endif - .create_options = qemu_gluster_create_options, + .create_opts = &qemu_gluster_create_opts, }; static BlockDriver bdrv_gluster_unix = {
@@ -666,7 +668,7 @@ static BlockDriver bdrv_gluster_unix = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .bdrv_close = qemu_gluster_close, - .bdrv_create = qemu_gluster_create, + .bdrv_create2 = qemu_gluster_create, .bdrv_getlength = qemu_gluster_getlength, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, .bdrv_truncate = qemu_gluster_truncate,
@@ -680,7 +682,7 @@ static BlockDriver bdrv_gluster_unix = { #ifdef CONFIG_GLUSTERFS_ZEROFILL .bdrv_co_write_zeroes = qemu_gluster_co_write_zeroes, #endif - .create_options = qemu_gluster_create_options, + .create_opts = &qemu_gluster_create_opts, }; static BlockDriver bdrv_gluster_rdma = {
@@ -690,7 +692,7 @@ static BlockDriver bdrv_gluster_rdma = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .bdrv_close = qemu_gluster_close, - .bdrv_create = qemu_gluster_create, + .bdrv_create2 = qemu_gluster_create, .bdrv_getlength = qemu_gluster_getlength, .bdrv_get_allocated_file_size = qemu_gluster_allocated_file_size, .bdrv_truncate = qemu_gluster_truncate,
@@ -704,7 +706,7 @@ static BlockDriver bdrv_gluster_rdma = {#ifdef CONFIG_GLUSTERFS_ZEROFILL .bdrv_co_write_zeroes = qemu_gluster_co_write_zeroes, #endif - .create_options = qemu_gluster_create_options, + .create_opts = &qemu_gluster_create_opts, };static void bdrv_gluster_init (void )
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 08/26] gluster.c: replace QEMUOptionParameter with QemuOpts
block/gluster.c static int qemu_gluster_create(const char *filename, · line 406
Quoted 11 lines · Chunyan Liu
gluster.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/gluster.c | 80 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 41 insertions(+), 39 deletions(-)block/gluster.c +2
-0+ }else if (!strcmp (tmp,"full" ) && +gluster_supports_zerofill ()) {
Indentation looks off.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 9/26 iscsi.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuiscsi.c: replace QEMUOptionParamter with QemuOpts
--- block/iscsi.c | 31 +++++++++++++++---------------- 1 files changed, 15 insertions(+), 16 deletions(-)
block/iscsi.c +15 -16
@@ -1377,13 +1377,8 @@ static int iscsi_create(const char *filename, QEMUOptionParameter *options, bs =bdrv_new ("" );/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,"size" )) { - total_size = options->value.n /BDRV_SECTOR_SIZE ; - } - options++; - } - + total_size = +qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /BDRV_SECTOR_SIZE ; bs->opaque =g_malloc0 (sizeof (struct IscsiLun )); iscsilun = bs->opaque;
@@ -1434,13 +1429,17 @@ static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)return 0 ; } -static QEMUOptionParameter iscsi_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - {NULL } +static QemuOptsList iscsi_create_opts = { + .name ="iscsi-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (iscsi_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + {/* end of list */ } + } };static BlockDriver bdrv_iscsi = {
@@ -1451,8 +1450,8 @@ static BlockDriver bdrv_iscsi = { .bdrv_needs_filename = true, .bdrv_file_open = iscsi_open, .bdrv_close = iscsi_close, - .bdrv_create = iscsi_create, - .create_options = iscsi_create_options, + .bdrv_create2 = iscsi_create, + .create_opts = iscsi_create_opts, .bdrv_reopen_prepare = iscsi_reopen_prepare, .bdrv_getlength = iscsi_getlength,
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 09/26] iscsi.c: replace QEMUOptionParameter with QemuOpts
Quoted 8 lines · Chunyan Liu
iscsi.c: replace QEMUOptionParamter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/iscsi.c | 31 +++++++++++++++---------------- 1 files changed, 15 insertions(+), 16 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 10/26 qcow.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuqcow.c: replace QEMUOptionParamter with QemuOpts
--- block/qcow.c | 61 ++++++++++++++++++++++++++++----------------------------- 1 files changed, 30 insertions(+), 31 deletions(-)
block/qcow.c +30 -31
@@ -659,7 +659,7 @@ static void qcow_close(BlockDriverState *bs)error_free (s->migration_blocker); } -static int qcow_create (const char *filename,QEMUOptionParameter *options, +static int qcow_create (const char *filename,QemuOpts *opts,Error **errp) {int header_size, backing_filename_len, l1_size, shift, i;
@@ -673,18 +673,13 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options,BlockDriverState *qcow_bs;/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - total_size = options->value.n /512 ; - }else if (!strcmp (options->name,BLOCK_OPT_BACKING_FILE )) { - backing_file = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_ENCRYPT )) { - flags |= options->value.n ?BLOCK_FLAG_ENCRYPT :0 ; - } - options++; + total_size =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /512 ; + backing_file =qemu_opt_get_del (opts,BLOCK_OPT_BACKING_FILE ); +if (qemu_opt_get_bool_del (opts,BLOCK_OPT_ENCRYPT , false)) { + flags |=BLOCK_FLAG_ENCRYPT ; } - ret =bdrv_create_file (filename, options,NULL , &local_err); + ret =bdrv_create_file (filename,NULL , opts, &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
@@ -879,24 +874,28 @@ static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)return 0 ; } - -static QEMUOptionParameter qcow_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - { - .name =BLOCK_OPT_BACKING_FILE , - .type =OPT_STRING , - .help ="File name of a base image" - }, - { - .name =BLOCK_OPT_ENCRYPT , - .type =OPT_FLAG , - .help ="Encrypt the image" - }, - {NULL } +static QemuOptsList qcow_create_opts = { + .name ="qcow-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (qcow_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + { + .name =BLOCK_OPT_BACKING_FILE , + .type =QEMU_OPT_STRING , + .help ="File name of a base image" + }, + { + .name =BLOCK_OPT_ENCRYPT , + .type =QEMU_OPT_BOOL , + .help ="Encrypt the image" , + .def_value_str ="off" + }, + {/* end of list */ } + } };static BlockDriver bdrv_qcow = {
@@ -906,7 +905,7 @@ static BlockDriver bdrv_qcow = { .bdrv_open = qcow_open, .bdrv_close = qcow_close, .bdrv_reopen_prepare = qcow_reopen_prepare, - .bdrv_create = qcow_create, + .bdrv_create2 = qcow_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_co_readv = qcow_co_readv,
@@ -918,7 +917,7 @@ static BlockDriver bdrv_qcow = { .bdrv_write_compressed = qcow_write_compressed, .bdrv_get_info = qcow_get_info, - .create_options = qcow_create_options, + .create_opts = &qcow_create_opts, };static void bdrv_qcow_init (void )
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 10/26] qcow.c: replace QEMUOptionParameter with QemuOpts
Quoted 10 lines · Chunyan Liu
qcow.c: replace QEMUOptionParamter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/qcow.c | 61 ++++++++++++++++++++++++++++----------------------------- 1 files changed, 30 insertions(+), 31 deletions(-)+static QemuOptsList
qcow_create_opts= {
Probably could add 'const' here and in other patches.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 11/26 qcow2.c: replace QEMUOptionParameter with QemuOpts in create
In reply to Chunyan Liuqcow2.c: replace QEMUOptionParameter with QemuOpts in 'qemu-img create'.
--- block/qcow2.c | 176 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 88 insertions(+), 88 deletions(-)
block/qcow2.c +88 -88
@@ -1453,7 +1453,7 @@ static int preallocate(BlockDriverState *bs)static int qcow2_create2 (const char *filename,int64_t total_size,const char *backing_file,const char *backing_format,int flags,size_t cluster_size,int prealloc, -QEMUOptionParameter *options,int version, +QemuOpts *opts,int version,Error **errp) {/* Calculate cluster_bits */
@@ -1485,7 +1485,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,Error *local_err =NULL ;int ret; - ret =bdrv_create_file (filename, options,NULL , &local_err); + ret =bdrv_create_file (filename,NULL , opts, &local_err);if (ret <0 ) {error_propagate (errp, local_err);return ret;
@@ -1614,11 +1614,12 @@ out:return ret; } -static int qcow2_create (const char *filename,QEMUOptionParameter *options, +static int qcow2_create (const char *filename,QemuOpts *opts,Error **errp) {const char *backing_file =NULL ;const char *backing_fmt =NULL ; +const char *buf;uint64_t sectors =0 ;int flags =0 ;size_t cluster_size =DEFAULT_CLUSTER_SIZE ;
@@ -1628,45 +1629,38 @@ static int qcow2_create(const char *filename, QEMUOptionParameter *options,int ret;/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - sectors = options->value.n /512 ; - }else if (!strcmp (options->name,BLOCK_OPT_BACKING_FILE )) { - backing_file = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_BACKING_FMT )) { - backing_fmt = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_ENCRYPT )) { - flags |= options->value.n ?BLOCK_FLAG_ENCRYPT :0 ; - }else if (!strcmp (options->name,BLOCK_OPT_CLUSTER_SIZE )) { -if (options->value.n) { - cluster_size = options->value.n; - } - }else if (!strcmp (options->name,BLOCK_OPT_PREALLOC )) { -if (!options->value.s || !strcmp (options->value.s,"off" )) { - prealloc =0 ; - }else if (!strcmp (options->value.s,"metadata" )) { - prealloc =1 ; - }else { -error_setg (errp,"Invalid preallocation mode: '%s'" , - options->value.s); -return -EINVAL ; - } - }else if (!strcmp (options->name,BLOCK_OPT_COMPAT_LEVEL )) { -if (!options->value.s) { -/* keep the default */ - }else if (!strcmp (options->value.s,"0.10" )) { - version =2 ; - }else if (!strcmp (options->value.s,"1.1" )) { - version =3 ; - }else { -error_setg (errp,"Invalid compatibility level: '%s'" , - options->value.s); -return -EINVAL ; - } - }else if (!strcmp (options->name,BLOCK_OPT_LAZY_REFCOUNTS )) { - flags |= options->value.n ?BLOCK_FLAG_LAZY_REFCOUNTS :0 ; - } - options++; + sectors =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /512 ; + backing_file =qemu_opt_get_del (opts,BLOCK_OPT_BACKING_FILE ); + backing_fmt =qemu_opt_get_del (opts,BLOCK_OPT_BACKING_FMT ); +if (qemu_opt_get_bool_del (opts,BLOCK_OPT_ENCRYPT , false)) { + flags |=BLOCK_FLAG_ENCRYPT ; + } + cluster_size =qemu_opt_get_size_del (opts,BLOCK_OPT_CLUSTER_SIZE , +DEFAULT_CLUSTER_SIZE ); + buf =qemu_opt_get_del (opts,BLOCK_OPT_PREALLOC ); +if (!buf || !strcmp (buf,"off" )) { + prealloc =0 ; + }else if (!strcmp (buf,"metadata" )) { + prealloc =1 ; + }else { +fprintf (stderr,"Invalid preallocation mode: '%s'\n" , + buf); +return -EINVAL ; + } + buf =NULL ; + buf =qemu_opt_get_del (opts,BLOCK_OPT_COMPAT_LEVEL ); +if (!buf || !strcmp (buf,"0.10" )) { + version =2 ; + }else if (!strcmp (buf,"1.1" )) { + version =3 ; + }else { +fprintf (stderr,"Invalid compatibility level: '%s'\n" , + buf); +return -EINVAL ; + } + +if (qemu_opt_get_bool_del (opts,BLOCK_OPT_LAZY_REFCOUNTS , false)) { + flags |=BLOCK_FLAG_LAZY_REFCOUNTS ; }if (backing_file && prealloc) {
@@ -1682,7 +1676,7 @@ static int qcow2_create(const char *filename, QEMUOptionParameter *options, } ret =qcow2_create2 (filename, sectors, backing_file, backing_fmt, flags, - cluster_size, prealloc, options, version, &local_err); + cluster_size, prealloc, opts, version, &local_err);if (error_is_set (&local_err)) {error_propagate (errp, local_err); }
@@ -2176,49 +2170,55 @@ static int qcow2_amend_options(BlockDriverState *bs,return 0 ; } -static QEMUOptionParameter qcow2_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - { - .name =BLOCK_OPT_COMPAT_LEVEL , - .type =OPT_STRING , - .help ="Compatibility level (0.10 or 1.1)" - }, - { - .name =BLOCK_OPT_BACKING_FILE , - .type =OPT_STRING , - .help ="File name of a base image" - }, - { - .name =BLOCK_OPT_BACKING_FMT , - .type =OPT_STRING , - .help ="Image format of the base image" - }, - { - .name =BLOCK_OPT_ENCRYPT , - .type =OPT_FLAG , - .help ="Encrypt the image" - }, - { - .name =BLOCK_OPT_CLUSTER_SIZE , - .type =OPT_SIZE , - .help ="qcow2 cluster size" , - .value = { .n =DEFAULT_CLUSTER_SIZE }, - }, - { - .name =BLOCK_OPT_PREALLOC , - .type =OPT_STRING , - .help ="Preallocation mode (allowed values: off, metadata)" - }, - { - .name =BLOCK_OPT_LAZY_REFCOUNTS , - .type =OPT_FLAG , - .help ="Postpone refcount updates" , - }, - {NULL } +static QemuOptsList qcow2_create_opts = { + .name ="qcow2-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (qcow2_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + { + .name =BLOCK_OPT_COMPAT_LEVEL , + .type =QEMU_OPT_STRING , + .help ="Compatibility level (0.10 or 1.1)" + }, + { + .name =BLOCK_OPT_BACKING_FILE , + .type =QEMU_OPT_STRING , + .help ="File name of a base image" + }, + { + .name =BLOCK_OPT_BACKING_FMT , + .type =QEMU_OPT_STRING , + .help ="Image format of the base image" + }, + { + .name =BLOCK_OPT_ENCRYPT , + .type =QEMU_OPT_BOOL , + .help ="Encrypt the image" , + .def_value_str ="off" + }, + { + .name =BLOCK_OPT_CLUSTER_SIZE , + .type =QEMU_OPT_SIZE , + .help ="qcow2 cluster size" , + .def_value_str =stringify (DEFAULT_CLUSTER_SIZE ) + }, + { + .name =BLOCK_OPT_PREALLOC , + .type =QEMU_OPT_STRING , + .help ="Preallocation mode (allowed values: off, metadata)" + }, + { + .name =BLOCK_OPT_LAZY_REFCOUNTS , + .type =QEMU_OPT_BOOL , + .help ="Postpone refcount updates" , + .def_value_str ="off" + }, + {/* end of list */ } + } };static BlockDriver bdrv_qcow2 = {
@@ -2228,7 +2228,7 @@ static BlockDriver bdrv_qcow2 = { .bdrv_open = qcow2_open, .bdrv_close = qcow2_close, .bdrv_reopen_prepare = qcow2_reopen_prepare, - .bdrv_create = qcow2_create, + .bdrv_create2 = 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,
@@ -2258,7 +2258,7 @@ static BlockDriver bdrv_qcow2 = { .bdrv_refresh_limits = qcow2_refresh_limits, .bdrv_invalidate_cache = qcow2_invalidate_cache, - .create_options = qcow2_create_options, + .create_opts = &qcow2_create_opts, .bdrv_check = qcow2_check, .bdrv_amend_options = qcow2_amend_options, };
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 11/26] qcow2.c: replace QEMUOptionParameter with QemuOpts in create
block/qcow2.c static int qcow2_create(const char *filename, QEMUOptionParameter *options, · line 1651
Quoted 11 lines · Chunyan Liu
qcow2.c: replace QEMUOptionParameter with QemuOpts in 'qemu-img create'.Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/qcow2.c | 176 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 88 insertions(+), 88 deletions(-)block/qcow2.c +2
-0+ buf =NULL ; + buf =qemu_opt_get_del (opts,BLOCK_OPT_COMPAT_LEVEL );
Dead assignment to NULL.
block/qcow2.c static int qcow2_create(const char *filename, QEMUOptionParameter *options, · line 1658
Quoted 7 lines
block/qcow2.c +7
-0+if (!buf || !strcmp (buf,"0.10" )) { + version =2 ; + }else if (!strcmp (buf,"1.1" )) { + version =3 ; + }else { +fprintf (stderr,"Invalid compatibility level: '%s'\n" , + buf);
Indentation looks off.
block/qcow2.c static int qcow2_create(const char *filename, QEMUOptionParameter *options, · line 1681
Quoted 8 lines
block/qcow2.c +1
-1@@ -1682,7 +1676,7 @@ static int qcow2_create(const char *filename, QEMUOptionParameter *options, } ret =qcow2_create2 (filename, sectors, backing_file, backing_fmt, flags, - cluster_size, prealloc, options, version, &local_err); + cluster_size, prealloc, opts, version, &local_err);if (error_is_set (&local_err)) {error_propagate (errp, local_err);
Might conflict with other cleanups that is turning 'if (error_is_set(&local_err))' into 'if (local_err)'
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 12/26 qcow2.c: replace QEMUOptionParameter with QemuOpts in amend options
In reply to Chunyan Liuqcow2.c: replace QEMUOptionParameter with QemuOpts in 'qemu-img amend'
--- block.c | 4 +- block/qcow2.c | 90 ++++++++++++++++++++------------------------ include/block/block.h | 2 +- include/block/block_int.h | 2 +- qemu-img.c | 17 ++++---- 5 files changed, 53 insertions(+), 62 deletions(-)
block.c +2 -2
@@ -5382,12 +5382,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) +int bdrv_amend_options (BlockDriverState *bs,QemuOpts *opts) {if (bs->drv->bdrv_amend_options ==NULL ) {return -ENOTSUP ; } -return bs->drv->bdrv_amend_options (bs, options); +return bs->drv->bdrv_amend_options (bs, opts); }/* Used to recurse on single child block filters.
block/qcow2.c +41 -49
113 lines not on this page · raw message
include/block/block.h +1 -1
@@ -282,7 +282,7 @@ typedef enum {int bdrv_check (BlockDriverState *bs,BdrvCheckResult *res,BdrvCheckMode fix); -int bdrv_amend_options (BlockDriverState *bs_new,QEMUOptionParameter *options); +int bdrv_amend_options (BlockDriverState *bs_new,QemuOpts *opts);/* external snapshots */
include/block/block_int.h +1 -1
@@ -229,7 +229,7 @@ struct BlockDriver { BdrvCheckMode fix);int (*bdrv_amend_options)(BlockDriverState *bs, -QEMUOptionParameter *options); +QemuOpts *opts);void (*bdrv_debug_event)(BlockDriverState *bs,BlkDebugEvent event);
qemu-img.c +8 -9
@@ -2639,7 +2639,8 @@ static int img_amend(int argc, char **argv) {int c, ret =0 ;char *options =NULL ; -QEMUOptionParameter *create_options =NULL , *options_param =NULL ; +QemuOptsList *create_opts =NULL ; +QemuOpts *opts =NULL ;const char *fmt =NULL , *filename;bool quiet = false;BlockDriverState *bs =NULL ;
@@ -2691,17 +2692,15 @@ static int img_amend(int argc, char **argv) goto out; } - create_options =append_option_parameters (create_options, - bs->drv->create_options); - options_param =parse_option_parameters (options, create_options, - options_param); -if (options_param ==NULL ) { + 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); ret =-1 ; goto out; } - ret =bdrv_amend_options (bs, options_param); + ret =bdrv_amend_options (bs, opts);if (ret <0 ) {error_report ("Error while amending options: %s" ,strerror (-ret)); goto out;
@@ -2711,8 +2710,8 @@ out:if (bs) {bdrv_unref (bs); } -free_option_parameters (create_options); -free_option_parameters (options_param); +qemu_opts_del (opts); +qemu_opts_free (create_opts);if (ret) {return 1 ; }
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 12/26] qcow2.c: replace QEMUOptionParameter with QemuOpts in amend options
Quoted 14 lines · Chunyan Liu
qcow2.c: replace QEMUOptionParameter with QemuOpts in 'qemu-img amend'Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block.c | 4 +- block/qcow2.c | 90 ++++++++++++++++++++------------------------ include/block/block.h | 2 +- include/block/block_int.h | 2 +- qemu-img.c | 17 ++++---- 5 files changed, 53 insertions(+), 62 deletions(-)
block/qcow2.c static BlockDriver bdrv_qcow2 = { · line 2225
Quoted 7 lines
block/qcow2.c +1
-1@@ -2228,7 +2220,7 @@ static BlockDriver bdrv_qcow2 = { .bdrv_open = qcow2_open, .bdrv_close = qcow2_close, .bdrv_reopen_prepare = qcow2_reopen_prepare, - .bdrv_create2 = qcow2_create, + .bdrv_create2 = qcow2_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_co_get_block_status = qcow2_co_get_block_status,
Might be worth aligning the = while touching this.
include/block/block_int.h struct BlockDriver { · line 232
Quoted 7 lines
include/block/block_int.h +2
-1+++ b/include/block/block_int.h@@ -229,7 +229,7 @@ struct BlockDriver { BdrvCheckMode fix);int (*bdrv_amend_options)(BlockDriverState *bs, -QEMUOptionParameter *options); +QemuOpts *opts);
Indentation looks odd here; and with your change to shorter contents, you can just pull it into one line instead of wrapping and worrying about indentation in the first place.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 13/26 qed.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuqed.c: replace QEMUOptionParameter with QemuOpts
--- block/qed.c | 89 +++++++++++++++++++++++++++++------------------------------ block/qed.h | 3 +- 2 files changed, 45 insertions(+), 47 deletions(-)
block/qed.c +44 -45
@@ -619,7 +619,8 @@ out:return ret; } -static int bdrv_qed_create (const char *filename,QEMUOptionParameter *options, + +static int bdrv_qed_create (const char *filename,QemuOpts *opts,Error **errp) {uint64_t image_size =0 ;
@@ -628,24 +629,14 @@ static int bdrv_qed_create(const char *filename, QEMUOptionParameter *options,const char *backing_file =NULL ;const char *backing_fmt =NULL ; -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - image_size = options->value.n; - }else if (!strcmp (options->name,BLOCK_OPT_BACKING_FILE )) { - backing_file = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_BACKING_FMT )) { - backing_fmt = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_CLUSTER_SIZE )) { -if (options->value.n) { - cluster_size = options->value.n; - } - }else if (!strcmp (options->name,BLOCK_OPT_TABLE_SIZE )) { -if (options->value.n) { - table_size = options->value.n; - } - } - options++; - } + image_size =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ); + backing_file =qemu_opt_get_del (opts,BLOCK_OPT_BACKING_FILE ); + backing_fmt =qemu_opt_get_del (opts,BLOCK_OPT_BACKING_FMT ); + cluster_size =qemu_opt_get_size_del (opts, +BLOCK_OPT_CLUSTER_SIZE , +QED_DEFAULT_CLUSTER_SIZE ); + table_size =qemu_opt_get_size_del (opts,BLOCK_OPT_TABLE_SIZE , +QED_DEFAULT_TABLE_SIZE );if (!qed_is_cluster_size_valid (cluster_size)) { fprintf(stderr, "QED cluster size must be within range [%u, %u] and power of 2\n",
@@ -1573,43 +1564,51 @@ static int bdrv_qed_check(BlockDriverState *bs, BdrvCheckResult *result,return qed_check (s, result, !!fix); } -static QEMUOptionParameter qed_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size (in bytes)" - }, { - .name =BLOCK_OPT_BACKING_FILE , - .type =OPT_STRING , - .help ="File name of a base image" - }, { - .name =BLOCK_OPT_BACKING_FMT , - .type =OPT_STRING , - .help ="Image format of the base image" - }, { - .name =BLOCK_OPT_CLUSTER_SIZE , - .type =OPT_SIZE , - .help ="Cluster size (in bytes)" , - .value = { .n =QED_DEFAULT_CLUSTER_SIZE }, - }, { - .name =BLOCK_OPT_TABLE_SIZE , - .type =OPT_SIZE , - .help ="L1/L2 table size (in clusters)" - }, - {/* end of list */ } +static QemuOptsList qed_create_opts = { + .name ="qed-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (qed_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + { + .name =BLOCK_OPT_BACKING_FILE , + .type =QEMU_OPT_STRING , + .help ="File name of a base image" + }, + { + .name =BLOCK_OPT_BACKING_FMT , + .type =QEMU_OPT_STRING , + .help ="Image format of the base image" + }, + { + .name =BLOCK_OPT_CLUSTER_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Cluster size (in bytes)" , + .def_value_str =stringify (QED_DEFAULT_CLUSTER_SIZE ) + }, + { + .name =BLOCK_OPT_TABLE_SIZE , + .type =QEMU_OPT_SIZE , + .help ="L1/L2 table size (in clusters)" + }, + {/* end of list */ } + } };static BlockDriver bdrv_qed = { .format_name ="qed" , .instance_size =sizeof (BDRVQEDState), - .create_options = qed_create_options, + .create_opts = &qed_create_opts, .bdrv_probe = bdrv_qed_probe, .bdrv_rebind = bdrv_qed_rebind, .bdrv_open = bdrv_qed_open, .bdrv_close = bdrv_qed_close, .bdrv_reopen_prepare = bdrv_qed_reopen_prepare, - .bdrv_create = bdrv_qed_create, + .bdrv_create2 = 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,
block/qed.h +1 -2
@@ -43,7 +43,7 @@* * All fields are little-endian on disk. */ - +#define QED_DEFAULT_CLUSTER_SIZE 65536enum {QED_MAGIC ='Q' |'E' <<8 |'D' <<16 |'\0' <<24 ,
@@ -69,7 +69,6 @@ enum {*/ QED_MIN_CLUSTER_SIZE =4 *1024 ,/* in bytes */ QED_MAX_CLUSTER_SIZE = 64 * 1024 * 1024, -QED_DEFAULT_CLUSTER_SIZE =64 *1024 ,/* Allocated clusters are tracked using a 2-level pagetable. Table size is * a multiple of clusters so large maximum image sizes can be supported
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 13/26] qed.c: replace QEMUOptionParameter with QemuOpts
Quoted 18 lines · Chunyan Liu
qed.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/qed.c | 89 +++++++++++++++++++++++++++++------------------------------ block/qed.h | 3 +- 2 files changed, 45 insertions(+), 47 deletions(-)(quoted diff) +6
-0+ cluster_size = qemu_opt_get_size_del(opts, + BLOCK_OPT_CLUSTER_SIZE, + QED_DEFAULT_CLUSTER_SIZE); + table_size = qemu_opt_get_size_del(opts, BLOCK_OPT_TABLE_SIZE, + QED_DEFAULT_TABLE_SIZE); + {
Review
Quoted 10 lines
(quoted diff) +10
-0+ .name = BLOCK_OPT_CLUSTER_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Cluster size (in bytes)", + .def_value_str = stringify(QED_DEFAULT_CLUSTER_SIZE) + }, + { + .name = BLOCK_OPT_TABLE_SIZE, + .type = QEMU_OPT_SIZE, + .help = "L1/L2 table size (in clusters)" + },
Why does cluster size list a default, but table size does not?
Quoted 11 lines
+++
b/block/qed.hblock/qed.h +1
-1@@ -43,7 +43,7 @@* * All fields are little-endian on disk. */ - +#define QED_DEFAULT_CLUSTER_SIZE 65536enum {QED_MAGIC ='Q' |'E' <<8 |'D' <<16 |'\0' <<24 ,
block/qed.h enum { · line 72
Quoted 4 lines
block/qed.h +0
-1@@ -69,7 +69,6 @@ enum {*/ QED_MIN_CLUSTER_SIZE =4 *1024 ,/* in bytes */ QED_MAX_CLUSTER_SIZE = 64 * 1024 * 1024, - QED_DEFAULT_CLUSTER_SIZE = 64 * 1024,
Why this change? I actually prefer enums over #defines, because they behave nicer in gdb.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v20 13/26] qed.c: replace QEMUOptionParameter with QemuOpts
2014-02-18 2:01 GMT+08:00 Eric Blake <[email protected]>:
Quoted 31 lines · Chunyan Liu
Quoted 6 lines
qed.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/qed.c | 89+++++++++++++++++++++++++++++------------------------------
Quoted 12 lines
block/qed.h | 3 +- 2 files changed, 45 insertions(+), 47 deletions(-)(quoted diff) +6
-0+ cluster_size = qemu_opt_get_size_del(opts, + BLOCK_OPT_CLUSTER_SIZE, + QED_DEFAULT_CLUSTER_SIZE); + table_size = qemu_opt_get_size_del(opts, BLOCK_OPT_TABLE_SIZE, + QED_DEFAULT_TABLE_SIZE); + {Review
Quoted 10 lines
(quoted diff) +10
-0+ .name = BLOCK_OPT_CLUSTER_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Cluster size (in bytes)", + .def_value_str = stringify(QED_DEFAULT_CLUSTER_SIZE) + }, + { + .name = BLOCK_OPT_TABLE_SIZE, + .type = QEMU_OPT_SIZE, + .help = "L1/L2 table size (in clusters)" + },
Quoted 2 lines
Why does cluster size list a default, but table size does not?
Changed it from create_options, no default for table size in original create_options.
Quoted 21 lines
Quoted 12 lines
+++
b/block/qed.hblock/qed.h +1
-1@@ -43,7 +43,7 @@* * All fields are little-endian on disk. */ - +#define QED_DEFAULT_CLUSTER_SIZE 65536enum {QED_MAGIC ='Q' |'E' <<8 |'D' <<16 |'\0' <<24 ,block/qed.h enum { · line 72
Quoted 4 lines
block/qed.h +0
-1@@ -69,7 +69,6 @@ enum {*/ QED_MIN_CLUSTER_SIZE =4 *1024 ,/* in bytes */ QED_MAX_CLUSTER_SIZE = 64 * 1024 * 1024, - QED_DEFAULT_CLUSTER_SIZE = 64 * 1024,Why this change? I actually prefer enums over #defines, because they behave nicer in gdb.
Quoted 1 line
For
stringify()correctness.
.def_value_str = stringify(QED_DEFAULT_CLUSTER_SIZE)
Quoted 5 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v20 14/26 raw-posix.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuraw-posix.c: replace QEMUOptionParameter with QemuOpts
--- block/raw-posix.c | 58 ++++++++++++++++++++++++---------------------------- 1 files changed, 27 insertions(+), 31 deletions(-)
block/raw-posix.c +27 -31
@@ -1223,7 +1223,7 @@ static int64_t raw_get_allocated_file_size(BlockDriverState *bs)return (int64_t )st.st_blocks *512 ; } -static int raw_create (const char *filename,QEMUOptionParameter *options, +static int raw_create (const char *filename,QemuOpts *opts,Error **errp) {int fd;
@@ -1231,12 +1231,8 @@ static int raw_create(const char *filename, QEMUOptionParameter *options,int64_t total_size =0 ;/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - total_size = options->value.n /BDRV_SECTOR_SIZE ; - } - options++; - } + total_size = +qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /BDRV_SECTOR_SIZE ; fd =qemu_open (filename,O_WRONLY |O_CREAT |O_TRUNC |O_BINARY ,0644 );
@@ -1397,13 +1393,17 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)return 0 ; } -static QEMUOptionParameter raw_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - {NULL } +static QemuOptsList raw_create_opts = { + .name ="raw-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (raw_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + {/* end of list */ } + } };static BlockDriver bdrv_file = {
@@ -1417,7 +1417,7 @@ static BlockDriver bdrv_file = { .bdrv_reopen_commit = raw_reopen_commit, .bdrv_reopen_abort = raw_reopen_abort, .bdrv_close = raw_close, - .bdrv_create = raw_create, + .bdrv_create2 = 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,
@@ -1434,7 +1434,7 @@ static BlockDriver bdrv_file = { .bdrv_get_allocated_file_size = raw_get_allocated_file_size, - .create_options = raw_create_options, + .create_opts = &raw_create_opts, };/***********************************************/
@@ -1746,7 +1746,7 @@ static coroutine_fn int hdev_co_write_zeroes(BlockDriverState *bs,return -ENOTSUP ; } -static int hdev_create (const char *filename,QEMUOptionParameter *options, +static int hdev_create (const char *filename,QemuOpts *opts,Error **errp) {int fd;
@@ -1755,12 +1755,8 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options,int64_t total_size =0 ;/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,"size" )) { - total_size = options->value.n /BDRV_SECTOR_SIZE ; - } - options++; - } + total_size = +qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /BDRV_SECTOR_SIZE ; fd =qemu_open (filename,O_WRONLY |O_BINARY );if (fd <0 ) {
@@ -1796,8 +1792,8 @@ static BlockDriver bdrv_host_device = { .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit, .bdrv_reopen_abort = raw_reopen_abort, - .bdrv_create = hdev_create, - .create_options = raw_create_options, + .bdrv_create2 = hdev_create, + .create_opts = &raw_create_opts, .bdrv_co_write_zeroes = hdev_co_write_zeroes, .bdrv_aio_readv = raw_aio_readv,
@@ -1930,8 +1926,8 @@ static BlockDriver bdrv_host_floppy = { .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit, .bdrv_reopen_abort = raw_reopen_abort, - .bdrv_create = hdev_create, - .create_options = raw_create_options, + .bdrv_create2 = hdev_create, + .create_opts = &raw_create_opts, .bdrv_aio_readv = raw_aio_readv, .bdrv_aio_writev = raw_aio_writev,
@@ -2041,8 +2037,8 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit, .bdrv_reopen_abort = raw_reopen_abort, - .bdrv_create = hdev_create, - .create_options = raw_create_options, + .bdrv_create2 = hdev_create, + .create_opts = &raw_create_opts, .bdrv_aio_readv = raw_aio_readv, .bdrv_aio_writev = raw_aio_writev,
@@ -2171,8 +2167,8 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit, .bdrv_reopen_abort = raw_reopen_abort, - .bdrv_create = hdev_create, - .create_options = raw_create_options, + .bdrv_create2 = hdev_create, + .create_opts = &raw_create_opts, .bdrv_aio_readv = raw_aio_readv, .bdrv_aio_writev = raw_aio_writev,
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 14/26] raw-posix.c: replace QEMUOptionParameter with QemuOpts
Quoted 10 lines · Chunyan Liu
raw-posix.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/raw-posix.c | 58 ++++++++++++++++++++++++---------------------------- 1 files changed, 27 insertions(+), 31 deletions(-)
block/raw-posix.c static BlockDriver bdrv_host_cdrom = { · line 2171
Quoted 7 lines
block/raw-posix.c +2
-2@@ -2171,8 +2167,8 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_reopen_prepare = raw_reopen_prepare, .bdrv_reopen_commit = raw_reopen_commit, .bdrv_reopen_abort = raw_reopen_abort, - .bdrv_create = hdev_create, - .create_options = raw_create_options, + .bdrv_create2 = hdev_create, + .create_opts = &raw_create_opts,
Everywhere else in the patch maintained or added consistency, but alignment of = here is off.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 15/26 raw-win32.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuraw-win32.c: replace QEMUOptionParameter with QemuOpts
--- block/raw-win32.c | 33 +++++++++++++++++---------------- 1 files changed, 17 insertions(+), 16 deletions(-)
block/raw-win32.c +17 -16
@@ -464,19 +464,15 @@ static int64_t raw_get_allocated_file_size(BlockDriverState *bs)return st.st_size; } -static int raw_create (const char *filename,QEMUOptionParameter *options, +static int raw_create (const char *filename,QemuOpts *opts,Error **errp) {int fd;int64_t total_size =0 ;/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - total_size = options->value.n /512 ; - } - options++; - } + total_size = +qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ) /512 ; fd =qemu_open (filename,O_WRONLY |O_CREAT |O_TRUNC |O_BINARY ,0644 );
@@ -490,13 +486,18 @@ static int raw_create(const char *filename, QEMUOptionParameter *options,return 0 ; } -static QEMUOptionParameter raw_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - {NULL } + +static QemuOptsList raw_create_opts = { + .name ="raw-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (raw_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + {/* end of list */ } + } };static BlockDriver bdrv_file = {
@@ -506,7 +507,7 @@ static BlockDriver bdrv_file = { .bdrv_needs_filename = true, .bdrv_file_open = raw_open, .bdrv_close = raw_close, - .bdrv_create = raw_create, + .bdrv_create2 = raw_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_aio_readv = raw_aio_readv,
@@ -518,7 +519,7 @@ static BlockDriver bdrv_file = { .bdrv_get_allocated_file_size = raw_get_allocated_file_size, - .create_options = raw_create_options, + .create_opts = &raw_create_opts, };/***********************************************/
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 15/26] raw-win32.c: replace QEMUOptionParameter with QemuOpts
Quoted 9 lines · Chunyan Liu
raw-win32.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/raw-win32.c | 33 +++++++++++++++++---------------- 1 files changed, 17 insertions(+), 16 deletions(-)
block/raw-win32.c static BlockDriver bdrv_file = { · line 512
Quoted 7 lines
block/raw-win32.c +1
-1@@ -506,7 +507,7 @@ static BlockDriver bdrv_file = { .bdrv_needs_filename = true, .bdrv_file_open = raw_open, .bdrv_close = raw_close, - .bdrv_create = raw_create, + .bdrv_create2 = raw_create, .bdrv_has_zero_init = bdrv_has_zero_init_1,
Alignment was inconsistent before your patch, but you could take this opportunity to clean it up.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 16/26 raw_bsd.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuraw_bsd.c: replace QEMUOptionParameter with QemuOpts
--- block/raw_bsd.c | 27 ++++++++++++++++----------- 1 files changed, 16 insertions(+), 11 deletions(-)
block/raw_bsd.c +16 -11
@@ -29,13 +29,17 @@#include "block/block_int.h" #include "qemu/option.h" -static QEMUOptionParameter raw_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - {0 } +static QemuOptsList raw_create_opts = { + .name ="raw-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (raw_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + {/* end of list */ } + } }; static int raw_reopen_prepare(BDRVReopenState *reopen_state,
@@ -133,19 +137,20 @@ static int raw_has_zero_init(BlockDriverState *bs)return bdrv_has_zero_init (bs->file); } -static int raw_create (const char *filename,QEMUOptionParameter *options, +static int raw_create (const char *filename,QemuOpts *opts,Error **errp) {Error *local_err =NULL ;int ret; - ret =bdrv_create_file (filename, options,NULL , &local_err); + ret =bdrv_create_file (filename,NULL , opts, &local_err);if (error_is_set (&local_err)) {error_propagate (errp, local_err); }return ret; } +static int raw_open (BlockDriverState *bs,QDict *options,int flags,Error **errp) {
@@ -172,7 +177,7 @@ static BlockDriver bdrv_raw = { .bdrv_reopen_prepare = &raw_reopen_prepare, .bdrv_open = &raw_open, .bdrv_close = &raw_close, - .bdrv_create = &raw_create, + .bdrv_create2 = &raw_create, .bdrv_co_readv = &raw_co_readv, .bdrv_co_writev = &raw_co_writev, .bdrv_co_write_zeroes = &raw_co_write_zeroes,
@@ -188,7 +193,7 @@ static BlockDriver bdrv_raw = { .bdrv_lock_medium = &raw_lock_medium, .bdrv_ioctl = &raw_ioctl, .bdrv_aio_ioctl = &raw_aio_ioctl, - .create_options = &raw_create_options[0], + .create_opts = &raw_create_opts, .bdrv_has_zero_init = &raw_has_zero_init };
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 16/26] raw_bsd.c: replace QEMUOptionParameter with QemuOpts
Quoted 8 lines · Chunyan Liu
raw_bsd.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/raw_bsd.c | 27 ++++++++++++++++----------- 1 files changed, 16 insertions(+), 11 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 17/26 rbd.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liurbd.c: replace QEMUOptionParameter with QemuOpts
--- block/rbd.c | 63 +++++++++++++++++++++++++++++------------------------------ 1 files changed, 31 insertions(+), 32 deletions(-)
block/rbd.c +31 -32
@@ -282,7 +282,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf)return ret; } -static int qemu_rbd_create (const char *filename,QEMUOptionParameter *options, +static int qemu_rbd_create (const char *filename,QemuOpts *opts,Error **errp) {int64_t bytes =0 ;
@@ -306,24 +306,18 @@ static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options, }/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - bytes = options->value.n; - }else if (!strcmp (options->name,BLOCK_OPT_CLUSTER_SIZE )) { -if (options->value.n) { - objsize = options->value.n; -if ((objsize -1 ) & objsize) {/* not a power of 2? */ -error_report ("obj size needs to be power of 2" ); -return -EINVAL ; - } -if (objsize <4096 ) { -error_report ("obj size too small" ); -return -EINVAL ; - } - obj_order =ffs (objsize) -1 ; - } + bytes =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ); + objsize =qemu_opt_get_size_del (opts,BLOCK_OPT_CLUSTER_SIZE ,0 ); +if (objsize) { +if ((objsize -1 ) & objsize) {/* not a power of 2? */ +error_report ("obj size needs to be power of 2" ); +return -EINVAL ; + } +if (objsize <4096 ) { +error_report ("obj size too small" ); +return -EINVAL ; } - options++; + obj_order =ffs (objsize) -1 ; } clientname =qemu_rbd_parse_clientname (conf, clientname_buf);
@@ -900,18 +894,23 @@ static BlockDriverAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs, }#endif -static QEMUOptionParameter qemu_rbd_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - { - .name =BLOCK_OPT_CLUSTER_SIZE , - .type =OPT_SIZE , - .help ="RBD object size" - }, - {NULL } +static QemuOptsList qemu_rbd_create_opts = { + .name ="rbd-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (qemu_rbd_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + { + .name =BLOCK_OPT_CLUSTER_SIZE , + .type =QEMU_OPT_SIZE , + .help ="RBD object size" , + .def_value_str =stringify (0 ), + }, + {/* end of list */ } + } };static BlockDriver bdrv_rbd = {
@@ -920,10 +919,10 @@ static BlockDriver bdrv_rbd = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_rbd_open, .bdrv_close = qemu_rbd_close, - .bdrv_create = qemu_rbd_create, + .bdrv_create2 = qemu_rbd_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_get_info = qemu_rbd_getinfo, - .create_options = qemu_rbd_create_options, + .create_opts = qemu_rbd_create_opts, .bdrv_getlength = qemu_rbd_getlength, .bdrv_truncate = qemu_rbd_truncate, .protocol_name = "rbd",
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 17/26] rbd.c: replace QEMUOptionParameter with QemuOpts
Quoted 15 lines · Chunyan Liu
rbd.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/rbd.c | 63 +++++++++++++++++++++++++++++------------------------------ 1 files changed, 31 insertions(+), 32 deletions(-)block/rbd.c +6
-0+ objsize =qemu_opt_get_size_del (opts,BLOCK_OPT_CLUSTER_SIZE ,0 ); +if (objsize) { +if ((objsize -1 ) & objsize) {/* not a power of 2? */ +error_report ("obj size needs to be power of 2" ); +return -EINVAL ; + }
block/rbd.c static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options,
Quoted 10 lines
block/rbd.c +8
-0+if (objsize <4096 ) { +error_report ("obj size too small" ); +return -EINVAL ; } + { + .name = BLOCK_OPT_CLUSTER_SIZE, + .type = QEMU_OPT_SIZE, + .help = "RBD object size", + .def_value_str = stringify(0),
Do we really want to list a default of 0, given that the code behaves the same as if 0 had been specified or if the argument had been omitted?
Passing 0 doesn't really mean using a cluster size of 0, which makes
listing it as an explicit default would look odd.
block/rbd.c static BlockDriver bdrv_rbd = { · line 925
Quoted 2 lines
block/rbd.c +1
-1- .create_options = qemu_rbd_create_options, + .create_opts = qemu_rbd_create_opts,
Hmm, I've noticed that your series is inconsistent on whether it uses '= foo_opts' or '= &foo_opts' in these initializers (for example, 15/26 used & even though nothing else did, 16/26 uses & but all other initializers were also using &, and in this 17/26 nothing is using &). Not that it matters to the compiler, but there's a lot to be said for consistency.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v20 17/26] rbd.c: replace QEMUOptionParameter with QemuOpts
2014-02-18 2:57 GMT+08:00 Eric Blake <[email protected]>:
Quoted 39 lines · Chunyan Liu
Quoted 6 lines
rbd.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/rbd.c | 63+++++++++++++++++++++++++++++------------------------------
Quoted 9 lines
1 files changed, 31 insertions(+), 32 deletions(-)block/rbd.c +6
-0+ objsize =qemu_opt_get_size_del (opts,BLOCK_OPT_CLUSTER_SIZE ,0 ); +if (objsize) { +if ((objsize -1 ) & objsize) {/* not a power of 2? */ +error_report ("obj size needs to be power of 2" ); +return -EINVAL ; + }block/rbd.c static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options,
Quoted 10 lines
block/rbd.c +8
-0+if (objsize <4096 ) { +error_report ("obj size too small" ); +return -EINVAL ; } + { + .name = BLOCK_OPT_CLUSTER_SIZE, + .type = QEMU_OPT_SIZE, + .help = "RBD object size", + .def_value_str = stringify(0),Do we really want to list a default of 0, given that the code behaves the same as if 0 had been specified or if the argument had been omitted?
Passing 0 doesn't really mean using a cluster size of 0, which makes
listing it as an explicit default would look odd.Inherited from old patches. Not necessary in fact. Will remove that.
block/rbd.c static BlockDriver bdrv_rbd = { · line 925
Quoted 2 lines
block/rbd.c +1
-1- .create_options = qemu_rbd_create_options, + .create_opts = qemu_rbd_create_opts,
Quoted 8 lines
Hmm, I've noticed that your series is inconsistent on whether it uses '=
foo_opts' or '=&foo_opts' in these initializers (for example, 15/26 used & even though nothing else did, 16/26 uses & but all other initializers were also using &, and in this 17/26 nothing is using &). Not that it matters to the compiler, but there's a lot to be said for consistency.
Sorry, will correct that.
Quoted 5 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v20 18/26 sheepdog.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liusheepdog.c: replace QEMUOptionParameter with QemuOpts
--- block/sheepdog.c | 101 +++++++++++++++++++++++++----------------------------- 1 files changed, 47 insertions(+), 54 deletions(-)
block/sheepdog.c +47 -54
@@ -1625,12 +1625,13 @@ static int parse_redundancy(BDRVSheepdogState *s, const char *opt)return 0 ; } -static int sd_create (const char *filename,QEMUOptionParameter *options, +static int sd_create (const char *filename,QemuOpts *opts,Error **errp) {int ret =0 ;uint32_t vid =0 ; -char *backing_file =NULL ; +const char *backing_file =NULL ; +const char *buf =NULL ;BDRVSheepdogState *s;char tag[SD_MAX_VDI_TAG_LEN ];uint32_t snapid;
@@ -1649,31 +1650,26 @@ static int sd_create(const char *filename, QEMUOptionParameter *options, goto out; } -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - s->inode.vdi_size = options->value.n; - }else if (!strcmp (options->name,BLOCK_OPT_BACKING_FILE )) { - backing_file = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_PREALLOC )) { -if (!options->value.s || !strcmp (options->value.s,"off" )) { - prealloc = false; - }else if (!strcmp (options->value.s,"full" )) { - prealloc = true; - }else { -error_report ("Invalid preallocation mode: '%s'" , - options->value.s); - ret = -EINVAL ; - goto out; - } - }else if (!strcmp (options->name,BLOCK_OPT_REDUNDANCY )) { -if (options->value.s) { - ret =parse_redundancy (s, options->value.s); -if (ret <0 ) { - goto out; - } - } + s->inode.vdi_size =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ); + backing_file =qemu_opt_get_del (opts,BLOCK_OPT_BACKING_FILE ); + buf =qemu_opt_get_del (opts,BLOCK_OPT_PREALLOC ); +if (!buf || !strcmp (buf,"off" )) { + prealloc = false; + }else if (!strcmp (buf,"full" )) { + prealloc = true; + }else { +error_report ("Invalid preallocation mode: '%s'" , buf); + ret = -EINVAL ; + goto out; + } + + buf =NULL ; + buf =qemu_opt_get_del (opts,BLOCK_OPT_REDUNDANCY ); +if (buf) { + ret =parse_redundancy (s, buf); +if (ret <0 ) { + goto out; } - options++; }if (s->inode.vdi_size >SD_MAX_VDI_SIZE ) {
@@ -2487,28 +2483,27 @@ static int64_t sd_get_allocated_file_size(BlockDriverState *bs)return size; } -static QEMUOptionParameter sd_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - { - .name =BLOCK_OPT_BACKING_FILE , - .type =OPT_STRING , - .help ="File name of a base image" - }, - { - .name =BLOCK_OPT_PREALLOC , - .type =OPT_STRING , - .help ="Preallocation mode (allowed values: off, full)" - }, - { - .name =BLOCK_OPT_REDUNDANCY , - .type =OPT_STRING , - .help ="Redundancy of the image" - }, - {NULL } +static QemuOptsList sd_create_opts = { + .name ="sheepdog-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (sd_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + { + .name =BLOCK_OPT_BACKING_FILE , + .type =QEMU_OPT_STRING , + .help ="File name of a base image" + }, + { + .name =BLOCK_OPT_PREALLOC , + .type =QEMU_OPT_STRING , + .help ="Preallocation mode (allowed values: off, full)" + }, + {/* end of list */ } + } };static BlockDriver bdrv_sheepdog = {
@@ -2518,7 +2513,7 @@ static BlockDriver bdrv_sheepdog = { .bdrv_needs_filename = true, .bdrv_file_open = sd_open, .bdrv_close = sd_close, - .bdrv_create = sd_create, + .bdrv_create2 = 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,
@@ -2538,7 +2533,7 @@ static BlockDriver bdrv_sheepdog = { .bdrv_save_vmstate = sd_save_vmstate, .bdrv_load_vmstate = sd_load_vmstate, - .create_options = sd_create_options, + .create_opts = &sd_create_opts, };static BlockDriver bdrv_sheepdog_tcp = {
@@ -2548,7 +2543,7 @@ static BlockDriver bdrv_sheepdog_tcp = { .bdrv_needs_filename = true, .bdrv_file_open = sd_open, .bdrv_close = sd_close, - .bdrv_create = sd_create, + .bdrv_create2 = 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,
@@ -2568,7 +2563,6 @@ static BlockDriver bdrv_sheepdog_tcp = { .bdrv_save_vmstate = sd_save_vmstate, .bdrv_load_vmstate = sd_load_vmstate, - .create_options = sd_create_options, };static BlockDriver bdrv_sheepdog_unix = {
@@ -2578,7 +2572,7 @@ static BlockDriver bdrv_sheepdog_unix = { .bdrv_needs_filename = true, .bdrv_file_open = sd_open, .bdrv_close = sd_close, - .bdrv_create = sd_create, + .bdrv_create2 = 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,
@@ -2598,7 +2592,6 @@ static BlockDriver bdrv_sheepdog_unix = { .bdrv_save_vmstate = sd_save_vmstate, .bdrv_load_vmstate = sd_load_vmstate, - .create_options = sd_create_options, };static void bdrv_sheepdog_init (void )
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 18/26] sheepdog.c: replace QEMUOptionParameter with QemuOpts
block/sheepdog.c static int sd_create(const char *filename, QEMUOptionParameter *options, · line 1667
Quoted 12 lines · Chunyan Liu
sheepdog.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/sheepdog.c | 101 +++++++++++++++++++++++++----------------------------- 1 files changed, 47 insertions(+), 54 deletions(-)block/sheepdog.c +3
-0+ + buf =NULL ; + buf =qemu_opt_get_del (opts,BLOCK_OPT_REDUNDANCY );
Dead NULL assignment.
block/sheepdog.c static int sd_create(const char *filename, QEMUOptionParameter *options, · line 1672
Quoted 5 lines
block/sheepdog.c +4
-0+if (buf) { + ret =parse_redundancy (s, buf); +if (ret <0 ) { + goto out; }
Do you need to store into ret here, or is it sufficient to use 'if (parse_redundancy(s, buf) < 0) {'
Quoted 7 lines
block/sheepdog.c +1
-6- { - .name = BLOCK_OPT_REDUNDANCY, - .type = OPT_STRING, - .help = "Redundancy of the image" - }, - { NULL } +static QemuOptsList sd_create_opts = {
block/sheepdog.c static int64_t sd_get_allocated_file_size(BlockDriverState *bs)
Quoted 10 lines
block/sheepdog.c +9
-0+ .name = "sheepdog-create-opts", + .head = QTAILQ_HEAD_INITIALIZER(sd_create_opts.head), + .desc = { + { + .name = BLOCK_OPT_PREALLOC, + .type = QEMU_OPT_STRING, + .help = "Preallocation mode (allowed values: off, full)" + }, + {/* end of list */ }
Missing redundancy in the new list.
block/sheepdog.c static BlockDriver bdrv_sheepdog = { · line 2536
Quoted 6 lines
block/sheepdog.c +1
-1@@ -2538,7 +2533,7 @@ static BlockDriver bdrv_sheepdog = { .bdrv_save_vmstate = sd_save_vmstate, .bdrv_load_vmstate = sd_load_vmstate, - .create_options = sd_create_options, + .create_opts = &sd_create_opts,
Another example of the inconsistent use of &.
Quoted 13 lines
block/sheepdog.c +1
-1};static BlockDriver bdrv_sheepdog_tcp = {@@ -2548,7 +2543,7 @@ static BlockDriver bdrv_sheepdog_tcp = { .bdrv_needs_filename = true, .bdrv_file_open = sd_open, .bdrv_close = sd_close, - .bdrv_create = sd_create, + .bdrv_create2 = 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,
block/sheepdog.c static BlockDriver bdrv_sheepdog_tcp = { · line 2566
Quoted 5 lines
block/sheepdog.c +0
-1@@ -2568,7 +2563,6 @@ static BlockDriver bdrv_sheepdog_tcp = { .bdrv_save_vmstate = sd_save_vmstate, .bdrv_load_vmstate = sd_load_vmstate, - .create_options = sd_create_options, };
Why no .create_opts replacement?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v20 18/26] sheepdog.c: replace QEMUOptionParameter with QemuOpts
2014-02-18 3:01 GMT+08:00 Eric Blake <[email protected]>:
Quoted 23 lines · Chunyan Liu
Quoted 6 lines
sheepdog.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/sheepdog.c | 101+++++++++++++++++++++++++-----------------------------
block/sheepdog.c static int sd_create(const char *filename, QEMUOptionParameter *options, · line 1667
Quoted 6 lines
1 files changed, 47 insertions(+), 54 deletions(-)block/sheepdog.c +3
-0+ + buf =NULL ; + buf =qemu_opt_get_del (opts,BLOCK_OPT_REDUNDANCY );Dead NULL assignment.
block/sheepdog.c static int sd_create(const char *filename, QEMUOptionParameter *options, · line 1672
Quoted 5 lines
block/sheepdog.c +4
-0+if (buf) { + ret =parse_redundancy (s, buf); +if (ret <0 ) { + goto out; }
Quoted 4 lines
Do you need to store into ret here, or is it sufficient to use 'if (
parse_redundancy(s, buf)< 0) {'It followed the logic in existing code. If function ret < 0, return
with that return value. Same logic in earlier codes of the function.
if (strstr(filename, "://")) {
ret = sd_parse_uri(s, filename, s->name, &snapid, tag);
} else {
ret = parse_vdiname(s, filename, s->name, &snapid, tag);
}
if (ret < 0) {
goto out;
}Quoted 55 lines
Quoted 7 lines
block/sheepdog.c +1
-6- { - .name = BLOCK_OPT_REDUNDANCY, - .type = OPT_STRING, - .help = "Redundancy of the image" - }, - { NULL } +static QemuOptsList sd_create_opts = {block/sheepdog.c static int64_t sd_get_allocated_file_size(BlockDriverState *bs)
Quoted 10 lines
block/sheepdog.c +9
-0+ .name = "sheepdog-create-opts", + .head = QTAILQ_HEAD_INITIALIZER(sd_create_opts.head), + .desc = { + { + .name = BLOCK_OPT_PREALLOC, + .type = QEMU_OPT_STRING, + .help = "Preallocation mode (allowed values: off, full)" + }, + {/* end of list */ }Missing redundancy in the new list.
block/sheepdog.c static BlockDriver bdrv_sheepdog = { · line 2536
Quoted 6 lines
block/sheepdog.c +1
-1@@ -2538,7 +2533,7 @@ static BlockDriver bdrv_sheepdog = { .bdrv_save_vmstate = sd_save_vmstate, .bdrv_load_vmstate = sd_load_vmstate, - .create_options = sd_create_options, + .create_opts = &sd_create_opts,Another example of the inconsistent use of &.
Quoted 13 lines
block/sheepdog.c +1
-1};static BlockDriver bdrv_sheepdog_tcp = {@@ -2548,7 +2543,7 @@ static BlockDriver bdrv_sheepdog_tcp = { .bdrv_needs_filename = true, .bdrv_file_open = sd_open, .bdrv_close = sd_close, - .bdrv_create = sd_create, + .bdrv_create2 = 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,block/sheepdog.c static BlockDriver bdrv_sheepdog_tcp = { · line 2566
Quoted 5 lines
block/sheepdog.c +0
-1@@ -2568,7 +2563,6 @@ static BlockDriver bdrv_sheepdog_tcp = { .bdrv_save_vmstate = sd_save_vmstate, .bdrv_load_vmstate = sd_load_vmstate, - .create_options = sd_create_options, };Why no .create_opts replacement?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v20 19/26 ssh.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liussh.c: replace QEMUOptionParameter with QemuOpts
--- block/ssh.c | 31 +++++++++++++++---------------- 1 files changed, 15 insertions(+), 16 deletions(-)
block/ssh.c +15 -16
@@ -642,16 +642,20 @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags,return ret; } -static QEMUOptionParameter ssh_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - {NULL } +static QemuOptsList ssh_create_opts = { + .name ="ssh-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (ssh_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + {/* end of list */ } + } }; -static int ssh_create (const char *filename,QEMUOptionParameter *options, +static int ssh_create (const char *filename,QemuOpts *opts,Error **errp) {int r, ret;
@@ -665,12 +669,7 @@ static int ssh_create(const char *filename, QEMUOptionParameter *options,ssh_state_init (&s);/* Get desired file size. */ -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - total_size = options->value.n; - } - options++; - } + total_size =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 );DPRINTF ("total_size=%" PRIi64, total_size); uri_options =qdict_new ();
@@ -1044,14 +1043,14 @@ static BlockDriver bdrv_ssh = { .instance_size = sizeof(BDRVSSHState), .bdrv_parse_filename = ssh_parse_filename, .bdrv_file_open = ssh_file_open, - .bdrv_create = ssh_create, + .bdrv_create2 = ssh_create, .bdrv_close = ssh_close, .bdrv_has_zero_init = ssh_has_zero_init, .bdrv_co_readv = ssh_co_readv, .bdrv_co_writev = ssh_co_writev, .bdrv_getlength = ssh_getlength, .bdrv_co_flush_to_disk = ssh_co_flush, - .create_options = ssh_create_options, + .create_opts = &ssh_create_opts, };static void bdrv_ssh_init (void )
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 19/26] ssh.c: replace QEMUOptionParameter with QemuOpts
block/ssh.c static BlockDriver bdrv_ssh = { · line 1053
Quoted 13 lines · Chunyan Liu
ssh.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/ssh.c | 31 +++++++++++++++---------------- 1 files changed, 15 insertions(+), 16 deletions(-).bdrv_getlength =
ssh_getlength,
.bdrv_co_flush_to_disk =ssh_co_flush,block/ssh.c +1
-1- .create_options = ssh_create_options, + .create_opts = &ssh_create_opts,
More inconsistent &. I'll quit pointing it out.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 20/26 vdi.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuvdi.c: replace QEMUOptionParameter with QemuOpts
--- block/vdi.c | 71 ++++++++++++++++++++++++++++------------------------------ 1 files changed, 34 insertions(+), 37 deletions(-)
block/vdi.c +34 -37
@@ -646,7 +646,7 @@ static int vdi_co_write(BlockDriverState *bs,return ret; } -static int vdi_create (const char *filename,QEMUOptionParameter *options, +static int vdi_create (const char *filename,QemuOpts *opts,Error **errp) {int fd;
@@ -662,25 +662,17 @@ 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; - } + 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 fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
@@ -760,29 +752,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 = {
@@ -792,7 +789,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,
@@ -804,7 +801,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, };
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 20/26] vdi.c: replace QEMUOptionParameter with QemuOpts
Quoted 8 lines · Chunyan Liu
vdi.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/vdi.c | 71 ++++++++++++++++++++++++++++------------------------------ 1 files changed, 34 insertions(+), 37 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 21/26 vmdk.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuvmdk.c: replace QEMUOptionParameter with QemuOpts
--- block/vmdk.c | 109 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 55 insertions(+), 54 deletions(-)
block/vmdk.c +55 -54
@@ -1641,7 +1641,7 @@ static int filename_decompose(const char *filename, char *path, char *prefix,return VMDK_OK ; } -static int vmdk_create (const char *filename,QEMUOptionParameter *options, +static int vmdk_create (const char *filename,QemuOpts *opts,Error **errp) {int idx =0 ;
@@ -1691,22 +1691,17 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options, goto exit; }/* Read out options */ -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - total_size = options->value.n; - }else if (!strcmp (options->name,BLOCK_OPT_ADAPTER_TYPE )) { - adapter_type = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_BACKING_FILE )) { - backing_file = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_COMPAT6 )) { - flags |= options->value.n ?BLOCK_FLAG_COMPAT6 :0 ; - }else if (!strcmp (options->name,BLOCK_OPT_SUBFMT )) { - fmt = options->value.s; - }else if (!strcmp (options->name,BLOCK_OPT_ZEROED_GRAIN )) { - zeroed_grain |= options->value.n; - } - options++; + total_size =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ); + adapter_type =qemu_opt_get_del (opts,BLOCK_OPT_ADAPTER_TYPE ); + backing_file =qemu_opt_get_del (opts,BLOCK_OPT_BACKING_FILE ); +if (qemu_opt_get_bool_del (opts,BLOCK_OPT_COMPAT6 , false)) { + flags |=BLOCK_FLAG_COMPAT6 ; + } + fmt =qemu_opt_get_del (opts,BLOCK_OPT_SUBFMT ); +if (qemu_opt_get_bool_del (opts,BLOCK_OPT_ZEROED_GRAIN , false)) { + zeroed_grain = true; } +if (!adapter_type) { adapter_type ="ide" ; } else if (strcmp(adapter_type, "ide") &&
@@ -1825,7 +1820,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,if (!split && !flat) { desc_offset =0x200 ; }else { - ret =bdrv_create_file (filename, options,NULL , &local_err); + ret =bdrv_create_file (filename,NULL , opts, &local_err);if (ret <0 ) {error_setg_errno (errp, -ret,"Could not create image file" ); goto exit;
@@ -2020,41 +2015,47 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)return spec_info; } -static QEMUOptionParameter vmdk_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size" - }, - { - .name =BLOCK_OPT_ADAPTER_TYPE , - .type =OPT_STRING , - .help ="Virtual adapter type, can be one of " -"ide (default), lsilogic, buslogic or legacyESX" - }, - { - .name =BLOCK_OPT_BACKING_FILE , - .type =OPT_STRING , - .help ="File name of a base image" - }, - { - .name =BLOCK_OPT_COMPAT6 , - .type =OPT_FLAG , - .help ="VMDK version 6 image" - }, - { - .name =BLOCK_OPT_SUBFMT , - .type =OPT_STRING , - .help = -"VMDK flat extent format, can be one of " -"{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse | twoGbMaxExtentFlat | streamOptimized} " - }, - { - .name =BLOCK_OPT_ZEROED_GRAIN , - .type =OPT_FLAG , - .help ="Enable efficient zero writes using the zeroed-grain GTE feature" - }, - {NULL } +static QemuOptsList vmdk_create_opts = { + .name ="vmdk-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (vmdk_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size" + }, + { + .name =BLOCK_OPT_ADAPTER_TYPE , + .type =QEMU_OPT_STRING , + .help ="Virtual adapter type, can be one of " +"ide (default), lsilogic, buslogic or legacyESX" + }, + { + .name =BLOCK_OPT_BACKING_FILE , + .type =QEMU_OPT_STRING , + .help ="File name of a base image" + }, + { + .name =BLOCK_OPT_COMPAT6 , + .type =QEMU_OPT_BOOL , + .help ="VMDK version 6 image" , + .def_value_str ="off" + }, + { + .name =BLOCK_OPT_SUBFMT , + .type =QEMU_OPT_STRING , + .help = +"VMDK flat extent format, can be one of " +"{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse | twoGbMaxExtentFlat | streamOptimized} " + }, + { + .name =BLOCK_OPT_ZEROED_GRAIN , + .type =QEMU_OPT_BOOL , + .help ="Enable efficient zero writes " +"using the zeroed-grain GTE feature" + }, + {/* end of list */ } + } };static BlockDriver bdrv_vmdk = {
@@ -2068,7 +2069,7 @@ static BlockDriver bdrv_vmdk = { .bdrv_write = vmdk_co_write, .bdrv_co_write_zeroes = vmdk_co_write_zeroes, .bdrv_close = vmdk_close, - .bdrv_create = vmdk_create, + .bdrv_create2 = 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,
@@ -2076,7 +2077,7 @@ static BlockDriver bdrv_vmdk = { .bdrv_get_specific_info = vmdk_get_specific_info, .bdrv_refresh_limits = vmdk_refresh_limits, - .create_options = vmdk_create_options, + .create_opts = &vmdk_create_opts, };static void bdrv_vmdk_init (void )
Signature · 1 line
1.6.0.2
PATCH v20 22/26 vpc.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuvpc.c: replace QEMUOptionParameter with QemuOpts
--- block/vpc.c | 52 +++++++++++++++++++++++++++------------------------- 1 files changed, 27 insertions(+), 25 deletions(-)
block/vpc.c +27 -25
@@ -713,12 +713,12 @@ 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, +static int vpc_create (const char *filename,QemuOpts *opts,Error **errp) {uint8_t buf[1024 ];VHDFooter *footer = (VHDFooter *) buf; -QEMUOptionParameter *disk_type_param; +const char *disk_type_param;int fd, i;uint16_t cyls =0 ;uint8_t heads =0 ;
@@ -729,13 +729,12 @@ 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 ;
@@ -841,20 +840,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 = {
@@ -865,14 +868,13 @@ 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, };
Signature · 1 line
1.6.0.2
PATCH v20 23/26 vhdx.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuvhdx.c: replace QEMUOptionParameter with QemuOpts
--- block/vhdx.c | 93 +++++++++++++++++++++++++++------------------------------ block/vhdx.h | 1 + 2 files changed, 45 insertions(+), 49 deletions(-)
block/vhdx.c +44 -49
@@ -1711,7 +1711,7 @@ exit:* .---- ~ ----------- ~ ------------ ~ ---------------- ~ -----------. * 1MB */ -static int vhdx_create (const char *filename,QEMUOptionParameter *options, +static int vhdx_create (const char *filename,QemuOpts *opts,Error **errp) {int ret =0 ;
@@ -1729,20 +1729,11 @@ static int vhdx_create(const char *filename, QEMUOptionParameter *options,VHDXImageType image_type;Error *local_err =NULL ; -while (options && options->name) { -if (!strcmp (options->name,BLOCK_OPT_SIZE )) { - image_size = options->value.n; - }else if (!strcmp (options->name,VHDX_BLOCK_OPT_LOG_SIZE )) { - log_size = options->value.n; - }else if (!strcmp (options->name,VHDX_BLOCK_OPT_BLOCK_SIZE )) { - block_size = options->value.n; - }else if (!strcmp (options->name,BLOCK_OPT_SUBFMT )) { - type = options->value.s; - }else if (!strcmp (options->name,VHDX_BLOCK_OPT_ZERO )) { - use_zero_blocks = options->value.n !=0 ; - } - options++; - } + image_size =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ); + log_size =qemu_opt_get_size_del (opts,VHDX_BLOCK_OPT_LOG_SIZE ,0 ); + block_size =qemu_opt_get_size_del (opts,VHDX_BLOCK_OPT_BLOCK_SIZE ,0 ); + type =qemu_opt_get_del (opts,BLOCK_OPT_SUBFMT ); + use_zero_blocks =qemu_opt_get_bool_del (opts,VHDX_BLOCK_OPT_ZERO ,0 );if (image_size >VHDX_MAX_IMAGE_SIZE ) {error_setg_errno (errp,EINVAL ,"Image size too large; max of 64TB" );
@@ -1791,7 +1782,7 @@ static int vhdx_create(const char *filename, QEMUOptionParameter *options, block_size = block_size >VHDX_BLOCK_SIZE_MAX ?VHDX_BLOCK_SIZE_MAX : block_size; - ret =bdrv_create_file (filename, options,NULL , &local_err); + ret =bdrv_create_file (filename,NULL , opts, &local_err);if (ret <0 ) {error_propagate (errp, local_err); goto exit;
@@ -1871,37 +1862,41 @@ static int vhdx_check(BlockDriverState *bs, BdrvCheckResult *result,return 0 ; } -static QEMUOptionParameter vhdx_create_options[] = { - { - .name =BLOCK_OPT_SIZE , - .type =OPT_SIZE , - .help ="Virtual disk size; max of 64TB." - }, - { - .name =VHDX_BLOCK_OPT_LOG_SIZE , - .type =OPT_SIZE , - .value.n =1 * MiB, - .help ="Log size; min 1MB." - }, - { - .name =VHDX_BLOCK_OPT_BLOCK_SIZE , - .type =OPT_SIZE , - .value.n =0 , - .help ="Block Size; min 1MB, max 256MB. " \ -"0 means auto-calculate based on image size." - }, - { - .name =BLOCK_OPT_SUBFMT , - .type =OPT_STRING , - .help ="VHDX format type, can be either 'dynamic' or 'fixed'. " \ -"Default is 'dynamic'." - }, - { - .name =VHDX_BLOCK_OPT_ZERO , - .type =OPT_FLAG , - .help ="Force use of payload blocks of type 'ZERO'. Non-standard." - }, - {NULL } +static QemuOptsList vhdx_create_opts = { + .name ="vhdx-create-opts" , + .head =QTAILQ_HEAD_INITIALIZER (vhdx_create_opts.head), + .desc = { + { + .name =BLOCK_OPT_SIZE , + .type =QEMU_OPT_SIZE , + .help ="Virtual disk size; max of 64TB." + }, + { + .name =VHDX_BLOCK_OPT_LOG_SIZE , + .type =QEMU_OPT_SIZE , + .def_value_str =stringify (DEFAULT_LOG_SIZE ), + .help ="Log size; min 1MB." + }, + { + .name =VHDX_BLOCK_OPT_BLOCK_SIZE , + .type =QEMU_OPT_SIZE , + .def_value_str =stringify (0 ), + .help ="Block Size; min 1MB, max 256MB. " \ +"0 means auto-calculate based on image size." + }, + { + .name =BLOCK_OPT_SUBFMT , + .type =QEMU_OPT_STRING , + .help ="VHDX format type, can be either 'dynamic' or 'fixed'. " \ +"Default is 'dynamic'." + }, + { + .name =VHDX_BLOCK_OPT_ZERO , + .type =QEMU_OPT_BOOL , + .help ="Force use of payload blocks of type 'ZERO'. Non-standard." + }, + {NULL } + } };static BlockDriver bdrv_vhdx = {
@@ -1913,11 +1908,11 @@ static BlockDriver bdrv_vhdx = { .bdrv_reopen_prepare = vhdx_reopen_prepare, .bdrv_co_readv = vhdx_co_readv, .bdrv_co_writev = vhdx_co_writev, - .bdrv_create = vhdx_create, + .bdrv_create2 = vhdx_create, .bdrv_get_info = vhdx_get_info, .bdrv_check = vhdx_check, - .create_options = vhdx_create_options, + .create_opts = &vhdx_create_opts, };static void bdrv_vhdx_init (void )
block/vhdx.h +1 -0
@@ -23,6 +23,7 @@#define GiB (MiB * 1024)#define TiB ((uint64_t) GiB * 1024) +#define DEFAULT_LOG_SIZE 1048576/* 1MiB */ /* Structures and fields present in the VHDX file */ /* The header section has the following blocks,
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 23/26] vhdx.c: replace QEMUOptionParameter with QemuOpts
Quoted 10 lines · Chunyan Liu
vhdx.c: replace QEMUOptionParameter with QemuOptsSigned-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block/vhdx.c | 93 +++++++++++++++++++++++++++------------------------------ block/vhdx.h | 1 + 2 files changed, 45 insertions(+), 49 deletions(-)
block/vhdx.c static int vhdx_create(const char *filename, QEMUOptionParameter *options, · line 1736
Quoted 5 lines
block/vhdx.c +5
-0+ image_size =qemu_opt_get_size_del (opts,BLOCK_OPT_SIZE ,0 ); + log_size =qemu_opt_get_size_del (opts,VHDX_BLOCK_OPT_LOG_SIZE ,0 ); + block_size =qemu_opt_get_size_del (opts,VHDX_BLOCK_OPT_BLOCK_SIZE ,0 ); + type =qemu_opt_get_del (opts,BLOCK_OPT_SUBFMT ); + use_zero_blocks =qemu_opt_get_bool_del (opts,VHDX_BLOCK_OPT_ZERO ,0 );
s/0/false/ when passing a bool to qemu_opt_get_bool_del.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 24/26 vvfat.c: replace QEMUOptionParameter with QemuOpts
In reply to Chunyan Liuvvfat.c: replace QEMUOptionParameter with QemuOpts
--- block/vvfat.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
block/vvfat.c +5 -5
@@ -2910,7 +2910,7 @@ static BlockDriver vvfat_write_target = {static int enable_write_target (BDRVVVFATState *s) {BlockDriver *bdrv_qcow; -QEMUOptionParameter *options; +QemuOpts *opts;Error *local_err =NULL ;int ret;int size =sector2cluster (s, s->sector_count);
@@ -2925,11 +2925,11 @@ static int enable_write_target(BDRVVVFATState *s) } bdrv_qcow =bdrv_find_format ("qcow" ); - options =parse_option_parameters ("" , bdrv_qcow->create_options,NULL ); -set_option_parameter_int (options,BLOCK_OPT_SIZE , s->sector_count *512 ); -set_option_parameter (options,BLOCK_OPT_BACKING_FILE ,"fat:" ); + 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, options,NULL , &local_err); + ret =bdrv_create (bdrv_qcow, s->qcow_filename,NULL , opts, &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
Signature · 1 line
1.6.0.2
PATCH v20 25/26 cleanup QEMUOptionParameter
In reply to Chunyan LiuNow all places using QEMUOptionParameter could use QemuOpts too, remove QEMUOptionParameter related code.
--- block.c | 57 ++----- block/cow.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/raw_bsd.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 4 +- block/vvfat.c | 2 +- include/block/block.h | 4 +- include/block/block_int.h | 3 - include/qemu/option.h | 37 ---- qemu-img.c | 39 +---- util/qemu-option.c | 405 --------------------------------------------- 14 files changed, 30 insertions(+), 533 deletions(-)
block.c +12 -45
@@ -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;
@@ -421,11 +420,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)CreateCo *cco = opaque;assert (cco->drv); -if (cco->drv->bdrv_create2) { - ret = cco->drv->bdrv_create2 (cco->filename, cco->opts, &local_err); - }else { - ret = cco->drv->bdrv_create (cco->filename, cco->options, &local_err); - } + ret = cco->drv->bdrv_create2 (cco->filename, cco->opts, &local_err);if (error_is_set (&local_err)) {error_propagate (&cco->err, local_err); }
@@ -433,7 +428,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque) }int bdrv_create (BlockDriver *drv,const char * filename, -QEMUOptionParameter *options,QemuOpts *opts,Error **errp) +QemuOpts *opts,Error **errp) {int ret;
@@ -441,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_create2) {error_setg (errp,"Driver '%s' does not support image creation" , drv->format_name); ret = -ENOTSUP ; goto out;
@@ -478,7 +472,7 @@ out:return ret; } -int bdrv_create_file (const char * filename,QEMUOptionParameter *options, +int bdrv_create_file (const char *filename,QemuOpts *opts,Error **errp) {BlockDriver *drv;
@@ -491,7 +485,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 (error_is_set (&local_err)) {error_propagate (errp, local_err); }
@@ -1252,7 +1246,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,BlockDriverState *bs1;int64_t total_size;BlockDriver *bdrv_qcow2; -QEMUOptionParameter *create_options =NULL ;QemuOpts *opts =NULL ;QDict *snapshot_options;
@@ -1280,20 +1273,11 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, } bdrv_qcow2 =bdrv_find_format ("qcow2" ); -if (bdrv_qcow2->bdrv_create2) { - opts =qemu_opts_create (bdrv_qcow2->create_opts,NULL ,0 , - &error_abort); -qemu_opt_set_number (opts,BLOCK_OPT_SIZE , total_size); - }else { - create_options = -parse_option_parameters ("" , bdrv_qcow2->create_options,NULL ); -set_option_parameter_int (create_options,BLOCK_OPT_SIZE , - total_size); - } + 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, create_options, opts, - &local_err); -free_option_parameters (create_options); + ret =bdrv_create (bdrv_qcow2, tmp_filename, opts, &local_err);qemu_opts_del (opts);if (ret <0 ) { error_setg_errno(errp, -ret, "Could not create temporary overlay "
@@ -5211,7 +5195,6 @@ void bdrv_img_create(const char *filename, const char *fmt, char *options, uint64_t img_size, int flags, Error **errp, bool quiet) { - QEMUOptionParameter *param = NULL, *create_options = NULL; QemuOptsList *create_opts = NULL;QemuOpts *opts =NULL ;const char *backing_fmt, *backing_file;
@@ -5234,16 +5217,8 @@ void bdrv_img_create(const char *filename, const char *fmt,return ; } -if (drv->bdrv_create2) { - create_opts =qemu_opts_append (create_opts, drv->create_opts); - create_opts =qemu_opts_append (create_opts, proto_drv->create_opts); - }else { - create_options =append_option_parameters (create_options, - drv->create_options); - create_options =append_option_parameters (create_options, - proto_drv->create_options); - create_opts =params_to_opts (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);
@@ -5338,12 +5313,7 @@ void bdrv_img_create(const char *filename, const char *fmt,puts ("" ); } -if (drv->bdrv_create2) { - ret =bdrv_create (drv, filename,NULL , opts, &local_err); - }else { - param =opts_to_params (opts); - ret =bdrv_create (drv, filename, param,NULL , &local_err); - } + ret =bdrv_create (drv, filename, opts, &local_err);if (ret == -EFBIG ) {/* This is generally a better message than whatever the driver would
@@ -5360,9 +5330,6 @@ void bdrv_img_create(const char *filename, const char *fmt, } out: -free_option_parameters (create_options); -free_option_parameters (param); -qemu_opts_del (opts);qemu_opts_free (create_opts);if (error_is_set (&local_err)) {
block/cow.c +1 -1
@@ -338,7 +338,7 @@ static int cow_create(const char *filename, QemuOpts *opts, 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 ) {qerror_report_err (local_err);error_free (local_err);
block/qcow.c +1 -1
@@ -679,7 +679,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, flags |=BLOCK_FLAG_ENCRYPT ; } - ret =bdrv_create_file (filename,NULL , opts, &local_err); + ret =bdrv_create_file (filename, opts, &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
block/qcow2.c +1 -1
@@ -1485,7 +1485,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;
block/qed.c +1 -1
@@ -564,7 +564,7 @@ static int qed_create(const char *filename, uint32_t cluster_size,int ret =0 ;BlockDriverState *bs =NULL ; - ret =bdrv_create_file (filename,NULL ,NULL , &local_err); + ret =bdrv_create_file (filename,NULL , &local_err);if (ret <0 ) {qerror_report_err (local_err);error_free (local_err);
block/raw_bsd.c +1 -1
@@ -143,7 +143,7 @@ static int raw_create(const char *filename, QemuOpts *opts,Error *local_err =NULL ;int ret; - ret =bdrv_create_file (filename,NULL , opts, &local_err); + ret =bdrv_create_file (filename, opts, &local_err);if (error_is_set (&local_err)) {error_propagate (errp, local_err); }
block/vhdx.c +1 -1
@@ -1782,7 +1782,7 @@ static int vhdx_create(const char *filename, QemuOpts *opts, 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;
block/vmdk.c +2 -2
@@ -1487,7 +1487,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;
@@ -1820,7 +1820,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts,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;
block/vvfat.c +1 -1
@@ -2929,7 +2929,7 @@ static int enable_write_target(BDRVVVFATState *s)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);
include/block/block.h +2 -2
@@ -174,8 +174,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); +int bdrv_create_file (const char *filename,QemuOpts *opts,Error **errp);BlockDriverState *bdrv_new (const char *device_name);void bdrv_make_anon (BlockDriverState *bs);
include/block/block_int.h +0 -3
@@ -116,8 +116,6 @@ 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);int (*bdrv_create2)(const char *filename,QemuOpts *opts,Error **errp);int (*bdrv_set_key)(BlockDriverState *bs,const char *key);
@@ -218,7 +216,6 @@ struct BlockDriver { BlockDriverCompletionFunc *cb, void *opaque);/* List of options for creating images, terminated by name == NULL */ -QEMUOptionParameter *create_options;QemuOptsList *create_opts;/*
include/qemu/option.h +0 -37
@@ -38,18 +38,6 @@ enum QEMUOptionParType { 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,
@@ -57,29 +45,6 @@ int get_next_param_value(char *buf, int buf_size,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); -/* ------------------------------------------------------------------ */ typedef struct QemuOpt QemuOpt ;
@@ -168,6 +133,4 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,QemuOptsList *qemu_opts_append (QemuOptsList *dst,QemuOptsList *list);void qemu_opts_free (QemuOptsList *list);void qemu_opts_print_help (QemuOptsList *list); -QEMUOptionParameter *opts_to_params (QemuOpts *opts); -QemuOptsList *params_to_opts (QEMUOptionParameter *list);#endif
qemu-img.c +7 -32
@@ -241,7 +241,6 @@ static int read_password(char *buf, int buf_size)static int print_block_option_help (const char *filename,const char *fmt) {BlockDriver *drv, *proto_drv; -QEMUOptionParameter *create_options =NULL ;QemuOptsList *create_opts =NULL ;/* Find driver and parse its options */
@@ -257,18 +256,10 @@ static int print_block_option_help(const char *filename, const char *fmt)return 1 ; } -if (drv->bdrv_create2) { - create_opts =qemu_opts_append (create_opts, drv->create_opts); - create_opts =qemu_opts_append (create_opts, proto_drv->create_opts); -qemu_opts_print_help (create_opts); - }else { - create_options =append_option_parameters (create_options, - drv->create_options); - create_options =append_option_parameters (create_options, - proto_drv->create_options); -print_option_help (create_options); - } -free_option_parameters (create_options); + create_opts =qemu_opts_append (create_opts, drv->create_opts); + create_opts =qemu_opts_append (create_opts, proto_drv->create_opts); +qemu_opts_print_help (create_opts); +qemu_opts_free (create_opts);return 0 ; }
@@ -1149,7 +1140,6 @@ static int img_convert(int argc, char **argv)size_t bufsectors =IO_BUF_SIZE /BDRV_SECTOR_SIZE ;const uint8_t *buf1;BlockDriverInfo bdi; -QEMUOptionParameter *param =NULL , *create_options =NULL ;QemuOpts *opts =NULL ;QemuOptsList *create_opts =NULL ;const char *out_baseimg_param;
@@ -1322,16 +1312,8 @@ static int img_convert(int argc, char **argv) goto out; } -if (drv->bdrv_create2) { - create_opts =qemu_opts_append (create_opts, drv->create_opts); - create_opts =qemu_opts_append (create_opts, proto_drv->create_opts); - }else { - create_options =append_option_parameters (create_options, - drv->create_options); - create_options =append_option_parameters (create_options, - proto_drv->create_options); - create_opts =params_to_opts (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 )) {
@@ -1384,12 +1366,7 @@ static int img_convert(int argc, char **argv)if (!skip_create) {/* Create the new image */ -if (drv->bdrv_create2) { - ret =bdrv_create (drv, out_filename,NULL , opts, &local_err); - }else { - param =opts_to_params (opts); - ret =bdrv_create (drv, out_filename, param,NULL , &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));
@@ -1653,8 +1630,6 @@ out:qemu_progress_print (100 ,0 ); }qemu_progress_end (); -free_option_parameters (create_options); -free_option_parameters (param);qemu_opts_free (create_opts);qemu_opts_del (opts);qemu_vfree (buf);
util/qemu-option.c +0 -405
426 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 25/26] cleanup QEMUOptionParameter
Quoted 9 lines · Chunyan Liu
Now all places using QEMUOptionParameter could use QemuOpts too, remove QEMUOptionParameter related code.
Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>---
+++
b/include/qemu/option.h
include/qemu/option.h enum QEMUOptionParType { · line 43
Quoted 6 lines
include/qemu/option.h +0
-3@@ -38,18 +38,6 @@ enum QEMUOptionParType { OPT_STRING, }; -typedef struct QEMUOptionParameter { - const char *name; - enum QEMUOptionParType type;
enum QEMUOptionParType several lines above is now dead, too. Kill it as well.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v20 26/26 change back to original name from bdrv_create2 to bdrv_create
In reply to Chunyan LiuRename the new driver callback bdrv_create2 to the old name bdrv_create.
--- block.c | 4 ++-- block/cow.c | 2 +- block/gluster.c | 8 ++++---- block/iscsi.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/raw-posix.c | 10 +++++----- block/raw-win32.c | 2 +- block/raw_bsd.c | 2 +- block/rbd.c | 2 +- block/sheepdog.c | 6 +++--- block/ssh.c | 2 +- block/vdi.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 2 +- block/vpc.c | 2 +- include/block/block_int.h | 2 +- 18 files changed, 28 insertions(+), 28 deletions(-)
block.c +2 -2
@@ -420,7 +420,7 @@ static void coroutine_fn bdrv_create_co_entry(void *opaque)CreateCo *cco = opaque;assert (cco->drv); - ret = cco->drv->bdrv_create2 (cco->filename, cco->opts, &local_err); + ret = cco->drv->bdrv_create (cco->filename, cco->opts, &local_err);if (error_is_set (&local_err)) {error_propagate (&cco->err, local_err); }
@@ -441,7 +441,7 @@ int bdrv_create(BlockDriver *drv, const char* filename, .err = NULL, }; -if (!drv->bdrv_create2) { +if (!drv->bdrv_create) {error_setg (errp,"Driver '%s' does not support image creation" , drv->format_name); ret = -ENOTSUP ; goto out;
block/cow.c +1 -1
@@ -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,
block/gluster.c +4 -4
@@ -620,7 +620,7 @@ static BlockDriver bdrv_gluster = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .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,
@@ -644,7 +644,7 @@ static BlockDriver bdrv_gluster_tcp = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .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,
@@ -668,7 +668,7 @@ static BlockDriver bdrv_gluster_unix = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .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,
@@ -692,7 +692,7 @@ static BlockDriver bdrv_gluster_rdma = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .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,
block/iscsi.c +1 -1
@@ -1450,7 +1450,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, .create_opts = iscsi_create_opts, .bdrv_reopen_prepare = iscsi_reopen_prepare,
block/qcow.c +1 -1
@@ -905,7 +905,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,
block/qcow2.c +1 -1
@@ -2220,7 +2220,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,
block/qed.c +1 -1
@@ -1608,7 +1608,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,
block/raw-posix.c +5 -5
@@ -1417,7 +1417,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,
@@ -1792,7 +1792,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,
@@ -1926,7 +1926,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,
@@ -2037,7 +2037,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,
@@ -2167,7 +2167,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,
block/raw-win32.c +1 -1
@@ -507,7 +507,7 @@ static BlockDriver bdrv_file = { .bdrv_needs_filename = true, .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,
block/raw_bsd.c +1 -1
@@ -177,7 +177,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,
block/rbd.c +1 -1
@@ -919,7 +919,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,
block/sheepdog.c +3 -3
@@ -2513,7 +2513,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,
@@ -2543,7 +2543,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,
@@ -2572,7 +2572,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,
block/ssh.c +1 -1
@@ -1043,7 +1043,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,
block/vdi.c +1 -1
@@ -789,7 +789,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,
block/vhdx.c +1 -1
@@ -1908,7 +1908,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,
block/vmdk.c +1 -1
@@ -2069,7 +2069,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,
block/vpc.c +1 -1
@@ -868,7 +868,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,
include/block/block_int.h +1 -1
@@ -116,7 +116,7 @@ struct BlockDriver { const uint8_t *buf, int nb_sectors);void (*bdrv_close)(BlockDriverState *bs);void (*bdrv_rebind)(BlockDriverState *bs); -int (*bdrv_create2)(const char *filename,QemuOpts *opts, +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);
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH v20 26/26] change back to original name from bdrv_create2 to bdrv_create
Quoted 16 lines · Chunyan Liu
Rename the new driver callback
bdrv_create2to the old namebdrv_create.Signed-off-by Dong Xu Wang <[email protected]>Signed-off-by Chunyan Liu <[email protected]>--- block.c | 4 ++-- block/cow.c | 2 +- block/gluster.c | 8 ++++---- block/iscsi.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/raw-posix.c | 10 +++++----- block/raw-win32.c | 2 +- block/raw_bsd.c | 2 +- block/rbd.c | 2 +-
Quoted 8 lines
block/sheepdog.c | 6 +++--- block/ssh.c | 2 +- block/vdi.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 2 +- block/vpc.c | 2 +- include/block/block_int.h | 2 +- 18 files changed, 28 insertions(+), 28 deletions(-)
I would squash this in to the previous patch.
block/gluster.c static BlockDriver bdrv_gluster = { · line 623
Quoted 7 lines
+++
b/block/gluster.cblock/gluster.c +1
-1@@ -620,7 +620,7 @@ static BlockDriver bdrv_gluster = { .bdrv_needs_filename = true, .bdrv_file_open = qemu_gluster_open, .bdrv_close = qemu_gluster_close, - .bdrv_create2 = qemu_gluster_create, + .bdrv_create = qemu_gluster_create,
Don't mess up indentation.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org