From 69981744d1af6a0e7110a6baada096dc8bf83b44 Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Wed, 15 Jan 2025 17:05:06 +0100 Subject: [PATCH] fix: enable qubes memory management to sys-bitcoin Upstream issue: https://github.com/QubesOS/qubes-issues/issues/8936 Helped-by: Atrate --- salt/sys-bitcoin/create.sls | 4 ++-- salt/sys-bitcoin/files/server/bin/bitcoin-dbcache | 13 ++++++++++--- salt/sys-bitcoin/install-common.sls | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/salt/sys-bitcoin/create.sls b/salt/sys-bitcoin/create.sls index 030e1188..252ed683 100644 --- a/salt/sys-bitcoin/create.sls +++ b/salt/sys-bitcoin/create.sls @@ -1,5 +1,5 @@ {# -SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. SPDX-License-Identifier: AGPL-3.0-or-later #} @@ -87,10 +87,10 @@ features: - enable: - servicevm - service.bitcoin-server + - service.meminfo-writer - disable: - service.cups - service.cups-browsed - - service.meminfo-writer - set: - menu-items: "qubes-run-terminal.desktop qubes-start.desktop" tags: diff --git a/salt/sys-bitcoin/files/server/bin/bitcoin-dbcache b/salt/sys-bitcoin/files/server/bin/bitcoin-dbcache index 00aa7c0e..ec2dde68 100755 --- a/salt/sys-bitcoin/files/server/bin/bitcoin-dbcache +++ b/salt/sys-bitcoin/files/server/bin/bitcoin-dbcache @@ -1,11 +1,18 @@ #!/bin/sh -## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. +## SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. ## ## SPDX-License-Identifier: AGPL-3.0-or-later set -eu conf="${HOME}/.bitcoin/conf.d/dbcache.conf" -cache_Mi="$(awk -- '/^MemTotal:/{printf "%.0f", $2/1024}' /proc/meminfo)" -cache="$((cache_Mi*75/100))" +domid="$(xenstore-read -- domid)" +xenstore_mem_dir="/local/domain/${domid}/memory" +if test -f /var/run/qubes-service/meminfo-writer; then + mem_KiB="$(xenstore-read -- "${xenstore_mem_dir}/hotplug-max")" +else + mem_KiB="$(xenstore-read -- "${xenstore_mem_dir}/static-max")" +fi +cache_MiB=$((mem_KiB/1024)) +cache="$((cache_MiB*80/100))" printf '%s\n' "dbcache=${cache}" | tee -- "${conf}" >/dev/null diff --git a/salt/sys-bitcoin/install-common.sls b/salt/sys-bitcoin/install-common.sls index e941ba65..b1591de6 100644 --- a/salt/sys-bitcoin/install-common.sls +++ b/salt/sys-bitcoin/install-common.sls @@ -1,5 +1,5 @@ {# -SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. SPDX-License-Identifier: AGPL-3.0-or-later #} @@ -59,8 +59,8 @@ include: - source: salt://{{ slsdotpath }}/files/server/bin/ - file_mode: '0755' - dir_mode: '0755' - - user: user - - group: user + - user: root + - group: root - makedirs: True "{{ slsdotpath }}-rpc":