From: minyard@acm.org
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <mlureau@redhat.com>,
minyard@acm.org, "Corey Minyard" <cminyard@mvista.com>
Subject: [Qemu-devel] [PATCH v3 4/4] ipmi_bmc_sim: Add a proper unrealize function
Date: Fri, 22 Jul 2016 14:50:41 -0500 [thread overview]
Message-ID: <1469217041-15358-5-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1469217041-15358-1-git-send-email-minyard@acm.org>
From: Corey Minyard <cminyard@mvista.com>
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 <cminyard@mvista.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/ipmi/ipmi_bmc_sim.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
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;
}
--
2.7.4
next prev parent reply other threads:[~2016-07-22 19:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-22 19:50 [Qemu-devel] [PATCH v3 0/4] Plug some memory leaks on unrealize minyard
2016-07-22 19:50 ` [Qemu-devel] [PATCH v3 1/4] ipmi_bmc_sim: Remove an unnecessary mutex minyard
2016-07-22 19:50 ` [Qemu-devel] [PATCH v3 2/4] wdt_i6300esb: Free timer minyard
2016-07-22 19:50 ` [Qemu-devel] [PATCH v3 3/4] wdt_ib700: " minyard
2016-07-22 19:50 ` minyard [this message]
2016-07-23 7:46 ` [Qemu-devel] [PATCH v3 0/4] Plug some memory leaks on unrealize Paolo Bonzini
2016-07-23 13:18 ` Corey Minyard
2016-07-23 15:16 ` Paolo Bonzini
2016-07-23 18:04 ` Corey Minyard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1469217041-15358-5-git-send-email-minyard@acm.org \
--to=minyard@acm.org \
--cc=cminyard@mvista.com \
--cc=mlureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).