From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJg5f-0005HD-Ku for qemu-devel@nongnu.org; Thu, 14 Jan 2016 06:29:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJg5e-0007Mm-LO for qemu-devel@nongnu.org; Thu, 14 Jan 2016 06:29:19 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:4977 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJg5e-0007Ma-8F for qemu-devel@nongnu.org; Thu, 14 Jan 2016 06:29:18 -0500 From: "Denis V. Lunev" Date: Thu, 14 Jan 2016 14:29:01 +0300 Message-Id: <1452770941-21582-9-git-send-email-den@openvz.org> In-Reply-To: <1452770941-21582-1-git-send-email-den@openvz.org> References: <1452770941-21582-1-git-send-email-den@openvz.org> Subject: [Qemu-devel] [PATCH 8/8] block: allow to skip block driver in selection of one for VM state saving List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "Denis V. Lunev" , qemu-devel@nongnu.org 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 CC: Kevin Wolf --- block.c | 7 +++++++ block/snapshot.c | 10 ++++++++++ include/block/block_int.h | 3 +++ 3 files changed, 20 insertions(+) diff --git a/block.c b/block.c index 01655de..c36393f 100644 --- a/block.c +++ b/block.c @@ -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 select to save VM state", + .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, diff --git a/block/snapshot.c b/block/snapshot.c index 237a015..eb73c76 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -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); diff --git a/include/block/block_int.h b/include/block/block_int.h index 256609d..a30b576 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -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 */ -- 2.5.0