From: Kevin Wolf <kwolf@redhat.com>
To: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH V10 3/4] Use QemuOpts support in block layer
Date: Tue, 15 Jan 2013 13:28:54 +0100 [thread overview]
Message-ID: <50F54B86.2090802@redhat.com> (raw)
In-Reply-To: <1357536383-7299-4-git-send-email-wdongxu@linux.vnet.ibm.com>
Am 07.01.2013 06:26, schrieb Dong Xu Wang:
> This patch will use QemuOpts related functions in block layer, add
> a member bdrv_create_options to BlockDriver struct, it will return
> a QemuOptsList pointer, which includes the image format's create
> options.
>
> And create options's primary consumer is block creating related functions,
> so modify them together.
>
> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
> diff --git a/block/qcow.c b/block/qcow.c
> index 4276610..46aad7f 100644
> --- a/block/qcow.c
> +++ b/block/qcow.c
> @@ -651,7 +651,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)
> {
> int header_size, backing_filename_len, l1_size, shift, i;
> QCowHeader header;
> @@ -662,19 +662,16 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options)
> int ret;
> 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;
> + /* Read out opts */
> + if (opts) {
Can opts ever be NULL? (Same question for all other block drivers)
> + total_size = qemu_opt_get_number(opts, BLOCK_OPT_SIZE, 0) / 512;
> + backing_file = qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE);
> + if (qemu_opt_get_bool(opts, BLOCK_OPT_ENCRYPT, 0)) {
> + flags |= BLOCK_FLAG_ENCRYPT;
> }
> - options++;
> }
>
> - ret = bdrv_create_file(filename, options);
> + ret = bdrv_create_file(filename, NULL);
Why is this change correct?
Previously you could pass options to the protocol that are not supported
by the file format. For example, you can specify a backing file for raw
over sheepdog. Interestingly you keep this correct behaviour for raw,
but you seem to break it for other image formats.
> if (ret < 0) {
> return ret;
> }
Kevin
next prev parent reply other threads:[~2013-01-15 12:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-07 5:26 [Qemu-devel] [PATCH V10 0/4] replace QEMUOptionParameter with QemuOpts parser Dong Xu Wang
2013-01-07 5:26 ` [Qemu-devel] [PATCH V10 1/4] add def_print_str and use it in qemu_opts_print Dong Xu Wang
2013-01-15 11:08 ` Kevin Wolf
2013-01-07 5:26 ` [Qemu-devel] [PATCH V10 2/4] Create four opts list related functions Dong Xu Wang
2013-01-07 5:26 ` [Qemu-devel] [PATCH V10 3/4] Use QemuOpts support in block layer Dong Xu Wang
2013-01-14 8:50 ` Dong Xu Wang
2013-01-15 12:28 ` Kevin Wolf [this message]
2013-01-07 5:26 ` [Qemu-devel] [PATCH V10 4/4] remove QEMUOptionParameter related functions and struct Dong Xu Wang
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=50F54B86.2090802@redhat.com \
--to=kwolf@redhat.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).