From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQFI1-0000on-07 for qemu-devel@nongnu.org; Thu, 21 Jul 2016 10:49:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQFHw-0007sz-2X for qemu-devel@nongnu.org; Thu, 21 Jul 2016 10:49:28 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:51007) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQFHv-0007sj-Qq for qemu-devel@nongnu.org; Thu, 21 Jul 2016 10:49:23 -0400 Date: Thu, 21 Jul 2016 10:49:20 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <568261880.7102035.1469112560328.JavaMail.zimbra@redhat.com> In-Reply-To: <1469112292-30548-1-git-send-email-minyard@acm.org> References: <1469112292-30548-1-git-send-email-minyard@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/3] ipmi_bmc_sim: Free timer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: minyard@acm.org Cc: qemu-devel@nongnu.org, Corey Minyard Hi ----- Original Message ----- > From: Corey Minyard >=20 > Add an unrealize function to free the timer allocated in the > realize function. >=20 > Signed-off-by: Corey Minyard > Cc: Marc-Andr=C3=A9 Lureau > --- > hw/ipmi/ipmi_bmc_sim.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) >=20 > diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c > index dc9c14c..c83adf8 100644 > --- a/hw/ipmi/ipmi_bmc_sim.c > +++ b/hw/ipmi/ipmi_bmc_sim.c > @@ -1786,12 +1786,22 @@ static void ipmi_sim_realize(DeviceState *dev, Er= ror > **errp) > vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs); > } > =20 > +static void ipmi_sim_unrealize(DeviceState *dev, Error **errp) > +{ > + IPMIBmc *b =3D IPMI_BMC(dev); > + IPMIBmcSim *ibs =3D IPMI_BMC_SIMULATOR(b); > + > + timer_del(ibs->timer); > + timer_free(ibs->timer); > +} > + I think we may want to unrealize more here: +static void ipmi_sim_unrealize(DeviceState *dev, Error **errp) +{ + IPMIBmcSim *ibs =3D IPMI_BMC_SIMULATOR(dev); + IPMIRcvBufEntry *msg, *tmp; + + 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); + } + qemu_mutex_destroy(&ibs->lock); > static void ipmi_sim_class_init(ObjectClass *oc, void *data) > { > DeviceClass *dc =3D DEVICE_CLASS(oc); > IPMIBmcClass *bk =3D IPMI_BMC_CLASS(oc); > =20 > dc->realize =3D ipmi_sim_realize; > + dc->unrealize =3D ipmi_sim_unrealize; > bk->handle_command =3D ipmi_sim_handle_command; > } > =20 > -- > 2.7.4 >=20 >=20