qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: sheepdog@lists.wpkg.org, hch@lst.de, kvm@vger.kernel.org,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] add support for protocol driver	create_options
Date: Tue, 25 May 2010 15:43:17 +0200	[thread overview]
Message-ID: <4BFBD3F5.5020805@redhat.com> (raw)
In-Reply-To: <87bpc524gm.wl%morita.kazutaka@lab.ntt.co.jp>

Am 24.05.2010 08:34, schrieb MORITA Kazutaka:
> At Fri, 21 May 2010 18:57:36 +0200,
> Kevin Wolf wrote:
>>
>> Am 20.05.2010 07:36, schrieb MORITA Kazutaka:
>>> +
>>> +/*
>>> + * Append an option list (list) to an option list (dest).
>>> + *
>>> + * If dest is NULL, a new copy of list is created.
>>> + *
>>> + * Returns a pointer to the first element of dest (or the newly allocated copy)
>>> + */
>>> +QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest,
>>> +    QEMUOptionParameter *list)
>>> +{
>>> +    size_t num_options, num_dest_options;
>>> +
>>> +    num_options = count_option_parameters(dest);
>>> +    num_dest_options = num_options;
>>> +
>>> +    num_options += count_option_parameters(list);
>>> +
>>> +    dest = qemu_realloc(dest, (num_options + 1) * sizeof(QEMUOptionParameter));
>>> +
>>> +    while (list && list->name) {
>>> +        if (get_option_parameter(dest, list->name) == NULL) {
>>> +            dest[num_dest_options++] = *list;
>>
>> You need to add a dest[num_dest_options].name = NULL; here. Otherwise
>> the next loop iteration works on uninitialized memory and possibly an
>> unterminated list. I got a segfault for that reason.
>>
> 
> I forgot to add it, sorry.
> Fixed version is below.
> 
> Thanks,
> 
> Kazutaka
> 
> ==
> This patch enables protocol drivers to use their create options which
> are not supported by the format.  For example, protcol drivers can use
> a backing_file option with raw format.
> 
> Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>

$ ./qemu-img create -f qcow2 -o cluster_size=4k /tmp/test.qcow2 4G
Unknown option 'cluster_size'
qemu-img: Invalid options for file format 'qcow2'.

I think you added another num_dest_options++ which shouldn't be there.

Kevin

  reply	other threads:[~2010-05-25 13:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-20  5:36 [Qemu-devel] [PATCH] add support for protocol driver create_options MORITA Kazutaka
2010-05-20  5:40 ` [Qemu-devel] Kvm device passthrough Mu Lin
2010-05-21 11:40 ` [Qemu-devel] Re: [PATCH] add support for protocol driver create_options Kevin Wolf
2010-05-24  6:21   ` MORITA Kazutaka
2010-05-21 16:57 ` Kevin Wolf
2010-05-24  6:34   ` MORITA Kazutaka
2010-05-25 13:43     ` Kevin Wolf [this message]
2010-05-26  2:35       ` MORITA Kazutaka
2010-05-26  9:02         ` Kevin Wolf

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=4BFBD3F5.5020805@redhat.com \
    --to=kwolf@redhat.com \
    --cc=hch@lst.de \
    --cc=kvm@vger.kernel.org \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=sheepdog@lists.wpkg.org \
    /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).