From 4da05e52d89bd2de3a79999a7f6744e80dfa300a Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Wed, 13 Jul 2011 20:16:04 +0200 Subject: [PATCH] vm: more reliably set IP address of VM --- appvm/qubes_core_appvm | 7 ------- common/qubes_core | 6 ++++++ common/setup_ip | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/appvm/qubes_core_appvm b/appvm/qubes_core_appvm index cb1fe53..a4c2465 100755 --- a/appvm/qubes_core_appvm +++ b/appvm/qubes_core_appvm @@ -50,13 +50,6 @@ start() usleep 10 done echo Back to life. - # Fix IP address (replace template IP with DispVM one) - IP=$(/usr/bin/xenstore-read qubes_ip 2>/dev/null) - if [ "$IP" ]; then - ip addr flush dev eth0 - ip addr add dev eth0 $IP/32 - ip route add dev eth0 - fi fi MEM_CHANGE_THRESHOLD_KB=30000 diff --git a/common/qubes_core b/common/qubes_core index 357be8a..74158a6 100755 --- a/common/qubes_core +++ b/common/qubes_core @@ -26,6 +26,12 @@ start() hostname $name fi + # Set IP address again (besides action in udev rules); this is needed by + # DispVM (to override DispVM-template IP) and in case when qubes_ip was + # called by udev before loading evtchn kernel module - in which case + # xenstore-read fails + INTERFACE=eth0 /usr/lib/qubes/setup_ip + if [ -e /dev/xvdb ] ; then mount /rw diff --git a/common/setup_ip b/common/setup_ip index aec795e..61f197c 100755 --- a/common/setup_ip +++ b/common/setup_ip @@ -1,10 +1,10 @@ #!/bin/sh -ip=`/usr/bin/xenstore-read qubes_ip` -netmask=`/usr/bin/xenstore-read qubes_netmask` -gateway=`/usr/bin/xenstore-read qubes_gateway` -secondary_dns=`/usr/bin/xenstore-read qubes_secondary_dns` +ip=`/usr/bin/xenstore-read qubes_ip 2> /dev/null` if [ x$ip != x ]; then + netmask=`/usr/bin/xenstore-read qubes_netmask` + gateway=`/usr/bin/xenstore-read qubes_gateway` + secondary_dns=`/usr/bin/xenstore-read qubes_secondary_dns` /sbin/ifconfig $INTERFACE $ip netmask 255.255.255.255 /sbin/ifconfig $INTERFACE up /sbin/route add default dev $INTERFACE