From patchwork Wed Oct 17 15:17:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 192074 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5D3F82C0092 for ; Thu, 18 Oct 2012 02:18:27 +1100 (EST) Received: from localhost ([::1]:54558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOVO5-0004j8-Dj for incoming@patchwork.ozlabs.org; Wed, 17 Oct 2012 11:18:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOVNm-0004Kt-5y for qemu-devel@nongnu.org; Wed, 17 Oct 2012 11:18:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOVNa-0006cx-GJ for qemu-devel@nongnu.org; Wed, 17 Oct 2012 11:18:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOVNa-0006aV-8P for qemu-devel@nongnu.org; Wed, 17 Oct 2012 11:17:54 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9HFHq3Z012539 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Oct 2012 11:17:52 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9HFHmld002552; Wed, 17 Oct 2012 11:17:51 -0400 From: Avi Kivity To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2012 17:17:45 +0200 Message-Id: <1350487065-32022-3-git-send-email-avi@redhat.com> In-Reply-To: <1350487065-32022-1-git-send-email-avi@redhat.com> References: <1350487065-32022-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] memory: abort if a memory region is destroyed during a transaction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Destroying a memory region is illegal within a transaction, as until the transaction is committed, the memory core may hold references to the region. Add an assert to check for violations of this rule. Signed-off-by: Avi Kivity --- memory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/memory.c b/memory.c index d2f2fd6..94049a7 100644 --- a/memory.c +++ b/memory.c @@ -1022,6 +1022,7 @@ void memory_region_init_reservation(MemoryRegion *mr, void memory_region_destroy(MemoryRegion *mr) { assert(QTAILQ_EMPTY(&mr->subregions)); + assert(memory_region_transaction_depth == 0); mr->destructor(mr); memory_region_clear_coalescing(mr); g_free((char *)mr->name);