From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHZvC-0002cg-O6 for qemu-devel@nongnu.org; Mon, 18 Mar 2013 09:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHZv8-0002U3-7l for qemu-devel@nongnu.org; Mon, 18 Mar 2013 09:16:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHZv7-0002Tw-Vj for qemu-devel@nongnu.org; Mon, 18 Mar 2013 09:16:10 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2IDG9Ho016072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Mar 2013 09:16:09 -0400 Date: Mon, 18 Mar 2013 14:16:05 +0100 From: Kevin Wolf Message-ID: <20130318131605.GD2476@dhcp-200-207.str.redhat.com> References: <1363608618-14961-1-git-send-email-kwolf@redhat.com> <51470B32.8080004@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51470B32.8080004@redhat.com> Subject: Re: [Qemu-devel] [PATCH] qcow2: Fix segfault in qcow2_invalidate_cache List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, stefanha@redhat.com Am 18.03.2013 um 13:40 hat Paolo Bonzini geschrieben: > Il 18/03/2013 13:10, Kevin Wolf ha scritto: > > Need to pass an options QDict to qcow2_open() now. This fixes a segfault > > on the migration target with qcow2. > > > > Signed-off-by: Kevin Wolf > > --- > > block/qcow2.c | 12 ++++++++++-- > > block/qcow2.h | 3 +++ > > 2 files changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/block/qcow2.c b/block/qcow2.c > > index b90dd9e..7fcdc62 100644 > > --- a/block/qcow2.c > > +++ b/block/qcow2.c > > @@ -29,6 +29,7 @@ > > #include "block/qcow2.h" > > #include "qemu/error-report.h" > > #include "qapi/qmp/qerror.h" > > +#include "qapi/qmp/qbool.h" > > #include "trace.h" > > > > /* > > @@ -520,7 +521,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags) > > goto fail; > > } > > > > - s->use_lazy_refcounts = qemu_opt_get_bool(opts, "lazy_refcounts", > > + s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, > > (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); > > Why not add > > s->use_lazy_refcounts || > > to the default, and just use an empty QDict in qcow2_invalidate_cache? I think it's better not to depend on any previous state in qcow2_open(), but start from scratch with all options directly passed. Otherwise it would become easy to lose the overview over the data flow. Also, qcow2_invalidate_cache clears the state so that all other information in s is properly reset: memset(s, 0, sizeof(BDRVQcowState)); So s->use_lazy_refcounts doesn't even have it's old value any more. Kevin