From patchwork Thu Nov 1 05:59:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10663495 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 426C717D5 for ; Thu, 1 Nov 2018 06:00:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23F182BC19 for ; Thu, 1 Nov 2018 06:00:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14EAF2BC33; Thu, 1 Nov 2018 06:00:28 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,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 A79622BC19 for ; Thu, 1 Nov 2018 06:00:26 +0000 (UTC) Received: from localhost ([::1]:35513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gI61p-0000ai-LA for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Nov 2018 02:00:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gI61A-0000Cz-C5 for qemu-devel@nongnu.org; Thu, 01 Nov 2018 01:59:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gI617-00040w-72 for qemu-devel@nongnu.org; Thu, 01 Nov 2018 01:59:44 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:35662) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gI616-0003z6-W6 for qemu-devel@nongnu.org; Thu, 01 Nov 2018 01:59:41 -0400 Received: by mail-pf1-x441.google.com with SMTP id z2-v6so6202350pfe.2 for ; Wed, 31 Oct 2018 22:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=TOOT3H+TDP41fIJgw2tvvTEwEnMMmP6vwkv56lTGqpQ=; b=WfktqApR332lk3Z1fmPaKmQnPjFmRgJ+pIUjd6N6BkbhzYzjkhlKWft4BX4pEE+plA T+F4hfHRSc6HzpFtGgkAc63qU14eII7fn+VSZfe28NMcQp+XwFKriLN3yGFVoV8etwj/ 2lp13tJXjCV11pgVj+WQi4olWqNUOPz0IRTPk7B9YkSNpT2ne1h2tDozrqix3a4nIFfy 1X/cypTgmffKn5ZqYLj/bjE/JcG3u2dxWOMje3pg+33ULR6XCms4tM/LC6ERHoiAW63t qEmCHtwbrEJd7TbM46guLsOqRhzsQo/67oaOS7D069Y0SbfbnZUUHOc+Tm/CIvD01bFv ZdKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TOOT3H+TDP41fIJgw2tvvTEwEnMMmP6vwkv56lTGqpQ=; b=IrbX2aKFGUIHacCONXv6FAIDCMu89NP+RScy58P6b7AmVIM1+kIRcUAHpp9+oxT8Hm bWGQ7KLCtj6GOqhppWq4Tsw447HZ50PvSPWeQuRUfBp2N3ltho3s2CJE+qbiY3AO/GB9 hZJmdbvQZSr0CRZzNoQBxbU/lmjMUynt0hnHOm5KAn4c6jfzQgVRCg6IDj3hHOAjhTOy xf02zGS/QrTnsfUP2ieQCmxkRCJjnh1uvBOVplx5bELb6fAEuHAKP1cH+O1hIfekSsi3 VsOo1InXB4akc70ZX3adPOaEOrctrFGysvijmpeRF0hSXM4Z+CJFavmv3lzo2COcJ5/Q 24vw== X-Gm-Message-State: AGRZ1gJxqrrQXf4RZcXtvazUyBDQqcOJ7WgHl0n0/4gVEW2gpn/e6t5+ y9q3YdptTZSaG0tOGuC9b3Y= X-Google-Smtp-Source: AJdET5ehtEhPSPKp7UjPxdPaea4u2/b27JRlRpFaoMBMu/baTy4AtUlZVBzfAC5/RmJtpW0fLA5JuA== X-Received: by 2002:a65:45c9:: with SMTP id m9-v6mr5930206pgr.212.1541051978565; Wed, 31 Oct 2018 22:59:38 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.100]) by smtp.gmail.com with ESMTPSA id v83-v6sm56519130pfa.103.2018.10.31.22.59.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 22:59:37 -0700 (PDT) From: Li Qiang To: pbonzini@redhat.com, armbru@redhat.com, philmd@redhat.com Date: Wed, 31 Oct 2018 22:59:31 -0700 Message-Id: <1541051971-28584-1-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH] vl: Improve error message when we can't load fw_cfg from file 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: Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP parse_fw_cfg() reports "can't load" without further details. Get the details from g_file_get_contents(), and include them in the error message. Signed-off-by: Li Qiang --- vl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 1fcacc5..f0bd899 100644 --- a/vl.c +++ b/vl.c @@ -2244,8 +2244,10 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp) size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */ buf = g_memdup(str, size); } else { - if (!g_file_get_contents(file, &buf, &size, NULL)) { - error_setg(errp, "can't load %s", file); + GError *err = NULL; + if (!g_file_get_contents(file, &buf, &size, &err)) { + error_setg(errp, "can't load %s: %s", file, err->message); + g_error_free(err); return -1; } }