Skip to content

Commit

Permalink
fix: enable qubes memory management to sys-bitcoin
Browse files Browse the repository at this point in the history
Upstream issue: QubesOS/qubes-issues#8936

Helped-by: Atrate <[email protected]>
  • Loading branch information
ben-grande committed Jan 15, 2025
1 parent f3a89c4 commit 6998174
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions salt/sys-bitcoin/create.sls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{#
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 10 additions & 3 deletions salt/sys-bitcoin/files/server/bin/bitcoin-dbcache
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/bin/sh
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <[email protected]>
## SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. <[email protected]>
##
## 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
6 changes: 3 additions & 3 deletions salt/sys-bitcoin/install-common.sls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{#
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 6998174

Please sign in to comment.