From patchwork Sat Feb 26 12:45:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12761301 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 CB924C433FE for ; Sat, 26 Feb 2022 12:52:55 +0000 (UTC) Received: from localhost ([::1]:32982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNwZC-0002td-7G for qemu-devel@archiver.kernel.org; Sat, 26 Feb 2022 07:52:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNwSM-0001Pa-SW for qemu-devel@nongnu.org; Sat, 26 Feb 2022 07:45:50 -0500 Received: from [2607:f8b0:4864:20::1034] (port=39581 helo=mail-pj1-x1034.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nNwSK-0003KN-IT for qemu-devel@nongnu.org; Sat, 26 Feb 2022 07:45:50 -0500 Received: by mail-pj1-x1034.google.com with SMTP id h17-20020a17090acf1100b001bc68ecce4aso10754175pju.4 for ; Sat, 26 Feb 2022 04:45:48 -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=2TxLC9fYa4dsSXt2w85XmJ89x3QqEVRdv+e2nZt/7lg=; b=olesjjnq4KZlzXPtT9YV486okFXbJ0rqGS2v1SlFea6rrOQQ/OrUbOewPZM8Eo8inY Yt38iEjxGBwbGZ1Pc+dFJ5F6lO0fEHqcwevL2qsKeazsV3xnT0jAFQLuX1QXO0p2C7cu V+W+UERDX5xpcCjfu4u3Yc1Mdl75m9ijE/ci3UXQqCFcvUQkgtQub2plVNRcvzFvbMTc wYuFQ6CYla5ex0kr6Y5AsC9Y+lG1LuWdUNhgZOBBL6QGZaOP3suLqhDToVWcb8SnVbDA yqe6MM6eu9SUe/D3tALj+yfdih0mRENyRpxxlGQ1yEZvqbwQRRflD6f+hfyuyejPnP32 F6Ag== 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=2TxLC9fYa4dsSXt2w85XmJ89x3QqEVRdv+e2nZt/7lg=; b=LjwOl1CvFE6kzLQdki3fVC7oZsj7mBcIsM9fKgF65uI3uyZ3zvCmVc9naFYhzuVa2Q ocAQLMwUOQVOPzILXSpgGhjdW61Na/PJ2KhH3A5hsT3ecxG5MXRw1OyZTk1qcp5K056m UtH0wst5B6WgOQ4wnDqvEHqdWbXCoWuVtdTJnxhWkH4+FazGVjzz4xvVJuD8cCSRlLH/ 6ilfKNDGBUrGSE+7BUpR/Mb9WLQKAqyW25DbSxAybWDuDBPjCpHiu52WD8a+hltPmROJ POD89vJBPAvGZKV2QauLzdN3t7wh+ZxXCiYERJ/BpSumIZOKr7paQBK5iuATPN3kBZG/ QjAg== X-Gm-Message-State: AOAM531Ir8H7syD1sznuwvWyn9ooqlDmSC3S8YfNRiLu3z2eRNJCbFhk W2CqK6hXv9VhXNyz0eeYGhAyt4nokQY= X-Google-Smtp-Source: ABdhPJwtExKSg7KSKyVetcc9qanIXCKb/54ATwpcP90OF/lzAVNZg9eyMt6KgHaKKzZLQS//IyINNw== X-Received: by 2002:a17:902:d4c6:b0:150:15ed:3cd9 with SMTP id o6-20020a170902d4c600b0015015ed3cd9mr11358404plg.2.1645879547009; Sat, 26 Feb 2022 04:45:47 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:4c8a:825a:fb9a:12f3]) by smtp.gmail.com with ESMTPSA id r4-20020a17090a438400b001bc6d52de70sm11725653pjg.24.2022.02.26.04.45.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 26 Feb 2022 04:45:46 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v2 1/4] cutils: Introduce bundle mechanism Date: Sat, 26 Feb 2022 21:45:32 +0900 Message-Id: <20220226124535.76885-2-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220226124535.76885-1-akihiko.odaki@gmail.com> References: <20220226124535.76885-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1034 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x1034.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 , 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. 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 Sat Feb 26 12:45:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12761305 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 B461AC433F5 for ; Sat, 26 Feb 2022 12:56:27 +0000 (UTC) Received: from localhost ([::1]:38994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNwcc-0007DW-Gb for qemu-devel@archiver.kernel.org; Sat, 26 Feb 2022 07:56:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNwSP-0001Pm-37 for qemu-devel@nongnu.org; Sat, 26 Feb 2022 07:45:55 -0500 Received: from [2607:f8b0:4864:20::1035] (port=42809 helo=mail-pj1-x1035.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nNwSM-0003KZ-Rs for qemu-devel@nongnu.org; Sat, 26 Feb 2022 07:45:52 -0500 Received: by mail-pj1-x1035.google.com with SMTP id q8-20020a17090a178800b001bc299b8de1so7263178pja.1 for ; Sat, 26 Feb 2022 04:45:50 -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=/9mK1xO4TByeuzuYFvQ7V+Fn6OHDRjXWjpXpK7eIeg4=; b=Z9LabU0D8yS8qzmk6hdDXBWI39wAFMRoAbtFejBa1qi1VBGyDuCOADdtGiOY7qnqA2 DGPWvK76EQZQkHO2+Q5/C4K0Ne0u4m8yAZ82Cm189nmvuqJAWV0AF0Ck+VJH4hb8MCVX sajVVkof+DtEJl5IESAJYqzGJDowYuExLoCsMPj8oNUC5lTW3xjR0vF2Vuvcg/g1eMcT bnzB3nbZXwXF42ezlLlgOSky/vlc93M6Cvk25JIEOyhu18SXKxTSvp7ZeoLrzkdzHOQW rjCK2PrbfdFKMz0/07jw7eFWBH1cfPyKOd97l99FC+AvqRV19EdgN2Av1wI40oObxmvc zV4A== 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=/9mK1xO4TByeuzuYFvQ7V+Fn6OHDRjXWjpXpK7eIeg4=; b=ST9RjWf2fZPsCnbr14txTTzS8wwa1RqQVOoa9l9VXadiK8jbqepPmni3gBCe7u9M6R wwU61z0eaXoMjZafcxzooJ0m7qOup4rMPwBf1Io/SBxwZnGk0Q/XClS+/AmrxYPmAeXy MIcU8xPmAsVnYTbpqlJE215fKJKsFx1VYFIAIw/gyd6ml9AaFiOqelTCgGI+gsRc/OCW U/y1B9cjIV76wY0nFREs36ELt66qkkmxWega1KJ1J67wS2UVlKAPUJkwHH1HvsJWE5zV 2ZJs/Qe7UPA0lpVnvMAdnfSOzdivmrn8Ipo948CBmfhxszwDHtRyldeM+VOZ4XWHqWo8 NKaQ== X-Gm-Message-State: AOAM530LzBzeBZPFaadTEWObKVYRDzNIbeTJrPOhuc5+uxVIeoKs9FSy sEP0o3f5v+OIzvbFKejuxt0U/sNTdfE= X-Google-Smtp-Source: ABdhPJxe/hIR0oH5w8sHOP709Z74sanIrfdUiZ2TWDSs6i2P8T/L6Dyg5G/Ab5RF6fa2MzwzboUqOw== X-Received: by 2002:a17:902:ccce:b0:14e:ed3f:e3a1 with SMTP id z14-20020a170902ccce00b0014eed3fe3a1mr12021451ple.12.1645879549277; Sat, 26 Feb 2022 04:45:49 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:4c8a:825a:fb9a:12f3]) by smtp.gmail.com with ESMTPSA id r4-20020a17090a438400b001bc6d52de70sm11725653pjg.24.2022.02.26.04.45.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 26 Feb 2022 04:45:49 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v2 2/4] datadir: Use bundle mechanism Date: Sat, 26 Feb 2022 21:45:33 +0900 Message-Id: <20220226124535.76885-3-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220226124535.76885-1-akihiko.odaki@gmail.com> References: <20220226124535.76885-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1035 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x1035.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 , Gerd Hoffmann , Akihiko Odaki Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" bundle mechanism and softmmu/datadir.c provides some overlapped functionality. Use bundle mechanism in softmmu/datadir.c to remove the redundancy. 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 Sat Feb 26 12:45:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12761307 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 0C0A3C433EF for ; Sat, 26 Feb 2022 12:58:56 +0000 (UTC) Received: from localhost ([::1]:44708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNwf1-0002fi-M9 for qemu-devel@archiver.kernel.org; Sat, 26 Feb 2022 07:58:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNwSS-0001Pn-3O for qemu-devel@nongnu.org; Sat, 26 Feb 2022 07:45:57 -0500 Received: from [2607:f8b0:4864:20::52b] (port=37556 helo=mail-pg1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nNwSO-0003Kk-SO for qemu-devel@nongnu.org; Sat, 26 Feb 2022 07:45:54 -0500 Received: by mail-pg1-x52b.google.com with SMTP id 75so7218795pgb.4 for ; Sat, 26 Feb 2022 04:45:52 -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=mWe5MLSC4VGeBzNy9WiMp6e6+eXir4Z8lxuHUM5L0NFRP5rg9c33TAVmJzXUVc+ZN8 XzMH0eJ160TS0TqTOw3OvmTjF+12aO/dzD9BC0PSCH24rKyBwYX6yEWuPn6HCwQu6T+3 Ept/yLXwG6WIzb5ZQOa2Xk4S3mdbOPVIaRL94gBr4rMS0xwHwBeh8mzqYrqnTMIs95t2 pRysxKowcfAtfN7EVUL9xRde66ztEONLgFvj21ZSJhx51mYi6MwK5Ddk+S25SImehrpQ RT5xsYsjMnpKmWhA7OO1qHoO4g1TXI8xtDJu2Sh/mF/lqkrNNUXvyQ1X30YTVZnqXGyl YBSQ== 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=SkuLzJsVdYbQwrGpzjREyVOZqQEj3ZqkhDHrFQYOzGVsekrOm9Q7IXWIfNKN9dHvN4 gKsq5FPJMPnlpNKFvHQXZ5gkKgwd4WSgFGtyx+DW3lCK3C0PNQHCj8y2G0XsIn+kPM1x KeAJlKS92p23jjQHtIuml/La5rJI8YHv5Ja+6RR7H7+KEI2EhCpgg4YxsmaKe81iCEoC wso1hdqkfS3M3qfVuDN8MIuRekMvdsoV4PDwGE66smTs05951mvZ91vAHoEz1Jg3twTi Yw5eMcDTLyq5cqWLXPH6i9e211Urx0DwsM12HaLSx9HXEa4ARX5uIkAQv+l0QPx1Ra+2 /E6w== X-Gm-Message-State: AOAM5337eruiAqxpG3Fi63Q4teay+yMitm+AWrgPkQBADyK+lCc96z+U 81FEq6LIe9hXTMROUPRF2rPSkP4YunM= X-Google-Smtp-Source: ABdhPJzeydso1j03mr5yIkRSakuJIKhU2TXzNx5Yb0tOwlWa1ifyA05b4QFL+RHkRtimYhM4P7ZviQ== X-Received: by 2002:a05:6a00:24c4:b0:4cb:7324:bfd with SMTP id d4-20020a056a0024c400b004cb73240bfdmr12656895pfv.60.1645879551513; Sat, 26 Feb 2022 04:45:51 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:4c8a:825a:fb9a:12f3]) by smtp.gmail.com with ESMTPSA id r4-20020a17090a438400b001bc6d52de70sm11725653pjg.24.2022.02.26.04.45.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 26 Feb 2022 04:45:51 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v2 3/4] ui/icons: Use bundle mechanism Date: Sat, 26 Feb 2022 21:45:34 +0900 Message-Id: <20220226124535.76885-4-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220226124535.76885-1-akihiko.odaki@gmail.com> References: <20220226124535.76885-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=akihiko.odaki@gmail.com; helo=mail-pg1-x52b.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 , 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 Sat Feb 26 12:45:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12761308 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 084CAC433F5 for ; Sat, 26 Feb 2022 13:01:47 +0000 (UTC) Received: from localhost ([::1]:47760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNwhl-0004k7-U1 for qemu-devel@archiver.kernel.org; Sat, 26 Feb 2022 08:01:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNwSU-0001QC-De for qemu-devel@nongnu.org; Sat, 26 Feb 2022 07:46:02 -0500 Received: from [2607:f8b0:4864:20::62c] (port=35809 helo=mail-pl1-x62c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nNwSR-0003Ku-Rn for qemu-devel@nongnu.org; Sat, 26 Feb 2022 07:45:57 -0500 Received: by mail-pl1-x62c.google.com with SMTP id i1so6989248plr.2 for ; Sat, 26 Feb 2022 04:45:54 -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=5RcX9KNvZOz10vLgkZvfBQaI33Kp2lfBYnofxB3uzVI=; b=Z79MmeE+aAjLYAOaXJobzlMemKMNFqBgiH51ZeCoUfEMqnq8+aejtUFjV2FWvEWdL6 n6k9+Y4PpWlO6Qc57RGzScpmXmx8hOMpX3wWbs7bOdW5XI2RNH2uZjAKrBcHMPOLl/8F emADkccSmJxjfqN0y/Wc7KUPEcMAJEilt/rkUeP/Gbd1m1P/COOfPjWtw4+L8yvhckYc I7I+DqZs57mVy2S4OP7G+CnXGbVGe+IFCEYLKencdyZgZU1Lh5Magp89TDz0RFYkyX/t HGsMWyhdyDryeqQmEyNLvtv7mZvgnQUmsw6kzh1titWNBi0eEHhAsEduv+I9PTfTJltq zqmg== 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=5RcX9KNvZOz10vLgkZvfBQaI33Kp2lfBYnofxB3uzVI=; b=50JdHSsfKiWY7PVZvca39MxsPQ1J79boYAIMtG+oxaEEc0s3QoZpgHPlboHsELKq77 GtRE/U3NahQL4NwqwmxYgNz1Gkn3FBT7DoQoMcViF7n9KnoQe1MrOvKQX1+4n1Ffrcb9 7wFfxRgwwbRytF9Gx2envFaHwDPbL0Nud2FKPs7a+I99Gdr6Y99JdRFNznlzjeRpVrb7 ibG80hfbPMSuxkjSpQ+AkvcpX6hqvBlGxC2P3dTdYcF8P+gAeDmx2H9P3tOIaoc2/aAR NG2hooPrDojGaw7mjdJTl9MCss9xdipu2K/CoMVFKrHrvg9SdQyofRZDTE5FPoWzU3qZ vRIw== X-Gm-Message-State: AOAM533CPL1QIseR8Vjv2GQVxH/NZezDysV3nwAULN2RXoYB81LATIsw XyFsG+5hOAmkyL8+UfRsNnm64NmLoUs= X-Google-Smtp-Source: ABdhPJwDWoPhfq2+8gE2tTbLQO7xBYai6EkDs5RBGLlvrvJOVzJM1TayVZeY2pJ04tFGbLCPN0kcKg== X-Received: by 2002:a17:90b:2496:b0:1b9:a6dd:ae7 with SMTP id nt22-20020a17090b249600b001b9a6dd0ae7mr7760798pjb.35.1645879553799; Sat, 26 Feb 2022 04:45:53 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:4c8a:825a:fb9a:12f3]) by smtp.gmail.com with ESMTPSA id r4-20020a17090a438400b001bc6d52de70sm11725653pjg.24.2022.02.26.04.45.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 26 Feb 2022 04:45:53 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH v2 4/4] net: Use bundle mechanism Date: Sat, 26 Feb 2022 21:45:35 +0900 Message-Id: <20220226124535.76885-5-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220226124535.76885-1-akihiko.odaki@gmail.com> References: <20220226124535.76885-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=akihiko.odaki@gmail.com; helo=mail-pl1-x62c.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 , 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..3225d91ae00 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, "birdge 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"