From mboxrd@z Thu Jan 1 00:00:00 1970 From: Qingtang Zhou Subject: Re: [PATCH] virt-test: support static ip address in framework Date: Tue, 20 Dec 2011 11:14:04 +0800 Message-ID: <20111220031404.GA11482@qzhou-TP> References: <20111219131132.7235.31811.stgit@dhcp-8-167.nay.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: wquan@redhat.com, kvm@vger.kernel.org, autotest@test.kernel.org To: Amos Kong Return-path: Content-Disposition: inline In-Reply-To: <20111219131132.7235.31811.stgit@dhcp-8-167.nay.redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org * 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 > --- > 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