Am 20.01.2014 um 15:19 hat Chunyan Liu geschrieben: > 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 <wdon...@linux.vnet.ibm.com> > Signed-off-by: Chunyan Liu <cy...@suse.com>
It would be worth mentioning that qemu_opts_print() is unused, so changing the prototype and behaviour is fine. > -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) { I think 'if (opts_accepts_any(opts))' would be more readable. > + QTAILQ_FOREACH(opt, &opts->head, next) { > + printf("%s=\"%s\" ", opt->name, opt->str); > + } > + return; > + } > + for (; desc && desc->name; desc++) { > + const char *value = desc->def_value_str; > + QemuOpt *opt; > + > + opt = qemu_opt_find(opts, desc->name); > + if (opt) { > + value = opt->str; > + } > + > + if (!value) { > + continue; > + } > + > + 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); This is so that a value like '64k' gets expanded to '65536'? Perhaps add a comment? > + } else { > + printf("%s=%s ", desc->name, value); > + } > } > - fprintf(stderr, "\n"); > - return 0; > } Kevin