nbd-proxy: listen for udev change event before running start hook
Currently, we run the start state-change hook as soon as the nbd session
has been established. However, at that point the nbd device isn't
connected, as we haven't processed any read/write operations on the
block device.
This change defers running the start script until we know that the
device is initialised - when we see a udev change event occur. To do
this, we establish a udev monitor.
Once we see that state change, we run the state change hooks and shut
down the udev monitor.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/Makefile.am b/Makefile.am
index e494d27..ffeb594 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,8 +2,10 @@
nbd_proxy_CPPFLAGS = \
$(JSON_CFLAGS) \
+ $(UDEV_CFLAGS) \
-DRUNSTATEDIR=\"$(localstatedir)/run\" \
-DSYSCONFDIR=\"$(sysconfdir)\"
nbd_proxy_LDADD = \
- $(JSON_LIBS)
+ $(JSON_LIBS) \
+ $(UDEV_LIBS)