From patchwork Mon Feb 28 00:57:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12762261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13488C433F5 for ; Mon, 28 Feb 2022 00:58:49 +0000 (UTC) Received: from localhost ([::1]:47518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOUND-0006v2-UP for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 19:58:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOUM0-00051C-1r for qemu-devel@nongnu.org; Sun, 27 Feb 2022 19:57:32 -0500 Received: from [2607:f8b0:4864:20::52f] (port=34561 helo=mail-pg1-x52f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOULy-0004cb-LT for qemu-devel@nongnu.org; Sun, 27 Feb 2022 19:57:31 -0500 Received: by mail-pg1-x52f.google.com with SMTP id 139so10066729pge.1 for ; Sun, 27 Feb 2022 16:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E4JpDBscu6i2X5FGSRsHLHRQJcgwmq4SRaqL2cxC2ak=; b=Az1y9P3PeUKe1Sr1Ue7uu2BucYPN3bCOTIsFxs/trep6RI8bRjAquxxH1xSwgLmXX7 xyv4XYlx6o4gULNbo9Vkg72L1aWPBwulIMsqTGlnrAy4NDbWA4sSNb/PaK2oxW2fn7/r 2dO7sRIa8cmiF3L5eBqYisV2THD/sss4UzogfHE+EBmTapQI9RzDkfl7WFHJM8YceyBD 92BWabtI7Pj272MjesdfxjImNQFId3A+/PdePabmkLCzLZJf9RVz3fwINzqkDSIHaRnv WShRzACNEMFQ3Zou6r7Uu5tuz2DltBcVDGNw1FPqHtrElyJrP07DNjoaPrCp7hoEvVVG ggKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E4JpDBscu6i2X5FGSRsHLHRQJcgwmq4SRaqL2cxC2ak=; b=MKS8rfsOYoniWZ9ob5jkHlw6Gqu+MAaSrgk+s5UxLY3TH3Q+Hi4DtjpH5dhjbAjfL2 ENzUtqTHBst4x9gDm+hKgDQo6kNo+8HxL5kL/aWJhu18n++5ET0ykjmAFdLp3eJ30ZQU hjN2B7ZKmLW6nH96FUgD2/vZaxPTL7aTh3NOm5N94K8jqwJkyn52Dh9qrAwfiJPDyPXo XXwrRgxPnQoeYAkzqlhPWY5jPzVITh4vGDKEjY+YLAo6NswJdOWw5FBo4iWgNge4Ip1l U2tze5XdKkjr6dvmxZzJYo9tC4orGdD+cXGCvyBU90uGwSToj2+LMDkA9hUHT1/Geppl Yw9Q== X-Gm-Message-State: AOAM5302cfhVNnDCCXrb0hfQjt5gDoM+tkyW63k9104TgBPWw45whcLA 8qOKhszWhqHvPg9ui7SXfZBVMC/TCGk= X-Google-Smtp-Source: ABdhPJwsD/yScuz17u8KlZ3Xc2ada+5XekYNbNmUVrBYIwptDUCEBz5jOXFlbrT+gnJyM81hX9pn0A== X-Received: by 2002:a65:6a08:0:b0:374:4256:9ed8 with SMTP id m8-20020a656a08000000b0037442569ed8mr15331998pgu.79.1646009849260; Sun, 27 Feb 2022 16:57:29 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:6839:3c6:46aa:5d85]) by smtp.gmail.com with ESMTPSA id j1-20020a056a00130100b004df82ad0498sm10634610pfu.82.2022.02.27.16.57.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Feb 2022 16:57:29 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v3 1/4] cutils: Introduce bundle mechanism Date: Mon, 28 Feb 2022 09:57:06 +0900 Message-Id: <20220228005710.10442-2-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220228005710.10442-1-akihiko.odaki@gmail.com> References: <20220228005710.10442-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=akihiko.odaki@gmail.com; helo=mail-pg1-x52f.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Peter Maydell , Jason Wang , qemu-devel@nongnu.org, Programmingkid , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Gerd Hoffmann , Akihiko Odaki Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Developers often run QEMU without installing. The bundle mechanism allows to look up files which should be present in installation even in such a situation. It is a general mechanism and can find any files located relative to the installation tree. The build tree must have a new directory, qemu-bundle, to represent what files the installation tree would have for reference by the executables. Signed-off-by: Akihiko Odaki --- include/qemu/cutils.h | 19 +++++++++++++++++++ util/cutils.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 320543950c4..98ff59e38e3 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -209,6 +209,25 @@ int qemu_pstrcmp0(const char **str1, const char **str2); */ char *get_relocated_path(const char *dir); +/** + * find_bundle: + * @path: Relative path + * + * Returns a path for the specified directory or file bundled in QEMU. It uses + * the directory of the running executable as the prefix first. See + * get_relocated_path() for the details. The next candidate is "qemu-bundle" + * directory in the directory of the running executable. "qemu-bundle" + * directory is typically present in the build tree. + * + * The returned string should be freed by the caller. + * + * Returns: a path that can access the bundle, or NULL if no matching bundle + * exists. + */ +char *find_bundle(const char *path); + +void list_bundle_candidates(const char *path); + static inline const char *yes_no(bool b) { return b ? "yes" : "no"; diff --git a/util/cutils.c b/util/cutils.c index c9b91e7535a..b4e4cda71c8 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -1057,3 +1057,36 @@ char *get_relocated_path(const char *dir) } return g_string_free(result, false); } + +static const char * const bundle_formats[] = { + "%s" G_DIR_SEPARATOR_S ".." G_DIR_SEPARATOR_S "%s", + "%s" G_DIR_SEPARATOR_S "qemu-bundle" G_DIR_SEPARATOR_S "%s" +}; + +char *find_bundle(const char *path) +{ + const char *dir = qemu_get_exec_dir(); + char *candidate; + int i; + + for (i = 0; i < ARRAY_SIZE(bundle_formats); i++) { + candidate = g_strdup_printf(bundle_formats[i], dir, path); + if (access(candidate, R_OK) == 0) { + return candidate; + } + g_free(candidate); + } + + return NULL; +} + +void list_bundle_candidates(const char *path) +{ + const char *dir = qemu_get_exec_dir(); + int i; + + for (i = 0; i < ARRAY_SIZE(bundle_formats); i++) { + printf(bundle_formats[i], dir, path); + putc('\n', stdout); + } +} From patchwork Mon Feb 28 00:57:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12762268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57972C433EF for ; Mon, 28 Feb 2022 00:59:01 +0000 (UTC) Received: from localhost ([::1]:48530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOUNQ-0007bs-Cz for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 19:59:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOUMD-0005Rf-4j for qemu-devel@nongnu.org; Sun, 27 Feb 2022 19:57:45 -0500 Received: from [2607:f8b0:4864:20::433] (port=36833 helo=mail-pf1-x433.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOUM3-0004eQ-Pi for qemu-devel@nongnu.org; Sun, 27 Feb 2022 19:57:44 -0500 Received: by mail-pf1-x433.google.com with SMTP id z16so9600864pfh.3 for ; Sun, 27 Feb 2022 16:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jqOyJs8JXB+RFi0kH0Q1rdJYocA7grqj4zcYRIDA1W8=; b=iEqJ4YZ3sQS8RVCz/iRFKtfCH1RV/FS0igCxyZcm6uRRGHixnlqFaO2ZYdFBy1SAdY nl5VGmb2pRYLhpNZMSQhLk5w3PSIo+i73S+FkR0R7zH6QpJDAVT6yQ4rrbNrGG9JsTws N6SW5FCPClPYoEEl6o2D/EOHi+togHO/ZjoX/MFWk8JCc5LHBBJ/nnk3qX+oloUiegsB 4PyWCzpP+e/J6VBcjpjMF0XHdNch2JNpM2nekb6+Rb/O/NLEoRydntg0WO+ay9qbE7zf eXyfUQ+LDqeg0iYKkw45Y5kdxEiJLxuzXDoRTvNbLOLHENgpMX/sozdBgih4vSBX0rNr QAvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jqOyJs8JXB+RFi0kH0Q1rdJYocA7grqj4zcYRIDA1W8=; b=6QLR11UfTLri7Z1nSQ2PMFDY8hxORVFsbtF4jUNNsL68Cdhv10GWYqnSYCLb1RSkjN yYEdUhDptee4m5tF/3QJEfbqrwfWrYde+qdJNk0AAq2NuqeeJEBgmuilA+fFHb31d+pO WhMocMlH3PUPoizZxg/tjOuOIkNvNbXLLnVtzJnzKSoUe1o6/RqIucwKftFfuoqsTExY u3kvYcMQ5ZkDdHKQgZ0nZ3lW1CNtlDy/gy4iYIs5Y5u25OAUxLMHB9BNs/HHYfXlRD8k IZHpU83lQTaZ7QMFnqgjSEGAex0sLwJ+eW19ntPcWU1ZRZT2Cpn5cB+YhkU92dsbfKq2 jCuQ== X-Gm-Message-State: AOAM530GJhp4HnhCKiHlPZ6AdFwUTDnPOt3a8Y0X45WlupYw9Y0dGNN9 SfHWWcwTWFeSUv+x1uYeoaN44ZvGrQ4= X-Google-Smtp-Source: ABdhPJww7vaIKDYP5jUveR012AX7qrrQgnlIN9mT1xn2quDN7Hjtfq8lJL1VL5W65gBE7Ec+N/UyVw== X-Received: by 2002:a05:6a00:1251:b0:4f1:2a1:3073 with SMTP id u17-20020a056a00125100b004f102a13073mr18671168pfi.72.1646009854132; Sun, 27 Feb 2022 16:57:34 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:6839:3c6:46aa:5d85]) by smtp.gmail.com with ESMTPSA id j1-20020a056a00130100b004df82ad0498sm10634610pfu.82.2022.02.27.16.57.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Feb 2022 16:57:33 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v3 2/4] datadir: Use bundle mechanism Date: Mon, 28 Feb 2022 09:57:08 +0900 Message-Id: <20220228005710.10442-4-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220228005710.10442-1-akihiko.odaki@gmail.com> References: <20220228005710.10442-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::433 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=akihiko.odaki@gmail.com; helo=mail-pf1-x433.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Peter Maydell , Jason Wang , qemu-devel@nongnu.org, Programmingkid , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Gerd Hoffmann , Akihiko Odaki Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" softmmu/datadir.c had its own implementation to find files in the build tree, but now bundle mechanism provides the unified implementation which works for datadir and the other files. Signed-off-by: Akihiko Odaki --- configure | 2 ++ meson.build | 2 +- softmmu/datadir.c | 35 ++++++++++++----------------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/configure b/configure index c56ed53ee36..fda1a35cbc0 100755 --- a/configure +++ b/configure @@ -3089,6 +3089,8 @@ for f in $LINKS ; do fi done +symlink ../../pc-bios qemu-bundle/share/qemu + (for i in $cross_cc_vars; do export $i done diff --git a/meson.build b/meson.build index 8df40bfac4d..a2c987b41d6 100644 --- a/meson.build +++ b/meson.build @@ -1469,7 +1469,7 @@ endif config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir')) config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix')) config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir) -config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir) +config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_DATADIR', qemu_datadir) config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir) config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath')) config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) diff --git a/softmmu/datadir.c b/softmmu/datadir.c index 504c4665bed..2d8366039d9 100644 --- a/softmmu/datadir.c +++ b/softmmu/datadir.c @@ -36,6 +36,7 @@ char *qemu_find_file(int type, const char *name) int i; const char *subdir; char *buf; + char *bundle; /* Try the name as a straight path first */ if (access(name, R_OK) == 0) { @@ -62,6 +63,16 @@ char *qemu_find_file(int type, const char *name) } g_free(buf); } + + bundle = g_strdup_printf("%s/%s%s", + CONFIG_QEMU_BUNDLE_DATADIR, subdir, name); + buf = find_bundle(bundle); + g_free(bundle); + if (buf) { + trace_load_file(name, buf); + return buf; + } + return NULL; } @@ -84,26 +95,6 @@ void qemu_add_data_dir(char *path) data_dir[data_dir_idx++] = path; } -/* - * Find a likely location for support files using the location of the binary. - * When running from the build tree this will be "$bindir/pc-bios". - * Otherwise, this is CONFIG_QEMU_DATADIR (possibly relocated). - * - * The caller must use g_free() to free the returned data when it is - * no longer required. - */ -static char *find_datadir(void) -{ - g_autofree char *dir = NULL; - - dir = g_build_filename(qemu_get_exec_dir(), "pc-bios", NULL); - if (g_file_test(dir, G_FILE_TEST_IS_DIR)) { - return g_steal_pointer(&dir); - } - - return get_relocated_path(CONFIG_QEMU_DATADIR); -} - void qemu_add_default_firmwarepath(void) { char **dirs; @@ -115,9 +106,6 @@ void qemu_add_default_firmwarepath(void) qemu_add_data_dir(get_relocated_path(dirs[i])); } g_strfreev(dirs); - - /* try to find datadir relative to the executable path */ - qemu_add_data_dir(find_datadir()); } void qemu_list_data_dirs(void) @@ -126,4 +114,5 @@ void qemu_list_data_dirs(void) for (i = 0; i < data_dir_idx; i++) { printf("%s\n", data_dir[i]); } + list_bundle_candidates(CONFIG_QEMU_BUNDLE_DATADIR); } From patchwork Mon Feb 28 00:57:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12762269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DC96C433EF for ; Mon, 28 Feb 2022 01:01:06 +0000 (UTC) Received: from localhost ([::1]:53074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOUPR-0002Mh-5m for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 20:01:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOUM7-0005En-NW for qemu-devel@nongnu.org; Sun, 27 Feb 2022 19:57:39 -0500 Received: from [2607:f8b0:4864:20::429] (port=45743 helo=mail-pf1-x429.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOUM5-0004eY-MO for qemu-devel@nongnu.org; Sun, 27 Feb 2022 19:57:39 -0500 Received: by mail-pf1-x429.google.com with SMTP id u16so9556605pfg.12 for ; Sun, 27 Feb 2022 16:57:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dPuzGEBcEqdlsA6JeaKEgUYjkg87ycyuZGvU6x1HEk4=; b=a9fay6rFs2atTUwR28jt/JypWaOEuZKbbEO59GmIhtaUwJIdk57j6XoaIXyvUMLfib AXjCzTaiDeZmd2sjwx5hcgHFcwFY7KhtzjwmT7kaQa7grHDvzZ0cVwqnJB8b+ATN9Hse lCgVSAyyMKUduG4sWcwJCILzp/YveIDTyok59MyKA8Q/GlPzRaBIc2jV3jXmsKBt0UIS DQyNGceyGFhuDT/Z5Jada8Cx0ybey0LtQWhqwalROQPq1LxBiZ4IayEIPC+OBdDRKcP0 J0LUNEBSVxeiIo3G9nAQQ4vyh8+WAA7fBhZ/ZsbtWcGzpR8AT/mWAeP8XemQqmoGVwzc 1B0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dPuzGEBcEqdlsA6JeaKEgUYjkg87ycyuZGvU6x1HEk4=; b=dwqHJZkBfIMSh+6aTXLXyOe+nIo51EVJRSxBoT8sp4ydXsMBTUnktCO+4497h82AI1 oA11ko1DuJNH/HspRsl21FmYsuDY1Lhdv7i5EfsL/YyZJUHlocF/RqXEtRNmmHzEzm+4 AatAovApPAam7Ze803FjFVSuW43GK730UcJgI7YH0+pxUwyw0kOKtmKwwLVFO724Qk/j CYkD704Q7m9v9EyNcFb2aDxqP2ah2G7BoG8SgF3/Sy4AyB/gZPfAx17bb0M+zHuYCVN3 wGDUryPJgZt5oeXizSr42GHfKHgrXR0DcUBFQk08ZOs8NOEudxkqcylDBWs48MzHkRhX K3eg== X-Gm-Message-State: AOAM530lV/wEsmySKqa2BcUCaiVrxsk1nxo7truHUYXiMkiYrhglxLdN MB3ztS0lG9KH+rwhfXlEAaC6LTn2FQc= X-Google-Smtp-Source: ABdhPJwGLyn3PI9cVDqcnDWNLdbeOo1enxJRFix4OdzIedKfk37Q/jrzkdG1TDEbjN86Efk8fwe+Cw== X-Received: by 2002:a63:2c91:0:b0:373:7200:d079 with SMTP id s139-20020a632c91000000b003737200d079mr15328518pgs.65.1646009856334; Sun, 27 Feb 2022 16:57:36 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:6839:3c6:46aa:5d85]) by smtp.gmail.com with ESMTPSA id j1-20020a056a00130100b004df82ad0498sm10634610pfu.82.2022.02.27.16.57.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Feb 2022 16:57:36 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v3 3/4] ui/icons: Use bundle mechanism Date: Mon, 28 Feb 2022 09:57:09 +0900 Message-Id: <20220228005710.10442-5-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220228005710.10442-1-akihiko.odaki@gmail.com> References: <20220228005710.10442-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::429 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=akihiko.odaki@gmail.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Peter Maydell , Jason Wang , qemu-devel@nongnu.org, Programmingkid , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Gerd Hoffmann , Akihiko Odaki Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Akihiko Odaki --- configure | 10 ++++++++++ meson.build | 3 +-- ui/cocoa.m | 20 +++++++++++--------- ui/gtk.c | 8 +++++--- ui/sdl2.c | 18 +++++++++++------- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/configure b/configure index fda1a35cbc0..80d36a85bc5 100755 --- a/configure +++ b/configure @@ -3089,6 +3089,16 @@ for f in $LINKS ; do fi done +for icon_extension in bmp png ; do + for icon_file in $source_path/ui/icons/qemu_*.$icon_extension ; do + icon_basename=${icon_file%.$icon_extension} + icon_name=${icon_basename#$source_path/ui/icons/qemu_} + icon_dir=qemu-bundle/share/icons/hicolor/$icon_name/apps + symlink $icon_file $icon_dir/qemu.$icon_extension + done +done + +symlink $source_path/ui/icons/qemu.svg qemu-bundle/share/icons/hicolor/scalable/apps/qemu.svg symlink ../../pc-bios qemu-bundle/share/qemu (for i in $cross_cc_vars; do diff --git a/meson.build b/meson.build index a2c987b41d6..f7e64a74545 100644 --- a/meson.build +++ b/meson.build @@ -1472,8 +1472,7 @@ config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_c config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_DATADIR', qemu_datadir) config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir) config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath')) -config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) -config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir) +config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_ICONDIR', qemu_icondir) config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir')) config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir')) config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir) diff --git a/ui/cocoa.m b/ui/cocoa.m index a8f1cdaf926..e5e49c50fbb 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1477,15 +1477,17 @@ - (void)make_about_window NSRect picture_rect = NSMakeRect(x, y, picture_width, picture_height); /* Make the picture of QEMU */ - NSImageView *picture_view = [[NSImageView alloc] initWithFrame: - picture_rect]; - char *qemu_image_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png"); - NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c]; - g_free(qemu_image_path_c); - NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path]; - [picture_view setImage: qemu_image]; - [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown]; - [superView addSubview: picture_view]; + char *qemu_image_path_c = find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor/512x512/apps/qemu.png"); + if (qemu_image_path_c) { + NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c]; + g_free(qemu_image_path_c); + NSImageView *picture_view = [[NSImageView alloc] initWithFrame: + picture_rect]; + NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path]; + [picture_view setImage: qemu_image]; + [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown]; + [superView addSubview: picture_view]; + } /* Make the name label */ NSBundle *bundle = [NSBundle mainBundle]; diff --git a/ui/gtk.c b/ui/gtk.c index a8567b9ddc8..a86d1c126f0 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2296,9 +2296,11 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) s->opts = opts; theme = gtk_icon_theme_get_default(); - dir = get_relocated_path(CONFIG_QEMU_ICONDIR); - gtk_icon_theme_prepend_search_path(theme, dir); - g_free(dir); + dir = find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR); + if (dir) { + gtk_icon_theme_prepend_search_path(theme, dir); + g_free(dir); + } g_set_prgname("qemu"); s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); diff --git a/ui/sdl2.c b/ui/sdl2.c index 46a252d7d9d..9d1f6e74cb5 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -893,15 +893,19 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o) } #ifdef CONFIG_SDL_IMAGE - dir = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png"); - icon = IMG_Load(dir); + dir = find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor/128x128/apps/qemu.png"); + if (dir) { + icon = IMG_Load(dir); + } #else /* Load a 32x32x4 image. White pixels are transparent. */ - dir = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp"); - icon = SDL_LoadBMP(dir); - if (icon) { - uint32_t colorkey = SDL_MapRGB(icon->format, 255, 255, 255); - SDL_SetColorKey(icon, SDL_TRUE, colorkey); + dir = find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor/32x32/apps/qemu.bmp"); + if (dir) { + icon = SDL_LoadBMP(dir); + if (icon) { + uint32_t colorkey = SDL_MapRGB(icon->format, 255, 255, 255); + SDL_SetColorKey(icon, SDL_TRUE, colorkey); + } } #endif g_free(dir); From patchwork Mon Feb 28 00:57:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12762271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FF20C433EF for ; Mon, 28 Feb 2022 01:03:33 +0000 (UTC) Received: from localhost ([::1]:59132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOURo-0006cR-Ik for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 20:03:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOUMA-0005Li-Ap for qemu-devel@nongnu.org; Sun, 27 Feb 2022 19:57:42 -0500 Received: from [2607:f8b0:4864:20::102b] (port=56084 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOUM7-0004ev-VN for qemu-devel@nongnu.org; Sun, 27 Feb 2022 19:57:41 -0500 Received: by mail-pj1-x102b.google.com with SMTP id gb21so9679674pjb.5 for ; Sun, 27 Feb 2022 16:57:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o3yYCKAK4PyDr13xPU5WQLsZEQoxfNSDnsUZjZq2iaU=; b=Ya52YTASGIjYLFKIAsiAIZpBbfpLxJhaqumJfuvOsgNQMBEviQZ9wVeaskv6rW8M4G 5VVB2aZZVb4wVO7IWkcpED3kpKPw1vXEkX/8QStJVrGVqS0IpSYkPDotqEK+d+MAfavp +SmdNfV6qp52jFI1yeK5F8wSrv8P2mJMNHV9SdVi76HnN/hR/b0L8eYdXOGKvJ3cn9km +2qQbf7PU0QgDtSpPGKDawNZDCptN6Ss6z8pU6LH+m/8VxEIz75O5VH2ISDT12Czb514 xBm9+ukSOaac5c/T3EhAwIJo9Jeczy8Ew/LXQzWYV2s4V+0QRZNvY2RNH7g1QD7jp2qV z2sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o3yYCKAK4PyDr13xPU5WQLsZEQoxfNSDnsUZjZq2iaU=; b=3Mr3Lq1ytZeWaUvy7pc5f2JJp1tmH0JcsWFBe3va++yYGV7Y70R1haGS/0gM+pTPng 1mNRXlAu7psdwVGEYdn3gqVwD+3+tuiGWLQ00pciFIjjyqWkRhwCyKXX3QeVNBqd7U0T u3B/m5mpRHyPjX82eRNNx3gwYIDBi49T5cSvdfWUvEbPPSbITrlvwXeVgHcbtNMDfEcm Xs2uFVTIBjdHdOH116Q3yvl6m6F6ta0YuuQQkbde3+rFELzJlQe6ZXZ0mN0HojaHfR7d UU5g6T5ZhuLVt37ncbnwIa45NF7cjpV7enbQUrf888Kt+ilJMiF6zzdjO3ot+2ldu9pd PjKQ== X-Gm-Message-State: AOAM5337M+z5iqsdNOzU/rVXmJG1kVG8JLra93/V/TYDB7T3WycPsQSQ Mc5EDNGXbHn8NJ+ndgh01jwsNwrCCd4= X-Google-Smtp-Source: ABdhPJwAHkMgy/bxldgAJFLOZkzVRvqL3m7Uf/QexVVgkLt+229SOh+MFrw+E8zMskAxbOXrW+SjdA== X-Received: by 2002:a17:90a:ab93:b0:1b8:831d:2ee4 with SMTP id n19-20020a17090aab9300b001b8831d2ee4mr14052734pjq.123.1646009858504; Sun, 27 Feb 2022 16:57:38 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:6839:3c6:46aa:5d85]) by smtp.gmail.com with ESMTPSA id j1-20020a056a00130100b004df82ad0498sm10634610pfu.82.2022.02.27.16.57.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Feb 2022 16:57:38 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v3 4/4] net: Use bundle mechanism Date: Mon, 28 Feb 2022 09:57:10 +0900 Message-Id: <20220228005710.10442-6-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220228005710.10442-1-akihiko.odaki@gmail.com> References: <20220228005710.10442-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x102b.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Peter Maydell , Jason Wang , qemu-devel@nongnu.org, Programmingkid , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Gerd Hoffmann , Akihiko Odaki Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Akihiko Odaki --- configure | 1 + include/net/net.h | 2 +- meson.build | 1 + net/tap.c | 6 +++++- qemu-options.hx | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 80d36a85bc5..63df8f5886e 100755 --- a/configure +++ b/configure @@ -3100,6 +3100,7 @@ done symlink $source_path/ui/icons/qemu.svg qemu-bundle/share/icons/hicolor/scalable/apps/qemu.svg symlink ../../pc-bios qemu-bundle/share/qemu +symlink ../../qemu-bridge-helper qemu-bundle/libexec/qemu-bridge-helper (for i in $cross_cc_vars; do export $i diff --git a/include/net/net.h b/include/net/net.h index 523136c7acb..4a5ed27a4b7 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -228,7 +228,7 @@ NetClientState *net_hub_port_find(int hub_id); #define DEFAULT_NETWORK_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifup" #define DEFAULT_NETWORK_DOWN_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifdown" -#define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper" +#define DEFAULT_BUNDLE_BRIDGE_HELPER CONFIG_QEMU_BUNDLE_HELPERDIR "/qemu-bridge-helper" #define DEFAULT_BRIDGE_INTERFACE "br0" void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); diff --git a/meson.build b/meson.build index f7e64a74545..95ee0a7c14e 100644 --- a/meson.build +++ b/meson.build @@ -1472,6 +1472,7 @@ config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_c config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_DATADIR', qemu_datadir) config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir) config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath')) +config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_HELPERDIR', get_option('libexecdir')) config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_ICONDIR', qemu_icondir) config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir')) config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir')) diff --git a/net/tap.c b/net/tap.c index c5cbeaa7a2b..91415cd376c 100644 --- a/net/tap.c +++ b/net/tap.c @@ -508,7 +508,11 @@ static int net_bridge_run_helper(const char *helper, const char *bridge, sigprocmask(SIG_BLOCK, &mask, &oldmask); if (!helper) { - helper = default_helper = get_relocated_path(DEFAULT_BRIDGE_HELPER); + helper = default_helper = find_bundle(DEFAULT_BUNDLE_BRIDGE_HELPER); + if (!helper) { + error_setg(errp, "bridge helper not found"); + return -1; + } } if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) { diff --git a/qemu-options.hx b/qemu-options.hx index 094a6c1d7c2..a5c03e2caf3 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2665,7 +2665,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n" " to deconfigure it\n" " use '[down]script=no' to disable script execution\n" - " use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n" + " use network helper 'helper' (default=" DEFAULT_BUNDLE_BRIDGE_HELPER ") to\n" " configure it\n" " use 'fd=h' to connect to an already opened TAP interface\n" " use 'fds=x:y:...:z' to connect to already opened multiqueue capable TAP interfaces\n" @@ -2684,7 +2684,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, "-netdev bridge,id=str[,br=bridge][,helper=helper]\n" " configure a host TAP network backend with ID 'str' that is\n" " connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n" - " using the program 'helper (default=" DEFAULT_BRIDGE_HELPER ")\n" + " using the program 'helper (default=" DEFAULT_BUNDLE_BRIDGE_HELPER ")\n" #endif #ifdef __linux__ "-netdev l2tpv3,id=str,src=srcaddr,dst=dstaddr[,srcport=srcport][,dstport=dstport]\n"