From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651739555; cv=none; d=zohomail.com; s=zohoarc; b=WeBrjhMQRZssJ1rlvnwWl/+PLTF697pxD9jLl+mLuXhPzR3t3P2GYIGxz0p6bnoHM9Phcb+1sDEn6iVwtUe7n+GWVG/u1XMtnqGHgCFnteDZHGsQBM6pOB7eGv0Zs0+gbICY+FDaqc9EtaUZ6FGVhb99NQ4NTQhMyptcasZZG0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651739555; 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=rOJ/LJ/5c/gMbrm+HulZCXhwL5UliLeDMjK7EhViaxs=; b=SiPoiGdZ8G7O232PFnid90OHv8hw5308XvVROVPXKdbhTOs96sJgk2JBrc2+xGYQLfEWj+l5roXvBMPguyoDDP4XMptmpj2NbBh0aVsoTEtcAPQGbHp5KhD5LsXqQR7hRIOdXS1lKahKekM5oa8ZosBa1HB9vQe71wgqcxwYd7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651739555557584.4122538864966; Thu, 5 May 2022 01:32:35 -0700 (PDT) Received: from localhost ([::1]:53366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWuY-0007wi-Dt for importer@patchew.org; Thu, 05 May 2022 04:32:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWe0-0006Rb-MA for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:28 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:59445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWdx-0007jp-8u for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-282-SpyJirLBPHeDTRH5FPoAAw-1; Thu, 05 May 2022 04:15:21 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8B981014A78; Thu, 5 May 2022 08:15:20 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 662C240CF900; Thu, 5 May 2022 08:15:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738524; 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=rOJ/LJ/5c/gMbrm+HulZCXhwL5UliLeDMjK7EhViaxs=; b=bs7f20ZBllnVM80MCZCmX+kUGZJN/+jhnCZtIhaVrT7T9JQ8kqzGeeNWDk0eVROU2nyiVT qMeMQvFgwEolT5lLobJpllum7QkYEwFLS0H7BtMr0nIayu9tm6ifALFzcrkcLiRYko+STr u/y2jUAWze6pSm/trQEpZ9ySA8oH1XM= X-MC-Unique: SpyJirLBPHeDTRH5FPoAAw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 01/15] include: move qemu_*_exec_dir() to cutils Date: Thu, 5 May 2022 12:14:17 +0400 Message-Id: <20220505081431.934739-2-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651739557737100001 From: Marc-Andr=C3=A9 Lureau The function is required by get_relocated_path() (already in cutils), and used by qemu-ga and may be generally useful. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qemu/cutils.h | 7 ++ include/qemu/osdep.h | 8 -- qemu-io.c | 1 + storage-daemon/qemu-storage-daemon.c | 1 + tests/qtest/fuzz/fuzz.c | 1 + util/cutils.c | 108 +++++++++++++++++++++++++++ util/oslib-posix.c | 81 -------------------- util/oslib-win32.c | 36 --------- 8 files changed, 118 insertions(+), 125 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 5c6572d44422..40e10e19a7ed 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -193,6 +193,13 @@ int uleb128_decode_small(const uint8_t *in, uint32_t *= n); */ int qemu_pstrcmp0(const char **str1, const char **str2); =20 +/* Find program directory, and save it for later usage with + * qemu_get_exec_dir(). + * Try OS specific API first, if not working, parse from argv0. */ +void qemu_init_exec_dir(const char *argv0); + +/* Get the saved exec dir. */ +const char *qemu_get_exec_dir(void); =20 /** * get_relocated_path: diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 1c1e7eca9898..67cc4654166b 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -557,14 +557,6 @@ void qemu_set_cloexec(int fd); */ char *qemu_get_local_state_dir(void); =20 -/* Find program directory, and save it for later usage with - * qemu_get_exec_dir(). - * Try OS specific API first, if not working, parse from argv0. */ -void qemu_init_exec_dir(const char *argv0); - -/* Get the saved exec dir. */ -const char *qemu_get_exec_dir(void); - /** * qemu_getauxval: * @type: the auxiliary vector key to lookup diff --git a/qemu-io.c b/qemu-io.c index d70d3dd4fde5..2bd7bfb65073 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -16,6 +16,7 @@ #endif =20 #include "qemu/help-texts.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qemu-io.h" #include "qemu/error-report.h" diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index 9b8b17f52e48..c104817cdddc 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -44,6 +44,7 @@ =20 #include "qemu/help-texts.h" #include "qemu-version.h" +#include "qemu/cutils.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qemu/help_option.h" diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index a7a5e14fa3bc..0ad4ba9e94dc 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -15,6 +15,7 @@ =20 #include =20 +#include "qemu/cutils.h" #include "qemu/datadir.h" #include "sysemu/sysemu.h" #include "sysemu/qtest.h" diff --git a/util/cutils.c b/util/cutils.c index b2777210e7da..6cc7cc8cde99 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -931,6 +931,114 @@ static inline const char *next_component(const char *= dir, int *p_len) return dir; } =20 +static const char *exec_dir; + +void qemu_init_exec_dir(const char *argv0) +{ +#ifdef G_OS_WIN32 + char *p; + char buf[MAX_PATH]; + DWORD len; + + if (exec_dir) { + return; + } + + len =3D GetModuleFileName(NULL, buf, sizeof(buf) - 1); + if (len =3D=3D 0) { + return; + } + + buf[len] =3D 0; + p =3D buf + len - 1; + while (p !=3D buf && *p !=3D '\\') { + p--; + } + *p =3D 0; + if (access(buf, R_OK) =3D=3D 0) { + exec_dir =3D g_strdup(buf); + } else { + exec_dir =3D CONFIG_BINDIR; + } +#else + char *p =3D NULL; + char buf[PATH_MAX]; + + if (exec_dir) { + return; + } + +#if defined(__linux__) + { + int len; + len =3D readlink("/proc/self/exe", buf, sizeof(buf) - 1); + if (len > 0) { + buf[len] =3D 0; + p =3D buf; + } + } +#elif defined(__FreeBSD__) \ + || (defined(__NetBSD__) && defined(KERN_PROC_PATHNAME)) + { +#if defined(__FreeBSD__) + static int mib[4] =3D {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1= }; +#else + static int mib[4] =3D {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PAT= HNAME}; +#endif + size_t len =3D sizeof(buf) - 1; + + *buf =3D '\0'; + if (!sysctl(mib, ARRAY_SIZE(mib), buf, &len, NULL, 0) && + *buf) { + buf[sizeof(buf) - 1] =3D '\0'; + p =3D buf; + } + } +#elif defined(__APPLE__) + { + char fpath[PATH_MAX]; + uint32_t len =3D sizeof(fpath); + if (_NSGetExecutablePath(fpath, &len) =3D=3D 0) { + p =3D realpath(fpath, buf); + if (!p) { + return; + } + } + } +#elif defined(__HAIKU__) + { + image_info ii; + int32_t c =3D 0; + + *buf =3D '\0'; + while (get_next_image_info(0, &c, &ii) =3D=3D B_OK) { + if (ii.type =3D=3D B_APP_IMAGE) { + strncpy(buf, ii.name, sizeof(buf)); + buf[sizeof(buf) - 1] =3D 0; + p =3D buf; + break; + } + } + } +#endif + /* If we don't have any way of figuring out the actual executable + location then try argv[0]. */ + if (!p && argv0) { + p =3D realpath(argv0, buf); + } + if (p) { + exec_dir =3D g_path_get_dirname(p); + } else { + exec_dir =3D CONFIG_BINDIR; + } +#endif +} + +const char *qemu_get_exec_dir(void) +{ + return exec_dir; +} + char *get_relocated_path(const char *dir) { size_t prefix_len =3D strlen(CONFIG_PREFIX); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 477990f39baf..7ba4472760ba 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -283,87 +283,6 @@ void qemu_set_tty_echo(int fd, bool echo) tcsetattr(fd, TCSANOW, &tty); } =20 -static const char *exec_dir; - -void qemu_init_exec_dir(const char *argv0) -{ - char *p =3D NULL; - char buf[PATH_MAX]; - - if (exec_dir) { - return; - } - -#if defined(__linux__) - { - int len; - len =3D readlink("/proc/self/exe", buf, sizeof(buf) - 1); - if (len > 0) { - buf[len] =3D 0; - p =3D buf; - } - } -#elif defined(__FreeBSD__) \ - || (defined(__NetBSD__) && defined(KERN_PROC_PATHNAME)) - { -#if defined(__FreeBSD__) - static int mib[4] =3D {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1= }; -#else - static int mib[4] =3D {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PAT= HNAME}; -#endif - size_t len =3D sizeof(buf) - 1; - - *buf =3D '\0'; - if (!sysctl(mib, ARRAY_SIZE(mib), buf, &len, NULL, 0) && - *buf) { - buf[sizeof(buf) - 1] =3D '\0'; - p =3D buf; - } - } -#elif defined(__APPLE__) - { - char fpath[PATH_MAX]; - uint32_t len =3D sizeof(fpath); - if (_NSGetExecutablePath(fpath, &len) =3D=3D 0) { - p =3D realpath(fpath, buf); - if (!p) { - return; - } - } - } -#elif defined(__HAIKU__) - { - image_info ii; - int32_t c =3D 0; - - *buf =3D '\0'; - while (get_next_image_info(0, &c, &ii) =3D=3D B_OK) { - if (ii.type =3D=3D B_APP_IMAGE) { - strncpy(buf, ii.name, sizeof(buf)); - buf[sizeof(buf) - 1] =3D 0; - p =3D buf; - break; - } - } - } -#endif - /* If we don't have any way of figuring out the actual executable - location then try argv[0]. */ - if (!p && argv0) { - p =3D realpath(argv0, buf); - } - if (p) { - exec_dir =3D g_path_get_dirname(p); - } else { - exec_dir =3D CONFIG_BINDIR; - } -} - -const char *qemu_get_exec_dir(void) -{ - return exec_dir; -} - #ifdef CONFIG_LINUX static void sigbus_handler(int signal, siginfo_t *siginfo, void *ctx) #else /* CONFIG_LINUX */ diff --git a/util/oslib-win32.c b/util/oslib-win32.c index dafef4f15733..6c818749d2b9 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -269,42 +269,6 @@ void qemu_set_tty_echo(int fd, bool echo) } } =20 -static const char *exec_dir; - -void qemu_init_exec_dir(const char *argv0) -{ - - char *p; - char buf[MAX_PATH]; - DWORD len; - - if (exec_dir) { - return; - } - - len =3D GetModuleFileName(NULL, buf, sizeof(buf) - 1); - if (len =3D=3D 0) { - return; - } - - buf[len] =3D 0; - p =3D buf + len - 1; - while (p !=3D buf && *p !=3D '\\') { - p--; - } - *p =3D 0; - if (access(buf, R_OK) =3D=3D 0) { - exec_dir =3D g_strdup(buf); - } else { - exec_dir =3D CONFIG_BINDIR; - } -} - -const char *qemu_get_exec_dir(void) -{ - return exec_dir; -} - int getpagesize(void) { SYSTEM_INFO system_info; --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651738937; cv=none; d=zohomail.com; s=zohoarc; b=LEEE8bWBWg3V330XjGa/Qkg1vTWvPt+50x01R9tcFN98gfwa1FOqGeEtaXpl01DPXAkf2P6DhQQjOotuDAbn6uVkB/30VGeKlVeQi5eiHxKJIJOkQX/UTeRAZyFJKFiIpnSzN9juDFMzIKJ/jMexzAHu/5k/KQ099pRkhLWW4g0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738937; 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=ZCH+L1qE9NPvkWVkwSY7/FzON+zAGzwQBt4cs5Mltng=; b=FxhPar3wHxBB1X2jlJs59vZAjyE9JDeElrbaR9VL2gDbq8cKia//N7NPkOnPyAsK6JjWG8j2Y4RP6uuqpLTUe6NvJk2HXHcdJFqgYGSewwR0q/zvPVq99QJdp8iIjvQnSgTebUuPt7LCUKpyRzlIJRNtZM5Oz1VvyHnS1oVnuio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651738937913775.713774365859; Thu, 5 May 2022 01:22:17 -0700 (PDT) Received: from localhost ([::1]:38216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWka-0005eQ-OK for importer@patchew.org; Thu, 05 May 2022 04:22:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWe2-0006Xt-M4 for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:30 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.129.74]:57200) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWe1-0007o7-1s for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:30 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-6j4SyP-sPpurLuVu959Asw-1; Thu, 05 May 2022 04:15:25 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5C5D8BDEEB; Thu, 5 May 2022 08:15:24 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC1B0C28112; Thu, 5 May 2022 08:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738528; 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=ZCH+L1qE9NPvkWVkwSY7/FzON+zAGzwQBt4cs5Mltng=; b=ZsZ/rowaK2HDzfl7EjmYP4upEjLkwEeCTJt5qy6HgUMsb5NEQk98/F1SaHOj6X+ati/+EF P8MGFS2j0BYcZfecAy0Vl4d7YryG+cfwXe5R1Yjpa7T10wpdV3Br3Qb9SLeerSnEpdP3fF RRNXI5i2+9tdTJHeTnxZr1PLQLsYiS0= X-MC-Unique: 6j4SyP-sPpurLuVu959Asw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 02/15] util/win32: simplify qemu_get_local_state_dir() Date: Thu, 5 May 2022 12:14:18 +0400 Message-Id: <20220505081431.934739-3-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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; Received-SPF: pass client-ip=170.10.129.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651738939501100001 From: Marc-Andr=C3=A9 Lureau SHGetFolderPath() is a deprecated API: https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_co= re-shgetfolderpatha It is a wrapper for SHGetKnownFolderPath() and CSIDL_COMMON_PATH is mapped to FOLDERID_ProgramData: https://docs.microsoft.com/en-us/windows/win32/shell/csidl g_get_system_data_dirs() is a suitable replacement, as it will have FOLDERID_ProgramData in the returned list. However, it follows the XDG Base Directory Specification, if `XDG_DATA_DIRS` is defined, it will be returned instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Weil --- util/oslib-win32.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 6c818749d2b9..5723d3eb4c5a 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -40,9 +40,6 @@ #include "qemu/error-report.h" #include =20 -/* this must come after including "trace.h" */ -#include - static int get_allocation_granularity(void) { SYSTEM_INFO system_info; @@ -237,17 +234,11 @@ int qemu_get_thread_id(void) char * qemu_get_local_state_dir(void) { - HRESULT result; - char base_path[MAX_PATH+1] =3D ""; + const char * const *data_dirs =3D g_get_system_data_dirs(); =20 - result =3D SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, - /* SHGFP_TYPE_CURRENT */ 0, base_path); - if (result !=3D S_OK) { - /* misconfigured environment */ - g_critical("CSIDL_COMMON_APPDATA unavailable: %ld", (long)result); - abort(); - } - return g_strdup(base_path); + g_assert(data_dirs && data_dirs[0]); + + return g_strdup(data_dirs[0]); } =20 void qemu_set_tty_echo(int fd, bool echo) --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651739460; cv=none; d=zohomail.com; s=zohoarc; b=D8FYdEmLKLonJYQVdgttgp9rAuZqXKYK0Uyftv8S8OAKI++A27NDRScQDGUFHAVHJRdaqOvZu9A6cRNDaT7gXvCtL/rRiay/zZ7zS9qPQ+eRBHV4y20wDqy57W9ovQEOL+Xd8qzry8wawfvlW8mjYJ2eaZOYEoG1ZnqoYeI4nS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651739460; 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=Z8V4PowSbp6KiN32NnxVUfW1RJVoP7G0Taw4agHMlqM=; b=ke/OPE8dz7ZOW3FA96QJ5Nq4IkP5nHNqX79bT7WXeKuNoiDDegAMhOfblEWDbWKut6Q/E4h0uRCsiyI6vBa8iaBpgoBIDZBAoaLcpKfOlqpqTlKWYKMd6ehWM5V9MoOr9T73Sc8kNrQ+7dNkkMUCw2G/h2vMczx0DqSBEIf/D4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651739460278833.0990481161805; Thu, 5 May 2022 01:31:00 -0700 (PDT) Received: from localhost ([::1]:50576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWt1-0005tk-9I for importer@patchew.org; Thu, 05 May 2022 04:30:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWe6-0006dR-TN for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:35 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:28279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWe5-0007qM-AE for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-270-fck9EHBaOkGnpv9lOYGR-w-1; Thu, 05 May 2022 04:15:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C3F2299E745; Thu, 5 May 2022 08:15:29 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31749C27E90; Thu, 5 May 2022 08:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738532; 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=Z8V4PowSbp6KiN32NnxVUfW1RJVoP7G0Taw4agHMlqM=; b=GyL83e/Xaw2zYuqT39O4Chczo0Pg63eEnEPXpLUT+1/0Uj33uUCJKzjkJ0Hg3ImtlsX28j 7ZvgEDgbtyn7KyGd+ayQcbq9zLFw4UkSQZF5A60wUgtRcQjdCjUjbhYzbfsBG5ACT8CFQ2 NtUrSXUc0//nKyL/pWJqxF4XKAyT2n4= X-MC-Unique: fck9EHBaOkGnpv9lOYGR-w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 03/15] tests: make libqmp buildable for win32 Date: Thu, 5 May 2022 12:14:19 +0400 Message-Id: <20220505081431.934739-4-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651739462276100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth --- tests/qtest/libqmp.h | 2 ++ tests/qtest/libqmp.c | 35 +++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqmp.h b/tests/qtest/libqmp.h index 94aa97328a17..772f18b73ba3 100644 --- a/tests/qtest/libqmp.h +++ b/tests/qtest/libqmp.h @@ -20,8 +20,10 @@ #include "qapi/qmp/qdict.h" =20 QDict *qmp_fd_receive(int fd); +#ifndef G_OS_WIN32 void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, const char *fmt, va_list ap) G_GNUC_PRINTF(4, 0); +#endif void qmp_fd_vsend(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0); void qmp_fd_send(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3); void qmp_fd_send_raw(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3); diff --git a/tests/qtest/libqmp.c b/tests/qtest/libqmp.c index 0358b8313dc4..93c9b31cd4ca 100644 --- a/tests/qtest/libqmp.c +++ b/tests/qtest/libqmp.c @@ -15,9 +15,13 @@ */ =20 #include "qemu/osdep.h" - #include "libqmp.h" =20 +#ifndef G_OS_WIN32 +#include +#endif + +#include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/qjson.h" @@ -87,6 +91,7 @@ QDict *qmp_fd_receive(int fd) return qmp.response; } =20 +#ifndef G_OS_WIN32 /* Sends a message and file descriptors to the socket. * It's needed for qmp-commands like getfd/add-fd */ static void socket_send_fds(int socket_fd, int *fds, size_t fds_num, @@ -120,17 +125,23 @@ static void socket_send_fds(int socket_fd, int *fds, = size_t fds_num, } while (ret < 0 && errno =3D=3D EINTR); g_assert_cmpint(ret, >, 0); } +#endif =20 /** * Allow users to send a message without waiting for the reply, * in the case that they choose to discard all replies up until * a particular EVENT is received. */ -void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, - const char *fmt, va_list ap) +static void +_qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, + const char *fmt, va_list ap) { QObject *qobj; =20 +#ifdef G_OS_WIN32 + assert(fds_num =3D=3D 0); +#endif + /* Going through qobject ensures we escape strings properly */ qobj =3D qobject_from_vjsonf_nofail(fmt, ap); =20 @@ -148,10 +159,14 @@ void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_nu= m, if (log) { fprintf(stderr, "%s", str->str); } + +#ifndef G_OS_WIN32 /* Send QMP request */ if (fds && fds_num > 0) { socket_send_fds(fd, fds, fds_num, str->str, str->len); - } else { + } else +#endif + { socket_send(fd, str->str, str->len); } =20 @@ -160,15 +175,23 @@ void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_nu= m, } } =20 +#ifndef G_OS_WIN32 +void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, + const char *fmt, va_list ap) +{ + _qmp_fd_vsend_fds(fd, fds, fds_num, fmt, ap); +} +#endif + void qmp_fd_vsend(int fd, const char *fmt, va_list ap) { - qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); + _qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); } =20 =20 QDict *qmp_fdv(int fd, const char *fmt, va_list ap) { - qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); + _qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); =20 return qmp_fd_receive(fd); } --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651739959; cv=none; d=zohomail.com; s=zohoarc; b=TpzIa0TJinILvy0JogiWthTV4UR40slTsqkryXsRL11Db5H7QxTa5ury5L4+T5nOg9ql556VY3Tz90ycLgEL5FmcFJk4htACZ9g2WK9VdtQ5KDcwlqLMCFBFSedpAtc8OWi2htsQeIGAPy/aRGu+nnciFVYZf29kLr3lqtg45v0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651739959; 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=xCxjIaSXvgo1vovv7B5aggf/rquRbBd08MNC+kTE5kM=; b=jrgSEqYPrhlwNRqGtLtT4CL2Y5CEbwPUGdAG2a0KepN2BtI6NTRGDJNRjwT2Sd2qv2ZY494XiCofu2mIXklRAD7SfmuD0KmzEwZS1Waz6Y6y3Mfu69a56re6dMh8HA9vYJkZK3l4WAsMAZo0T8K6wFMxILYUNhBODQP5iD7QC/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651739959877385.37192813801175; Thu, 5 May 2022 01:39:19 -0700 (PDT) Received: from localhost ([::1]:33800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmX14-0005gr-Jo for importer@patchew.org; Thu, 05 May 2022 04:39:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeJ-0006l4-Co for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:49 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:21964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeH-0007sO-Rn for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:47 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-228-ArIh8mJRO1CsbXo1WttrTw-1; Thu, 05 May 2022 04:15:42 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D8508007CE; Thu, 5 May 2022 08:15:41 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B79840314B; Thu, 5 May 2022 08:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738545; 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=xCxjIaSXvgo1vovv7B5aggf/rquRbBd08MNC+kTE5kM=; b=PEwAobWAZy6ZaN6TL7ZH+ky0T1LL7Hae0b3SDrN464q4KzjJh+7F1E+In0jfsgoPTh7KNM EdRfwqPyTm3zcpCChNQcHfVOqGrQnLnkJNdinV5wbZHrWHBIkuxcfSkHyEUL0nV3wXow9m iM1pqcLA0noU4lrwkkKpVVGWdehOH3o= X-MC-Unique: ArIh8mJRO1CsbXo1WttrTw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 04/15] include: adjust header guards after renaming Date: Thu, 5 May 2022 12:14:20 +0400 Message-Id: <20220505081431.934739-5-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651739961736100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Weil Reviewed-by: Markus Armbruster --- include/qemu/help-texts.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qemu/help-texts.h b/include/qemu/help-texts.h index ba32cc8b1f39..4f265fed8df1 100644 --- a/include/qemu/help-texts.h +++ b/include/qemu/help-texts.h @@ -1,5 +1,5 @@ -#ifndef QEMU_COMMON_H -#define QEMU_COMMON_H +#ifndef QEMU_HELP_TEXTS_H +#define QEMU_HELP_TEXTS_H =20 /* Copyright string for -version arguments, About dialogs, etc */ #define QEMU_COPYRIGHT "Copyright (c) 2003-2022 " \ --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651740286; cv=none; d=zohomail.com; s=zohoarc; b=OwL3+pnVYeud7KZgBS4c/N+qMTX9s010NdJyR9bBa5SoxYBaUI/vG/+xX9UvNM8ge9K2QsWvNdmYhyJdOUEyy9SI0OgmHBI/61Bw6qq7mVkP/BEIuZWRCcQRHhfhfUqoYVziDev7EX1uX+ZPr+QeMoHJ0D7Nbe9rVdLR/8h7dlE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651740286; 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=uQOpHYPfgI2lX2Mdfl+rfOehX+tXCf4jqiRnGqO398A=; b=PNmKgEYIt3yqapBalGPMMsDjJIP85SHksv8EKJI4V26me2vgIk8DYNee4TXcx8i4DCczEjWThVL/48Z5XQevtgRmGF98py/eEnSSggNBDOLNDOt5Vooyu0IdCCChZcfEXTg9mZruHWiTA8Yxx5ezJFlvEOfrxPMvfZDWwgkceOk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651740286143811.0733840319572; Thu, 5 May 2022 01:44:46 -0700 (PDT) Received: from localhost ([::1]:42390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmX6L-0003FX-3I for importer@patchew.org; Thu, 05 May 2022 04:44:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeO-0006mK-LO for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:52 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:26716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeM-0007sh-VL for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:52 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-172-j1LoL1EyOCKvuj-lwD2gEw-1; Thu, 05 May 2022 04:15:47 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76A0C29ABA35; Thu, 5 May 2022 08:15:46 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A0DAC28102; Thu, 5 May 2022 08:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738550; 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=uQOpHYPfgI2lX2Mdfl+rfOehX+tXCf4jqiRnGqO398A=; b=YkahhGYNI8X7AwCUITkWuwcu7AuRNpt+elUi3YnDlFdoQHZnb6bAfLHXwt1HpdLYdEK9Iy ODlnRVZBE2DxZAMdxRiJ4k3U8tj41vJ1TSDIlE5XJiIgLXdQ2/6+rSROY/Ha+LUWtfgDAM E9UrMsN2LOD/xOBM/PmIK3CoYbyCkH0= X-MC-Unique: j1LoL1EyOCKvuj-lwD2gEw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 05/15] qga: flatten safe_open_or_create() Date: Thu, 5 May 2022 12:14:21 +0400 Message-Id: <20220505081431.934739-6-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651740290528100001 From: Marc-Andr=C3=A9 Lureau There is a bit too much branching in the function, this can be simplified a bit, and have a common exit point thanks to ERRP_PROPAGATE. This also helps with the following error handling changes. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qga/commands-posix.c | 124 ++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 61 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 69f209af87e6..0ef049650e31 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -339,73 +339,75 @@ find_open_flag(const char *mode_str, Error **errp) static FILE * safe_open_or_create(const char *path, const char *mode, Error **errp) { - Error *local_err =3D NULL; - int oflag; - - oflag =3D find_open_flag(mode, &local_err); - if (local_err =3D=3D NULL) { - int fd; + ERRP_GUARD(); + int oflag, fd =3D -1; + FILE *f =3D NULL; + + oflag =3D find_open_flag(mode, errp); + if (*errp) { + goto end; + } + + /* If the caller wants / allows creation of a new file, we implement it + * with a two step process: open() + (open() / fchmod()). + * + * First we insist on creating the file exclusively as a new file. If + * that succeeds, we're free to set any file-mode bits on it. (The + * motivation is that we want to set those file-mode bits independently + * of the current umask.) + * + * If the exclusive creation fails because the file already exists + * (EEXIST is not possible for any other reason), we just attempt to + * open the file, but in this case we won't be allowed to change the + * file-mode bits on the preexistent file. + * + * The pathname should never disappear between the two open()s in + * practice. If it happens, then someone very likely tried to race us. + * In this case just go ahead and report the ENOENT from the second + * open() to the caller. + * + * If the caller wants to open a preexistent file, then the first + * open() is decisive and its third argument is ignored, and the second + * open() and the fchmod() are never called. + */ + fd =3D open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0); + if (fd =3D=3D -1 && errno =3D=3D EEXIST) { + oflag &=3D ~(unsigned)O_CREAT; + fd =3D open(path, oflag); + } + if (fd =3D=3D -1) { + error_setg_errno(errp, errno, + "failed to open file '%s' " + "(mode: '%s')", + path, mode); + goto end; + } =20 - /* If the caller wants / allows creation of a new file, we impleme= nt it - * with a two step process: open() + (open() / fchmod()). - * - * First we insist on creating the file exclusively as a new file.= If - * that succeeds, we're free to set any file-mode bits on it. (The - * motivation is that we want to set those file-mode bits independ= ently - * of the current umask.) - * - * If the exclusive creation fails because the file already exists - * (EEXIST is not possible for any other reason), we just attempt = to - * open the file, but in this case we won't be allowed to change t= he - * file-mode bits on the preexistent file. - * - * The pathname should never disappear between the two open()s in - * practice. If it happens, then someone very likely tried to race= us. - * In this case just go ahead and report the ENOENT from the second - * open() to the caller. - * - * If the caller wants to open a preexistent file, then the first - * open() is decisive and its third argument is ignored, and the s= econd - * open() and the fchmod() are never called. - */ - fd =3D open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0); - if (fd =3D=3D -1 && errno =3D=3D EEXIST) { - oflag &=3D ~(unsigned)O_CREAT; - fd =3D open(path, oflag); - } + qemu_set_cloexec(fd); =20 - if (fd =3D=3D -1) { - error_setg_errno(&local_err, errno, "failed to open file '%s' " - "(mode: '%s')", path, mode); - } else { - qemu_set_cloexec(fd); + if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) =3D=3D -1) { + error_setg_errno(errp, errno, + "failed to set permission 0%03o on new file '%s' = (mode: '%s')", + (unsigned)DEFAULT_NEW_FILE_MODE, path, mode); + goto end; + } =20 - if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) =3D= =3D -1) { - error_setg_errno(&local_err, errno, "failed to set permiss= ion " - "0%03o on new file '%s' (mode: '%s')", - (unsigned)DEFAULT_NEW_FILE_MODE, path, mo= de); - } else { - FILE *f; - - f =3D fdopen(fd, mode); - if (f =3D=3D NULL) { - error_setg_errno(&local_err, errno, "failed to associa= te " - "stdio stream with file descriptor %d= , " - "file '%s' (mode: '%s')", fd, path, m= ode); - } else { - return f; - } - } + f =3D fdopen(fd, mode); + if (f =3D=3D NULL) { + error_setg_errno(errp, errno, + "failed to associate stdio stream with file descr= iptor %d, " + "file '%s' (mode: '%s')", + fd, path, mode); + } =20 - close(fd); - if (oflag & O_CREAT) { - unlink(path); - } +end: + if (f =3D=3D NULL && fd !=3D -1) { + close(fd); + if (oflag & O_CREAT) { + unlink(path); } } - - error_propagate(errp, local_err); - return NULL; + return f; } =20 int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *m= ode, --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651739853; cv=none; d=zohomail.com; s=zohoarc; b=DSXvgSv1Hz+gC3BcS++YOXGg6Ez/RQxj1Oly4EKjagbr3ZRSc4uwyr+gQ+hFYE4UbdK67Ba73VFECdDfZDFa7xGbyK03olccbCXnRniomrQdikNp/uv4h9dhX5S38EGxPHW0DhNRxBeBmD0381dYzOndX5UK5ugHGBmM/o55oGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651739853; 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=KlsHIrWV+HO7aeZTRbvh+8pSkcJ71kOwRP1Qu6+MR7M=; b=S4Hxhm4DOzmN2ysiYR/eF6dgT/uL1SHSnkTn745aaE19AHwAY7sYFpSISvztM1VdtL0ejtu6jreRi0RHs55EajpJER0a8sByNRdb5TykPmi95GyLfP5qgrp6ACOlIh/9uk7SzjXPwX3ELoly447U2cym9c6cpe4Vw0XJoJ9mvZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651739853501182.8813950686806; Thu, 5 May 2022 01:37:33 -0700 (PDT) Received: from localhost ([::1]:59194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWzM-0003dw-Ab for importer@patchew.org; Thu, 05 May 2022 04:37:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeS-0006nV-2n for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:01 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.129.74]:31786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeO-0007ss-Lm for qemu-devel@nongnu.org; Thu, 05 May 2022 04:15:55 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-GkuFbQeTOmC53r62SEiAqg-1; Thu, 05 May 2022 04:15:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F74D803792; Thu, 5 May 2022 08:15:50 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC4AE1468D6B; Thu, 5 May 2022 08:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738552; 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=KlsHIrWV+HO7aeZTRbvh+8pSkcJ71kOwRP1Qu6+MR7M=; b=do9Hh2k5iaAkwjOB2jGxK/GhYQiiF5qAIQsLoj8B94/kZdk3GblR+SGWxO1MuzSsN/OUTg nucWYXO7yGAs4vMKP6jblNB3Cdu4KL/c1o5LFAT5tE7SQM9MF9o6F+4cYtUf/rw+Hqra3f Kgit7p9e5WjKURW2jad2ncl3FllATcA= X-MC-Unique: GkuFbQeTOmC53r62SEiAqg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 06/15] osdep: export qemu_open_cloexec() Date: Thu, 5 May 2022 12:14:22 +0400 Message-Id: <20220505081431.934739-7-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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; Received-SPF: pass client-ip=170.10.129.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651739855235100001 From: Marc-Andr=C3=A9 Lureau Used in the next patch, to simplify qga code. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qemu/osdep.h | 1 + util/osdep.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 67cc4654166b..64f51cfb7a62 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -489,6 +489,7 @@ void sigaction_invoke(struct sigaction *action, */ int qemu_open_old(const char *name, int flags, ...); int qemu_open(const char *name, int flags, Error **errp); +int qemu_open_cloexec(const char *name, int flags, mode_t mode, Error **er= rp); int qemu_create(const char *name, int flags, mode_t mode, Error **errp); int qemu_close(int fd); int qemu_unlink(const char *name); diff --git a/util/osdep.c b/util/osdep.c index 60fcbbaebe72..67541b7654ef 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -279,9 +279,11 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t l= en, bool exclusive) } #endif =20 -static int qemu_open_cloexec(const char *name, int flags, mode_t mode) +int qemu_open_cloexec(const char *name, int flags, mode_t mode, Error **er= rp) { + ERRP_GUARD(); int ret; + #ifdef O_CLOEXEC ret =3D open(name, flags | O_CLOEXEC, mode); #else @@ -290,6 +292,10 @@ static int qemu_open_cloexec(const char *name, int fla= gs, mode_t mode) qemu_set_cloexec(ret); } #endif + if (ret =3D=3D -1) { + error_setg_errno(errp, errno, "Could not open '%s'", name); + } + return ret; } =20 @@ -327,7 +333,7 @@ qemu_open_internal(const char *name, int flags, mode_t = mode, Error **errp) } #endif =20 - ret =3D qemu_open_cloexec(name, flags, mode); + ret =3D qemu_open_cloexec(name, flags, mode, NULL); =20 if (ret =3D=3D -1) { const char *action =3D flags & O_CREAT ? "create" : "open"; --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651738798; cv=none; d=zohomail.com; s=zohoarc; b=W+fgv/BtokIqG7o3wuXS/PFt1M7xAdCxXn7c1w6/D1/uIw2SXPfwHE/hrhSlomDkvBZOSV+fWaWLAjCOPn5565PUxpQpK7F/Vjn9W1+9eykqP2BWglF0Mw4Rr0peitjhMhM3PbX/Zc3b2f9M5NFC2/BiMdGC0wAEolmFKQk4dUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738798; 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=ZzLfXaSZU74ozme9WubVrM5Ht+PC6ZsnOZ+umHLbX6U=; b=nswx0TAvZw748MkxymEImPRr98UkVN0ss9WwBfpL3p/Uzh2tjH7E1xhxvNsvR+HFuPy6Y6qWgmQhVSWgdLZVvyDnjPOBtdfwiVwIQlJ6AEWvse7Qn8DMQtXlvEvHFAGIQOC2tRXvW1mT+8B2YjdODzMeLfo1/SpimDMm8IUvpLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651738798432516.2206896095649; Thu, 5 May 2022 01:19:58 -0700 (PDT) Received: from localhost ([::1]:34764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWiL-0003Av-7Z for importer@patchew.org; Thu, 05 May 2022 04:19:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeX-0006oj-70 for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:01 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:48029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeV-0007ur-Nk for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:00 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-524-V-vzBnFGODWnK642T6hO9g-1; Thu, 05 May 2022 04:15:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3ED50857AA8; Thu, 5 May 2022 08:15:55 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39C3740CF900; Thu, 5 May 2022 08:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738559; 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=ZzLfXaSZU74ozme9WubVrM5Ht+PC6ZsnOZ+umHLbX6U=; b=XEyIpqEAMb+mbBJMimLloXYk9fH0JomdH18AJh1231cfxh5D6PENFlkRV1YEyBONDJE2+p ZQz5AMnCr8dXnhQKTHNpgz+yRmIBn/6ywahqkAI5WnaCcJYvvmjuy2bI0Ay3xKJJHjBdR2 o6iH6B7KbiY0oqLgaRgI2HW6xBSpwkk= X-MC-Unique: V-vzBnFGODWnK642T6hO9g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 07/15] qga: use qemu_open_cloexec() for safe_open_or_create() Date: Thu, 5 May 2022 12:14:23 +0400 Message-Id: <20220505081431.934739-8-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651738799311100001 From: Marc-Andr=C3=A9 Lureau The function takes care of setting CLOEXEC, and reporting error. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qga/commands-posix.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 0ef049650e31..8ebc327c5e02 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -370,21 +370,16 @@ safe_open_or_create(const char *path, const char *mod= e, Error **errp) * open() is decisive and its third argument is ignored, and the second * open() and the fchmod() are never called. */ - fd =3D open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0); + fd =3D qemu_open_cloexec(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0= ), 0, errp); if (fd =3D=3D -1 && errno =3D=3D EEXIST) { + g_clear_pointer(errp, error_free); oflag &=3D ~(unsigned)O_CREAT; - fd =3D open(path, oflag); + fd =3D qemu_open_cloexec(path, oflag, 0, errp); } if (fd =3D=3D -1) { - error_setg_errno(errp, errno, - "failed to open file '%s' " - "(mode: '%s')", - path, mode); goto end; } =20 - qemu_set_cloexec(fd); - if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) =3D=3D -1) { error_setg_errno(errp, errno, "failed to set permission 0%03o on new file '%s' = (mode: '%s')", --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651740179; cv=none; d=zohomail.com; s=zohoarc; b=Ri0EUrj3/0MwOVzDh3zHzpw7cqEjXh/9fw3DGuSbrbzJq+afahNNzlL5Y7Ad4MVPtVDRhRk+iBBOd4l2HlsgrW6vtJ8I+AIZ0GlKWrFHNryl6vr2RpOyPrVCZ5yboqWDPDGV5jPqvufamBjCjgZ3xpglsxONns/uFpr7cwLkOLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651740179; 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=6oZBQ9WYB7rOReK2m+uLVNbgBKZ2RFI8zPGCTc5TzQQ=; b=jz5YPZC3n9Ffn4nvDAjRSdFgqnYUiDQVs9SDtTY2EJwNa1eLKYP0IotzzYwb0kPlHUcjI1hZ+BwR+AVAEbyKl5fXi3r5PUoYmR4xXLxeEQEG8LYzXZ9YGJ8nL2HMUnjUGly+WUYXN9TA8EAHaPfy5E7rznnxfwTdYVZNmjUgUq8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651740179383714.4482186847482; Thu, 5 May 2022 01:42:59 -0700 (PDT) Received: from localhost ([::1]:39612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmX4c-0001JZ-3h for importer@patchew.org; Thu, 05 May 2022 04:42:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWee-00072Z-Qq for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:08 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.129.74]:54947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWec-0007vJ-VO for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:08 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-Uc0LZxKwOO2-w8kszp2I1Q-1; Thu, 05 May 2022 04:16:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA6B4803FF3; Thu, 5 May 2022 08:15:59 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64D3E40CF900; Thu, 5 May 2022 08:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738566; 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=6oZBQ9WYB7rOReK2m+uLVNbgBKZ2RFI8zPGCTc5TzQQ=; b=CDbyHpDfAwbO6nWK0hjvCDKmwl0mBcNtyweD1QsUj3tMeA1mMAAgLjFzJMlGxUuNGwfezn 7D79VPcPQquBOraZcEgLD4boWDZWsGz3W5UZEmYum8muPpRWKu4+zrhQ/oHv80dJK4vVZ/ /g0MZG+Dm3wgUNwXuq89bmBz8VIKegs= X-MC-Unique: Uc0LZxKwOO2-w8kszp2I1Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 08/15] qga: throw an Error in ga_channel_open() Date: Thu, 5 May 2022 12:14:24 +0400 Message-Id: <20220505081431.934739-9-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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; Received-SPF: pass client-ip=170.10.129.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651740181253100001 From: Marc-Andr=C3=A9 Lureau Allow for a single point of error reporting, and further refactoring. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qga/channel-posix.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index a996858e2492..0ce594bc36c2 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -119,8 +119,9 @@ static int ga_channel_client_add(GAChannel *c, int fd) } =20 static gboolean ga_channel_open(GAChannel *c, const gchar *path, - GAChannelMethod method, int fd) + GAChannelMethod method, int fd, Error **er= rp) { + ERRP_GUARD(); int ret; c->method =3D method; =20 @@ -133,21 +134,20 @@ static gboolean ga_channel_open(GAChannel *c, const g= char *path, #endif ); if (fd =3D=3D -1) { - g_critical("error opening channel: %s", strerror(errno)); + error_setg_errno(errp, errno, "error opening channel"); return false; } #ifdef CONFIG_SOLARIS ret =3D ioctl(fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI); if (ret =3D=3D -1) { - g_critical("error setting event mask for channel: %s", - strerror(errno)); + error_setg_errno(errp, errno, "error setting event mask for ch= annel"); close(fd); return false; } #endif ret =3D ga_channel_client_add(c, fd); if (ret) { - g_critical("error adding channel to main loop"); + error_setg(errp, "error adding channel to main loop"); close(fd); return false; } @@ -159,7 +159,7 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, assert(fd < 0); fd =3D qemu_open_old(path, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd =3D=3D -1) { - g_critical("error opening channel: %s", strerror(errno)); + error_setg_errno(errp, errno, "error opening channel"); return false; } tcgetattr(fd, &tio); @@ -180,7 +180,7 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, tcsetattr(fd, TCSANOW, &tio); ret =3D ga_channel_client_add(c, fd); if (ret) { - g_critical("error adding channel to main loop"); + error_setg(errp, "error adding channel to main loop"); close(fd); return false; } @@ -188,12 +188,8 @@ static gboolean ga_channel_open(GAChannel *c, const gc= har *path, } case GA_CHANNEL_UNIX_LISTEN: { if (fd < 0) { - Error *local_err =3D NULL; - - fd =3D unix_listen(path, &local_err); - if (local_err !=3D NULL) { - g_critical("%s", error_get_pretty(local_err)); - error_free(local_err); + fd =3D unix_listen(path, errp); + if (fd < 0) { return false; } } @@ -202,24 +198,19 @@ static gboolean ga_channel_open(GAChannel *c, const g= char *path, } case GA_CHANNEL_VSOCK_LISTEN: { if (fd < 0) { - Error *local_err =3D NULL; SocketAddress *addr; char *addr_str; =20 addr_str =3D g_strdup_printf("vsock:%s", path); - addr =3D socket_parse(addr_str, &local_err); + addr =3D socket_parse(addr_str, errp); g_free(addr_str); - if (local_err !=3D NULL) { - g_critical("%s", error_get_pretty(local_err)); - error_free(local_err); + if (*errp) { return false; } =20 - fd =3D socket_listen(addr, 1, &local_err); + fd =3D socket_listen(addr, 1, errp); qapi_free_SocketAddress(addr); - if (local_err !=3D NULL) { - g_critical("%s", error_get_pretty(local_err)); - error_free(local_err); + if (*errp) { return false; } } @@ -227,7 +218,7 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, break; } default: - g_critical("error binding/listening to specified socket"); + error_setg(errp, "error binding/listening to specified socket"); return false; } =20 @@ -272,12 +263,13 @@ GIOStatus ga_channel_read(GAChannel *c, gchar *buf, g= size size, gsize *count) GAChannel *ga_channel_new(GAChannelMethod method, const gchar *path, int listen_fd, GAChannelCallback cb, gpointer op= aque) { + Error *err =3D NULL; GAChannel *c =3D g_new0(GAChannel, 1); c->event_cb =3D cb; c->user_data =3D opaque; =20 - if (!ga_channel_open(c, path, method, listen_fd)) { - g_critical("error opening channel"); + if (!ga_channel_open(c, path, method, listen_fd, &err)) { + error_report_err(err); ga_channel_free(c); return NULL; } --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651739349; cv=none; d=zohomail.com; s=zohoarc; b=E1qZOZ3AAwuma5bKT586jSR/X0CFdqn33giNxl925IWOiUyS+zsdcPPh88INLvuLRKWnOkESIbqXw5UauRWJISHVNgTHBRHXgUOoD0+xueDwBdA1xdukwgQN3u3o6WMN7KWlWs2cpVueFbvD15jX4Nz37hMyypy1gOCzOKrhTl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651739349; 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=XNQ/c09URpcdOpejx2bIqowJdwTpNyRlw871zeo0Abo=; b=FbR/pgvDRn51n3BIg3fkLIkg4gVszIS0tdGKju+RuhZ+i7ZCn6UgJs95W5ZwFzyUVU3Rro/aoFN1jPLy/xEWAU2DH7/UTK+fZRXYvpHqBKlhXgLizVseTlfXy7rM1Hf7BPp2xs4pgV7IYkQJeIrTX8kFg+IDO5fdj98seJUICns= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651739349542928.5898710968031; Thu, 5 May 2022 01:29:09 -0700 (PDT) Received: from localhost ([::1]:48260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWrE-0004JK-Dr for importer@patchew.org; Thu, 05 May 2022 04:29:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWeg-00077N-CY for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:10 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:47350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWee-0007wM-GI for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-314-3nlkgYiTOr2WhGZ08vbaIw-1; Thu, 05 May 2022 04:16:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 618BA803D4E; Thu, 5 May 2022 08:16:04 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B7BB400E86A; Thu, 5 May 2022 08:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738567; 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=XNQ/c09URpcdOpejx2bIqowJdwTpNyRlw871zeo0Abo=; b=WPtbZRQjP3b444LHNhEWaCQTlfUGV1JKpxulFJKC5A1FpDoll1Apv8EBVTYQleXXJOG3c/ cEBc5aCLr3b5xqA1WHCBU2tzQXAKEVMpiFMOEL29oXBY8dK315iHNR2NUDeE9/62pV8apn 9L9UH2SoyUH5y9AS20DD0hjtIFdEcXM= X-MC-Unique: 3nlkgYiTOr2WhGZ08vbaIw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 09/15] qga: replace qemu_open_old() with qemu_open_cloexec() Date: Thu, 5 May 2022 12:14:25 +0400 Message-Id: <20220505081431.934739-10-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651739351712100001 From: Marc-Andr=C3=A9 Lureau qemu_open_old() uses qemu_open_internal() which handles special "/dev/fdset/" path for monitor fd sets, set CLOEXEC, and uses Error reporting (and some O_DIRECT special error casing). The monitor fdset handling is unnecessary for qga, use qemu_open_cloexec() instead. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qga/channel-posix.c | 14 +++++++++----- qga/commands-posix.c | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 0ce594bc36c2..a1262b130145 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -1,4 +1,5 @@ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include #include "qapi/error.h" #include "qemu/sockets.h" @@ -128,11 +129,15 @@ static gboolean ga_channel_open(GAChannel *c, const g= char *path, switch (c->method) { case GA_CHANNEL_VIRTIO_SERIAL: { assert(fd < 0); - fd =3D qemu_open_old(path, O_RDWR | O_NONBLOCK + fd =3D qemu_open_cloexec( + path, #ifndef CONFIG_SOLARIS - | O_ASYNC + O_ASYNC | #endif - ); + O_RDWR | O_NONBLOCK, + 0, + errp + ); if (fd =3D=3D -1) { error_setg_errno(errp, errno, "error opening channel"); return false; @@ -157,9 +162,8 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, struct termios tio; =20 assert(fd < 0); - fd =3D qemu_open_old(path, O_RDWR | O_NOCTTY | O_NONBLOCK); + fd =3D qemu_open_cloexec(path, O_RDWR | O_NOCTTY | O_NONBLOCK, 0, = errp); if (fd =3D=3D -1) { - error_setg_errno(errp, errno, "error opening channel"); return false; } tcgetattr(fd, &tio); diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 8ebc327c5e02..f82205e25813 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1392,6 +1392,7 @@ static GuestDiskInfoList *get_disk_partitions( =20 static void get_nvme_smart(GuestDiskInfo *disk) { + Error *err =3D NULL; int fd; GuestNVMeSmart *smart; NvmeSmartLog log =3D {0}; @@ -1404,9 +1405,10 @@ static void get_nvme_smart(GuestDiskInfo *disk) | (((sizeof(log) >> 2) - 1) << 16) }; =20 - fd =3D qemu_open_old(disk->name, O_RDONLY); + fd =3D qemu_open_cloexec(disk->name, O_RDONLY, 0, &err); if (fd =3D=3D -1) { - g_debug("Failed to open device: %s: %s", disk->name, g_strerror(er= rno)); + g_debug("Failed to open device: %s: %s", disk->name, error_get_pre= tty(err)); + error_free(err); return; } =20 @@ -1737,9 +1739,8 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mount= points, } } =20 - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qemu_open_cloexec(mount->dirname, O_RDONLY, 0, errp); if (fd =3D=3D -1) { - error_setg_errno(errp, errno, "failed to open %s", mount->dirn= ame); goto error; } =20 @@ -1804,7 +1805,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp) =20 QTAILQ_FOREACH(mount, &mounts, next) { logged =3D false; - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qemu_open_cloexec(mount->dirname, O_RDONLY, 0, NULL); if (fd =3D=3D -1) { continue; } @@ -1864,21 +1865,20 @@ static void guest_fsfreeze_cleanup(void) GuestFilesystemTrimResponse * qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp) { + ERRP_GUARD(); GuestFilesystemTrimResponse *response; GuestFilesystemTrimResult *result; int ret =3D 0; FsMountList mounts; struct FsMount *mount; int fd; - Error *local_err =3D NULL; struct fstrim_range r; =20 slog("guest-fstrim called"); =20 QTAILQ_INIT(&mounts); - build_fs_mount_list(&mounts, &local_err); - if (local_err) { - error_propagate(errp, local_err); + build_fs_mount_list(&mounts, errp); + if (*errp) { return NULL; } =20 @@ -1890,11 +1890,11 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum,= Error **errp) =20 QAPI_LIST_PREPEND(response->paths, result); =20 - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qemu_open_cloexec(mount->dirname, O_RDONLY, 0, errp); if (fd =3D=3D -1) { - result->error =3D g_strdup_printf("failed to open: %s", - strerror(errno)); + result->error =3D g_strdup(error_get_pretty(*errp)); result->has_error =3D true; + g_clear_pointer(errp, error_free); continue; } =20 --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651740725; cv=none; d=zohomail.com; s=zohoarc; b=LEclhQnGpTFGU/1K6dDaHf8lxvPbCOunUmoj6G4IK+UBjZfIASO7q8Qh3vHa2p6qL2WUOXKe7KCznkwOdnRBUXpt2AwQ9NPD05y9wJ2EFHMMpg7dwHNymp9H3x6h8wnec3+kWV0YspkM5/Q3qv207cgEbZS6u8IGP+2jmuhoQHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651740725; 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=6nQaHUnsbUm++6YauvTEXvH8F+hiBUZ26qTaZtgMhqY=; b=KYFToMKh2qo5V8l4zUbDagyi+tUeEIePGtAxFiW5tEsEwvCchymbTtg/W/Xkl2JOsieYnwX+KcRnuaJm37LSMB6ezljxVogHcOdfBFePnLJQLNNsVjhG5UY+Qn32GfvBfGEzf3a5hcRC1HZYMde8i4P+VBr8a8xTGmiWYCpsTFY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651740725851869.3558140062321; Thu, 5 May 2022 01:52:05 -0700 (PDT) Received: from localhost ([::1]:48206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmXDQ-0007Ui-2I for importer@patchew.org; Thu, 05 May 2022 04:52:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWek-0007FW-Hv for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:15 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.129.74]:22410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWej-0007yV-09 for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:14 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-l_OD3SLwNvqjps14OnwsWA-1; Thu, 05 May 2022 04:16:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A43E229ABA37; Thu, 5 May 2022 08:16:08 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB64D40CF900; Thu, 5 May 2022 08:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738572; 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=6nQaHUnsbUm++6YauvTEXvH8F+hiBUZ26qTaZtgMhqY=; b=Rg+niUFVRw7sPxNLEjY893jY0EyEKvE6goLAuOVfn4jhvflaTshTFjEvABUXQaNn683VXf fQs1gaJlyf2HoqbD58lOwECRpi0anao/6nUQ2N4UlURBBQ2rFvKWJGCNTl8wyLWq7y4dP9 Oz/ncQWARoACvWuq6zNgOOXJc3GHCuo= X-MC-Unique: l_OD3SLwNvqjps14OnwsWA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 10/15] test/qga: use G_TEST_DIR to locate os-release test file Date: Thu, 5 May 2022 12:14:26 +0400 Message-Id: <20220505081431.934739-11-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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; Received-SPF: pass client-ip=170.10.129.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651740726167100001 From: Marc-Andr=C3=A9 Lureau This a more accurate way to lookup the test data, and will allow to move the test in a subproject. Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/unit/test-qga.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index d6df1ee92ea1..ab0b12a2dd16 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -914,15 +914,14 @@ static void test_qga_guest_get_osinfo(gconstpointer d= ata) { TestFixture fixture; const gchar *str; - gchar *cwd, *env[2]; - QDict *ret, *val; + QDict *ret =3D NULL; + char *env[2]; + QDict *val; =20 - cwd =3D g_get_current_dir(); env[0] =3D g_strdup_printf( - "QGA_OS_RELEASE=3D%s%ctests%cdata%ctest-qga-os-release", - cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR, G_DIR_SEPARATOR); + "QGA_OS_RELEASE=3D%s%c..%cdata%ctest-qga-os-release", + g_test_get_dir(G_TEST_DIST), G_DIR_SEPARATOR, G_DIR_SEPARATOR, G_D= IR_SEPARATOR); env[1] =3D NULL; - g_free(cwd); fixture_setup(&fixture, NULL, env); =20 ret =3D qmp_fd(fixture.fd, "{'execute': 'guest-get-osinfo'}"); --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651739155; cv=none; d=zohomail.com; s=zohoarc; b=a4LPa7xlCBgfurtEwEhh/cqre0HxIzLet6XNGfvZ3wCV/VLsYCFTcXUUWnLt+TjHCdBdXibm1YAybWiLuVaZsKAE9YHIeCVmK353FVmDD4GjfP9lmxWnqAdTVytraU8kqMT0tEBj8DlQkUqccUrCbgHc0CNuSWo/VUnAc0DXyAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651739155; 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=MttDrHkHjPFv/UJzopMS9KRbknWRjbTif+1Pc/xe8E0=; b=hC3Qv3PfeXhOunWnlxkZAEieoi6WRsAeeZa2VUG/swkunlCpXljcLTFlAQMKrsiNvDOCGe5D94W4BhsIjpi6OOYNHf/zABe42eeSpMvIy19DQpZLgdeweKeRjZrurx1+94RWftwwLMRdVa1iBK05Njii1Jwx0F4OkH8DhGyN/6c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651739155556576.4375178403797; Thu, 5 May 2022 01:25:55 -0700 (PDT) Received: from localhost ([::1]:44014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWo6-0001He-3F for importer@patchew.org; Thu, 05 May 2022 04:25:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWet-0007KN-P2 for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:24 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.129.74]:25893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWer-0007zB-Sr for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:23 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-dDcjTUVxPiSPlVTuhidgWQ-1; Thu, 05 May 2022 04:16:15 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E253285A5BC; Thu, 5 May 2022 08:16:14 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3929741617E; Thu, 5 May 2022 08:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738581; 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=MttDrHkHjPFv/UJzopMS9KRbknWRjbTif+1Pc/xe8E0=; b=PAaWjXGyLheD6U0iQnUsRUJx+LSKq/3dy+WgNT+/d8grXgxgpQsVCtQI/7/kd7NVxJBgda iaeRKYxa+BtUVXsq/kvoaZP5/RvKOS7/m4YGvJomvknznwVaX1cz/kKC2jqAa7jv3NVch8 sUntBlKUqtwmL/sjEdZuAAftg1KNmWA= X-MC-Unique: dDcjTUVxPiSPlVTuhidgWQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 11/15] qga/wixl: prefer variables over environment Date: Thu, 5 May 2022 12:14:27 +0400 Message-Id: <20220505081431.934739-12-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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; Received-SPF: pass client-ip=170.10.129.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651739156158100001 From: Marc-Andr=C3=A9 Lureau No need to setup an environment or to check if the variable is undefined manually. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- qga/installer/qemu-ga.wxs | 30 +++++++++--------------------- qga/meson.build | 9 ++++----- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index 0950e8c6becc..8a19aa165651 100644 --- a/qga/installer/qemu-ga.wxs +++ b/qga/installer/qemu-ga.wxs @@ -1,17 +1,5 @@ - - - - - - - - - - - - @@ -43,20 +31,20 @@ Name=3D"QEMU guest agent" Id=3D"*" UpgradeCode=3D"{EB6B8302-C06E-4BEC-ADAC-932C68A3A98D}" - Manufacturer=3D"$(env.QEMU_GA_MANUFACTURER)" - Version=3D"$(env.QEMU_GA_VERSION)" + Manufacturer=3D"$(var.QEMU_GA_MANUFACTURER)" + Version=3D"$(var.QEMU_GA_VERSION)" Language=3D"1033"> NOT VersionNT64 - + 1 - + - + - + @@ -133,9 +121,9 @@ + Key=3D"Software\$(var.QEMU_GA_MANUFACTURER)\$(var= .QEMU_GA_DISTRO)\Tools\QemuGA"> - + diff --git a/qga/meson.build b/qga/meson.build index 6d9f39bb321b..3ad3bc0260cf 100644 --- a/qga/meson.build +++ b/qga/meson.build @@ -121,15 +121,14 @@ if targetos =3D=3D 'windows' output: 'qemu-ga-@0@.msi'.format(host_arch), depends: deps, command: [ - find_program('env'), - 'QEMU_GA_VERSION=3D' + config_host['QEMU_GA_= VERSION'], - 'QEMU_GA_MANUFACTURER=3D' + config_host['QEM= U_GA_MANUFACTURER'], - 'QEMU_GA_DISTRO=3D' + config_host['QEMU_GA_D= ISTRO'], - 'BUILD_DIR=3D' + meson.build_root(), wixl, '-o', '@OUTPUT0@', '@INPUT0@', qemu_ga_msi_arch[cpu], qemu_ga_msi_vss, + '-D', 'BUILD_DIR=3D' + meson.build_root(), '-D', 'Mingw_bin=3D' + config_host['QEMU_GA_= MSI_MINGW_BIN_PATH'], + '-D', 'QEMU_GA_VERSION=3D' + config_host['QE= MU_GA_VERSION'], + '-D', 'QEMU_GA_MANUFACTURER=3D' + config_hos= t['QEMU_GA_MANUFACTURER'], + '-D', 'QEMU_GA_DISTRO=3D' + config_host['QEM= U_GA_DISTRO'], ]) all_qga +=3D [qga_msi] alias_target('msi', qga_msi) --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651740898; cv=none; d=zohomail.com; s=zohoarc; b=J1s2PVyxt5FhWhwOuW9R1Pb0DQzsQQYpwom4wZOKkvoY3MYUKwInU+74gzwIoqFnretIxrnfQn98q7uNxLxWzRqk1A/qC2chxYImpYnjPayNHqYmON4YhAYkbFI6ak+58hnzMLUiCEN+6TzWDzKzWx8PwCNK/b0qs31Hr2b1boE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651740898; 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=jsVkNgQt2/NtdmSx0vIG08OtD1zVsdFhwezp5JU9cqU=; b=OiJ58hGbAfPgk+MVvJhL77uayBFl/tAY1aNcVdHruvfxplHxKeUkW12ug8t+/xq9p+DyCsQ+SFJpTITJI9f13U6wk1V4ZqCbhtfLAlPDbR05FLNks76Mt94J9wl7yCcnEn+Kq+7/vE1T2kziB23I/ooptuKAAW3dW9Q4whLvVqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651740898454457.40925229306504; Thu, 5 May 2022 01:54:58 -0700 (PDT) Received: from localhost ([::1]:53226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmXGD-0002tK-BW for importer@patchew.org; Thu, 05 May 2022 04:54:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWew-0007M0-Sn for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:28 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.129.74]:30731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWev-0007za-8T for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:26 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-505-09mTCCbpPZG9cT1K5_sWhA-1; Thu, 05 May 2022 04:16:20 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C72B3C8ACF6; Thu, 5 May 2022 08:16:20 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75B61463E1F; Thu, 5 May 2022 08:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738584; 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=jsVkNgQt2/NtdmSx0vIG08OtD1zVsdFhwezp5JU9cqU=; b=CgZMnmD9xa4BwRMVuH+IqodDeeOGE5C/m1RloHKQi6HPigHFEO/CQefRLRgPxCD+1PPKnR m4Q7lFOSb8VwZvK2dJuWDIlvpgPDSEn0Z7aqC6YPORncQOqp9UZFkTcdIZ8lNC05NaYdtD P13ROwC4h5RUMyL1ztcEBFCAvRpYUMs= X-MC-Unique: 09mTCCbpPZG9cT1K5_sWhA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 12/15] qga/wixl: require Mingw_bin Date: Thu, 5 May 2022 12:14:28 +0400 Message-Id: <20220505081431.934739-13-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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; Received-SPF: pass client-ip=170.10.129.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651740900436100001 From: Marc-Andr=C3=A9 Lureau No clear reason to make guesses here. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- qga/installer/qemu-ga.wxs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index 8a19aa165651..651db6e51cda 100644 --- a/qga/installer/qemu-ga.wxs +++ b/qga/installer/qemu-ga.wxs @@ -4,15 +4,6 @@ =20 - - - - - - - - - --=20 2.36.0.44.g0f828332d5ac From nobody Sun May 19 08:30:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1651739543; cv=none; d=zohomail.com; s=zohoarc; b=Lwb+vv85+Q6BgQkT1xOx61Gfiepdads7uPW5vZ3sunp09FQeIlEfBuso0O0IYG4CLYFXcb4abNoYUtERm6pl3zyMCIdUD/VU/Su1G9iouktEZ0ScFtW/atrZbm23Z46a+oxDhGb7nb+kIxPd7x42HDHMrxJ5gIKARMwOfO4bPxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651739543; 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=y0/XOvpyj0RJD5iIUN6OFymhbF0wmETapoPndwhY0xs=; b=W6OTkHPX7c1g7eOIx0T7ko2o1/h8r/vDd2TnafwIAaDlgVTFH70v0oMrXvcWA6TLpPg2uDGGshM0NwD7yTZdUDQLHqqdqR60DwWqPuINwa7rjYoy0bFnzKaYoi2z+ufDylp5qjw4Qv5Lvxa8cn/vZsYIpSIlt/DXqUibNPti4P8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651739543606861.0327027983127; Thu, 5 May 2022 01:32:23 -0700 (PDT) Received: from localhost ([::1]:52652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWuM-0007Rh-An for importer@patchew.org; Thu, 05 May 2022 04:32:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWf0-0007Mz-LO for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:32 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:47792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWey-000800-3u for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:30 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-W824-FPaOa-mcAIUoBrlpw-1; Thu, 05 May 2022 04:16:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13AAE1815CFB; Thu, 5 May 2022 08:16:24 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 303BA40D2820; Thu, 5 May 2022 08:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738587; 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=y0/XOvpyj0RJD5iIUN6OFymhbF0wmETapoPndwhY0xs=; b=ffbIiaZu+xdZJN2pI1Nd99rjJ4jCknTq5f/Z2JUTXqsIQ8rxzrHwGNsUp/ZiT0kMgW58VL Rt8tGugHeKFbsfVofPUVzrAylq0QIJkp4/cgjd7BeDPhc/HL0Wb/YOjtg8kC1FSAFiQAhO PTF/OTzt3snlhvV+4eMmdDVwxGoTpQc= X-MC-Unique: W824-FPaOa-mcAIUoBrlpw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 13/15] qga/wixl: simplify some pre-processing Date: Thu, 5 May 2022 12:14:29 +0400 Message-Id: <20220505081431.934739-14-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651739545618100001 From: Marc-Andr=C3=A9 Lureau Sadly, wixl doesn't have 'elif'. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- qga/installer/qemu-ga.wxs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index 651db6e51cda..e5b0958e1898 100644 --- a/qga/installer/qemu-ga.wxs +++ b/qga/installer/qemu-ga.wxs @@ -1,21 +1,15 @@ - - - - - - - - - - - - - + + + + + + + =20 (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16517413739820.5219011093689687; Thu, 5 May 2022 02:02:53 -0700 (PDT) Received: from localhost ([::1]:33636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmXNs-0000Ws-0p for importer@patchew.org; Thu, 05 May 2022 05:02:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWf4-0007Qm-3N for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:34 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:25471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWf1-00080O-Uj for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-60-s7sSNLa3NTe--ybk3lmraA-1; Thu, 05 May 2022 04:16:30 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74A3F100BABB; Thu, 5 May 2022 08:16:29 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 037A514A507B; Thu, 5 May 2022 08:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738591; 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=nspy6ScmfmxJvkKy6xaXMmxbASccohQU5I65OHpVnk4=; b=QGXYlgHiwYkxIO98dubP/GA8ewjUlE7v03rN57G1/r4kHPhmCweSGjekizXhaGUcd/073P vFtwdJwJYvLRtw9xivK7+Ax6VeK845qJ8tN3Udc65AeI51pkcXWhTZlZSbx2DNQItKhc8r zbvsaJIBnX54iQjsCqhV0RRx9Z540eo= X-MC-Unique: s7sSNLa3NTe--ybk3lmraA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 14/15] qga/wixl: replace QEMU_GA_MSI_MINGW_BIN_PATH with glib bindir Date: Thu, 5 May 2022 12:14:30 +0400 Message-Id: <20220505081431.934739-15-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651741375375100001 From: Marc-Andr=C3=A9 Lureau Use more conventional variables to set the location of pre-built DLL/bin. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- configure | 9 ++++++--- meson.build | 5 ++++- qga/installer/qemu-ga.wxs | 24 ++++++++++++------------ qga/meson.build | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 59c43bea05eb..616cd2d0e36c 100755 --- a/configure +++ b/configure @@ -2023,6 +2023,11 @@ for i in $glib_modules; do fi done =20 +glib_bindir=3D"$($pkg_config --variable=3Dbindir glib-2.0)" +if test -z "$glib_bindir" ; then + glib_bindir=3D"$($pkg_config --variable=3Dprefix glib-2.0)"/bin +fi + # This workaround is required due to a bug in pkg-config file for glib as = it # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static =20 @@ -2430,8 +2435,6 @@ if test "$QEMU_GA_VERSION" =3D ""; then QEMU_GA_VERSION=3D$(cat $source_path/VERSION) fi =20 -QEMU_GA_MSI_MINGW_BIN_PATH=3D"$($pkg_config --variable=3Dprefix glib-2.0)/= bin" - # Mac OS X ships with a broken assembler roms=3D if { test "$cpu" =3D "i386" || test "$cpu" =3D "x86_64"; } && \ @@ -2518,7 +2521,6 @@ if test "$debug_tcg" =3D "yes" ; then fi if test "$mingw32" =3D "yes" ; then echo "CONFIG_WIN32=3Dy" >> $config_host_mak - echo "QEMU_GA_MSI_MINGW_BIN_PATH=3D${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $co= nfig_host_mak echo "QEMU_GA_MANUFACTURER=3D${QEMU_GA_MANUFACTURER}" >> $config_host_mak echo "QEMU_GA_DISTRO=3D${QEMU_GA_DISTRO}" >> $config_host_mak echo "QEMU_GA_VERSION=3D${QEMU_GA_VERSION}" >> $config_host_mak @@ -2639,6 +2641,7 @@ echo "QEMU_CXXFLAGS=3D$QEMU_CXXFLAGS" >> $config_host= _mak echo "QEMU_OBJCFLAGS=3D$QEMU_OBJCFLAGS" >> $config_host_mak echo "GLIB_CFLAGS=3D$glib_cflags" >> $config_host_mak echo "GLIB_LIBS=3D$glib_libs" >> $config_host_mak +echo "GLIB_BINDIR=3D$glib_bindir" >> $config_host_mak echo "GLIB_VERSION=3D$(pkg-config --modversion glib-2.0)" >> $config_host_= mak echo "QEMU_LDFLAGS=3D$QEMU_LDFLAGS" >> $config_host_mak echo "LD_I386_EMULATION=3D$ld_i386_emulation" >> $config_host_mak diff --git a/meson.build b/meson.build index c26aa442d40e..2f68b6cb8634 100644 --- a/meson.build +++ b/meson.build @@ -443,7 +443,10 @@ add_project_arguments(config_host['GLIB_CFLAGS'].split= (), native: false, language: ['c', 'cpp', 'objc']) glib =3D declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split= (), link_args: config_host['GLIB_LIBS'].split(), - version: config_host['GLIB_VERSION']) + version: config_host['GLIB_VERSION'], + variables: { + 'bindir': config_host['GLIB_BINDIR'], + }) # override glib dep with the configure results (for subprojects) meson.override_dependency('glib-2.0', glib) =20 diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index e5b0958e1898..813d1c6ca6ae 100644 --- a/qga/installer/qemu-ga.wxs +++ b/qga/installer/qemu-ga.wxs @@ -58,7 +58,7 @@ - + @@ -69,40 +69,40 @@ - + - + - + - + - + - + - + - + - + - + - + (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651740000806158.64847108541187; Thu, 5 May 2022 01:40:00 -0700 (PDT) Received: from localhost ([::1]:34626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmX1j-0006EB-0N for importer@patchew.org; Thu, 05 May 2022 04:39:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWfB-0007c2-KM for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:42 -0400 Received: from us-smtp-delivery-74.mimecast.com ([170.10.133.74]:43407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWf9-00081L-Aq for qemu-devel@nongnu.org; Thu, 05 May 2022 04:16:41 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-230-dEQNTk1bNeWmkkIaNdW6GQ-1; Thu, 05 May 2022 04:16:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A882B8339C1; Thu, 5 May 2022 08:16:34 +0000 (UTC) Received: from localhost (unknown [10.39.208.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9927C2813A; Thu, 5 May 2022 08:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651738598; 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=P2DQcg2f7d6Ls9Ryi5RaJ5AgskrjL/TQo/dulXyKwCY=; b=F4HXvkaRVkRjqxw84prhoeoAwXT6rTa3JUeHOTPr4MBG23DxCl0YjRCoOugBsJqlZLdFLs 7wURSrE9Oal9zEBm7pLP9WlNPpXIV2ARonmpkSk3NOc0zH0dK9T0DqqZDkvZw0Ew1vfBZ6 7zU22cTV6UTDyvV0OVWV2QNHd71pURk= X-MC-Unique: dEQNTk1bNeWmkkIaNdW6GQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Bandan Das , Thomas Huth , Hanna Reitz , Markus Armbruster , Konstantin Kostiuk , Stefan Weil , Kevin Wolf , Darren Kenny , Laurent Vivier , Michael Roth , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 15/15] test/qga: use g_auto wherever sensible Date: Thu, 5 May 2022 12:14:31 +0400 Message-Id: <20220505081431.934739-16-marcandre.lureau@redhat.com> In-Reply-To: <20220505081431.934739-1-marcandre.lureau@redhat.com> References: <20220505081431.934739-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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; Received-SPF: pass client-ip=170.10.133.74; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-74.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1651740001958100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/unit/test-qga.c | 125 +++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 80 deletions(-) diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index ab0b12a2dd16..53cefc2c2649 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -51,8 +51,11 @@ static void fixture_setup(TestFixture *fixture, gconstpointer data, gchar **envp) { const gchar *extra_arg =3D data; - GError *error =3D NULL; - gchar *cwd, *path, *cmd, **argv =3D NULL; + g_autoptr(GError) error =3D NULL; + g_autofree char *cwd =3D NULL; + g_autofree char *path =3D NULL; + g_autofree char *cmd =3D NULL; + g_auto(GStrv) argv =3D NULL; =20 fixture->loop =3D g_main_loop_new(NULL, FALSE); =20 @@ -78,17 +81,12 @@ fixture_setup(TestFixture *fixture, gconstpointer data,= gchar **envp) =20 fixture->fd =3D connect_qga(path); g_assert_cmpint(fixture->fd, !=3D, -1); - - g_strfreev(argv); - g_free(cmd); - g_free(cwd); - g_free(path); } =20 static void fixture_tear_down(TestFixture *fixture, gconstpointer data) { - gchar *tmp; + g_autofree char *tmp =3D NULL; =20 kill(fixture->pid, SIGTERM); =20 @@ -107,7 +105,6 @@ fixture_tear_down(TestFixture *fixture, gconstpointer d= ata) =20 tmp =3D g_build_filename(fixture->test_dir, "sock", NULL); g_unlink(tmp); - g_free(tmp); =20 g_rmdir(fixture->test_dir); g_free(fixture->test_dir); @@ -122,7 +119,7 @@ static void qmp_assertion_message_error(const char = *domain, QDict *dict) { const char *class, *desc; - char *s; + g_autofree char *s =3D NULL; QDict *error; =20 error =3D qdict_get_qdict(dict, "error"); @@ -131,7 +128,6 @@ static void qmp_assertion_message_error(const char = *domain, =20 s =3D g_strdup_printf("assertion failed %s: %s %s", expr, class, desc); g_assertion_message(domain, file, line, func, s); - g_free(s); } =20 #define qmp_assert_no_error(err) do { \ @@ -146,7 +142,7 @@ static void test_qga_sync_delimited(gconstpointer fix) const TestFixture *fixture =3D fix; guint32 v, r =3D g_test_rand_int(); unsigned char c; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; =20 qmp_fd_send_raw(fixture->fd, "\xff"); qmp_fd_send(fixture->fd, @@ -180,15 +176,13 @@ static void test_qga_sync_delimited(gconstpointer fix) =20 v =3D qdict_get_int(ret, "return"); g_assert_cmpint(r, =3D=3D, v); - - qobject_unref(ret); } =20 static void test_qga_sync(gconstpointer fix) { const TestFixture *fixture =3D fix; guint32 v, r =3D g_test_rand_int(); - QDict *ret; + g_autoptr(QDict) ret =3D NULL; =20 /* * TODO guest-sync is inherently limited: we cannot distinguish @@ -210,33 +204,27 @@ static void test_qga_sync(gconstpointer fix) =20 v =3D qdict_get_int(ret, "return"); g_assert_cmpint(r, =3D=3D, v); - - qobject_unref(ret); } =20 static void test_qga_ping(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-ping'}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); - - qobject_unref(ret); } =20 static void test_qga_id(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-ping', 'id': 1}"); g_assert_nonnull(ret); qmp_assert_no_error(ret); g_assert_cmpint(qdict_get_int(ret, "id"), =3D=3D, 1); - - qobject_unref(ret); } =20 static void test_qga_invalid_oob(gconstpointer fix) @@ -253,7 +241,8 @@ static void test_qga_invalid_oob(gconstpointer fix) static void test_qga_invalid_args(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *error; + g_autoptr(QDict) ret =3D NULL; + QDict *error; const gchar *class, *desc; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-ping', " @@ -266,14 +255,13 @@ static void test_qga_invalid_args(gconstpointer fix) =20 g_assert_cmpstr(class, =3D=3D, "GenericError"); g_assert_cmpstr(desc, =3D=3D, "Parameter 'foo' is unexpected"); - - qobject_unref(ret); } =20 static void test_qga_invalid_cmd(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *error; + g_autoptr(QDict) ret =3D NULL; + QDict *error; const gchar *class, *desc; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-invalid-cmd'}"); @@ -285,14 +273,13 @@ static void test_qga_invalid_cmd(gconstpointer fix) =20 g_assert_cmpstr(class, =3D=3D, "CommandNotFound"); g_assert_cmpint(strlen(desc), >, 0); - - qobject_unref(ret); } =20 static void test_qga_info(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *val; + g_autoptr(QDict) ret =3D NULL; + QDict *val; const gchar *version; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-info'}"); @@ -302,14 +289,12 @@ static void test_qga_info(gconstpointer fix) val =3D qdict_get_qdict(ret, "return"); version =3D qdict_get_try_str(val, "version"); g_assert_cmpstr(version, =3D=3D, QEMU_VERSION); - - qobject_unref(ret); } =20 static void test_qga_get_vcpus(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; QList *list; const QListEntry *entry; =20 @@ -322,14 +307,12 @@ static void test_qga_get_vcpus(gconstpointer fix) entry =3D qlist_first(list); g_assert(qdict_haskey(qobject_to(QDict, entry->value), "online")); g_assert(qdict_haskey(qobject_to(QDict, entry->value), "logical-id")); - - qobject_unref(ret); } =20 static void test_qga_get_fsinfo(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; QList *list; const QListEntry *entry; =20 @@ -346,14 +329,13 @@ static void test_qga_get_fsinfo(gconstpointer fix) g_assert(qdict_haskey(qobject_to(QDict, entry->value), "type")); g_assert(qdict_haskey(qobject_to(QDict, entry->value), "disk")); } - - qobject_unref(ret); } =20 static void test_qga_get_memory_block_info(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *val; + g_autoptr(QDict) ret =3D NULL; + QDict *val; int64_t size; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-memory-block-info'= }"); @@ -366,14 +348,12 @@ static void test_qga_get_memory_block_info(gconstpoin= ter fix) size =3D qdict_get_int(val, "size"); g_assert_cmpint(size, >, 0); } - - qobject_unref(ret); } =20 static void test_qga_get_memory_blocks(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; QList *list; const QListEntry *entry; =20 @@ -391,14 +371,12 @@ static void test_qga_get_memory_blocks(gconstpointer = fix) g_assert(qdict_haskey(qobject_to(QDict, entry->value), "online= ")); } } - - qobject_unref(ret); } =20 static void test_qga_network_get_interfaces(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; QList *list; const QListEntry *entry; =20 @@ -410,8 +388,6 @@ static void test_qga_network_get_interfaces(gconstpoint= er fix) list =3D qdict_get_qlist(ret, "return"); entry =3D qlist_first(list); g_assert(qdict_haskey(qobject_to(QDict, entry->value), "name")); - - qobject_unref(ret); } =20 static void test_qga_file_ops(gconstpointer fix) @@ -642,7 +618,7 @@ static void test_qga_file_write_read(gconstpointer fix) static void test_qga_get_time(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; int64_t time; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-time'}"); @@ -651,8 +627,6 @@ static void test_qga_get_time(gconstpointer fix) =20 time =3D qdict_get_int(ret, "return"); g_assert_cmpint(time, >, 0); - - qobject_unref(ret); } =20 static void test_qga_blacklist(gconstpointer data) @@ -692,19 +666,23 @@ static void test_qga_blacklist(gconstpointer data) =20 static void test_qga_config(gconstpointer data) { - GError *error =3D NULL; - char *cwd, *cmd, *out, *err, *str, **strv, **argv =3D NULL; + g_autoptr(GError) error =3D NULL; + g_autofree char *out =3D NULL; + g_autofree char *err =3D NULL; + g_autofree char *cwd =3D NULL; + g_autofree char *cmd =3D NULL; + g_auto(GStrv) argv =3D NULL; + g_auto(GStrv) strv =3D NULL; + g_autoptr(GKeyFile) kf =3D NULL; + char *str; char *env[2]; int status; gsize n; - GKeyFile *kf; =20 cwd =3D g_get_current_dir(); cmd =3D g_strdup_printf("%s%cqga%cqemu-ga -D", cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR); - g_free(cwd); g_shell_parse_argv(cmd, NULL, &argv, &error); - g_free(cmd); g_assert_no_error(error); =20 env[0] =3D g_strdup_printf("QGA_CONF=3Dtests%cdata%ctest-qga-config", @@ -712,7 +690,6 @@ static void test_qga_config(gconstpointer data) env[1] =3D NULL; g_spawn_sync(NULL, argv, env, 0, NULL, NULL, &out, &err, &status, &error); - g_strfreev(argv); =20 g_assert_no_error(error); g_assert_cmpstr(err, =3D=3D, ""); @@ -759,18 +736,14 @@ static void test_qga_config(gconstpointer data) g_assert_true(g_strv_contains((const char * const *)strv, "guest-get-time")); g_assert_no_error(error); - g_strfreev(strv); =20 - g_free(out); - g_free(err); g_free(env[0]); - g_key_file_free(kf); } =20 static void test_qga_fsfreeze_status(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; const gchar *status; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-fsfreeze-status'}"); @@ -779,16 +752,15 @@ static void test_qga_fsfreeze_status(gconstpointer fi= x) =20 status =3D qdict_get_try_str(ret, "return"); g_assert_cmpstr(status, =3D=3D, "thawed"); - - qobject_unref(ret); } =20 static void test_qga_guest_exec(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *val; + g_autoptr(QDict) ret =3D NULL; + QDict *val; const gchar *out; - guchar *decoded; + g_autofree guchar *decoded =3D NULL; int64_t pid, now, exitcode; gsize len; bool exited; @@ -827,14 +799,13 @@ static void test_qga_guest_exec(gconstpointer fix) decoded =3D g_base64_decode(out, &len); g_assert_cmpint(len, =3D=3D, 12); g_assert_cmpstr((char *)decoded, =3D=3D, "\" test_str \""); - g_free(decoded); - qobject_unref(ret); } =20 static void test_qga_guest_exec_invalid(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *error; + g_autoptr(QDict) ret =3D NULL; + QDict *error; const gchar *class, *desc; =20 /* invalid command */ @@ -859,13 +830,13 @@ static void test_qga_guest_exec_invalid(gconstpointer= fix) desc =3D qdict_get_str(error, "desc"); g_assert_cmpstr(class, =3D=3D, "GenericError"); g_assert_cmpint(strlen(desc), >, 0); - qobject_unref(ret); } =20 static void test_qga_guest_get_host_name(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *val; + g_autoptr(QDict) ret =3D NULL; + QDict *val; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-host-name'}"); g_assert_nonnull(ret); @@ -873,14 +844,13 @@ static void test_qga_guest_get_host_name(gconstpointe= r fix) =20 val =3D qdict_get_qdict(ret, "return"); g_assert(qdict_haskey(val, "host-name")); - - qobject_unref(ret); } =20 static void test_qga_guest_get_timezone(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret, *val; + g_autoptr(QDict) ret =3D NULL; + QDict *val; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-timezone'}"); g_assert_nonnull(ret); @@ -889,14 +859,12 @@ static void test_qga_guest_get_timezone(gconstpointer= fix) /* Make sure there's at least offset */ val =3D qdict_get_qdict(ret, "return"); g_assert(qdict_haskey(val, "offset")); - - qobject_unref(ret); } =20 static void test_qga_guest_get_users(gconstpointer fix) { const TestFixture *fixture =3D fix; - QDict *ret; + g_autoptr(QDict) ret =3D NULL; QList *val; =20 ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-users'}"); @@ -906,15 +874,13 @@ static void test_qga_guest_get_users(gconstpointer fi= x) /* There is not much to test here */ val =3D qdict_get_qlist(ret, "return"); g_assert_nonnull(val); - - qobject_unref(ret); } =20 static void test_qga_guest_get_osinfo(gconstpointer data) { TestFixture fixture; const gchar *str; - QDict *ret =3D NULL; + g_autoptr(QDict) ret =3D NULL; char *env[2]; QDict *val; =20 @@ -958,7 +924,6 @@ static void test_qga_guest_get_osinfo(gconstpointer dat= a) g_assert_nonnull(str); g_assert_cmpstr(str, =3D=3D, "unit-test"); =20 - qobject_unref(ret); g_free(env[0]); fixture_tear_down(&fixture, NULL); } --=20 2.36.0.44.g0f828332d5ac