savevm: Convert fprintf to error_report

Convert a bunch of fprintfs to error_reports

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
Dr. David Alan Gilbert 2015-01-21 10:14:47 +00:00 committed by Juan Quintela
parent 027f15696d
commit 6a64b644ac
2 changed files with 15 additions and 13 deletions

View File

@ -3,6 +3,7 @@
#include "migration/qemu-file.h" #include "migration/qemu-file.h"
#include "migration/vmstate.h" #include "migration/vmstate.h"
#include "qemu/bitops.h" #include "qemu/bitops.h"
#include "qemu/error-report.h"
#include "trace.h" #include "trace.h"
static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
@ -122,8 +123,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
} }
} }
} else if (field->flags & VMS_MUST_EXIST) { } else if (field->flags & VMS_MUST_EXIST) {
fprintf(stderr, "Input validation failed: %s/%s\n", error_report("Input validation failed: %s/%s",
vmsd->name, field->name); vmsd->name, field->name);
return -1; return -1;
} }
field++; field++;
@ -167,7 +168,7 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
} }
} else { } else {
if (field->flags & VMS_MUST_EXIST) { if (field->flags & VMS_MUST_EXIST) {
fprintf(stderr, "Output state validation failed: %s/%s\n", error_report("Output state validation failed: %s/%s",
vmsd->name, field->name); vmsd->name, field->name);
assert(!(field->flags & VMS_MUST_EXIST)); assert(!(field->flags & VMS_MUST_EXIST));
} }

View File

@ -898,7 +898,7 @@ int qemu_loadvm_state(QEMUFile *f)
v = qemu_get_be32(f); v = qemu_get_be32(f);
if (v == QEMU_VM_FILE_VERSION_COMPAT) { if (v == QEMU_VM_FILE_VERSION_COMPAT) {
fprintf(stderr, "SaveVM v2 format is obsolete and don't work anymore\n"); error_report("SaveVM v2 format is obsolete and don't work anymore");
return -ENOTSUP; return -ENOTSUP;
} }
if (v != QEMU_VM_FILE_VERSION) { if (v != QEMU_VM_FILE_VERSION) {
@ -925,15 +925,16 @@ int qemu_loadvm_state(QEMUFile *f)
/* Find savevm section */ /* Find savevm section */
se = find_se(idstr, instance_id); se = find_se(idstr, instance_id);
if (se == NULL) { if (se == NULL) {
fprintf(stderr, "Unknown savevm section or instance '%s' %d\n", idstr, instance_id); error_report("Unknown savevm section or instance '%s' %d",
idstr, instance_id);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
/* Validate version */ /* Validate version */
if (version_id > se->version_id) { if (version_id > se->version_id) {
fprintf(stderr, "savevm: unsupported version %d for '%s' v%d\n", error_report("savevm: unsupported version %d for '%s' v%d",
version_id, idstr, se->version_id); version_id, idstr, se->version_id);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
@ -948,8 +949,8 @@ int qemu_loadvm_state(QEMUFile *f)
ret = vmstate_load(f, le->se, le->version_id); ret = vmstate_load(f, le->se, le->version_id);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n", error_report("error while loading state for instance 0x%x of"
instance_id, idstr); " device '%s'", instance_id, idstr);
goto out; goto out;
} }
break; break;
@ -963,20 +964,20 @@ int qemu_loadvm_state(QEMUFile *f)
} }
} }
if (le == NULL) { if (le == NULL) {
fprintf(stderr, "Unknown savevm section %d\n", section_id); error_report("Unknown savevm section %d", section_id);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
ret = vmstate_load(f, le->se, le->version_id); ret = vmstate_load(f, le->se, le->version_id);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "qemu: warning: error while loading state section id %d\n", error_report("error while loading state section id %d(%s)",
section_id); section_id, le->se->idstr);
goto out; goto out;
} }
break; break;
default: default:
fprintf(stderr, "Unknown savevm section type %d\n", section_type); error_report("Unknown savevm section type %d", section_type);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }