[PATCH] libxl: Create log directory earlier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit d9f19c30d054c86b15a304f4118baa4fa75af9d2 moved a lot of the
configuration setup into libxlDriverConfigNew().
However that tries to create the libxl/libxl-driver.log before the
libxl directory gets created in libxlStateInitialize().

This causes the daemon to fail on systems that have not had the directory
created before.

Move the code to create the libxl directory into libxlDriverConfigNew().

Signed-off-by: Stefan Bader <stefan.bader@xxxxxxxxxxxxx>
---
 src/libxl/libxl_conf.c   |    8 ++++++++
 src/libxl/libxl_driver.c |    7 -------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index a6bf1cf..56bb84a 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1108,6 +1108,14 @@ libxlDriverConfigNew(void)
     if (virAsprintf(&log_file, "%s/libxl-driver.log", cfg->logDir) < 0)
         goto error;
 
+    if (virFileMakePath(cfg->logDir) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("failed to create log dir '%s': %s"),
+                       cfg->logDir,
+                       virStrerror(errno, ebuf, sizeof(ebuf)));
+        goto error;
+    }
+
     if ((cfg->logger_file = fopen(log_file, "a")) == NULL)  {
         VIR_ERROR(_("Failed to create log file '%s': %s"),
                   log_file, virStrerror(errno, ebuf, sizeof(ebuf)));
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 0c6672b..e6316a7 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -306,13 +306,6 @@ libxlStateInitialize(bool privileged,
         goto error;
 
     libxl_driver->config = cfg;
-    if (virFileMakePath(cfg->logDir) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to create log dir '%s': %s"),
-                       cfg->logDir,
-                       virStrerror(errno, ebuf, sizeof(ebuf)));
-        goto error;
-    }
     if (virFileMakePath(cfg->stateDir) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("failed to create state dir '%s': %s"),
-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]