Lines Matching refs:vmsd

23 static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
25 static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
78 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, in vmstate_load_state() argument
81 const VMStateField *field = vmsd->fields; in vmstate_load_state()
84 trace_vmstate_load_state(vmsd->name, version_id); in vmstate_load_state()
85 if (version_id > vmsd->version_id) { in vmstate_load_state()
88 vmsd->name, version_id, vmsd->version_id); in vmstate_load_state()
89 trace_vmstate_load_state_end(vmsd->name, "too new", -EINVAL); in vmstate_load_state()
92 if (version_id < vmsd->minimum_version_id) { in vmstate_load_state()
93 if (vmsd->load_state_old && in vmstate_load_state()
94 version_id >= vmsd->minimum_version_id_old) { in vmstate_load_state()
95 ret = vmsd->load_state_old(f, opaque, version_id); in vmstate_load_state()
96 trace_vmstate_load_state_end(vmsd->name, "old path", ret); in vmstate_load_state()
101 vmsd->name, version_id, vmsd->minimum_version_id); in vmstate_load_state()
102 trace_vmstate_load_state_end(vmsd->name, "too old", -EINVAL); in vmstate_load_state()
105 if (vmsd->pre_load) { in vmstate_load_state()
106 int ret = vmsd->pre_load(opaque); in vmstate_load_state()
112 trace_vmstate_load_state_field(vmsd->name, field->name); in vmstate_load_state()
137 ret = vmstate_load_state(f, field->vmsd, curr_elem, in vmstate_load_state()
138 field->vmsd->version_id); in vmstate_load_state()
140 ret = vmstate_load_state(f, field->vmsd, curr_elem, in vmstate_load_state()
150 error_report("Failed to load %s:%s", vmsd->name, in vmstate_load_state()
158 vmsd->name, field->name); in vmstate_load_state()
163 ret = vmstate_subsection_load(f, vmsd, opaque); in vmstate_load_state()
167 if (vmsd->post_load) { in vmstate_load_state()
168 ret = vmsd->post_load(opaque, version_id); in vmstate_load_state()
170 trace_vmstate_load_state_end(vmsd->name, "end", ret); in vmstate_load_state()
234 const VMStateField *sfield = field->vmsd->fields; in vmsd_can_compress()
243 if (field->vmsd->subsections) { in vmsd_can_compress()
252 static void vmsd_desc_field_start(const VMStateDescription *vmsd, in vmsd_desc_field_start() argument
267 if (!vmfield_name_is_unique(vmsd->fields, field)) { in vmsd_desc_field_start()
268 int num = vmfield_name_num(vmsd->fields, field); in vmsd_desc_field_start()
292 static void vmsd_desc_field_end(const VMStateDescription *vmsd, in vmsd_desc_field_end() argument
310 bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque) in vmstate_save_needed() argument
312 if (vmsd->needed && !vmsd->needed(opaque)) { in vmstate_save_needed()
320 int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, in vmstate_save_state() argument
323 return vmstate_save_state_v(f, vmsd, opaque, vmdesc_id, vmsd->version_id); in vmstate_save_state()
326 int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, in vmstate_save_state_v() argument
330 const VMStateField *field = vmsd->fields; in vmstate_save_state_v()
332 trace_vmstate_save_state_top(vmsd->name); in vmstate_save_state_v()
334 if (vmsd->pre_save) { in vmstate_save_state_v()
335 ret = vmsd->pre_save(opaque); in vmstate_save_state_v()
336 trace_vmstate_save_state_pre_save_res(vmsd->name, ret); in vmstate_save_state_v()
338 error_report("pre-save failed: %s", vmsd->name); in vmstate_save_state_v()
344 json_writer_str(vmdesc, "vmsd_name", vmsd->name); in vmstate_save_state_v()
360 trace_vmstate_save_state_loop(vmsd->name, field->name, n_elems); in vmstate_save_state_v()
368 vmsd_desc_field_start(vmsd, vmdesc_loop, field, i, n_elems); in vmstate_save_state_v()
380 ret = vmstate_save_state(f, field->vmsd, curr_elem, in vmstate_save_state_v()
383 ret = vmstate_save_state_v(f, field->vmsd, curr_elem, in vmstate_save_state_v()
392 vmsd->name, field->name); in vmstate_save_state_v()
393 if (vmsd->post_save) { in vmstate_save_state_v()
394 vmsd->post_save(opaque); in vmstate_save_state_v()
400 vmsd_desc_field_end(vmsd, vmdesc_loop, field, written_bytes, i); in vmstate_save_state_v()
410 vmsd->name, field->name); in vmstate_save_state_v()
421 ret = vmstate_subsection_save(f, vmsd, opaque, vmdesc); in vmstate_save_state_v()
423 if (vmsd->post_save) { in vmstate_save_state_v()
424 int ps_ret = vmsd->post_save(opaque); in vmstate_save_state_v()
444 static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd, in vmstate_subsection_load() argument
447 trace_vmstate_subsection_load(vmsd->name); in vmstate_subsection_load()
456 if (len < strlen(vmsd->name) + 1) { in vmstate_subsection_load()
458 trace_vmstate_subsection_load_bad(vmsd->name, "(short)", ""); in vmstate_subsection_load()
463 trace_vmstate_subsection_load_bad(vmsd->name, "(peek fail)", ""); in vmstate_subsection_load()
469 if (strncmp(vmsd->name, idstr, strlen(vmsd->name)) != 0) { in vmstate_subsection_load()
470 trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(prefix)"); in vmstate_subsection_load()
474 sub_vmsd = vmstate_get_subsection(vmsd->subsections, idstr); in vmstate_subsection_load()
476 trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(lookup)"); in vmstate_subsection_load()
486 trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(child)"); in vmstate_subsection_load()
491 trace_vmstate_subsection_load_good(vmsd->name); in vmstate_subsection_load()
495 static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, in vmstate_subsection_save() argument
498 const VMStateDescription **sub = vmsd->subsections; in vmstate_subsection_save()
502 trace_vmstate_subsection_save_top(vmsd->name); in vmstate_subsection_save()
508 trace_vmstate_subsection_save_loop(vmsd->name, vmsdsub->name); in vmstate_subsection_save()