From patchwork Fri Oct 8 15:28:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 241521 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o98FSTcV019589 for ; Fri, 8 Oct 2010 15:28:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758617Ab0JHP2Y (ORCPT ); Fri, 8 Oct 2010 11:28:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44387 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758355Ab0JHP2Y (ORCPT ); Fri, 8 Oct 2010 11:28:24 -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 o98FSNWj017841 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Oct 2010 11:28:23 -0400 Received: from freedom.redhat.com (vpn-9-43.rdu.redhat.com [10.11.9.43]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o98FSIQu014267; Fri, 8 Oct 2010 11:28:21 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, jasowang@redhat.com, mst@redhat.com, Lucas Meneghel Rodrigues Subject: [PATCH 1/2] KVM test: Use -device to add nic device when possible Date: Fri, 8 Oct 2010 12:28:12 -0300 Message-Id: <1286551693-7872-2-git-send-email-lmr@redhat.com> In-Reply-To: <1286551693-7872-1-git-send-email-lmr@redhat.com> References: <1286551693-7872-1-git-send-email-lmr@redhat.com> 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Oct 2010 15:28:29 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index a473bb4..3388b14 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -253,13 +253,31 @@ class VM: if boot: cmd += ",boot=on" return cmd - def add_nic(help, vlan, model=None, mac=None, netdev_id=None): - if has_option(help, "netdev"): - cmd = " -net nic,netdev=%s" % netdev_id + def add_nic(help, vlan, model=None, mac=None, netdev_id=None, + nic_extra_params=None): + if has_option(help, "device"): + if model == "virtio": + model="virtio-net-pci" + if not model: + model= "rtl8139" + cmd = " -device %s" % model + if mac: + cmd += ",mac=%s" % mac + if has_option(help, "netdev"): + cmd += ",netdev=%s" % netdev_id + else: + cmd += "vlan=%d," % vlan + if nic_extra_params: + cmd += ",%s" % nic_extra_params else: - cmd = " -net nic,vlan=%d" % vlan - if model: cmd += ",model=%s" % model - if mac: cmd += ",macaddr='%s'" % mac + if has_option(help, "netdev"): + cmd = " -net nic,netdev=%s" % netdev_id + else: + cmd = " -net nic,vlan=%d" % vlan + if model: + cmd += ",model=%s" % model + if mac: + cmd += ",macaddr='%s'" % mac return cmd def add_net(help, vlan, mode, ifname=None, script=None, @@ -414,7 +432,8 @@ class VM: self.mac_prefix) qemu_cmd += add_nic(help, vlan, nic_params.get("nic_model"), mac, - self.netdev_id[vlan]) + self.netdev_id[vlan], + nic_params.get("nic_extra_params")) # Handle the '-net tap' or '-net user' part script = nic_params.get("nic_script") downscript = nic_params.get("nic_downscript") diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index a524242..8d62c42 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -699,6 +699,9 @@ variants: supported_features = "tx rx sg tso gso gro lro" - virtio_net: nic_model = virtio + # you can add advanced attributes on nic_extra_params + # such as mrg_rxbuf + #nic_extra_params = jumbo: mtu = 65520 ethtool: