]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
admin: Throw a system error when 'open' fails on user-provided output
authorErik Skultety <eskultet@redhat.com>
Fri, 31 Mar 2017 08:05:08 +0000 (10:05 +0200)
committerErik Skultety <eskultet@redhat.com>
Fri, 31 Mar 2017 10:07:07 +0000 (12:07 +0200)
There was an unhandled 'open' call which resulted in:

"error: Library function returned error but did not set virError"

Even if this happens during the daemon's start when we still don't have
any set of outputs defined yet, we can safely report an error, since we
automatically fallback to stderr which is fine even for both
running as a daemonized process, since this happens before the daemon
forks into the background, and running as a systemd service, since
systemd re-directs std outputs to journald by default.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1436060

Signed-off-by: Erik Skultety <eskultet@redhat.com>
src/util/virlog.c

index 7b584f8e37a58af6c23550f8cc7a3b3043c925bf..7933e1a7a043eefbd0bd23fd94189c5aa3b646a6 100644 (file)
@@ -750,8 +750,10 @@ virLogNewOutputToFile(virLogPriority priority,
     virLogOutputPtr ret = NULL;
 
     fd = open(file, O_CREAT | O_APPEND | O_WRONLY, S_IRUSR | S_IWUSR);
-    if (fd < 0)
+    if (fd < 0) {
+        virReportSystemError(errno, _("failed to open %s"), file);
         return NULL;
+    }
 
     if (!(ret = virLogOutputNew(virLogOutputToFd, virLogCloseFd,
                                 (void *)(intptr_t)fd,