[libvirt] [PATCH v2 12/13] nwfilter: Move creation of configDir to driver initialization

John Ferlan jferlan at redhat.com
Tue Apr 25 19:30:32 UTC 2017


Rather than "wait" for the first config file to be created, force creation
of the configDir during driver state initialization.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/conf/nwfilter_conf.c       | 7 -------
 src/nwfilter/nwfilter_driver.c | 7 +++++++
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 752d4e1..032700c 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2778,13 +2778,6 @@ virNWFilterSaveXML(const char *configDir,
     if (!(configFile = virFileBuildPath(configDir, def->name, ".xml")))
         goto cleanup;
 
-    if (virFileMakePath(configDir) < 0) {
-        virReportSystemError(errno,
-                             _("cannot create config directory '%s'"),
-                             configDir);
-        goto cleanup;
-    }
-
     virUUIDFormat(def->uuid, uuidstr);
     ret = virXMLSaveFile(configFile,
                          virXMLPickShellSafeComment(def->name, uuidstr),
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index faa4fe8..5e62023 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -40,6 +40,7 @@
 #include "nwfilter_driver.h"
 #include "nwfilter_gentech_driver.h"
 #include "configmake.h"
+#include "virfile.h"
 #include "virstring.h"
 #include "viraccessapicheck.h"
 
@@ -237,6 +238,12 @@ nwfilterStateInitialize(bool privileged,
 
     VIR_FREE(base);
 
+    if (virFileMakePathWithMode(driver->configDir, S_IRWXU) < 0) {
+        virReportSystemError(errno, _("cannot create config directory '%s'"),
+                             driver->configDir);
+        goto error;
+    }
+
     if (!(driver->nwfilters = virNWFilterObjListNew()))
         goto error;
 
-- 
2.9.3




More information about the libvir-list mailing list