int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,

                       void *opaque, int version_id)

{

    VMStateField *field = vmsd->fields;

    int ret = 0;



    trace_vmstate_load_state(vmsd->name, version_id);

    if (version_id > vmsd->version_id) {

        error_report("%s: incoming version_id %d is too new "

                     "for local version_id %d",

                     vmsd->name, version_id, vmsd->version_id);

        trace_vmstate_load_state_end(vmsd->name, "too new", -EINVAL);

        return -EINVAL;

    }

    if  (version_id < vmsd->minimum_version_id) {

        if (vmsd->load_state_old &&

            version_id >= vmsd->minimum_version_id_old) {

            ret = vmsd->load_state_old(f, opaque, version_id);

            trace_vmstate_load_state_end(vmsd->name, "old path", ret);

            return ret;

        }

        error_report("%s: incoming version_id %d is too old "

                     "for local minimum version_id  %d",

                     vmsd->name, version_id, vmsd->minimum_version_id);

        trace_vmstate_load_state_end(vmsd->name, "too old", -EINVAL);

        return -EINVAL;

    }

    if (vmsd->pre_load) {

        int ret = vmsd->pre_load(opaque);

        if (ret) {

            return ret;

        }

    }

    while (field->name) {

        trace_vmstate_load_state_field(vmsd->name, field->name);

        if ((field->field_exists &&

             field->field_exists(opaque, version_id)) ||

            (!field->field_exists &&

             field->version_id <= version_id)) {

            void *first_elem = opaque + field->offset;

            int i, n_elems = vmstate_n_elems(opaque, field);

            int size = vmstate_size(opaque, field);



            vmstate_handle_alloc(first_elem, field, opaque);

            if (field->flags & VMS_POINTER) {

                first_elem = *(void **)first_elem;

                assert(first_elem  || !n_elems);

            }

            for (i = 0; i < n_elems; i++) {

                void *curr_elem = first_elem + size * i;



                if (field->flags & VMS_ARRAY_OF_POINTER) {

                    curr_elem = *(void **)curr_elem;

                }

                if (field->flags & VMS_STRUCT) {

                    ret = vmstate_load_state(f, field->vmsd, curr_elem,

                                             field->vmsd->version_id);

                } else {

                    ret = field->info->get(f, curr_elem, size, field);

                }

                if (ret >= 0) {

                    ret = qemu_file_get_error(f);

                }

                if (ret < 0) {

                    qemu_file_set_error(f, ret);

                    error_report("Failed to load %s:%s", vmsd->name,

                                 field->name);

                    trace_vmstate_load_field_error(field->name, ret);

                    return ret;

                }

            }

        } else if (field->flags & VMS_MUST_EXIST) {

            error_report("Input validation failed: %s/%s",

                         vmsd->name, field->name);

            return -1;

        }

        field++;

    }

    ret = vmstate_subsection_load(f, vmsd, opaque);

    if (ret != 0) {

        return ret;

    }

    if (vmsd->post_load) {

        ret = vmsd->post_load(opaque, version_id);

    }

    trace_vmstate_load_state_end(vmsd->name, "end", ret);

    return ret;

}

int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,

                       void *opaque, int version_id)

{

    VMStateField *field = vmsd->fields;

    int ret = 0;



    trace_vmstate_load_state(vmsd->name, version_id);

    if (version_id > vmsd->version_id) {

        error_report("%s: incoming version_id %d is too new "

                     "for local version_id %d",

                     vmsd->name, version_id, vmsd->version_id);

        trace_vmstate_load_state_end(vmsd->name, "too new", -EINVAL);

        return -EINVAL;

    }

    if  (version_id < vmsd->minimum_version_id) {

        if (vmsd->load_state_old &&

            version_id >= vmsd->minimum_version_id_old) {

            ret = vmsd->load_state_old(f, opaque, version_id);

            trace_vmstate_load_state_end(vmsd->name, "old path", ret);

            return ret;

        }

        error_report("%s: incoming version_id %d is too old "

                     "for local minimum version_id  %d",

                     vmsd->name, version_id, vmsd->minimum_version_id);

        trace_vmstate_load_state_end(vmsd->name, "too old", -EINVAL);

        return -EINVAL;

    }

    if (vmsd->pre_load) {

        int ret = vmsd->pre_load(opaque);

        if (ret) {

            return ret;

        }

    }

    while (field->name) {

        trace_vmstate_load_state_field(vmsd->name, field->name);

        if ((field->field_exists &&

             field->field_exists(opaque, version_id)) ||

            (!field->field_exists &&

             field->version_id <= version_id)) {

            void *first_elem = opaque + field->offset;

            int i, n_elems = vmstate_n_elems(opaque, field);

            int size = vmstate_size(opaque, field);



            vmstate_handle_alloc(first_elem, field, opaque);

            if (field->flags & VMS_POINTER) {

                first_elem = *(void **)first_elem;

                assert(first_elem  || !n_elems);

            }

            for (i = 0; i < n_elems; i++) {

                void *curr_elem = first_elem + size * i;



                if (field->flags & VMS_ARRAY_OF_POINTER) {

                    curr_elem = *(void **)curr_elem;

                }

                if (field->flags & VMS_STRUCT) {

                    ret = vmstate_load_state(f, field->vmsd, curr_elem,

                                             field->vmsd->version_id);

                } else {

                    ret = field->info->get(f, curr_elem, size, field);

                }

                if (ret >= 0) {

                    ret = qemu_file_get_error(f);

                }

                if (ret < 0) {

                    qemu_file_set_error(f, ret);

                    error_report("Failed to load %s:%s", vmsd->name,

                                 field->name);

                    trace_vmstate_load_field_error(field->name, ret);

                    return ret;

                }

            }

        } else if (field->flags & VMS_MUST_EXIST) {

            error_report("Input validation failed: %s/%s",

                         vmsd->name, field->name);

            return -1;

        }

        field++;

    }

    ret = vmstate_subsection_load(f, vmsd, opaque);

    if (ret != 0) {

        return ret;

    }

    if (vmsd->post_load) {

        ret = vmsd->post_load(opaque, version_id);

    }

    trace_vmstate_load_state_end(vmsd->name, "end", ret);

    return ret;

}

                if (field->flags & VMS_STRUCT) {                 if (field->flags & VMS_STRUCT) {
int FUNC_0(QEMUFile *VAR_0, const VMStateDescription *VAR_1,

                       void *VAR_2, int VAR_3)

{

    VMStateField *field = VAR_1->fields;

    int VAR_5 = 0;



    trace_vmstate_load_state(VAR_1->name, VAR_3);

    if (VAR_3 > VAR_1->VAR_3) {

        error_report("%s: incoming VAR_3 %d is too new "

                     "for local VAR_3 %d",

                     VAR_1->name, VAR_3, VAR_1->VAR_3);

        trace_vmstate_load_state_end(VAR_1->name, "too new", -EINVAL);

        return -EINVAL;

    }

    if  (VAR_3 < VAR_1->minimum_version_id) {

        if (VAR_1->load_state_old &&

            VAR_3 >= VAR_1->minimum_version_id_old) {

            VAR_5 = VAR_1->load_state_old(VAR_0, VAR_2, VAR_3);

            trace_vmstate_load_state_end(VAR_1->name, "old path", VAR_5);

            return VAR_5;

        }

        error_report("%s: incoming VAR_3 %d is too old "

                     "for local minimum VAR_3  %d",

                     VAR_1->name, VAR_3, VAR_1->minimum_version_id);

        trace_vmstate_load_state_end(VAR_1->name, "too old", -EINVAL);

        return -EINVAL;

    }

    if (VAR_1->pre_load) {

        int VAR_5 = VAR_1->pre_load(VAR_2);

        if (VAR_5) {

            return VAR_5;

        }

    }

    while (field->name) {

        trace_vmstate_load_state_field(VAR_1->name, field->name);

        if ((field->field_exists &&

             field->field_exists(VAR_2, VAR_3)) ||

            (!field->field_exists &&

             field->VAR_3 <= VAR_3)) {

            void *VAR_5 = VAR_2 + field->offset;

            int VAR_6, VAR_7 = vmstate_n_elems(VAR_2, field);

            int VAR_8 = vmstate_size(VAR_2, field);



            vmstate_handle_alloc(VAR_5, field, VAR_2);

            if (field->flags & VMS_POINTER) {

                VAR_5 = *(void **)VAR_5;

                assert(VAR_5  || !VAR_7);

            }

            for (VAR_6 = 0; VAR_6 < VAR_7; VAR_6++) {

                void *VAR_9 = VAR_5 + VAR_8 * VAR_6;



                if (field->flags & VMS_ARRAY_OF_POINTER) {

                    VAR_9 = *(void **)VAR_9;

                }

                if (field->flags & VMS_STRUCT) {

                    VAR_5 = FUNC_0(VAR_0, field->VAR_1, VAR_9,

                                             field->VAR_1->VAR_3);

                } else {

                    VAR_5 = field->info->get(VAR_0, VAR_9, VAR_8, field);

                }

                if (VAR_5 >= 0) {

                    VAR_5 = qemu_file_get_error(VAR_0);

                }

                if (VAR_5 < 0) {

                    qemu_file_set_error(VAR_0, VAR_5);

                    error_report("Failed to load %s:%s", VAR_1->name,

                                 field->name);

                    trace_vmstate_load_field_error(field->name, VAR_5);

                    return VAR_5;

                }

            }

        } else if (field->flags & VMS_MUST_EXIST) {

            error_report("Input validation failed: %s/%s",

                         VAR_1->name, field->name);

            return -1;

        }

        field++;

    }

    VAR_5 = vmstate_subsection_load(VAR_0, VAR_1, VAR_2);

    if (VAR_5 != 0) {

        return VAR_5;

    }

    if (VAR_1->post_load) {

        VAR_5 = VAR_1->post_load(VAR_2, VAR_3);

    }

    trace_vmstate_load_state_end(VAR_1->name, "end", VAR_5);

    return VAR_5;

}

int FUNC_0(QEMUFile *VAR_0, const VMStateDescription *VAR_1,
void *VAR_2, int VAR_3)
{ VMStateField *field = VAR_1->fields; int VAR_5 = 0; trace_vmstate_load_state(VAR_1->name, VAR_3); if (VAR_3 > VAR_1->VAR_3) { error_report("%s: incoming VAR_3 %d is too new "
"for local VAR_3 %d",
VAR_1->name, VAR_3, VAR_1->VAR_3); trace_vmstate_load_state_end(VAR_1->name, "too new", -EINVAL); return -EINVAL; } if  (VAR_3 < VAR_1->minimum_version_id) { if (VAR_1->load_state_old &&
VAR_3 >= VAR_1->minimum_version_id_old) { VAR_5 = VAR_1->load_state_old(VAR_0, VAR_2, VAR_3); trace_vmstate_load_state_end(VAR_1->name, "old path", VAR_5); return VAR_5; } error_report("%s: incoming VAR_3 %d is too old "
"for local minimum VAR_3  %d",
VAR_1->name, VAR_3, VAR_1->minimum_version_id); trace_vmstate_load_state_end(VAR_1->name, "too old", -EINVAL); return -EINVAL; } if (VAR_1->pre_load) { int VAR_5 = VAR_1->pre_load(VAR_2); if (VAR_5) { return VAR_5; } } while (field->name) { trace_vmstate_load_state_field(VAR_1->name, field->name); if ((field->field_exists &&
field->field_exists(VAR_2, VAR_3)) ||
(!field->field_exists &&
field->VAR_3 <= VAR_3)) { void *VAR_5 = VAR_2 + field->offset; int VAR_6, VAR_7 = vmstate_n_elems(VAR_2, field); int VAR_8 = vmstate_size(VAR_2, field); vmstate_handle_alloc(VAR_5, field, VAR_2); if (field->flags & VMS_POINTER) { VAR_5 = *(void **)VAR_5; assert(VAR_5  || !VAR_7); } for (VAR_6 = 0; VAR_6 < VAR_7; VAR_6++) { void *VAR_9 = VAR_5 + VAR_8 * VAR_6; if (field->flags & VMS_ARRAY_OF_POINTER) { VAR_9 = *(void **)VAR_9; } if (field->flags & VMS_STRUCT) { VAR_5 = FUNC_0(VAR_0, field->VAR_1, VAR_9,
field->VAR_1->VAR_3); } else { VAR_5 = field->info->get(VAR_0, VAR_9, VAR_8, field); } if (VAR_5 >= 0) { VAR_5 = qemu_file_get_error(VAR_0); } if (VAR_5 < 0) { qemu_file_set_error(VAR_0, VAR_5); error_report("Failed to load %s:%s", VAR_1->name,
field->name); trace_vmstate_load_field_error(field->name, VAR_5); return VAR_5; } } } else if (field->flags & VMS_MUST_EXIST) { error_report("Input validation failed: %s/%s",
VAR_1->name, field->name); return -1; } field++; } VAR_5 = vmstate_subsection_load(VAR_0, VAR_1, VAR_2); if (VAR_5 != 0) { return VAR_5; } if (VAR_1->post_load) { VAR_5 = VAR_1->post_load(VAR_2, VAR_3); } trace_vmstate_load_state_end(VAR_1->name, "end", VAR_5); return VAR_5; }