@@ -895,6 +895,12 @@ static QemuOptsList bdrv_runtime_opts = {
.type = QEMU_OPT_BOOL,
.help = "Ignore flush requests",
},
+ {
+ .name = "vmstate",
+ .type = QEMU_OPT_BOOL,
+ .help = "Allow to to save VM state to this block device",
+ .def_value_str = "on",
+ },
{ /* end of list */ }
},
};
@@ -957,6 +963,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
bs->zero_beyond_eof = true;
open_flags = bdrv_open_flags(bs, flags);
bs->read_only = !(open_flags & BDRV_O_RDWR);
+ bs->enable_vmstate = qemu_opt_get_bool(opts, "vmstate", true);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
error_setg(errp,
@@ -498,6 +498,12 @@ BlockDriverState *bdrv_all_find_vmstate_bs(const char *device, Error **errp)
device);
return NULL;
}
+ if (!bs->enable_vmstate) {
+ error_setg(errp,
+ "It is not allowed to save VM state to the device '%s'",
+ device);
+ return NULL;
+ }
ctx = bdrv_get_aio_context(bs);
@@ -515,6 +521,10 @@ BlockDriverState *bdrv_all_find_vmstate_bs(const char *device, Error **errp)
while (not_found && (bs = bdrv_next(bs))) {
ctx = bdrv_get_aio_context(bs);
+ if (!bs->enable_vmstate) {
+ continue;
+ }
+
aio_context_acquire(ctx);
not_found = !bdrv_can_snapshot(bs);
aio_context_release(ctx);
@@ -438,6 +438,9 @@ struct BlockDriverState {
/* do we need to tell the quest if we have a volatile write cache? */
int enable_write_cache;
+ /* allow to save VM state on snapshot here */
+ bool enable_vmstate;
+
/* the following member gives a name to every node on the bs graph. */
char node_name[32];
/* element of the list of named nodes building the graph */
@@ -1583,6 +1583,8 @@
# statistics, in seconds (default: none) (Since 2.5)
# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
# (default: off)
+# @vmstate: #optional allow to save VM state to this device (Since 2.6)
+# (default: on)
#
# Since: 1.7
##
@@ -1599,7 +1601,8 @@
'*stats-account-invalid': 'bool',
'*stats-account-failed': 'bool',
'*stats-intervals': ['int'],
- '*detect-zeroes': 'BlockdevDetectZeroesOptions' } }
+ '*detect-zeroes': 'BlockdevDetectZeroesOptions',
+ '*vmstate': 'bool' } }
##
# @BlockdevOptionsFile
Some block drives like PFLASH ones in OVFM setup are not suitable for VM state saving. Allow option to ban them in this selection. Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Kevin Wolf <kwolf@redhat.com> CC: Markus Armbruster <armbru@redhat.com> CC: Eric Blake <eblake@redhat.com> CC: Juan Quintela <quintela@redhat.com> CC: Amit Shah <amit.shah@redhat.com> --- Changes from v5: - added to vmstate option to blkdev JSON block.c | 7 +++++++ block/snapshot.c | 10 ++++++++++ include/block/block_int.h | 3 +++ qapi/block-core.json | 5 ++++- 4 files changed, 24 insertions(+), 1 deletion(-)