• Juan Quintela's avatar
    savevm: improve subsections detection on load · c6380724
    Juan Quintela authored
    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).
    - 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()
    - return "done" on error case
    - fix qemu_file_skip() off by one.
    Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
savevm.c 55.7 KB