From patchwork Wed Jan 21 10:14:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 431405 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 84F7514014D for ; Wed, 21 Jan 2015 21:15:29 +1100 (AEDT) Received: from localhost ([::1]:47349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDsJr-0007tu-N4 for incoming@patchwork.ozlabs.org; Wed, 21 Jan 2015 05:15:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDsJQ-0007Ei-7g for qemu-devel@nongnu.org; Wed, 21 Jan 2015 05:15:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDsJK-0007Rg-2e for qemu-devel@nongnu.org; Wed, 21 Jan 2015 05:15:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43995) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDsJJ-0007Ra-SH for qemu-devel@nongnu.org; Wed, 21 Jan 2015 05:14:54 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0LAErV7020941 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 21 Jan 2015 05:14:53 -0500 Received: from dgilbert-t530.redhat.com (ovpn-116-96.ams2.redhat.com [10.36.116.96]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0LAEnPX026969; Wed, 21 Jan 2015 05:14:52 -0500 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Wed, 21 Jan 2015 10:14:47 +0000 Message-Id: <1421835289-15020-2-git-send-email-dgilbert@redhat.com> In-Reply-To: <1421835289-15020-1-git-send-email-dgilbert@redhat.com> References: <1421835289-15020-1-git-send-email-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: amit.shah@redhat.com, stefanha@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH v2 1/3] savevm: Convert fprintf to error_report X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Dr. David Alan Gilbert" Convert a bunch of fprintfs to error_reports Signed-off-by: Dr. David Alan Gilbert --- migration/vmstate.c | 7 ++++--- savevm.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 3dde574..2c0b135 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -3,6 +3,7 @@ #include "migration/qemu-file.h" #include "migration/vmstate.h" #include "qemu/bitops.h" +#include "qemu/error-report.h" #include "trace.h" 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) { - fprintf(stderr, "Input validation failed: %s/%s\n", - vmsd->name, field->name); + error_report("Input validation failed: %s/%s", + vmsd->name, field->name); return -1; } field++; @@ -167,7 +168,7 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, } } else { 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); assert(!(field->flags & VMS_MUST_EXIST)); } diff --git a/savevm.c b/savevm.c index 08ec678..48c2396 100644 --- a/savevm.c +++ b/savevm.c @@ -898,7 +898,7 @@ int qemu_loadvm_state(QEMUFile *f) v = qemu_get_be32(f); 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; } if (v != QEMU_VM_FILE_VERSION) { @@ -925,15 +925,16 @@ int qemu_loadvm_state(QEMUFile *f) /* Find savevm section */ se = find_se(idstr, instance_id); 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; goto out; } /* Validate version */ if (version_id > se->version_id) { - fprintf(stderr, "savevm: unsupported version %d for '%s' v%d\n", - version_id, idstr, se->version_id); + error_report("savevm: unsupported version %d for '%s' v%d", + version_id, idstr, se->version_id); ret = -EINVAL; goto out; } @@ -948,8 +949,8 @@ int qemu_loadvm_state(QEMUFile *f) ret = vmstate_load(f, le->se, le->version_id); if (ret < 0) { - fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n", - instance_id, idstr); + error_report("error while loading state for instance 0x%x of" + " device '%s'", instance_id, idstr); goto out; } break; @@ -963,20 +964,20 @@ int qemu_loadvm_state(QEMUFile *f) } } if (le == NULL) { - fprintf(stderr, "Unknown savevm section %d\n", section_id); + error_report("Unknown savevm section %d", section_id); ret = -EINVAL; goto out; } ret = vmstate_load(f, le->se, le->version_id); if (ret < 0) { - fprintf(stderr, "qemu: warning: error while loading state section id %d\n", - section_id); + error_report("error while loading state section id %d(%s)", + section_id, le->se->idstr); goto out; } break; default: - fprintf(stderr, "Unknown savevm section type %d\n", section_type); + error_report("Unknown savevm section type %d", section_type); ret = -EINVAL; goto out; }