From nobody Sat Apr 20 11:04:20 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=1652465398; cv=none; d=zohomail.com; s=zohoarc; b=CgjcdFFRSNIf4ohJaOoQ28cIlGrZz3p21Yp2leAAMQYIxs4uPYpiRzZWBMKr1dLp76hCEHm+0XF8y1jpOu4wD5tdvLjA8EKWxLFS1VGhqAA5o3TZeKBNK+iSvfL8T67FqhhymuhyHjMOZIID4wuBT/oGmRLhQ/5DLqbVIkM3Se4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465398; 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=umFav0GnuOG9UGPI7l22HPWZ0Y4hDmcUiuMIut1Ebfk=; b=WiCJDK34LV9uTZKBFPF7WwkvVfPRR7/LWzZEK0s+kp49KzmXSOno/qNhdAHjW1wwUXcdDus9ZIeVzX4LPhpZ8c4GOegf81xFeLkZUHksk9Nz5bHHkac+tU+59FI66W7jVR+h7jd8kFZNqChP3QqDsmX+fepPVfQx/Ooqc0h1NlU= 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 1652465398430946.1621402139549; Fri, 13 May 2022 11:09:58 -0700 (PDT) Received: from localhost ([::1]:35108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZjh-0002kV-4e for importer@patchew.org; Fri, 13 May 2022 14:09:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiI-0000HJ-Ht for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiF-0006z4-9A for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:29 -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-205-ZJ57TcbiOlO75t-BzDxR_g-1; Fri, 13 May 2022 14:08:25 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C5CA93802B8B; Fri, 13 May 2022 18:08:24 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6826E43EA06; Fri, 13 May 2022 18:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465306; 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=umFav0GnuOG9UGPI7l22HPWZ0Y4hDmcUiuMIut1Ebfk=; b=GrRD8NZDltkComFrnnH9zPeOqQITPjfXg8yY5ojw82SeaOF/KqSbb23dn8KG52Z+Hq3noZ lehRrp0/MT1FbUHAPFKnBlTjfFivep0S/RqdPulqP36JDmytXG07DlNaTAEXxzeXJ+fVx7 JMORkh5CKvxH8PhB8RbYZG+/snhAgwA= X-MC-Unique: ZJ57TcbiOlO75t-BzDxR_g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 01/15] include: move qemu_*_exec_dir() to cutils Date: Fri, 13 May 2022 20:08:07 +0200 Message-Id: <20220513180821.905149-2-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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.9 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465399929100001 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 --- include/qemu/cutils.h | 7 ++ include/qemu/osdep.h | 8 -- qemu-io.c | 1 + storage-daemon/qemu-storage-daemon.c | 1 + tests/qtest/fuzz/fuzz.c | 1 + util/cutils.c | 108 +++++++++++++++++++++++++++ util/oslib-posix.c | 81 -------------------- util/oslib-win32.c | 36 --------- 8 files changed, 118 insertions(+), 125 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 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 1c1e7eca98..67cc465416 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..6cc7cc8cde 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -931,6 +931,114 @@ static inline const char *next_component(const char *= dir, int *p_len) return dir; } =20 +static const char *exec_dir; + +void qemu_init_exec_dir(const char *argv0) +{ +#ifdef G_OS_WIN32 + char *p; + char buf[MAX_PATH]; + DWORD len; + + if (exec_dir) { + return; + } + + len =3D GetModuleFileName(NULL, buf, sizeof(buf) - 1); + if (len =3D=3D 0) { + return; + } + + buf[len] =3D 0; + p =3D buf + len - 1; + while (p !=3D buf && *p !=3D '\\') { + p--; + } + *p =3D 0; + if (access(buf, R_OK) =3D=3D 0) { + exec_dir =3D g_strdup(buf); + } else { + exec_dir =3D CONFIG_BINDIR; + } +#else + char *p =3D NULL; + char buf[PATH_MAX]; + + if (exec_dir) { + return; + } + +#if defined(__linux__) + { + int len; + len =3D readlink("/proc/self/exe", buf, sizeof(buf) - 1); + if (len > 0) { + buf[len] =3D 0; + p =3D buf; + } + } +#elif defined(__FreeBSD__) \ + || (defined(__NetBSD__) && defined(KERN_PROC_PATHNAME)) + { +#if defined(__FreeBSD__) + static int mib[4] =3D {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1= }; +#else + static int mib[4] =3D {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PAT= HNAME}; +#endif + size_t len =3D sizeof(buf) - 1; + + *buf =3D '\0'; + if (!sysctl(mib, ARRAY_SIZE(mib), buf, &len, NULL, 0) && + *buf) { + buf[sizeof(buf) - 1] =3D '\0'; + p =3D buf; + } + } +#elif defined(__APPLE__) + { + char fpath[PATH_MAX]; + uint32_t len =3D sizeof(fpath); + if (_NSGetExecutablePath(fpath, &len) =3D=3D 0) { + p =3D realpath(fpath, buf); + if (!p) { + return; + } + } + } +#elif defined(__HAIKU__) + { + image_info ii; + int32_t c =3D 0; + + *buf =3D '\0'; + while (get_next_image_info(0, &c, &ii) =3D=3D B_OK) { + if (ii.type =3D=3D B_APP_IMAGE) { + strncpy(buf, ii.name, sizeof(buf)); + buf[sizeof(buf) - 1] =3D 0; + p =3D buf; + break; + } + } + } +#endif + /* If we don't have any way of figuring out the actual executable + location then try argv[0]. */ + if (!p && argv0) { + p =3D realpath(argv0, buf); + } + if (p) { + exec_dir =3D g_path_get_dirname(p); + } else { + exec_dir =3D CONFIG_BINDIR; + } +#endif +} + +const char *qemu_get_exec_dir(void) +{ + return exec_dir; +} + char *get_relocated_path(const char *dir) { size_t prefix_len =3D strlen(CONFIG_PREFIX); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 477990f39b..7ba4472760 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -283,87 +283,6 @@ void qemu_set_tty_echo(int fd, bool echo) tcsetattr(fd, TCSANOW, &tty); } =20 -static const char *exec_dir; - -void qemu_init_exec_dir(const char *argv0) -{ - char *p =3D NULL; - char buf[PATH_MAX]; - - if (exec_dir) { - return; - } - -#if defined(__linux__) - { - int len; - len =3D readlink("/proc/self/exe", buf, sizeof(buf) - 1); - if (len > 0) { - buf[len] =3D 0; - p =3D buf; - } - } -#elif defined(__FreeBSD__) \ - || (defined(__NetBSD__) && defined(KERN_PROC_PATHNAME)) - { -#if defined(__FreeBSD__) - static int mib[4] =3D {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1= }; -#else - static int mib[4] =3D {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PAT= HNAME}; -#endif - size_t len =3D sizeof(buf) - 1; - - *buf =3D '\0'; - if (!sysctl(mib, ARRAY_SIZE(mib), buf, &len, NULL, 0) && - *buf) { - buf[sizeof(buf) - 1] =3D '\0'; - p =3D buf; - } - } -#elif defined(__APPLE__) - { - char fpath[PATH_MAX]; - uint32_t len =3D sizeof(fpath); - if (_NSGetExecutablePath(fpath, &len) =3D=3D 0) { - p =3D realpath(fpath, buf); - if (!p) { - return; - } - } - } -#elif defined(__HAIKU__) - { - image_info ii; - int32_t c =3D 0; - - *buf =3D '\0'; - while (get_next_image_info(0, &c, &ii) =3D=3D B_OK) { - if (ii.type =3D=3D B_APP_IMAGE) { - strncpy(buf, ii.name, sizeof(buf)); - buf[sizeof(buf) - 1] =3D 0; - p =3D buf; - break; - } - } - } -#endif - /* If we don't have any way of figuring out the actual executable - location then try argv[0]. */ - if (!p && argv0) { - p =3D realpath(argv0, buf); - } - if (p) { - exec_dir =3D g_path_get_dirname(p); - } else { - exec_dir =3D CONFIG_BINDIR; - } -} - -const char *qemu_get_exec_dir(void) -{ - return exec_dir; -} - #ifdef CONFIG_LINUX static void sigbus_handler(int signal, siginfo_t *siginfo, void *ctx) #else /* CONFIG_LINUX */ diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 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 Sat Apr 20 11:04:20 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=1652465629; cv=none; d=zohomail.com; s=zohoarc; b=gPgH17d5D+/UvgegqRYuJtVLRT6XBQMPowhwZsCTHhxjR77CnF3HdmIRCt0vRmE3BT06m+QAxDNmwksUEXvYdWuZV7AZyfaPM2kmDcugYn/xuDE8AAS6+NLmwbTOIwroM0B/9f94gaWjX458UeKTG9AXJKgSq4/bwAIjdwUwNto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465629; 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=lwU0IIX84LupWziufp4z1foxxfyW5QXhf/iA8+wlBWQ=; b=Inyc8rmperEgt7skdxgVSL35WvPbql1nyJf7Iki1uyJTJZtT3VfDd+EItEgPqsrCk/2qcXQLqHKpVTYPdUVeV1l414LityLu4msxYiZZGsgpkYLGyJJVZtko4sc/2OLXEIOTqtBneGMXvtOJI6tGT2T+HulnV6bY+2z3+5GUa/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652465629331813.6114791503793; Fri, 13 May 2022 11:13:49 -0700 (PDT) Received: from localhost ([::1]:43620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZnP-0000ov-PI for importer@patchew.org; Fri, 13 May 2022 14:13:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiO-0000TG-2U for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiM-0006ze-BY for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:35 -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-526-7HHjcwb6N6eQvnteaLYKlA-1; Fri, 13 May 2022 14:08:30 -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 12FA9101A52C; Fri, 13 May 2022 18:08:30 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 056572026987; Fri, 13 May 2022 18:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465313; 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=lwU0IIX84LupWziufp4z1foxxfyW5QXhf/iA8+wlBWQ=; b=T7K5BmjHJwXfBUlKb3cGiHCuCVGVN5RYWFeHmbZfdcyuLc6TZ1+iHCVnJ7+xSnzLIbCsnE b6+oX9LOXrfZVYyK6w0IPe21SVS8aKqt7ihRvQECe90lh6b0ELCt/kjNk23jq8NkxOYi27 CfHXGTf/WAAg4muktj26l8zaufq8WY4= X-MC-Unique: 7HHjcwb6N6eQvnteaLYKlA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 02/15] util/win32: simplify qemu_get_local_state_dir() Date: Fri, 13 May 2022 20:08:08 +0200 Message-Id: <20220513180821.905149-3-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465631144100001 From: Marc-Andr=C3=A9 Lureau SHGetFolderPath() is a deprecated API: https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_co= re-shgetfolderpatha It is a wrapper for SHGetKnownFolderPath() and CSIDL_COMMON_PATH is mapped to FOLDERID_ProgramData: https://docs.microsoft.com/en-us/windows/win32/shell/csidl g_get_system_data_dirs() is a suitable replacement, as it will have FOLDERID_ProgramData in the returned list. However, it follows the XDG Base Directory Specification, if `XDG_DATA_DIRS` is defined, it will be returned instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Weil --- util/oslib-win32.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 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 Sat Apr 20 11:04:20 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=1652465406; cv=none; d=zohomail.com; s=zohoarc; b=nPaO9FYh3myZdHTpBtNFDjmNQnLbkBvjtrZRBW42Q2ly323DKenMTTgcDZpqgaMfMUtd2B9OxtjwI9cZZNRkSK57j/uYGEkE9fupwvkd3JZfyv/7nITvhwkkDHz+ipOyZwiJ9iM5e1JoFelsOUIqJf90Yp/DmYr1tHFmHK//xaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465406; 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=wx5WCElJnb/uveh/OKqsNDKj+M6vRBZmcC9RnUhdD14=; b=dw2wvINi2fTxtWVHpYSGmyRPre+pWUFrIyVa+ldrm0sFdJQncpMhkf/njeUri0hWpHhzwTyNdfkqA8w8in1nv8JCMANa5Be/j2Kp1vbkrJG54qAoBZiYqwtU/I4b2N0fqiq0jhQ6pMJPukkxNlQY36+vq46H78UfySG76BI8dAU= 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 1652465406220442.37421691122984; Fri, 13 May 2022 11:10:06 -0700 (PDT) Received: from localhost ([::1]:35684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZjo-00038Y-SZ for importer@patchew.org; Fri, 13 May 2022 14:10:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiO-0000TH-2u for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiM-0006zc-C1 for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:35 -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-45-ge1EEh21PDqRNq6akQo2rg-1; Fri, 13 May 2022 14:08:32 -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 D94C82919EBC; Fri, 13 May 2022 18:08:31 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84826416156; Fri, 13 May 2022 18:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465313; 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=wx5WCElJnb/uveh/OKqsNDKj+M6vRBZmcC9RnUhdD14=; b=S++9opCBQSjMnfhq3ux/qzmoDwLJqBELtULqp3xUR97HaGc465N1OAYSc+pcp1uoTK8JS6 6UQTQ5bnYFFt0VxgO0DZpJXdX6zm5k2UwwSOtMLT2Iz/Ck54ElT/kaVFCB5vMh9rjte1oy 7a9qdkjSUF+fG3ylwZgabokJZ7ju6+w= X-MC-Unique: ge1EEh21PDqRNq6akQo2rg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 03/15] tests: make libqmp buildable for win32 Date: Fri, 13 May 2022 20:08:09 +0200 Message-Id: <20220513180821.905149-4-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465407760100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth --- tests/qtest/libqmp.c | 34 +++++++++++++++++++++++++++++----- tests/qtest/libqmp.h | 2 ++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/tests/qtest/libqmp.c b/tests/qtest/libqmp.c index 0358b8313d..df39d250fe 100644 --- a/tests/qtest/libqmp.c +++ b/tests/qtest/libqmp.c @@ -18,6 +18,11 @@ =20 #include "libqmp.h" =20 +#ifndef G_OS_WIN32 +#include +#endif + +#include "qemu/cutils.h" #include "qapi/error.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/qjson.h" @@ -87,6 +92,7 @@ QDict *qmp_fd_receive(int fd) return qmp.response; } =20 +#ifndef G_OS_WIN32 /* Sends a message and file descriptors to the socket. * It's needed for qmp-commands like getfd/add-fd */ static void socket_send_fds(int socket_fd, int *fds, size_t fds_num, @@ -120,17 +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 G_OS_WIN32 + assert(fds_num =3D=3D 0); +#endif + /* Going through qobject ensures we escape strings properly */ qobj =3D qobject_from_vjsonf_nofail(fmt, ap); =20 @@ -148,10 +160,14 @@ void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_nu= m, if (log) { fprintf(stderr, "%s", str->str); } + +#ifndef G_OS_WIN32 /* Send QMP request */ if (fds && fds_num > 0) { socket_send_fds(fd, fds, fds_num, str->str, str->len); - } else { + } else +#endif + { socket_send(fd, str->str, str->len); } =20 @@ -160,15 +176,23 @@ void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_nu= m, } } =20 +#ifndef G_OS_WIN32 +void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, + const char *fmt, va_list ap) +{ + _qmp_fd_vsend_fds(fd, fds, fds_num, fmt, ap); +} +#endif + void qmp_fd_vsend(int fd, const char *fmt, va_list ap) { - qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); + _qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); } =20 =20 QDict *qmp_fdv(int fd, const char *fmt, va_list ap) { - qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); + _qmp_fd_vsend_fds(fd, NULL, 0, fmt, ap); =20 return qmp_fd_receive(fd); } diff --git a/tests/qtest/libqmp.h b/tests/qtest/libqmp.h index 5cb7eeaa18..9e9768f559 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 G_OS_WIN32 void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num, const char *fmt, va_list ap) G_GNUC_PRINTF(4, 0); +#endif void qmp_fd_vsend(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0); void qmp_fd_send(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3); void qmp_fd_send_raw(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3); --=20 2.36.1 From nobody Sat Apr 20 11:04:20 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=1652465639; cv=none; d=zohomail.com; s=zohoarc; b=ip3egNgW9FzOeH5o1nIYJAUnPtxVqkku7FFlwOWvxDW6WhGYKjL2oJkJt4Na1Qd1ZpJXxpD0rOiq9i29t+OtLO7/anN2P3AK5OG6ZGCkIKL7uNo7Z56gioIs4Rf0X5KoY22piUXJs/65Y0UZuMdI5dtoB21lQ/b8t9p/GdBZr8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465639; 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=5o9fChlsjwtRFsvSIL+alf7xKwV3z5PfCag2L300olU=; b=gmqKgJTup+Nf5ESYtXoV5k7XoUJApXFKlioZEoFTurvPssvP9IYn6VPEyO0ucaHhGMPZ+sidR2p+wFILYmRcFmLyuMJqkQEUkTxXYzo46vU6AkbBzZmiMeuMMyCavuClLDALDRXq6hLr7+PaVGezLVLeftG/9a9iM/WDgnV3dLA= 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 1652465639237871.7769772774483; Fri, 13 May 2022 11:13:59 -0700 (PDT) Received: from localhost ([::1]:44164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZna-0001B2-6D for importer@patchew.org; Fri, 13 May 2022 14:13:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiS-0000fM-Ok for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37213) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiQ-000708-Su for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:40 -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-391-kpUkhDgnNh252WU0cgOvLA-1; Fri, 13 May 2022 14:08:34 -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 D0C6B2919EBE; Fri, 13 May 2022 18:08:33 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2516740D2820; Fri, 13 May 2022 18:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465318; 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=5o9fChlsjwtRFsvSIL+alf7xKwV3z5PfCag2L300olU=; b=bQbQpEZHjm2h3vIvusGJVLenm4i1SeaGhjdMSHirt1kEKOGTukwn4bZ1y+AESmsfXRH07n xwgXv2qy2YnWH6IiKQsCX+jC6Dtf/+kaz0Ky0kMDbZ33vvpwth1NJIsf6fQZ2R4st2cku3 2aCN739RHn7gSB/xA3P9mEg//cJaCCA= X-MC-Unique: kpUkhDgnNh252WU0cgOvLA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 04/15] qga: flatten safe_open_or_create() Date: Fri, 13 May 2022 20:08:10 +0200 Message-Id: <20220513180821.905149-5-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465641226100001 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 --- qga/commands-posix.c | 122 ++++++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 60 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 69f209af87..15eb7cb77d 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -339,73 +339,75 @@ find_open_flag(const char *mode_str, Error **errp) static FILE * safe_open_or_create(const char *path, const char *mode, Error **errp) { - Error *local_err =3D NULL; int oflag; + 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 with file descr= iptor %d, " + "file '%s' (mode: '%s')", + fd, path, mode); + } =20 - close(fd); - if (oflag & O_CREAT) { - unlink(path); - } +end: + if (f =3D=3D NULL && fd !=3D -1) { + close(fd); + if (oflag & O_CREAT) { + unlink(path); } } - - error_propagate(errp, local_err); - return NULL; + return f; } =20 int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *m= ode, --=20 2.36.1 From nobody Sat Apr 20 11:04:20 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=1652465674; cv=none; d=zohomail.com; s=zohoarc; b=PIsd93HqCNDG5BvbyRlJV6Tt0115c3NRQ1EMVP5KQ5xD7N37YhqmKP+Qa0ldgBd8X9wwWYynTKqdMYSYiwkZV8dODQHb6PB58Rg32embS1VdaBw2KM7z2Z0HSp/tA/ms8/MhGX87sX4p30EK42m74ZnxDy4wz3EOKLH15YGW7lY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465674; 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=o+pDJbQ4xP8ZbW1GDaVXIl7W0jZ515k7FalXl/i1mqU=; b=dXk5kNbMRCV1WVrdsRzTONlZgWXyn80svOfgI2NeuGO8JLPbThIt28qiFSSc+DTNf7Z5hPs29iwJNOshX1SXPacAgXpOq8at6MECjv4Y5P1op2Pbx8FnmLgpIaywefLzSfI97bOYzGf7Ztj+q+BqRCMUNgJYeYX6dyBO1/g/gJo= 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 1652465674054956.4134790323121; Fri, 13 May 2022 11:14:34 -0700 (PDT) Received: from localhost ([::1]:46398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZo8-0002nd-JF for importer@patchew.org; Fri, 13 May 2022 14:14:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiR-0000cT-AX for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiP-000703-MI for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:38 -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-610-27Kd_EvrPGyRTqFaylnGxQ-1; Fri, 13 May 2022 14:08:35 -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 572581C01B43; Fri, 13 May 2022 18:08:35 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEC5340D1CF; Fri, 13 May 2022 18:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465317; 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=o+pDJbQ4xP8ZbW1GDaVXIl7W0jZ515k7FalXl/i1mqU=; b=Js9Qpn6hFtiH9jnGv+2IdEmQPLLtMQlOdS0FWsfyO9Zp0IEui1zTN1nXUz+ByI2XEFOBaJ 8oUNR5aY8dy5yNcWzMPws6Ma76DpaleAJup4i52zh3Pbxn7JLSp4F0Dux7Rghv/obQZnX8 Co6Qx5nIpMSSAC9emuH0QxE0woVqZ9k= X-MC-Unique: 27Kd_EvrPGyRTqFaylnGxQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 05/15] osdep: export qemu_open_cloexec() Date: Fri, 13 May 2022 20:08:11 +0200 Message-Id: <20220513180821.905149-6-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465676053100001 From: Marc-Andr=C3=A9 Lureau Used in the next patch, to simplify qga code. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qemu/osdep.h | 1 + util/osdep.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 67cc465416..64f51cfb7a 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -489,6 +489,7 @@ void sigaction_invoke(struct sigaction *action, */ int qemu_open_old(const char *name, int flags, ...); int qemu_open(const char *name, int flags, Error **errp); +int qemu_open_cloexec(const char *name, int flags, mode_t mode, Error **er= rp); int qemu_create(const char *name, int flags, mode_t mode, Error **errp); int qemu_close(int fd); int qemu_unlink(const char *name); diff --git a/util/osdep.c b/util/osdep.c index 60fcbbaebe..545a88e1fd 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -279,9 +279,11 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t l= en, bool exclusive) } #endif =20 -static int qemu_open_cloexec(const char *name, int flags, mode_t mode) +int qemu_open_cloexec(const char *name, int flags, mode_t mode, Error **er= rp) { + ERRP_GUARD(); int ret; + #ifdef O_CLOEXEC ret =3D open(name, flags | O_CLOEXEC, mode); #else @@ -290,6 +292,10 @@ static int qemu_open_cloexec(const char *name, int fla= gs, mode_t mode) qemu_set_cloexec(ret); } #endif + if (ret =3D=3D -1) { + error_setg_errno(errp, errno, "Failed to open file '%s'", name); + } + return ret; } =20 @@ -327,7 +333,7 @@ qemu_open_internal(const char *name, int flags, mode_t = mode, Error **errp) } #endif =20 - ret =3D qemu_open_cloexec(name, flags, mode); + ret =3D qemu_open_cloexec(name, flags, mode, NULL); =20 if (ret =3D=3D -1) { const char *action =3D flags & O_CREAT ? "create" : "open"; --=20 2.36.1 From nobody Sat Apr 20 11:04:20 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=1652465432; cv=none; d=zohomail.com; s=zohoarc; b=BF85ZARZtBVK1LggIYwBQ8e3TI6Sg8twXp7YG7iHJ+90Of4SpmlW8mBFgU5chbFWfd5QT+nhsr2a3m1gXD/b8UqJ7NtXJzTM0B24i1ec4Tyv7ZXqq/orR3znLEOHkIqm/noTezju5s0FvFCDiUHwJZ66/KtuI0KxPfpHTBnFHJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465432; 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=cuAqkUPEiEthZ35kiz/2rgeUeVaqzBg0dF3Oi579Z68=; b=m1Gy5WtKLl2LJ5z/ytyiHi3UKW2woHNVlSmBg9o9mu/CSKMFDGo073o8ROCurLb6LcAqCmdqgJSZ0iMpB0YFDal/LVI6OycX8mBScWJBlqWO6+Kt0P4bYfACAyP9Uwkl/3jSG3VqUymRLRVI//xrbHMKAgdO5FliQkl8djBgsms= 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 1652465432447746.7466701151212; Fri, 13 May 2022 11:10:32 -0700 (PDT) Received: from localhost ([::1]:36430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZkD-0003eu-R6 for importer@patchew.org; Fri, 13 May 2022 14:10:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiV-0000p8-Nb for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiU-00070Z-5k for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:43 -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-511-b-llxf2SOS-0jsYVqBYi7Q-1; Fri, 13 May 2022 14:08:38 -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 1DCD9185A794; Fri, 13 May 2022 18:08:38 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD9A4416369; Fri, 13 May 2022 18:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465321; 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=cuAqkUPEiEthZ35kiz/2rgeUeVaqzBg0dF3Oi579Z68=; b=Gq10KYCA0dVvErL4pz+ise9C6BSM3XsFfMgE3y+uXnSkQACH34xAZdJa0pN767KxwczREP tc89elE0yQWLr4d0uLIxqCKzCjuD779CR5M3IgTS0Aesw2AcUZTMCH4B5p8mLnqij456yP 2s+uRKj38tjixqOJHlg0OjXV5eQ0FDE= X-MC-Unique: b-llxf2SOS-0jsYVqBYi7Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 06/15] qga: use qemu_open_cloexec() for safe_open_or_create() Date: Fri, 13 May 2022 20:08:12 +0200 Message-Id: <20220513180821.905149-7-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465433858100001 From: Marc-Andr=C3=A9 Lureau The function takes care of setting CLOEXEC, and reporting error. The reported error message will differ, from: "failed to open file 'foo' (mode: 'r')" to: "Failed to open file 'foo'" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- qga/commands-posix.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 15eb7cb77d..7761458ce1 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -339,6 +339,7 @@ find_open_flag(const char *mode_str, Error **errp) static FILE * safe_open_or_create(const char *path, const char *mode, Error **errp) { + ERRP_GUARD(); int oflag; int fd =3D -1; FILE *f =3D NULL; @@ -370,21 +371,17 @@ safe_open_or_create(const char *path, const char *mod= e, Error **errp) * open() is decisive and its third argument is ignored, and the second * open() and the fchmod() are never called. */ - fd =3D open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0); + fd =3D qemu_open_cloexec(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0= ), 0, errp); if (fd =3D=3D -1 && errno =3D=3D EEXIST) { + error_free(*errp); + *errp =3D NULL; oflag &=3D ~(unsigned)O_CREAT; - fd =3D open(path, oflag); + fd =3D qemu_open_cloexec(path, oflag, 0, errp); } if (fd =3D=3D -1) { - error_setg_errno(errp, errno, - "failed to open file '%s' " - "(mode: '%s')", - path, mode); goto end; } =20 - qemu_set_cloexec(fd); - if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) =3D=3D -1) { error_setg_errno(errp, errno, "failed to set permission 0%03o on new file '%s' = (mode: '%s')", --=20 2.36.1 From nobody Sat Apr 20 11:04:20 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=1652465961; cv=none; d=zohomail.com; s=zohoarc; b=nBCWU0nba3+TYVT+I1kBQFf+qX3b9tG7rqqwg7KuQ92z6rPn+whC/QjuF9qqbWsmfRJ+rqAL3wij47F0N+hIGDqzIZDHQ045uVjutamrUux1VSXM/7+nKEvXePusE5vkmCaZqnbZxaTSIKHyzmcD19ssl1qFjoBUH97nFo35IFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465961; 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=jh8aRrRJckFcHtiQlCat4NAPKRU4Hvu05QLyujh6EXQ=; b=GtZvBd7GiG181SWXxwiSZhIziuKCxSFQAZbVjTwSMYUGNURepz565W6BY1nT6ATTVY0DsBucwax3bFI5cYJCw0pFeAvfrwsqc7M8IIpJ45aXBFjnLgTe5yQTRGmXp0cV+oM7HNDPnT+Hodo5LoPwMf/2DmMHFgUlUNClJwrqoO4= 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 1652465961258164.71710247530052; Fri, 13 May 2022 11:19:21 -0700 (PDT) Received: from localhost ([::1]:52696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZsm-0007Xg-3w for importer@patchew.org; Fri, 13 May 2022 14:19:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiW-0000rO-Oh for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZiV-00070k-3K for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:44 -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-257-KsCE1c-JNgeB3uNEzJomqQ-1; Fri, 13 May 2022 14:08:41 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DED69801E80; Fri, 13 May 2022 18:08:40 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84F0C438BF4; Fri, 13 May 2022 18:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465322; 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=jh8aRrRJckFcHtiQlCat4NAPKRU4Hvu05QLyujh6EXQ=; b=ekiFqTaH2lIeOQar0aPRkykVZg/xK5ZNt/6DTK6QjS3UEXa9SwaCexgEXeowVmZxXAOMHd Jt4baKXqdHXKKRW09h1wSOLW0rb/cpyQYMPp+arqwVshiak4HViuuwgInni5l0SoSrHBsV EALIOXy0EmlsE1liYuLUl/NsdhQFSvI= X-MC-Unique: KsCE1c-JNgeB3uNEzJomqQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 07/15] qga: throw an Error in ga_channel_open() Date: Fri, 13 May 2022 20:08:13 +0200 Message-Id: <20220513180821.905149-8-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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.9 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465962492100001 From: Marc-Andr=C3=A9 Lureau Allow for a single point of error reporting, and further refactoring. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qga/channel-posix.c | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index a996858e24..039e1ddcb2 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -119,8 +119,9 @@ static int ga_channel_client_add(GAChannel *c, int fd) } =20 static gboolean ga_channel_open(GAChannel *c, const gchar *path, - GAChannelMethod method, int fd) + GAChannelMethod method, int fd, Error **er= rp) { + ERRP_GUARD(); int ret; c->method =3D method; =20 @@ -133,21 +134,20 @@ static gboolean ga_channel_open(GAChannel *c, const g= char *path, #endif ); if (fd =3D=3D -1) { - g_critical("error opening channel: %s", strerror(errno)); + error_setg_errno(errp, errno, "error opening channel"); return false; } #ifdef CONFIG_SOLARIS ret =3D ioctl(fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI); if (ret =3D=3D -1) { - g_critical("error setting event mask for channel: %s", - strerror(errno)); + error_setg_errno(errp, errno, "error setting event mask for ch= annel"); close(fd); return false; } #endif ret =3D ga_channel_client_add(c, fd); if (ret) { - g_critical("error adding channel to main loop"); + error_setg(errp, "error adding channel to main loop"); close(fd); return false; } @@ -159,7 +159,7 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, assert(fd < 0); fd =3D qemu_open_old(path, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd =3D=3D -1) { - g_critical("error opening channel: %s", strerror(errno)); + error_setg_errno(errp, errno, "error opening channel"); return false; } tcgetattr(fd, &tio); @@ -180,7 +180,7 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, tcsetattr(fd, TCSANOW, &tio); ret =3D ga_channel_client_add(c, fd); if (ret) { - g_critical("error adding channel to main loop"); + error_setg(errp, "error adding channel to main loop"); close(fd); return false; } @@ -188,12 +188,8 @@ static gboolean ga_channel_open(GAChannel *c, const gc= har *path, } case GA_CHANNEL_UNIX_LISTEN: { if (fd < 0) { - Error *local_err =3D NULL; - - fd =3D unix_listen(path, &local_err); - if (local_err !=3D NULL) { - g_critical("%s", error_get_pretty(local_err)); - error_free(local_err); + fd =3D unix_listen(path, errp); + if (fd < 0) { return false; } } @@ -202,24 +198,19 @@ static gboolean ga_channel_open(GAChannel *c, const g= char *path, } case GA_CHANNEL_VSOCK_LISTEN: { if (fd < 0) { - Error *local_err =3D NULL; SocketAddress *addr; char *addr_str; =20 addr_str =3D g_strdup_printf("vsock:%s", path); - addr =3D socket_parse(addr_str, &local_err); + addr =3D socket_parse(addr_str, errp); g_free(addr_str); - if (local_err !=3D NULL) { - g_critical("%s", error_get_pretty(local_err)); - error_free(local_err); + if (!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 +218,7 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, break; } default: - g_critical("error binding/listening to specified socket"); + error_setg(errp, "error binding/listening to specified socket"); return false; } =20 @@ -272,12 +263,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 Sat Apr 20 11:04:20 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=1652465988; cv=none; d=zohomail.com; s=zohoarc; b=ZtBeb61vMhjdskUHrGy6kuS85XXC3YIF4GUj78W1LkIDJOjiS/WZQ31vV9Z4cTrs8ResWOQLa2QutP3bEAh3m4W2C+1trxL5vSRyNHQHEh9FG3eMepdkJnbxFylR6Ug2trBjGNW1mypBmKoflZ7utZKWdRGWmHCxbl5jha5DlPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465988; 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=zLW3ERMVmhDAAG+REaOZKcjlv8XYBvV4yL5VFMVvzr8=; b=j90PKR2o8l5InIRpUZvHV9GnJMsYooZN2DZsOJwm/PUmgF+ngvkb5Z/yIrxJfJpYTwt75p3/oNs6ZGiLL/UL5ndvRiMveIQifUEnC5RhMHfqJGQ6F82+Y3pCvsVNb7hfsKj+VuebqeDjiJgUb05jZAXAU34+BiE1DmkSxTLZBnI= 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 165246598829072.47573593331458; Fri, 13 May 2022 11:19:48 -0700 (PDT) Received: from localhost ([::1]:54810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZtC-0000av-RP for importer@patchew.org; Fri, 13 May 2022 14:19:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZic-00018u-4U for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50111) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZia-00071G-6O for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:49 -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-467-NyMu8-p6OIaZ2T9Y2gN9eA-1; Fri, 13 May 2022 14:08: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 E7F3086B8BC; Fri, 13 May 2022 18:08:45 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EA1E7AD5; Fri, 13 May 2022 18:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465327; 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=zLW3ERMVmhDAAG+REaOZKcjlv8XYBvV4yL5VFMVvzr8=; b=jIQd++RCjyD8iRsX2ZgVJ/9K9dTH1wM8nQSkFEI40kwOPiUiHjjcMuiQbBQcAwwl5v6O3j ISiIOFF2vGI67zfztcpx6uXMN1gmCLWKe0/rLqiDNtXPMuviFAMXms2h26JWg1Eyadkhgr yefKH7qmh3MqQJBZM1Xp4+m6loj1mNc= X-MC-Unique: NyMu8-p6OIaZ2T9Y2gN9eA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 08/15] qga: replace qemu_open_old() with qemu_open_cloexec() Date: Fri, 13 May 2022 20:08:14 +0200 Message-Id: <20220513180821.905149-9-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465988714100001 From: Marc-Andr=C3=A9 Lureau qemu_open_old() uses qemu_open_internal() which handles special "/dev/fdset/" path for monitor fd sets, set CLOEXEC, and uses Error reporting (and some O_DIRECT special error casing). The monitor fdset handling is unnecessary for qga, use qemu_open_cloexec() instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- qga/channel-posix.c | 14 +++++++++----- qga/commands-posix.c | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 039e1ddcb2..affee485fc 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -1,4 +1,5 @@ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include #include "qapi/error.h" #include "qemu/sockets.h" @@ -128,11 +129,15 @@ static gboolean ga_channel_open(GAChannel *c, const g= char *path, switch (c->method) { case GA_CHANNEL_VIRTIO_SERIAL: { assert(fd < 0); - fd =3D qemu_open_old(path, O_RDWR | O_NONBLOCK + fd =3D qemu_open_cloexec( + path, #ifndef CONFIG_SOLARIS - | O_ASYNC + O_ASYNC | #endif - ); + O_RDWR | O_NONBLOCK, + 0, + errp + ); if (fd =3D=3D -1) { error_setg_errno(errp, errno, "error opening channel"); return false; @@ -157,9 +162,8 @@ static gboolean ga_channel_open(GAChannel *c, const gch= ar *path, struct termios tio; =20 assert(fd < 0); - fd =3D qemu_open_old(path, O_RDWR | O_NOCTTY | O_NONBLOCK); + fd =3D qemu_open_cloexec(path, O_RDWR | O_NOCTTY | O_NONBLOCK, 0, = errp); if (fd =3D=3D -1) { - error_setg_errno(errp, errno, "error opening channel"); return false; } tcgetattr(fd, &tio); diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 7761458ce1..e8eafad74d 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1394,6 +1394,7 @@ static GuestDiskInfoList *get_disk_partitions( =20 static void get_nvme_smart(GuestDiskInfo *disk) { + Error *err =3D NULL; int fd; GuestNVMeSmart *smart; NvmeSmartLog log =3D {0}; @@ -1406,9 +1407,10 @@ static void get_nvme_smart(GuestDiskInfo *disk) | (((sizeof(log) >> 2) - 1) << 16) }; =20 - fd =3D qemu_open_old(disk->name, O_RDONLY); + fd =3D qemu_open_cloexec(disk->name, O_RDONLY, 0, &err); if (fd =3D=3D -1) { - g_debug("Failed to open device: %s: %s", disk->name, g_strerror(er= rno)); + g_debug("Failed to open device: %s: %s", disk->name, error_get_pre= tty(err)); + error_free(err); return; } =20 @@ -1739,9 +1741,8 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mount= points, } } =20 - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qemu_open_cloexec(mount->dirname, O_RDONLY, 0, errp); if (fd =3D=3D -1) { - error_setg_errno(errp, errno, "failed to open %s", mount->dirn= ame); goto error; } =20 @@ -1806,7 +1807,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp) =20 QTAILQ_FOREACH(mount, &mounts, next) { logged =3D false; - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qemu_open_cloexec(mount->dirname, O_RDONLY, 0, NULL); if (fd =3D=3D -1) { continue; } @@ -1866,21 +1867,20 @@ static void guest_fsfreeze_cleanup(void) GuestFilesystemTrimResponse * qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp) { + ERRP_GUARD(); GuestFilesystemTrimResponse *response; GuestFilesystemTrimResult *result; int ret =3D 0; FsMountList mounts; struct FsMount *mount; int fd; - Error *local_err =3D NULL; struct fstrim_range r; =20 slog("guest-fstrim called"); =20 QTAILQ_INIT(&mounts); - build_fs_mount_list(&mounts, &local_err); - if (local_err) { - error_propagate(errp, local_err); + build_fs_mount_list(&mounts, errp); + if (*errp) { return NULL; } =20 @@ -1892,11 +1892,11 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum,= Error **errp) =20 QAPI_LIST_PREPEND(response->paths, result); =20 - fd =3D qemu_open_old(mount->dirname, O_RDONLY); + fd =3D qemu_open_cloexec(mount->dirname, O_RDONLY, 0, errp); if (fd =3D=3D -1) { - result->error =3D g_strdup_printf("failed to open: %s", - strerror(errno)); + result->error =3D g_strdup(error_get_pretty(*errp)); result->has_error =3D true; + g_clear_pointer(errp, error_free); continue; } =20 --=20 2.36.1 From nobody Sat Apr 20 11:04:20 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=1652466108; cv=none; d=zohomail.com; s=zohoarc; b=cSN29Bw80RxdyFwwN0ENHxFn2lKw5oZZYCm99tmbQU2VB6b+tA+9oMw4zfm7I764kYOt2bobvhze2nSIrmvMBsjT2hOrwKkPcFQXczVu2y4YLCCqvsaAAglrvfAV0ljl3smrjfdVzwNWUaifwTQEyMbvx3vRW0QFwYlNOXc0eUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652466108; 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=enVbbMbhoSNYtj7arAt2rOduXQLObAdfM5LH2ckDfPg=; b=ThddC3NOCRaFfq+7+h9QZ1K+fST9o5GahcSxzl4SGfZjC252WaLbOhzaDkb1C8ZyXPBuH7mdfgzXIHdrI3/jSXbS34fBaGwRN0mhecw8BqiXCUd5+RPAGzf9XicIy+kbEOfCp9GLNLczymr0Nkt9pZuAWhNqSsArn31erR6qaU8= 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 1652466108721751.2792556539948; Fri, 13 May 2022 11:21:48 -0700 (PDT) Received: from localhost ([::1]:33016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZv9-00052V-NZ for importer@patchew.org; Fri, 13 May 2022 14:21:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZid-0001DG-6l for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZib-00071L-J1 for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:50 -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-384-Jh_72J4kObGad21ZjK1s0g-1; Fri, 13 May 2022 14:08:47 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 762618339BE; Fri, 13 May 2022 18:08:47 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 199CBC28106; Fri, 13 May 2022 18:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465329; 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=enVbbMbhoSNYtj7arAt2rOduXQLObAdfM5LH2ckDfPg=; b=A3wWFx5mXcfMEN4/AcvLI/GixQ5byjESSi/t+ZtlS12QcWs5VvPLqIOrMj0FHPND4iAUZL /leoWye0TH5GQFz7g5BudHpjataWydij3TKTJgWxFaona69/oTdTwRWHvPF5w5/uJChWe+ PBoHmwOojBFyF6SC+7Jw5k75Y+pbk04= X-MC-Unique: Jh_72J4kObGad21ZjK1s0g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 09/15] qga: make build_fs_mount_list() return a bool Date: Fri, 13 May 2022 20:08:15 +0200 Message-Id: <20220513180821.905149-10-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652466109374100001 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 --- qga/commands-posix.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index e8eafad74d..a414875109 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 @@ -1594,8 +1595,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; } @@ -1718,8 +1718,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; } @@ -1799,8 +1798,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; } @@ -1879,8 +1877,7 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, E= rror **errp) slog("guest-fstrim called"); =20 QTAILQ_INIT(&mounts); - build_fs_mount_list(&mounts, errp); - if (*errp) { + if (!build_fs_mount_list(&mounts, errp)) { return NULL; } =20 --=20 2.36.1 From nobody Sat Apr 20 11:04:20 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=1652465969; cv=none; d=zohomail.com; s=zohoarc; b=lHV78P+7m5pNq7f6+vl4N7zJ6z893xoAe7pNcWbhyYWnBCW6nh714k6c0hFgK2fjcNIz27F09CoV2BWbMifbPy3IwOPLGYI4OuU9Ht8e1/H3TM4BvaSfxmxGNmtR3Xmm+c0leeoFBKb1i+gkafZv/fHxIFGSXVCqYd7gGRrGirI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465969; 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=x1vDNkyDxENYzuxXRNo3L5BE9SMj1BnRZK7GnlyDWoE=; b=kWFpKzNWeiOqMDAaB2Qmo1uNa+iSI7yMIf67SR8yiEew1p4oF/gkOQjOm6WF5mH+kQyfiVdvDetC/u2z7VW45JpukTWcciCkhseVmKQKn38PChwek3z45KWFuYpBwhNo6Ih4NqT1ljkllVFMLni9KF5QO0ie7dUFVHZTvZm7Sx8= 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 1652465969904304.8498312375949; Fri, 13 May 2022 11:19:29 -0700 (PDT) Received: from localhost ([::1]:53360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZsu-0007zG-QK for importer@patchew.org; Fri, 13 May 2022 14:19:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZih-0001R5-6x for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZif-00071s-Dp for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08: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-637-o_pkEWuaPnOjhPSoxigmIQ-1; Fri, 13 May 2022 14:08:51 -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 65FD010665A0; Fri, 13 May 2022 18:08:49 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC95640D1CF; Fri, 13 May 2022 18:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465332; 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=x1vDNkyDxENYzuxXRNo3L5BE9SMj1BnRZK7GnlyDWoE=; b=Z/ILGxGzoUGGFAPj63B/53+EZ+1nhBe2TcsFBf+u/9PlYrgl8bZ0SFc8s+zavqnDuxkwpK P108EYefXKaPHPND3wkKSJ4b24p+h6Y1ZMTNRJm4WSVT64eVPlaTkxF+b1SuBjmba6Uifg zuxwi9l7/tbP174LLGW9OvaK+wt7sz8= X-MC-Unique: o_pkEWuaPnOjhPSoxigmIQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 10/15] test/qga: use G_TEST_DIR to locate os-release test file Date: Fri, 13 May 2022 20:08:16 +0200 Message-Id: <20220513180821.905149-11-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465970621100001 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 --- 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 Sat Apr 20 11:04:20 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=1652465652; cv=none; d=zohomail.com; s=zohoarc; b=CHeTIM3L0MsB0Me8DFA9+s44hPk7o4i6BfIBY3psTH3aQ0AMLyWzu9JfEV0WMzrgz4hhNAvq3r5wl0bZqcoVYtZ3IRZ9srHOFyT9oxUrwRp8R3GsTKF2P5qvpStsisF/FhfrlUPGqk+7hw2+awyOkA8cpN4rrcRytgV2nTb9fYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652465652; 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=Olum9Pty0O24L9mPdjGTqHP2sNTsbWFCGNZznGFul1I=; b=hCMxGix7ZMFcVLkR5BsOYsMpYrPW40K4LIrBXhXLOuWoisnMG/GZgH5M2WdUJQ8JbkC7deUk83QMAqpVciUD6p4DGcZkiW1WHgBytvXBXSw5nNbuJ7esjrpUeGYKOhD5rab5/cito40Oq34b1vVseEMvRF7T9zUAKamU5EemoXo= 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 1652465652138326.84171524163537; Fri, 13 May 2022 11:14:12 -0700 (PDT) Received: from localhost ([::1]:44912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZnm-0001mJ-M7 for importer@patchew.org; Fri, 13 May 2022 14:14:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZij-0001aT-PV for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZih-00072B-Sk for qemu-devel@nongnu.org; Fri, 13 May 2022 14:08:57 -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-144-t3KHer6HOUyJ8XbbR-2emw-1; Fri, 13 May 2022 14:08:53 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32A8880CDA7; Fri, 13 May 2022 18:08:51 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id B12ED43EA06; Fri, 13 May 2022 18:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465335; 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=Olum9Pty0O24L9mPdjGTqHP2sNTsbWFCGNZznGFul1I=; b=bHitKL4wpZAhfzq727ke83lLt6txa4sxaw2xKw9tDnBj0fGx6aRmibBasQ/rP925IB0A+x YkFsKIgyKprTGNRGCZJCKPontEo6wMxoDdDKXE6S939m6g6BuWtnrEUOilxGdKJjlpBUtv c340D1LMxkHVzsCPQizU/Slh7K9L6GU= X-MC-Unique: t3KHer6HOUyJ8XbbR-2emw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 11/15] qga/wixl: prefer variables over environment Date: Fri, 13 May 2022 20:08:17 +0200 Message-Id: <20220513180821.905149-12-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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.9 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465653968100001 From: Marc-Andr=C3=A9 Lureau No need to setup an environment or to check if the variable is undefined manually. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- qga/installer/qemu-ga.wxs | 30 +++++++++--------------------- qga/meson.build | 9 ++++----- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index 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 6d9f39bb32..3ad3bc0260 100644 --- a/qga/meson.build +++ b/qga/meson.build @@ -121,15 +121,14 @@ if targetos =3D=3D 'windows' output: 'qemu-ga-@0@.msi'.format(host_arch), depends: deps, command: [ - find_program('env'), - 'QEMU_GA_VERSION=3D' + config_host['QEMU_GA_= VERSION'], - 'QEMU_GA_MANUFACTURER=3D' + config_host['QEM= U_GA_MANUFACTURER'], - 'QEMU_GA_DISTRO=3D' + config_host['QEMU_GA_D= ISTRO'], - 'BUILD_DIR=3D' + meson.build_root(), wixl, '-o', '@OUTPUT0@', '@INPUT0@', qemu_ga_msi_arch[cpu], qemu_ga_msi_vss, + '-D', 'BUILD_DIR=3D' + meson.build_root(), '-D', 'Mingw_bin=3D' + config_host['QEMU_GA_= MSI_MINGW_BIN_PATH'], + '-D', 'QEMU_GA_VERSION=3D' + config_host['QE= MU_GA_VERSION'], + '-D', 'QEMU_GA_MANUFACTURER=3D' + config_hos= t['QEMU_GA_MANUFACTURER'], + '-D', 'QEMU_GA_DISTRO=3D' + config_host['QEM= U_GA_DISTRO'], ]) all_qga +=3D [qga_msi] alias_target('msi', qga_msi) --=20 2.36.1 From nobody Sat Apr 20 11:04:20 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=1652466240; cv=none; d=zohomail.com; s=zohoarc; b=HEjoB7pgR/aQeKfcESqIrymRCtliTd+CDQY7uTqU9GsaI12wFhVu3k9+0akp+NxSTdQYudKOSb9JyeRQlm2jUOJQ53mriJp34I9s2jmw0vjVoh9nzLj1Dn2vaGb6imu8JWyhSzMzruKEsfoy2HSEY1FASxnJ77KRhBHKSjO/fuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652466240; 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=xHa+MKmmyBQTjsqTAkhCU6sL+AVzFTPDl677BcvCVPg=; b=jlL/oGXx5mZ7BQYDMQzXeVNTgvth70/FRjz7Rs63ky36taltBLv65SFKFi9wM/38fqR+Z+FvGflLoA8s6ioJb9RxgCEuUTYR+bI3zhRVzt/4/G1IVuNm2t38WUluwNldHmFNSXnVe3kESdv5kmri8YXKBG25oyEbGQZP+QPiVBo= 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 1652466240585947.2941963770301; Fri, 13 May 2022 11:24:00 -0700 (PDT) Received: from localhost ([::1]:40854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZxH-0001sV-3b for importer@patchew.org; Fri, 13 May 2022 14:23:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZim-0001e7-Am for qemu-devel@nongnu.org; Fri, 13 May 2022 14:09:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44320) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZik-00072O-U5 for qemu-devel@nongnu.org; Fri, 13 May 2022 14:09: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-543-2lLSSvIzML-ZCqNHfY8FUA-1; Fri, 13 May 2022 14:08:55 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03C2D28B847E; Fri, 13 May 2022 18:08:53 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B14942D4E4; Fri, 13 May 2022 18:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465338; 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=xHa+MKmmyBQTjsqTAkhCU6sL+AVzFTPDl677BcvCVPg=; b=Wqx3vqAUFG7TthNFh/EQH2/dOSuHKq0crn63NDFlkEEVM5kr1eDGyW8kdvYYtWztxubiZp P5sU35iK8eP9WXOPGe3qeh9RbdQh5yzfrrDf1KgFE6ES6CSvJ8C2tkbtxuHYrvqbyKd9Bv xskp0Qs5GjAmQmVtw63NJW33dPx74V4= X-MC-Unique: 2lLSSvIzML-ZCqNHfY8FUA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 12/15] qga/wixl: require Mingw_bin Date: Fri, 13 May 2022 20:08:18 +0200 Message-Id: <20220513180821.905149-13-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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.9 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652466242482100007 From: Marc-Andr=C3=A9 Lureau No clear reason to make guesses here. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- qga/installer/qemu-ga.wxs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index 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 Sat Apr 20 11:04:20 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=1652466449; cv=none; d=zohomail.com; s=zohoarc; b=LKbJpHrpo5qZJhACuzPIyTdu7qk8QW9CRavgz4my/ncjl+5Y4TXVm/30lMbJ4zH4IELVSSmAEe/w3ZK5u9umFKIAZEXfBpO0Gfjv3TZ7dfECPZ07gK5k9/frKHTH7pHHbqIRG33unkE6GA4UHCSS/cWSbcL7NOOipHWahvpUKXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652466449; 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=v3LVImncM88Cgi5k/8KLgFb4Y+UE9CZITjEiSgR1j/I=; b=gMiUt1fFVTQO79efsdh6b/9WvekqiBamknwLuUyIRudq04U+cZjCG91+ui4JQpS96/A5Gv3sgVbZgvmW+1fCYXmNeNqo6NDOVBo3KgTnlk7yQJ510fvYiI0Gf85q1zLJciCmonbV8zu/wQLtmM3auhyrveNZfcPDQAfcOnG0AiA= 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 1652466449639209.43521708240053; Fri, 13 May 2022 11:27:29 -0700 (PDT) Received: from localhost ([::1]:47570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npa0e-0006aH-Fd for importer@patchew.org; Fri, 13 May 2022 14:27:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZin-0001eY-BZ for qemu-devel@nongnu.org; Fri, 13 May 2022 14:09:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZil-00072S-Rn for qemu-devel@nongnu.org; Fri, 13 May 2022 14:09:01 -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-563-MMJia9rmPTSZkmVzVk-CMQ-1; Fri, 13 May 2022 14:08:56 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C5F1F10AF651; Fri, 13 May 2022 18:08:54 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D67A438BF4; Fri, 13 May 2022 18:08:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465338; 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=v3LVImncM88Cgi5k/8KLgFb4Y+UE9CZITjEiSgR1j/I=; b=WONWUtzOtam3OoG6YV0ghTxuxtwoaanfClSdxEB8L16V+/Nr6r3dNYC8Gng5HRSyyLf4HF qP0VdeD1Biq3EtSOW27lrz29bnIHBJ/6Cm8KwRcZVkgp5U5NJhu6vHU3M5LLjvsuyOtzhl 7TUISjZJUQ/d2bdrsefBCX1+qcpzwVg= X-MC-Unique: MMJia9rmPTSZkmVzVk-CMQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 13/15] qga/wixl: simplify some pre-processing Date: Fri, 13 May 2022 20:08:19 +0200 Message-Id: <20220513180821.905149-14-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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.9 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652466451923100001 From: Marc-Andr=C3=A9 Lureau Sadly, wixl doesn't have 'elif'. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- qga/installer/qemu-ga.wxs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index 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 1652465970685113.27049691729394; Fri, 13 May 2022 11:19:30 -0700 (PDT) Received: from localhost ([::1]:53342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npZsv-0007yP-1g for importer@patchew.org; Fri, 13 May 2022 14:19:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZj6-0002bH-Ls for qemu-devel@nongnu.org; Fri, 13 May 2022 14:09:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZj4-00076N-Mp for qemu-devel@nongnu.org; Fri, 13 May 2022 14:09:20 -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-374-GgS8dws7MXuX-VrodVwSsg-1; Fri, 13 May 2022 14:09:16 -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 3E6911D33880; Fri, 13 May 2022 18:09:12 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D2B1111F3B6; Fri, 13 May 2022 18:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465358; 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=NdZL93hw1EaxCrqVlCeuRTdZ7zSgtNFx2zhI3s9sl+g=; b=ZQ0v4LQDdVZeBKKPRgtJjbuCFEF0jY85oKrHAn4Awh/wj4DN3Jkew00YyUnYFs9tLDk5V3 uEAp6AGJrmf5S8snd7xCLIMQfe7tdOlTJReUwWk5QpDI8dBxdz3zLAtveezwVeK0vFU47t oksmFSN7j2ACFK0tjhJl+IWU4rR5nas= X-MC-Unique: GgS8dws7MXuX-VrodVwSsg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 14/15] qga/wixl: replace QEMU_GA_MSI_MINGW_BIN_PATH with glib bindir Date: Fri, 13 May 2022 20:08:20 +0200 Message-Id: <20220513180821.905149-15-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652465972707100001 From: Marc-Andr=C3=A9 Lureau Use more conventional variables to set the location of pre-built DLL/bin. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Konstantin Kostiuk --- configure | 9 ++++++--- meson.build | 5 ++++- qga/installer/qemu-ga.wxs | 24 ++++++++++++------------ qga/meson.build | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/configure b/configure index c8b5b99532..fb9b4657ae 100755 --- a/configure +++ b/configure @@ -1507,6 +1507,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 @@ -1882,8 +1887,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"; } && \ @@ -1970,7 +1973,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 @@ -2043,6 +2045,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 9b20dcd143..3e5040fe0b 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 1652466665071255.5503616204702; Fri, 13 May 2022 11:31:05 -0700 (PDT) Received: from localhost ([::1]:55174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npa47-0003Oj-Rp for importer@patchew.org; Fri, 13 May 2022 14:31:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZj8-0002gg-4m for qemu-devel@nongnu.org; Fri, 13 May 2022 14:09:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35054) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npZj5-00076T-TR for qemu-devel@nongnu.org; Fri, 13 May 2022 14:09:21 -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-646-uwn1_cSpNS6-67lIkLbNvw-1; Fri, 13 May 2022 14:09:16 -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 6B3678339A9; Fri, 13 May 2022 18:09:15 +0000 (UTC) Received: from localhost (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id B525740D1CF; Fri, 13 May 2022 18:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652465359; 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=VhOFY1x4JVyE2suVa09NKYg3nSAHShmA91SCUZkLQJo=; b=Ld1ngbmwFOlWVAzWoXlq8qVqY4WFvJHdSL5ovYvvF1GGh/8HplkCoK7ABI30pIS99KbbUa TW1TvZutFVrJnAb9AglwahD3iukZrGIw+5Pb1SQBd5vNG0DUV9kCoJTndUJOpDnU3YTAld e8GjLMwOOgitmuv4oJyBVHhxMVQCfis= X-MC-Unique: uwn1_cSpNS6-67lIkLbNvw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Konstantin Kostiuk , Michael Roth , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 15/15] test/qga: use g_auto wherever sensible Date: Fri, 13 May 2022 20:08:21 +0200 Message-Id: <20220513180821.905149-16-marcandre.lureau@redhat.com> In-Reply-To: <20220513180821.905149-1-marcandre.lureau@redhat.com> References: <20220513180821.905149-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652466665937100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- 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