mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
vmstate: Create optional sections
To make sections optional, we need to do it at the beggining of the code. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
parent
13d16814d2
commit
df8961522a
4 changed files with 22 additions and 0 deletions
|
@ -836,6 +836,11 @@ void qemu_savevm_state_complete(QEMUFile *f)
|
|||
if ((!se->ops || !se->ops->save_state) && !se->vmsd) {
|
||||
continue;
|
||||
}
|
||||
if (se->vmsd && !vmstate_save_needed(se->vmsd, se->opaque)) {
|
||||
trace_savevm_section_skip(se->idstr, se->section_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
trace_savevm_section_start(se->idstr, se->section_id);
|
||||
|
||||
json_start_object(vmdesc, NULL);
|
||||
|
@ -949,6 +954,9 @@ static int qemu_save_device_state(QEMUFile *f)
|
|||
if ((!se->ops || !se->ops->save_state) && !se->vmsd) {
|
||||
continue;
|
||||
}
|
||||
if (se->vmsd && !vmstate_save_needed(se->vmsd, se->opaque)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
save_section_header(f, se, QEMU_VM_SECTION_FULL);
|
||||
|
||||
|
|
|
@ -276,6 +276,17 @@ static void vmsd_desc_field_end(const VMStateDescription *vmsd, QJSON *vmdesc,
|
|||
json_end_object(vmdesc);
|
||||
}
|
||||
|
||||
|
||||
bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque)
|
||||
{
|
||||
if (vmsd->needed && !vmsd->needed(opaque)) {
|
||||
/* optional section not needed */
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
|
||||
void *opaque, QJSON *vmdesc)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue