From patchwork Wed Jan 17 08:13:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 10168729 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 A6055601D3 for ; Wed, 17 Jan 2018 08:20:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8165D283CF for ; Wed, 17 Jan 2018 08:20:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 801EE2844E; Wed, 17 Jan 2018 08:20:49 +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 1C8F928468 for ; Wed, 17 Jan 2018 08:20:48 +0000 (UTC) Received: from localhost ([::1]:46731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebixk-0006yr-88 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 17 Jan 2018 03:20:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebitc-0003qn-0u for qemu-devel@nongnu.org; Wed, 17 Jan 2018 03:16:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebita-00064P-CB for qemu-devel@nongnu.org; Wed, 17 Jan 2018 03:16:31 -0500 Received: from mga03.intel.com ([134.134.136.65]:44721) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebita-0005wC-0A for qemu-devel@nongnu.org; Wed, 17 Jan 2018 03:16:30 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2018 00:16:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,372,1511856000"; d="scan'208";a="23986406" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.13.35]) by orsmga001.jf.intel.com with ESMTP; 17 Jan 2018 00:16:26 -0800 From: Haozhong Zhang To: qemu-devel@nongnu.org Date: Wed, 17 Jan 2018 16:13:24 +0800 Message-Id: <20180117081325.11924-3-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180117081325.11924-1-haozhong.zhang@intel.com> References: <20180117081325.11924-1-haozhong.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Subject: [Qemu-devel] [PATCH v3 2/3] 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 e319ec1ad8..ed7d145365 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -79,7 +79,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); @@ -99,7 +100,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; @@ -136,7 +138,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);