]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Create directory for lease files if it's missing
authorGuido Günther <agx@sigxcpu.org>
Sun, 7 Jul 2013 12:59:48 +0000 (14:59 +0200)
committerGuido Günther <agx@sigxcpu.org>
Tue, 16 Jul 2013 17:46:31 +0000 (19:46 +0200)
If we don't autostart a network it's not being created.

Debian Bug http://bugs.debian.org/715200

src/nwfilter/nwfilter_dhcpsnoop.c

index 0965f6301deccdf7ead1174a16477879baad8c18..3e9f0465891cb7e12dca646be4dbb083f98b3264 100644 (file)
@@ -74,8 +74,9 @@
 
 #ifdef HAVE_LIBPCAP
 
-# define LEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.leases"
-# define TMPLEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.ltmp"
+# define LEASEFILE_DIR LOCALSTATEDIR "/run/libvirt/network/"
+# define LEASEFILE LEASEFILE_DIR "nwfilter.leases"
+# define TMPLEASEFILE LEASEFILE_DIR "nwfilter.ltmp"
 
 struct virNWFilterSnoopState {
     /* lease file */
@@ -1881,6 +1882,11 @@ virNWFilterSnoopLeaseFileRefresh(void)
 {
     int tfd;
 
+    if (virFileMakePathWithMode(LEASEFILE_DIR, 0700) < 0) {
+        virReportError(errno, _("mkdir(\"%s\")"), LEASEFILE_DIR);
+        return;
+    }
+
     if (unlink(TMPLEASEFILE) < 0 && errno != ENOENT)
         virReportSystemError(errno, _("unlink(\"%s\")"), TMPLEASEFILE);