From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941302; cv=none; d=zohomail.com; s=zohoarc; b=I+GlhPybdQHShVZWcWsNehcOz0/gVvgRfZnYbQjSD2kgIjoFlTqibnB2BpUUimHJlsF5ePDyHsM0AUctv9Bvebzzr1nwtf6EmW8BdHJFKkWZiWu+zeluF2Ypf2bnPzcSVyyujbcpuPPoweThcM1FjpGynO6npehbyMNEw5Iu4EI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941302; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uwcgrc5N8R8AKSdo6mXj+LpU39C+cRrrIVhDcdfRpDw=; b=eJ8HFkQrwlsRv30eiil2zGAguMc+Y8lfOefjBjm6APWIk/WaarxtgN2wxSdRe5RVNDF8NPE05ZP8yU49sQoT48vL+rjUVdiwmQJdnDRqa1vOvOI580vqVL1EwcLUj0NJRMafjmNG36LW5petFzFrAzNQhiNFzkOOEQrUsuTf74Y= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941302096337.29125874169927; Mon, 31 Aug 2020 23:21:42 -0700 (PDT) Received: from localhost ([::1]:55420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzfp-0007bj-2N for importer@patchew.org; Tue, 01 Sep 2020 02:21:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzed-0005ym-6L for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:29530 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 1kCzeb-0000kd-Fk for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:26 -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-77-DZHpTDkCPxiHgpMiZwm_wA-1; Tue, 01 Sep 2020 02:20:22 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8CFC310066FE; Tue, 1 Sep 2020 06:20:21 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A5FC1002D57; Tue, 1 Sep 2020 06:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uwcgrc5N8R8AKSdo6mXj+LpU39C+cRrrIVhDcdfRpDw=; b=ZMlYezErQ2jYslKCz8ffx/JCeSxir3PzekwqOzB/R1TujKnXt2asWzHFE4cgy4Z4qBH2EG Nc02mM6g3erUGZ8BaXnB/NW8FZ+QDgMxSV+BadSSRgQxevuIB0G8P7HTbzhEXm7n+lr7CH 846OV0oytZgVTv+4Lxo+AV14prP/Tvg= X-MC-Unique: DZHpTDkCPxiHgpMiZwm_wA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 01/13] fuzz: use qemu_get_exec_dir Date: Tue, 1 Sep 2020 02:20:08 -0400 Message-Id: <20200901062020.26660-2-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/01 00:57:59 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Make things consistent with how softmmu/vl.c uses os_find_datadir. Initializing the path to the executables will also be needed for get_relocatable_path to work. Signed-off-by: Paolo Bonzini Reviewed-by: Alexander Bulekov Reviewed-by: Thomas Huth --- tests/qtest/fuzz/fuzz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 1ceea84702..391223219d 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -152,6 +152,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char = ***envp) module_call_init(MODULE_INIT_QOM); module_call_init(MODULE_INIT_LIBQOS); =20 + qemu_init_exec_dir(**argv); target_name =3D strstr(**argv, "-target-"); if (target_name) { /* The binary name specifies the target */ target_name +=3D strlen("-target-"); @@ -164,7 +165,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char = ***envp) * location of the executable. Using this we add exec_dir/pc-bios = to * the datadirs. */ - bindir =3D g_path_get_dirname(**argv); + bindir =3D qemu_get_exec_dir(); datadir =3D g_build_filename(bindir, "pc-bios", NULL); g_free(bindir); if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) { --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941384; cv=none; d=zohomail.com; s=zohoarc; b=XupOYHvt5ACrKxnpV9p6SWks+zKLY0Ju54KrZb4pq0iOuV93ROwSsD/sqq51Z6e5eELOQo1FoxeBHBBTl40KBLq0B5Aj6ZYqaVeSAZF+VolpTxvhvSdS0b8UyYeRqetLUVExTR7upypQprz+Qn1CtxdkF1DMenWdhAcLGV1Mrn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941384; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tSSh8Fj8KagTnesaHCQXywrAQbGBYsigzg8baFolzVs=; b=JJmFKadlpe5n/9fzZ6/CWDaZdbFaZz23OMRhisr+GmCyyMuYlktPsaty/wFo0f14S8c3abNUke9lICiTfOV49QIZALSMk6tEFYu+jCEOJWD1/7ED4I/c5TGowO0FYGk5v7aBEs0RwaQ3AwW+AoROqF4o34sW9YODdYntD7ORsTE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941384973337.8214002864306; Mon, 31 Aug 2020 23:23:04 -0700 (PDT) Received: from localhost ([::1]:35960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzhA-0002ez-5Y for importer@patchew.org; Tue, 01 Sep 2020 02:23:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzed-0005zA-MR for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:27 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:20613 helo=us-smtp-delivery-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 1kCzeb-0000kY-FP for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:27 -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-83-k3r2n5a5Ne-NNOkD9yrwZA-1; Tue, 01 Sep 2020 02:20:22 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F09701DDF0; Tue, 1 Sep 2020 06:20:21 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8B5C10027A6; Tue, 1 Sep 2020 06:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tSSh8Fj8KagTnesaHCQXywrAQbGBYsigzg8baFolzVs=; b=XJtlfep2RSMchKAu0YfXHOL5UDe6BRMkCn8uVBb1E9ikRORU+2t8As0XXDQfjnrnsYvEST ENeAn0YMPg1W+OBSZw0c0aDdd+KbbK7GptWzxEyZhlEg+lmWAuIoZj/1P6L7bDAh7WiiH4 7JU3fIn3mYwuJ3+lvcEStEUCpya6oFE= X-MC-Unique: k3r2n5a5Ne-NNOkD9yrwZA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 02/13] oslib: do not call g_strdup from qemu_get_exec_dir Date: Tue, 1 Sep 2020 02:20:09 -0400 Message-Id: <20200901062020.26660-3-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/01 02:08:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Just return the directory without requiring the caller to free it. This also removes a bogus check for NULL in os_find_datadir and module_load_one; g_strdup of a static variable cannot return NULL. Signed-off-by: Paolo Bonzini Reviewed-by: Thomas Huth --- include/qemu/osdep.h | 8 ++------ os-posix.c | 6 +----- os-win32.c | 2 +- tests/qtest/fuzz/fuzz.c | 4 ++-- util/module.c | 7 +------ util/oslib-posix.c | 8 +++++--- util/oslib-win32.c | 12 ++++++++---- 7 files changed, 20 insertions(+), 27 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 412962d91a..db2cfffaff 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -590,12 +590,8 @@ char *qemu_get_local_state_pathname(const char *relati= ve_pathname); * Try OS specific API first, if not working, parse from argv0. */ void qemu_init_exec_dir(const char *argv0); =20 -/* Get the saved exec dir. - * - * The caller is responsible for releasing the value returned with g_free() - * after use. - */ -char *qemu_get_exec_dir(void); +/* Get the saved exec dir. */ +const char *qemu_get_exec_dir(void); =20 /** * qemu_getauxval: diff --git a/os-posix.c b/os-posix.c index bf98508b6d..8d8e7fc15c 100644 --- a/os-posix.c +++ b/os-posix.c @@ -90,13 +90,9 @@ void os_setup_signal_handling(void) */ char *os_find_datadir(void) { - g_autofree char *exec_dir =3D NULL; g_autofree char *dir =3D NULL; =20 - exec_dir =3D qemu_get_exec_dir(); - g_return_val_if_fail(exec_dir !=3D NULL, NULL); - - dir =3D g_build_filename(exec_dir, "pc-bios", 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); } diff --git a/os-win32.c b/os-win32.c index c9c3afe648..eb8501b9e5 100644 --- a/os-win32.c +++ b/os-win32.c @@ -65,7 +65,7 @@ void os_setup_early_signal_handling(void) */ char *os_find_datadir(void) { - return qemu_get_exec_dir(); + return g_strdup(qemu_get_exec_dir()); } =20 void os_set_line_buffering(void) diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 391223219d..1811cb1d88 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -143,7 +143,8 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char = ***envp) { =20 char *target_name; - char *bindir, *datadir; + const char *bindir; + char *datadir; bool serialize =3D false; =20 /* Initialize qgraph and modules */ @@ -167,7 +168,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char = ***envp) */ bindir =3D qemu_get_exec_dir(); datadir =3D g_build_filename(bindir, "pc-bios", NULL); - g_free(bindir); if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) { qemu_add_data_dir(datadir); } diff --git a/util/module.c b/util/module.c index 6e63006a8f..aed04b578a 100644 --- a/util/module.c +++ b/util/module.c @@ -172,7 +172,6 @@ bool module_load_one(const char *prefix, const char *li= b_name) =20 #ifdef CONFIG_MODULES char *fname =3D NULL; - char *exec_dir; #ifdef CONFIG_MODULE_UPGRADES char *version_dir; #endif @@ -199,13 +198,12 @@ bool module_load_one(const char *prefix, const char *= lib_name) return true; } =20 - exec_dir =3D qemu_get_exec_dir(); search_dir =3D getenv("QEMU_MODULE_DIR"); if (search_dir !=3D NULL) { dirs[n_dirs++] =3D g_strdup_printf("%s", search_dir); } dirs[n_dirs++] =3D g_strdup_printf("%s", CONFIG_QEMU_MODDIR); - dirs[n_dirs++] =3D g_strdup_printf("%s", exec_dir ? : ""); + dirs[n_dirs++] =3D g_strdup(qemu_get_exec_dir()); =20 #ifdef CONFIG_MODULE_UPGRADES version_dir =3D g_strcanon(g_strdup(QEMU_PKGVERSION), @@ -216,9 +214,6 @@ bool module_load_one(const char *prefix, const char *li= b_name) =20 assert(n_dirs <=3D ARRAY_SIZE(dirs)); =20 - g_free(exec_dir); - exec_dir =3D NULL; - for (i =3D 0; i < n_dirs; i++) { fname =3D g_strdup_printf("%s/%s%s", dirs[i], module_name, CONFIG_HOST_DSOSUF); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index ad8001a4ad..0dd8d24076 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -366,7 +366,9 @@ void qemu_init_exec_dir(const char *argv0) char *p =3D NULL; char buf[PATH_MAX]; =20 - assert(!exec_dir[0]); + if (exec_dir[0]) { + return; + } =20 #if defined(__linux__) { @@ -439,9 +441,9 @@ void qemu_init_exec_dir(const char *argv0) g_free(dir); } =20 -char *qemu_get_exec_dir(void) +const char *qemu_get_exec_dir(void) { - return g_strdup(exec_dir); + return exec_dir; } =20 static void sigbus_handler(int signal) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index c654dafd93..1a33912944 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -315,7 +315,7 @@ void qemu_set_tty_echo(int fd, bool echo) } } =20 -static char exec_dir[PATH_MAX]; +static char *exec_dir; =20 void qemu_init_exec_dir(const char *argv0) { @@ -324,6 +324,10 @@ void qemu_init_exec_dir(const char *argv0) char buf[MAX_PATH]; DWORD len; =20 + if (exec_dir) { + return; + } + len =3D GetModuleFileName(NULL, buf, sizeof(buf) - 1); if (len =3D=3D 0) { return; @@ -336,13 +340,13 @@ void qemu_init_exec_dir(const char *argv0) } *p =3D 0; if (access(buf, R_OK) =3D=3D 0) { - pstrcpy(exec_dir, sizeof(exec_dir), buf); + exec_dir =3D g_strdup(buf); } } =20 -char *qemu_get_exec_dir(void) +const char *qemu_get_exec_dir(void) { - return g_strdup(exec_dir); + return exec_dir; } =20 #if !GLIB_CHECK_VERSION(2, 50, 0) --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941380; cv=none; d=zohomail.com; s=zohoarc; b=jjfD2kt9ChErT38qeNbBQyYUbAgKhykUxCnOEhyhb8F+Y2vYWoRQk+S8HOHVNC2/yPsV0jt/s7GuvL4k7SYjWe8skTKmLAdhts0iYW/B1zhUOscSl1QizJK1pKb4y5GZJvvr6u0Evj7608jw5s3nFHs8tJ133+aYpSFiOeIbbJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941380; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VFTSKgbtfOAZ0MhoeAhMnWBNPjjt3/Q0xsLFhvDTcA8=; b=WgqkOuy0iDj7DEVwCz7AuOPFjyo0w3cZ7QLy1NnAMuvs0xfvd0uN9geOZAZaadMarWoe/aiagRFhMqbCEMnCHWA4kstpaW8A9Bq9wlAkOK9oyJNaAYt5w1DbdL1kSNG5m6wpiq73uR9IypgHhvswZW+a0PvHwxcp+WKINSIsNTU= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941380574980.2188281663883; Mon, 31 Aug 2020 23:23:00 -0700 (PDT) Received: from localhost ([::1]:35576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzh5-0002Vc-OA for importer@patchew.org; Tue, 01 Sep 2020 02:22:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzef-00062H-Oc for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kCzed-0000me-PV for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:29 -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-151-ftj5EehnPvqSuh8ElIiUSA-1; Tue, 01 Sep 2020 02:20:23 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B9FD801AC5; Tue, 1 Sep 2020 06:20:22 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 184401002D4E; Tue, 1 Sep 2020 06:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VFTSKgbtfOAZ0MhoeAhMnWBNPjjt3/Q0xsLFhvDTcA8=; b=MvMm+F0g+V96wFaazpJgyNSRryIhzy0D0nqHbjyOtFGzP4bCK5l+t99SoIVBfqRb45UMPt asxecdxloS9+e5aFFnLSNEI06ly5bmEuHs3Nfgfxy/QDKEieJcENpSflzAYGab2TruGC+6 Hkz+8kQ5Je/o4sa4RjXnTB8pC7AM6gw= X-MC-Unique: ftj5EehnPvqSuh8ElIiUSA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 03/13] oslib-posix: default exec_dir to bindir Date: Tue, 1 Sep 2020 02:20:10 -0400 Message-Id: <20200901062020.26660-4-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/01 01:27:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If the exec_dir cannot be retrieved, just assume it's the installation directory that was specified at configure time. This makes it simpler to reason about what the callers will do if they get back an empty path. Signed-off-by: Paolo Bonzini --- meson.build | 2 +- util/oslib-posix.c | 23 ++++++++--------------- util/oslib-win32.c | 2 ++ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/meson.build b/meson.build index 93182d36e3..10ab189bc5 100644 --- a/meson.build +++ b/meson.build @@ -415,7 +415,7 @@ config_host_data.set('QEMU_VERSION_MINOR', meson.projec= t_version().split('.')[1] config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('= .')[2]) =20 arrays =3D ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BD= RV_RO_WHITELIST'] -strings =3D ['HOST_DSOSUF', 'CONFIG_IASL', 'qemu_confdir', 'qemu_datadir', +strings =3D ['HOST_DSOSUF', 'CONFIG_IASL', 'bindir', 'qemu_confdir', 'qemu= _datadir', 'qemu_moddir', 'qemu_localstatedir', 'qemu_helperdir', 'qemu_lo= caledir', 'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath'] foreach k, v: config_host diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 0dd8d24076..a68fccb52d 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -358,15 +358,14 @@ void qemu_set_tty_echo(int fd, bool echo) tcsetattr(fd, TCSANOW, &tty); } =20 -static char exec_dir[PATH_MAX]; +static char *exec_dir; =20 void qemu_init_exec_dir(const char *argv0) { - char *dir; char *p =3D NULL; char buf[PATH_MAX]; =20 - if (exec_dir[0]) { + if (exec_dir) { return; } =20 @@ -425,20 +424,14 @@ void qemu_init_exec_dir(const char *argv0) #endif /* If we don't have any way of figuring out the actual executable location then try argv[0]. */ - if (!p) { - if (!argv0) { - return; - } + if (!p && argv0) { p =3D realpath(argv0, buf); - if (!p) { - return; - } } - dir =3D g_path_get_dirname(p); - - pstrcpy(exec_dir, sizeof(exec_dir), dir); - - g_free(dir); + if (p) { + exec_dir =3D g_path_get_dirname(p); + } else { + exec_dir =3D g_strdup(CONFIG_BINDIR); + } } =20 const char *qemu_get_exec_dir(void) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 1a33912944..8d3f940a54 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -341,6 +341,8 @@ void qemu_init_exec_dir(const char *argv0) *p =3D 0; if (access(buf, R_OK) =3D=3D 0) { exec_dir =3D g_strdup(buf); + } else { + exec_dir =3D g_strdup(CONFIG_BINDIR); } } =20 --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941625; cv=none; d=zohomail.com; s=zohoarc; b=czT7mtzWSMozTBCaA9HtZDVXcHsHPHSjXSz51Sf1QLB7JJAybr/S3FPXsan0sVO/3nT/3gyNXwiEtuUjGrnnfEHaaHPI55ays21jAZKxUbsy9raM8FknJFcUDyLyGbb0pI5ccs6Et3WwMXXCIaxVqzz9JjjUS7jH7Vyg68R57UU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941625; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v0YO1TAcvCtmXkC39YCljAG2/PM+mDgbUZfwAa2IeAs=; b=X6QiQV905R+J7NHuNSE+gOvrUVkIzXamcYJ7B3IvRpGI12BJpXZheJeI0ZGnmhLSxrc/4bh3wXhUlzIl9pGs3xx8rpdehKO4yv6NPJ9DtoF1OkC0XlF+R7cNBnx6u+sVfJ57zfy/zkmnm3l5v416jdIvalEvvwR+316PUAEXAhg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941625631405.21965661025433; Mon, 31 Aug 2020 23:27:05 -0700 (PDT) Received: from localhost ([::1]:53172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzl2-0001fI-Pm for importer@patchew.org; Tue, 01 Sep 2020 02:27:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzfK-0007Br-Em for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:21:10 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:50020 helo=us-smtp-delivery-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 1kCzfH-0000wj-VX for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:21:10 -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-504-z9Bw_fQDPjGlHMk201JJUQ-1; Tue, 01 Sep 2020 02:20:23 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B94A41888A01; Tue, 1 Sep 2020 06:20:22 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 773181002393; Tue, 1 Sep 2020 06:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v0YO1TAcvCtmXkC39YCljAG2/PM+mDgbUZfwAa2IeAs=; b=OZuZYwCkcByojxyCLW0aod7mlKA1UxHS2qQxFpQ0T2uf6jNWpq1Ed62mMurhU8TNKQVNsm urgfqQ4K/G3VBQJZ/FkSqbmWdhzZBx/YxLGfwhWXCfpeewJmghoXqTwMUbLpgH1pdfDe1H gLzHiMqkNYtHmGLj6ITMjb+eKcE0v1c= X-MC-Unique: z9Bw_fQDPjGlHMk201JJUQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 04/13] cutils: introduce get_relocated_path Date: Tue, 1 Sep 2020 02:20:11 -0400 Message-Id: <20200901062020.26660-5-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=205.139.110.61; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 23:17:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add the function that will compute a relocated version of the directories in CONFIG_QEMU_*DIR and CONFIG_QEMU_*PATH. Signed-off-by: Paolo Bonzini --- include/qemu/cutils.h | 12 +++++++++ meson.build | 4 +-- util/cutils.c | 61 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index eb59852dfd..3a86ec0321 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -184,4 +184,16 @@ int uleb128_decode_small(const uint8_t *in, uint32_t *= n); */ int qemu_pstrcmp0(const char **str1, const char **str2); =20 + +/** + * get_relocated_path: + * @dir: the directory (typically a `CONFIG_*DIR` variable) to be relocate= d. + * + * Returns a path for @dir that uses the directory of the running executab= le + * as the prefix. For example, if `bindir` is `/usr/bin` and @dir is + * `/usr/share/qemu`, the function will append `../share/qemu` to the + * directory that contains the running executable and return the result. + */ +char *get_relocated_path(const char *dir); + #endif diff --git a/meson.build b/meson.build index 10ab189bc5..5ff005b835 100644 --- a/meson.build +++ b/meson.build @@ -415,9 +415,9 @@ config_host_data.set('QEMU_VERSION_MINOR', meson.projec= t_version().split('.')[1] config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('= .')[2]) =20 arrays =3D ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BD= RV_RO_WHITELIST'] -strings =3D ['HOST_DSOSUF', 'CONFIG_IASL', 'bindir', 'qemu_confdir', 'qemu= _datadir', +strings =3D ['HOST_DSOSUF', 'CONFIG_IASL', 'bindir', 'prefix', 'qemu_confd= ir', 'qemu_datadir', 'qemu_moddir', 'qemu_localstatedir', 'qemu_helperdir', 'qemu_lo= caledir', - 'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath'] + 'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath', 'syscon= fdir'] foreach k, v: config_host if arrays.contains(k) if v !=3D '' diff --git a/util/cutils.c b/util/cutils.c index 36ce712271..8da34e04b0 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -889,3 +889,64 @@ int qemu_pstrcmp0(const char **str1, const char **str2) { return g_strcmp0(*str1, *str2); } + +static inline bool starts_with_prefix(const char *dir) +{ + size_t prefix_len =3D strlen(CONFIG_PREFIX); + return !memcmp(dir, CONFIG_PREFIX, prefix_len) && + (!dir[prefix_len] || G_IS_DIR_SEPARATOR(dir[prefix_len])); +} + +/* Return the next path component in dir, and store its length in *p_len. = */ +static inline const char *next_component(const char *dir, int *p_len) +{ + int len; + while (*dir && G_IS_DIR_SEPARATOR(*dir)) { + dir++; + } + len =3D 0; + while (dir[len] && !G_IS_DIR_SEPARATOR(dir[len])) { + len++; + } + *p_len =3D len; + return dir; +} + +char *get_relocated_path(const char *dir) +{ + size_t prefix_len =3D strlen(CONFIG_PREFIX); + const char *bindir =3D CONFIG_BINDIR; + const char *exec_dir =3D qemu_get_exec_dir(); + GString *result; + int len_dir, len_bindir; + + /* Fail if qemu_init_exec_dir was not called. */ + assert(exec_dir[0]); + if (!starts_with_prefix(dir) || !starts_with_prefix(bindir)) { + return strdup(dir); + } + + result =3D g_string_new(exec_dir); + + /* Advance over common components. */ + len_dir =3D len_bindir =3D prefix_len; + do { + dir +=3D len_dir; + bindir +=3D len_bindir; + dir =3D next_component(dir, &len_dir); + bindir =3D next_component(bindir, &len_bindir); + } while (len_dir =3D=3D len_bindir && !memcmp(dir, bindir, len_dir)); + + /* Ascend from bindir to the common prefix with dir. */ + while (len_bindir) { + bindir +=3D len_bindir; + g_string_append(result, "/.."); + bindir =3D next_component(bindir, &len_bindir); + } + + if (*dir) { + assert(G_IS_DIR_SEPARATOR(dir[-1])); + g_string_append(result, dir - 1); + } + return result->str; +} --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941314; cv=none; d=zohomail.com; s=zohoarc; b=DqsXOqCOfafrMp1kG7TJeEXo2EveW52aqMmanUv4Qdj/tgGTHG5QsY8czBOQfXKonCOEUsQXgVEGMADPaRnaSNHndXPbilyhvXQLvh+E/+TIWak6Vg8Ak4su+hIIuxLHSiZtHCV/rb+vt3dWeEl0Nt/Wkot2WYrtyK2/kqhlRSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941314; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QG2WVA4E0ooYR/bAUcK1A88DLhADj01++WMdzTaU6bc=; b=Lx/wP4dwi1Bx57CLZ6Fpt/R3to/w9omu6v99GwXN9dtP5kv0RJ6fG2tgCemqaU/I7gsfF8uJJA7tFwPOiZCsG46G22cdQ6OoQ81niywgh9OlM99Y9/6By2WON2B162DPt3nEZGiBXNL1PA9XFwAO8QM7fbsqoZ3lRE9wz1c0eLM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941314733201.41445133411992; Mon, 31 Aug 2020 23:21:54 -0700 (PDT) Received: from localhost ([::1]:56848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzg1-0008AR-Rz for importer@patchew.org; Tue, 01 Sep 2020 02:21:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzee-0005zp-Bo for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:28 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45898 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 1kCzec-0000lQ-EZ for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:28 -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-212-42MuJNoLOcenhsp96w5W4A-1; Tue, 01 Sep 2020 02:20:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 239641DDF1; Tue, 1 Sep 2020 06:20:23 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4E7C1002393; Tue, 1 Sep 2020 06:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QG2WVA4E0ooYR/bAUcK1A88DLhADj01++WMdzTaU6bc=; b=OyqnEjuo4L6r+JOlu3SciAs5TFoamAEXwYzlVW4/WDllAuay2SGehZ92wHlaFl4+WCHEhb ewKD3UnkQfORmh+GzaBE05mBawxcLA/Gf5yZhJSNQeNgEm3/azdAkE7bkvxW0VsiXCq+i4 t6g3/IwAF8fdzxUAh+USefNvMaWWwgc= X-MC-Unique: 42MuJNoLOcenhsp96w5W4A-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 05/13] oslib-posix: relocate path to /var Date: Tue, 1 Sep 2020 02:20:12 -0400 Message-Id: <20200901062020.26660-6-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 22:05:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- util/oslib-posix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index a68fccb52d..8e23b8fac0 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -339,8 +339,10 @@ int qemu_pipe(int pipefd[2]) char * qemu_get_local_state_pathname(const char *relative_pathname) { - return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR, - relative_pathname); + g_autofree char *dir =3D g_strdup_printf("%s/%s", + CONFIG_QEMU_LOCALSTATEDIR, + relative_pathname); + return get_relocated_path(dir); } =20 void qemu_set_tty_echo(int fd, bool echo) --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941473; cv=none; d=zohomail.com; s=zohoarc; b=MVSPF859ET1XcUAB1Q7ACp5pUou/cM5Qop8EWEndZGf77qNjaKJb3yN2AQ99O2J1+a0fzL7N8EAGc0tvWxBReQftqZ+0uuom1TOgbEsoADEgNtxxNoDVKE/DYgpDhkRZdbPKe+lYPnz2qrkhOm/e+9pccw56NE0ySO0OwKcljo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941473; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qT7Og9yKc+ElkQOZ5LTq5q40H2+YJrt0WLYbBYCvK18=; b=Fq7IP3vj1Mn3LCl80kTgF5bT28MqTHNS5IrK74rWgfWTqS7gDOkAUW8kYDAiUlswiF7pWjcOiYEdQ9Co3gc/cWKzpi3oBZaxKpIFEsawc7ajY0WXnd4qPgg23dFps6rJ6X3RKIzObLJpw8JCP+cDnfuQVway2sYfEaisEW80Zm4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941473085806.5737964068595; Mon, 31 Aug 2020 23:24:33 -0700 (PDT) Received: from localhost ([::1]:44464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzia-00063F-C8 for importer@patchew.org; Tue, 01 Sep 2020 02:24:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzeg-00064K-U3 for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kCzef-0000nZ-D7 for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:30 -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-50-DTpM9OPHNeGybjQXzcY4cw-1; Tue, 01 Sep 2020 02:20:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81B661888A1F; Tue, 1 Sep 2020 06:20:23 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F5C71002393; Tue, 1 Sep 2020 06:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qT7Og9yKc+ElkQOZ5LTq5q40H2+YJrt0WLYbBYCvK18=; b=RcVTRVmMdkzy5L7deqhVNDcrMpUrfAYSPM3pz3VxamEx4nZEiTA32aQwHHiHQWFCPxlMNW al5dCo2CATsrmMR6HgVGX0EujzQ62X83HQyFXT1IAvM8YsEqYkoFy4JIjQsY16akFXbpia Ed80YMebjoYTFP/ioE3O3nRNnyMG6Rw= X-MC-Unique: DTpM9OPHNeGybjQXzcY4cw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 06/13] module: relocate path to modules Date: Tue, 1 Sep 2020 02:20:13 -0400 Message-Id: <20200901062020.26660-7-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 23:17:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- util/module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/module.c b/util/module.c index aed04b578a..c117d770fd 100644 --- a/util/module.c +++ b/util/module.c @@ -19,6 +19,7 @@ #endif #include "qemu/queue.h" #include "qemu/module.h" +#include "qemu/cutils.h" #ifdef CONFIG_MODULE_UPGRADES #include "qemu-version.h" #endif @@ -202,7 +203,7 @@ bool module_load_one(const char *prefix, const char *li= b_name) if (search_dir !=3D NULL) { dirs[n_dirs++] =3D g_strdup_printf("%s", search_dir); } - dirs[n_dirs++] =3D g_strdup_printf("%s", CONFIG_QEMU_MODDIR); + dirs[n_dirs++] =3D get_relocated_path(CONFIG_QEMU_MODDIR); dirs[n_dirs++] =3D g_strdup(qemu_get_exec_dir()); =20 #ifdef CONFIG_MODULE_UPGRADES --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941305; cv=none; d=zohomail.com; s=zohoarc; b=UrnD2PzysBjIPveZeOh5sEGOmKcRZpQwsXVN9XC26nLqsdFY0kvlftFzBOn/xVEZ0U4IlgzMXpGZeWHnmdqbfNSs5szROkUzBdDIjkS1q3/h+Z5yDaMVC0byX6IKyl4WndO1t3wJBxlz/bGSBjj9m+9AMGg9y2dEyUcBAL1w+1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941305; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fDAR9Gc1bkWQ8YVcuK3lfmWjcu2H3hixFFWXHzCayLk=; b=U3QyWkaTAZmHNn+btcUpF6KRpOI7iVxoLriEPmOaCSsDjzi39TbICRi4KwR7iD83IIhRlpDesxcRi1ee3KiR2GoUkOM1vYSPh9ihaVWCtijNOi3CHmqdVr26BZncVPhAs7WlM3vhitvCIBCGs6pZRJcx3m7CLIzrmo4OEw+vs20= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941305936568.3817231478004; Mon, 31 Aug 2020 23:21:45 -0700 (PDT) Received: from localhost ([::1]:55756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzft-0007jj-5f for importer@patchew.org; Tue, 01 Sep 2020 02:21:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzef-00061u-Gx for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:29 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:44629 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 1kCzed-0000lp-N4 for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:29 -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-238-namVbS7zPS2-VGEwNYqkvQ-1; Tue, 01 Sep 2020 02:20:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DFD811DDF0; Tue, 1 Sep 2020 06:20:23 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D6141002D4E; Tue, 1 Sep 2020 06:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fDAR9Gc1bkWQ8YVcuK3lfmWjcu2H3hixFFWXHzCayLk=; b=IdlIBhotY2sEE111Sjhp5lh4wdtRqNAsqr1gn0HE1hNH0BZymI4PFncXq6f4qRXGEHDY5e lpHqVTMl/tNxpSbfqytEsd8x33GkqUWozJPhZ+Fyld5VeoDaVl5H8Hv+vnoFA5efbXOxH0 cgcgYEYTcmVsPnnCtWvJGmfScnSfBqo= X-MC-Unique: namVbS7zPS2-VGEwNYqkvQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 07/13] net: relocate paths to helpers and scripts Date: Tue, 1 Sep 2020 02:20:14 -0400 Message-Id: <20200901062020.26660-8-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 22:05:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/net/net.h | 4 ++-- net/tap.c | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index e7ef42d62b..897b2d7595 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -209,8 +209,8 @@ void netdev_add(QemuOpts *opts, Error **errp); int net_hub_id_for_client(NetClientState *nc, int *id); NetClientState *net_hub_port_find(int hub_id); =20 -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" +#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_BRIDGE_INTERFACE "br0" =20 diff --git a/net/tap.c b/net/tap.c index 14dc904fca..a271046461 100644 --- a/net/tap.c +++ b/net/tap.c @@ -582,14 +582,20 @@ int net_init_bridge(const Netdev *netdev, const char = *name, NetClientState *peer, Error **errp) { const NetdevBridgeOptions *bridge; - const char *helper, *br; + g_autofree char *default_helper =3D NULL; + const char *helper; + const char *br; TAPState *s; int fd, vnet_hdr; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_BRIDGE); bridge =3D &netdev->u.bridge; =20 - helper =3D bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER; + if (!bridge->has_helper) { + helper =3D default_helper =3D get_relocated_path(DEFAULT_BRIDGE_HE= LPER); + } else { + helper =3D bridge->helper; + } br =3D bridge->has_br ? bridge->br : DEFAULT_BRIDGE_INTERF= ACE; =20 fd =3D net_bridge_run_helper(helper, br, errp); @@ -773,8 +779,8 @@ int net_init_tap(const Netdev *netdev, const char *name, const NetdevTapOptions *tap; int fd, vnet_hdr =3D 0, i =3D 0, queues; /* for the no-fd, no-helper case */ - const char *script =3D NULL; /* suppress wrong "uninit'd use" gcc warn= ing */ - const char *downscript =3D NULL; + const char *script; + const char *downscript; Error *err =3D NULL; const char *vhostfdname; char ifname[128]; @@ -784,6 +790,8 @@ int net_init_tap(const Netdev *netdev, const char *name, tap =3D &netdev->u.tap; queues =3D tap->has_queues ? tap->queues : 1; vhostfdname =3D tap->has_vhostfd ? tap->vhostfd : NULL; + script =3D tap->has_script ? tap->script : NULL; + downscript =3D tap->has_downscript ? tap->downscript : NULL; =20 /* QEMU hubs do not support multiqueue tap, in this case peer is set. * For -netdev, peer is always NULL. */ @@ -934,13 +942,19 @@ free_fail: return -1; } } else { + g_autofree char *default_script =3D NULL; + g_autofree char *default_downscript =3D NULL; if (tap->has_vhostfds) { error_setg(errp, "vhostfds=3D is invalid if fds=3D wasn't spec= ified"); return -1; } - script =3D tap->has_script ? tap->script : DEFAULT_NETWORK_SCRIPT; - downscript =3D tap->has_downscript ? tap->downscript : - DEFAULT_NETWORK_DOWN_SCRIPT; + + if (!tap->has_script) { + script =3D default_script =3D get_relocated_path(DEFAULT_NETWO= RK_SCRIPT); + } + if (!tap->has_downscript) { + downscript =3D default_downscript =3D get_relocated_path(DEFAU= LT_NETWORK_SCRIPT); + } =20 if (tap->has_ifname) { pstrcpy(ifname, sizeof ifname, tap->ifname); --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941393; cv=none; d=zohomail.com; s=zohoarc; b=huSaZngwZeKSOGzaBsp1f3NnRlcXBNhHT1vwj1SOSIbLsxGcqw0TavqpwmELy/Qeu+w6whd2weKaVW6C1ALMNtpnUoj/LfB308XwciMmJQ0LpzGBSDWfQGz3zxMMRvWG5G13YZFKvyb5bV2qd50A17rcerHy9Q3MdEjwc9rwJ04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941393; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K1ivvTlvLg7AQlWAjK0/Hz1PJE3X143Bw4l4uh4gfFc=; b=JQFbjt+kV2LbqBnkseDWoAAS2Wanj3f62x5a+MMfxlIv5SlPRcfUOm+flAnCzvbYCMWkOUfx/daLTVW+tMXiV4hSPDgVMHenCxxZLD3gyJl81cu0in1acJKNkZRDHt8c1vZnct0EfQQA+2Pi3vqf8kdjSzX9T3XM04B/MJoQ3mg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941393138630.7453324086783; Mon, 31 Aug 2020 23:23:13 -0700 (PDT) Received: from localhost ([::1]:36956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzhI-00033N-Cc for importer@patchew.org; Tue, 01 Sep 2020 02:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzeg-00062o-29 for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kCzed-0000mh-S7 for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:29 -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-297-jYoUgaLfOc2_ffBE7UYHOw-1; Tue, 01 Sep 2020 02:20:25 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49A0A1DDF6; Tue, 1 Sep 2020 06:20:24 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 073211002393; Tue, 1 Sep 2020 06:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K1ivvTlvLg7AQlWAjK0/Hz1PJE3X143Bw4l4uh4gfFc=; b=L3jKJAS0l5C03EY+leo/Rxqe3yE/eZIOq4zIT381zihKu2xzSIzXSWyMi7qME/nBb8gM/H +t9FnZZBMcd5Hh7KGhQzpoaAj/o6CBomBYTJvH/c4rN1G9fxLFojJ0hRdM6I6fDC/r57VS DI7GC/Mtu7S7Br/EaqkvVYlyik1jEiw= X-MC-Unique: jYoUgaLfOc2_ffBE7UYHOw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 08/13] vl: relocate paths to data directories Date: Tue, 1 Sep 2020 02:20:15 -0400 Message-Id: <20200901062020.26660-9-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/01 01:27:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" As an additional advantage, the logic is now unified between POSIX and Win32 systems. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu-common.h | 1 - include/sysemu/sysemu.h | 2 +- os-posix.c | 20 -------------------- os-win32.c | 11 ----------- softmmu/vl.c | 40 ++++++++++++++++++++++++++++------------ tests/qtest/fuzz/fuzz.c | 5 +++-- 6 files changed, 32 insertions(+), 47 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index bb9496bd80..b856bfcec4 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -131,7 +131,6 @@ char *qemu_find_file(int type, const char *name); =20 /* OS specific functions */ void os_setup_early_signal_handling(void); -char *os_find_datadir(void); int os_parse_cmd_args(int index, const char *optarg); =20 /* diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 4b6a5c459c..817ff4cf75 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -14,7 +14,7 @@ extern const char *qemu_name; extern QemuUUID qemu_uuid; extern bool qemu_uuid_set; =20 -void qemu_add_data_dir(const char *path); +void qemu_add_data_dir(char *path); =20 void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); diff --git a/os-posix.c b/os-posix.c index 8d8e7fc15c..af91089c01 100644 --- a/os-posix.c +++ b/os-posix.c @@ -80,26 +80,6 @@ void os_setup_signal_handling(void) sigaction(SIGTERM, &act, NULL); } =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. - * - * The caller must use g_free() to free the returned data when it is - * no longer required. - */ -char *os_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 g_strdup(CONFIG_QEMU_DATADIR); -} - void os_set_proc_name(const char *s) { #if defined(PR_SET_NAME) diff --git a/os-win32.c b/os-win32.c index eb8501b9e5..fd1137bab1 100644 --- a/os-win32.c +++ b/os-win32.c @@ -57,17 +57,6 @@ void os_setup_early_signal_handling(void) atexit(os_undo_timer_resolution); } =20 -/* - * Look for support files in the same directory as the executable. - * - * The caller must use g_free() to free the returned data when it is - * no longer required. - */ -char *os_find_datadir(void) -{ - return g_strdup(qemu_get_exec_dir()); -} - void os_set_line_buffering(void) { setbuf(stdout, NULL); diff --git a/softmmu/vl.c b/softmmu/vl.c index 0cc86b0766..81e325fa44 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2005,7 +2005,7 @@ char *qemu_find_file(int type, const char *name) return NULL; } =20 -void qemu_add_data_dir(const char *path) +void qemu_add_data_dir(char *path) { int i; =20 @@ -2017,10 +2017,11 @@ void qemu_add_data_dir(const char *path) } for (i =3D 0; i < data_dir_idx; i++) { if (strcmp(data_dir[i], path) =3D=3D 0) { - return; /* duplicate */ + g_free(path); /* duplicate */ + return; } } - data_dir[data_dir_idx++] =3D g_strdup(path); + data_dir[data_dir_idx++] =3D path; } =20 static inline bool nonempty_str(const char *str) @@ -2829,6 +2830,26 @@ static void create_default_memdev(MachineState *ms, = const char *path) &error_fatal); } =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_init(int argc, char **argv, char **envp) { int i; @@ -2862,7 +2883,7 @@ void qemu_init(int argc, char **argv, char **envp) Error *main_loop_err =3D NULL; Error *err =3D NULL; bool list_data_dirs =3D false; - char *dir, **dirs; + char **dirs; const char *mem_path =3D NULL; bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); @@ -3195,7 +3216,7 @@ void qemu_init(int argc, char **argv, char **envp) if (is_help_option(optarg)) { list_data_dirs =3D true; } else { - qemu_add_data_dir(optarg); + qemu_add_data_dir(g_strdup(optarg)); } break; case QEMU_OPTION_bios: @@ -3927,17 +3948,12 @@ void qemu_init(int argc, char **argv, char **envp) /* add configured firmware directories */ dirs =3D g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S= , 0); for (i =3D 0; dirs[i] !=3D NULL; i++) { - qemu_add_data_dir(dirs[i]); + qemu_add_data_dir(get_relocated_path(dirs[i])); } g_strfreev(dirs); =20 /* try to find datadir relative to the executable path */ - dir =3D os_find_datadir(); - qemu_add_data_dir(dir); - g_free(dir); - - /* add the datadir specified when building */ - qemu_add_data_dir(CONFIG_QEMU_DATADIR); + qemu_add_data_dir(find_datadir()); =20 /* -L help lists the data directories and exits. */ if (list_data_dirs) { diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 1811cb1d88..d9ef4b3e1e 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -170,8 +170,9 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char = ***envp) datadir =3D g_build_filename(bindir, "pc-bios", NULL); if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) { qemu_add_data_dir(datadir); - } - g_free(datadir); + } else { + g_free(datadir); + } } else if (*argc > 1) { /* The target is specified as an argument */ target_name =3D (*argv)[1]; if (!strstr(target_name, "--fuzz-target=3D")) { --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941306; cv=none; d=zohomail.com; s=zohoarc; b=IGNilfpqMl8c/HfjeoWwUZn1+Y3QC4WtUV70cPTDe7Ey+BbdQBHfW6PnMOg360HT7ZZXr7Bm1JKy+mEyhUnZfv/5Bt/UEmut/swhE08ujgT77f1BdZZfk9kTLIg55NXHk7NZfCkHcvQUYozBeKPBj7/qni6INp//0teTAg+qE3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941306; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5100EacLuYkDYltPVxHgmLdEsUFOENxvEHFQgPnV+LQ=; b=MuRhy955Z/OtznDXe559t+hlMcapQTYW0kWauTYoM8QP2Ou0q4pmd/c8GFYZIEZEXbHSIE593qj2QSY/frl1yD1oNgyMJQrD5mTCBE3IlYUdUiChXTBK+1DHluCAX9/de8Q1aX+rwphbB6LIDKpuAOTHjokPHSytbArv1g18gak= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941306099200.53775933594977; Mon, 31 Aug 2020 23:21:46 -0700 (PDT) Received: from localhost ([::1]:55838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzft-0007ld-5T for importer@patchew.org; Tue, 01 Sep 2020 02:21:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzeg-00063R-Ds for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:30 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:35347 helo=us-smtp-delivery-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 1kCzee-0000mj-04 for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:30 -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-473-SuNWgHeiNRCmX6A57Ag0AA-1; Tue, 01 Sep 2020 02:20:25 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A792F1888A24; Tue, 1 Sep 2020 06:20:24 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64FA31002393; Tue, 1 Sep 2020 06:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5100EacLuYkDYltPVxHgmLdEsUFOENxvEHFQgPnV+LQ=; b=OFlxLvUvB/W54Z42jw7Oj6y6Zngtxf3ocP+wFz4iscQJ/2bks9o7mLGLCa9C9NAx9j006j 5R9bzkdkuYXWUOSEXoVEuW69hwkGWDLPIUoQhVjC0EqGiFQPq76eexwNPX4hPylFc7ADWU u0HWydDyIqsOjYIlKrgY8A/erjbgM1I= X-MC-Unique: SuNWgHeiNRCmX6A57Ag0AA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 09/13] vl: relocate path to configuration file Date: Tue, 1 Sep 2020 02:20:16 -0400 Message-Id: <20200901062020.26660-10-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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.81; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/01 02:08:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- softmmu/vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 81e325fa44..b79de9cd66 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2676,8 +2676,9 @@ static int global_init_func(void *opaque, QemuOpts *o= pts, Error **errp) static int qemu_read_default_config_file(void) { int ret; + g_autofree char *file =3D get_relocated_path(CONFIG_QEMU_CONFDIR "/qem= u.conf"); =20 - ret =3D qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf"); + ret =3D qemu_read_config_file(file); if (ret < 0 && ret !=3D -ENOENT) { return ret; } --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941553; cv=none; d=zohomail.com; s=zohoarc; b=femFZ4jgpLDzZfMgV2HhfaBIez7qpe5EZUMGvVw3wXKVgdRxxzOFsls4HyXZAw0SH6QkNK0RNA8wXZdY0Lp6/rnZEGqtpQAvdEJ5dRPJtiTIJ6Une/hAPUpC1373u02ZWaTBOXBEeeUKP84sJDQGIsER7XYdI7zhzpbQcWJoFiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941553; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VPwMOZku7UBRQhHSdhV1lO2uk4iu6y/xIf7/rYHqH0c=; b=l3zF0iegthWNzBZyjH4Mo68bA096E/5dM08xwaEjH6fdnOHCR9tjHkMILnBJzXohhhVbWopEcY8PDFpMULavsldqLSq3XEu3j+stMZFodCyNLltQjyqJsHZuIT6op0gdkOCSUF055BQTNDebcNKYtf2bSodROmDmkfR6kukFSgQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941553457921.7445643274131; Mon, 31 Aug 2020 23:25:53 -0700 (PDT) Received: from localhost ([::1]:49316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzjr-00006Q-UR for importer@patchew.org; Tue, 01 Sep 2020 02:25:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzei-00067X-Dv for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:32 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42909 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 1kCzee-0000nP-K4 for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:32 -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-94-CzBJ730JOJ-lbBQ9LgPPBA-1; Tue, 01 Sep 2020 02:20:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 545FF10066FC; Tue, 1 Sep 2020 06:20:25 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1143178B26; Tue, 1 Sep 2020 06:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VPwMOZku7UBRQhHSdhV1lO2uk4iu6y/xIf7/rYHqH0c=; b=BDeqmTl+jRjjYJOAfaoRmWaeG61R1C41FhQdEoQWDdNip6+JOfFhybzHJ12Ohgl6I+ONGv 3nl3Z71FEcKeuIv427nrrc1u7+55wEf8OFnsnnwz63kSbj6gl7n7eM3SlvQKDUWfqqr/PJ MkGNwiZkHU2aeAm4AafEdNd1RXnfsXY= X-MC-Unique: CzBJ730JOJ-lbBQ9LgPPBA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 10/13] qemu-bridge-helper: relocate path to default ACL Date: Tue, 1 Sep 2020 02:20:17 -0400 Message-Id: <20200901062020.26660-11-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com 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=205.139.110.120; envelope-from=pbonzini@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 22:05:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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=-0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- qemu-bridge-helper.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c index 88b26747fc..a26e1663f0 100644 --- a/qemu-bridge-helper.c +++ b/qemu-bridge-helper.c @@ -40,6 +40,7 @@ #endif =20 #include "qemu/queue.h" +#include "qemu/cutils.h" =20 #include "net/tap-linux.h" =20 @@ -245,6 +246,7 @@ int main(int argc, char **argv) ACLList acl_list; int access_allowed, access_denied; int ret =3D EXIT_SUCCESS; + g_autofree char *acl_file =3D NULL; =20 #ifdef CONFIG_LIBCAP_NG /* if we're run from an suid binary, immediately drop privileges prese= rving @@ -257,6 +259,8 @@ int main(int argc, char **argv) } #endif =20 + qemu_init_exec_dir(argv[0]); + /* parse arguments */ for (index =3D 1; index < argc; index++) { if (strcmp(argv[index], "--use-vnet") =3D=3D 0) { @@ -282,9 +286,10 @@ int main(int argc, char **argv) =20 /* parse default acl file */ QSIMPLEQ_INIT(&acl_list); - if (parse_acl_file(DEFAULT_ACL_FILE, &acl_list) =3D=3D -1) { + acl_file =3D get_relocated_path(DEFAULT_ACL_FILE); + if (parse_acl_file(acl_file, &acl_list) =3D=3D -1) { fprintf(stderr, "failed to parse default acl file `%s'\n", - DEFAULT_ACL_FILE); + acl_file); ret =3D EXIT_FAILURE; goto cleanup; } --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941571; cv=none; d=zohomail.com; s=zohoarc; b=Xbdeava0aVS2WPVXvPnQNi0LATak+bMkM2FUc2K1IgshkYEoLjG9zbl2kyMqLA53uBiVzhajQDGcIjMboAcr6HxpTKOjlnVIt0mI+sKazYUkegurh+2uHwNO5OOzflIBR473BK+1h2RgDVlp4s5lkVbe0XfXts9LnuW4yMh1l5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941571; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XPqE+1RTgT7cBSEBGYwO//KNVPh3KzZA8Ugolxgl+TE=; b=A+p+THd/YjOqzaGXPPbRsD2y8UeRhnt/x8vibjjI8f4u3wV8fqQe+B5etZ6AFY+Qs1JMdcKTuIP/8uEGLLbin0qwYd/ccS+iO7Tl7fuiKIV0i5nTv2KINJXOuBIFEfiSsMuXcfi57sjUtU2S0hHl+eV1m8w/5JdYSOoyUU5vHDc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941571506595.719385387507; Mon, 31 Aug 2020 23:26:11 -0700 (PDT) Received: from localhost ([::1]:50628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzkA-0000eB-OR for importer@patchew.org; Tue, 01 Sep 2020 02:26:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzj7-00082k-8Q for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:25:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kCzj5-0001NI-Js for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:25:04 -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-130-SZOppECwOg657Fo9W6DdVQ-1; Tue, 01 Sep 2020 02:20:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B13C110066FE; Tue, 1 Sep 2020 06:20:25 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F32B78B46; Tue, 1 Sep 2020 06:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XPqE+1RTgT7cBSEBGYwO//KNVPh3KzZA8Ugolxgl+TE=; b=Od76Ri8ZTn3g01ftvHu+Z9TqaZEEss4ZXY/Um9GqrBikR8Ce/e4T4KQGNGzO4TJkgMETg6 /fpa1nmAbLzIeV5m6D1yBMZDszBX+zZo/0Hn453Taccoi7943f48dpEOizGhgxnhzzXE2x ynEkNdDAq1MCyFHKFqqn5xJfOEoAkKE= X-MC-Unique: SZOppECwOg657Fo9W6DdVQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 11/13] qga: relocate path to default configuration and hook Date: Tue, 1 Sep 2020 02:20:18 -0400 Message-Id: <20200901062020.26660-12-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/01 01:27:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- qga/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qga/main.c b/qga/main.c index 3febf3b0fd..740f5f7303 100644 --- a/qga/main.c +++ b/qga/main.c @@ -29,6 +29,7 @@ #include "qapi/error.h" #include "channel.h" #include "qemu/bswap.h" +#include "qemu/cutils.h" #include "qemu/help_option.h" #include "qemu/sockets.h" #include "qemu/systemd.h" @@ -968,7 +969,7 @@ static void config_load(GAConfig *config) { GError *gerr =3D NULL; GKeyFile *keyfile; - const char *conf =3D g_getenv("QGA_CONF") ?: QGA_CONF_DEFAULT; + g_autofree char *conf =3D g_strdup(g_getenv("QGA_CONF")) ?: get_reloca= ted_path(QGA_CONF_DEFAULT); =20 /* read system config */ keyfile =3D g_key_file_new(); @@ -1027,7 +1028,7 @@ end: if (gerr && !(gerr->domain =3D=3D G_FILE_ERROR && gerr->code =3D=3D G_FILE_ERR= OR_NOENT)) { g_critical("error loading configuration from path: %s, %s", - QGA_CONF_DEFAULT, gerr->message); + conf, gerr->message); exit(EXIT_FAILURE); } g_clear_error(&gerr); @@ -1141,7 +1142,7 @@ static void config_parse(GAConfig *config, int argc, = char **argv) #ifdef CONFIG_FSFREEZE case 'F': g_free(config->fsfreeze_hook); - config->fsfreeze_hook =3D g_strdup(optarg ?: QGA_FSFREEZE_HOOK= _DEFAULT); + config->fsfreeze_hook =3D g_strdup(optarg) ?: get_relocated_pa= th(QGA_FSFREEZE_HOOK_DEFAULT); break; #endif case 't': @@ -1463,6 +1464,7 @@ int main(int argc, char **argv) =20 config->log_level =3D G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL; =20 + qemu_init_exec_dir(argv[0]); qga_qmp_init_marshal(&ga_commands); =20 init_dfl_pathnames(); --=20 2.26.2 From nobody Fri May 17 21:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941384; cv=none; d=zohomail.com; s=zohoarc; b=MZR5iEUQXivyhffWnVhY2grk9zqmf0wKUab5IPS/CZYnNWaftDcAMJt11M8gllibD7Qrhj0vVQCn/hWimGXS+zrzCZ+jbpcTsNdNIKvThpwvHtsadrdrFGEDRVH32/wSXFWUHl3rQW3jfsz0wu9i21ICPzo8tq1Nd1/IhEknagk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941384; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pI5Jy3OYPqm2Gv6FAxa1jk28yZeAxya6itFzgt9QAso=; b=AUlSoHKl8Ft7MQi+ioC9LqK20eCpfvfsg7opXLIEOh9jwDrpgP18qWVlnrmw8IpvLhMgMBBcWm+pdIOALO+I9DD8+IqC7zZBmYIf8C9B0pEtM6R7DG165RvAc1diDd3RyNcX4dDVP9oMpwclmXAHCFN5UmM/1b6fk+9g0abYo3k= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941384394497.15174591506286; Mon, 31 Aug 2020 23:23:04 -0700 (PDT) Received: from localhost ([::1]:35992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzh9-0002fm-KZ for importer@patchew.org; Tue, 01 Sep 2020 02:23:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzeh-00065f-Ja for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kCzef-0000o0-R5 for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:31 -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-140-HHOh4Mu1PU6GAwaVRrF4sg-1; Tue, 01 Sep 2020 02:20:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1BC071888A1F; Tue, 1 Sep 2020 06:20:26 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD29B78B46; Tue, 1 Sep 2020 06:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pI5Jy3OYPqm2Gv6FAxa1jk28yZeAxya6itFzgt9QAso=; b=cojidpyDBx+TD1iudd6Oc7PSEeSy9EgUcwsfwQmczPFPLrroaFFGSHkHbpZ7wunrUVKjXF 0WxWhLV7703k38l+lsJ5HZFbUColJo/FwzJktpFovEn32+wJpALGMhZ0zHOY6t5csTeoSD QjpOcy8JgQjV/VGKqsLt9RxjoMwndng= X-MC-Unique: HHOh4Mu1PU6GAwaVRrF4sg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 12/13] ui: relocate paths to icons and translations Date: Tue, 1 Sep 2020 02:20:19 -0400 Message-Id: <20200901062020.26660-13-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 23:17:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ui/gtk.c | 10 ++++++++-- ui/sdl2.c | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index b0cc08ad6d..597f829ad9 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -51,6 +51,7 @@ #include =20 #include "trace.h" +#include "qemu/cutils.h" #include "ui/input.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" @@ -2200,6 +2201,7 @@ static void gtk_display_init(DisplayState *ds, Displa= yOptions *opts) GtkDisplayState *s =3D g_malloc0(sizeof(*s)); GdkDisplay *window_display; GtkIconTheme *theme; + char *dir; =20 if (!gtkinit) { fprintf(stderr, "gtk initialization failed\n"); @@ -2209,7 +2211,9 @@ static void gtk_display_init(DisplayState *ds, Displa= yOptions *opts) s->opts =3D opts; =20 theme =3D gtk_icon_theme_get_default(); - gtk_icon_theme_prepend_search_path(theme, CONFIG_QEMU_ICONDIR); + dir =3D get_relocated_path(CONFIG_QEMU_ICONDIR); + gtk_icon_theme_prepend_search_path(theme, dir); + g_free(dir); g_set_prgname("qemu"); =20 s->window =3D gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -2225,7 +2229,9 @@ static void gtk_display_init(DisplayState *ds, Displa= yOptions *opts) * sure that we don't accidentally break implicit assumptions. */ setlocale(LC_MESSAGES, ""); setlocale(LC_CTYPE, "C.UTF-8"); - bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR); + dir =3D get_relocated_path(CONFIG_QEMU_LOCALEDIR); + bindtextdomain("qemu", dir); + g_free(dir); bind_textdomain_codeset("qemu", "UTF-8"); textdomain("qemu"); =20 diff --git a/ui/sdl2.c b/ui/sdl2.c index b23a8f0a8e..abad7f981e 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -25,6 +25,7 @@ =20 #include "qemu/osdep.h" #include "qemu/module.h" +#include "qemu/cutils.h" #include "ui/console.h" #include "ui/input.h" #include "ui/sdl2.h" @@ -795,6 +796,7 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) int i; SDL_SysWMinfo info; SDL_Surface *icon =3D NULL; + char *dir; =20 assert(o->type =3D=3D DISPLAY_TYPE_SDL); =20 @@ -868,15 +870,18 @@ static void sdl2_display_init(DisplayState *ds, Displ= ayOptions *o) } =20 #ifdef CONFIG_SDL_IMAGE - icon =3D IMG_Load(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png"= ); + dir =3D get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/= qemu.png"); + icon =3D IMG_Load(dir); #else /* Load a 32x32x4 image. White pixels are transparent. */ - icon =3D SDL_LoadBMP(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp= "); + 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); } #endif + g_free(dir); if (icon) { SDL_SetWindowIcon(sdl2_console[0].real_window, icon); } --=20 2.26.2 From nobody Fri May 17 21:46:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598941488; cv=none; d=zohomail.com; s=zohoarc; b=Fzu6IOHNv/b+zYxanvDSCvM9c6b0S5T4/JnTQFnJgYG2zMCQnFxQhw+SS2dtlL9cfaUBXH5Trq31r+NjIGoPZzWdoOtaEH+uJBPPuqewvgSqkOR1asANqA6cku28vdzRnXAr9IYEn3RbS382eZBhuhXyGutLa/AQZF10Ay8eb6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598941488; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=o0QobZlwjsT7Kc8fp1pirRRsg0TYlKZXjIQ1EVrG5A4=; b=SIAMLtwFgzK6c3uyCrS7wcd5B36nOr7ym2jnjBz/rIjPS33AYttDeymHbCJ4fA80kHXrqLd3s4NWZSNC+3T4W6cZ85OY82KldkQf5rMFxd1Mzy2gYY/JBqrP/pIqlXaZr+9PUSfSrO4lGCb5M7nGhBfwh89pQMo5STkjk6q0mA0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598941488703800.789194403922; Mon, 31 Aug 2020 23:24:48 -0700 (PDT) Received: from localhost ([::1]:45940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCzip-0006jB-VD for importer@patchew.org; Tue, 01 Sep 2020 02:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCzem-0006Hn-7w for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kCzek-0000qO-At for qemu-devel@nongnu.org; Tue, 01 Sep 2020 02:20:35 -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-384-fwH-5IC5OEiQMsBO_dhWVg-1; Tue, 01 Sep 2020 02:20:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7948C801AE2; Tue, 1 Sep 2020 06:20:26 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 376BE78B26; Tue, 1 Sep 2020 06:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598941233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o0QobZlwjsT7Kc8fp1pirRRsg0TYlKZXjIQ1EVrG5A4=; b=ivhYmmDY4QHP5BTaSw6fUThdo3PRhRiyOd3za+VLoZfncmaTAczQTXRPx4HliCpLblLwWZ IQDP6bkNwcASwFZjhj18/vxnHSdzv8coVs32Olp/aOF3swWytsC4nPJz4WzYmdvkykLIp0 w0YjbbimdQu68yZh4UXKbP34Rw3Pfa4= X-MC-Unique: fwH-5IC5OEiQMsBO_dhWVg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 13/13] configure: use a platform-neutral prefix Date: Tue, 1 Sep 2020 02:20:20 -0400 Message-Id: <20200901062020.26660-14-pbonzini@redhat.com> In-Reply-To: <20200901062020.26660-1-pbonzini@redhat.com> References: <20200901062020.26660-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0.0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 23:17:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now that the installation is relocatable, there is no need to compile a Windows-format prefix into Win32 binaries. Instead, the prefix will only be used to compute installation-relative paths, and it can be any string. Drop the "Program Files" path completely: it is only usable on English versions of Windows; therefore, using the NSIS installer to get the "correct" path to the Program Files folder is recommended, and NSIS works just as well with any prefix. Signed-off-by: Paolo Bonzini --- configure | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/configure b/configure index 105e780c09..558b3579db 100755 --- a/configure +++ b/configure @@ -1009,7 +1009,7 @@ if test "$mingw32" =3D "yes" ; then if compile_prog "" "-liberty" ; then LIBS=3D"-liberty $LIBS" fi - prefix=3D"c:/Program Files/QEMU" + prefix=3D"/qemu" qemu_suffix=3D"" libs_qga=3D"-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi = -lnetapi32 $libs_qga" fi @@ -8145,17 +8145,9 @@ echo "strip =3D $(meson_quote $strip)" >> $cross echo "windres =3D $(meson_quote $windres)" >> $cross if test -n "$cross_prefix"; then cross_arg=3D"--cross-file config-meson.cross" - # Hack: Meson expects an absolute path for the *build* machine - # for the prefix, so add a slash in front of a Windows path that - # includes a drive letter. - # - # See https://github.com/mesonbuild/meson/issues/7577. echo "[host_machine]" >> $cross if test "$mingw32" =3D "yes" ; then echo "system =3D 'windows'" >> $cross - case $prefix in - ?:*) pre_prefix=3D/ ;; - esac fi case "$ARCH" in i386|x86_64) @@ -8181,16 +8173,16 @@ mv $cross config-meson.cross =20 rm -rf meson-private meson-info meson-logs NINJA=3D${ninja:-$PWD/ninjatool} $meson setup \ - --prefix "${pre_prefix}$prefix" \ - --libdir "${pre_prefix}$libdir" \ - --libexecdir "${pre_prefix}$libexecdir" \ - --bindir "${pre_prefix}$bindir" \ - --includedir "${pre_prefix}$includedir" \ - --datadir "${pre_prefix}$datadir" \ - --mandir "${pre_prefix}$mandir" \ - --sysconfdir "${pre_prefix}$sysconfdir" \ - --localstatedir "${pre_prefix}$local_statedir" \ - -Ddocdir=3D"${pre_prefix}$docdir" \ + --prefix "$prefix" \ + --libdir "$libdir" \ + --libexecdir "$libexecdir" \ + --bindir "$bindir" \ + --includedir "$includedir" \ + --datadir "$datadir" \ + --mandir "$mandir" \ + --sysconfdir "$sysconfdir" \ + --localstatedir "$local_statedir" \ + -Ddocdir=3D"$docdir" \ -Dqemu_suffix=3D"$qemu_suffix" \ -Doptimization=3D$(if test "$debug" =3D yes; then echo 0; else ech= o 2; fi) \ -Ddebug=3D$(if test "$debug_info" =3D yes; then echo true; else ec= ho false; fi) \ --=20 2.26.2