Suspected sync issue while starting application from Qubes menu


I like tinkering with application settings, so I use the rc.local script to copy application settings to /tmp and symlink the .config folder to /tmp where the files can be found. This way, if I mess up with some settings, restarting the VM will restore the settings to the original state. And this method works… for 99% of cases.

On some occasions, starting an application from the menu ended up with the application complaining about configuration file not found. But by the time I look at /tmp folder, the file is there.

The name of the application is irrelevant. I have been using it for years and I am sure it is nut buggy in term of not able to see the config file while the file is already in the expected place. Read-write permissions are as needed.

I could only came up with the following hypothesis of what could be happening in the 1% of cases:

  1. I clicked the menu item, and dom0 starts the required VM.

  2. After dom0 gets signal from the VM that it is up, dom0 tells the VM to run the required application.

But somehow in the step number 2 dom0 told the VM to start the application too soon. In fact, the application has been started when the rc.local script was still running. That might explain why the application did not find the config file, but when I looked, the config file was there.

In short, I suspect it is a synchronisation problem.

So my question is: Is there any trick to make sure application started from Qubes menu while appVM is not yet running runs only after the rc.local script has finished?


You can probably enforce to run rc.local before any user applications by changing service ordering. Something like this in /etc/systemd/system/qubes-misc-post.service.d/30_user.conf (directory needs to be created) the template:


(totally untested)

May not be entirely relevant (seems to be the other way around in relation to what you need), but your question reminded me of this answer about another VM startup race condition:

what I like to do is: define a custom shell script for your app start inside the qube.
Inside, block app execution until the shell process for /rw/config/rc.local has finished:

# this is the blocking snippet for rc.local
[ -z "$(pgrep -f "/bin/sh /rw/config/rc.local")" ] || \
  tail --pid=$(pgrep -f "/bin/sh /rw/config/rc.local") -f /dev/null;

# continue application start here