9ae3a8
From 08a3a60a9a3cdd4d67e858981e4446d8f1d31fe4 Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Mon, 4 Nov 2013 22:32:31 +0100
9ae3a8
Subject: [PATCH 38/87] qcow2: Add overlap-check options
9ae3a8
9ae3a8
RH-Author: Max Reitz <mreitz@redhat.com>
9ae3a8
Message-id: <1383604354-12743-41-git-send-email-mreitz@redhat.com>
9ae3a8
Patchwork-id: 55340
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm PATCH 40/43] qcow2: Add overlap-check options
9ae3a8
Bugzilla: 1004347
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
BZ: 1004347
9ae3a8
9ae3a8
Add runtime options to tune the overlap checks to be performed before
9ae3a8
write accesses.
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 05de7e86cab3ed3830de38b38b39bbc711bc1158)
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
---
9ae3a8
 block/qcow2.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
9ae3a8
 block/qcow2.h |  9 +++++++++
9ae3a8
 2 files changed, 55 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block/qcow2.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
9ae3a8
 block/qcow2.h |    9 +++++++++
9ae3a8
 2 files changed, 55 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/block/qcow2.c b/block/qcow2.c
9ae3a8
index 157361f..c47286f 100644
9ae3a8
--- a/block/qcow2.c
9ae3a8
+++ b/block/qcow2.c
9ae3a8
@@ -354,6 +354,52 @@ static QemuOptsList qcow2_runtime_opts = {
9ae3a8
             .type = QEMU_OPT_BOOL,
9ae3a8
             .help = "Generate discard requests when other clusters are freed",
9ae3a8
         },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP,
9ae3a8
+            .type = QEMU_OPT_STRING,
9ae3a8
+            .help = "Selects which overlap checks to perform from a range of "
9ae3a8
+                    "templates (none, constant, cached, all)",
9ae3a8
+        },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP_MAIN_HEADER,
9ae3a8
+            .type = QEMU_OPT_BOOL,
9ae3a8
+            .help = "Check for unintended writes into the main qcow2 header",
9ae3a8
+        },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP_ACTIVE_L1,
9ae3a8
+            .type = QEMU_OPT_BOOL,
9ae3a8
+            .help = "Check for unintended writes into the active L1 table",
9ae3a8
+        },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP_ACTIVE_L2,
9ae3a8
+            .type = QEMU_OPT_BOOL,
9ae3a8
+            .help = "Check for unintended writes into an active L2 table",
9ae3a8
+        },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP_REFCOUNT_TABLE,
9ae3a8
+            .type = QEMU_OPT_BOOL,
9ae3a8
+            .help = "Check for unintended writes into the refcount table",
9ae3a8
+        },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK,
9ae3a8
+            .type = QEMU_OPT_BOOL,
9ae3a8
+            .help = "Check for unintended writes into a refcount block",
9ae3a8
+        },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE,
9ae3a8
+            .type = QEMU_OPT_BOOL,
9ae3a8
+            .help = "Check for unintended writes into the snapshot table",
9ae3a8
+        },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP_INACTIVE_L1,
9ae3a8
+            .type = QEMU_OPT_BOOL,
9ae3a8
+            .help = "Check for unintended writes into an inactive L1 table",
9ae3a8
+        },
9ae3a8
+        {
9ae3a8
+            .name = QCOW2_OPT_OVERLAP_INACTIVE_L2,
9ae3a8
+            .type = QEMU_OPT_BOOL,
9ae3a8
+            .help = "Check for unintended writes into an inactive L2 table",
9ae3a8
+        },
9ae3a8
         { /* end of list */ }
9ae3a8
     },
9ae3a8
 };
9ae3a8
diff --git a/block/qcow2.h b/block/qcow2.h
9ae3a8
index d1fd91b..1bba3ed 100644
9ae3a8
--- a/block/qcow2.h
9ae3a8
+++ b/block/qcow2.h
9ae3a8
@@ -63,6 +63,15 @@
9ae3a8
 #define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request"
9ae3a8
 #define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot"
9ae3a8
 #define QCOW2_OPT_DISCARD_OTHER "pass-discard-other"
9ae3a8
+#define QCOW2_OPT_OVERLAP "overlap-check"
9ae3a8
+#define QCOW2_OPT_OVERLAP_MAIN_HEADER "overlap-check.main-header"
9ae3a8
+#define QCOW2_OPT_OVERLAP_ACTIVE_L1 "overlap-check.active-l1"
9ae3a8
+#define QCOW2_OPT_OVERLAP_ACTIVE_L2 "overlap-check.active-l2"
9ae3a8
+#define QCOW2_OPT_OVERLAP_REFCOUNT_TABLE "overlap-check.refcount-table"
9ae3a8
+#define QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK "overlap-check.refcount-block"
9ae3a8
+#define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE "overlap-check.snapshot-table"
9ae3a8
+#define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1"
9ae3a8
+#define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2"
9ae3a8
 
9ae3a8
 typedef struct QCowHeader {
9ae3a8
     uint32_t magic;
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8