From nobody Mon Feb 9 23:01:08 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529374214308262.99767249632134; Mon, 18 Jun 2018 19:10:14 -0700 (PDT) Received: from localhost ([::1]:38510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV661-0002zl-EL for importer@patchew.org; Mon, 18 Jun 2018 22:10:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5i7-0001j4-TZ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5i6-0008Rb-AC for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:31 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:41480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5i6-0008RN-2n; Mon, 18 Jun 2018 21:45:30 -0400 Received: by mail-oi0-x231.google.com with SMTP id a141-v6so16693765oii.8; Mon, 18 Jun 2018 18:45:29 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id a202-v6sm8674877oib.28.2018.06.18.18.45.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=yQujSyrP+o5vviIFx8FFFNYs2QJFyViQZ28Byt3zhGE=; b=mI0xt7gTHGWUl1XuhTLdrvfVN75mNm7V8NOwgTBN61FYScdoYhwKs7uGo0vXyJW1LM ZxA8ywByHGCF8xFbaXkt51EN95jpOCZwLhFXzRs5ZoZGOlJrS0eC/vfpsor47ua90qUu desVtXKHNSvZ5ujtvPaMr9DGxbLExFZi80DhBQ+AE1KeTSTthDDhqeY0xJWq4lGSPBP0 x/aPcyDiAMH5fEUJGswkoGGevaAEc+eCSvl4aOinlRo2PZ4zr5o8RX02CFjuA3lTvlWi P9XzZx3m6+bKGOc3tsRq2gsITIQpdnEqxziq6Kg3UEh1AaB6KbySUejqP4WuCsFxurhE bR6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=yQujSyrP+o5vviIFx8FFFNYs2QJFyViQZ28Byt3zhGE=; b=F4byyJCWasr9mcwGkb68ITu/4YK/w/6Q+AgJki9SFsl66bwjV6duQGsJ4kb6fmWKQw dgQjRK6O4E+32RKLMBPiBNrYavNNeo/N02CeGNStOVHcH8/GUuDk7O5+wKPZBdpSh/aZ 4kubFuCwTtv0A2Hdp0IGwjjVs5tfITFDIP+6++gIgb3dL/Ox75pGtUyUyHzon7cqOOeI nV8hqi7XHrGPIpbE8L35gaMicELGF1ThvHTQN9SNPY79YjV+JPIB3sr7g5e8OLqb8Mu8 R7Ew7dmde+yHbG1kBFyyJy0l2bgOYtms+dWS6lpqDx3RCvhLrcmX8DOKmjlUN2IwY62v GhEA== X-Gm-Message-State: APt69E3uZm4k7dyvHqloNZILWleI51s4/c49fx+Ha3Bq/HZxkrMUp5tg DO+FmdGcpXhX3/N5OJVhlTl4y3QX X-Google-Smtp-Source: ADUXVKJOVZAFX0S+whvcgygIWcsRjG4XOiRyRM2DkYyPLw+CjYktdVHgChEd0Q1BnuOojrKsAFH8AQ== X-Received: by 2002:aca:3c07:: with SMTP id j7-v6mr8617177oia.13.1529372728691; Mon, 18 Jun 2018 18:45:28 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:05 -0500 Message-Id: <20180619014319.28272-40-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::231 Subject: [Qemu-devel] [PATCH 039/113] 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: Kevin Wolf , qemu-stable@nongnu.org, Jack Schwartz 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" 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 (cherry picked from commit 4b9006a41ea8818f2385ae5228e07f211bb4a33d) Signed-off-by: Michael Roth --- 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 818728bdf8..d9a0a95a2f 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.11.0