From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAhbg-0008SZ-Mp for qemu-devel@nongnu.org; Fri, 25 Jul 2014 11:40:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAhbX-0001Jm-6n for qemu-devel@nongnu.org; Fri, 25 Jul 2014 11:40:28 -0400 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:33415) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAhbW-0001Jh-V3 for qemu-devel@nongnu.org; Fri, 25 Jul 2014 11:40:19 -0400 Received: by mail-pa0-f42.google.com with SMTP id lf10so6337912pab.29 for ; Fri, 25 Jul 2014 08:40:18 -0700 (PDT) From: Sanidhya Kashyap Date: Fri, 25 Jul 2014 21:09:26 +0530 Message-Id: <1406302776-2306-3-git-send-email-sanidhya.iiith@gmail.com> In-Reply-To: <1406302776-2306-1-git-send-email-sanidhya.iiith@gmail.com> References: <1406302776-2306-1-git-send-email-sanidhya.iiith@gmail.com> Subject: [Qemu-devel] [PATCH RFC v2 02/12] reset handler for qdevified devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Sanidhya Kashyap , "Dr. David Alan Gilbert" , Juan Quintela 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); + 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) -- 1.9.3