qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 16/18] blockdev: Split up 'cache' option


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 16/18] blockdev: Split up 'cache' option
Date: Fri, 26 Jul 2013 10:30:24 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 07/23/2013 07:03 AM, Kevin Wolf wrote:
> The old 'cache' option really encodes three different boolean flags into
> a cache mode name, without providing all combinations. Make them three
> separate options instead and translate the old option to the new ones
> for drive_init().
> 
> The specific boolean options take precedence if the old cache option is
> specified as well, so the following options are equivalent:
> 
> -drive file=x,cache=none,cache.no-flush=true
> -drive file=x,cache.writeback=true,cache.direct=true,cache.no-flush=true
> 
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
>  blockdev.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 47 insertions(+), 10 deletions(-)
> 

> +++ b/blockdev.c
> @@ -452,12 +452,15 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
>          }
>      }
>  
> -    bdrv_flags |= BDRV_O_CACHE_WB;
> -    if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
> -        if (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) {

The old code calls bdrv_parse_cache_flags() with non-zero bdrv_flags.

> @@ -751,6 +756,31 @@ DriveInfo *drive_init(QemuOpts *all_opts, 
> BlockInterfaceType block_default_type)
>  
>      qemu_opt_rename(all_opts, "readonly", "read-only");
>  
> +    value = qemu_opt_get(all_opts, "cache");
> +    if (value) {
> +        int flags = 0;
> +
> +        if (bdrv_parse_cache_flags(value, &flags) != 0) {

The new code calls it with flags starting at 0.  But looking at
bdrv_parse_cache_flags(), the first thing that code did was zero out
BDRV_O_CACHE_MASK, which includes BDRV_O_CACHE_WB, so I think that in
reality you still end up with the same bits set at the end of that parse
call.  Phew - that means you are actually getting rid of a dead |=
assignment.  [And you proved that the block code is a twisty maze of
back-compat hacks.]

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]