Fix device snapshots

This commit is contained in:
Andrea Fioraldi 2023-06-02 16:09:33 +02:00
parent d1c0659ca5
commit bd1f40e27e
2 changed files with 8 additions and 20 deletions

View File

@ -36,28 +36,18 @@ device_save_state_t* device_save_all(void) {
if (se->is_ram) { if (se->is_ram) {
continue; continue;
} }
if ((!se->ops || !se->ops->save_state) && !se->vmsd) {
continue;
}
if (se->vmsd && !vmstate_save_needed(se->vmsd, se->opaque)) {
continue;
}
if (!strcmp(se->idstr, "globalstate")) { if (!strcmp(se->idstr, "globalstate")) {
continue; continue;
} }
// SYX_PRINTF("Saving section %s...\n", se->idstr); // SYX_PRINTF("Saving section %s...\n", se->idstr);
save_section_header(f, se, QEMU_VM_SECTION_FULL);
ret = vmstate_save(f, se, NULL); ret = vmstate_save(f, se, NULL);
if (ret) { if (ret) {
SYX_PRINTF("Device save all error: %d\n", ret); SYX_PRINTF("Device save all error: %d\n", ret);
abort(); abort();
} }
save_section_footer(f, se);
} }
printf("\n"); printf("\n");

View File

@ -914,18 +914,10 @@ static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se,
} }
} }
//// --- Begin LibAFL code ---
void save_section_header(QEMUFile *f, SaveStateEntry *se, uint8_t section_type);
void save_section_footer(QEMUFile *f, SaveStateEntry *se);
int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc);
//// --- End LibAFL code ---
/* /*
* Write the header for device section (QEMU_VM_SECTION START/END/PART/FULL) * Write the header for device section (QEMU_VM_SECTION START/END/PART/FULL)
*/ */
/* static */ void save_section_header(QEMUFile *f, SaveStateEntry *se, static void save_section_header(QEMUFile *f, SaveStateEntry *se,
uint8_t section_type) uint8_t section_type)
{ {
qemu_put_byte(f, section_type); qemu_put_byte(f, section_type);
@ -947,7 +939,7 @@ int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc);
* Write a footer onto device sections that catches cases misformatted device * Write a footer onto device sections that catches cases misformatted device
* sections. * sections.
*/ */
/* static */ void save_section_footer(QEMUFile *f, SaveStateEntry *se) static void save_section_footer(QEMUFile *f, SaveStateEntry *se)
{ {
if (migrate_get_current()->send_section_footer) { if (migrate_get_current()->send_section_footer) {
qemu_put_byte(f, QEMU_VM_SECTION_FOOTER); qemu_put_byte(f, QEMU_VM_SECTION_FOOTER);
@ -955,6 +947,12 @@ int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc);
} }
} }
//// --- Begin LibAFL code ---
int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc);
//// --- End LibAFL code ---
/* static */ int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc) /* static */ int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc)
{ {
int ret; int ret;