]> git.proxmox.com Git - qemu.git/commit
savevm: improve subsections detection on load
authorJuan Quintela <quintela@redhat.com>
Tue, 4 Oct 2011 13:28:31 +0000 (15:28 +0200)
committerJuan Quintela <quintela@redhat.com>
Thu, 20 Oct 2011 11:23:11 +0000 (13:23 +0200)
commitc63807244fb55071675907460a0ecf228c1766c8
tree40e84a912c1cd8904478dcc3d692b5a0f9ff80e5
parent65f3bb3da3d5b46daebbfc54bd41ee493fdaba86
savevm: improve subsections detection on load

We add qemu_peek_buffer, that is identical to qemu_get_buffer, just
that it don't update f->buf_index.

We add a paramenter to qemu_peek_byte() to be able to peek more than
one byte.

Once this is done, to see if we have a subsection we look:
- 1st byte is QEMU_VM_SUBSECTION
- 2nd byte is a length, and is bigger than section name
- 3rd element is a string that starts with section_name

So, we shouldn't have false positives (yes, content could still get us
wrong but probabilities are really low).

v2:
- Alex Williamsom found that we could get negative values on index.
- Rework code to fix that part.
- Rewrite qemu_get_buffer() using qemu_peek_buffer()

v3:
- return "done" on error case

v4:
- fix qemu_file_skip() off by one.

Signed-off-by: Juan Quintela <quintela@redhat.com>
savevm.c