On 01/13/2017 02:52 PM, Max Reitz wrote: > Split the part which actually refreshes the BlockDriverState.filename > field off of bdrv_refresh_filename() into a more generic function > bdrv_filename(), which first calls bdrv_refresh_filename() and then > stores a qemu-usable filename in the given buffer instead of > BlockDriverState.filename. > > Since bdrv_refresh_filename() therefore no longer refreshes that field, > all of the existing calls to that function have to be replaced by calls > to bdrv_filename() "manually" refreshing the BDS filename field (this is > only temporary). > > Signed-off-by: Max Reitz <[email protected]> > --- > include/block/block.h | 1 + > block.c | 50 +++++++++++++++++++++++++++++++++++++++++--------- > block/replication.c | 2 +- > blockdev.c | 3 ++- > 4 files changed, 45 insertions(+), 11 deletions(-) >
> + > +/* First refreshes exact_filename and full_open_options by calling > + * bdrv_refresh_filename(). Then, if exact_filename is set, it is copied into > + * the target buffer. Otherwise, full_open_options is converted to a JSON > + * object, prefixed with "json:" (for use through the JSON pseudo protocol) > and > + * put there. > + * > + * If @dest is not NULL, the filename will be truncated to @sz - 1 bytes and > + * placed there. If @sz > 0, it will always be null-terminated. > + * > + * If @dest is NULL, @sz is ignored and a new buffer will be allocated which > is > + * large enough to hold the filename and the trailing '\0'. This buffer is > then > + * returned and has to be freed by the caller when it is no longer needed. > + * > + * Returns @dest if it is not NULL, and the newly allocated buffer otherwise. > + */ > +char *bdrv_filename(BlockDriverState *bs, char *dest, size_t sz) Seems like a reasonable interface. Reviewed-by: Eric Blake <[email protected]> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
