Skip to contentSkip to conversation

ipmi_bmc_sim: Free timer

PATCH In review [email protected] 3 participants 10 messages Jul 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ipmi_bmc_sim: Free timer

From: Corey Minyard <[email protected]>

Add an unrealize function to free the timer allocated in the realize function.

Cc Marc-André Lureau <[email protected]>
---
 hw/ipmi/ipmi_bmc_sim.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/ipmi/ipmi_bmc_sim.c +10 -0
index dc9c14c..c83adf8 100644
@@ -1786,12 +1786,22 @@ 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);
+    IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b);
+
+    timer_del(ibs->timer);
+    timer_free(ibs->timer);
+}
+
 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;
 }
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/3 wdt_i6300esb: Free timer

From: Corey Minyard <[email protected]>

Add an exit function to free the timer allocated in the realize function.

Cc Richard W.M. Jones <[email protected]>
Cc Marc-André Lureau <[email protected]>
---
 hw/watchdog/wdt_i6300esb.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/watchdog/wdt_i6300esb.c +9 -0
index a83d951..49b3cd1 100644
@@ -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;
Signature · 1 line
2.7.4
Reviewed-by on v1 2/3
#2 lore raw

Re: [Qemu-devel] [PATCH 2/3] wdt_i6300esb: Free timer

Hi

----- Original Message -----

Quoted 18 lines

From: Corey Minyard <[email protected]>

Add an exit function to free the timer allocated in the realize function.

Cc Richard W.M. Jones <[email protected]>
Cc Marc-André Lureau <[email protected]>
---
 hw/watchdog/wdt_i6300esb.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/watchdog/wdt_i6300esb.c +0 -0
index a83d951..49b3cd1 100644
@@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error
 **errp)

hw/watchdog/wdt_i6300esb.c static void i6300esb_realize(PCIDevice *dev, Error · line 438

Quoted 10 lines
hw/watchdog/wdt_i6300esb.c +7 -0
     /* 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);
+}
Quoted 17 lines
hw/watchdog/wdt_i6300esb.c +1 -0
+
 static WatchdogTimerModel model = {
     .wdt_name = "i6300esb",
     .wdt_description = "Intel 6300ESB",
hw/watchdog/wdt_i6300esb.c +1 -0
@@ -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

Reviewed-by on v1 2/3
#3 lore raw

Re: [Qemu-devel] [PATCH 2/3] wdt_i6300esb: Free timer

In reply to [email protected]
Quoted 32 lines · On Thu, Jul 21, 2016 at 09:44:51AM -0500, [email protected] wrote:

From: Corey Minyard <[email protected]>

Add an exit function to free the timer allocated in the realize function.

Cc Richard W.M. Jones <[email protected]>
Cc Marc-André Lureau <[email protected]>
---
 hw/watchdog/wdt_i6300esb.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/watchdog/wdt_i6300esb.c +8 -0
index a83d951..49b3cd1 100644
@@ -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",

hw/watchdog/wdt_i6300esb.c static void i6300esb_class_init(ObjectClass *klass, void *data) · line 455

Quoted 7 lines
hw/watchdog/wdt_i6300esb.c +1 -0
@@ -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;

With the caveat that I only examined the code and compile-tested it:

Rich.

Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
#4 lore raw

PATCH 3/3 wdt_ib700: Free timer

In reply to [email protected]

From: Corey Minyard <[email protected]>

Add an unrealize function to free the timer allocated in the realize function.

Cc Richard W.M. Jones <[email protected]>
Cc Marc-André Lureau <[email protected]>
---
 hw/watchdog/wdt_ib700.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/watchdog/wdt_ib700.c +9 -0
index 532afe8..179771a 100644
@@ -117,6 +117,14 @@ 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);
+}
+
 static void wdt_ib700_reset(DeviceState *dev)
 {
     IB700State *s = IB700(dev);
@@ -136,6 +144,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);
Signature · 1 line
2.7.4
#5 lore raw

Re: [Qemu-devel] [PATCH 3/3] wdt_ib700: Free timer

Hi

----- Original Message -----

Quoted 19 lines

From: Corey Minyard <[email protected]>

Add an unrealize function to free the timer allocated in the realize function.

Cc Richard W.M. Jones <[email protected]>
Cc Marc-André Lureau <[email protected]>
---
 hw/watchdog/wdt_ib700.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/watchdog/wdt_ib700.c +0 -0
index 532afe8..179771a 100644
@@ -117,6 +117,14 @@ static void wdt_ib700_realize(DeviceState *dev, Error
 **errp)
     portio_list_add(&s->port_list, isa_address_space_io(&s->parent_obj), 0);

hw/watchdog/wdt_ib700.c static void wdt_ib700_realize(DeviceState *dev, Error · line 128

Quoted 10 lines
hw/watchdog/wdt_ib700.c +8 -0
 }
 
+static void wdt_ib700_unrealize(DeviceState *dev, Error **errp)
+{
+    IB700State *s = IB700(dev);
+
+    timer_del(s->timer);
+    timer_free(s->timer);
+}
+

We may want to call portio_list_del() too here (although this is a dead function today)

Quoted 16 lines
hw/watchdog/wdt_ib700.c +0 -0
 static void wdt_ib700_reset(DeviceState *dev)
 {
     IB700State *s = IB700(dev);
hw/watchdog/wdt_ib700.c +1 -0
@@ -136,6 +144,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

Reviewed-by on v1 3/3
#6 lore raw

Re: [Qemu-devel] [PATCH 3/3] wdt_ib700: Free timer

In reply to [email protected]
Quoted 32 lines · On Thu, Jul 21, 2016 at 09:44:52AM -0500, [email protected] wrote:

From: Corey Minyard <[email protected]>

Add an unrealize function to free the timer allocated in the realize function.

Cc Richard W.M. Jones <[email protected]>
Cc Marc-André Lureau <[email protected]>
---
 hw/watchdog/wdt_ib700.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/watchdog/wdt_ib700.c +8 -0
index 532afe8..179771a 100644
@@ -117,6 +117,14 @@ 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);
+}
+
 static void wdt_ib700_reset(DeviceState *dev)
 {
     IB700State *s = IB700(dev);

hw/watchdog/wdt_ib700.c static void wdt_ib700_class_init(ObjectClass *klass, void *data) · line 150

Quoted 7 lines
hw/watchdog/wdt_ib700.c +1 -0
@@ -136,6 +144,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);

With the caveat that I only examined the code and compile-tested it:

Rich.

Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
#7 lore raw
In reply to [email protected]

Hi

----- Original Message -----

Quoted 19 lines

From: Corey Minyard <[email protected]>

Add an unrealize function to free the timer allocated in the realize function.

Cc Marc-André Lureau <[email protected]>
---
 hw/ipmi/ipmi_bmc_sim.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/ipmi/ipmi_bmc_sim.c +0 -0
index dc9c14c..c83adf8 100644
@@ -1786,12 +1786,22 @@ static void ipmi_sim_realize(DeviceState *dev, Error
 **errp)
     vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs);
 }

hw/ipmi/ipmi_bmc_sim.c static void ipmi_sim_realize(DeviceState *dev, Error · line 1798

Quoted 10 lines
hw/ipmi/ipmi_bmc_sim.c +9 -0
 
+static void ipmi_sim_unrealize(DeviceState *dev, Error **errp)
+{
+    IPMIBmc *b = IPMI_BMC(dev);
+    IPMIBmcSim *ibs = 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 = 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);

Quoted 14 lines
hw/ipmi/ipmi_bmc_sim.c +1 -1
 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

#8 lore raw
Quoted 34 lines · Marc-André Lureau

Hi

----- Original Message -----

Quoted 19 lines

From: Corey Minyard <[email protected]>

Add an unrealize function to free the timer allocated in the realize function.

Cc Marc-André Lureau <[email protected]>
---
  hw/ipmi/ipmi_bmc_sim.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
hw/ipmi/ipmi_bmc_sim.c +0 -0
index dc9c14c..c83adf8 100644
@@ -1786,12 +1786,22 @@ static void ipmi_sim_realize(DeviceState *dev, Error
 **errp)
      vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs);
  }

hw/ipmi/ipmi_bmc_sim.c static void ipmi_sim_realize(DeviceState *dev, Error · line 1798

Quoted 10 lines
hw/ipmi/ipmi_bmc_sim.c +9 -0
 
+static void ipmi_sim_unrealize(DeviceState *dev, Error **errp)
+{
+    IPMIBmc *b = IPMI_BMC(dev);
+    IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b);
+
+    timer_del(ibs->timer);
+    timer_free(ibs->timer);
+}
+

I think we may want to unrealize more here:

hw/ipmi/ipmi_bmc_sim.c static void ipmi_sim_realize(DeviceState *dev, Error **errp)

Quoted 6 lines
hw/ipmi/ipmi_bmc_sim.c +6 -0
+static void ipmi_sim_unrealize(DeviceState *dev, Error **errp)
+{
+    IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(dev);
+    IPMIRcvBufEntry *msg, *tmp;
+
+    vmstate_unregister(NULL, &vmstate_ipmi_sim, ibs);

Isn't this already done automatically in device_set_realized()?

Review

Quoted 7 lines
(quoted diff) +7 -0
+    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);

That mutex should probably go away, it was a vestige of something else that is no longer there.

Thanks,

-corey

Quoted 14 lines
Quoted 14 lines
hw/ipmi/ipmi_bmc_sim.c +1 -1
  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

#9 lore raw
Quoted 35 lines · Corey Minyard
Quoted 34 lines · Marc-André Lureau

Hi

----- Original Message -----

Quoted 19 lines

From: Corey Minyard <[email protected]>

Add an unrealize function to free the timer allocated in the realize function.

Cc Marc-André Lureau <[email protected]>
---
  hw/ipmi/ipmi_bmc_sim.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
hw/ipmi/ipmi_bmc_sim.c +0 -0
index dc9c14c..c83adf8 100644
@@ -1786,12 +1786,22 @@ static void ipmi_sim_realize(DeviceState 
 *dev, Error
 **errp)
      vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs);

hw/ipmi/ipmi_bmc_sim.c static void ipmi_sim_realize(DeviceState · line 1798

Quoted 10 lines
hw/ipmi/ipmi_bmc_sim.c +8 -0
  }
  +static void ipmi_sim_unrealize(DeviceState *dev, Error **errp)
+{
+    IPMIBmc *b = IPMI_BMC(dev);
+    IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(b);
+
+    timer_del(ibs->timer);
+    timer_free(ibs->timer);
+}
+

I think we may want to unrealize more here:

Quoted 8 lines

hw/ipmi/ipmi_bmc_sim.c static void ipmi_sim_realize(DeviceState *dev, Error **errp)

Quoted 6 lines
hw/ipmi/ipmi_bmc_sim.c +6 -0
+static void ipmi_sim_unrealize(DeviceState *dev, Error **errp)
+{
+    IPMIBmcSim *ibs = IPMI_BMC_SIMULATOR(dev);
+    IPMIRcvBufEntry *msg, *tmp;
+
+    vmstate_unregister(NULL, &vmstate_ipmi_sim, ibs);

Isn't this already done automatically in device_set_realized()?

Never mind, I misunderstood that code.

-corey

Quoted 29 lines

Review

Quoted 8 lines
(quoted diff) +7 -0
+    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);

That mutex should probably go away, it was a vestige of something else that is no longer there.

Thanks,

-corey

Quoted 12 lines
Quoted 12 lines
hw/ipmi/ipmi_bmc_sim.c +1 -0
  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