From patchwork Fri Jul 22 19:50:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 72643 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1174305qga; Fri, 22 Jul 2016 12:56:01 -0700 (PDT) X-Received: by 10.55.164.205 with SMTP id n196mr6389482qke.73.1469217361873; Fri, 22 Jul 2016 12:56:01 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o76si9688027qkh.212.2016.07.22.12.56.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jul 2016 12:56:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:49110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQgYD-0001LZ-Cn for patch@linaro.org; Fri, 22 Jul 2016 15:56:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQgTC-0005d5-G0 for qemu-devel@nongnu.org; Fri, 22 Jul 2016 15:50:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQgTB-00005l-5c for qemu-devel@nongnu.org; Fri, 22 Jul 2016 15:50:50 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:35948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQgTB-00005a-0r for qemu-devel@nongnu.org; Fri, 22 Jul 2016 15:50:49 -0400 Received: by mail-oi0-x243.google.com with SMTP id d204so11270058oig.3 for ; Fri, 22 Jul 2016 12:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NPG14DDqoHASVIauoy28eh7G31AK9XW6ESEJFpVmRK8=; b=Udg7hPs17JmZ6dFduuFmzzwnVGFwFxI+1hwFzVIo+XniqBqtwLYBxEUR3FSeGzQhix w5qGAKm2GaDaLYDReHZ4k5jDZwETLm+jtRGSHnqJver5GBMBuNhN57l6yTt+8RRuKTDn 2s84lqgtXvWgDA5LZGME8ihGMiB9K3YoQF1Bdz40o9NgcnIClYixT4EYvCCFEqKgX1uh H5pLFNDNf5VwnyqQk9KNRlrafSriFghW8IZP9kZQJKHFRhwsIxmKQwTx/U5k46Oy5X7s al3eMwnxwwGiG+OQLaunXx1bdK+W/Nn7KReEgLSOJOkCowDdBWD9qVwX3gZ+pb+gbSjq zYCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=NPG14DDqoHASVIauoy28eh7G31AK9XW6ESEJFpVmRK8=; b=Bz3AAhKNJc72GAxtseQMRbErSRKLA0AG+HCUda/mQbqZzfj481MBDXqtp0h+/cIWbx RxYO/EOqDmFus4NpwvtoS2FrsLP0w12d2hjB0gTjzeMYsvFm0osBjL7lJFF+L+FT5OXt pR/Uq0svxN1ZhSSmZp2QgBs3lol3HtZ0uJckxtXgvkZ/PlprsiXIrIV4lwU3V3DZL0yA aJwoZ/WfQaFTgVn8NeQqRU5y/YDSHMma3yB+M++2ZWNt9UqjhSUUOm+Tm3ZACyilISvY 3wZa2kWx8mJGfG6YVplVeRN6EpFe04OIwpST7EsBYPPo960PdL7uU0mIC+LpgunAcCPQ icQg== X-Gm-Message-State: AEkooutUg0lIjnae3YXUHRcISCqY5WW1VmLdoOIBj4WqTSWMqycDrnsxHIzObXPtunJVdA== X-Received: by 10.157.16.65 with SMTP id o1mr3169342oto.148.1469217048567; Fri, 22 Jul 2016 12:50:48 -0700 (PDT) Received: from serve.minyard.net ([173.64.235.97]) by smtp.gmail.com with ESMTPSA id d82sm5841775oia.14.2016.07.22.12.50.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jul 2016 12:50:47 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:c87e:7f7a:2ef0:2f10]) by serve.minyard.net (Postfix) with ESMTPA id 2E9961338; Fri, 22 Jul 2016 14:50:45 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 67D36302316; Fri, 22 Jul 2016 14:50:43 -0500 (CDT) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Fri, 22 Jul 2016 14:50:41 -0500 Message-Id: <1469217041-15358-5-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469217041-15358-1-git-send-email-minyard@acm.org> References: <1469217041-15358-1-git-send-email-minyard@acm.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH v3 4/4] ipmi_bmc_sim: Add a proper unrealize function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , minyard@acm.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Add an unrealize function to free the timer allocated in the realize function, unregister the vmstate, and free any pending messages. Signed-off-by: Corey Minyard Reviewed-by: Marc-André Lureau --- hw/ipmi/ipmi_bmc_sim.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.7.4 diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index b742d8d..fe92b93 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -1780,12 +1780,28 @@ static void ipmi_sim_realize(DeviceState *dev, Error **errp) vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs); } +static void ipmi_sim_unrealize(DeviceState *dev, Error **errp) +{ + IPMIBmc *b = IPMI_BMC(dev); + IPMIRcvBufEntry *msg, *tmp; + IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b); + + vmstate_unregister(NULL, &vmstate_ipmi_sim, ibs); + timer_del(ibs->timer); + timer_free(ibs->timer); + QTAILQ_FOREACH_SAFE(msg, &ibs->rcvbufs, entry, tmp) { + QTAILQ_REMOVE(&ibs->rcvbufs, msg, entry); + g_free(msg); + } +} + static void ipmi_sim_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); IPMIBmcClass *bk = IPMI_BMC_CLASS(oc); dc->realize = ipmi_sim_realize; + dc->unrealize = ipmi_sim_unrealize; bk->handle_command = ipmi_sim_handle_command; }