From patchwork Thu Jan 14 15:09:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8032831 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9961FBEEE5 for ; Thu, 14 Jan 2016 15:12:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB99A20444 for ; Thu, 14 Jan 2016 15:12:38 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B44982037E for ; Thu, 14 Jan 2016 15:12:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJjX7-0004rR-4y; Thu, 14 Jan 2016 15:09:53 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJjX5-0004qk-Nx for xen-devel@lists.xensource.com; Thu, 14 Jan 2016 15:09:51 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id 00/D7-08977-F3AB7965; Thu, 14 Jan 2016 15:09:51 +0000 X-Env-Sender: armbru@redhat.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1452784183!10101281!1 X-Originating-IP: [209.132.183.28] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMjA5LjEzMi4xODMuMjggPT4gNTQwNjQ=\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29051 invoked from network); 14 Jan 2016 15:09:49 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by server-15.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Jan 2016 15:09:49 -0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id DE82B8DFE1; Thu, 14 Jan 2016 15:09:42 +0000 (UTC) Received: from blackfin.pond.sub.org ([10.3.113.7]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0EF9eCo013307 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 14 Jan 2016 10:09:42 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 02D38300383E; Thu, 14 Jan 2016 16:09:40 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 14 Jan 2016 16:09:39 +0100 Message-Id: <1452784179-6749-3-git-send-email-armbru@redhat.com> In-Reply-To: <1452784179-6749-1-git-send-email-armbru@redhat.com> References: <1452784179-6749-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Cc: xen-devel@lists.xensource.com, stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH 2/2] xen-hvm: Clean up xen_ram_alloc() error handling X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP xen_ram_alloc() dies with hw_error() on error, even though its caller ram_block_add() handles errors just fine. Add an Error **errp parameter and use it. Leave case RUN_STATE_INMIGRATE alone, because that looks like some kind of warning. Signed-off-by: Markus Armbruster Reviewed-by: Stefano Stabellini --- exec.c | 8 +++++++- include/hw/xen/xen.h | 2 +- xen-hvm-stub.c | 3 ++- xen-hvm.c | 7 ++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index 7f0ce42..c268c36 100644 --- a/exec.c +++ b/exec.c @@ -1474,6 +1474,7 @@ static ram_addr_t ram_block_add(RAMBlock *new_block, Error **errp) RAMBlock *block; RAMBlock *last_block = NULL; ram_addr_t old_ram_size, new_ram_size; + Error *err = NULL; old_ram_size = last_ram_offset() >> TARGET_PAGE_BITS; @@ -1483,7 +1484,12 @@ static ram_addr_t ram_block_add(RAMBlock *new_block, Error **errp) if (!new_block->host) { if (xen_enabled()) { xen_ram_alloc(new_block->offset, new_block->max_length, - new_block->mr); + new_block->mr, &err); + if (err) { + error_propagate(errp, err); + qemu_mutex_unlock_ramlist(); + return -1; + } } else { new_block->host = phys_mem_alloc(new_block->max_length, &new_block->mr->align); diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index d07bc99..1b81b4b 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -41,7 +41,7 @@ void xenstore_store_pv_console_info(int i, struct CharDriverState *chr); #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY) void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory); void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, - struct MemoryRegion *mr); + struct MemoryRegion *mr, Error **errp); void xen_modified_memory(ram_addr_t start, ram_addr_t length); #endif diff --git a/xen-hvm-stub.c b/xen-hvm-stub.c index 7ff0602..b958367 100644 --- a/xen-hvm-stub.c +++ b/xen-hvm-stub.c @@ -30,7 +30,8 @@ void xen_hvm_inject_msi(uint64_t addr, uint32_t data) { } -void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr) +void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, + Error **errp) { } diff --git a/xen-hvm.c b/xen-hvm.c index cb7128c..a9085a8 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -239,9 +239,9 @@ static void xen_ram_init(PCMachineState *pcms, } } -void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr) +void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, + Error **errp) { - /* FIXME caller ram_block_add() wants error_setg() on failure */ unsigned long nr_pfn; xen_pfn_t *pfn_list; int i; @@ -268,7 +268,8 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr) } if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 0, pfn_list)) { - hw_error("xen: failed to populate ram at " RAM_ADDR_FMT, ram_addr); + error_setg(errp, "xen: failed to populate ram at " RAM_ADDR_FMT, + ram_addr); } g_free(pfn_list);