Sanidhya Kashyap <sanidhya.ii...@gmail.com> wrote: > I have added a structure containing the list of qdevified devices which have > been added to the SaveVMHandlers. Since, I was unable to find any particular > struct containing the information about all the qdevified devices. So, I have > created my own version, which is very very specific. > > I shall be grateful if anyone can give some pointers on this. > > Signed-off-by: Sanidhya Kashyap <sanidhya.ii...@gmail.com> > --- > savevm.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/savevm.c b/savevm.c > index e19ae0a..0255fa0 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -503,12 +503,29 @@ void unregister_savevm(DeviceState *dev, const char > *idstr, void *opaque) > } > } > > +/* > + * Reset entry for qdevified devices. > + * Contains all those devices which have been qdevified and are > + * part of the SaveVMHandlers. This one allows resetting of > + * single device at any time. > + */ > + > +typedef struct VMStatesQdevResetEntry { > + QTAILQ_ENTRY(VMStatesQdevResetEntry) entry; > + DeviceState *dev; > + char device_name[256]; > +} VMStatesQdevResetEntry; > + > +static QTAILQ_HEAD(vmstate_reset_handlers, VMStatesQdevResetEntry) > + vmstate_reset_handlers = > QTAILQ_HEAD_INITIALIZER(vmstate_reset_handlers); > + > int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, > const VMStateDescription *vmsd, > void *opaque, int alias_id, > int required_for_version) > { > SaveStateEntry *se; > + VMStatesQdevResetEntry *qre; > > /* If this triggers, alias support can be dropped for the vmsd. */ > assert(alias_id == -1 || required_for_version >= > vmsd->minimum_version_id); > @@ -521,6 +538,12 @@ int vmstate_register_with_alias_id(DeviceState *dev, int > instance_id, > se->alias_id = alias_id; > > if (dev) { > + > + qre = g_malloc0(sizeof(VMStatesQdevResetEntry)); > + qre->dev = dev; > + strcpy(qre->device_name, vmsd->name); > + QTAILQ_INSERT_TAIL(&vmstate_reset_handlers, qre, entry); > +
As stated on irc, you could add a "dev" field to SaveStateEntry and call it a day. Thanks, Juan. > char *id = qdev_get_dev_path(dev); > if (id) { > pstrcpy(se->idstr, sizeof(se->idstr), id); > @@ -551,6 +574,7 @@ void vmstate_unregister(DeviceState *dev, const > VMStateDescription *vmsd, > void *opaque) > { > SaveStateEntry *se, *new_se; > + VMStatesQdevResetEntry *qre, *new_qre; > > QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { > if (se->vmsd == vmsd && se->opaque == opaque) { > @@ -561,6 +585,12 @@ void vmstate_unregister(DeviceState *dev, const > VMStateDescription *vmsd, > g_free(se); > } > } > + > + QTAILQ_FOREACH_SAFE(qre, &vmstate_reset_handlers, entry, new_qre) { > + if (dev && qre->dev && !strcmp(vmsd->name, qre->device_name)) { > + QTAILQ_REMOVE(&vmstate_reset_handlers, qre, entry); > + } > + } > } > > static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)