From patchwork Tue Jun 6 16:55:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Halil Pasic X-Patchwork-Id: 9769279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D85BC60364 for ; Tue, 6 Jun 2017 16:58:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D664025223 for ; Tue, 6 Jun 2017 16:58:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9E3427C05; Tue, 6 Jun 2017 16:58:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CA57325223 for ; Tue, 6 Jun 2017 16:58:21 +0000 (UTC) Received: from localhost ([::1]:39347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIHoD-0003Kz-1Q for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Jun 2017 12:58:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIHlW-0001WZ-7K for qemu-devel@nongnu.org; Tue, 06 Jun 2017 12:55:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIHlS-0006OL-BJ for qemu-devel@nongnu.org; Tue, 06 Jun 2017 12:55:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIHlS-0006NG-2J for qemu-devel@nongnu.org; Tue, 06 Jun 2017 12:55:30 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v56GsBcx145242 for ; Tue, 6 Jun 2017 12:55:28 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2awvegpe4h-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 06 Jun 2017 12:55:28 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Jun 2017 17:55:25 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Jun 2017 17:55:23 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v56GtNUE38994114; Tue, 6 Jun 2017 16:55:23 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D7264C04E; Tue, 6 Jun 2017 17:53:43 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A3AB4C040; Tue, 6 Jun 2017 17:53:43 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 6 Jun 2017 17:53:43 +0100 (BST) From: Halil Pasic To: "Dr. David Alan Gilbert" Date: Tue, 6 Jun 2017 18:55:08 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170606165510.33057-1-pasic@linux.vnet.ibm.com> References: <20170606165510.33057-1-pasic@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17060616-0040-0000-0000-000003A31338 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060616-0041-0000-0000-0000259AE4DC Message-Id: <20170606165510.33057-2-pasic@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-06_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706060291 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [RFC PATCH 1/3] vmstate: error hint for failed equal checks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Halil Pasic , qemu-devel@nongnu.org, "Jason J . Herne" , Juan Quintela Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In some cases a failing VMSTATE_*_EQUAL does not mean we detected a bug (it's actually the best we can do). Especially in these cases a verbose error message is required. Let's introduce infrastructure for specifying a error hint to be used if equal check fails. Signed-off-by: Halil Pasic --- Macros come in part 2. Once we are happy with the macros this two patches should be squashed into one. --- include/migration/vmstate.h | 1 + migration/vmstate-types.c | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 66895623da..d90d9b12ca 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -200,6 +200,7 @@ typedef enum { struct VMStateField { const char *name; + const char *err_hint; size_t offset; size_t size; size_t start; diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 7287c6baa6..84d0545a38 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -19,6 +19,7 @@ #include "qemu/error-report.h" #include "qemu/queue.h" #include "trace.h" +#include "qapi/error.h" /* bool */ @@ -118,6 +119,7 @@ const VMStateInfo vmstate_info_int32 = { static int get_int32_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { + Error *err = NULL; int32_t *v = pv; int32_t v2; qemu_get_sbe32s(f, &v2); @@ -125,7 +127,11 @@ static int get_int32_equal(QEMUFile *f, void *pv, size_t size, if (*v == v2) { return 0; } - error_report("%" PRIx32 " != %" PRIx32, *v, v2); + error_setg(&err, "%" PRIx32 " != %" PRIx32, *v, v2); + if (field->err_hint) { + error_append_hint(&err, "%s\n", field->err_hint); + } + error_report_err(err); return -EINVAL; } @@ -259,6 +265,7 @@ const VMStateInfo vmstate_info_uint32 = { static int get_uint32_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { + Error *err = NULL; uint32_t *v = pv; uint32_t v2; qemu_get_be32s(f, &v2); @@ -266,7 +273,11 @@ static int get_uint32_equal(QEMUFile *f, void *pv, size_t size, if (*v == v2) { return 0; } - error_report("%" PRIx32 " != %" PRIx32, *v, v2); + error_setg(&err, "%" PRIx32 " != %" PRIx32, *v, v2); + if (field->err_hint) { + error_append_hint(&err, "%s\n", field->err_hint); + } + error_report_err(err); return -EINVAL; } @@ -333,6 +344,7 @@ const VMStateInfo vmstate_info_nullptr = { static int get_uint64_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { + Error *err = NULL; uint64_t *v = pv; uint64_t v2; qemu_get_be64s(f, &v2); @@ -340,7 +352,11 @@ static int get_uint64_equal(QEMUFile *f, void *pv, size_t size, if (*v == v2) { return 0; } - error_report("%" PRIx64 " != %" PRIx64, *v, v2); + error_setg(&err, "%" PRIx64 " != %" PRIx64, *v, v2); + if (field->err_hint) { + error_append_hint(&err, "%s\n", field->err_hint); + } + error_report_err(err); return -EINVAL; } @@ -356,6 +372,7 @@ const VMStateInfo vmstate_info_uint64_equal = { static int get_uint8_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { + Error *err = NULL; uint8_t *v = pv; uint8_t v2; qemu_get_8s(f, &v2); @@ -363,7 +380,11 @@ static int get_uint8_equal(QEMUFile *f, void *pv, size_t size, if (*v == v2) { return 0; } - error_report("%x != %x", *v, v2); + error_setg(&err, "%x != %x", *v, v2); + if (field->err_hint) { + error_append_hint(&err, "%s\n", field->err_hint); + } + error_report_err(err); return -EINVAL; } @@ -379,6 +400,7 @@ const VMStateInfo vmstate_info_uint8_equal = { static int get_uint16_equal(QEMUFile *f, void *pv, size_t size, VMStateField *field) { + Error *err = NULL; uint16_t *v = pv; uint16_t v2; qemu_get_be16s(f, &v2); @@ -386,7 +408,11 @@ static int get_uint16_equal(QEMUFile *f, void *pv, size_t size, if (*v == v2) { return 0; } - error_report("%x != %x", *v, v2); + error_setg(&err, "%x != %x", *v, v2); + if (field->err_hint) { + error_append_hint(&err, "%s\n", field->err_hint); + } + error_report_err(err); return -EINVAL; }