From nobody Tue Feb 10 23:00:57 2026 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151387790762925.39247634993103; Thu, 21 Dec 2017 09:38:27 -0800 (PST) Received: from localhost ([::1]:32779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4nI-0005Rl-Ct for importer@patchew.org; Thu, 21 Dec 2017 12:38:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS4jc-0003CT-Rw for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:34:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS4jZ-0007VG-JE for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:34:20 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:56926) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS4jZ-0007Uo-9z for qemu-devel@nongnu.org; Thu, 21 Dec 2017 12:34:17 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBLHRQoi160171; Thu, 21 Dec 2017 17:34:16 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2f0h6w83hg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Dec 2017 17:34:15 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vBLHPBT8028547 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Dec 2017 17:25:11 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vBLHPBHv002739; Thu, 21 Dec 2017 17:25:11 GMT Received: from strongheart.us.oracle.com (/10.132.90.51) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Dec 2017 09:25:11 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=O9WrjdFfqoqdUMMsbyIUWrDdSMWJAeN6qnY50/yV/1c=; b=pX+UyJKmpBKwMVS7HV/R/GTtK6lmrq8ZOwO77a3T71sQfJqxKUsLXv2FJFJq0CRX/Xk1 dd6k0wqHJSClbjqTl3U+RPR1dQ0nnXWjXevTv9R/b3vjRrzDgTEA+nhz/ccI5NMmVrTb jtlAYXqahYGe+7EajjpDBgVSmgnDzu9HotEfrueTbcmaNsY1qTTiODNQ2SEcENqXB3g6 RIO0uuTF9soE6C9Iy3I1p3CXkaLZRf+ozgiF94TIqzuXEGEcHfQLUKYOxbVFXBsQgnHC H7V57vdde7GkFwUkBwl4cnOBsdEjV94KUTqMfQtaVcbpRkF85BmkhvxaqyHrPfTie3av 0w== From: Jack Schwartz To: qemu-devel@nongnu.org Date: Thu, 21 Dec 2017 09:25:18 -0800 Message-Id: <1513877118-3149-5-git-send-email-jack.schwartz@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1513877118-3149-1-git-send-email-jack.schwartz@oracle.com> References: <1513877118-3149-1-git-send-email-jack.schwartz@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8752 signatures=668651 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712210238 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH QEMU v1 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: ehabkost@redhat.com, konrad.wilk@oracle.com, daniel.kiper@oracle.com, mst@redhat.com, pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 818728b..d9a0a95 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 1.8.3.1