Re: [PATCH] add support for protocol driver create_options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <morita.kazutaka@xxxxxxxxxxxxx>
>>
>> $ ./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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux