[Libguestfs] [PATCH v2 1/4] appliance: Use dhclient instead of hard-coding IP address of appliance.

Richard W.M. Jones rjones at redhat.com
Thu Oct 2 11:39:56 UTC 2014

qemu in SLIRP mode offers DHCP services to the appliance.  We don't
use them, but use a fixed IP address intead.  This changes the
appliance to get its IP address using DHCP.

Note: This is only used when the network is enabled.  dhclient is
somewhat slower, but the penalty (a few seconds) is only paid for
network users.  We could consider using the faster systemd dhcp client
 appliance/init           | 9 +++------
 appliance/packagelist.in | 1 +
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/appliance/init b/appliance/init
index 6d62338..d688a52 100755
--- a/appliance/init
+++ b/appliance/init
@@ -79,12 +79,9 @@ hwclock -u -s
 ip addr add brd + dev lo scope host
 ip link set dev lo up
-ip addr add brd + dev eth0 scope global
-ip link set dev eth0 up
-ip route add default via
-echo nameserver > /etc/resolv.conf
+if grep -sq guestfs_network=1 /proc/cmdline; then
+    dhclient
 # Scan for MDs.
 mdadm -As --auto=yes --run
diff --git a/appliance/packagelist.in b/appliance/packagelist.in
index 276b4c2..4e93eaf 100644
--- a/appliance/packagelist.in
+++ b/appliance/packagelist.in
@@ -210,6 +210,7 @@ binutils

More information about the Libguestfs mailing list