Published: 2022-02-07 Last modified: 2022-02-07
Ever wondered why two similar VMs behave differently, for example one VM may access some network resource while for the other the access is denied?
There are five commands one can run in dom0 which provide VM configuration info:
qvm-tags
, qvm-service
, qvm-prefs
, qvm-features
, and, last but not least, qvm-firewall
.
But to run all of them manually and to compare the results for different VMs is a bit tedious. The following Bash function automatizes this task.
Usage example (run in dom0)
~$ qubes-vm-diff home-VM work-VM
Put this in dom0 ~/.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
qubes-vm-diff() {
[[ $# -eq 2 ]] || { echo "need 2 arguments (VM names)"; exit; }
# check that the arguments are indeed VM names
for arg in $1 $2; do
qvm-ls --raw-list | grep -qx "$arg" || { echo "No such VM: '$arg'"; exit; }
done
echo "comparing $1 and $2"
# loop through all the relevant 'qvm-<command>' commands and diff the outputs
for command in {tags,service,prefs,features,firewall}; do
echo "diff $(tput setaf 2) qvm-$command $(tput sgr0) of $1 and $2:" (1)
diff <(qvm-$command $1|sort) <(qvm-$command $2|sort)
done
}
1 | $(tput …) commands added for visibility. $(tput setaf 2) sets the font color to green, $(tput sgr0) reverts it back to default. See man tput and man terminfo . If you are still suspicious, remove those commands, so the line simply become echo "diff qvm-$command of $1 and $2:" . |