From patchwork Mon Jan 18 09:19:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 8053581 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D3E5D9F8AA for ; Mon, 18 Jan 2016 09:20:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 24D242026D for ; Mon, 18 Jan 2016 09:20:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EFD4E20220 for ; Mon, 18 Jan 2016 09:20:20 +0000 (UTC) Received: from localhost ([::1]:58432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aL5z2-0007AM-4c for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Jan 2016 04:20:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aL5yv-0007AF-B7 for qemu-devel@nongnu.org; Mon, 18 Jan 2016 04:20:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aL5yr-0003KW-9R for qemu-devel@nongnu.org; Mon, 18 Jan 2016 04:20:13 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:33876 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aL5yq-0003E5-RO for qemu-devel@nongnu.org; Mon, 18 Jan 2016 04:20:09 -0500 Received: from hades.sw.ru ([10.30.8.132]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id u0H7hOrP007511; Sun, 17 Jan 2016 10:43:26 +0300 (MSK) From: "Denis V. Lunev" To: Date: Mon, 18 Jan 2016 12:19:42 +0300 Message-Id: <1453108782-29522-1-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452770941-21582-9-git-send-email-den@openvz.org> References: <1452770941-21582-9-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Cc: Kevin Wolf , Juan Quintela , qemu-devel@nongnu.org, Markus Armbruster , Amit Shah , "Denis V. Lunev" Subject: [Qemu-devel] [PATCH v6 8/8] block: allow to skip block driver in selection of one for VM state saving X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 CC: Markus Armbruster CC: Eric Blake CC: Juan Quintela CC: Amit Shah --- 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(-) diff --git a/block.c b/block.c index 01655de..08c1db6 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 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, 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 */ diff --git a/qapi/block-core.json b/qapi/block-core.json index 0a915ed..d04453f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -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