From patchwork Tue Oct 27 04:08:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 56029 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9R4D2o9031078 for ; Tue, 27 Oct 2009 04:13:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751032AbZJ0EMz (ORCPT ); Tue, 27 Oct 2009 00:12:55 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751012AbZJ0EMz (ORCPT ); Tue, 27 Oct 2009 00:12:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1026 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750889AbZJ0EMy (ORCPT ); Tue, 27 Oct 2009 00:12:54 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9R4CwZ1005779; Tue, 27 Oct 2009 00:12:59 -0400 Received: from localhost (dhcp-65-140.nay.redhat.com [10.66.65.140]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9R4Cv8U030197; Tue, 27 Oct 2009 00:12:58 -0400 Date: Tue, 27 Oct 2009 12:08:54 +0800 From: Amos Kong To: Michael Goldish Cc: autotest@test.kernel.org, kvm@vger.kernel.org, dlaor@redhat.com Subject: [PATCH 2/2] KSM-test: Test 802.1Q vlan of nic Message-ID: <20091027040854.GB22627@dhcp-66-70-48.nay.redhat.com> Reply-To: Amos Kong References: <301351519.552421256044394416.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> <1934714265.553191256044790508.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> <20091021103756.GB2641@dhcp-66-70-48.nay.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091021103756.GB2641@dhcp-66-70-48.nay.redhat.com> User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 573206c..7f9512a 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -157,6 +157,18 @@ variants: used_cpus = 5 used_mem = 2560 + - vlan_tag: install setup + type = vlan_tag + # subnet2 should not be used by host + subnet2 = 192.168.123 + vlans = "10 20" + nic_mode = tap + vms += " vm2" + extra_params_vm1 += " -snapshot" + extra_params_vm2 += " -snapshot" + kill_vm_gracefully_vm2 = no + address_index_vm2 = 1 + - autoit: install setup type = autoit autoit_binary = D:\AutoIt3.exe diff --git a/client/tests/kvm/tests/vlan_tag.py b/client/tests/kvm/tests/vlan_tag.py new file mode 100644 index 0000000..ada919f --- /dev/null +++ b/client/tests/kvm/tests/vlan_tag.py @@ -0,0 +1,68 @@ +import logging, time +from autotest_lib.client.common_lib import error +import kvm_subprocess, kvm_test_utils, kvm_utils + +def run_vlan_tag(test, params, env): + """ + Test 802.1Q vlan of nic, config it by vconfig command. + + 1) Create two VMs + 2) Setup guests in different vlan by vconfig and test communication by ping + using hard-coded ip address + 3) Setup guests in same vlan and test communication by ping + 4) Recover the vlan config + + @param test: Kvm test object + @param params: Dictionary with the test parameters. + @param env: Dictionary with test environment. + """ + + vm = [] + session = [] + subnet2 = params.get("subnet2") + vlans = params.get("vlans").split() + + vm.append(kvm_test_utils.get_living_vm(env, params.get("main_vm"))) + vm.append(kvm_test_utils.get_living_vm(env, "vm2")) + + if not vm[1].create(): + raise error.TestError("VM 1 create faild") + + for i in range(2): + session.append(kvm_test_utils.wait_for_login(vm[i])) + + try: + vconfig_cmd = "vconfig add eth0 %s;ifconfig eth0.%s %s.%s" + # Attempt to configure IPs for the VMs and record the results in + # boolean variables + # Make vm1 and vm2 in the different vlan + + ip_config_vm1_ok = (session[0].get_command_status(vconfig_cmd + % (vlans[0], vlans[0], subnet2, "11")) == 0) + ip_config_vm2_ok = (session[1].get_command_status(vconfig_cmd + % (vlans[1], vlans[1], subnet2, "12")) == 0) + if not ip_config_vm1_ok or not ip_config_vm2_ok: + raise error.TestError, "Fail to config VMs ip address" + ping_diff_vlan_ok = (session[0].get_command_status( + "ping -c 2 -I eth0.%s %s.12" % (vlans[0], subnet2)) == 0) + + if ping_diff_vlan_ok: + raise error.TestFail("VM 2 is unexpectedly pingable in different " + "vlan") + # Make vm2 in the same vlan with vm1 + vlan_config_vm2_ok = (session[1].get_command_status( + "vconfig rem eth0.%s;vconfig add eth0 %s;" + "ifconfig eth0.%s %s.12" % + (vlans[1], vlans[0], vlans[0], subnet2)) == 0) + if not vlan_config_vm2_ok: + raise error.TestError, "Fail to config ip address of VM 2" + + ping_same_vlan_ok = (session[0].get_command_status( + "ping -c 2 -I eth0.%s %s.12" % (vlans[0], subnet2)) == 0) + if not ping_same_vlan_ok: + raise error.TestFail("Fail to ping the guest in same vlan") + finally: + # Clean the vlan config + for i in range(2): + session[i].get_command_status("vconfig rem eth0.%s" % vlans[0]) + session[i].close()