From patchwork Wed Jan 31 06:02:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 10193285 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 7AD2760380 for ; Wed, 31 Jan 2018 06:10:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66F9D28478 for ; Wed, 31 Jan 2018 06:10:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5960F2847D; Wed, 31 Jan 2018 06:10:01 +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 DF60728478 for ; Wed, 31 Jan 2018 06:10:00 +0000 (UTC) Received: from localhost ([::1]:37766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eglao-0003D2-5c for patchwork-qemu-devel@patchwork.kernel.org; Wed, 31 Jan 2018 01:09:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eglUT-0006Tj-BV for qemu-devel@nongnu.org; Wed, 31 Jan 2018 01:03:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eglUS-0007g1-Bo for qemu-devel@nongnu.org; Wed, 31 Jan 2018 01:03:25 -0500 Received: from mga12.intel.com ([192.55.52.136]:50362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eglUR-0007QP-Vu for qemu-devel@nongnu.org; Wed, 31 Jan 2018 01:03:24 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2018 22:03:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,438,1511856000"; d="scan'208";a="200149433" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.13.35]) by fmsmga006.fm.intel.com with ESMTP; 30 Jan 2018 22:03:20 -0800 From: Haozhong Zhang To: qemu-devel@nongnu.org Date: Wed, 31 Jan 2018 14:02:28 +0800 Message-Id: <20180131060229.9294-6-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180131060229.9294-1-haozhong.zhang@intel.com> References: <20180131060229.9294-1-haozhong.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.136 Subject: [Qemu-devel] [PATCH v4 5/6] hostmem: add more information in error messages 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: Haozhong Zhang , Xiao Guangrong , mst@redhat.com, dgilbert@redhat.com, Stefan Hajnoczi , Paolo Bonzini , Igor Mammedov , Dan Williams , Eduardo Habkost Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When there are multiple memory backends in use, including the object type name, ID and the property name in the error message can help users to locate the error. Signed-off-by: Haozhong Zhang Suggested-by: "Dr. David Alan Gilbert" Reviewed-by: Michael S. Tsirkin --- backends/hostmem-file.c | 9 ++++++--- backends/hostmem.c | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 67ecfed895..df06b547a6 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -80,7 +80,8 @@ static void set_mem_path(Object *o, const char *str, Error **errp) HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o); if (host_memory_backend_mr_inited(backend)) { - error_setg(errp, "cannot change property value"); + error_setg(errp, "cannot change property 'mem-path' of %s '%s'", + object_get_typename(o), backend->id); return; } g_free(fb->mem_path); @@ -100,7 +101,8 @@ static void file_memory_backend_set_share(Object *o, bool value, Error **errp) HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o); if (host_memory_backend_mr_inited(backend)) { - error_setg(errp, "cannot change property value"); + error_setg(errp, "cannot change property 'share' of %s '%s'", + object_get_typename(o), backend->id); return; } fb->share = value; @@ -137,7 +139,8 @@ static void file_memory_backend_set_align(Object *o, Visitor *v, uint64_t val; if (host_memory_backend_mr_inited(backend)) { - error_setg(&local_err, "cannot change property value"); + error_setg(&local_err, "cannot change property '%s' of %s '%s'", + name, object_get_typename(o), backend->id); goto out; } diff --git a/backends/hostmem.c b/backends/hostmem.c index ee2c2d5bfd..6853d19bc5 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -46,7 +46,8 @@ host_memory_backend_set_size(Object *obj, Visitor *v, const char *name, uint64_t value; if (host_memory_backend_mr_inited(backend)) { - error_setg(&local_err, "cannot change property value"); + error_setg(&local_err, "cannot change property %s of %s '%s'", + name, object_get_typename(obj), backend->id); goto out; } @@ -55,8 +56,9 @@ host_memory_backend_set_size(Object *obj, Visitor *v, const char *name, goto out; } if (!value) { - error_setg(&local_err, "Property '%s.%s' doesn't take value '%" - PRIu64 "'", object_get_typename(obj), name, value); + error_setg(&local_err, + "property '%s' of %s '%s' doesn't take value '%" PRIu64 "'", + name, object_get_typename(obj), backend->id, value); goto out; } backend->size = value; @@ -363,7 +365,8 @@ static void set_id(Object *o, const char *str, Error **errp) HostMemoryBackend *backend = MEMORY_BACKEND(o); if (backend->id) { - error_setg(errp, "cannot change property value"); + error_setg(errp, "cannot change property 'id' of %s '%s'", + object_get_typename(o), backend->id); return; } backend->id = g_strdup(str);