From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC6kl-0001Tu-4d for qemu-devel@nongnu.org; Tue, 29 Jul 2014 08:43:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XC6kd-0002Mt-Kh for qemu-devel@nongnu.org; Tue, 29 Jul 2014 08:43:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC6kd-0002Mm-Cw for qemu-devel@nongnu.org; Tue, 29 Jul 2014 08:43:31 -0400 From: Juan Quintela In-Reply-To: <1406302776-2306-3-git-send-email-sanidhya.iiith@gmail.com> (Sanidhya Kashyap's message of "Fri, 25 Jul 2014 21:09:26 +0530") References: <1406302776-2306-1-git-send-email-sanidhya.iiith@gmail.com> <1406302776-2306-3-git-send-email-sanidhya.iiith@gmail.com> Date: Tue, 29 Jul 2014 14:43:27 +0200 Message-ID: <87lhrctjww.fsf@troll.troll> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH RFC v2 02/12] reset handler for qdevified devices Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sanidhya Kashyap Cc: qemu list , "Dr. David Alan Gilbert" Sanidhya Kashyap 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 > --- > 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)