|
|
218e99 |
From c5321890678045bf4de3b1845110aeed348203b9 Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
Date: Mon, 4 Nov 2013 22:32:34 +0100
|
|
|
218e99 |
Subject: [PATCH 41/87] qcow2: Evaluate overlap check options
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
Message-id: <1383604354-12743-44-git-send-email-mreitz@redhat.com>
|
|
|
218e99 |
Patchwork-id: 55343
|
|
|
218e99 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 43/43] qcow2: Evaluate overlap check options
|
|
|
218e99 |
Bugzilla: 1004347
|
|
|
218e99 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
BZ: 1004347
|
|
|
218e99 |
|
|
|
218e99 |
Evaluate the runtime overlap check options and set
|
|
|
218e99 |
BDRVQcowState.overlap_check appropriately.
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
(cherry picked from commit 1fa5cc839aa6068c9182ad8d611f844c58f95f42)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block/qcow2.c | 29 ++++++++++++++++++++++++++++-
|
|
|
218e99 |
1 file changed, 28 insertions(+), 1 deletion(-)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block/qcow2.c | 29 ++++++++++++++++++++++++++++-
|
|
|
218e99 |
1 files changed, 28 insertions(+), 1 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
218e99 |
index b6f300d..01b535d 100644
|
|
|
218e99 |
--- a/block/qcow2.c
|
|
|
218e99 |
+++ b/block/qcow2.c
|
|
|
218e99 |
@@ -425,6 +425,8 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
218e99 |
Error *local_err = NULL;
|
|
|
218e99 |
uint64_t ext_end;
|
|
|
218e99 |
uint64_t l1_vm_state_index;
|
|
|
218e99 |
+ const char *opt_overlap_check;
|
|
|
218e99 |
+ int overlap_check_template = 0;
|
|
|
218e99 |
|
|
|
218e99 |
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
|
|
|
218e99 |
if (ret < 0) {
|
|
|
218e99 |
@@ -687,7 +689,32 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
218e99 |
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
|
|
|
218e99 |
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
|
|
|
218e99 |
|
|
|
218e99 |
- s->overlap_check = QCOW2_OL_CACHED;
|
|
|
218e99 |
+ opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached";
|
|
|
218e99 |
+ if (!strcmp(opt_overlap_check, "none")) {
|
|
|
218e99 |
+ overlap_check_template = 0;
|
|
|
218e99 |
+ } else if (!strcmp(opt_overlap_check, "constant")) {
|
|
|
218e99 |
+ overlap_check_template = QCOW2_OL_CONSTANT;
|
|
|
218e99 |
+ } else if (!strcmp(opt_overlap_check, "cached")) {
|
|
|
218e99 |
+ overlap_check_template = QCOW2_OL_CACHED;
|
|
|
218e99 |
+ } else if (!strcmp(opt_overlap_check, "all")) {
|
|
|
218e99 |
+ overlap_check_template = QCOW2_OL_ALL;
|
|
|
218e99 |
+ } else {
|
|
|
218e99 |
+ error_setg(errp, "Unsupported value '%s' for qcow2 option "
|
|
|
218e99 |
+ "'overlap-check'. Allowed are either of the following: "
|
|
|
218e99 |
+ "none, constant, cached, all", opt_overlap_check);
|
|
|
218e99 |
+ qemu_opts_del(opts);
|
|
|
218e99 |
+ ret = -EINVAL;
|
|
|
218e99 |
+ goto fail;
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+
|
|
|
218e99 |
+ s->overlap_check = 0;
|
|
|
218e99 |
+ for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
|
|
|
218e99 |
+ /* overlap-check defines a template bitmask, but every flag may be
|
|
|
218e99 |
+ * overwritten through the associated boolean option */
|
|
|
218e99 |
+ s->overlap_check |=
|
|
|
218e99 |
+ qemu_opt_get_bool(opts, overlap_bool_option_names[i],
|
|
|
218e99 |
+ overlap_check_template & (1 << i)) << i;
|
|
|
218e99 |
+ }
|
|
|
218e99 |
|
|
|
218e99 |
qemu_opts_del(opts);
|
|
|
218e99 |
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|