* [Qemu-devel] [PATCH v2 0/3] Handle freeing data in some devices
@ 2016-07-21 16:49 minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 1/3] ipmi_bmc_sim: Add a proper unrealize function minyard
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: minyard @ 2016-07-21 16:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Marc-André Lureau, minyard
Changes from v1:
Added portio_list_del() to the wdt_ib700 device
Free pending messages and the vmstate, and get rid of the
unnecessary mutex in the ipmi_bmc_sim device.
BTW, I haven't figured out a way to test this. Halting qemu doesn't
seem to result in unrealizing anything, and none of the devices
here can be hotplugged, so you can't delete them in the emulator.
-corey
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 1/3] ipmi_bmc_sim: Add a proper unrealize function
2016-07-21 16:49 [Qemu-devel] [PATCH v2 0/3] Handle freeing data in some devices minyard
@ 2016-07-21 16:49 ` minyard
2016-07-22 9:22 ` Marc-André Lureau
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 2/3] wdt_i6300esb: Free timer minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 3/3] wdt_ib700: " minyard
2 siblings, 1 reply; 9+ messages in thread
From: minyard @ 2016-07-21 16:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Marc-André Lureau, minyard, Corey Minyard
From: Corey Minyard <cminyard@mvista.com>
Add an unrealize function to free the timer allocated in the
realize function, unregsiter the vmstate, and free any
pending messages.
Also, get rid of the unnecessary mutex, it was a vestige
of something else that was not done. That way we don't
have to free it.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Marc-André Lureau <mlureau@redhat.com>
---
hw/ipmi/ipmi_bmc_sim.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index dc9c14c..fe92b93 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -217,7 +217,6 @@ struct IPMIBmcSim {
/* Odd netfns are for responses, so we only need the even ones. */
const IPMINetfn *netfns[MAX_NETFNS / 2];
- QemuMutex lock;
/* We allow one event in the buffer */
uint8_t evtbuf[16];
@@ -940,7 +939,6 @@ static void get_msg(IPMIBmcSim *ibs,
{
IPMIRcvBufEntry *msg;
- qemu_mutex_lock(&ibs->lock);
if (QTAILQ_EMPTY(&ibs->rcvbufs)) {
rsp_buffer_set_error(rsp, 0x80); /* Queue empty */
goto out;
@@ -960,7 +958,6 @@ static void get_msg(IPMIBmcSim *ibs,
}
out:
- qemu_mutex_unlock(&ibs->lock);
return;
}
@@ -1055,11 +1052,9 @@ static void send_msg(IPMIBmcSim *ibs,
end_msg:
msg->buf[msg->len] = ipmb_checksum(msg->buf, msg->len, 0);
msg->len++;
- qemu_mutex_lock(&ibs->lock);
QTAILQ_INSERT_TAIL(&ibs->rcvbufs, msg, entry);
ibs->msg_flags |= IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;
k->set_atn(s, 1, attn_irq_enabled(ibs));
- qemu_mutex_unlock(&ibs->lock);
}
static void do_watchdog_reset(IPMIBmcSim *ibs)
@@ -1753,7 +1748,6 @@ static void ipmi_sim_realize(DeviceState *dev, Error **errp)
unsigned int i;
IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b);
- qemu_mutex_init(&ibs->lock);
QTAILQ_INIT(&ibs->rcvbufs);
ibs->bmc_global_enables = (1 << IPMI_BMC_EVENT_LOG_BIT);
@@ -1786,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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] wdt_i6300esb: Free timer
2016-07-21 16:49 [Qemu-devel] [PATCH v2 0/3] Handle freeing data in some devices minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 1/3] ipmi_bmc_sim: Add a proper unrealize function minyard
@ 2016-07-21 16:49 ` minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 3/3] wdt_ib700: " minyard
2 siblings, 0 replies; 9+ messages in thread
From: minyard @ 2016-07-21 16:49 UTC (permalink / raw)
To: qemu-devel
Cc: Marc-André Lureau, minyard, Corey Minyard, Richard W . M . Jones
From: Corey Minyard <cminyard@mvista.com>
Add an exit function to free the timer allocated in the
realize function.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
---
hw/watchdog/wdt_i6300esb.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index a83d951..49b3cd1 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp)
/* qemu_register_coalesced_mmio (addr, 0x10); ? */
}
+static void i6300esb_exit(PCIDevice *dev)
+{
+ I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev);
+
+ timer_del(d->timer);
+ timer_free(d->timer);
+}
+
static WatchdogTimerModel model = {
.wdt_name = "i6300esb",
.wdt_description = "Intel 6300ESB",
@@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data)
k->config_read = i6300esb_config_read;
k->config_write = i6300esb_config_write;
k->realize = i6300esb_realize;
+ k->exit = i6300esb_exit;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;
k->class_id = PCI_CLASS_SYSTEM_OTHER;
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] wdt_ib700: Free timer
2016-07-21 16:49 [Qemu-devel] [PATCH v2 0/3] Handle freeing data in some devices minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 1/3] ipmi_bmc_sim: Add a proper unrealize function minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 2/3] wdt_i6300esb: Free timer minyard
@ 2016-07-21 16:49 ` minyard
2016-07-22 9:26 ` Marc-André Lureau
2 siblings, 1 reply; 9+ messages in thread
From: minyard @ 2016-07-21 16:49 UTC (permalink / raw)
To: qemu-devel
Cc: Marc-André Lureau, minyard, Corey Minyard, Richard W . M . Jones
From: Corey Minyard <cminyard@mvista.com>
Add an unrealize function to free the timer allocated in the
realize function and to delete the port memory added there,
too.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Richard W.M. Jones <rjones@redhat.com>
Cc: Marc-André Lureau <mlureau@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
---
hw/watchdog/wdt_ib700.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c
index 532afe8..23d4857 100644
--- a/hw/watchdog/wdt_ib700.c
+++ b/hw/watchdog/wdt_ib700.c
@@ -117,6 +117,15 @@ static void wdt_ib700_realize(DeviceState *dev, Error **errp)
portio_list_add(&s->port_list, isa_address_space_io(&s->parent_obj), 0);
}
+static void wdt_ib700_unrealize(DeviceState *dev, Error **errp)
+{
+ IB700State *s = IB700(dev);
+
+ timer_del(s->timer);
+ timer_free(s->timer);
+ portio_list_del(&s->port_list);
+}
+
static void wdt_ib700_reset(DeviceState *dev)
{
IB700State *s = IB700(dev);
@@ -136,6 +145,7 @@ static void wdt_ib700_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = wdt_ib700_realize;
+ dc->unrealize = wdt_ib700_unrealize;
dc->reset = wdt_ib700_reset;
dc->vmsd = &vmstate_ib700;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/3] ipmi_bmc_sim: Add a proper unrealize function
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 1/3] ipmi_bmc_sim: Add a proper unrealize function minyard
@ 2016-07-22 9:22 ` Marc-André Lureau
2016-07-22 12:14 ` Corey Minyard
0 siblings, 1 reply; 9+ messages in thread
From: Marc-André Lureau @ 2016-07-22 9:22 UTC (permalink / raw)
To: minyard; +Cc: qemu-devel, Corey Minyard
Hi
----- Original Message -----
> From: Corey Minyard <cminyard@mvista.com>
>
> Add an unrealize function to free the timer allocated in the
> realize function, unregsiter the vmstate, and free any
> pending messages.
I don't know how to test this either, the device seems to be hotpluggable, but doing device_del crashes qemu. Looks like it would be worth fixing that too (even better would be to automate this kind of test for all devices, but that's just some thought)
> Also, get rid of the unnecessary mutex, it was a vestige
> of something else that was not done. That way we don't
> have to free it.
You may want to split this in a seperate patch
>
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> Cc: Marc-André Lureau <mlureau@redhat.com>
> ---
> hw/ipmi/ipmi_bmc_sim.c | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
> index dc9c14c..fe92b93 100644
> --- a/hw/ipmi/ipmi_bmc_sim.c
> +++ b/hw/ipmi/ipmi_bmc_sim.c
> @@ -217,7 +217,6 @@ struct IPMIBmcSim {
> /* Odd netfns are for responses, so we only need the even ones. */
> const IPMINetfn *netfns[MAX_NETFNS / 2];
>
> - QemuMutex lock;
> /* We allow one event in the buffer */
> uint8_t evtbuf[16];
>
> @@ -940,7 +939,6 @@ static void get_msg(IPMIBmcSim *ibs,
> {
> IPMIRcvBufEntry *msg;
>
> - qemu_mutex_lock(&ibs->lock);
> if (QTAILQ_EMPTY(&ibs->rcvbufs)) {
> rsp_buffer_set_error(rsp, 0x80); /* Queue empty */
> goto out;
> @@ -960,7 +958,6 @@ static void get_msg(IPMIBmcSim *ibs,
> }
>
> out:
> - qemu_mutex_unlock(&ibs->lock);
> return;
> }
>
> @@ -1055,11 +1052,9 @@ static void send_msg(IPMIBmcSim *ibs,
> end_msg:
> msg->buf[msg->len] = ipmb_checksum(msg->buf, msg->len, 0);
> msg->len++;
> - qemu_mutex_lock(&ibs->lock);
> QTAILQ_INSERT_TAIL(&ibs->rcvbufs, msg, entry);
> ibs->msg_flags |= IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;
> k->set_atn(s, 1, attn_irq_enabled(ibs));
> - qemu_mutex_unlock(&ibs->lock);
> }
>
> static void do_watchdog_reset(IPMIBmcSim *ibs)
> @@ -1753,7 +1748,6 @@ static void ipmi_sim_realize(DeviceState *dev, Error
> **errp)
> unsigned int i;
> IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b);
>
> - qemu_mutex_init(&ibs->lock);
> QTAILQ_INIT(&ibs->rcvbufs);
>
> ibs->bmc_global_enables = (1 << IPMI_BMC_EVENT_LOG_BIT);
> @@ -1786,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);
> + }
> +}
> +
Otherwise, for completeness, this looks good so
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> 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
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] wdt_ib700: Free timer
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 3/3] wdt_ib700: " minyard
@ 2016-07-22 9:26 ` Marc-André Lureau
2016-07-22 10:12 ` Richard W.M. Jones
0 siblings, 1 reply; 9+ messages in thread
From: Marc-André Lureau @ 2016-07-22 9:26 UTC (permalink / raw)
To: minyard; +Cc: qemu-devel, Corey Minyard, Richard W . M . Jones
Hi
----- Original Message -----
> From: Corey Minyard <cminyard@mvista.com>
>
> Add an unrealize function to free the timer allocated in the
> realize function and to delete the port memory added there,
> too.
>
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> Cc: Richard W.M. Jones <rjones@redhat.com>
> Cc: Marc-André Lureau <mlureau@redhat.com>
> Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
> ---
> hw/watchdog/wdt_ib700.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c
> index 532afe8..23d4857 100644
> --- a/hw/watchdog/wdt_ib700.c
> +++ b/hw/watchdog/wdt_ib700.c
> @@ -117,6 +117,15 @@ static void wdt_ib700_realize(DeviceState *dev, Error
> **errp)
> portio_list_add(&s->port_list, isa_address_space_io(&s->parent_obj), 0);
> }
>
> +static void wdt_ib700_unrealize(DeviceState *dev, Error **errp)
> +{
> + IB700State *s = IB700(dev);
> +
> + timer_del(s->timer);
> + timer_free(s->timer);
> + portio_list_del(&s->port_list);
actually portio_list_destroy() seems to be more appropriate (cleaning up allocations)
btw, I do not how to test this yet either.
> +}
> +
> static void wdt_ib700_reset(DeviceState *dev)
> {
> IB700State *s = IB700(dev);
> @@ -136,6 +145,7 @@ static void wdt_ib700_class_init(ObjectClass *klass, void
> *data)
> DeviceClass *dc = DEVICE_CLASS(klass);
>
> dc->realize = wdt_ib700_realize;
> + dc->unrealize = wdt_ib700_unrealize;
> dc->reset = wdt_ib700_reset;
> dc->vmsd = &vmstate_ib700;
> set_bit(DEVICE_CATEGORY_MISC, dc->categories);
> --
> 2.7.4
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] wdt_ib700: Free timer
2016-07-22 9:26 ` Marc-André Lureau
@ 2016-07-22 10:12 ` Richard W.M. Jones
2016-07-22 12:12 ` Corey Minyard
0 siblings, 1 reply; 9+ messages in thread
From: Richard W.M. Jones @ 2016-07-22 10:12 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: minyard, qemu-devel, Corey Minyard
On Fri, Jul 22, 2016 at 05:26:27AM -0400, Marc-André Lureau wrote:
> btw, I do not how to test this yet either.
I have a little test framework for the watchdog device which cuts
through a lot of the BS with running the full watchdog daemon, and
also has some simple instructions to follow:
http://git.annexia.org/?p=watchdog-test-framework.git;a=tree
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] wdt_ib700: Free timer
2016-07-22 10:12 ` Richard W.M. Jones
@ 2016-07-22 12:12 ` Corey Minyard
0 siblings, 0 replies; 9+ messages in thread
From: Corey Minyard @ 2016-07-22 12:12 UTC (permalink / raw)
To: Richard W.M. Jones, Marc-André Lureau; +Cc: qemu-devel, Corey Minyard
On 07/22/2016 05:12 AM, Richard W.M. Jones wrote:
> On Fri, Jul 22, 2016 at 05:26:27AM -0400, Marc-André Lureau wrote:
>> btw, I do not how to test this yet either.
> I have a little test framework for the watchdog device which cuts
> through a lot of the BS with running the full watchdog daemon, and
> also has some simple instructions to follow:
>
> http://git.annexia.org/?p=watchdog-test-framework.git;a=tree
>
> Rich.
>
Thanks, but unfortunately, I need to be able to test unrealizing
the device in qemu. These changes don't affect the function
of the watchdog. Nice little program, though, I'll point our
testers at it.
-corey
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/3] ipmi_bmc_sim: Add a proper unrealize function
2016-07-22 9:22 ` Marc-André Lureau
@ 2016-07-22 12:14 ` Corey Minyard
0 siblings, 0 replies; 9+ messages in thread
From: Corey Minyard @ 2016-07-22 12:14 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, Corey Minyard
On 07/22/2016 04:22 AM, Marc-André Lureau wrote:
> Hi
>
> ----- Original Message -----
>> From: Corey Minyard <cminyard@mvista.com>
>>
>> Add an unrealize function to free the timer allocated in the
>> realize function, unregsiter the vmstate, and free any
>> pending messages.
> I don't know how to test this either, the device seems to be hotpluggable, but doing device_del crashes qemu. Looks like it would be worth fixing that too (even better would be to automate this kind of test for all devices, but that's just some thought)
>
That's actually a bug. This device's hot plug should be tied to it's
interface's hot plug, which is a separate device. I was trying to
unplug the interface, which is on an ISA bus, not the BMC.
>> Also, get rid of the unnecessary mutex, it was a vestige
>> of something else that was not done. That way we don't
>> have to free it.
> You may want to split this in a seperate patch
Yeah, you are right.
Thanks,
-corey
>
>> Signed-off-by: Corey Minyard <cminyard@mvista.com>
>> Cc: Marc-André Lureau <mlureau@redhat.com>
>> ---
>> hw/ipmi/ipmi_bmc_sim.c | 22 ++++++++++++++++------
>> 1 file changed, 16 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
>> index dc9c14c..fe92b93 100644
>> --- a/hw/ipmi/ipmi_bmc_sim.c
>> +++ b/hw/ipmi/ipmi_bmc_sim.c
>> @@ -217,7 +217,6 @@ struct IPMIBmcSim {
>> /* Odd netfns are for responses, so we only need the even ones. */
>> const IPMINetfn *netfns[MAX_NETFNS / 2];
>>
>> - QemuMutex lock;
>> /* We allow one event in the buffer */
>> uint8_t evtbuf[16];
>>
>> @@ -940,7 +939,6 @@ static void get_msg(IPMIBmcSim *ibs,
>> {
>> IPMIRcvBufEntry *msg;
>>
>> - qemu_mutex_lock(&ibs->lock);
>> if (QTAILQ_EMPTY(&ibs->rcvbufs)) {
>> rsp_buffer_set_error(rsp, 0x80); /* Queue empty */
>> goto out;
>> @@ -960,7 +958,6 @@ static void get_msg(IPMIBmcSim *ibs,
>> }
>>
>> out:
>> - qemu_mutex_unlock(&ibs->lock);
>> return;
>> }
>>
>> @@ -1055,11 +1052,9 @@ static void send_msg(IPMIBmcSim *ibs,
>> end_msg:
>> msg->buf[msg->len] = ipmb_checksum(msg->buf, msg->len, 0);
>> msg->len++;
>> - qemu_mutex_lock(&ibs->lock);
>> QTAILQ_INSERT_TAIL(&ibs->rcvbufs, msg, entry);
>> ibs->msg_flags |= IPMI_BMC_MSG_FLAG_RCV_MSG_QUEUE;
>> k->set_atn(s, 1, attn_irq_enabled(ibs));
>> - qemu_mutex_unlock(&ibs->lock);
>> }
>>
>> static void do_watchdog_reset(IPMIBmcSim *ibs)
>> @@ -1753,7 +1748,6 @@ static void ipmi_sim_realize(DeviceState *dev, Error
>> **errp)
>> unsigned int i;
>> IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b);
>>
>> - qemu_mutex_init(&ibs->lock);
>> QTAILQ_INIT(&ibs->rcvbufs);
>>
>> ibs->bmc_global_enables = (1 << IPMI_BMC_EVENT_LOG_BIT);
>> @@ -1786,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);
>> + }
>> +}
>> +
> Otherwise, for completeness, this looks good so
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
>> 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
>>
>>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-07-22 12:14 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-21 16:49 [Qemu-devel] [PATCH v2 0/3] Handle freeing data in some devices minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 1/3] ipmi_bmc_sim: Add a proper unrealize function minyard
2016-07-22 9:22 ` Marc-André Lureau
2016-07-22 12:14 ` Corey Minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 2/3] wdt_i6300esb: Free timer minyard
2016-07-21 16:49 ` [Qemu-devel] [PATCH v2 3/3] wdt_ib700: " minyard
2016-07-22 9:26 ` Marc-André Lureau
2016-07-22 10:12 ` Richard W.M. Jones
2016-07-22 12:12 ` Corey Minyard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.