qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH v6 5/9] block: Add bdrv_filename()


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH v6 5/9] block: Add bdrv_filename()
Date: Mon, 16 Jan 2017 15:33:14 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

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 <address@hidden>
> ---
>  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 <address@hidden>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]