From: Kevin Wolf <kwolf@redhat.com>
To: Chunyan Liu <cyliu@suse.com>
Cc: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>,
qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [v19 01/25] add def_value_str to QemuOptDesc
Date: Wed, 22 Jan 2014 14:25:54 +0100 [thread overview]
Message-ID: <20140122132554.GG10065@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <1390227608-7225-2-git-send-email-cyliu@suse.com>
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 <wdongxu@linux.vnet.ibm.com>
> Signed-off-by: Chunyan Liu <cyliu@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
next prev parent reply other threads:[~2014-01-22 14:23 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-20 14:19 [Qemu-devel] [v19 00/25] replace QEMUOptionParameter with QemuOpts Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 01/25] add def_value_str to QemuOptDesc Chunyan Liu
2014-01-22 13:25 ` Kevin Wolf [this message]
2014-01-20 14:19 ` [Qemu-devel] [v19 02/25] qapi: output def_value_str when query command line options Chunyan Liu
2014-01-20 15:53 ` Eric Blake
2014-01-20 14:19 ` [Qemu-devel] [v19 03/25] improve some functions in qemu-option.c Chunyan Liu
2014-01-22 13:33 ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 04/25] add some QemuOpts functions for replace work Chunyan Liu
2014-01-22 13:57 ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 05/25] change block layer to support both QemuOpts and QEMUOptionParameter Chunyan Liu
2014-01-22 14:19 ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 06/25] cow.c: replace QEMUOptionParameter with QemuOpts Chunyan Liu
2014-01-22 14:20 ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 07/25] gluster.c: " Chunyan Liu
2014-01-22 13:10 ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 08/25] iscsi.c: replace QEMUOptionParamter " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 09/25] qcow.c: " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 10/25] qcow2.c: replace QEMUOptionParameter with QemuOpts in create Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 11/25] qcow2.c: replace QEMUOptionParameter with QemuOpts in amend options Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 12/25] qed.c: replace QEMUOptionParameter with QemuOpts Chunyan Liu
2014-01-22 14:24 ` Kevin Wolf
2014-01-20 14:19 ` [Qemu-devel] [v19 13/25] raw-posix.c: " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 14/25] raw-win32.c: " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 15/25] rbd.c: " Chunyan Liu
2014-01-20 14:19 ` [Qemu-devel] [v19 16/25] sheepdog.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 17/25] ssh.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 18/25] vdi.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 19/25] vmdk.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 20/25] vpc.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 21/25] raw_bsd.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 22/25] vhdx.c: " Chunyan Liu
2014-01-22 14:26 ` Kevin Wolf
2014-01-20 14:20 ` [Qemu-devel] [v19 23/25] vvfat.c: " Chunyan Liu
2014-01-20 14:20 ` [Qemu-devel] [v19 24/25] cleanup QEMUOptionParameter Chunyan Liu
2014-01-22 14:33 ` Kevin Wolf
2014-01-20 14:20 ` [Qemu-devel] [v19 25/25] change back to original name from bdrv_create2 to bdrv_create Chunyan Liu
2014-01-22 14:35 ` [Qemu-devel] [v19 00/25] replace QEMUOptionParameter with QemuOpts Kevin Wolf
2014-01-22 16:11 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140122132554.GG10065@dhcp-200-207.str.redhat.com \
--to=kwolf@redhat.com \
--cc=cyliu@suse.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wdongxu@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).