[1/9] savevm: don't rely on paths if we can store a DeviceState object

Submitted by Anthony Liguori on Aug. 26, 2012, 3:51 p.m.

Details

Message ID 1345996298-4892-2-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori Aug. 26, 2012, 3:51 p.m.
Paths break during tear down which can result in odd behavior since we do path
based lookup during unregister (which happens at tear down).

For devices, just store the DeviceState directly and use that.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 savevm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/savevm.c b/savevm.c
index c7fe283..bb6494b 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1177,6 +1177,7 @@  typedef struct SaveStateEntry {
     CompatEntry *compat;
     int no_migrate;
     int is_ram;
+    DeviceState *dev;
 } SaveStateEntry;
 
 
@@ -1235,6 +1236,7 @@  int register_savevm_live(DeviceState *dev,
     se->opaque = opaque;
     se->vmsd = NULL;
     se->no_migrate = 0;
+    se->dev = dev;
     /* if this is a live_savem then set is_ram */
     if (ops->save_live_setup != NULL) {
         se->is_ram = 1;
@@ -1298,7 +1300,8 @@  void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
     pstrcat(id, sizeof(id), idstr);
 
     QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) {
-        if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
+        if ((dev && se->dev == dev) ||
+            (strcmp(se->idstr, id) == 0 && se->opaque == opaque)) {
             QTAILQ_REMOVE(&savevm_handlers, se, entry);
             if (se->compat) {
                 g_free(se->compat);