All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virt-test: support static ip address in framework
@ 2011-12-19 13:11 Amos Kong
  2011-12-20  3:14 ` Qingtang Zhou
  2011-12-20 19:03 ` Lucas Meneghel Rodrigues
  0 siblings, 2 replies; 5+ messages in thread
From: Amos Kong @ 2011-12-19 13:11 UTC (permalink / raw)
  To: autotest; +Cc: lmr, wquan, kvm, jasowang, kristof.katus, qzhou

Sometime, we need to test with guest(s) which have static ip
address(es).
eg. No real/emulated DHCP server in test environment.
eg. Test with old image we don't want to change the net config.
eg. Test when DHCP exists problem.

This is an example of using static ip address:
1. edit ifcfg-eth0 of guest to assign static IP
   (192.168.100.110). You can also do this by install
   post-script/serial.
2. add and setup bridge in host
   # brctl addbr vbr
   # ifconfig vbr 192.168.100.1
3. add script for setup tap device
   /etc/qemu-ifup-vbr
   | #!/bin/sh
   | switch=vbr
   | /sbin/ifconfig $1 0.0.0.0 up
   | /usr/sbin/brctl addif ${switch} $1
   | /usr/sbin/brctl setfd ${switch} 0
   | /usr/sbin/brctl stp ${switch} off
4. assign parameters in config file and execute test as usual
   test.cfg:
   | ip_nic1 = 192.168.100.110
   | mac_nic1 = 11:22:33:44:55:67
   | bridge = vbr

Signed-off-by: Amos Kong <akong@redhat.com>
---
 client/tests/kvm/base.cfg.sample |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/base.cfg.sample b/client/tests/kvm/base.cfg.sample
index 411decf..c86ec1f 100644
--- a/client/tests/kvm/base.cfg.sample
+++ b/client/tests/kvm/base.cfg.sample
@@ -17,6 +17,9 @@ nics = nic1
 # Connect NIC devices to host bridge device
 bridge = virbr0
 
+# Tell framework of nic1's static ip address
+ip_nic1 = 192.168.100.110
+
 # List of block device object names (whitespace seperated)
 images = image1
 # List of optical device object names
diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index fa258c3..1fb177f 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -821,7 +821,12 @@ class VM(virt_vm.BaseVM):
                 if mac:
                     virt_utils.set_mac_address(self.instance, vlan, mac)
                 else:
-                    virt_utils.generate_mac_address(self.instance, vlan)
+                    mac = virt_utils.generate_mac_address(self.instance, vlan)
+
+                if nic_params.get("ip"):
+                    self.address_cache[mac] = nic_params.get("ip")
+                    logging.debug("(address cache) Adding static cache entry: "
+                                  "%s ---> %s" % (mac, nic_params.get("ip")))
 
             # Assign a PCI assignable device
             self.pci_assignable = None


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] virt-test: support static ip address in framework
  2011-12-19 13:11 [PATCH] virt-test: support static ip address in framework Amos Kong
@ 2011-12-20  3:14 ` Qingtang Zhou
  2011-12-20  3:37   ` Amos Kong
  2011-12-20 19:03 ` Lucas Meneghel Rodrigues
  1 sibling, 1 reply; 5+ messages in thread
From: Qingtang Zhou @ 2011-12-20  3:14 UTC (permalink / raw)
  To: Amos Kong; +Cc: wquan, kvm, autotest

* On 2011-12-19 21:11:32 +0800, Amos Kong (akong@redhat.com) wrote:
> Sometime, we need to test with guest(s) which have static ip
> address(es).
> eg. No real/emulated DHCP server in test environment.
> eg. Test with old image we don't want to change the net config.
> eg. Test when DHCP exists problem.
> 
> This is an example of using static ip address:
> 1. edit ifcfg-eth0 of guest to assign static IP
>    (192.168.100.110). You can also do this by install
>    post-script/serial.
> 2. add and setup bridge in host
>    # brctl addbr vbr
>    # ifconfig vbr 192.168.100.1
> 3. add script for setup tap device
>    /etc/qemu-ifup-vbr
>    | #!/bin/sh
>    | switch=vbr
>    | /sbin/ifconfig $1 0.0.0.0 up
>    | /usr/sbin/brctl addif ${switch} $1
>    | /usr/sbin/brctl setfd ${switch} 0
>    | /usr/sbin/brctl stp ${switch} off
> 4. assign parameters in config file and execute test as usual
>    test.cfg:
>    | ip_nic1 = 192.168.100.110
>    | mac_nic1 = 11:22:33:44:55:67
>    | bridge = vbr
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  client/tests/kvm/base.cfg.sample |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/client/tests/kvm/base.cfg.sample b/client/tests/kvm/base.cfg.sample
> index 411decf..c86ec1f 100644
> --- a/client/tests/kvm/base.cfg.sample
> +++ b/client/tests/kvm/base.cfg.sample
> @@ -17,6 +17,9 @@ nics = nic1
>  # Connect NIC devices to host bridge device
>  bridge = virbr0
>  
> +# Tell framework of nic1's static ip address
> +ip_nic1 = 192.168.100.110
oops, Amos, better to comment out this line in patch, if this patch applied,
all nic1 will use this static ip, it interrupts our normal testing process.
Who need the static ip should add this line by himself.

> +
>  # List of block device object names (whitespace seperated)
>  images = image1
>  # List of optical device object names
> diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
> index fa258c3..1fb177f 100644
> --- a/client/virt/kvm_vm.py
> +++ b/client/virt/kvm_vm.py
> @@ -821,7 +821,12 @@ class VM(virt_vm.BaseVM):
>                  if mac:
>                      virt_utils.set_mac_address(self.instance, vlan, mac)
>                  else:
> -                    virt_utils.generate_mac_address(self.instance, vlan)
> +                    mac = virt_utils.generate_mac_address(self.instance, vlan)
> +
> +                if nic_params.get("ip"):
> +                    self.address_cache[mac] = nic_params.get("ip")
> +                    logging.debug("(address cache) Adding static cache entry: "
> +                                  "%s ---> %s" % (mac, nic_params.get("ip")))
>  
>              # Assign a PCI assignable device
>              self.pci_assignable = None

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] virt-test: support static ip address in framework
  2011-12-20  3:14 ` Qingtang Zhou
@ 2011-12-20  3:37   ` Amos Kong
  0 siblings, 0 replies; 5+ messages in thread
From: Amos Kong @ 2011-12-20  3:37 UTC (permalink / raw)
  To: Qingtang Zhou; +Cc: wquan, kvm, autotest

----- Original Message -----
> * On 2011-12-19 21:11:32 +0800, Amos Kong (akong@redhat.com) wrote:
> > Sometime, we need to test with guest(s) which have static ip
> > address(es).
> > eg. No real/emulated DHCP server in test environment.
> > eg. Test with old image we don't want to change the net config.
> > eg. Test when DHCP exists problem.
> > 
> > This is an example of using static ip address:
> > 1. edit ifcfg-eth0 of guest to assign static IP
> >    (192.168.100.110). You can also do this by install
> >    post-script/serial.
> > 2. add and setup bridge in host
> >    # brctl addbr vbr
> >    # ifconfig vbr 192.168.100.1
> > 3. add script for setup tap device
> >    /etc/qemu-ifup-vbr
> >    | #!/bin/sh
> >    | switch=vbr
> >    | /sbin/ifconfig $1 0.0.0.0 up
> >    | /usr/sbin/brctl addif ${switch} $1
> >    | /usr/sbin/brctl setfd ${switch} 0
> >    | /usr/sbin/brctl stp ${switch} off
> > 4. assign parameters in config file and execute test as usual
> >    test.cfg:
> >    | ip_nic1 = 192.168.100.110
> >    | mac_nic1 = 11:22:33:44:55:67
> >    | bridge = vbr
> > 
> > Signed-off-by: Amos Kong <akong@redhat.com>
> > ---
> >  client/tests/kvm/base.cfg.sample |    3 +++
> >  1 files changed, 3 insertions(+), 0 deletions(-)
> > 
> > diff --git a/client/tests/kvm/base.cfg.sample
> > b/client/tests/kvm/base.cfg.sample
> > index 411decf..c86ec1f 100644
> > --- a/client/tests/kvm/base.cfg.sample
> > +++ b/client/tests/kvm/base.cfg.sample
> > @@ -17,6 +17,9 @@ nics = nic1
> >  # Connect NIC devices to host bridge device
> >  bridge = virbr0
> >  
> > +# Tell framework of nic1's static ip address
> > +ip_nic1 = 192.168.100.110
> oops, Amos, better to comment out this line in patch, if this patch
> applied,
> all nic1 will use this static ip, it interrupts our normal testing
> process.
> Who need the static ip should add this line by himself.

Yeah, it's my fault.
Let's wait for other comments and send a v2 later.

Thanks, Amos
 
> > +
> >  # List of block device object names (whitespace seperated)
> >  images = image1
> >  # List of optical device object names
> > diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
> > index fa258c3..1fb177f 100644
> > --- a/client/virt/kvm_vm.py
> > +++ b/client/virt/kvm_vm.py
> > @@ -821,7 +821,12 @@ class VM(virt_vm.BaseVM):
> >                  if mac:
> >                      virt_utils.set_mac_address(self.instance,
> >                      vlan, mac)
> >                  else:
> > -                    virt_utils.generate_mac_address(self.instance,
> > vlan)
> > +                    mac =
> > virt_utils.generate_mac_address(self.instance, vlan)
> > +
> > +                if nic_params.get("ip"):
> > +                    self.address_cache[mac] = nic_params.get("ip")
> > +                    logging.debug("(address cache) Adding static
> > cache entry: "
> > +                                  "%s ---> %s" % (mac,
> > nic_params.get("ip")))
> >  
> >              # Assign a PCI assignable device
> >              self.pci_assignable = None
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] virt-test: support static ip address in framework
  2011-12-19 13:11 [PATCH] virt-test: support static ip address in framework Amos Kong
  2011-12-20  3:14 ` Qingtang Zhou
@ 2011-12-20 19:03 ` Lucas Meneghel Rodrigues
  2011-12-21  5:56   ` Amos Kong
  1 sibling, 1 reply; 5+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-12-20 19:03 UTC (permalink / raw)
  To: Amos Kong; +Cc: wquan, kvm, autotest

On 12/19/2011 11:11 AM, Amos Kong wrote:
> Sometime, we need to test with guest(s) which have static ip
> address(es).
> eg. No real/emulated DHCP server in test environment.
> eg. Test with old image we don't want to change the net config.
> eg. Test when DHCP exists problem.

Ok Amos, looks reasonable. Would you please send a v2 with ip_nic 
commented out and a companion wiki documentation? It'd be the start of a 
KVM autotest networking documentation. In case you are not aware, the 
autotest wiki is now a git repo, you can clone it, edit the pages on 
your editor, commit and push the changes.

If you have any problems, please contact me.

Cheers,

Lucas

> This is an example of using static ip address:
> 1. edit ifcfg-eth0 of guest to assign static IP
>     (192.168.100.110). You can also do this by install
>     post-script/serial.
> 2. add and setup bridge in host
>     # brctl addbr vbr
>     # ifconfig vbr 192.168.100.1
> 3. add script for setup tap device
>     /etc/qemu-ifup-vbr
>     | #!/bin/sh
>     | switch=vbr
>     | /sbin/ifconfig $1 0.0.0.0 up
>     | /usr/sbin/brctl addif ${switch} $1
>     | /usr/sbin/brctl setfd ${switch} 0
>     | /usr/sbin/brctl stp ${switch} off
> 4. assign parameters in config file and execute test as usual
>     test.cfg:
>     | ip_nic1 = 192.168.100.110
>     | mac_nic1 = 11:22:33:44:55:67
>     | bridge = vbr
>
> Signed-off-by: Amos Kong<akong@redhat.com>
> ---
>   client/tests/kvm/base.cfg.sample |    3 +++
>   1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/client/tests/kvm/base.cfg.sample b/client/tests/kvm/base.cfg.sample
> index 411decf..c86ec1f 100644
> --- a/client/tests/kvm/base.cfg.sample
> +++ b/client/tests/kvm/base.cfg.sample
> @@ -17,6 +17,9 @@ nics = nic1
>   # Connect NIC devices to host bridge device
>   bridge = virbr0
>
> +# Tell framework of nic1's static ip address
> +ip_nic1 = 192.168.100.110
> +
>   # List of block device object names (whitespace seperated)
>   images = image1
>   # List of optical device object names
> diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
> index fa258c3..1fb177f 100644
> --- a/client/virt/kvm_vm.py
> +++ b/client/virt/kvm_vm.py
> @@ -821,7 +821,12 @@ class VM(virt_vm.BaseVM):
>                   if mac:
>                       virt_utils.set_mac_address(self.instance, vlan, mac)
>                   else:
> -                    virt_utils.generate_mac_address(self.instance, vlan)
> +                    mac = virt_utils.generate_mac_address(self.instance, vlan)
> +
> +                if nic_params.get("ip"):
> +                    self.address_cache[mac] = nic_params.get("ip")
> +                    logging.debug("(address cache) Adding static cache entry: "
> +                                  "%s --->  %s" % (mac, nic_params.get("ip")))
>
>               # Assign a PCI assignable device
>               self.pci_assignable = None
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] virt-test: support static ip address in framework
  2011-12-20 19:03 ` Lucas Meneghel Rodrigues
@ 2011-12-21  5:56   ` Amos Kong
  0 siblings, 0 replies; 5+ messages in thread
From: Amos Kong @ 2011-12-21  5:56 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: wquan, kvm, autotest

On 21/12/11 03:03, Lucas Meneghel Rodrigues wrote:
> On 12/19/2011 11:11 AM, Amos Kong wrote:
>> Sometime, we need to test with guest(s) which have static ip
>> address(es).
>> eg. No real/emulated DHCP server in test environment.
>> eg. Test with old image we don't want to change the net config.
>> eg. Test when DHCP exists problem.
>
> Ok Amos, looks reasonable. Would you please send a v2 with ip_nic
> commented out and a companion wiki documentation? It'd be the start of a
> KVM autotest networking documentation.

> In case you are not aware, the
> autotest wiki is now a git repo, you can clone it, edit the pages on
> your editor, commit and push the changes.

I cloned it, but I dont' have permission to commit this repo.
git@github.com:autotest/autotest.wiki.git

I have updated the doc through website:
https://github.com/autotest/autotest/wiki/Networking

Thanks, Amos.

> If you have any problems, please contact me.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-21  5:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-19 13:11 [PATCH] virt-test: support static ip address in framework Amos Kong
2011-12-20  3:14 ` Qingtang Zhou
2011-12-20  3:37   ` Amos Kong
2011-12-20 19:03 ` Lucas Meneghel Rodrigues
2011-12-21  5:56   ` Amos Kong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.