From: Anthony Liguori <aliguori@us.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 08/28] qcow2: Allow lazy refcounts to be enabled on the command line
Date: Fri, 15 Mar 2013 12:35:18 -0500 [thread overview]
Message-ID: <87d2v0in1l.fsf@codemonkey.ws> (raw)
In-Reply-To: <5143541B.3020407@redhat.com>
Paolo Bonzini <pbonzini@redhat.com> writes:
> Il 15/03/2013 16:14, Stefan Hajnoczi ha scritto:
>> From: Kevin Wolf <kwolf@redhat.com>
>>
>> qcow2 images now accept a boolean lazy_refcounts options. Use it like
>> this:
>>
>> -drive file=test.qcow2,lazy_refcounts=on
>>
>> If the option is specified on the command line, it overrides the default
>> specified by the qcow2 header flags that were set when creating the
>> image.
>>
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>> ---
>> block/qcow2-cluster.c | 2 +-
>> block/qcow2.c | 37 +++++++++++++++++++++++++++++++++++++
>> block/qcow2.h | 1 +
>> 3 files changed, 39 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
>> index 56fccf9..ff9ae18 100644
>> --- a/block/qcow2-cluster.c
>> +++ b/block/qcow2-cluster.c
>> @@ -668,7 +668,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
>> }
>>
>> /* Update L2 table. */
>> - if (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS) {
>> + if (s->use_lazy_refcounts) {
>> qcow2_mark_dirty(bs);
>> }
>> if (qcow2_need_accurate_refcounts(s)) {
>> diff --git a/block/qcow2.c b/block/qcow2.c
>> index f5e4269..ad43a13 100644
>> --- a/block/qcow2.c
>> +++ b/block/qcow2.c
>> @@ -285,11 +285,26 @@ static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result,
>> return ret;
>> }
>>
>> +static QemuOptsList qcow2_runtime_opts = {
>> + .name = "qcow2",
>> + .head = QTAILQ_HEAD_INITIALIZER(qcow2_runtime_opts.head),
>> + .desc = {
>> + {
>> + .name = "lazy_refcounts",
>> + .type = QEMU_OPT_BOOL,
>> + .help = "Postpone refcount updates",
>> + },
>> + { /* end of list */ }
>> + },
>> +};
>> +
>> static int qcow2_open(BlockDriverState *bs, QDict *options, int flags)
>> {
>> BDRVQcowState *s = bs->opaque;
>> int len, i, ret = 0;
>> QCowHeader header;
>> + QemuOpts *opts;
>> + Error *local_err = NULL;
>> uint64_t ext_end;
>>
>> ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
>> @@ -495,6 +510,28 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags)
>> }
>> }
>>
>> + /* Enable lazy_refcounts according to image and command line options */
>> + opts = qemu_opts_create_nofail(&qcow2_runtime_opts);
>> + qemu_opts_absorb_qdict(opts, options, &local_err);
>
> This breaks migration with qcow2 images:
I already processed the pull unfortunately. I'm going to be offline for
most of the weekend but if there's a patch in the next hour to revert or
fix I can apply it.
Regards,
Anthony Liguori
>
> Program received signal SIGSEGV, Segmentation fault.
> qdict_next_entry (first_bucket=0, qdict=0x0) at /home/pbonzini/work/upstream/qemu/qobject/qdict.c:371
> 371 if (!QLIST_EMPTY(&qdict->table[i])) {
> (gdb) up
> #1 qdict_first (qdict=qdict@entry=0x0) at /home/pbonzini/work/upstream/qemu/qobject/qdict.c:384
> 384 return qdict_next_entry(qdict, 0);
> (gdb)
> #2 0x00007fb8edf75ae6 in qemu_opts_absorb_qdict (opts=opts@entry=0x7fb8f0651740, qdict=qdict@entry=0x0, errp=errp@entry=0x7fb8edc36e80)
> at /home/pbonzini/work/upstream/qemu/util/qemu-option.c:1078
> 1078 entry = qdict_first(qdict);
> (gdb)
> #3 0x00007fb8edd15074 in qcow2_open (bs=0x7fb8f041b800, options=0x0, flags=<optimized out>) at /home/pbonzini/work/upstream/qemu/block/qcow2.c:515
> 515 qemu_opts_absorb_qdict(opts, options, &local_err);
> (gdb)
> #4 0x00007fb8edd00352 in bdrv_invalidate_cache (bs=0x7fb8f041b800) at /home/pbonzini/work/upstream/qemu/block.c:4192
> 4192 bs->drv->bdrv_invalidate_cache(bs);
>
> Paolo
>
>> + if (error_is_set(&local_err)) {
>> + qerror_report_err(local_err);
>> + error_free(local_err);
>> + ret = -EINVAL;
>> + goto fail;
>> + }
>> +
>> + s->use_lazy_refcounts = qemu_opt_get_bool(opts, "lazy_refcounts",
>> + (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
>> +
>> + qemu_opts_del(opts);
>> +
>> + if (s->use_lazy_refcounts && s->qcow_version < 3) {
>> + qerror_report(ERROR_CLASS_GENERIC_ERROR, "Lazy refcounts require "
>> + "a qcow2 image with at least qemu 1.1 compatibility level");
>> + ret = -EINVAL;
>> + goto fail;
>> + }
>> +
>> #ifdef DEBUG_ALLOC
>> {
>> BdrvCheckResult result = {0};
>> diff --git a/block/qcow2.h b/block/qcow2.h
>> index 718b52b..103abdb 100644
>> --- a/block/qcow2.h
>> +++ b/block/qcow2.h
>> @@ -173,6 +173,7 @@ typedef struct BDRVQcowState {
>>
>> int flags;
>> int qcow_version;
>> + bool use_lazy_refcounts;
>>
>> uint64_t incompatible_features;
>> uint64_t compatible_features;
>>
next prev parent reply other threads:[~2013-03-15 17:36 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-15 15:13 [Qemu-devel] [PULL 00/28] Block patches Stefan Hajnoczi
2013-03-15 15:13 ` [Qemu-devel] [PATCH 01/28] block: Add options QDict to .bdrv_open() Stefan Hajnoczi
2013-03-15 15:13 ` [Qemu-devel] [PATCH 02/28] block: Add options QDict to bdrv_open() prototype Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 03/28] Add qdict_clone_shallow() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 04/28] block: Add options QDict to bdrv_open_common() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 05/28] qemu-option: Add qemu_opts_absorb_qdict() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 06/28] blockdev: Keep a copy of DriveInfo.serial Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 07/28] block: Support driver specific options in drive_init() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 08/28] qcow2: Allow lazy refcounts to be enabled on the command line Stefan Hajnoczi
2013-03-15 17:02 ` Paolo Bonzini
2013-03-15 17:35 ` Anthony Liguori [this message]
2013-03-15 15:14 ` [Qemu-devel] [PATCH 09/28] qcow2: flush refcount cache correctly in alloc_refcount_block() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 10/28] qcow2: flush refcount cache correctly in qcow2_write_snapshots() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 11/28] qcow2: set L2 cache dependency in qcow2_alloc_bytes() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 12/28] qcow2: flush in qcow2_update_snapshot_refcount() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 13/28] qcow2: drop flush in update_cluster_refcount() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 14/28] qcow2: drop unnecessary flush in qcow2_update_snapshot_refcount() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 15/28] qcow2: make is_allocated return true for zero clusters Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 16/28] sheepdog: use non-blocking fd in coroutine context Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 17/28] sheepdog: set io_flush handler in do_co_req Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 18/28] main-loop: add qemu_get_aio_context() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 19/28] threadpool: move globals into struct ThreadPool Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 20/28] threadpool: add thread_pool_new() and thread_pool_free() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 21/28] aio: add a ThreadPool instance to AioContext Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 22/28] block: add bdrv_get_aio_context() Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 23/28] threadpool: drop global thread pool Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 24/28] coroutine: use AioContext for CoQueue BH Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 25/28] dataplane: fix hang introduced by AioContext transition Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 26/28] qemu-iotests: add tests for rebasing zero clusters Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 27/28] qemu-iotests: use -nographic in test case 007 Stefan Hajnoczi
2013-03-15 15:14 ` [Qemu-devel] [PATCH 28/28] blockdev: Fix up copyright and permission notice Stefan Hajnoczi
2013-03-15 15:46 ` [Qemu-devel] [PULL 00/28] Block patches Anthony Liguori
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=87d2v0in1l.fsf@codemonkey.ws \
--to=aliguori@us.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).