Skip to content

Commit

Permalink
vmupdate: Send SIGUSR1 to meminfo-writer
Browse files Browse the repository at this point in the history
The current implementation restart the meminfo-writer service after
changing the selinux label which can sometime take a while for the
memory to go back to normal.
Instead, send a USR1 signal to the meminfo-writer process to change the
memory immediately, which also assure smooth selinux updates
installation in the future.
  • Loading branch information
Minimalist73 committed Jan 17, 2025
1 parent 7301b1c commit 7f317f2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions vmupdate/agent/source/plugins/fix_meminfo_writer_label.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import subprocess
import os
import signal


def fix_meminfo_writer_label(os_data, log, **kwargs):
Expand Down Expand Up @@ -33,9 +34,13 @@ def fix_meminfo_writer_label(os_data, log, **kwargs):

if label_changed:
try:
subprocess.check_call(
["systemctl", "restart", "qubes-meminfo-writer"]
with open("/run/meminfo-writer.pid", "r", encoding="utf-8") as f:
target_pid = int(f.read().strip())
os.kill(target_pid, signal.SIGUSR1)
log.info(
f"USR1 signal sent to meminfo-writer process id: {target_pid}"
)
except (FileNotFoundError, ValueError, OSError) as e:
log.error(
f"Error sending USR1 signal to meminfo-writer process: {e}"
)
log.info("qubes-meminfo-writer service restarted")
except subprocess.CalledProcessError as e:
log.error(f"Error restarting qubes-meminfo-writer service: {e}")

0 comments on commit 7f317f2

Please sign in to comment.