From nobody Sat Oct 25 08:52:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421674179946.1326267836974; Wed, 7 Mar 2018 03:21:14 -0800 (PST) Received: from localhost ([::1]:60850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX8D-0005z0-9V for importer@patchew.org; Wed, 07 Mar 2018 06:21:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX5h-0004DI-Ur for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:18:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etX5g-0005j8-Kg for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:18:37 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45710 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etX5g-0005iv-GV for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:18:36 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 323C38182D17; Wed, 7 Mar 2018 11:18:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-216.ams2.redhat.com [10.36.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A586215CDAA; Wed, 7 Mar 2018 11:18:35 +0000 (UTC) From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:18:22 +0100 Message-Id: <20180307111822.29403-5-kwolf@redhat.com> In-Reply-To: <20180307111822.29403-1-kwolf@redhat.com> References: <20180307111822.29403-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 07 Mar 2018 11:18:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 07 Mar 2018 11:18:36 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 4/4] multiboot: fprintf(stderr...) -> error_report() 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: kwolf@redhat.com, jack.schwartz@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jack Schwartz Change all fprintf(stderr...) calls in hw/i386/multiboot.c to call error_report() instead, including the mb_debug macro. Remove the "\n" from strings passed to all modified calls, since error_report() appends one. Signed-off-by: Jack Schwartz Reviewed-by: Daniel Kiper Signed-off-by: Kevin Wolf --- hw/i386/multiboot.c | 55 ++++++++++++++++++++++++++++---------------------= ---- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 07fdccb84a..b9064264d8 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -31,12 +31,13 @@ #include "hw/loader.h" #include "elf.h" #include "sysemu/sysemu.h" +#include "qemu/error-report.h" =20 /* Show multiboot debug output */ //#define DEBUG_MULTIBOOT =20 #ifdef DEBUG_MULTIBOOT -#define mb_debug(a...) fprintf(stderr, ## a) +#define mb_debug(a...) error_report(a) #else #define mb_debug(a...) #endif @@ -137,7 +138,7 @@ static void mb_add_mod(MultibootState *s, stl_p(p + MB_MOD_END, end); stl_p(p + MB_MOD_CMDLINE, cmdline_phys); =20 - mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n", + mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx, s->mb_mods_count, start, end); =20 s->mb_mods_count++; @@ -179,12 +180,12 @@ int load_multiboot(FWCfgState *fw_cfg, if (!is_multiboot) return 0; /* no multiboot */ =20 - mb_debug("qemu: I believe we found a multiboot image!\n"); + mb_debug("qemu: I believe we found a multiboot image!"); memset(bootinfo, 0, sizeof(bootinfo)); memset(&mbs, 0, sizeof(mbs)); =20 if (flags & 0x00000004) { /* MULTIBOOT_HEADER_HAS_VBE */ - fprintf(stderr, "qemu: multiboot knows VBE. we don't.\n"); + error_report("qemu: multiboot knows VBE. we don't."); } if (!(flags & 0x00010000)) { /* MULTIBOOT_HEADER_HAS_ADDR */ uint64_t elf_entry; @@ -193,7 +194,7 @@ int load_multiboot(FWCfgState *fw_cfg, fclose(f); =20 if (((struct elf64_hdr*)header)->e_machine =3D=3D EM_X86_64) { - fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n= "); + error_report("Cannot load x86-64 image, give a 32bit one."); exit(1); } =20 @@ -201,7 +202,7 @@ int load_multiboot(FWCfgState *fw_cfg, &elf_low, &elf_high, 0, I386_ELF_MACHINE, 0, 0); if (kernel_size < 0) { - fprintf(stderr, "Error while loading elf kernel\n"); + error_report("Error while loading elf kernel"); exit(1); } mh_load_addr =3D elf_low; @@ -210,12 +211,13 @@ int load_multiboot(FWCfgState *fw_cfg, =20 mbs.mb_buf =3D g_malloc(mb_kernel_size); if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) !=3D mb_ker= nel_size) { - fprintf(stderr, "Error while fetching elf kernel from rom\n"); + error_report("Error while fetching elf kernel from rom"); exit(1); } =20 - mb_debug("qemu: loading multiboot-elf kernel (%#x bytes) with entr= y %#zx\n", - mb_kernel_size, (size_t)mh_entry_addr); + mb_debug("qemu: loading multiboot-elf kernel " + "(%#x bytes) with entry %#zx", + mb_kernel_size, (size_t)mh_entry_addr); } else { /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ uint32_t mh_header_addr =3D ldl_p(header+i+12); @@ -224,7 +226,7 @@ int load_multiboot(FWCfgState *fw_cfg, =20 mh_load_addr =3D ldl_p(header+i+16); if (mh_header_addr < mh_load_addr) { - fprintf(stderr, "invalid load_addr address\n"); + error_report("invalid load_addr address"); exit(1); } =20 @@ -234,20 +236,20 @@ int load_multiboot(FWCfgState *fw_cfg, =20 if (mh_load_end_addr) { if (mh_load_end_addr < mh_load_addr) { - fprintf(stderr, "invalid load_end_addr address\n"); + error_report("invalid load_end_addr address"); exit(1); } mb_load_size =3D mh_load_end_addr - mh_load_addr; } else { if (kernel_file_size < mb_kernel_text_offset) { - fprintf(stderr, "invalid kernel_file_size\n"); + error_report("invalid kernel_file_size"); exit(1); } mb_load_size =3D kernel_file_size - mb_kernel_text_offset; } if (mh_bss_end_addr) { if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { - fprintf(stderr, "invalid bss_end_addr address\n"); + error_report("invalid bss_end_addr address"); exit(1); } mb_kernel_size =3D mh_bss_end_addr - mh_load_addr; @@ -255,17 +257,17 @@ int load_multiboot(FWCfgState *fw_cfg, mb_kernel_size =3D mb_load_size; } =20 - mb_debug("multiboot: header_addr =3D %#x\n", mh_header_addr); - mb_debug("multiboot: load_addr =3D %#x\n", mh_load_addr); - mb_debug("multiboot: load_end_addr =3D %#x\n", mh_load_end_addr); - mb_debug("multiboot: bss_end_addr =3D %#x\n", mh_bss_end_addr); - mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x\n", + mb_debug("multiboot: header_addr =3D %#x", mh_header_addr); + mb_debug("multiboot: load_addr =3D %#x", mh_load_addr); + mb_debug("multiboot: load_end_addr =3D %#x", mh_load_end_addr); + mb_debug("multiboot: bss_end_addr =3D %#x", mh_bss_end_addr); + mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x", mb_load_size, mh_load_addr); =20 mbs.mb_buf =3D g_malloc(mb_kernel_size); fseek(f, mb_kernel_text_offset, SEEK_SET); if (fread(mbs.mb_buf, 1, mb_load_size, f) !=3D mb_load_size) { - fprintf(stderr, "fread() failed\n"); + error_report("fread() failed"); exit(1); } memset(mbs.mb_buf + mb_load_size, 0, mb_kernel_size - mb_load_size= ); @@ -319,10 +321,10 @@ int load_multiboot(FWCfgState *fw_cfg, hwaddr c =3D mb_add_cmdline(&mbs, tmpbuf); if ((next_space =3D strchr(tmpbuf, ' '))) *next_space =3D '\0'; - mb_debug("multiboot loading module: %s\n", tmpbuf); + mb_debug("multiboot loading module: %s", tmpbuf); mb_mod_length =3D get_image_size(tmpbuf); if (mb_mod_length < 0) { - fprintf(stderr, "Failed to open file '%s'\n", tmpbuf); + error_report("Failed to open file '%s'", tmpbuf); exit(1); } =20 @@ -333,7 +335,7 @@ int load_multiboot(FWCfgState *fw_cfg, mb_add_mod(&mbs, mbs.mb_buf_phys + offs, mbs.mb_buf_phys + offs + mb_mod_length, c); =20 - mb_debug("mod_start: %p\nmod_end: %p\n cmdline: "TARGET_FMT= _plx"\n", + mb_debug("mod_start: %p\nmod_end: %p\n cmdline: "TARGET_FMT= _plx, (char *)mbs.mb_buf + offs, (char *)mbs.mb_buf + offs + mb_mod_length, c); initrd_filename =3D next_initrd+1; @@ -361,10 +363,11 @@ int load_multiboot(FWCfgState *fw_cfg, stl_p(bootinfo + MBI_BOOT_DEVICE, 0x8000ffff); /* XXX: use the -boot s= witch? */ stl_p(bootinfo + MBI_MMAP_ADDR, ADDR_E820_MAP); =20 - mb_debug("multiboot: entry_addr =3D %#x\n", mh_entry_addr); - mb_debug(" mb_buf_phys =3D "TARGET_FMT_plx"\n", mbs.mb_buf= _phys); - mb_debug(" mod_start =3D "TARGET_FMT_plx"\n", mbs.mb_buf= _phys + mbs.offset_mods); - mb_debug(" mb_mods_count =3D %d\n", mbs.mb_mods_count); + mb_debug("multiboot: entry_addr =3D %#x", mh_entry_addr); + mb_debug(" mb_buf_phys =3D "TARGET_FMT_plx, mbs.mb_buf_phy= s); + mb_debug(" mod_start =3D "TARGET_FMT_plx, + mbs.mb_buf_phys + mbs.offset_mods); + mb_debug(" mb_mods_count =3D %d", mbs.mb_mods_count); =20 /* save bootinfo off the stack */ mb_bootinfo_data =3D g_memdup(bootinfo, sizeof(bootinfo)); --=20 2.13.6