[libvirt] [PATCH] Create directory for lease files if it's missing

If we don't autostart a network it's not being created. Debian Bug http://bugs.debian.org/715200 --- src/nwfilter/nwfilter_dhcpsnoop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 0965f63..3e9f046 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -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); -- 1.8.3.2

On Thu, Jul 11, 2013 at 07:33:52PM +0200, Guido Günther wrote:
If we don't autostart a network it's not being created.
Debian Bug http://bugs.debian.org/715200
Ping? -- Guido
--- src/nwfilter/nwfilter_dhcpsnoop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 0965f63..3e9f046 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -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);
-- 1.8.3.2
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Tue, Jul 16, 2013 at 04:04:56PM +0200, Guido Günther wrote:
On Thu, Jul 11, 2013 at 07:33:52PM +0200, Guido Günther wrote:
If we don't autostart a network it's not being created.
Debian Bug http://bugs.debian.org/715200
Ping? -- Guido
--- src/nwfilter/nwfilter_dhcpsnoop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 0965f63..3e9f046 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -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);
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Tue, Jul 16, 2013 at 03:18:25PM +0100, Daniel P. Berrange wrote:
On Tue, Jul 16, 2013 at 04:04:56PM +0200, Guido Günther wrote:
On Thu, Jul 11, 2013 at 07:33:52PM +0200, Guido Günther wrote:
If we don't autostart a network it's not being created.
Debian Bug http://bugs.debian.org/715200
Ping? -- Guido
--- src/nwfilter/nwfilter_dhcpsnoop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 0965f63..3e9f046 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -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);
ACK Pushed. Thanks! -- Guido
participants (2)
-
Daniel P. Berrange
-
Guido Günther