On Mon, Jun 14, 2010 at 3:43 PM, Kevin Wolf <kw...@redhat.com> wrote: > Instead of doing lots of magic for setting up initial refcount blocks and > stuff > create a minimal (inconsistent) image, open it and initialize the rest with > regular qcow2 functions.
Nice idea. > + ret = bdrv_pwrite(bs, 0, &header, sizeof(header)); > + if (ret < 0) { > + return ret; > + } The bs is not closed on error. Also, this function will leave a partially created file on disk if it fails. > + /* And if we're supposed to preallocate metadata, do that now */ > + if (prealloc) { > + preallocate(bs); > + } > + > + return 0; > +} The bs is leaked when the function succeeds. Stefan