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 at 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 |