[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH] add support for protocol driver create_options
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] Re: [PATCH] add support for protocol driver create_options |
Date: |
Wed, 26 May 2010 11:02:18 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc12 Thunderbird/3.0.4 |
Am 26.05.2010 04:35, schrieb MORITA Kazutaka:
> At Tue, 25 May 2010 15:43:17 +0200,
> Kevin Wolf wrote:
>>
>> 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 <address@hidden>
>>
>> $ ./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.
>>
>
> Sorry again. I wrongly added `dest[num_dest_options++].name = NULL;'
> instead of `dest[num_dest_options].name = NULL;'.
Thanks, now it looks good and passes all qemu-iotests tests again.
Applied the patch to the block branch.
Kevin