From: John Snow <jsnow@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/2] qcow2: add overlap check for bitmap directory
Date: Wed, 6 Dec 2017 17:56:00 -0500 [thread overview]
Message-ID: <2291b175-1d72-1c85-9767-bf8dbaeedef5@redhat.com> (raw)
In-Reply-To: <20171130164750.47320-2-vsementsov@virtuozzo.com>
On 11/30/2017 11:47 AM, Vladimir Sementsov-Ogievskiy wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> block/qcow2.h | 7 +++++--
> block/qcow2-refcount.c | 12 ++++++++++++
> block/qcow2.c | 6 ++++++
> 3 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/block/qcow2.h b/block/qcow2.h
> index 6f0ff15dd0..8f226a3609 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -98,6 +98,7 @@
> #define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE "overlap-check.snapshot-table"
> #define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1"
> #define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2"
> +#define QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY "overlap-check.bitmap-directory"
> #define QCOW2_OPT_CACHE_SIZE "cache-size"
> #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size"
> #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size"
> @@ -406,8 +407,9 @@ typedef enum QCow2MetadataOverlap {
> QCOW2_OL_SNAPSHOT_TABLE_BITNR = 5,
> QCOW2_OL_INACTIVE_L1_BITNR = 6,
> QCOW2_OL_INACTIVE_L2_BITNR = 7,
> + QCOW2_OL_BITMAP_DIRECTORY_BITNR = 8,
>
> - QCOW2_OL_MAX_BITNR = 8,
> + QCOW2_OL_MAX_BITNR = 9,
>
> QCOW2_OL_NONE = 0,
> QCOW2_OL_MAIN_HEADER = (1 << QCOW2_OL_MAIN_HEADER_BITNR),
> @@ -420,12 +422,13 @@ typedef enum QCow2MetadataOverlap {
> /* NOTE: Checking overlaps with inactive L2 tables will result in bdrv
> * reads. */
> QCOW2_OL_INACTIVE_L2 = (1 << QCOW2_OL_INACTIVE_L2_BITNR),
> + QCOW2_OL_BITMAP_DIRECTORY = (1 << QCOW2_OL_BITMAP_DIRECTORY_BITNR),
> } QCow2MetadataOverlap;
>
> /* Perform all overlap checks which can be done in constant time */
> #define QCOW2_OL_CONSTANT \
> (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_REFCOUNT_TABLE | \
> - QCOW2_OL_SNAPSHOT_TABLE)
> + QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_BITMAP_DIRECTORY)
>
> /* Perform all overlap checks which don't require disk access */
> #define QCOW2_OL_CACHED \
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 3de1ab51ba..a7a2703f26 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -2585,6 +2585,18 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,
> }
> }
>
> + if ((chk & QCOW2_OL_BITMAP_DIRECTORY) &&
> + (s->autoclear_features & QCOW2_AUTOCLEAR_BITMAPS))
> + {
> + /* update_ext_header_and_dir_in_place firstly drop autoclear flag,
> + * so it will not fail */
> + if (overlaps_with(s->bitmap_directory_offset,
> + s->bitmap_directory_size))
> + {
> + return QCOW2_OL_BITMAP_DIRECTORY;
> + }
> + }
> +
Isn't the purpose of this function to test if a given offset conflicts
with known regions of the file? I don't see you actually utilize the
'offset' parameter here, but maybe I don't understand what you're trying
to accomplish.
> return 0;
> }
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 1914a940e5..8278c0e124 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -655,6 +655,11 @@ static QemuOptsList qcow2_runtime_opts = {
> .help = "Check for unintended writes into an inactive L2 table",
> },
> {
> + .name = QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY,
> + .type = QEMU_OPT_BOOL,
> + .help = "Check for unintended writes into the bitmap directory",
> + },
> + {
> .name = QCOW2_OPT_CACHE_SIZE,
> .type = QEMU_OPT_SIZE,
> .help = "Maximum combined metadata (L2 tables and refcount blocks) "
> @@ -690,6 +695,7 @@ static const char *overlap_bool_option_names[QCOW2_OL_MAX_BITNR] = {
> [QCOW2_OL_SNAPSHOT_TABLE_BITNR] = QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE,
> [QCOW2_OL_INACTIVE_L1_BITNR] = QCOW2_OPT_OVERLAP_INACTIVE_L1,
> [QCOW2_OL_INACTIVE_L2_BITNR] = QCOW2_OPT_OVERLAP_INACTIVE_L2,
> + [QCOW2_OL_BITMAP_DIRECTORY_BITNR] = QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY,
> };
>
> static void cache_clean_timer_cb(void *opaque)
>
next prev parent reply other threads:[~2017-12-06 22:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 16:47 [Qemu-devel] [PATCH for-2.12 0/2] qcow2: add overlap check for bitmap directory Vladimir Sementsov-Ogievskiy
2017-11-30 16:47 ` [Qemu-devel] [PATCH 1/2] " Vladimir Sementsov-Ogievskiy
2017-12-01 17:59 ` Eric Blake
2017-12-06 22:56 ` John Snow [this message]
[not found] ` <2af21d5f-3ad9-3492-03ea-c720929c4e36@virtuozzo.com>
2017-12-07 17:03 ` [Qemu-devel] [Qemu-block] " John Snow
2018-01-29 15:34 ` [Qemu-devel] " Max Reitz
2018-02-02 12:07 ` Vladimir Sementsov-Ogievskiy
2018-02-02 13:00 ` Max Reitz
2018-02-02 13:48 ` Vladimir Sementsov-Ogievskiy
2018-02-02 13:53 ` Max Reitz
2018-02-02 14:28 ` Vladimir Sementsov-Ogievskiy
2017-11-30 16:47 ` [Qemu-devel] [PATCH 2/2] qcow2: fix indentation after previous patch Vladimir Sementsov-Ogievskiy
2017-12-01 17:56 ` Eric Blake
2017-12-08 18:53 ` [Qemu-devel] [Qemu-block] " John Snow
2018-03-16 22:21 ` [Qemu-devel] [Qemu-block] [PATCH for-2.12 0/2] qcow2: add overlap check for bitmap directory John Snow
2018-03-19 6:49 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2291b175-1d72-1c85-9767-bf8dbaeedef5@redhat.com \
--to=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).