From nobody Sat Sep 21 03:25:30 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1655240981; cv=none; d=zohomail.com; s=zohoarc; b=HBtU5LzgyC6GHzrUyYAZYotjzr3s8NKr7xwWg/JwItwKaiPHYiPknGQOCP86CovDjyKG3wMSp7lX2cV1XRS1M4fU8GIagzHGT6awC/NvYJMG25PnTrrbsTI6OBDrvN8mIXi9Hrp96U590lcdaXFH2Lgk5INRyl5w5iAJv5JzFa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655240981; h=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; bh=0JDPtmJtIBq1IHFDsbna1CTcRo1CbVD+DG/jmYsEX1A=; b=EDsAhwHJQ9c6gfCEWedo1isp/l8VbslP4B9JRQ/dHh0VuMHtNx8ENdTWx1naLOp29VU6iPXJykLw562ij+ddxRCtdFVJOW9+q7gSkLchFcAe4Y15ioXa4xSxsGgycdrFquEBHe024uOfqwn27qd7XGVacRTWIKbIqJo9QipOAw0= 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 1655240981184258.3326163448554; Tue, 14 Jun 2022 14:09:41 -0700 (PDT) Received: from localhost ([::1]:42612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1Dn9-0007p5-2e for importer@patchew.org; Tue, 14 Jun 2022 17:09:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1Dla-0005IX-Ds for qemu-devel@nongnu.org; Tue, 14 Jun 2022 17:08:02 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:46875) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1DlY-0007kb-Ud for qemu-devel@nongnu.org; Tue, 14 Jun 2022 17:08:02 -0400 Received: by mail-pl1-x632.google.com with SMTP id d13so8737083plh.13 for ; Tue, 14 Jun 2022 14:08:00 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:d5aa:1806:cce3:7773]) by smtp.gmail.com with ESMTPSA id h65-20020a62de44000000b0050dc762813csm8129456pfg.22.2022.06.14.14.07.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Jun 2022 14:07:59 -0700 (PDT) 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=0JDPtmJtIBq1IHFDsbna1CTcRo1CbVD+DG/jmYsEX1A=; b=EA0godP1b4Tm08b37VG0elunUpOGXYeqzFI84sua/vNBTI8pNVn0jU5KcLeirugqMZ dabvjAyXd1i764vQABiINsNFTOLBXjo1+pSlueBi+wwvtjv+egOKlA6AAKM6ADheZv1h NwCaPJQJmMqmMcDRduSByC0ArZxVmRmb4v3ghrJuHIY1NIWr3Te70DSC6CUffAeN16f5 SYhjLtg4W6KRMNxRvqhjc7ajYcJCZOptZMWLZPJ2NAzTcBSCgw3yqfqzJiVYh+fmfEw3 hBLpmWBIrzwsJmejMm2W7GHOqfqaCL0gJhVV6dorpLILn9nLiNUIFzsasWblKtOvrTmb rxfw== 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=0JDPtmJtIBq1IHFDsbna1CTcRo1CbVD+DG/jmYsEX1A=; b=gU0Tk/UBq9wzJ5lTATTYwkhMdD71+7SFVLB+Z3NWxQVWsSnqnLJUtsSHo2hHQyen0/ WN30OgysqM7j6kmqWPb8xQb24Px5bKNvuhwaHxY8ojK4fbDcaRELT44AgchJGWlInq2o crQsahZWhS09JAG5jqmoTFMX2hyhHMj8xrxEY0yCEuXzh5slK7Il6aiD4ck+tfUL0prh Has63MxL/7M5TL52YM8gcaBVHcDfZvQQu3QXhzyP9a3cDLVhDyAHFN6ndLiPpgjth3ps UnI8f3h+mSp0Dfj08Vi+K1jAGalT8Ah5UwcaPvWxCneNn6sy+qVl8NEocwRooVY/CqtD 9KyQ== X-Gm-Message-State: AJIora8YTb9/FF1MjKUEa5c6JY/J/UGZ+mahX6e/DcOKEoLmIW+ezHOH drYUGAPgHIyaCCAb2RamwcI= X-Google-Smtp-Source: AGRyM1sXilXxho3kVmcDLIVph5xvX+Vi8Wob6AEkZTN8IZg6x/rtaQQ0MY78fj1svrHhDSe6+1SFEQ== X-Received: by 2002:a17:90a:a002:b0:1e8:6ea3:849c with SMTP id q2-20020a17090aa00200b001e86ea3849cmr6408363pjp.179.1655240879670; Tue, 14 Jun 2022 14:07:59 -0700 (PDT) From: Akihiko Odaki To: Cc: Peter Maydell , Jason Wang , qemu-devel@nongnu.org, Programmingkid , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Akihiko Odaki Subject: [PATCH v4 1/4] cutils: Introduce bundle mechanism Date: Wed, 15 Jun 2022 06:07:43 +0900 Message-Id: <20220614210746.78911-2-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220614210746.78911-1-akihiko.odaki@gmail.com> References: <20220614210746.78911-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::632; envelope-from=akihiko.odaki@gmail.com; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1655240983027100001 Content-Type: text/plain; charset="utf-8" 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 40e10e19a7e..3b66026cd3c 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -213,6 +213,25 @@ const char *qemu_get_exec_dir(void); */ char *get_relocated_path(const char *dir); =20 +/** + * 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-bundl= e" + * 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 bund= le + * 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 a58bcfd80e7..fe3bbb1c4eb 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -1086,3 +1086,36 @@ char *get_relocated_path(const char *dir) } return g_string_free(result, false); } + +static const char * const bundle_formats[] =3D { + "%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 =3D qemu_get_exec_dir(); + char *candidate; + int i; + + for (i =3D 0; i < ARRAY_SIZE(bundle_formats); i++) { + candidate =3D g_strdup_printf(bundle_formats[i], dir, path); + if (access(candidate, R_OK) =3D=3D 0) { + return candidate; + } + g_free(candidate); + } + + return NULL; +} + +void list_bundle_candidates(const char *path) +{ + const char *dir =3D qemu_get_exec_dir(); + int i; + + for (i =3D 0; i < ARRAY_SIZE(bundle_formats); i++) { + printf(bundle_formats[i], dir, path); + putc('\n', stdout); + } +} --=20 2.32.1 (Apple Git-133) From nobody Sat Sep 21 03:25:30 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1655241005; cv=none; d=zohomail.com; s=zohoarc; b=eHUoeFGfmz2sHaUCWe7/UmFH7yEc7WjdnivNLliXbfBysV+lrYtt90Jd0O8pc3AgGvsgvHklEIYAyR1ap10Pgx6k8K30HQQh4DRoBbytOxN7yHXONrJrKtzclxiA8zF2dzJhyvbIQRXJwcPANNqc0jLs1NtQmhJ6O2I2//YkJAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655241005; h=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; bh=vFXw3S/lKKr8k4tmj6/hlHwCnffDmNRB5XhVT1Lgayo=; b=d5/gmvAf2lZQc6zKKlWIJwvnS3dOoi8ZNfoYCNc+mQdHCx1lZZu4E4L1VHX1ZjUvWiY/Cd/Jm6HvsERZfQOariPQPaknTSUx4XffD6VIquGkrIIDCe7tAT9S0jErnzYEyknS47Uw57dwrgf5rjKcznH3/vxYO11VOGQ8aYlmbLs= 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 1655241005937273.2506397745342; Tue, 14 Jun 2022 14:10:05 -0700 (PDT) Received: from localhost ([::1]:43088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1DnX-00088J-Pr for importer@patchew.org; Tue, 14 Jun 2022 17:10:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1Dld-0005OP-Nh for qemu-devel@nongnu.org; Tue, 14 Jun 2022 17:08:05 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:45575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1Dlb-0007kv-MA for qemu-devel@nongnu.org; Tue, 14 Jun 2022 17:08:05 -0400 Received: by mail-pl1-x630.google.com with SMTP id d5so6158101plo.12 for ; Tue, 14 Jun 2022 14:08:03 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:d5aa:1806:cce3:7773]) by smtp.gmail.com with ESMTPSA id h65-20020a62de44000000b0050dc762813csm8129456pfg.22.2022.06.14.14.07.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Jun 2022 14:08:01 -0700 (PDT) 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=vFXw3S/lKKr8k4tmj6/hlHwCnffDmNRB5XhVT1Lgayo=; b=NLabtPXmMmAhzluF8F8pLJq+HwlTU9TF2gnqscSUKa2k+e4Y/VH6Hyk806V38xhInS x9sn0vTEouf1MtNAAiIjqhSnzsDrsly71r0Rtmyywwog1q3lxnRtfSqoJGLsRle28yCF fiTkqnV0KYZCTPwIh9jMhUjmrDJkSlD2kHowLLCIDwlR7hw1CjEGWGgX0ezU7TG74VC3 iXpryNk6vVL3cOZ3bgTElSaWnfoMaNy1p3PBvKnvxVLON39sx2Vql652gKGjFt4gxExj 2kxyCirbv6xutJcD4v6FNwgUBwyepCPZtoo1d9b972EZhoCxG+kI3RaS49vrYotEh3kI Ohow== 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=vFXw3S/lKKr8k4tmj6/hlHwCnffDmNRB5XhVT1Lgayo=; b=dz/GzfcQZz9kK5VpYoj/PkRKsxxv2deiGJ/jLrpzM8PO/sFX808SNhEW042THaGW+e mFi4CdHhKVTfw8ZSQI8a1zbE3iYIvG3u29rTgMTMsIGMnOH/QVZT8lOTPjh2WiDSync2 pTnM2ojYSAbHC7lNz0Rkc//JmU/w/iWpwh3dFnVaWXmqMgp2K9stVadl3iqZATpH37/v DtvcAznCJ4zWGxo3Q64DRpDCfAqs4tmQF6i+Vk16OGFoRdIycKcem/LEHXdSbvoEiXCO bP07I92iF41Sq/yqH731PFVlASlbkttt0CQCoQ6AZI2hAXuLEBCl7jsYdSwemgtcoPZI oZ4A== X-Gm-Message-State: AJIora+Nmxz/MgyQKLrEnla8PshhlYljwmFwnfXLM57OgurnziSydWJd CwnymA43JY6MPEl93Oz6XmY= X-Google-Smtp-Source: ABdhPJzx2PBy4f609vzSXWUYUp58j26cdhsJz183xm5jONB+j+pDfzdNJHCWcWMJ0yxLUurl+Lk6vw== X-Received: by 2002:a17:902:c651:b0:164:127:cdfd with SMTP id s17-20020a170902c65100b001640127cdfdmr6334958pls.154.1655240882368; Tue, 14 Jun 2022 14:08:02 -0700 (PDT) From: Akihiko Odaki To: Cc: Peter Maydell , Jason Wang , qemu-devel@nongnu.org, Programmingkid , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Akihiko Odaki Subject: [PATCH v4 2/4] datadir: Use bundle mechanism Date: Wed, 15 Jun 2022 06:07:44 +0900 Message-Id: <20220614210746.78911-3-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220614210746.78911-1-akihiko.odaki@gmail.com> References: <20220614210746.78911-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::630; envelope-from=akihiko.odaki@gmail.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1655241006972100002 Content-Type: text/plain; charset="utf-8" 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 --- .travis.yml | 2 +- meson.build | 3 ++- pc-bios/keymaps/meson.build | 3 +++ pc-bios/meson.build | 17 +++++++++-------- scripts/oss-fuzz/build.sh | 2 +- softmmu/datadir.c | 35 ++++++++++++----------------------- tests/qtest/fuzz/fuzz.c | 15 --------------- tests/vm/fedora | 2 +- tests/vm/freebsd | 2 +- tests/vm/netbsd | 2 +- tests/vm/openbsd | 2 +- 11 files changed, 32 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9afc4a54b8f..9fee2167b95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -223,7 +223,7 @@ jobs: - BUILD_RC=3D0 && make -j${JOBS} || BUILD_RC=3D$? - | if [ "$BUILD_RC" -eq 0 ] ; then - mv pc-bios/s390-ccw/*.img pc-bios/ ; + mv pc-bios/s390-ccw/*.img qemu-bundle/share/qemu ; ${TEST_CMD} ; else $(exit $BUILD_RC); diff --git a/meson.build b/meson.build index 0c2e11ff071..c573815813f 100644 --- a/meson.build +++ b/meson.build @@ -32,6 +32,7 @@ if get_option('qemu_suffix').startswith('/') error('qemu_suffix cannot start with a /') endif =20 +qemu_bundledir =3D meson.project_build_root() / 'qemu-bundle' qemu_confdir =3D get_option('sysconfdir') / get_option('qemu_suffix') qemu_datadir =3D get_option('datadir') / get_option('qemu_suffix') qemu_docdir =3D get_option('docdir') / get_option('qemu_suffix') @@ -1682,7 +1683,7 @@ endif config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_op= tion('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('prefix= ') / get_option('qemu_firmwarepath')) config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') = / get_option('libexecdir')) diff --git a/pc-bios/keymaps/meson.build b/pc-bios/keymaps/meson.build index 44247a12b54..b8bac138756 100644 --- a/pc-bios/keymaps/meson.build +++ b/pc-bios/keymaps/meson.build @@ -67,3 +67,6 @@ if native_qemu_keymap.found() endif =20 install_data(['sl', 'sv'], install_dir: qemu_datadir / 'keymaps') + +run_command('ln', '-sf', '../../../pc-bios/keymaps', qemu_bundledir / qemu= _datadir, + check: true) diff --git a/pc-bios/meson.build b/pc-bios/meson.build index 41ba1c0ec7b..d1ff75b0b13 100644 --- a/pc-bios/meson.build +++ b/pc-bios/meson.build @@ -1,3 +1,5 @@ +run_command('mkdir', '-p', qemu_bundledir / qemu_datadir, check: true) + roms =3D [] if unpack_edk2_blobs fds =3D [ @@ -20,6 +22,9 @@ if unpack_edk2_blobs install: get_option('install_blobs'), install_dir: qemu_datadir, command: [ bzip2, '-dc', '@INPUT0@' ]) + + run_command('ln', '-sf', '../../../pc-bios' / f, qemu_bundledir / qemu= _datadir, + check: true) endforeach endif =20 @@ -85,15 +90,11 @@ blobs =3D [ 'vof-nvram.bin', ] =20 -ln_s =3D [find_program('ln', required: true), '-sf'] +install_data(blobs, install_dir: qemu_datadir) + foreach f : blobs - roms +=3D custom_target(f, - build_by_default: have_system, - output: f, - input: files('meson.build'), # dummy input - install: get_option('install_blobs'), - install_dir: qemu_datadir, - command: [ ln_s, meson.project_source_root() / 'pc-bios' /= f, '@OUTPUT@' ]) + run_command('ln', '-sf', meson.current_source_dir() / f, qemu_bundledir = / qemu_datadir, + check: true) endforeach =20 subdir('descriptors') diff --git a/scripts/oss-fuzz/build.sh b/scripts/oss-fuzz/build.sh index 98b56e05210..cbf8b3080e9 100755 --- a/scripts/oss-fuzz/build.sh +++ b/scripts/oss-fuzz/build.sh @@ -88,7 +88,7 @@ if [ "$GITLAB_CI" !=3D "true" ]; then fi =20 # Copy over the datadir -cp -r ../pc-bios/ "$DEST_DIR/pc-bios" +cp -r ../pc-bios/ "$DEST_DIR/qemu-bundle/share/qemu" =20 targets=3D$(./qemu-fuzz-i386 | awk '$1 ~ /\*/ {print $2}') base_copy=3D"$DEST_DIR/qemu-fuzz-i386-target-$(echo "$targets" | head -n 1= )" diff --git a/softmmu/datadir.c b/softmmu/datadir.c index 160cac999a6..4dadf0e010c 100644 --- a/softmmu/datadir.c +++ b/softmmu/datadir.c @@ -35,6 +35,7 @@ char *qemu_find_file(int type, const char *name) int i; const char *subdir; char *buf; + char *bundle; =20 /* Try the name as a straight path first */ if (access(name, R_OK) =3D=3D 0) { @@ -61,6 +62,16 @@ char *qemu_find_file(int type, const char *name) } g_free(buf); } + + bundle =3D g_strdup_printf("%s/%s%s", + CONFIG_QEMU_BUNDLE_DATADIR, subdir, name); + buf =3D find_bundle(bundle); + g_free(bundle); + if (buf) { + trace_load_file(name, buf); + return buf; + } + return NULL; } =20 @@ -83,26 +94,6 @@ void qemu_add_data_dir(char *path) data_dir[data_dir_idx++] =3D path; } =20 -/* - * Find a likely location for support files using the location of the bina= ry. - * 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 =3D NULL; - - dir =3D 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; @@ -114,9 +105,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()); } =20 void qemu_list_data_dirs(void) @@ -125,4 +113,5 @@ void qemu_list_data_dirs(void) for (i =3D 0; i < data_dir_idx; i++) { printf("%s\n", data_dir[i]); } + list_bundle_candidates(CONFIG_QEMU_BUNDLE_DATADIR); } diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 0ad4ba9e94d..2062b40d82b 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -174,21 +174,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char= ***envp) target_name =3D strstr(**argv, "-target-"); if (target_name) { /* The binary name specifies the target */ target_name +=3D strlen("-target-"); - /* - * With oss-fuzz, the executable is kept in the root of a director= y (we - * cannot assume the path). All data (including bios binaries) mus= t be - * in the same dir, or a subdir. Thus, we cannot place the pc-bios= so - * that it would be in exec_dir/../pc-bios. - * As a workaround, oss-fuzz allows us to use argv[0] to get the - * location of the executable. Using this we add exec_dir/pc-bios = to - * the datadirs. - */ - bindir =3D qemu_get_exec_dir(); - datadir =3D g_build_filename(bindir, "pc-bios", NULL); - if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) { - qemu_add_data_dir(datadir); - } else { - g_free(datadir); } } else if (*argc > 1) { /* The target is specified as an argument */ target_name =3D (*argv)[1]; diff --git a/tests/vm/fedora b/tests/vm/fedora index 92b78d6e2c9..4ccd31bba61 100755 --- a/tests/vm/fedora +++ b/tests/vm/fedora @@ -79,7 +79,7 @@ class FedoraVM(basevm.BaseVM): self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size) self.print_step("Booting installer") self.boot(img_tmp, extra_args =3D [ - "-bios", "pc-bios/bios-256k.bin", + "-bios", "qemu-bundle/share/qemu/bios-256k.bin", "-machine", "graphics=3Doff", "-device", "VGA", "-cdrom", iso diff --git a/tests/vm/freebsd b/tests/vm/freebsd index 805db759d67..2095d8c5204 100755 --- a/tests/vm/freebsd +++ b/tests/vm/freebsd @@ -95,7 +95,7 @@ class FreeBSDVM(basevm.BaseVM): =20 self.print_step("Booting installer") self.boot(img_tmp, extra_args =3D [ - "-bios", "pc-bios/bios-256k.bin", + "-bios", "qemu-bundle/share/qemu/bios-256k.bin", "-machine", "graphics=3Doff", "-device", "VGA", "-cdrom", iso diff --git a/tests/vm/netbsd b/tests/vm/netbsd index 45aa9a7fda7..d59cfedb83e 100755 --- a/tests/vm/netbsd +++ b/tests/vm/netbsd @@ -86,7 +86,7 @@ class NetBSDVM(basevm.BaseVM): =20 self.print_step("Booting installer") self.boot(img_tmp, extra_args =3D [ - "-bios", "pc-bios/bios-256k.bin", + "-bios", "qemu-bundle/share/qemu/bios-256k.bin", "-machine", "graphics=3Doff", "-cdrom", iso ]) diff --git a/tests/vm/openbsd b/tests/vm/openbsd index 13c82542140..036907c6243 100755 --- a/tests/vm/openbsd +++ b/tests/vm/openbsd @@ -82,7 +82,7 @@ class OpenBSDVM(basevm.BaseVM): =20 self.print_step("Booting installer") self.boot(img_tmp, extra_args =3D [ - "-bios", "pc-bios/bios-256k.bin", + "-bios", "qemu-bundle/share/qemu/bios-256k.bin", "-machine", "graphics=3Doff", "-device", "VGA", "-cdrom", iso --=20 2.32.1 (Apple Git-133) From nobody Sat Sep 21 03:25:30 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1655241006; cv=none; d=zohomail.com; s=zohoarc; b=YJ3wIBZ/RLMVCH6L7QkDDiuWp7MWcyT2vd/milUp/MSHzKmiLNhaU6axMe8wW0nTUlOjhfgBtP6XRH2K4WhOUDOZzDjsVTzpJHYyT9hfocyphCH57we49CBvz+5xF9Q2k3TfMkrkkjN1c/DBxfhSGuUWNO8XIF02PPgq3U2lDR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655241006; h=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; bh=2v2fqfQBBwIobbnCkG9YdJzqBvr3hmOh6z0ss4gpln0=; b=MD+R7GiCrz0FLfnsuNlmYYs/ifPOsHIFTGgoDYxeZLb6WlqjlDyg2e0LnIe6C0c8hIxpGeAlFK2d6FTc2zCR6GPxcAeIiFE2DZT2CSKMCQa9Wh5r4tj6Xp8VisfecFwYmfwSeZhiIWAmILBuIET4Jgxmgzk/Ig5RPc9BvbJ4To0= 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 16552410062421023.4945227073856; Tue, 14 Jun 2022 14:10:06 -0700 (PDT) Received: from localhost ([::1]:43244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1DnZ-0008Eb-4Y for importer@patchew.org; Tue, 14 Jun 2022 17:10:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1Dli-0005ZB-Pt for qemu-devel@nongnu.org; Tue, 14 Jun 2022 17:08:10 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:38699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1Dlg-0007l6-Tf for qemu-devel@nongnu.org; Tue, 14 Jun 2022 17:08:10 -0400 Received: by mail-pg1-x532.google.com with SMTP id 123so9603926pgb.5 for ; Tue, 14 Jun 2022 14:08:06 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:d5aa:1806:cce3:7773]) by smtp.gmail.com with ESMTPSA id h65-20020a62de44000000b0050dc762813csm8129456pfg.22.2022.06.14.14.08.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Jun 2022 14:08:04 -0700 (PDT) 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=2v2fqfQBBwIobbnCkG9YdJzqBvr3hmOh6z0ss4gpln0=; b=lX2APd+AYz0l0dbQh+VPOsQZAOs9xO2Q1opqOGdOZsnx1cIFXRKsFFwcgbWzAiIrA+ GbRQmBxSnT3AA8RWlijrscg3pdp3vM+JagkX1HPfIGgQ+BPp5EUWOeKZyskR7MOEoo+R cLpJTPljA1r1vL/xMUrhmanEaACQnpr2J93btPYNbUSjROALhvaJmZD8FnmIheOfqvqx qKwHG1eyH1EIG3ElSU44Vbe76FT6XNKhFjtj8GYhF/s9ciyOf64a1il/FXLEciE+sMtn ePO4Q7p+V9Z/KzAXLLC3kOyesEAB785dfmarGKaKawets6QTIYaau7VikysTrDknuwyl 4aCQ== 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=2v2fqfQBBwIobbnCkG9YdJzqBvr3hmOh6z0ss4gpln0=; b=Z1Zpy0XfzGzYBIFmJu/1t07pO8jUs2yj0SMN/tmY7pTLJpBeFKYE5wPAMRkBVjlCd+ FXs5kiyFkGSQQAQv4bMgIFIamXe91nZjl5ipScOn5Aa11TnMJ2F0Vk1Tsg6vulNLNiqV ULmKMoL7u4NKKtQmkvSVG4rQY8ZBOVMXvboMH4/K3hvlt1AnsmM/z6+z6iQYCRHWUKxf +1RWpQdtmwoNXT5t6Cnj6u2M4W2hOBTdHfBJNPFI04nGqa7W3GKNSJIX53nyTkhs1ZYZ PcWYZXfVGRtUbXgo8sP16K328vvx5ugo0JBTxsHvTdTaW+GoA8jv5m12IT0QM2PD+NIt vu8Q== X-Gm-Message-State: AOAM531kRuu5xmBvOx9Q1WsPyaWJ7R+7R8sjardqYPEBjIXgz9tVP5zU h0zU430BIG2+gpDq2cPEBOXEfUkVTp4= X-Google-Smtp-Source: ABdhPJxZBZGbnpYFilEQ0OEST6W1f8pSr0tIRC41Pl+UWVh1qq/MIzMTASbxLl43DZdoyVFlb6/eag== X-Received: by 2002:a63:d60a:0:b0:3d8:22cb:9224 with SMTP id q10-20020a63d60a000000b003d822cb9224mr5970533pgg.548.1655240885048; Tue, 14 Jun 2022 14:08:05 -0700 (PDT) From: Akihiko Odaki To: Cc: Peter Maydell , Jason Wang , qemu-devel@nongnu.org, Programmingkid , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Akihiko Odaki Subject: [PATCH v4 3/4] ui/icons: Use bundle mechanism Date: Wed, 15 Jun 2022 06:07:45 +0900 Message-Id: <20220614210746.78911-4-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220614210746.78911-1-akihiko.odaki@gmail.com> References: <20220614210746.78911-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::532; envelope-from=akihiko.odaki@gmail.com; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1655241006961100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Akihiko Odaki --- meson.build | 2 +- ui/cocoa.m | 29 ++++++++++++++++------------- ui/gtk.c | 6 +++++- ui/icons/meson.build | 36 ++++++++++++++++++++++++++++-------- ui/sdl2.c | 18 +++++++++++------- 5 files changed, 61 insertions(+), 30 deletions(-) diff --git a/meson.build b/meson.build index c573815813f..e7b385eaf34 100644 --- a/meson.build +++ b/meson.build @@ -1687,7 +1687,7 @@ config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_DATAD= IR', 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('prefix= ') / 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('prefi= x') / get_option('localstatedir')) config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / q= emu_moddir) diff --git a/ui/cocoa.m b/ui/cocoa.m index 84c84e98fc5..bd8a3211d3b 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1562,21 +1562,24 @@ - (BOOL)verifyQuit - (IBAction) do_about_menu_item: (id) sender { NSAutoreleasePool *pool =3D [[NSAutoreleasePool alloc] init]; - char *icon_path_c =3D get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor= /512x512/apps/qemu.png"); - NSString *icon_path =3D [NSString stringWithUTF8String:icon_path_c]; - g_free(icon_path_c); - NSImage *icon =3D [[NSImage alloc] initWithContentsOfFile:icon_path]; + char *icon_path_c =3D find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor= /512x512/apps/qemu.png"); NSString *version =3D @"QEMU emulator version " QEMU_FULL_VERSION; NSString *copyright =3D @QEMU_COPYRIGHT; - NSDictionary *options; - if (icon) { - options =3D @{ - NSAboutPanelOptionApplicationIcon : icon, - NSAboutPanelOptionApplicationVersion : version, - @"Copyright" : copyright, - }; - [icon release]; - } else { + NSDictionary *options =3D nil; + if (icon_path_c) { + NSString *icon_path =3D [NSString stringWithUTF8String:icon_path_c= ]; + g_free(icon_path_c); + NSImage *icon =3D [[NSImage alloc] initWithContentsOfFile:icon_pat= h]; + if (icon) { + options =3D @{ + NSAboutPanelOptionApplicationIcon : icon, + NSAboutPanelOptionApplicationVersion : version, + @"Copyright" : copyright, + }; + [icon release]; + } + } + if (!options) { options =3D @{ NSAboutPanelOptionApplicationVersion : version, @"Copyright" : copyright, diff --git a/ui/gtk.c b/ui/gtk.c index 2a791dd2aa0..8f7afe795f4 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2321,7 +2321,11 @@ static void gtk_display_init(DisplayState *ds, Displ= ayOptions *opts) s->opts =3D opts; =20 theme =3D gtk_icon_theme_get_default(); - dir =3D get_relocated_path(CONFIG_QEMU_ICONDIR); + dir =3D find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR); + if (dir) { + gtk_icon_theme_prepend_search_path(theme, dir); + g_free(dir); + } gtk_icon_theme_prepend_search_path(theme, dir); g_free(dir); g_set_prgname("qemu"); diff --git a/ui/icons/meson.build b/ui/icons/meson.build index 12c52080ebd..23292773074 100644 --- a/ui/icons/meson.build +++ b/ui/icons/meson.build @@ -1,13 +1,33 @@ +icons =3D [ + { + 'source': 'qemu_32x32.bmp', + 'install': 'hicolor' / '32x32' / 'apps' / 'qemu.bmp', + }, + { + 'source': 'qemu.svg', + 'install': 'hicolor' / 'scalable' / 'apps' / 'qemu.svg', + }, +] + foreach s: [16, 24, 32, 48, 64, 128, 256, 512] s =3D '@0@x@0@'.format(s.to_string()) - install_data('qemu_@0@.png'.format(s), - rename: 'qemu.png', - install_dir: qemu_icondir / 'hicolor' / s / 'apps') + icons +=3D { + 'source': 'qemu_@0@.png'.format(s), + 'install': 'hicolor' / s / 'apps' / 'qemu.png', + } endforeach =20 -install_data('qemu_32x32.bmp', - rename: 'qemu.bmp', - install_dir: qemu_icondir / 'hicolor' / '32x32' / 'apps') +foreach icon: icons + source =3D icon.get('source') + install =3D icon.get('install') + + install_data(source, + rename: fs.name(install), + install_dir: qemu_icondir / fs.parent(install)) =20 -install_data('qemu.svg', - install_dir: qemu_icondir / 'hicolor' / 'scalable' / 'apps') + run_command('mkdir', '-p', qemu_bundledir / qemu_icondir / fs.parent(ins= tall), + check: true) + + run_command('ln', '-sf', meson.current_source_dir() / source, qemu_bundl= edir / qemu_icondir / install, + check: true) +endforeach diff --git a/ui/sdl2.c b/ui/sdl2.c index 8cb77416af2..bbcb4762e1b 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -910,15 +910,19 @@ static void sdl2_display_init(DisplayState *ds, Displ= ayOptions *o) } =20 #ifdef CONFIG_SDL_IMAGE - dir =3D get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/= qemu.png"); - icon =3D IMG_Load(dir); + dir =3D find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor/128x128/apps/= qemu.png"); + if (dir) { + icon =3D IMG_Load(dir); + } #else /* Load a 32x32x4 image. White pixels are transparent. */ - dir =3D get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qe= mu.bmp"); - icon =3D SDL_LoadBMP(dir); - if (icon) { - uint32_t colorkey =3D SDL_MapRGB(icon->format, 255, 255, 255); - SDL_SetColorKey(icon, SDL_TRUE, colorkey); + dir =3D find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor/32x32/apps/qe= mu.bmp"); + if (dir) { + icon =3D SDL_LoadBMP(dir); + if (icon) { + uint32_t colorkey =3D SDL_MapRGB(icon->format, 255, 255, 255); + SDL_SetColorKey(icon, SDL_TRUE, colorkey); + } } #endif g_free(dir); --=20 2.32.1 (Apple Git-133) From nobody Sat Sep 21 03:25:30 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1655241143; cv=none; d=zohomail.com; s=zohoarc; b=nDY+dPMlteRAXLiHsNHJVH9qCsrOP9t06zoEqK2NYYtd13CYG2wf9Ek4+2mGpl08Ni3S1GcIWKXVitRjrG4FeJ1iPnYBisAGGDI0tv/DvaF483dhlp/pjaAcTp6+BoYP8CFDZbJdZKxQUmxfMJ8O9t6eAcDCohtha+koYsp6x5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655241143; h=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; bh=5OEPrwlGXS58p8HvgS1ILRM7xBQDf6JCfGW6ElXKY/4=; b=kWhdJyVsFEizHY01TTNkfXSEpB5Qg7j9mG/nUGKmU/WFolAmJz4HHjMRyoUJZFVXJiFJtqkya+l59Xkahbq+eqypu2W5irL/M9zL8xJ2VqbF5s/5PXvQ8sil8wTHJAO3eNUa0e8FnfVWexY7n45hfhZy3cY3IxBjimgR3nGA4oI= 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 165524114320546.08288204458631; Tue, 14 Jun 2022 14:12:23 -0700 (PDT) Received: from localhost ([::1]:50254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1Dpl-0004Yu-Nt for importer@patchew.org; Tue, 14 Jun 2022 17:12:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1Dli-0005Zk-V1 for qemu-devel@nongnu.org; Tue, 14 Jun 2022 17:08:11 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:41515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1Dlh-0007lF-64 for qemu-devel@nongnu.org; Tue, 14 Jun 2022 17:08:10 -0400 Received: by mail-pl1-x62c.google.com with SMTP id g8so3562788plt.8 for ; Tue, 14 Jun 2022 14:08:08 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:d5aa:1806:cce3:7773]) by smtp.gmail.com with ESMTPSA id h65-20020a62de44000000b0050dc762813csm8129456pfg.22.2022.06.14.14.08.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 14 Jun 2022 14:08:07 -0700 (PDT) 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=5OEPrwlGXS58p8HvgS1ILRM7xBQDf6JCfGW6ElXKY/4=; b=qSEAVT6CFgkqFdi7Jb/1VcV9K/DZtnwpHDQ56EsFUgX1CMYijXfwTjk0ow6r8VPE1v xViErMxpHM6I5LXLrE/K2pR+mFszU2x8o39tCaM97rOeudmLi674MPHufqodxmTdW7aE Idnea95DKHa77XS8YqN2CkBKMY5BywBjjLRBl1Yb63KabnPfOH7CvTHdLyqB42oXgpvr Qp94hFo57pOns2FfvOM0AXlGp/Mb/b3ovdDzlFdCSr8axX7Xd4n9BDa3ZN7TWy/XUpgf Cvl7QCsx5NXslQVpviN3QJq064qvb7E3yKEolkc6Jd8CiPfoI4vAB3hsPL3K/gruExsE JZhg== 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=5OEPrwlGXS58p8HvgS1ILRM7xBQDf6JCfGW6ElXKY/4=; b=rzQzGZq/SMx0y7Z4OjJRc5kS6ySipixl6em/phpeZ+UO7H5dGTQNiFSNbuhqPPjCFu OkAQLxYAEjdrfV4QGzi4X2gM2ZH3YcCoIeojA76o4nsuJSb2IA331k4mhh7QOrpz4cJv 7r43yZU6OAg8Q5/P8Gb+5xKBy6cg2i+6lv82RzRKXQVJzcP9S8tWCr+v6dauzK8jQTCb n/kg5FbA3vRy29DvELWoVsTiN41L6Rt03hKhD/HNsWgY54IK0vBusxRnqyr0jWVKEHz6 1LaC7gO58Ed74BiXvQZ0Xqt5frX1dD7EVekCBogqCAZYNlTxk1rw5H11IdwewqfUprSx SMkQ== X-Gm-Message-State: AJIora/+X1PJ0zQP8JY6SJ6fAqk+2xQQs+t7ftUEcxnZU+jW9sklVLcq s9jiLHa/jYM+iaBwyCYzOgg= X-Google-Smtp-Source: ABdhPJxiWu1PElqEKJ0+36/mMBHLqJb4PCBRd1kJEKpte6Ocnr0c2OQnpuhQ0qEfa6GjX+q1Lacn9Q== X-Received: by 2002:a17:902:6b89:b0:168:cf03:9e63 with SMTP id p9-20020a1709026b8900b00168cf039e63mr6162562plk.46.1655240887790; Tue, 14 Jun 2022 14:08:07 -0700 (PDT) From: Akihiko Odaki To: Cc: Peter Maydell , Jason Wang , qemu-devel@nongnu.org, Programmingkid , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Akihiko Odaki Subject: [PATCH v4 4/4] net: Use bundle mechanism Date: Wed, 15 Jun 2022 06:07:46 +0900 Message-Id: <20220614210746.78911-5-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220614210746.78911-1-akihiko.odaki@gmail.com> References: <20220614210746.78911-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::62c; envelope-from=akihiko.odaki@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1655241143660100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Akihiko Odaki --- include/net/net.h | 2 +- meson.build | 8 +++++++- net/tap.c | 6 +++++- qemu-options.hx | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) 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); =20 #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-b= ridge-helper" #define DEFAULT_BRIDGE_INTERFACE "br0" =20 void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); diff --git a/meson.build b/meson.build index e7b385eaf34..72d006f228e 100644 --- a/meson.build +++ b/meson.build @@ -1686,7 +1686,7 @@ config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', ge= t_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('prefix= ') / 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_BUNDLE_HELPERDIR', get_option('li= bexecdir')) 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('prefi= x') / get_option('localstatedir')) @@ -3573,6 +3573,12 @@ if have_tools dependencies: [authz, crypto, io, qom, qemuutil, libcap_ng, mpathpersist], install: true) + + run_command('mkdir', '-p', qemu_bundledir / get_option('libexecdir'), + check: true) + + run_command('ln', '-sf', '../../qemu-bridge-helper', qemu_bundledir / = get_option('libexecdir'), + check: true) endif =20 if have_ivshmem diff --git a/net/tap.c b/net/tap.c index b3ddfd4a74b..ea013ca3873 100644 --- a/net/tap.c +++ b/net/tap.c @@ -507,7 +507,11 @@ static int net_bridge_run_helper(const char *helper, c= onst char *bridge, sigprocmask(SIG_BLOCK, &mask, &oldmask); =20 if (!helper) { - helper =3D default_helper =3D get_relocated_path(DEFAULT_BRIDGE_HE= LPER); + helper =3D default_helper =3D find_bundle(DEFAULT_BUNDLE_BRIDGE_HE= LPER); + if (!helper) { + error_setg(errp, "bridge helper not found"); + return -1; + } } =20 if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) =3D=3D -1) { diff --git a/qemu-options.hx b/qemu-options.hx index 377d22fbd82..1959db01061 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=3D" DEFAULT_NETW= ORK_DOWN_SCRIPT ")\n" " to deconfigure it\n" " use '[down]script=3Dno' to disable script execution\n" - " use network helper 'helper' (default=3D" DEFAULT_BRID= GE_HELPER ") to\n" + " use network helper 'helper' (default=3D" DEFAULT_BUND= LE_BRIDGE_HELPER ") to\n" " configure it\n" " use 'fd=3Dh' to connect to an already opened TAP inte= rface\n" " use 'fds=3Dx:y:...:z' to connect to already opened mu= ltiqueue capable TAP interfaces\n" @@ -2684,7 +2684,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, "-netdev bridge,id=3Dstr[,br=3Dbridge][,helper=3Dhelper]\n" " configure a host TAP network backend with ID 'str' th= at is\n" " connected to a bridge (default=3D" DEFAULT_BRIDGE_INT= ERFACE ")\n" - " using the program 'helper (default=3D" DEFAULT_BRIDGE= _HELPER ")\n" + " using the program 'helper (default=3D" DEFAULT_BUNDLE= _BRIDGE_HELPER ")\n" #endif #ifdef __linux__ "-netdev l2tpv3,id=3Dstr,src=3Dsrcaddr,dst=3Ddstaddr[,srcport=3Dsrcpor= t][,dstport=3Ddstport]\n" --=20 2.32.1 (Apple Git-133)