block: Forbid trying to change unsupported options during reopen
commit57f9db9a947f4d32bbd56ed9b1e0989f6c306dfb
authorAlberto Garcia <berto@igalia.com>
Thu, 6 Sep 2018 09:37:06 +0000 (6 12:37 +0300)
committerKevin Wolf <kwolf@redhat.com>
Mon, 1 Oct 2018 10:51:12 +0000 (1 12:51 +0200)
treeee9788dc1fce8f718f27a0e2cfd0d5319c9e78c2
parentdb905283b8084f168d239b2d7bfbf3e2f01ed50f
block: Forbid trying to change unsupported options during reopen

The bdrv_reopen_prepare() function checks all options passed to each
BlockDriverState (in the reopen_state->options QDict) and makes all
necessary preparations to apply the option changes requested by the
user.

Options are removed from the QDict as they are processed, so at the
end of bdrv_reopen_prepare() only the options that can't be changed
are left. Then a loop goes over all remaining options and verifies
that the old and new values are identical, returning an error if
they're not.

The problem is that at the moment there are options that are removed
from the QDict although they can't be changed. The consequence of this
is any modification to any of those options is silently ignored:

   (qemu) qemu-io virtio0 "reopen -o discard=on"

This happens when all options from bdrv_runtime_opts are removed
from the QDict but then only a few of them are processed. Since
it's especially important that "node-name" and "driver" are not
changed, the code puts them back into the QDict so they are checked
at the end of the function. Instead of putting only those two options
back into the QDict, this patch puts all unprocessed options using
qemu_opts_to_qdict().

update_flags_from_options() also needs to be modified to prevent
BDRV_OPT_CACHE_NO_FLUSH, BDRV_OPT_CACHE_DIRECT and BDRV_OPT_READ_ONLY
from going back to the QDict.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c