Patchwork [24/24] store a pointer to QemuOpts in DeviceState, release it when zapping a device.

login
register
mail settings
Submitter Gerd Hoffmann
Date Sept. 25, 2009, 7:42 p.m.
Message ID <1253907769-1067-25-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/34304/
State Superseded
Headers show

Comments

Gerd Hoffmann - Sept. 25, 2009, 7:42 p.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev.c |    3 +++
 hw/qdev.h |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index 00cb849..ae24df7 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -218,6 +218,7 @@  DeviceState *qdev_device_add(QemuOpts *opts)
         qdev_free(qdev);
         return NULL;
     }
+    qdev->opts = opts;
     return qdev;
 }
 
@@ -276,6 +277,8 @@  void qdev_free(DeviceState *dev)
             qemu_unregister_reset(dev->info->reset, dev);
         if (dev->info->exit)
             dev->info->exit(dev);
+        if (dev->opts)
+            qemu_opts_del(dev->opts);
     }
     QLIST_REMOVE(dev, sibling);
     qemu_free(dev);
diff --git a/hw/qdev.h b/hw/qdev.h
index 8b6e4fe..1884160 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -29,6 +29,7 @@  enum DevState {
 struct DeviceState {
     const char *id;
     enum DevState state;
+    QemuOpts *opts;
     int hotplugged;
     DeviceInfo *info;
     BusState *parent_bus;