[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer |
Date: |
Fri, 16 Sep 2011 11:00:24 -0500 |
qdev has this quirk that it owns a seemingly arbitrary QemuOpts pointer. That's
because qdev expects a static string for the id (which really makes no sense
since ids are supposed to be provided by the user). Instead of managing just
the id pointer, we currently take ownership of the entire QemuOpts structure
that was used to create the device just to keep the name around.
Just strdup the pointer we actually need.
Signed-off-by: Anthony Liguori <address@hidden>
---
hw/qdev.c | 3 ++-
hw/qdev.h | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index aeebdb9..41ed872 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -107,7 +107,7 @@ static DeviceState *qdev_create_from_info(BusState *bus,
DeviceInfo *info, const
}
dev->instance_id_alias = -1;
dev->state = DEV_STATE_CREATED;
- dev->id = id;
+ dev->id = g_strdup(id);
return dev;
}
@@ -414,6 +414,7 @@ void qdev_free(DeviceState *dev)
qemu_opts_del(dev->opts);
}
QLIST_REMOVE(dev, sibling);
+ g_free(dev->id);
for (prop = dev->info->props; prop && prop->name; prop++) {
if (prop->info->free) {
prop->info->free(dev, prop);
diff --git a/hw/qdev.h b/hw/qdev.h
index 626a1b6..c86736a 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -30,7 +30,7 @@ enum {
/* This structure should not be accessed directly. We declare it here
so that it can be embedded in individual device state structures. */
struct DeviceState {
- const char *id;
+ char *id;
enum DevState state;
QemuOpts *opts;
int hotplugged;
--
1.7.4.1
- [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking, (continued)
- [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking, Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 01/14] apic: rename apic.id -> apic.index, Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 13/14] ide: give IDE drives a default name in qdev, Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 12/14] pci: give pci devices a default name., Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 09/14] fw_cfg: add name to global fw_cfg device, Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 03/14] qdev: push id into qdev_create calls, Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 02/14] qdev: enforce that no devices overload the id property, Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 08/14] sysbus: make create_varargs take an id, Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 14/14] pc: assign names to machine created devices, Anthony Liguori, 2011/09/16
- [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer,
Anthony Liguori <=
- Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer, Gerd Hoffmann, 2011/09/19
- Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer, Anthony Liguori, 2011/09/19
- Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer, Gerd Hoffmann, 2011/09/20
- Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer, Anthony Liguori, 2011/09/20
- Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer, Gerd Hoffmann, 2011/09/20
- Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer, Anthony Liguori, 2011/09/20
- Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer, Gerd Hoffmann, 2011/09/20
[Qemu-devel] [PATCH 10/14] isa: add name parameter to device creation, Anthony Liguori, 2011/09/16
[Qemu-devel] [PATCH 06/14] qdev: add ability to do QOM-style derived naming, Anthony Liguori, 2011/09/16