static int qemu_loadvm_state(QEMUFile *f)

{

    SaveStateEntry *se;

    int len, ret, instance_id, record_len, version_id;

    int64_t total_len, end_pos, cur_pos;

    unsigned int v;

    char idstr[256];



    v = qemu_get_be32(f);

    if (v != QEMU_VM_FILE_MAGIC)

        goto fail;

    v = qemu_get_be32(f);

    if (v != QEMU_VM_FILE_VERSION) {

    fail:

        ret = -1;

        goto the_end;

    }

    total_len = qemu_get_be64(f);

    end_pos = total_len + qemu_ftell(f);

    for(;;) {

        if (qemu_ftell(f) >= end_pos)

            break;

        len = qemu_get_byte(f);

        qemu_get_buffer(f, (uint8_t *)idstr, len);

        idstr[len] = '\0';

        instance_id = qemu_get_be32(f);

        version_id = qemu_get_be32(f);

        record_len = qemu_get_be32(f);

#if 0

        printf("idstr=%s instance=0x%x version=%d len=%d\n",

               idstr, instance_id, version_id, record_len);

#endif

        cur_pos = qemu_ftell(f);

        se = find_se(idstr, instance_id);

        if (!se) {

            fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n",

                    instance_id, idstr);

        } else {

            ret = se->load_state(f, se->opaque, version_id);

            if (ret < 0) {

                fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n",

                        instance_id, idstr);

            }

        }

        /* always seek to exact end of record */

        qemu_fseek(f, cur_pos + record_len, SEEK_SET);

    }

    ret = 0;

 the_end:

    return ret;

}

static int qemu_loadvm_state(QEMUFile *f)

{

    SaveStateEntry *se;

    int len, ret, instance_id, record_len, version_id;

    int64_t total_len, end_pos, cur_pos;

    unsigned int v;

    char idstr[256];



    v = qemu_get_be32(f);

    if (v != QEMU_VM_FILE_MAGIC)

        goto fail;

    v = qemu_get_be32(f);

    if (v != QEMU_VM_FILE_VERSION) {

    fail:

        ret = -1;

        goto the_end;

    }

    total_len = qemu_get_be64(f);

    end_pos = total_len + qemu_ftell(f);

    for(;;) {

        if (qemu_ftell(f) >= end_pos)

            break;

        len = qemu_get_byte(f);

        qemu_get_buffer(f, (uint8_t *)idstr, len);

        idstr[len] = '\0';

        instance_id = qemu_get_be32(f);

        version_id = qemu_get_be32(f);

        record_len = qemu_get_be32(f);

#if 0

        printf("idstr=%s instance=0x%x version=%d len=%d\n",

               idstr, instance_id, version_id, record_len);

#endif

        cur_pos = qemu_ftell(f);

        se = find_se(idstr, instance_id);

        if (!se) {

            fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n",

                    instance_id, idstr);

        } else {

            ret = se->load_state(f, se->opaque, version_id);

            if (ret < 0) {

                fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n",

                        instance_id, idstr);

            }

        }

        

        qemu_fseek(f, cur_pos + record_len, SEEK_SET);

    }

    ret = 0;

 the_end:

    return ret;

}

        cur_pos = qemu_ftell(f);     ret = 0; static int qemu_loadvm_state(QEMUFile *f)     unsigned int v;     v = qemu_get_be32(f);     if (v != QEMU_VM_FILE_MAGIC)         goto fail;     v = qemu_get_be32(f);     if (v != QEMU_VM_FILE_VERSION) {     fail:         ret = -1;         goto the_end; #if 0         printf("idstr=%s instance=0x%x version=%d len=%d\n",                idstr, instance_id, version_id, record_len); #endif  the_end:
static int FUNC_0(QEMUFile *VAR_0)

{

    SaveStateEntry *se;

    int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;

    int64_t total_len, end_pos, cur_pos;

    unsigned int VAR_6;

    char VAR_7[256];



    VAR_6 = qemu_get_be32(VAR_0);

    if (VAR_6 != QEMU_VM_FILE_MAGIC)

        goto fail;

    VAR_6 = qemu_get_be32(VAR_0);

    if (VAR_6 != QEMU_VM_FILE_VERSION) {

    fail:

        VAR_2 = -1;

        goto the_end;

    }

    total_len = qemu_get_be64(VAR_0);

    end_pos = total_len + qemu_ftell(VAR_0);

    for(;;) {

        if (qemu_ftell(VAR_0) >= end_pos)

            break;

        VAR_1 = qemu_get_byte(VAR_0);

        qemu_get_buffer(VAR_0, (uint8_t *)VAR_7, VAR_1);

        VAR_7[VAR_1] = '\0';

        VAR_3 = qemu_get_be32(VAR_0);

        VAR_5 = qemu_get_be32(VAR_0);

        VAR_4 = qemu_get_be32(VAR_0);

#if 0

        printf("VAR_7=%s instance=0x%x version=%d VAR_1=%d\n",

               VAR_7, VAR_3, VAR_5, VAR_4);

#endif

        cur_pos = qemu_ftell(VAR_0);

        se = find_se(VAR_7, VAR_3);

        if (!se) {

            fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n",

                    VAR_3, VAR_7);

        } else {

            VAR_2 = se->load_state(VAR_0, se->opaque, VAR_5);

            if (VAR_2 < 0) {

                fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n",

                        VAR_3, VAR_7);

            }

        }

        

        qemu_fseek(VAR_0, cur_pos + VAR_4, SEEK_SET);

    }

    VAR_2 = 0;

 the_end:

    return VAR_2;

}

static int FUNC_0(QEMUFile *VAR_0)
{ SaveStateEntry *se; int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5; int64_t total_len, end_pos, cur_pos; unsigned int VAR_6; char VAR_7[256]; VAR_6 = qemu_get_be32(VAR_0); if (VAR_6 != QEMU_VM_FILE_MAGIC)
goto fail; VAR_6 = qemu_get_be32(VAR_0); if (VAR_6 != QEMU_VM_FILE_VERSION) { fail:
VAR_2 = -1; goto the_end; } total_len = qemu_get_be64(VAR_0); end_pos = total_len + qemu_ftell(VAR_0); for(;;) { if (qemu_ftell(VAR_0) >= end_pos)
break; VAR_1 = qemu_get_byte(VAR_0); qemu_get_buffer(VAR_0, (uint8_t *)VAR_7, VAR_1); VAR_7[VAR_1] = '\0'; VAR_3 = qemu_get_be32(VAR_0); VAR_5 = qemu_get_be32(VAR_0); VAR_4 = qemu_get_be32(VAR_0); #if 0
printf("VAR_7=%s instance=0x%x version=%d VAR_1=%d\n",
VAR_7, VAR_3, VAR_5, VAR_4); #endif
cur_pos = qemu_ftell(VAR_0); se = find_se(VAR_7, VAR_3); if (!se) { fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n",
VAR_3, VAR_7); } else { VAR_2 = se->load_state(VAR_0, se->opaque, VAR_5); if (VAR_2 < 0) { fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n",
VAR_3, VAR_7); } } qemu_fseek(VAR_0, cur_pos + VAR_4, SEEK_SET); } VAR_2 = 0; the_end:
return VAR_2; }