From: Michael Goldish Subject: [KVM-AUTOTEST PATCH] KVM test: kvm_vm.py: style corrections in add_nic() and add_net() Date: Wed, 27 Oct 2010 11:37:28 +0200 Message-ID: <1288172250-4304-1-git-send-email-mgoldish@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: autotest@test.kernel.org, kvm@vger.kernel.org Return-path: 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 Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_vm.py | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index bb24c6a..02d7dff 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -236,25 +236,22 @@ class VM: def add_nic(help, vlan, model=None, mac=None, netdev_id=None, nic_extra_params=None): + if has_option(help, "netdev"): + netdev_vlan_str = ",netdev=%s" % netdev_id + else: + netdev_vlan_str = ",vlan=%d" % vlan if has_option(help, "device"): - if model == "virtio": - model="virtio-net-pci" if not model: - model= "rtl8139" - cmd = " -device %s" % model + model = "rtl8139" + elif model == "virtio": + model = "virtio-net-pci" + cmd = " -device %s" % model + netdev_vlan_str if mac: - cmd += ",mac=%s" % mac - if has_option(help, "netdev"): - cmd += ",netdev=%s" % netdev_id - else: - cmd += "vlan=%d," % vlan + cmd += ",mac='%s'" % mac if nic_extra_params: cmd += ",%s" % nic_extra_params else: - if has_option(help, "netdev"): - cmd = " -net nic,netdev=%s" % netdev_id - else: - cmd = " -net nic,vlan=%d" % vlan + cmd = " -net nic" + netdev_vlan_str if model: cmd += ",model=%s" % model if mac: @@ -267,7 +264,7 @@ class VM: if has_option(help, "netdev"): cmd = " -netdev %s,id=%s" % (mode, netdev_id) if vhost: - cmd +=",vhost=on" + cmd += ",vhost=on" else: cmd = " -net %s,vlan=%d" % (mode, vlan) if mode == "tap": -- 1.5.5.6