From patchwork Thu Dec 6 13:32:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 204236 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 E97DB2C0131 for ; Fri, 7 Dec 2012 01:06:20 +1100 (EST) Received: from localhost ([::1]:57591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgbaQ-0004Ax-PK for incoming@patchwork.ozlabs.org; Thu, 06 Dec 2012 08:33:58 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgbZt-0003cm-6t for qemu-devel@nongnu.org; Thu, 06 Dec 2012 08:33:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TgbZb-0003YO-8O for qemu-devel@nongnu.org; Thu, 06 Dec 2012 08:33:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgbZb-0003Y7-0c for qemu-devel@nongnu.org; Thu, 06 Dec 2012 08:33:07 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qB6DX54I008036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Dec 2012 08:33:05 -0500 Received: from dhcp-5-188.str.redhat.com (vpn1-5-119.ams2.redhat.com [10.36.5.119]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qB6DX19A001149; Thu, 6 Dec 2012 08:33:04 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Thu, 6 Dec 2012 14:32:56 +0100 Message-Id: <1354800780-10683-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1354800780-10683-1-git-send-email-kwolf@redhat.com> References: <1354800780-10683-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 2/6] blkdebug: Factor out remove_rule() 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 The cleanup work to remove a rule depends on the type of the rule. It's easy for the existing rules as there is no data that must be cleaned up and is specific to a type yet, but the next patch will change this. Signed-off-by: Kevin Wolf --- block/blkdebug.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index c9041ec..859792b 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -234,6 +234,18 @@ static int add_rule(QemuOpts *opts, void *opaque) return 0; } +static void remove_rule(BlkdebugRule *rule) +{ + switch (rule->action) { + case ACTION_INJECT_ERROR: + case ACTION_SET_STATE: + break; + } + + QLIST_REMOVE(rule, next); + g_free(rule); +} + static int read_config(BDRVBlkdebugState *s, const char *filename) { FILE *f; @@ -402,8 +414,7 @@ static void blkdebug_close(BlockDriverState *bs) for (i = 0; i < BLKDBG_EVENT_MAX; i++) { QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) { - QLIST_REMOVE(rule, next); - g_free(rule); + remove_rule(rule); } } }