diff options
author | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-07-01 21:31:54 +0000 |
---|---|---|
committer | pbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-07-01 21:31:54 +0000 |
commit | 18be51872917e70e00cb21e018b6bff33162c4f7 (patch) | |
tree | b4cb449586ae3930e2d99dd4c00be2e46229b53c /vl.c | |
parent | 9656f324d25895ec16ebc5eaf624e28a96c1f1be (diff) | |
download | qemu-18be51872917e70e00cb21e018b6bff33162c4f7.tar.gz qemu-18be51872917e70e00cb21e018b6bff33162c4f7.tar.bz2 qemu-18be51872917e70e00cb21e018b6bff33162c4f7.zip |
Remove duplicate device index calculations.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4818 c046a42c-6fe2-441c-8c8c-71466251a162
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; } |