Skip to content

Instantly share code, notes, and snippets.

@apatard
Created November 16, 2020 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apatard/61c39a684c5d7eaff35d89a43104bd3c to your computer and use it in GitHub Desktop.
Save apatard/61c39a684c5d7eaff35d89a43104bd3c to your computer and use it in GitHub Desktop.
diff --git a/tools/test-setup.sh b/tools/test-setup.sh
index 4d2b09d..9c12333 100755
--- a/tools/test-setup.sh
+++ b/tools/test-setup.sh
@@ -22,7 +22,18 @@ sudo $PYTHON -m pip install -U tox
# === LIBVIRT SETUP ===
sudo systemctl enable --now libvirtd
+sudo sed \
+ -e 's!^[# ]*unix_sock_rw_perms = .*$!unix_sock_rw_perms = "0777"!g' \
+ -e 's!^[# ]*auth_unix_rw = .*$!auth_unix_rw = "polkit"!g' -i /etc/libvirt/libvirtd.conf
+# on fedora, looks like virbr0 iface stays there after a restart of libvirt but the network is not
+# started back, leading to network failure when the script tries to start the network
+sudo virsh net-destroy default
+sudo systemctl restart libvirtd
sudo usermod --append --groups libvirt "$(whoami)"
+# on some dists, it's auto-started, on some others, it's not
+if virsh -c qemu:///system net-list --name --inactive | grep -w default 2>&1 >/dev/null; then
+ virsh -c qemu:///system net-start default
+fi
# only info about the virtualisation is wanted, so no error please.
sudo virt-host-validate qemu || true
@@ -127,6 +138,5 @@ vagrant plugin list | tee >(grep -q "No plugins installed." && {
# we will use during testing.
cd $DIR
-# sudo su: dirty hack to make sure that usermod change has been taken into account
-sudo su -l "$(whoami)" -c "cd $(pwd) && timeout 300 vagrant up --no-tty --no-provision --debug"
-sudo su -l "$(whoami)" -c "cd $(pwd) && vagrant destroy -f"
+timeout 300 vagrant up --no-tty --no-provision --debug
+vagrant destroy -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment