From nobody Sun May 12 22:09:26 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=1653865070; cv=none; d=zohomail.com; s=zohoarc; b=cZplUHS+hQSupcD2KQ8cWe1WhsCkETdE8OYeibliqF+DYNP+2eH6AghHyn5j6qTLJXc0NCrD3X/IBIpT5STQDTGBmX/8M3fnInjvk49IAUfweKlxgEvC4fc0s6w8nzgZ5AypQFLTGmbrvG2d4HeET4eoThVBAsTtIT09pEFXr+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865070; 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=iNVQZFhasoB5bTGJiRo7AOywqvQUQPhXCCSykSaAp4c=; b=m/W47DOG10oh3Pg+TrEMIyWZJlixOL+1eiiQRiEUTaqZdZzpQVgmxWQs8i2AN48exW1E55w36cL12X1nUopGOCs46mfEzahO3aLTFkBxFyGw+MrPdp56Bzl/ZaHrlXVEY4zE7x/QSb3SO+L/lM69sNMQiqBTg/pVswf/unmBl6k= 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 1653865070776839.7327657452972; Sun, 29 May 2022 15:57:50 -0700 (PDT) Received: from localhost ([::1]:58968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRr3-0006dw-IW for importer@patchew.org; Sun, 29 May 2022 18:57:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlC-0006dd-Bz for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRl9-00029b-IR for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:45 -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-578-Drb7YqsEODm-OvCwOGKaEw-1; Sun, 29 May 2022 18:51:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 97135101A54E; Sun, 29 May 2022 22:51:40 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E9C217452; Sun, 29 May 2022 22:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864702; 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=iNVQZFhasoB5bTGJiRo7AOywqvQUQPhXCCSykSaAp4c=; b=P9spU/Ow8srhFXFhV+vHsOPt6kc24QfSwHPugz3ITSafqg+pXzIcm6NOPJv1UBaRBYGBEs xCuJUS+8IB4hPXszS7D+G5wxAxpteYsih1CCXsHvdSe6hP5PqkHfDj+/GK3yAfgyGxa7Qc uQCy7BwFohkuAK/U54yDn71Fa90fkpQ= X-MC-Unique: Drb7YqsEODm-OvCwOGKaEw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 01/15] include: move qemu_*_exec_dir() to cutils Date: Mon, 30 May 2022 00:51:23 +0200 Message-Id: <20220529225137.232359-2-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.79 on 10.11.54.5 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865071914100001 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 Reviewed-by: Markus Armbruster Message-Id: <20220525144140.591926-2-marcandre.lureau@redhat.com> --- 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 | 117 +++++++++++++++++++++++++++ util/oslib-posix.c | 86 +------------------- util/oslib-win32.c | 36 --------- 8 files changed, 129 insertions(+), 128 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 5c6572d444..40e10e19a7 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 a72e99db85..b1c161c035 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 d70d3dd4fd..2bd7bfb650 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 9b8b17f52e..c104817cdd 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 a7a5e14fa3..0ad4ba9e94 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 b2777210e7..a58bcfd80e 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -26,6 +26,15 @@ #include "qemu/host-utils.h" #include =20 +#ifdef __FreeBSD__ +#include +#include +#endif + +#ifdef __NetBSD__ +#include +#endif + #include "qemu/ctype.h" #include "qemu/cutils.h" #include "qemu/error-report.h" @@ -931,6 +940,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 477990f39b..7a34c1657c 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -48,14 +48,13 @@ #endif =20 #ifdef __FreeBSD__ -#include -#include #include +#include +#include #include #endif =20 #ifdef __NetBSD__ -#include #include #endif =20 @@ -283,87 +282,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 dafef4f157..6c818749d2 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.1 From nobody Sun May 12 22:09:26 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=1653864892; cv=none; d=zohomail.com; s=zohoarc; b=HYqph9tHN6aoZqMC/bIUMKY6Mc9J1OEHbaPKc2ZivvCK7zbCsD7K+00B5OpdKEmtMC9Q29Pp4JLCeh8eV0RljnCB1mn7f8ET1NcEMJ+JNcCYnuEXj+B2Ulfm7W4WvBwUV7dq9akUAipDcF/ryqVtxJP6GlvPkyNZbp8v9vB9AJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653864892; 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=vlbQY2O8t7JpFemon4zyJ5WJfd8gRb4PMEZAajAZ1zM=; b=QWaewPn/4TIqYrzC5cq5XHCbgjYVvLHWWzRU61ArWJnDu8v/LiHwYxAZfC2AqTALv4uvqfANXx49u2PNYNcCBbQ4cBstOi9Nwqi06w/4F4lxIgVvc0YsqJ62xhvC0uOQk4kGcdIRW7EI28fvIvoouVoGLm/KBFFrqAmTU6hmgzo= 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 1653864892673661.5585085506272; Sun, 29 May 2022 15:54:52 -0700 (PDT) Received: from localhost ([::1]:50616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRoA-00011a-JH for importer@patchew.org; Sun, 29 May 2022 18:54:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlG-0006et-Pz for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlC-00029p-Ip for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:48 -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-597-lLNdSZSrNVec2UCqUaiXRg-1; Sun, 29 May 2022 18:51: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 1395829AA3BF; Sun, 29 May 2022 22:51:42 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id B061C40F06B; Sun, 29 May 2022 22:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864705; 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=vlbQY2O8t7JpFemon4zyJ5WJfd8gRb4PMEZAajAZ1zM=; b=V6K48JudbUcsBG/wBqJVCqW3BDn6HexSSRx3Xf3QvV9wLt246ccOp5kTtcnJifOtb3xACw nK+lvLY8vgisBOcR8/dKUgat9xqxGfLWuZKkI4ChulWjkHtqYijIz8+gpmlTqqufgzivjb PPguFxxvqrlyWwDwYbrrWum36PpyIpE= X-MC-Unique: lLNdSZSrNVec2UCqUaiXRg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 02/15] util/win32: simplify qemu_get_local_state_dir() Date: Mon, 30 May 2022 00:51:24 +0200 Message-Id: <20220529225137.232359-3-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653864893402100001 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 Message-Id: <20220525144140.591926-3-marcandre.lureau@redhat.com> --- 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 6c818749d2..5723d3eb4c 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.1 From nobody Sun May 12 22:09:26 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=1653864893; cv=none; d=zohomail.com; s=zohoarc; b=T2lqkWE6r0MIoKQY4BDDzTMBVvFoM4avl8qJwESKu4aJ+SlYn7DfWxkP1pPcxta+wfz9FVLWt054n12OL5i1Gwy8afyxMUGJw5tmPpUKQ9I1KaPNV0INm/6UW0VcQQsRterKlN5wQBSS45APbf7psAe3RaceB+2j6Nq6QdI53Us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653864893; 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=8H6zuIE2egFMsrCZQdzyyYMVCVg5xyLLQ8xu1FmSUtc=; b=eWFUORBDaB7sz7wWJjTC+JsAegYkUaHFpSDH/EleJe7hgRNlx9A35Il4rwJ0mXsdhWbP2q7sK1XsOPDudICH2dFwi9dcsqXXb2GhC/gc2f0as8mxlaIOyCwSO2ZKwlyPP4denzm2lhMC1c8nDOTdYoYqGpKw7J0l2Xtz1tqNlFQ= 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 1653864893724186.45257632300775; Sun, 29 May 2022 15:54:53 -0700 (PDT) Received: from localhost ([::1]:50608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRoC-00011H-3F for importer@patchew.org; Sun, 29 May 2022 18:54:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlF-0006fM-Su for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55147) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlE-00029z-9c for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:49 -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-320-SLNwj3uHNhi9pCHm-uNTzw-1; Sun, 29 May 2022 18:51:44 -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 6F9C23C025B9; Sun, 29 May 2022 22:51:43 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19D2A40CF8F0; Sun, 29 May 2022 22:51:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864707; 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=8H6zuIE2egFMsrCZQdzyyYMVCVg5xyLLQ8xu1FmSUtc=; b=dUVRW7F/M1yg0hY0SlZw2Dm2Tr5MKg2EhhhmH+QZXjFLo6fLBXimp5VeQon4kYKEV/nXPA vMW3uL2xSnQInO+i9WN2NMN34OKpGm+hO0+UDQ/mrZiGkeAVx1IQHz1bRxsuYxI217u57n ZBO+npMRkfFd1z8QH5RclBwg57Kg8qU= X-MC-Unique: SLNwj3uHNhi9pCHm-uNTzw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 03/15] tests: make libqmp buildable for win32 Date: Mon, 30 May 2022 00:51:25 +0200 Message-Id: <20220529225137.232359-4-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653864895259100003 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth Message-Id: <20220525144140.591926-4-marcandre.lureau@redhat.com> --- tests/qtest/libqmp.h | 2 ++ tests/qtest/libqmp.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/tests/qtest/libqmp.h b/tests/qtest/libqmp.h index 5cb7eeaa18..3445b753ff 100644 --- a/tests/qtest/libqmp.h +++ b/tests/qtest/libqmp.h @@ -21,8 +21,10 @@ #include "qapi/qmp/qdict.h" =20 QDict *qmp_fd_receive(int fd); +#ifndef _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 0358b8313d..ade26c15f0 100644 --- a/tests/qtest/libqmp.c +++ b/tests/qtest/libqmp.c @@ -18,6 +18,11 @@ =20 #include "libqmp.h" =20 +#ifndef _WIN32 +#include +#endif + +#include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/qjson.h" @@ -87,6 +92,7 @@ QDict *qmp_fd_receive(int fd) return qmp.response; } =20 +#ifndef _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 +126,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 _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 +160,14 @@ void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_nu= m, if (log) { fprintf(stderr, "%s", str->str); } + +#ifndef _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 +176,23 @@ void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_nu= m, } } =20 +#ifndef _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.1 From nobody Sun May 12 22:09:26 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=1653865072; cv=none; d=zohomail.com; s=zohoarc; b=F0WS4IOea1101oixNZusXg9LHAHw7kEsltH0zI4FzSRmd65pc8i+625wUAu1UhXMmKR/WfyMdDHa6DAzgInVV/1iytXxqpJlC4Ze0ZmcoNPQ5snrQSA89nUrbNKWSJyJnwyXiZAjlMYscy3AVuyQ4NvUUu7AMScPQ300XmlxCdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865072; 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=4uyhUYzrFnjDWT+g5z6mgIJ9V99c4/wOyIMSSH4rRj0=; b=k1By3xJ5lGJwt4JdWIhY7TCHHH7LyzdGvRYH0ilvuoH1iRb5LRhsBkIGHN5nHfW19TU2G4xnvuPIMS5Rva9UMKGRXjLWZXkklt1sQux9qLgmCRajPFP26/Sc6KJP/eloa6hD0d2xrXSFBZL+kk/03QQ1O7hg662ayXNzy8Vz+wY= 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 1653865072553992.0565369189667; Sun, 29 May 2022 15:57:52 -0700 (PDT) Received: from localhost ([::1]:59078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRr5-0006iA-Hr for importer@patchew.org; Sun, 29 May 2022 18:57:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlH-0006fn-PQ for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlG-0002A9-23 for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:51 -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-473-RJHIvN7VP6yY9_BSElyTxQ-1; Sun, 29 May 2022 18:51:45 -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 DB29D811E81; Sun, 29 May 2022 22:51:44 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D34D40E80E0; Sun, 29 May 2022 22:51:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864709; 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=4uyhUYzrFnjDWT+g5z6mgIJ9V99c4/wOyIMSSH4rRj0=; b=hhqyOQSHpmDc3Cjt364F8Y7Y+HBqEj/xlQiBQAm4XTdvPtmomPkhpNPXb5HEzBN1PkjsjN YXWU+CfOz0QIhZ/B3pKpgejfiUER7flmW6OnykaSxwsmBZj7/wUrD+4bJE8wtJemWRX+wq pXoxI+F9BbJY0LxhO+4nLK7LnoXQeiA= X-MC-Unique: RJHIvN7VP6yY9_BSElyTxQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 04/15] qga: flatten safe_open_or_create() Date: Mon, 30 May 2022 00:51:26 +0200 Message-Id: <20220529225137.232359-5-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865073941100004 From: Marc-Andr=C3=A9 Lureau There is a bit too much nesting in the function, this can be simplified a bit to improve readability. This also helps with the following error handling changes. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Message-Id: <20220525144140.591926-5-marcandre.lureau@redhat.com> --- qga/commands-posix.c | 120 +++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 12b50b7124..3b2392398e 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -339,73 +339,73 @@ 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; + int fd =3D -1; + FILE *f =3D NULL; + + oflag =3D find_open_flag(mode, errp); + if (oflag < 0) { + 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 - oflag =3D find_open_flag(mode, &local_err); - if (local_err =3D=3D NULL) { - int fd; - - /* 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 wi= th " + "file descriptor %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.1 From nobody Sun May 12 22:09:26 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=1653865072; cv=none; d=zohomail.com; s=zohoarc; b=bL6IXRpnpFYBCKGLvcH3bnH2QsTvI0BquHSuga4xPDuV7vx7Tg7qrTLgVW2wEKr4C3GO5c6/gzT2tIq8o9B2MdhMeIwTSiPyh+5lt9y6toID6fP2KKz87Y84eJ91cC6NgFixw1/Yc0yNnGnhxAUWPPWhJhRyMnK7EwpyRiYq26o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865072; 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=kN3ay+S3h6CIL6xhz9CuNTjuCLbno+a3SZ4JjGmFXiw=; b=PAkhtD2PNbXW/k7S1t2/EH0nQFtg/wo8+wbEXyYOfdFdmTztsq1Mb+PIWDgYSpKm/aO9ZiNoUkvJkvMU7d6ppT8XfhuNUNR3s+T010KVf1hd1ogVwh2kgpQ2RARX5mmTkddlg4iri4Sw7L1Q0rjUpLyS0sgzvNbUbU+9B3NOwFA= 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 1653865072773797.1187212725279; Sun, 29 May 2022 15:57:52 -0700 (PDT) Received: from localhost ([::1]:59174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRr5-0006mD-PX for importer@patchew.org; Sun, 29 May 2022 18:57:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlH-0006fo-Sg for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlG-0002AH-BP for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:51 -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-509-1SH9VIMiPI6W-2IpBdny4g-1; Sun, 29 May 2022 18:51:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2013D811E75; Sun, 29 May 2022 22:51:46 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3C001678F; Sun, 29 May 2022 22:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864709; 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=kN3ay+S3h6CIL6xhz9CuNTjuCLbno+a3SZ4JjGmFXiw=; b=XfYfyT0JJmJOLhMaEYm07u4CKxoLra5lQbwil4PKV3Y9FLpkpQiJBdX1X/Dd98qW5Z9qC5 guNVxIdcIB2Y+Cn8vTivNr70bamW3f1X9uprN5Ti1TeOrDZcTW1BKgSY76gRXbb0EcjAUu JaKteI1iRYL6jSSOgDB8yAfbaic7nRE= X-MC-Unique: 1SH9VIMiPI6W-2IpBdny4g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 05/15] qga: add qga_open_cloexec() helper Date: Mon, 30 May 2022 00:51:27 +0200 Message-Id: <20220529225137.232359-6-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.79 on 10.11.54.5 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865073926100003 From: Marc-Andr=C3=A9 Lureau QGA calls qemu_open_old() in various places. Calling qemu_open() instead isn't a great alternative, as it has special "/dev/fdset" handling and depends on QEMU internal monitor data structures. Instead, provide a simple helper for QGA needs, with Error* support. The following patches will make use of it. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Message-Id: <20220525144140.591926-6-marcandre.lureau@redhat.com> --- qga/cutils.h | 8 ++++++++ qga/cutils.c | 33 +++++++++++++++++++++++++++++++++ qga/meson.build | 1 + 3 files changed, 42 insertions(+) create mode 100644 qga/cutils.h create mode 100644 qga/cutils.c diff --git a/qga/cutils.h b/qga/cutils.h new file mode 100644 index 0000000000..f0f30a7d28 --- /dev/null +++ b/qga/cutils.h @@ -0,0 +1,8 @@ +#ifndef CUTILS_H_ +#define CUTILS_H_ + +#include "qemu/osdep.h" + +int qga_open_cloexec(const char *name, int flags, mode_t mode); + +#endif /* CUTILS_H_ */ diff --git a/qga/cutils.c b/qga/cutils.c new file mode 100644 index 0000000000..b8e142ef64 --- /dev/null +++ b/qga/cutils.c @@ -0,0 +1,33 @@ +/* + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include "cutils.h" + +#include "qapi/error.h" + +/** + * qga_open_cloexec: + * @name: the pathname to open + * @flags: as in open() + * @mode: as in open() + * + * A wrapper for open() function which sets O_CLOEXEC. + * + * On error, -1 is returned. + */ +int qga_open_cloexec(const char *name, int flags, mode_t mode) +{ + int ret; + +#ifdef O_CLOEXEC + ret =3D open(name, flags | O_CLOEXEC, mode); +#else + ret =3D open(name, flags, mode); + if (ret >=3D 0) { + qemu_set_cloexec(ret); + } +#endif + + return ret; +} diff --git a/qga/meson.build b/qga/meson.build index 6d9f39bb32..35fe2229e9 100644 --- a/qga/meson.build +++ b/qga/meson.build @@ -65,6 +65,7 @@ qga_ss.add(files( 'commands.c', 'guest-agent-command-state.c', 'main.c', + 'cutils.c', )) qga_ss.add(when: 'CONFIG_POSIX', if_true: files( 'channel-posix.c', --=20 2.36.1 From nobody Sun May 12 22:09:26 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=1653864887; cv=none; d=zohomail.com; s=zohoarc; b=jbqdgP9MMqKW6wzhz8E20kYxR2m9Gk7fMsfxVQSWivBSrT06ODYMKhJKhGMqw4UKiJFVDRpqEux4R+kMZXC+QSHq3vEhcAibYssbi3LyVWBrMn5GLNhBMaLxumvoDhdztxtzVnOWSkXHFWNW5ZoKw5gTKxAnhbGLooLsw3oeKic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653864887; 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=AoC3af8qVDab0GoHo/bFL4H4GUuWAWqp9w2CRC6bztY=; b=NiDnhw88FftKIfiRFwO914g7VcQ5fvVdXDvl6BU0+y++E6+sdPW1oaY5EH29bApYOIVK3knZMZVeisvlnqLq/54uDTzATzR2FGsUAvKe6magPoUKH3gJ5nvGqn7GXG7rCQB7Jm/+0GVvXxlesCWt3nSdhmWMapKULiZxm8n1Wfs= 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 1653864887515808.977157002418; Sun, 29 May 2022 15:54:47 -0700 (PDT) Received: from localhost ([::1]:50524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRo5-0000yI-Rb for importer@patchew.org; Sun, 29 May 2022 18:54:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlJ-0006gl-1N for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29380) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlH-0002AM-IX for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51: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-530-zRdVT4dePqmLTAnQlqahjw-1; Sun, 29 May 2022 18:51:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 728F129AA3BC; Sun, 29 May 2022 22:51:47 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 143991121314; Sun, 29 May 2022 22:51:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864711; 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=AoC3af8qVDab0GoHo/bFL4H4GUuWAWqp9w2CRC6bztY=; b=gIobO0mR4SvsBszlqC8ISDiWy3xXhpg0m55EbSJ662Xwli1C+SOV0Q5WLSMDFqvTJbi8a3 ppkxsGlJ7dE0mzg4zuHrYenvny+dv/QVN31kmBkoDBQeC1FI6ejogE3f1GyN56Dxlsh8F6 iknm/Zod0J1dy2iIm0vldABPE/U/4Xs= X-MC-Unique: zRdVT4dePqmLTAnQlqahjw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 06/15] qga: use qga_open_cloexec() for safe_open_or_create() Date: Mon, 30 May 2022 00:51:28 +0200 Message-Id: <20220529225137.232359-7-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.78 on 10.11.54.3 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653864889532100003 From: Marc-Andr=C3=A9 Lureau The function takes care of setting CLOEXEC. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Message-Id: <20220525144140.591926-7-marcandre.lureau@redhat.com> --- qga/commands-posix.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 3b2392398e..2ecc43eca9 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -27,6 +27,7 @@ #include "qemu/cutils.h" #include "commands-common.h" #include "block/nvme.h" +#include "cutils.h" =20 #ifdef HAVE_UTMPX #include @@ -370,10 +371,10 @@ 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 qga_open_cloexec(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); + fd =3D qga_open_cloexec(path, oflag, 0); } if (fd =3D=3D -1) { error_setg_errno(errp, errno, @@ -382,8 +383,6 @@ safe_open_or_create(const char *path, const char *mode,= Error **errp) 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.1 From nobody Sun May 12 22:09:26 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=1653865200; cv=none; d=zohomail.com; s=zohoarc; b=cGFZGyElyWqvAKf2hLbVdN4CK/KXY8XcUtJF6VfpX3CxKKmwk07RXjAYwH2BmFR1exeZwDUI/ch/m5PlMlG/SVKLiQ8gfB5PGW0KrF1KR+CtgpvZt0MSR0KEnGzzUM8y4bVY6NZp/ZtCLIl/2y6pLE/kJ44ebGbgPYIIT/aXXI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865200; 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=zJqvlHZtYqvmx2A4UG8C1PCua0Uft5zi0vuUa2hnsIY=; b=ehpYv26gdkXBsHop18s3TtHB17NKSahQU/rcpaXX/rhBuiFFiwTJ2WFr9MbfbEfEAcIX9Pk3zwEuqw/ZkH8NnGS/W3F7NG07pAJ+mZfJsEzDtPlaqwjrcceoPALxTHAOeRqUMX29PlIdCw1YCCjj0WnrtoognafMJDaX+t6s/x4= 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 1653865200677306.0506060098737; Sun, 29 May 2022 16:00:00 -0700 (PDT) Received: from localhost ([::1]:39378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRt9-0003w5-6v for importer@patchew.org; Sun, 29 May 2022 18:59:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlK-0006iK-DS for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54229) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlI-0002Ad-O4 for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:54 -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-414-Bd7HZea6MlmOvTfQbale9A-1; Sun, 29 May 2022 18:51:49 -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 D6536858EEE; Sun, 29 May 2022 22:51:48 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AEFD40E80E0; Sun, 29 May 2022 22:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864712; 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=zJqvlHZtYqvmx2A4UG8C1PCua0Uft5zi0vuUa2hnsIY=; b=KkX3suRwxG02i+yHMBAYR/UOvFAaxSnl+xWP3Ioy6C+mkAiv/1sqZgF0g7OUL4zdQxqtLn YCTAjteMNlWK4YyeKWkMo9q6J7/2rg20T0x9A/JY6EJd5HFhnhX915UXjSbNRdayhJjvVG 8ZmXIrIG35PXP6toLSqW96VsPNLi6WE= X-MC-Unique: Bd7HZea6MlmOvTfQbale9A-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 07/15] qga: throw an Error in ga_channel_open() Date: Mon, 30 May 2022 00:51:29 +0200 Message-Id: <20220529225137.232359-8-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865202589100001 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 Reviewed-by: Markus Armbruster Message-Id: <20220525144140.591926-8-marcandre.lureau@redhat.com> --- 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 a996858e24..25fcc5cb1a 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -119,7 +119,7 @@ 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) { int ret; c->method =3D method; @@ -133,21 +133,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 +158,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 +179,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 +187,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 +197,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 (!addr) { 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 (fd < 0) { return false; } } @@ -227,7 +217,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 +262,14 @@ 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)) { + g_critical("%s", error_get_pretty(err)); + error_free(err); ga_channel_free(c); return NULL; } --=20 2.36.1 From nobody Sun May 12 22:09:26 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=1653865368; cv=none; d=zohomail.com; s=zohoarc; b=fUn4JPIpF/nUMOAOBpHDOEomi79BBy6gqlcQ63yjFo6sFIpLL+mfVVDk8CY/XU3dHzSQMPMszvRTNaVA/aSwzyeTICsZCSgoqXXNabrUUoWMiJ9pFWNcapmt4jCaFhrmaPHVz1fV87h6sUehyPBZFDY/tlemNM5wPqT0PhFtk48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865368; 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=3pMrhehUASX5vta19nQ9AuSJLJ81Nu2JOoMvD0sI/6c=; b=QjI7XFKaHNjsbSQvKNfdwnUNrKa8LduCpSSxFuBh7pZBIc4Shh0/AqEXvhWNvm2GtYg9Hc3AK2/x0GsmOU3RmlkkL0JapRoEUdyVBN56PnOV+W2Av13xO/J1t6FneJ0mut0FUosKo8GvNEMZFYt0bfIfqdy8LYfj9O0zpbpOOSM= 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 1653865368397612.4031983678018; Sun, 29 May 2022 16:02:48 -0700 (PDT) Received: from localhost ([::1]:46892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRvr-0000c9-CR for importer@patchew.org; Sun, 29 May 2022 19:02:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlM-0006jv-QI for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlL-0002As-87 for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:56 -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-665-TvriyHgEPda2avVHbJTrqA-1; Sun, 29 May 2022 18:51:51 -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 13CF3185A79C; Sun, 29 May 2022 22:51:51 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38050400F75F; Sun, 29 May 2022 22:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864714; 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=3pMrhehUASX5vta19nQ9AuSJLJ81Nu2JOoMvD0sI/6c=; b=MbkywSqcm3dR3eq3sOQKBSy7aaR9Hu3hhQY3ePD7nP0Gx9Vh6Uifvmyo90NjKex2cm3a85 Y4jgeavkgSw5Lr/fqqj5sjbT8pT30cE429L+jH6iSs/TD7CUsL3e627YJfAsA4ew8gSRKu QsRfaA9ODHEMxLH0irEWYB8R6ADHTxk= X-MC-Unique: TvriyHgEPda2avVHbJTrqA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 08/15] qga: replace qemu_open_old() with qga_open_cloexec() Date: Mon, 30 May 2022 00:51:30 +0200 Message-Id: <20220529225137.232359-9-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865369388100001 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 qga_open_cloexec() instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk Message-Id: <20220525144140.591926-9-marcandre.lureau@redhat.com> --- qga/channel-posix.c | 13 +++++++++---- qga/commands-posix.c | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 25fcc5cb1a..6796a02cff 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -1,8 +1,10 @@ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include #include "qapi/error.h" #include "qemu/sockets.h" #include "channel.h" +#include "cutils.h" =20 #ifdef CONFIG_SOLARIS #include @@ -127,11 +129,14 @@ 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 qga_open_cloexec( + path, #ifndef CONFIG_SOLARIS - | O_ASYNC + O_ASYNC | #endif - ); + O_RDWR | O_NONBLOCK, + 0 + ); if (fd =3D=3D -1) { error_setg_errno(errp, errno, "error opening channel"); return false; @@ -156,7 +161,7 @@ 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 qga_open_cloexec(path, O_RDWR | O_NOCTTY | O_NONBLOCK, 0); if (fd =3D=3D -1) { error_setg_errno(errp, errno, "error opening channel"); return false; diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 2ecc43eca9..0047245273 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1406,7 +1406,7 @@ static void get_nvme_smart(GuestDiskInfo *disk) | (((sizeof(log) >> 2) - 1) << 16) }; =20 - fd =3D qemu_open_old(disk->name, O_RDONLY); + fd =3D qga_open_cloexec(disk->name, O_RDONLY, 0); if (fd =3D=3D -1) { g_debug("Failed to open device: %s: %s", disk->name, g_strerror(er= rno)); return; @@ -1739,7 +1739,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mount= points, } } =20 - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qga_open_cloexec(mount->dirname, O_RDONLY, 0); if (fd =3D=3D -1) { error_setg_errno(errp, errno, "failed to open %s", mount->dirn= ame); goto error; @@ -1806,7 +1806,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 qga_open_cloexec(mount->dirname, O_RDONLY, 0); if (fd =3D=3D -1) { continue; } @@ -1892,7 +1892,7 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, E= rror **errp) =20 QAPI_LIST_PREPEND(response->paths, result); =20 - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qga_open_cloexec(mount->dirname, O_RDONLY, 0); if (fd =3D=3D -1) { result->error =3D g_strdup_printf("failed to open: %s", strerror(errno)); --=20 2.36.1 From nobody Sun May 12 22:09:26 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=1653865200; cv=none; d=zohomail.com; s=zohoarc; b=TIh2eQP7Ll/BbPkLSoZbUkN0W3WEnijGEx+4USRpvWe87EqJ6LaVdsK4KT3a4Q0ArpvyTx+SNiYRTPzJYN+EqZPpvlvu0rwDvH3+xl0sx9RykXJjvlrSVwcl3x+885MOBlYAjAoLMvq/Q+PHWw/a/ExBZ5jAHKgb/A9fdjB0sUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865200; 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=HBwIT9fmddq63wRURIcvgJBCvqN9PGym0LzbWCUIu/8=; b=Whb7EWvyP6Lq8sK/UcZOg8/tUAYSDSZ/S1Y/VX7JNV1SQWO+6gZ/L+QASiUjfMolMfFIFwOxpHfOJx1QMZEAd1K29HgaAUQKQvTrLZ6akDiliv04G4QruVjDeNt+2IYWF55XtDmlYtdcMXBobpA2OZ+/K77qXHVX4eVR/X7VE9c= 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 1653865200627224.55116611335256; Sun, 29 May 2022 16:00:00 -0700 (PDT) Received: from localhost ([::1]:39410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRt9-0003xN-2W for importer@patchew.org; Sun, 29 May 2022 18:59:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlQ-0006no-1W for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlN-0002B1-5K for qemu-devel@nongnu.org; Sun, 29 May 2022 18:51:59 -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-451-AznhESd1Pfq2FXjH-IqJDg-1; Sun, 29 May 2022 18:51:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E8D49101A54E; Sun, 29 May 2022 22:51:52 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6559D2166B26; Sun, 29 May 2022 22:51:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864716; 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=HBwIT9fmddq63wRURIcvgJBCvqN9PGym0LzbWCUIu/8=; b=DwRcgWZ/cJpKR+InD8jATW3xiOh7m6beU8UQXWrmUOYDLTImMnDh0OwrigTIeza0/b+HWV zHG5wP90d+BQY35HGG86FW1kXaSF3nli4oopOBJjanux4tpUtzABQZ49TKCUtrNmB/CqZM Ow8bT50gOuoogRPqew36/rdjuWQj4HU= X-MC-Unique: AznhESd1Pfq2FXjH-IqJDg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 09/15] qga: make build_fs_mount_list() return a bool Date: Mon, 30 May 2022 00:51:31 +0200 Message-Id: <20220529225137.232359-10-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.78 on 10.11.54.6 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865202602100002 From: Marc-Andr=C3=A9 Lureau Change build_fs_mount_list() to return bool, in accordance with the guidance under =3D Rules =3D in include/qapi/error.h Signed-off-by: Marc-Andr=C3=A9 Lureau Suggested-by: Markus Armbruster Message-Id: <20220525144140.591926-10-marcandre.lureau@redhat.com> --- qga/commands-posix.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 0047245273..0469dc409d 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -673,7 +673,7 @@ static int dev_major_minor(const char *devpath, /* * Walk the mount table and build a list of local file systems */ -static void build_fs_mount_list_from_mtab(FsMountList *mounts, Error **err= p) +static bool build_fs_mount_list_from_mtab(FsMountList *mounts, Error **err= p) { struct mntent *ment; FsMount *mount; @@ -684,7 +684,7 @@ static void build_fs_mount_list_from_mtab(FsMountList *= mounts, Error **errp) fp =3D setmntent(mtab, "r"); if (!fp) { error_setg(errp, "failed to open mtab file: '%s'", mtab); - return; + return false; } =20 while ((ment =3D getmntent(fp))) { @@ -714,6 +714,7 @@ static void build_fs_mount_list_from_mtab(FsMountList *= mounts, Error **errp) } =20 endmntent(fp); + return true; } =20 static void decode_mntname(char *name, int len) @@ -738,7 +739,7 @@ static void decode_mntname(char *name, int len) } } =20 -static void build_fs_mount_list(FsMountList *mounts, Error **errp) +static bool build_fs_mount_list(FsMountList *mounts, Error **errp) { FsMount *mount; char const *mountinfo =3D "/proc/self/mountinfo"; @@ -751,8 +752,7 @@ static void build_fs_mount_list(FsMountList *mounts, Er= ror **errp) =20 fp =3D fopen(mountinfo, "r"); if (!fp) { - build_fs_mount_list_from_mtab(mounts, errp); - return; + return build_fs_mount_list_from_mtab(mounts, errp); } =20 while (getline(&line, &n, fp) !=3D -1) { @@ -794,6 +794,7 @@ static void build_fs_mount_list(FsMountList *mounts, Er= ror **errp) free(line); =20 fclose(fp); + return true; } #endif =20 @@ -1592,8 +1593,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error *= *errp) Error *local_err =3D NULL; =20 QTAILQ_INIT(&mounts); - build_fs_mount_list(&mounts, &local_err); - if (local_err) { + if (!build_fs_mount_list(&mounts, &local_err)) { error_propagate(errp, local_err); return NULL; } @@ -1716,8 +1716,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mount= points, } =20 QTAILQ_INIT(&mounts); - build_fs_mount_list(&mounts, &local_err); - if (local_err) { + if (!build_fs_mount_list(&mounts, &local_err)) { error_propagate(errp, local_err); return -1; } @@ -1798,8 +1797,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp) Error *local_err =3D NULL; =20 QTAILQ_INIT(&mounts); - build_fs_mount_list(&mounts, &local_err); - if (local_err) { + if (!build_fs_mount_list(&mounts, &local_err)) { error_propagate(errp, local_err); return 0; } @@ -1872,15 +1870,12 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum,= Error **errp) 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); + if (!build_fs_mount_list(&mounts, errp)) { return NULL; } =20 --=20 2.36.1 From nobody Sun May 12 22:09:26 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=1653865300; cv=none; d=zohomail.com; s=zohoarc; b=dKpHYyO3Cm88XWnkVL2TkdKXxrtvs1ZIvEhqnbQo+It5f3T5dl73nJ7EDFQWE/MTTiwXtwsYB2wYCcInxMI4fMDTSdripddjT1EkEcZHAsc/ShUGrLtJq+bvXgDpfyMUM2kzUv5vStMuwrNsQXRCYffW7D9JEdx0DW3lCmhpJNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865300; 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=u0DbRGMr63goT3DSBSa6lrHxSumvKxGwUlDqjMNCLcg=; b=Jzfv54zckSWlRJKsqVNLSrazi1JiKEzeJK4/XgXs4LdW0rBuirptWL2XSymsHJUwV9Wun9QmFm+r/0TSupFhHlx1W6xt2wLifMPLTogPotKFWz8gSQj9tS1+hkjz78rSmZMPk+DpZFKYvR2CxO9ettamOCf05EL1nHbs58ol7Rg= 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 1653865300946540.1760844009051; Sun, 29 May 2022 16:01:40 -0700 (PDT) Received: from localhost ([::1]:42494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRul-0005zZ-VX for importer@patchew.org; Sun, 29 May 2022 19:01:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlU-0006t8-E2 for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlS-0002Bc-2r for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:04 -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-582-26_ddzLoP8WoujOUO5jvrg-1; Sun, 29 May 2022 18:51:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56BE9101A54E; Sun, 29 May 2022 22:51:54 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06B102166B26; Sun, 29 May 2022 22:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864721; 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=u0DbRGMr63goT3DSBSa6lrHxSumvKxGwUlDqjMNCLcg=; b=Vb0/xAwk2RqbY0mxGe+sezASX6bODFTSAstiqYNUmBsEeSL1DDvR7TngIKo16EynSJ/e+M zJY6K9gyheXdC72mIK08jwkRMFJUaXCwhLJoXuJ5s3dq+h0tRurU0VegXomDRdTG1wrw5y fMnsJ6RxDLMPUSIGzxitMKJJPba7KdY= X-MC-Unique: 26_ddzLoP8WoujOUO5jvrg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 10/15] test/qga: use G_TEST_DIR to locate os-release test file Date: Mon, 30 May 2022 00:51:32 +0200 Message-Id: <20220529225137.232359-11-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.78 on 10.11.54.6 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865302977100001 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 Reviewed-by: Konstantin Kostiuk Message-Id: <20220525144140.591926-11-marcandre.lureau@redhat.com> --- 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 d6df1ee92e..ab0b12a2dd 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.1 From nobody Sun May 12 22:09:26 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=1653865075; cv=none; d=zohomail.com; s=zohoarc; b=fYspD4pCnJY9u7/e5t7T0ALN+iMvQ8SVX4yD3+QrIiP4gHGNjUmWksfwy5pQAe/y/Fe83F9SI6yqb0cnYBrZBaYmo7qG2u74EHCJ8Z8Fdo/aaUFfiWhqQV3IaD/hN5/+s20eNDXNVqKx0FAMPSprZ9frw+7k7MjBg81OX4JZ428= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865075; 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=btAxxeHduh0Mjnmox07iuGxkVXgoLqF23HMxYRmZ/m0=; b=kOsrBlZ6AW+wi2hVX0H7K5F6C1mpaBrawFf55CIyQVqJ9vkqbAK3Zt3BJ82IFG0AhvNRRjfmIoEKuzuqk8I0p/pZKmrYqqsbEAkviVriOa+PizyFZhd7R9XYGgiaZAGVPVZrywCHjrAxz4oPNQ7eq7g/MJ9hHRj9/Dg2soEP62Y= 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 1653865075538616.6287482565253; Sun, 29 May 2022 15:57:55 -0700 (PDT) Received: from localhost ([::1]:59332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRr8-0006sL-I5 for importer@patchew.org; Sun, 29 May 2022 18:57:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlR-0006qZ-8g for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39287) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlP-0002BE-C5 for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:00 -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-112-GM8wx0nZMsGKKFWJ95-r0g-1; Sun, 29 May 2022 18:51:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 328B53C025B9; Sun, 29 May 2022 22:51:57 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0C9B2166B26; Sun, 29 May 2022 22:51:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864718; 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=btAxxeHduh0Mjnmox07iuGxkVXgoLqF23HMxYRmZ/m0=; b=MUbVFWWu/tUifD/X0BgkZ/lObMDmCnH18/eRiTZcLWmI+OYe6p7a2evCAGXqc7X/srwYuj eErOsRb4LVMDofo2LDhy8W/17yZ6hKHU453SbX8CIN0V2AkaS22Gzaooi/Equ6Q1X5wmfG QwbfjdiRQLvQpnSR4IMD0ol7uI8Yjvs= X-MC-Unique: GM8wx0nZMsGKKFWJ95-r0g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 11/15] qga/wixl: prefer variables over environment Date: Mon, 30 May 2022 00:51:33 +0200 Message-Id: <20220529225137.232359-12-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.78 on 10.11.54.6 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865075896100007 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 Message-Id: <20220525144140.591926-12-marcandre.lureau@redhat.com> --- 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 0950e8c6be..8a19aa1656 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 35fe2229e9..31370405f9 100644 --- a/qga/meson.build +++ b/qga/meson.build @@ -122,15 +122,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.1 From nobody Sun May 12 22:09:26 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=1653865461; cv=none; d=zohomail.com; s=zohoarc; b=Y7Qx/DzDvEzQVwdXpgnd+rWJkldmRvPrfTuKCYY8RL/qxCpySi5FMy4YD9BuahFWLAAohlsybe4KlXVnirixk6YmkaKTdliIr0Ri6QdESbk6q/amWMTWg2cyXWrM3p6f3qnFCEYC9n8cz09GytuSYsv30hSeSqFKOJ0cO6h15Ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865461; 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=Xo/YgDT7Dtg9tBXeh0aC/xzD0SY9Q7YYmGfa4881CLc=; b=QSrVKxR6RamFn+3h8vonaXdo33MWb1BmSxH8k32d7LJEBoYRiwq91SO1l+BBLxqIe5zYvFVKjbXFI8EyWtV+kxlf/+LYL3zzlfZ2A/+e6+qTvlXyIPURimFkRmnwMF3ciZzjDXyulMI0rI6Y6SBEdFB4VZgbdx3zrRghSKtwFMk= 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 1653865461218128.81205756227178; Sun, 29 May 2022 16:04:21 -0700 (PDT) Received: from localhost ([::1]:51122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRxM-0003Ra-8i for importer@patchew.org; Sun, 29 May 2022 19:04:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlT-0006s3-5W for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlR-0002BY-PJ for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:02 -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-518-HrEXb2viPO2ogpZO9ZvnnA-1; Sun, 29 May 2022 18:52:00 -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 B089D80418B; Sun, 29 May 2022 22:51:59 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 622D540E80E0; Sun, 29 May 2022 22:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864721; 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=Xo/YgDT7Dtg9tBXeh0aC/xzD0SY9Q7YYmGfa4881CLc=; b=dYQ38kv/pk/TLKdaFER8Qi2V2TQbC19SKTBCVe+vCRlwE/azkK0RVFgInnpEo50qgKBJ0G CM6jeioi61buhnsBegdkdGBwJZtU6Fldqchpss4io+P9o0jzJZ2AoaLJW7zM/C71OiydcD 0JVGP9+vTIGcbCoWedoP7nJu40ZuAkc= X-MC-Unique: HrEXb2viPO2ogpZO9ZvnnA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 12/15] qga/wixl: require Mingw_bin Date: Mon, 30 May 2022 00:51:34 +0200 Message-Id: <20220529225137.232359-13-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865461793100001 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 Message-Id: <20220525144140.591926-13-marcandre.lureau@redhat.com> --- 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 8a19aa1656..651db6e51c 100644 --- a/qga/installer/qemu-ga.wxs +++ b/qga/installer/qemu-ga.wxs @@ -4,15 +4,6 @@ =20 - - - - - - - - - --=20 2.36.1 From nobody Sun May 12 22:09:26 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=1653865207; cv=none; d=zohomail.com; s=zohoarc; b=ITKJCS35+A4OyLe0ej/Jbpey5gw4WEF2rYTKepiOvHE1GETmJGGXnh0S8XH4sih1f7NdAtvtnZvb/G3NAYtq+kIZj0DFmr1W5GOYLNPhKbr//9r2Jyind2RRjEQ/UIrO6iDjPOE0Vyt4jIVkWWL8OFowIdSbHlmMXnnyFWlSEu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653865207; 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=cGmqS90ikSsvVoQsSXjoby1IpMvvHrYoxBGo2U1opnI=; b=CfeO/Q9y27MMEShjAwxA7ZF9+OPUUreGR3TjRQT1mCellUmtyIkcdDOCAWfqxzy4ZTdq1JATqkVOBT4iMkDP1SvocMqCUw8Skx3J4bE0DZDg9Szcd+4DiAOiDcw24w4eFbzb7mLFCVqjs762hrsVy9WcaEaxBPj57zr2FcJebk0= 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 1653865207447798.2818778310768; Sun, 29 May 2022 16:00:07 -0700 (PDT) Received: from localhost ([::1]:39580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRtG-00045H-2b for importer@patchew.org; Sun, 29 May 2022 19:00:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlX-00073b-4C for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlV-0002CH-Hc for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:06 -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-520-vWcqmDt0NwuUoEFZ41jKtg-1; Sun, 29 May 2022 18:52:01 -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 4C16A29AA3BD; Sun, 29 May 2022 22:52:01 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE59040E80E0; Sun, 29 May 2022 22:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864725; 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=cGmqS90ikSsvVoQsSXjoby1IpMvvHrYoxBGo2U1opnI=; b=QLCW5+kzSLjz9B2Np2e8+Bs+Gai1oopLj+rRcx/rxvdCIRL894UqbbtL3UFKNfBdtGI57M R/AD6L46FpEu6lKTBzcZypbTMqoLVuUkFVrmcWPhNEyLYBe3NMh23+hVmO86XtACtmJ0Yt kZrBXGZSyR8lZzKQ+DC2jydikqfHEfY= X-MC-Unique: vWcqmDt0NwuUoEFZ41jKtg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 13/15] qga/wixl: simplify some pre-processing Date: Mon, 30 May 2022 00:51:35 +0200 Message-Id: <20220529225137.232359-14-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865208480100001 From: Marc-Andr=C3=A9 Lureau Sadly, wixl doesn't have 'elif'. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk Message-Id: <20220525144140.591926-14-marcandre.lureau@redhat.com> --- 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 651db6e51c..e5b0958e18 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 1653865370750519.4479722333903; Sun, 29 May 2022 16:02:50 -0700 (PDT) Received: from localhost ([::1]:46968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRvt-0000fH-Gm for importer@patchew.org; Sun, 29 May 2022 19:02:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRla-0007Bp-51 for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlY-0002Ch-7a for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52: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-213-l_K_Uom5NIyB_t3kvSE-2Q-1; Sun, 29 May 2022 18:52:04 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7140803B22; Sun, 29 May 2022 22:52:03 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55D0C2166B26; Sun, 29 May 2022 22:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864727; 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=8ShvTimvyNK05vkB8kbSeJ9lMAct8OkrAgdc2F16+0s=; b=HA+ossflA/yOTjhcMCzx/mnNDwkys4gZRXQQTgtvFfiaiOjfRN0ABCw1gliX55qFFHEa9v rHYjdfE0F5jubPV+W9SzaL+XMAczsWftJdH4/Za9ZZWW1GDZQJCoWGeOyld7tW75+Hij27 QwdN/5DE2eV/pyDEndlOVZ3OeSxCdXk= X-MC-Unique: l_K_Uom5NIyB_t3kvSE-2Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 14/15] qga/wixl: replace QEMU_GA_MSI_MINGW_BIN_PATH with glib bindir Date: Mon, 30 May 2022 00:51:36 +0200 Message-Id: <20220529225137.232359-15-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.78 on 10.11.54.6 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865371346100003 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 Message-Id: <20220525144140.591926-15-marcandre.lureau@redhat.com> --- 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 180ee688dc..f2baf2f526 100755 --- a/configure +++ b/configure @@ -1495,6 +1495,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 @@ -1860,8 +1865,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"; } && \ @@ -1948,7 +1951,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 @@ -2020,6 +2022,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 df7c34b076..bf318d9cbb 100644 --- a/meson.build +++ b/meson.build @@ -466,7 +466,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 e5b0958e18..813d1c6ca6 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 1653865461973730.8651371812239; Sun, 29 May 2022 16:04:21 -0700 (PDT) Received: from localhost ([::1]:51238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvRxM-0003WH-VW for importer@patchew.org; Sun, 29 May 2022 19:04:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRla-0007C9-9D for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvRlY-0002Cc-3E for qemu-devel@nongnu.org; Sun, 29 May 2022 18:52:09 -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-611-qGlai_FTMG68QQJsoHZLzw-1; Sun, 29 May 2022 18:52:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A617F1C0513F; Sun, 29 May 2022 22:52:05 +0000 (UTC) Received: from localhost (unknown [10.39.192.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A19D2026D64; Sun, 29 May 2022 22:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653864727; 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=J4AgK4+QLNtS4QScVyh2dG4giCX+VTt4UUUUP+4taZ8=; b=LQeolCJvSUwUEJ8YBQ8z+KVwbnA89Lntl1DDdp6/aaX2DPbfpr2SuZniuDumBpRugvOLLw SIOLA3/W9T2Xl9zX01uWbAK/wP4tYv9oAYa7CQWym2nyA6RPhdBRNHCQoosLiaO+jR9vyv t/Lv4RaSCy3TzVsseiCFGX77OOhiSZQ= X-MC-Unique: qGlai_FTMG68QQJsoHZLzw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 15/15] test/qga: use g_auto wherever sensible Date: Mon, 30 May 2022 00:51:37 +0200 Message-Id: <20220529225137.232359-16-marcandre.lureau@redhat.com> In-Reply-To: <20220529225137.232359-1-marcandre.lureau@redhat.com> References: <20220529225137.232359-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.78 on 10.11.54.4 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.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.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: 1653865463857100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk Message-Id: <20220525144140.591926-16-marcandre.lureau@redhat.com> --- tests/unit/test-qga.c | 121 +++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 78 deletions(-) diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index ab0b12a2dd..530317044b 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -52,7 +52,10 @@ 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_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) @@ -693,18 +667,22 @@ static void test_qga_blacklist(gconstpointer data) static void test_qga_config(gconstpointer data) { GError *error =3D NULL; - char *cwd, *cmd, *out, *err, *str, **strv, **argv =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.1