From nobody Sun Apr 28 13:21:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594908725; cv=none; d=zohomail.com; s=zohoarc; b=PRXIR1cehsZgXZslQ8g1jr+z8l+KHjXqilRXDG70KFoZh2H9O8wkT/ag0yB91+hrDSmVZHIuMpXugl4uD/wskQa9QoE11qqY92x1b7El643kPHnO+U9XwAWgHSU81Tn4y/lc9Hy3WWcfbdBkoVe0Iu4cQs7HcR3J2ci2K1WSGZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594908725; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Cj/ZwXO30nCzdzQIaVw1/gDL65Xcwz653+gyjrcG7Bw=; b=IOKWhEGkCmVsTFF1DnTjttl40iHBVMg6yofwVIWjtVasJ4IJOuLqDM9cNR4rV9/Rxg1J9UJalPxInAgqgMMXDX4qJ8NucMCP/0Xyhwio7VZXiz6D8f0dblyLvtjdNU5Sp5ngNG07yMjD5cLzx5puYivF0ZVud93nnDlogK0UQVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594908725690441.13307006084585; Thu, 16 Jul 2020 07:12:05 -0700 (PDT) Received: from localhost ([::1]:33290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jw4cG-0002aT-EB for importer@patchew.org; Thu, 16 Jul 2020 10:12:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jw4bV-0001pB-RD for qemu-devel@nongnu.org; Thu, 16 Jul 2020 10:11:17 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:31494 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jw4bT-0002uo-69 for qemu-devel@nongnu.org; Thu, 16 Jul 2020 10:11:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-251--HZ8ONe0N6e9WcWWTooP0w-1; Thu, 16 Jul 2020 10:11:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F125100A633; Thu, 16 Jul 2020 14:11:10 +0000 (UTC) Received: from localhost (unknown [10.36.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4C356FDD1; Thu, 16 Jul 2020 14:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594908673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Cj/ZwXO30nCzdzQIaVw1/gDL65Xcwz653+gyjrcG7Bw=; b=D1m+GI/JSzpileGgG4HfxdCQ3wfsKstIBRFL5dVOEIy/ciDxNGukb31ZJTNwZ9nINpDNNc 9eI9R05XjDo2VyBs2hdCAhH+Pw8L9Gmjcg30URaxJEtPY7C356rdwOO2/8SKEkR1jQxN7Y tOUCKQFlVKFjbXlSUYRlouIDd31VU6I= X-MC-Unique: -HZ8ONe0N6e9WcWWTooP0w-1 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Subject: [RFC PATCH] os-posix: fix regression for install-less datadir location Date: Thu, 16 Jul 2020 18:11:00 +0400 Message-Id: <20200716141100.398296-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=207.211.31.120; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/16 04:25:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , joe.slater@windriver.com, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) os_find_datadir() used to check the ../share/qemu location (regardless of CONFIG_QEMU_DATADIR). It turns out that people rely on that location for running qemu in an arbitrary "install-less/portable" fashion. Change the logic to return that directory as a last resort. (this is an alternative to the patch "[PATCH 1/1] os_find_datadir: search as in version 4.2" from Joe Slater) Fixes: 6dd2dacedd83d12328 ("os-posix: simplify os_find_datadir") Cc: Paolo Bonzini Signed-off-by: Marc-Andr=C3=A9 Lureau --- os-posix.c | 15 ++++++++++++--- scripts/create_config | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/os-posix.c b/os-posix.c index b674b20b1b1..bd0ed0c14d1 100644 --- a/os-posix.c +++ b/os-posix.c @@ -82,8 +82,13 @@ void os_setup_signal_handling(void) =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. + * + * If running from the install location (CONFIG_BINDIR), this will be + * CONFIG_QEMU_DATADIR. + * + * Otherwise, fallback on "$execdir/../pc-bios" if it exists (the build tr= ee + * location), else on "$execdir/../share/qemu" (for the install-less/"port= able" + * version). */ char *os_find_datadir(void) { @@ -93,12 +98,16 @@ char *os_find_datadir(void) exec_dir =3D qemu_get_exec_dir(); g_return_val_if_fail(exec_dir !=3D NULL, NULL); =20 + if (g_str_has_prefix(exec_dir, CONFIG_BINDIR)) { + return g_strdup(CONFIG_QEMU_DATADIR); + } + dir =3D g_build_filename(exec_dir, "..", "pc-bios", NULL); if (g_file_test(dir, G_FILE_TEST_IS_DIR)) { return g_steal_pointer(&dir); } =20 - return g_strdup(CONFIG_QEMU_DATADIR); + return g_build_filename(exec_dir, "..", "share", "qemu", NULL); } =20 void os_set_proc_name(const char *s) diff --git a/scripts/create_config b/scripts/create_config index 6d8f08b39da..03f8cb1dc10 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -15,7 +15,7 @@ case $line in echo "#define QEMU_VERSION_MINOR $minor" echo "#define QEMU_VERSION_MICRO $micro" ;; - qemu_*dir=3D* | qemu_*path=3D*) # qemu-specific directory configuration + bindir=3D* | qemu_*dir=3D* | qemu_*path=3D*) # qemu-specific directory co= nfiguration name=3D${line%=3D*} value=3D${line#*=3D} define_name=3D$(echo $name | LC_ALL=3DC tr '[a-z]' '[A-Z]') --=20 2.27.0.221.ga08a83db2b