dhcp: add dnsmasq dhcp-hostsdir

Add dhcp-hostsdir to support IP reservation.

BUG=b/321300259
TEST=manual

Change-Id: Ibb3700e0279d455faebd0a01f39f3c765a01d654
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/moblab/+/5366942
Tested-by: Tomasz Jakubowski <jakubowskit@google.com>
Reviewed-by: Jacek Klimkowicz <klimkowicz@google.com>
Commit-Queue: Tomasz Jakubowski <jakubowskit@google.com>
diff --git a/os-dependent/chromeos/upstart-scripts/moblab-dhcp.conf b/os-dependent/chromeos/upstart-scripts/moblab-dhcp.conf
index 1ba07d3..a026838 100644
--- a/os-dependent/chromeos/upstart-scripts/moblab-dhcp.conf
+++ b/os-dependent/chromeos/upstart-scripts/moblab-dhcp.conf
@@ -131,6 +131,12 @@
     --restart always \
     gcr.io/chromeos-partner-moblab/moblab-dhcp:release \
     ${DEV_ARGS} --interface "${INT_IFACE}" --bind-interfaces
+  # create dhcp-hostsdir if it doesn't exist and restart the DHCP server
+  DHCP_HOSTSDIR="/var/lib/misc/dhcp_hosts"
+  if ! [ -d "${DHCP_HOSTSDIR}" ]; then
+    docker exec dhcp mkdir -p ${DHCP_HOSTSDIR}
+    docker exec dhcp killall -HUP dnsmasq || true
+  fi
 
   logger -t "$UPSTART_JOB" "Ending."
 end script
diff --git a/src/dockerfiles/dhcp/dnsmasq-dev.conf b/src/dockerfiles/dhcp/dnsmasq-dev.conf
index a715ec2..a1dfe2d 100644
--- a/src/dockerfiles/dhcp/dnsmasq-dev.conf
+++ b/src/dockerfiles/dhcp/dnsmasq-dev.conf
@@ -8,3 +8,4 @@
 
 dhcp-range=192.168.231.10,192.168.231.250,1h
 dhcp-broadcast
+dhcp-hostsdir=/var/lib/misc/dhcp_hosts
diff --git a/src/dockerfiles/dhcp/dnsmasq.conf b/src/dockerfiles/dhcp/dnsmasq.conf
index 149e56c..f1bda2b 100644
--- a/src/dockerfiles/dhcp/dnsmasq.conf
+++ b/src/dockerfiles/dhcp/dnsmasq.conf
@@ -8,3 +8,4 @@
 
 dhcp-range=192.168.231.10,192.168.231.250,720h
 dhcp-broadcast
+dhcp-hostsdir=/var/lib/misc/dhcp_hosts