diff options
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -6060,6 +6060,8 @@ typedef struct SaveStateEntry { static SaveStateEntry *first_se; +/* TODO: Individual devices generally have very little idea about the rest + of the system, so instance_id should be removed/replaced. */ int register_savevm(const char *idstr, int instance_id, int version_id, @@ -6073,7 +6075,7 @@ int register_savevm(const char *idstr, if (!se) return -1; pstrcpy(se->idstr, sizeof(se->idstr), idstr); - se->instance_id = instance_id; + se->instance_id = (instance_id == -1) ? 0 : instance_id; se->version_id = version_id; se->save_state = save_state; se->load_state = load_state; @@ -6082,8 +6084,13 @@ int register_savevm(const char *idstr, /* add at the end of list */ pse = &first_se; - while (*pse != NULL) + while (*pse != NULL) { + if (instance_id == -1 + && strcmp(se->idstr, (*pse)->idstr) == 0 + && se->instance_id <= (*pse)->instance_id) + se->instance_id = (*pse)->instance_id + 1; pse = &(*pse)->next; + } *pse = se; return 0; } |