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 <[email protected]> > --- > 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 <[email protected]>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
