[Libguestfs] [PATCH v2 1/4] appliance: Use dhclient instead of hard-coding IP address of appliance.
Pino Toscano
ptoscano at redhat.com
Thu Oct 2 12:21:59 UTC 2014
On Thursday 02 October 2014 12:39:56 Richard W.M. Jones wrote:
> 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
> instead.
> ---
> 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 127.0.0.1/8 brd + dev lo scope host
> ip link set dev lo up
>
> -ip addr add 169.254.2.10/16 brd + dev eth0 scope global
> -ip link set dev eth0 up
> -
> -ip route add default via 169.254.2.2
> -
> -echo nameserver 169.254.2.3 > /etc/resolv.conf
> +if grep -sq guestfs_network=1 /proc/cmdline; then
> + dhclient
> +fi
When I tried v1 of this patch, with direct backend I still needed the
manual filling of /etc/resolv.conf, otherwise it was not able to resolve
names.
> 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
> bzip2
> coreutils
> cpio
> +dhclient
> diffutils
> dosfstools
> e2fsprogs
This should be moved to the REDHAT section, as this package name differs
between distributions:
- REDHAT: dhclient
- DEBIAN: isc-dhcp-client
- ARCHLINUX: dhclient
--
Pino Toscano
More information about the Libguestfs
mailing list