* [PATCH] make kvm service script transfer dhclient settings correctly
@ 2007-09-15 17:09 Ferry Huberts
[not found] ` <46EC11AE.9090408-NbsvJix5b8QAvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Ferry Huberts @ 2007-09-15 17:09 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
[-- Attachment #1: Type: text/plain, Size: 3054 bytes --]
Hi list,
I mailed about this earlier (may 7th, 2007) but the issue is still there: the
handling surrounding DHCP clients could be a bit improved...
Currently every dhcp client gets killed after which a very basic dhcp client is
started for the dst interface, which is not really inline with what the rest of
the script does: the settings of the src interface are transferred to the dst
interface.
I wrote a new patch to bring the handling of the dhcp client inline with the
reset of the script:
- only the dhclient that is running on the src interface gets killed,
- the commandline options of the killed dhcp client get reused for the new dhcp
client (running on dst)
- when no running dhcp client can be found on the src interface then a basic
dhcp client is started.
There is only one assumption in this script: the interface on which the dhcp
client is running must be the last argument on the commandline of the dhcp client.
I checked this assumption for Fedora 6 and 7 and it is met.
The patch is against kvm-snapshot-20070914 (since kvm-39 does not allow
insertion for me)
Hope this patch is a bit more palatable for you than the previous one :-)
Ferry
--- kvm.org 2007-09-14 19:17:29.000000000 +0200
+++ kvm 2007-09-15 18:46:34.000000000 +0200
@@ -124,15 +124,15 @@
fi
if [ $BOOTPROTO = "dhcp" ]; then
+ local dhclientcmd=`getdhclientcmdandkill ${src} ${dst}`
ifdown ${src} >/dev/null 2>&1 || true
ip link set ${src} up >/dev/null 2>&1
bond_link_up ${src}
- pkill dhclient >/dev/null 2>&1
for ((i=0;i<3;i++)); do
pgrep dhclient >/dev/null 2>&1 || i=4
sleep 1
done
- dhclient ${dst} >/dev/null 2>&1
+ ${dhclientcmd} >/dev/null 2>&1
else
get_ip_info ${src}
ifconfig ${src} 0.0.0.0
@@ -141,6 +141,44 @@
ip route add default via ${gateway} dev ${dst}
fi
}
+
+getdhclientcmdandkill () {
+ local src=$1
+ local dst=$2
+
+ # get pids for all running dhclients
+ local pidlist=`pgrep dhclient`
+
+ # get the commandline of the dhclient that is currently running on ${src}
+ local clientpid=""
+ local newcmdline=""
+ for i in ${pidlist} ; do
+ local cmdline_i=`ps -o args= ${i} | grep -E "[[:space:]]+${src}\$"`
+ if [ -n "${cmdline_i}" ] ; then
+ newcmdline=${cmdline_i}
+ clientpid=${i}
+ break
+ fi
+ done
+
+ if [ -n "${newcmdline}" ] ; then
+ # we found a dhclient running on ${src}: adjust the command line so
+ # that it will run on ${dst}
+ echo "${newcmdline}" | sed -r "s#[[:space:]]+${src}\$# ${dst}#"
+ kill ${clientpid} >/dev/null 2>&1
+ else
+ # we did not find a dhclient running on ${src}
+
+ # see if there is a configfile for the pif and use it when available
+ cffile="/etc/dhclient-${pif}.conf"
+ cfoption=""
+ if [ -r ${cffile} ]; then
+ cfoption="-cf ${cffile}"
+ fi
+ echo "dhclient ${cfoption} ${dst}"
+ pkill dhclient >/dev/null 2>&1
+ fi
+}
antispoofing () {
iptables -P FORWARD DROP >/dev/null 2>&1
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 391 bytes --]
--- kvm 2007-06-07 17:13:47.000000000 +0200
+++ /etc/init.d/kvm 2007-07-05 21:06:43.000000000 +0200
@@ -132,7 +132,7 @@
pgrep dhclient >/dev/null 2>&1 || i=4
sleep 1
done
- dhclient ${dst} >/dev/null 2>&1
+ dhclient -cf /etc/dhclient-${pif}.conf ${dst} >/dev/null 2>&1
else
get_ip_info ${src}
ifconfig ${src} 0.0.0.0
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] make kvm service script transfer dhclient settings correctly
[not found] ` <46EC11AE.9090408-NbsvJix5b8QAvxtiuMwx3w@public.gmane.org>
@ 2007-09-16 9:18 ` Avi Kivity
[not found] ` <46ECF4E2.9000203-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2007-09-16 9:18 UTC (permalink / raw)
To: Ferry Huberts; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Ferry Huberts wrote:
> Hi list,
>
> I mailed about this earlier (may 7th, 2007) but the issue is still
> there: the handling surrounding DHCP clients could be a bit improved...
>
> Currently every dhcp client gets killed after which a very basic dhcp
> client is started for the dst interface, which is not really inline
> with what the rest of the script does: the settings of the src
> interface are transferred to the dst interface.
>
> I wrote a new patch to bring the handling of the dhcp client inline
> with the reset of the script:
> - only the dhclient that is running on the src interface gets killed,
> - the commandline options of the killed dhcp client get reused for the
> new dhcp client (running on dst)
> - when no running dhcp client can be found on the src interface then a
> basic dhcp client is started.
>
> There is only one assumption in this script: the interface on which
> the dhcp client is running must be the last argument on the
> commandline of the dhcp client.
>
> I checked this assumption for Fedora 6 and 7 and it is met.
>
> The patch is against kvm-snapshot-20070914 (since kvm-39 does not
> allow insertion for me)
>
> Hope this patch is a bit more palatable for you than the previous one :-)
>
I really recommend against using the kvm initscript... it is fragile is
broken. On Fedora, you can use the standard initscripts (well, they are
fragile and broken too, but they are more complete than the kvm initscript):
[avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-sw0
DEVICE=sw0
BOOTPROTO=dhcp
HWADDR=00:0F:EA:6E:1E:F0
ONBOOT=yes
TYPE=Bridge
DHCP_HOSTNAME=blast
[avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BRIDGE=sw0
HWADDR=00:0F:EA:6E:1E:F0
ONBOOT=yes
TYPE=Ethernet
This setup starts dhcp directly on the bridge, without the need to move
things around. See especially the 'TYPE=Bridge' and 'BRIDGE=sw0'
statements.
Is there a reason to use the kvm initscript instead of this?
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] make kvm service script transfer dhclient settings correctly
[not found] ` <46ECF4E2.9000203-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-09-16 9:39 ` Ferry Huberts
[not found] ` <46ECF9DB.5020208-NbsvJix5b8QAvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Ferry Huberts @ 2007-09-16 9:39 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Avi Kivity wrote:
> Ferry Huberts wrote:
>> Hi list,
>>
>> I mailed about this earlier (may 7th, 2007) but the issue is still
>> there: the handling surrounding DHCP clients could be a bit improved...
>>
>> Currently every dhcp client gets killed after which a very basic dhcp
>> client is started for the dst interface, which is not really inline
>> with what the rest of the script does: the settings of the src
>> interface are transferred to the dst interface.
>>
>> I wrote a new patch to bring the handling of the dhcp client inline
>> with the reset of the script:
>> - only the dhclient that is running on the src interface gets killed,
>> - the commandline options of the killed dhcp client get reused for
>> the new dhcp client (running on dst)
>> - when no running dhcp client can be found on the src interface then
>> a basic dhcp client is started.
>>
>> There is only one assumption in this script: the interface on which
>> the dhcp client is running must be the last argument on the
>> commandline of the dhcp client.
>>
>> I checked this assumption for Fedora 6 and 7 and it is met.
>>
>> The patch is against kvm-snapshot-20070914 (since kvm-39 does not
>> allow insertion for me)
>>
>> Hope this patch is a bit more palatable for you than the previous one
>> :-)
>>
>
>
> I really recommend against using the kvm initscript... it is fragile
> is broken. On Fedora, you can use the standard initscripts (well,
> they are fragile and broken too, but they are more complete than the
> kvm initscript):
>
> [avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-sw0
> DEVICE=sw0
> BOOTPROTO=dhcp
> HWADDR=00:0F:EA:6E:1E:F0
> ONBOOT=yes
> TYPE=Bridge
> DHCP_HOSTNAME=blast
>
> [avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
> DEVICE=eth0
> BRIDGE=sw0
> HWADDR=00:0F:EA:6E:1E:F0
> ONBOOT=yes
> TYPE=Ethernet
>
>
> This setup starts dhcp directly on the bridge, without the need to
> move things around. See especially the 'TYPE=Bridge' and 'BRIDGE=sw0'
> statements.
>
> Is there a reason to use the kvm initscript instead of this?
>
no, just thought that since it's included in the kvm distribution I'd
use it. Seemed a logical conclusion that this one would be the
recommended way to do it. I'll just as happy convert to the distribution
scripts now. But maybe it's a good idea then to remove the script and
replace it with a text file on how to setup the config files. If you
don't remove the script maybe the patch can go in? At least it makes the
script more robust than it is.
You seem to use the same MAC address for both your interfaces Avi. Is
this on purpose?
Ferry
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] make kvm service script transfer dhclient settings correctly
[not found] ` <46ECF9DB.5020208-NbsvJix5b8QAvxtiuMwx3w@public.gmane.org>
@ 2007-09-16 9:52 ` Avi Kivity
[not found] ` <46ECFCF8.2020002-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-16 9:55 ` Dor Laor
1 sibling, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2007-09-16 9:52 UTC (permalink / raw)
To: Ferry Huberts; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Ferry Huberts wrote:
> Avi Kivity wrote:
>> Ferry Huberts wrote:
>>> Hi list,
>>>
>>> I mailed about this earlier (may 7th, 2007) but the issue is still
>>> there: the handling surrounding DHCP clients could be a bit improved...
>>>
>>> Currently every dhcp client gets killed after which a very basic
>>> dhcp client is started for the dst interface, which is not really
>>> inline with what the rest of the script does: the settings of the
>>> src interface are transferred to the dst interface.
>>>
>>> I wrote a new patch to bring the handling of the dhcp client inline
>>> with the reset of the script:
>>> - only the dhclient that is running on the src interface gets killed,
>>> - the commandline options of the killed dhcp client get reused for
>>> the new dhcp client (running on dst)
>>> - when no running dhcp client can be found on the src interface then
>>> a basic dhcp client is started.
>>>
>>> There is only one assumption in this script: the interface on which
>>> the dhcp client is running must be the last argument on the
>>> commandline of the dhcp client.
>>>
>>> I checked this assumption for Fedora 6 and 7 and it is met.
>>>
>>> The patch is against kvm-snapshot-20070914 (since kvm-39 does not
>>> allow insertion for me)
>>>
>>> Hope this patch is a bit more palatable for you than the previous
>>> one :-)
>>>
>>
>>
>> I really recommend against using the kvm initscript... it is fragile
>> is broken. On Fedora, you can use the standard initscripts (well,
>> they are fragile and broken too, but they are more complete than the
>> kvm initscript):
>>
>> [avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-sw0
>> DEVICE=sw0
>> BOOTPROTO=dhcp
>> HWADDR=00:0F:EA:6E:1E:F0
>> ONBOOT=yes
>> TYPE=Bridge
>> DHCP_HOSTNAME=blast
>>
>> [avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
>> DEVICE=eth0
>> BRIDGE=sw0
>> HWADDR=00:0F:EA:6E:1E:F0
>> ONBOOT=yes
>> TYPE=Ethernet
>>
>>
>> This setup starts dhcp directly on the bridge, without the need to
>> move things around. See especially the 'TYPE=Bridge' and
>> 'BRIDGE=sw0' statements.
>>
>> Is there a reason to use the kvm initscript instead of this?
>>
> no, just thought that since it's included in the kvm distribution I'd
> use it. Seemed a logical conclusion that this one would be the
> recommended way to do it. I'll just as happy convert to the
> distribution scripts now. But maybe it's a good idea then to remove
> the script and replace it with a text file on how to setup the config
> files. If you don't remove the script maybe the patch can go in? At
> least it makes the script more robust than it is.
>
I'll remove the script unless anyone sees an objection?
> You seem to use the same MAC address for both your interfaces Avi. Is
> this on purpose?
Not really. I just added lines until it worked. But I think it makes
sense -- you need the mac address for eth0 so it can detect the card,
and you need one for the switch, and since the real card won't use its
address this is a good choice.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] make kvm service script transfer dhclient settings correctly
[not found] ` <46ECF9DB.5020208-NbsvJix5b8QAvxtiuMwx3w@public.gmane.org>
2007-09-16 9:52 ` Avi Kivity
@ 2007-09-16 9:55 ` Dor Laor
1 sibling, 0 replies; 6+ messages in thread
From: Dor Laor @ 2007-09-16 9:55 UTC (permalink / raw)
To: Ferry Huberts; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Avi Kivity
[-- Attachment #1.1: Type: text/plain, Size: 1759 bytes --]
Ferry Huberts wrote:
>
> Avi Kivity wrote:
> >
> >
> > I really recommend against using the kvm initscript... it is fragile
> > is broken. On Fedora, you can use the standard initscripts (well,
> > they are fragile and broken too, but they are more complete than the
> > kvm initscript):
> >
> > [avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-sw0
> > DEVICE=sw0
> > BOOTPROTO=dhcp
> > HWADDR=00:0F:EA:6E:1E:F0
> > ONBOOT=yes
> > TYPE=Bridge
> > DHCP_HOSTNAME=blast
> >
> > [avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
> > DEVICE=eth0
> > BRIDGE=sw0
> > HWADDR=00:0F:EA:6E:1E:F0
> > ONBOOT=yes
> > TYPE=Ethernet
> >
> >
> > This setup starts dhcp directly on the bridge, without the need to
> > move things around. See especially the 'TYPE=Bridge' and 'BRIDGE=sw0'
> > statements.
> >
> > Is there a reason to use the kvm initscript instead of this?
> >
> no, just thought that since it's included in the kvm distribution I'd
> use it. Seemed a logical conclusion that this one would be the
> recommended way to do it. I'll just as happy convert to the distribution
> scripts now. But maybe it's a good idea then to remove the script and
> replace it with a text file on how to setup the config files. If you
> don't remove the script maybe the patch can go in? At least it makes the
> script more robust than it is.
>
> You seem to use the same MAC address for both your interfaces Avi. Is
> this on purpose?
>
> Ferry
>
Actually the propose was to have a script that can handle both creation
of a bridge and bonding together.
Last time I checked I couldn't add a bridge over bonding.
It's also nice to have a distribution agnostic script but I agree that
we should drop it since the its better to use
distribution tools instead.
[-- Attachment #1.2: Type: text/html, Size: 2613 bytes --]
[-- Attachment #2: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
[-- Attachment #3: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] make kvm service script transfer dhclient settings correctly
[not found] ` <46ECFCF8.2020002-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-09-16 18:28 ` Daniel P. Berrange
0 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrange @ 2007-09-16 18:28 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Ferry Huberts
On Sun, Sep 16, 2007 at 11:52:56AM +0200, Avi Kivity wrote:
> Ferry Huberts wrote:
> > Avi Kivity wrote:
> >> Ferry Huberts wrote:
> >>
> >>
> >> I really recommend against using the kvm initscript... it is fragile
> >> is broken. On Fedora, you can use the standard initscripts (well,
> >> they are fragile and broken too, but they are more complete than the
> >> kvm initscript):
I entirely agree with your recommendation against using the kvm initscript.
We don't include in the Fedora KVM rpms, and the equivalent script shipped
with Xen has inflicted untold misery & bug report chaos. Using the distro
specific initscripts for setting up bridges is a much more predictable and
reliable approach.
> >>
> >> [avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-sw0
> >> DEVICE=sw0
> >> BOOTPROTO=dhcp
> >> HWADDR=00:0F:EA:6E:1E:F0
> >> ONBOOT=yes
> >> TYPE=Bridge
> >> DHCP_HOSTNAME=blast
> >>
> >> [avi@blast ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
> >> DEVICE=eth0
> >> BRIDGE=sw0
> >> HWADDR=00:0F:EA:6E:1E:F0
> >> ONBOOT=yes
> >> TYPE=Ethernet
> >>
> >>
> >> This setup starts dhcp directly on the bridge, without the need to
> >> move things around. See especially the 'TYPE=Bridge' and
> >> 'BRIDGE=sw0' statements.
This is similar to the way we document bridge setup in Fedora, although
for the sake of consistent nomenculture with Xen, we have peth0 being the
physical device & eth0 being the bridge device. Either way its just naming,
the end result is functionally the same.
Libvirt also provides a 'virtual network' which is an isolated bridge
device, connected to the physical devices using NAT as our 'out of the box'
connectivity.
There's a short blog post with recommendations for KVM networking on Fedora
http://watzmann.net/blog/index.php/2007/04/27/networking_with_kvm_and_libvirt
> I'll remove the script unless anyone sees an objection?
Gets my vote.
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-09-16 18:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-15 17:09 [PATCH] make kvm service script transfer dhclient settings correctly Ferry Huberts
[not found] ` <46EC11AE.9090408-NbsvJix5b8QAvxtiuMwx3w@public.gmane.org>
2007-09-16 9:18 ` Avi Kivity
[not found] ` <46ECF4E2.9000203-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-16 9:39 ` Ferry Huberts
[not found] ` <46ECF9DB.5020208-NbsvJix5b8QAvxtiuMwx3w@public.gmane.org>
2007-09-16 9:52 ` Avi Kivity
[not found] ` <46ECFCF8.2020002-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-09-16 18:28 ` Daniel P. Berrange
2007-09-16 9:55 ` Dor Laor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox