From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHYth-0006DV-Ls for qemu-devel@nongnu.org; Mon, 18 Mar 2013 08:10:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHYtV-0005o9-Pi for qemu-devel@nongnu.org; Mon, 18 Mar 2013 08:10:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHYtV-0005o2-Gn for qemu-devel@nongnu.org; Mon, 18 Mar 2013 08:10:25 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2ICAPJX013623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Mar 2013 08:10:25 -0400 From: Kevin Wolf Date: Mon, 18 Mar 2013 13:10:18 +0100 Message-Id: <1363608618-14961-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: Fix segfault in qcow2_invalidate_cache List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com 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)); qemu_opts_del(opts); @@ -934,6 +935,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs) AES_KEY aes_encrypt_key; AES_KEY aes_decrypt_key; uint32_t crypt_method = 0; + QDict *options; /* * Backing files are read-only which makes all of their metadata immutable, @@ -948,8 +950,14 @@ static void qcow2_invalidate_cache(BlockDriverState *bs) qcow2_close(bs); + options = qdict_new(); + qdict_put(options, QCOW2_OPT_LAZY_REFCOUNTS, + qbool_from_int(s->use_lazy_refcounts)); + memset(s, 0, sizeof(BDRVQcowState)); - qcow2_open(bs, NULL, flags); + qcow2_open(bs, options, flags); + + QDECREF(options); if (crypt_method) { s->crypt_method = crypt_method; diff --git a/block/qcow2.h b/block/qcow2.h index 103abdb..e4b5e11 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -58,6 +58,9 @@ #define DEFAULT_CLUSTER_SIZE 65536 + +#define QCOW2_OPT_LAZY_REFCOUNTS "lazy_refcounts" + typedef struct QCowHeader { uint32_t magic; uint32_t version; -- 1.8.1.4