From nobody Thu Nov 13 20:35:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1582821309; cv=none; d=zohomail.com; s=zohoarc; b=Jqq4Ure+dQH9dRRk7yRZYnBDLbOB/+viRSt4FTvhhL4olqQ3WCg3XYBH7Ux9NlV/3rKyPeC10q675vLizjceFshyDHEi8P79Ttz3VpMp3o9FFuz476wCq5FglnPP1bH7USpour5UDjh3GBbhBnAwADrXEQ8Uh63ZrLziGuLbTt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582821309; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yT/3v5xc8MjkoVGOOK8X+qbWZgR0VaRsSfKEBOzcIOk=; b=T5ElsFRUUDpTHH1cfwCBZbLJgjSQqQMI9wCq11FBImxcwnmBrzBD/6MUxKeOlxKB6/TZNShKE03Mo7mQVohwzOoQ7DTMZqyRQ+l7wnngmvHVpqSgHt8BqNX8V9+JPhULC9tpuhT3T+FVIDC569zTtwrZQxpypHO4KIZqrGs7M0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582821309801410.7029320835063; Thu, 27 Feb 2020 08:35:09 -0800 (PST) Received: from localhost ([::1]:34242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M7w-0007jh-H5 for importer@patchew.org; Thu, 27 Feb 2020 11:35:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40798) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M4K-0003gG-9p for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:31:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7M4J-0002dI-81 for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:31:24 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35866 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7M4J-0002cs-4M for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:31:23 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-ZwpIfXPdNg-KBE8BvP3VSw-1; Thu, 27 Feb 2020 11:31:20 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 01FC68010F0; Thu, 27 Feb 2020 16:31:19 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-195.brq.redhat.com [10.40.205.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB7056E3EE; Thu, 27 Feb 2020 16:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582821082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yT/3v5xc8MjkoVGOOK8X+qbWZgR0VaRsSfKEBOzcIOk=; b=iT3pF2oVsa+KoITqO0PQ2kdbOaZBWFUga2NIXuQIMO823gAkWzTzS0ziXPeksNRowkGG3/ mGpb0K3SBn7grCt2QPCmqF+fob7eCKWbMwqarJaQXmbXMSIdlHF83LT/NfqiP/ZlZaL6Dc 3RImPDqGD78eyIuwdo6P6l8KVOhaJFk= X-MC-Unique: ZwpIfXPdNg-KBE8BvP3VSw-1 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/6] chardev: Improve error report by calling error_setg_win32() Date: Thu, 27 Feb 2020 17:30:56 +0100 Message-Id: <20200227163101.414-2-philmd@redhat.com> In-Reply-To: <20200227163101.414-1-philmd@redhat.com> References: <20200227163101.414-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Stefan Weil , Markus Armbruster , Michael Roth , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Use error_setg_win32() which adds a hint similar to strerror(errno)). Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-pipe.c | 2 +- chardev/char-win.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chardev/char-pipe.c b/chardev/char-pipe.c index 94d714ffcd..fd12c9e63b 100644 --- a/chardev/char-pipe.c +++ b/chardev/char-pipe.c @@ -70,7 +70,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *fi= lename, MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NU= LL); g_free(openname); if (s->file =3D=3D INVALID_HANDLE_VALUE) { - error_setg(errp, "Failed CreateNamedPipe (%lu)", GetLastError()); + error_setg_win32(errp, GetLastError(), "Failed CreateNamedPipe"); s->file =3D NULL; goto fail; } diff --git a/chardev/char-win.c b/chardev/char-win.c index 34825f683d..d4fb44c4dc 100644 --- a/chardev/char-win.c +++ b/chardev/char-win.c @@ -96,7 +96,7 @@ int win_chr_serial_init(Chardev *chr, const char *filenam= e, Error **errp) s->file =3D CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); if (s->file =3D=3D INVALID_HANDLE_VALUE) { - error_setg(errp, "Failed CreateFile (%lu)", GetLastError()); + error_setg_win32(errp, GetLastError(), "Failed CreateFile"); s->file =3D NULL; goto fail; } --=20 2.21.1 From nobody Thu Nov 13 20:35:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1582821217; cv=none; d=zohomail.com; s=zohoarc; b=GagCd/7+AgQFyFysbkgbiUMP+GgKTB6v7h5m+Q3tpa5ZbmnrlA7W+Y6CaGNAnaluluOBEWoDTQXc3ElE7qoY/e7h3Hua3m2jveZNG68UMEBpBuCexuEVa+ANCt38LbjK/VI4jN8LWxP4W4iVQ+MsXt8N6GF3yg5D9hLmnhy1St0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582821217; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=O0FaYIaPmg1DzLaX55LBHB1O4cEilmCbUbK2SbynOMs=; b=KQvx8igVpoMJk5y1JTqLs06BNbPqW3XxraFgwfPoeTjUMbsDa3XTjt6fcZCk/YSRQXo/HxxZLAhiHtjwBfwH/NS8DP0NKrU2pu4RtfDepFRxNDv51uKNjUvFXWAPlad8N2IkQLKWITEmwtH1K/sDdlPI9X3vSPxdyVc8NvrTeXM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582821217612775.6922803674299; Thu, 27 Feb 2020 08:33:37 -0800 (PST) Received: from localhost ([::1]:34228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M6S-00060e-B6 for importer@patchew.org; Thu, 27 Feb 2020 11:33:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40875) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M4l-0004Cj-RO for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:31:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7M4j-0002sS-U0 for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:31:51 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:48837 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7M4j-0002s4-NW for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:31:49 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-pgy7-kriOpagvecOAk1fAw-1; Thu, 27 Feb 2020 11:31:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C22FA8024DD; Thu, 27 Feb 2020 16:31:45 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-195.brq.redhat.com [10.40.205.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1D0090CD6; Thu, 27 Feb 2020 16:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582821109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O0FaYIaPmg1DzLaX55LBHB1O4cEilmCbUbK2SbynOMs=; b=CYbrB21hA3pY9RVNSKL3X0gX0w1u0b3pL2yJP8y982e5f0pg1oqo6Rp5V5tSbvE2eSi5bm OPbu+dBgCwgucZ/irgZ3ezcwoiQJ+6LDiVDGDCYGkTBOiseOVf0SBIrlbfdA5ozoxjwKDp VYwezKuIdki8z5r+6Pn7wRg++QPPxFg= X-MC-Unique: pgy7-kriOpagvecOAk1fAw-1 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 2/6] util: Replace fprintf(stderr, "*\n" with error_report() Date: Thu, 27 Feb 2020 17:30:57 +0100 Message-Id: <20200227163101.414-3-philmd@redhat.com> In-Reply-To: <20200227163101.414-1-philmd@redhat.com> References: <20200227163101.414-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Stefan Weil , Alistair Francis , Markus Armbruster , Michael Roth , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Alistair Francis , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alistair Francis Replace a large number of the fprintf(stderr, "*\n" calls with error_report(). The functions were renamed with these commands and then compiler issues where manually fixed. find ./* -type f -exec sed -i \ 'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_= report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_re= port("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report= ("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("= \1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1= "\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\= 2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2)= ;|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|= Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig= }' \ {} + find ./* -type f -exec sed -i \ 'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}'= \ {} + find ./* -type f -exec sed -i \ 'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \ {} + The error in aio_poll() was removed manually. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: Signed-off-by: Alistair Francis [PMD: Rebased] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- Cc: Alistair Francis Cc: Alistair Francis --- util/coroutine-sigaltstack.c | 3 ++- util/mmap-alloc.c | 11 ++++++----- util/module.c | 13 ++++++------- util/osdep.c | 4 ++-- util/oslib-posix.c | 3 ++- util/oslib-win32.c | 3 ++- util/qemu-coroutine.c | 10 +++++----- util/qemu-thread-posix.c | 5 +++-- util/qemu-thread-win32.c | 5 +++-- util/qemu-timer-common.c | 3 ++- 10 files changed, 33 insertions(+), 27 deletions(-) diff --git a/util/coroutine-sigaltstack.c b/util/coroutine-sigaltstack.c index f6fc49a0e5..63decd4d1d 100644 --- a/util/coroutine-sigaltstack.c +++ b/util/coroutine-sigaltstack.c @@ -29,6 +29,7 @@ #include #include "qemu-common.h" #include "qemu/coroutine_int.h" +#include "qemu/error-report.h" =20 typedef struct { Coroutine base; @@ -80,7 +81,7 @@ static void __attribute__((constructor)) coroutine_init(v= oid) =20 ret =3D pthread_key_create(&thread_state_key, qemu_coroutine_thread_cl= eanup); if (ret !=3D 0) { - fprintf(stderr, "unable to create leader key: %s\n", strerror(errn= o)); + error_report("unable to create leader key: %s", strerror(errno)); abort(); } } diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 27dcccd8ec..3ac6e10404 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -18,6 +18,7 @@ #endif /* CONFIG_LINUX */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qemu/mmap-alloc.h" #include "qemu/host-utils.h" =20 @@ -63,7 +64,7 @@ size_t qemu_mempath_getpagesize(const char *mem_path) } while (ret !=3D 0 && errno =3D=3D EINTR); =20 if (ret !=3D 0) { - fprintf(stderr, "Couldn't statfs() memory path: %s\n", + error_report("Couldn't statfs() memory path: %s", strerror(errno)); exit(1); } @@ -160,10 +161,10 @@ void *qemu_ram_mmap(int fd, len =3D 0; } file_name[len] =3D '\0'; - fprintf(stderr, "Warning: requesting persistence across crashe= s " - "for backend file %s failed. Proceeding without " - "persistence, data might become corrupted in case of h= ost " - "crash.\n", file_name); + error_report("Warning: requesting persistence across crashes " + "for backend file %s failed. Proceeding without " + "persistence, data might become corrupted in case= " + "of host crash.", file_name); g_free(proc_link); g_free(file_name); } diff --git a/util/module.c b/util/module.c index 236a7bb52a..28efa1f891 100644 --- a/util/module.c +++ b/util/module.c @@ -19,6 +19,7 @@ #endif #include "qemu/queue.h" #include "qemu/module.h" +#include "qemu/error-report.h" =20 typedef struct ModuleEntry { @@ -130,19 +131,17 @@ static int module_load_file(const char *fname) =20 g_module =3D g_module_open(fname, G_MODULE_BIND_LAZY | G_MODULE_BIND_L= OCAL); if (!g_module) { - fprintf(stderr, "Failed to open module: %s\n", - g_module_error()); + error_report("Failed to open module: %s", g_module_error()); ret =3D -EINVAL; goto out; } if (!g_module_symbol(g_module, DSO_STAMP_FUN_STR, (gpointer *)&sym)) { - fprintf(stderr, "Failed to initialize module: %s\n", - fname); + error_report("Failed to initialize module: %s", fname); /* Print some info if this is a QEMU module (but from different bu= ild), * this will make debugging user problems easier. */ if (g_module_symbol(g_module, "qemu_module_dummy", (gpointer *)&sy= m)) { - fprintf(stderr, - "Note: only modules from the same build can be loaded.= \n"); + error_report("Note: " + "only modules from the same build can be loaded."= ); } g_module_close(g_module); ret =3D -EINVAL; @@ -178,7 +177,7 @@ bool module_load_one(const char *prefix, const char *li= b_name) static GHashTable *loaded_modules; =20 if (!g_module_supported()) { - fprintf(stderr, "Module is not supported by system.\n"); + error_report("Module is not supported by system."); return false; } =20 diff --git a/util/osdep.c b/util/osdep.c index f7d06050f7..ef40ae512a 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -484,7 +484,7 @@ void fips_set_state(bool requested) #endif /* __linux__ */ =20 #ifdef _FIPS_DEBUG - fprintf(stderr, "FIPS mode %s (requested %s)\n", + error_report("FIPS mode %s (requested %s)", (fips_enabled ? "enabled" : "disabled"), (requested ? "enabled" : "disabled")); #endif @@ -511,7 +511,7 @@ int socket_init(void) ret =3D WSAStartup(MAKEWORD(2, 2), &Data); if (ret !=3D 0) { err =3D WSAGetLastError(); - fprintf(stderr, "WSAStartup: %d\n", err); + error_report("WSAStartup: %d", err); return -1; } atexit(socket_cleanup); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 897e8f3ba6..4977594a43 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -35,6 +35,7 @@ #include "sysemu/sysemu.h" #include "trace.h" #include "qapi/error.h" +#include "qemu/error-report.h" #include "qemu/sockets.h" #include "qemu/thread.h" #include @@ -170,7 +171,7 @@ fail_close: void *qemu_oom_check(void *ptr) { if (ptr =3D=3D NULL) { - fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno)= ); + error_report("Failed to allocate memory: %s", strerror(errno)); abort(); } return ptr; diff --git a/util/oslib-win32.c b/util/oslib-win32.c index e9b14ab178..84b937865a 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -39,6 +39,7 @@ #include "trace.h" #include "qemu/sockets.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" =20 /* this must come after including "trace.h" */ #include @@ -46,7 +47,7 @@ void *qemu_oom_check(void *ptr) { if (ptr =3D=3D NULL) { - fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError()= ); + error_report("Failed to allocate memory: %lu", GetLastError()); abort(); } return ptr; diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c index c3caa6c770..62d1dd09df 100644 --- a/util/qemu-coroutine.c +++ b/util/qemu-coroutine.c @@ -14,6 +14,7 @@ =20 #include "qemu/osdep.h" #include "trace.h" +#include "qemu/error-report.h" #include "qemu/thread.h" #include "qemu/atomic.h" #include "qemu/coroutine.h" @@ -125,14 +126,13 @@ void qemu_aio_coroutine_enter(AioContext *ctx, Corout= ine *co) * cause us to enter it twice, potentially even after the coroutin= e has * been deleted */ if (scheduled) { - fprintf(stderr, - "%s: Co-routine was already scheduled in '%s'\n", - __func__, scheduled); + error_report("%s: Co-routine was already scheduled in '%s'", + __func__, scheduled); abort(); } =20 if (to->caller) { - fprintf(stderr, "Co-routine re-entered recursively\n"); + error_report("Co-routine re-entered recursively"); abort(); } =20 @@ -185,7 +185,7 @@ void coroutine_fn qemu_coroutine_yield(void) trace_qemu_coroutine_yield(self, to); =20 if (!to) { - fprintf(stderr, "Co-routine is yielding to no one\n"); + error_report("Co-routine is yielding to no one"); abort(); } =20 diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 838980aaa5..b4d8de376c 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -14,6 +14,7 @@ #include "qemu/thread.h" #include "qemu/atomic.h" #include "qemu/notify.h" +#include "qemu/error-report.h" #include "qemu-thread-common.h" =20 static bool name_threads; @@ -25,14 +26,14 @@ void qemu_thread_naming(bool enable) #ifndef CONFIG_THREAD_SETNAME_BYTHREAD /* This is a debugging option, not fatal */ if (enable) { - fprintf(stderr, "qemu: thread naming not supported on this host\n"= ); + error_report("qemu: thread naming not supported on this host"); } #endif } =20 static void error_exit(int err, const char *msg) { - fprintf(stderr, "qemu: %s: %s\n", msg, strerror(err)); + error_report("qemu: %s: %s", msg, strerror(err)); abort(); } =20 diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c index 56a83333da..9bed338d7e 100644 --- a/util/qemu-thread-win32.c +++ b/util/qemu-thread-win32.c @@ -15,6 +15,7 @@ #include "qemu-common.h" #include "qemu/thread.h" #include "qemu/notify.h" +#include "qemu/error-report.h" #include "qemu-thread-common.h" #include =20 @@ -25,7 +26,7 @@ void qemu_thread_naming(bool enable) /* But note we don't actually name them on Windows yet */ name_threads =3D enable; =20 - fprintf(stderr, "qemu: thread naming not supported on this host\n"); + error_report("qemu: thread naming not supported on this host"); } =20 static void error_exit(int err, const char *msg) @@ -34,7 +35,7 @@ static void error_exit(int err, const char *msg) =20 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUF= FER, NULL, err, 0, (LPTSTR)&pstr, 2, NULL); - fprintf(stderr, "qemu: %s: %s\n", msg, pstr); + error_report("qemu: %s: %s", msg, pstr); LocalFree(pstr); abort(); } diff --git a/util/qemu-timer-common.c b/util/qemu-timer-common.c index baf3317f74..527944da1c 100644 --- a/util/qemu-timer-common.c +++ b/util/qemu-timer-common.c @@ -23,6 +23,7 @@ */ #include "qemu/osdep.h" #include "qemu/timer.h" +#include "qemu/error-report.h" =20 /***********************************************************/ /* real time host monotonic timer */ @@ -37,7 +38,7 @@ static void __attribute__((constructor)) init_get_clock(v= oid) int ret; ret =3D QueryPerformanceFrequency(&freq); if (ret =3D=3D 0) { - fprintf(stderr, "Could not calibrate ticks\n"); + error_report("Could not calibrate ticks"); exit(1); } clock_freq =3D freq.QuadPart; --=20 2.21.1 From nobody Thu Nov 13 20:35:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1582821216; cv=none; d=zohomail.com; s=zohoarc; b=clTDbnEslEdLGrmOLZkT4gyPyvjW6jwWwYaf90mC8BYBmyWlmRlvjobSfzW/d/lhgltIOUPOlJAEYXVOGwmL/IV8UapTrXZRKPIUSRMppmhsDeWWPgOFIg5XQlXzzvLc90EyS9AGPfV3QoV9GQB+p/d/CFX2AmsggF6VGs9os78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582821216; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+5BpXWc4ttockMxOyu9HMTF9T2jhqzT1UhQN9j5Aqo0=; b=ef4Dc/wrnyf8vd2TEUATolkF/GVyfYlfhD93kH4c07/qXrjlS8XiBs+fqHChscgffZ645b+ROgaUU4JUJHR3itwt1F/cvkiwCuz2ssPhX1xPwWRf47PdFyr4BO6KTuvmVQxbc7DCHJ6eMq5hAzomkl5HuTlvMQ2r+MzPX+c6tHk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582821216871321.1221771759973; Thu, 27 Feb 2020 08:33:36 -0800 (PST) Received: from localhost ([::1]:34230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M6R-00060n-I7 for importer@patchew.org; Thu, 27 Feb 2020 11:33:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40894) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M4u-0004GP-Fv for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7M4s-00030J-KB for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:00 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36824 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7M4s-0002zB-FH for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:31:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-avFKXIEUPsC5Gl6NXD6uOg-1; Thu, 27 Feb 2020 11:31:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33DAB190D342; Thu, 27 Feb 2020 16:31:52 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-195.brq.redhat.com [10.40.205.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4489990CD5; Thu, 27 Feb 2020 16:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582821116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+5BpXWc4ttockMxOyu9HMTF9T2jhqzT1UhQN9j5Aqo0=; b=QQ6WzJ8VZXf9Mz1TC5I++vLIKlMhjbwBqb2IsOncZ9Sz/isjHM0SvNS5QPOfTnm/y8XIdr NjbpklGo0nIKqsO0zIUj2KJML5ru2TyMqxvILB+O3JbEeMC6ac/SSrDoJAYS8TQeeql1xt 1rHVhZ+FLeDhVnQxQTTM7au2AGaps7w= X-MC-Unique: avFKXIEUPsC5Gl6NXD6uOg-1 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 3/6] util/oslib-win32: Improve error report by calling error_setg_win32() Date: Thu, 27 Feb 2020 17:30:58 +0100 Message-Id: <20200227163101.414-4-philmd@redhat.com> In-Reply-To: <20200227163101.414-1-philmd@redhat.com> References: <20200227163101.414-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Stefan Weil , Markus Armbruster , Michael Roth , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Use error_setg_win32() which adds a hint similar to strerror(errno)). Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- util/oslib-win32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 84b937865a..6a3e6174f6 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -47,7 +47,8 @@ void *qemu_oom_check(void *ptr) { if (ptr =3D=3D NULL) { - error_report("Failed to allocate memory: %lu", GetLastError()); + g_autofree gchar *emsg =3D g_win32_error_message(GetLastError()); + error_report("Failed to allocate memory: %s", emsg); abort(); } return ptr; --=20 2.21.1 From nobody Thu Nov 13 20:35:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1582821422; cv=none; d=zohomail.com; s=zohoarc; b=RfZ4X+CTMMjZYkM0t6xBvosVFy4bNUSx9nSNXeh1SI/B3IEUVqkFjBW5D0lPXDWEJZvtCJV17MYLOoLoudlqv9fWythiIOECvcI/eYTDeAPgJmbmmVAIF1UK0iMo+Q1LyI27gBrkqCxXnuIjuoFQJ+r7+vC8CM/jSX3cVqC/0Ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582821422; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P74SiNUxpKL8ZPS0To1187cVvGqPWjuWELUewBJjUJo=; b=TZw9PW/Ym7georojiXcZDi9zgM9QxLpaIAd8gvZWww+84BBlgavUA7EenVbITD/R4Iz4l7XvxoSqIbwFH3xvrN8qsvwuOco04RHuaEq3zSKCF1MD98pt+V7FaounQB548y7NiWeQiOHP/fROb8npWw+lOssSgtV1ABzHIe/6i7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582821422662193.98124098625237; Thu, 27 Feb 2020 08:37:02 -0800 (PST) Received: from localhost ([::1]:34282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M9l-0001py-Gh for importer@patchew.org; Thu, 27 Feb 2020 11:37:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40910) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M50-0004NX-RI for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7M4z-00033M-T8 for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:21885 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7M4z-00032s-5d for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:05 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-wTJ4Is98OBWftlPy7j-zKQ-1; Thu, 27 Feb 2020 11:31:58 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DBB0C802560; Thu, 27 Feb 2020 16:31:57 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-195.brq.redhat.com [10.40.205.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4F1C6E3EE; Thu, 27 Feb 2020 16:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582821123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P74SiNUxpKL8ZPS0To1187cVvGqPWjuWELUewBJjUJo=; b=BhgehElveBWPfI8QmiVjfH5eqq376b5cA+aRNHHGnGcBAfPmrGP8GYAzd1x5rc2/2yhtxO 6WCnin1S0p+JNaD2zkzBDmcbUeu0Nrc8EXW30dnOvlsrBpk0YAwEpq4Gh004CyYWpT4ROO DNmKHUXXqIdcTWcxAHAZW6lxgwAzXTo= X-MC-Unique: wTJ4Is98OBWftlPy7j-zKQ-1 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 4/6] util/osdep: Improve error report by calling error_setg_win32() Date: Thu, 27 Feb 2020 17:30:59 +0100 Message-Id: <20200227163101.414-5-philmd@redhat.com> In-Reply-To: <20200227163101.414-1-philmd@redhat.com> References: <20200227163101.414-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Stefan Weil , Markus Armbruster , Michael Roth , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Use error_setg_win32() which adds a hint similar to strerror(errno)). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- util/osdep.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util/osdep.c b/util/osdep.c index ef40ae512a..144e217cb9 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -82,8 +82,8 @@ static int qemu_mprotect__osdep(void *addr, size_t size, = int prot) DWORD old_protect; =20 if (!VirtualProtect(addr, size, prot, &old_protect)) { - error_report("%s: VirtualProtect failed with error code %ld", - __func__, GetLastError()); + g_autofree gchar *emsg =3D g_win32_error_message(GetLastError()); + error_report("%s: VirtualProtect failed: %s", __func__, emsg); return -1; } return 0; @@ -506,12 +506,12 @@ int socket_init(void) { #ifdef _WIN32 WSADATA Data; - int ret, err; + int ret; =20 ret =3D WSAStartup(MAKEWORD(2, 2), &Data); if (ret !=3D 0) { - err =3D WSAGetLastError(); - error_report("WSAStartup: %d", err); + g_autofree gchar *emsg =3D g_win32_error_message(WSAGetLastError()= ); + error_report("WSAStartup: %s", emsg); return -1; } atexit(socket_cleanup); --=20 2.21.1 From nobody Thu Nov 13 20:35:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1582821372; cv=none; d=zohomail.com; s=zohoarc; b=k2448ai6alkx3C3o7lPI//fl8vcA/dPhMWnsl/Z5sz8ilhvWCPkJOm5TJbbnLXGRj+dItYqetj6r1YotsatY0aSZRPiB7eNhA4rm1bZzKQNMxkswVXk47sCUKXrBNeHPmUGdBfGIL/kYGXLERYeuUH0tlU/TrnRcdttUsY8wnKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582821372; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lrxksytfH/4aQKzPhPTMKmDyBX6ftLeis8jZBIQPOJY=; b=nm96Uxf90WQDOdUuiS9Y+YN/SpMTF7r62SwK7QL+UaAAz5daupJjdLCyPujk6GOOgq9IiDwT3RLw9B/iEm8muC14mle8UA8hqg9tttsifE89mjEI+cNOz9d3LXm4n5p3aTmw+cGek3EpAWsDm50+YntOz6tE78Odid2724c6T8w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582821372106803.7823037143696; Thu, 27 Feb 2020 08:36:12 -0800 (PST) Received: from localhost ([::1]:34270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M8w-0000sp-WF for importer@patchew.org; Thu, 27 Feb 2020 11:36:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40912) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M50-0004Nj-U2 for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7M50-00033e-1i for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:06 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:58355 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7M4z-00033I-Ty for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:05 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-qrlnDfvtMbanvVC6FzKkoA-1; Thu, 27 Feb 2020 11:32:03 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE4D3800D50; Thu, 27 Feb 2020 16:32:00 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-195.brq.redhat.com [10.40.205.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AC436E3EE; Thu, 27 Feb 2020 16:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582821125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lrxksytfH/4aQKzPhPTMKmDyBX6ftLeis8jZBIQPOJY=; b=eIcU6rpWHQT5wNbvaHv41q0KLWtnG703RcuaMBSggVaQ8JmnTZVv20Pg9XmHOtGu+8bmyg s+QLzpdPcJG5oNWCl/FwSvqFYh+VKzR7PpEBnfqpu9jTNaYYyCs9s5GBZ12QxEmAUQnxfO atCGSgie6NTL8o35K8VC7ULRzK25v0I= X-MC-Unique: qrlnDfvtMbanvVC6FzKkoA-1 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 5/6] qga: Fix a memory leak Date: Thu, 27 Feb 2020 17:31:00 +0100 Message-Id: <20200227163101.414-6-philmd@redhat.com> In-Reply-To: <20200227163101.414-1-philmd@redhat.com> References: <20200227163101.414-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Stefan Weil , Markus Armbruster , Michael Roth , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The string returned by g_win32_error_message() has to be deallocated with g_free(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- qga/channel-win32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qga/channel-win32.c b/qga/channel-win32.c index c86f4388db..774205e017 100644 --- a/qga/channel-win32.c +++ b/qga/channel-win32.c @@ -302,8 +302,8 @@ static gboolean ga_channel_open(GAChannel *c, GAChannel= Method method, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, = NULL); if (c->handle =3D=3D INVALID_HANDLE_VALUE) { - g_critical("error opening path %s: %s", newpath, - g_win32_error_message(GetLastError())); + g_autofree gchar *emsg =3D g_win32_error_message(GetLastError()); + g_critical("error opening path %s: %s", newpath, emsg); return false; } =20 --=20 2.21.1 From nobody Thu Nov 13 20:35:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1582821226; cv=none; d=zohomail.com; s=zohoarc; b=ftvfF4sKREAm7JUUgikCcbq1Gz47Qz862W61qA+ec9+jJgUpjnjuv6Sb1C7Aok5JGt67doS7CjcVZBQI0jyI7EERCWxyQph7VoHqv1H8HCsjeexQ/ISQuOo8dnOveJMjErfFq3Guu/U+A8CPYS7+iGshNk5anMoyGVbhHk8YrVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582821226; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nQDBNrecZ++ehAWaj148iqa/qkCuUZmbV37u4dgQJEQ=; b=NMj07nV8Hqpp0tVdI1Vha6d2rf19XIzuI5Dd1mFnWIYQRViXZJYMN8nIVW4MMiQMkzisq2edPiMeyO51wOGaqGbADQKl7lodPM80d8L4+MiV5iCm/nnfzM4bxJ/WbrES5LUFbuT6EmAViz0Nwoa4IhZLaXD/tNzZITKWxSYu3xw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582821226533460.5666608930244; Thu, 27 Feb 2020 08:33:46 -0800 (PST) Received: from localhost ([::1]:34232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M6b-0006KN-8s for importer@patchew.org; Thu, 27 Feb 2020 11:33:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40936) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7M54-0004VS-Ej for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7M53-000357-Ck for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:10 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54976 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7M53-00034y-8H for qemu-devel@nongnu.org; Thu, 27 Feb 2020 11:32:09 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-CKf8VmUSOKCDrLXBSzYO3g-1; Thu, 27 Feb 2020 11:32:05 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14C3C802563; Thu, 27 Feb 2020 16:32:04 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-195.brq.redhat.com [10.40.205.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6F62A6E3EE; Thu, 27 Feb 2020 16:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582821128; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nQDBNrecZ++ehAWaj148iqa/qkCuUZmbV37u4dgQJEQ=; b=NKkatqTLaoYE+r3vLEDno9na4wTKJ2JPWJzZrckja4LTYiqk+XVaiodS4frQ8iwhBMWSbs FZ044u21gnWb87U7YR9zBl6fM3KWMFpmL6k/J1RLpU5gYIw4i2b2/pM3cZSaHmHgdEv+0P nlwl386HAL8sFxxnAHaV1xtuomakDTM= X-MC-Unique: CKf8VmUSOKCDrLXBSzYO3g-1 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 6/6] qga: Improve error report by calling error_setg_win32() Date: Thu, 27 Feb 2020 17:31:01 +0100 Message-Id: <20200227163101.414-7-philmd@redhat.com> In-Reply-To: <20200227163101.414-1-philmd@redhat.com> References: <20200227163101.414-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Stefan Weil , Markus Armbruster , Michael Roth , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Use error_setg_win32() which adds a hint similar to strerror(errno)). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- qga/channel-win32.c | 3 ++- qga/commands-win32.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qga/channel-win32.c b/qga/channel-win32.c index 774205e017..4f04868a76 100644 --- a/qga/channel-win32.c +++ b/qga/channel-win32.c @@ -308,7 +308,8 @@ static gboolean ga_channel_open(GAChannel *c, GAChannel= Method method, } =20 if (method =3D=3D GA_CHANNEL_ISA_SERIAL && !SetCommTimeouts(c->handle,= &comTimeOut)) { - g_critical("error setting timeout for com port: %lu",GetLastError(= )); + g_autofree gchar *emsg =3D g_win32_error_message(GetLastError()); + g_critical("error setting timeout for com port: %s", emsg); CloseHandle(c->handle); return false; } diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 2461fd19bf..8e1f32ea23 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -315,8 +315,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode= , Error **errp) } =20 if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) { - slog("guest-shutdown failed: %lu", GetLastError()); - error_setg(errp, QERR_UNDEFINED_ERROR); + error_setg_win32(errp, GetLastError(), "guest-shutdown failed"); } } =20 @@ -1319,7 +1318,8 @@ static DWORD WINAPI do_suspend(LPVOID opaque) DWORD ret =3D 0; =20 if (!SetSuspendState(*mode =3D=3D GUEST_SUSPEND_MODE_DISK, TRUE, TRUE)= ) { - slog("failed to suspend guest, %lu", GetLastError()); + g_autofree gchar *emsg =3D g_win32_error_message(GetLastError()); + slog("failed to suspend guest: %s", emsg); ret =3D -1; } g_free(mode); --=20 2.21.1