diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-08-28 16:00:19 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2020-01-06 18:41:32 +0400 |
commit | 107b59698f79b323c4d111c46eb9e3db6f9d258b (patch) | |
tree | 45152d37afb55b46ad20bcdfc1ee792dae7438e5 /hw/core/qdev.c | |
parent | b0b74e1f17508cb8cef8afd698558db1bd8999cc (diff) |
vmstate: add qom interface to get id
Add an interface to get the instance id, instead of depending on
Device and qdev_get_dev_path().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r-- | hw/core/qdev.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 82d3ee590a..1a98812be2 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1087,9 +1087,18 @@ static void device_unparent(Object *obj) } } +static char * +device_vmstate_if_get_id(VMStateIf *obj) +{ + DeviceState *dev = DEVICE(obj); + + return qdev_get_dev_path(dev); +} + static void device_class_init(ObjectClass *class, void *data) { DeviceClass *dc = DEVICE_CLASS(class); + VMStateIfClass *vc = VMSTATE_IF_CLASS(class); class->unparent = device_unparent; @@ -1101,6 +1110,7 @@ static void device_class_init(ObjectClass *class, void *data) */ dc->hotpluggable = true; dc->user_creatable = true; + vc->get_id = device_vmstate_if_get_id; } void device_class_set_parent_reset(DeviceClass *dc, @@ -1158,6 +1168,10 @@ static const TypeInfo device_type_info = { .class_init = device_class_init, .abstract = true, .class_size = sizeof(DeviceClass), + .interfaces = (InterfaceInfo[]) { + { TYPE_VMSTATE_IF }, + { } + } }; static void qdev_register_types(void) |