From be37ac1a83aabe85ccd09b7540c884a0a8e85802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Sat, 7 Dec 2024 23:13:44 +0000 Subject: Exit nicely, even if a VM doesn't have MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there is no '' tag, then the xmllint call will fail, and since we are running with `set -e`, then it will terminate the script. Before a VM not using routed-subnet would cause the following error: error: Hook script execution failed: internal error: \ Child process (LC_ALL=C PATH=<...> /etc/libvirt/hooks/qemu \ prepare begin -) unexpected exit status 10 Signed-off-by: Asbjørn Sloth Tønnesen --- qemu | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qemu b/qemu index b4272dd..9324f63 100755 --- a/qemu +++ b/qemu @@ -53,7 +53,10 @@ get_config(){ local ns='https://2e8.dk/libvirt-routed-subnet' local query = "//*[local-name()='$tag' and namespace-uri()='$ns']" fullxml="$(cat "$configfile")" - routingxml="$(xpath "$query" "$fullxml")" + routingxml="$(xpath "$query" "$fullxml" || true)" + if [ -z "$routingxml" ] ; then + exit 0 + fi } get_device(){ -- cgit v1.2.1