- update hv_kvp_daemon (merge 0783d72fa from v3.9-rc1)

Fix how ifcfg-* file is created

OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=59
This commit is contained in:
Olaf Hering 2013-07-15 14:17:26 +00:00 committed by Git OBS Bridge
parent 1051dacf7e
commit d58ac4b8e0
3 changed files with 56 additions and 50 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Jul 15 16:16:06 CEST 2013 - ohering@suse.de
- update hv_kvp_daemon (merge 0783d72fa from v3.9-rc1)
Fix how ifcfg-* file is created
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Jul 15 15:24:00 CEST 2013 - ohering@suse.de Mon Jul 15 15:24:00 CEST 2013 - ohering@suse.de

View File

@ -1177,16 +1177,13 @@ static int process_ip_string(FILE *f, char *ip_string, int type)
snprintf(str, sizeof(str), "%s", "DNS"); snprintf(str, sizeof(str), "%s", "DNS");
break; break;
} }
if (i != 0) {
if (type != DNS) { if (type == DNS) {
snprintf(sub_str, sizeof(sub_str),
"_%d", i++);
} else {
snprintf(sub_str, sizeof(sub_str),
"%d", ++i);
}
} else if (type == DNS) {
snprintf(sub_str, sizeof(sub_str), "%d", ++i); snprintf(sub_str, sizeof(sub_str), "%d", ++i);
} else if (type == GATEWAY && i == 0) {
++i;
} else {
snprintf(sub_str, sizeof(sub_str), "%d", i++);
} }
@ -1206,17 +1203,13 @@ static int process_ip_string(FILE *f, char *ip_string, int type)
snprintf(str, sizeof(str), "%s", "DNS"); snprintf(str, sizeof(str), "%s", "DNS");
break; break;
} }
if ((j != 0) || (type == DNS)) {
if (type != DNS) { if (type == DNS) {
snprintf(sub_str, sizeof(sub_str), snprintf(sub_str, sizeof(sub_str), "%d", ++i);
"_%d", j++); } else if (j == 0) {
} else { ++j;
snprintf(sub_str, sizeof(sub_str), } else {
"%d", ++i); snprintf(sub_str, sizeof(sub_str), "_%d", j++);
}
} else if (type == DNS) {
snprintf(sub_str, sizeof(sub_str),
"%d", ++i);
} }
} else { } else {
return HV_INVALIDARG; return HV_INVALIDARG;
@ -1259,18 +1252,19 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
* Here is the format of the ip configuration file: * Here is the format of the ip configuration file:
* *
* HWADDR=macaddr * HWADDR=macaddr
* IF_NAME=interface name * DEVICE=interface name
* DHCP=yes (This is optional; if yes, DHCP is configured) * BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured
* or "none" if no boot-time protocol should be used)
* *
* IPADDR=ipaddr1 * IPADDR0=ipaddr1
* IPADDR_1=ipaddr2 * IPADDR1=ipaddr2
* IPADDR_x=ipaddry (where y = x + 1) * IPADDRx=ipaddry (where y = x + 1)
* *
* NETMASK=netmask1 * NETMASK0=netmask1
* NETMASK_x=netmasky (where y = x + 1) * NETMASKx=netmasky (where y = x + 1)
* *
* GATEWAY=ipaddr1 * GATEWAY=ipaddr1
* GATEWAY_x=ipaddry (where y = x + 1) * GATEWAYx=ipaddry (where y = x + 1)
* *
* DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) * DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
* *
@ -1310,12 +1304,12 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
if (error) if (error)
goto setval_error; goto setval_error;
error = kvp_write_file(file, "IF_NAME", "", if_name); error = kvp_write_file(file, "DEVICE", "", if_name);
if (error) if (error)
goto setval_error; goto setval_error;
if (new_val->dhcp_enabled) { if (new_val->dhcp_enabled) {
error = kvp_write_file(file, "DHCP", "", "yes"); error = kvp_write_file(file, "BOOTPROTO", "", "dhcp");
if (error) if (error)
goto setval_error; goto setval_error;
@ -1323,6 +1317,11 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
* We are done!. * We are done!.
*/ */
goto setval_done; goto setval_done;
} else {
error = kvp_write_file(file, "BOOTPROTO", "", "none");
if (error)
goto setval_error;
} }
/* /*

View File

@ -10,18 +10,19 @@
# Here is the format of the ip configuration file: # Here is the format of the ip configuration file:
# #
# HWADDR=macaddr # HWADDR=macaddr
# IF_NAME=interface name # DEVICE=interface name
# DHCP=yes (This is optional; if yes, DHCP is configured) # BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured
# or "none" if no boot-time protocol should be used)
# #
# IPADDR=ipaddr1 # IPADDR0=ipaddr1
# IPADDR_1=ipaddr2 # IPADDR1=ipaddr2
# IPADDR_x=ipaddry (where y = x + 1) # IPADDRx=ipaddry (where y = x + 1)
# #
# NETMASK=netmask1 # NETMASK0=netmask1
# NETMASK_x=netmasky (where y = x + 1) # NETMASKx=netmasky (where y = x + 1)
# #
# GATEWAY=ipaddr1 # GATEWAY=ipaddr1
# GATEWAY_x=ipaddry (where y = x + 1) # GATEWAYx=ipaddry (where y = x + 1)
# #
# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) # DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
# #
@ -53,8 +54,8 @@ else
fi fi
# remove known config variables from environment # remove known config variables from environment
unset HWADDR unset HWADDR
unset DHCP unset BOOTPROTO
unset IF_NAME unset DEVICE
unset ${!IPADDR*} unset ${!IPADDR*}
unset ${!NETMASK*} unset ${!NETMASK*}
unset ${!GATEWAY*} unset ${!GATEWAY*}
@ -64,9 +65,9 @@ unset ${!IPV6_DEFAULTGW*}
unset ${!DNS*} unset ${!DNS*}
. "$1" . "$1"
# #
if test -z "${IF_NAME}" if test -z "${DEVICE}"
then then
echo "Missing IF_NAME= in ${cfg}" echo "Missing DEVICE= in ${cfg}"
exit 1 exit 1
fi fi
# #
@ -91,7 +92,7 @@ fi
: # ignore HWADDR, it just repeats the existing MAC value : # ignore HWADDR, it just repeats the existing MAC value
fi fi
# #
if test "${DHCP}" = "yes" if test "${BOOTPROTO}" = "dhcp"
then then
echo "BOOTPROTO=dhcp" echo "BOOTPROTO=dhcp"
fi fi
@ -145,11 +146,11 @@ fi
( (
if test -n "${GATEWAY}" if test -n "${GATEWAY}"
then then
echo "default $GATEWAY - $IF_NAME" echo "default $GATEWAY - $DEVICE"
fi fi
if test -n "${IPV6_DEFAULTGW}" if test -n "${IPV6_DEFAULTGW}"
then then
echo "default $IPV6_DEFAULTGW - $IF_NAME" echo "default $IPV6_DEFAULTGW - $DEVICE"
fi fi
) >> "${t_ifroute}" ) >> "${t_ifroute}"
# Only a single default gateway is supported # Only a single default gateway is supported
@ -172,14 +173,14 @@ do
fi fi
done done
# #
echo "$0: working on network interface ifcfg-${IF_NAME}" echo "$0: working on network interface ifcfg-${DEVICE}"
cp -fb ${t_ifcfg} "/etc/sysconfig/network/ifcfg-${IF_NAME}" cp -fb ${t_ifcfg} "/etc/sysconfig/network/ifcfg-${DEVICE}"
cp -fb ${t_ifroute} "/etc/sysconfig/network/ifroute-${IF_NAME}" cp -fb ${t_ifroute} "/etc/sysconfig/network/ifroute-${DEVICE}"
if test -w /etc/sysconfig/network/config if test -w /etc/sysconfig/network/config
then then
sed -i "s@^NETCONFIG_DNS_STATIC_SERVERS=.*@NETCONFIG_DNS_STATIC_SERVERS='$_DNS_'@" /etc/sysconfig/network/config sed -i "s@^NETCONFIG_DNS_STATIC_SERVERS=.*@NETCONFIG_DNS_STATIC_SERVERS='$_DNS_'@" /etc/sysconfig/network/config
netconfig update -m dns netconfig update -m dns
fi fi
ifdown "${IF_NAME}" ifdown "${DEVICE}"
ifup "${IF_NAME}" ifup "${DEVICE}"
) 2>&1 | logger -t "${0##*/}[$PPID / $$]" ) 2>&1 | logger -t "${0##*/}[$PPID / $$]"