]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
leaseshelper: Report errors on failure
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 15:09:08 +0000 (16:09 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 4 Jan 2021 14:33:30 +0000 (15:33 +0100)
If leasehelper fails all that we are left with is a simple error
message produced by dnsmasq:

  lease-init script returned exit code 1

This is because the leasehelper did not write any message to
stderr. According to dnsmasq's manpage, whenever it's invoking
leasehelper the stderr is kept open:

  All file descriptors are closed except stdin, which is open to
  /dev/null, and stdout and stderr which capture output for
  logging by dnsmasq.

As debugging leasehelper is not trivial (because dnsmasq invokes
it with plenty of env vars set - that's how data is passed onto
helper), let's print an error into stderr if exiting with an
error. And since we are not calling public APIs, we have to call
virDispatchError() explicitly and since we don't have any
connection open, we have to pass NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/network/leaseshelper.c

index 732dd0961095402d860bf2f4271860dffb1ae3ad..c20e63efa9339608a706df0f94a699e1e1cdd2a1 100644 (file)
@@ -253,6 +253,8 @@ main(int argc, char **argv)
     rv = EXIT_SUCCESS;
 
  cleanup:
+    if (rv != EXIT_SUCCESS)
+        virDispatchError(NULL);
     if (pid_file_fd != -1)
         virPidFileReleasePath(pid_file, pid_file_fd);