From patchwork Wed Jun 9 10:30:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Yang X-Patchwork-Id: 105115 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o59AUxYn017275 for ; Wed, 9 Jun 2010 10:30:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757215Ab0FIKa4 (ORCPT ); Wed, 9 Jun 2010 06:30:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44576 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756476Ab0FIKaz (ORCPT ); Wed, 9 Jun 2010 06:30:55 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o59AUskd017438 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Jun 2010 06:30:54 -0400 Received: from localhost.localdomain (dhcp-91-72.nay.redhat.com [10.66.91.72]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o59AUqNw029885; Wed, 9 Jun 2010 06:30:53 -0400 From: Feng Yang To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Feng Yang Subject: [Autotest][PATCH] KVM Test: Support netdev parameter in make_qemu_command. Date: Wed, 9 Jun 2010 18:30:51 +0800 Message-Id: <1276079451-6131-1-git-send-email-fyang@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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 (demeter.kernel.org [140.211.167.41]); Wed, 09 Jun 2010 10:30:59 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index f3ce4d6..1da4622 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -115,6 +115,9 @@ class VM: self.root_dir = root_dir self.address_cache = address_cache self.pci_assignable = None + self.netdev_id = [] + for nic in params.get("nics").split(): + self.netdev_id.append(kvm_utils.generate_random_string(4)) # Find available monitor filename while True: @@ -226,15 +229,20 @@ class VM: if boot: cmd += ",boot=on" return cmd - def add_nic(help, vlan, model=None, mac=None): + def add_nic(help, vlan, model=None, mac=None, netdev_id=None): cmd = " -net nic,vlan=%d" % vlan if model: cmd += ",model=%s" % model + if has_option(help, "netdev"): + cmd +=",netdev=%s" % netdev_id if mac: cmd += ",macaddr=%s" % mac return cmd def add_net(help, vlan, mode, ifname=None, script=None, - downscript=None): - cmd = " -net %s,vlan=%d" % (mode, vlan) + downscript=None, netdev_id=None): + if has_option(help, "netdev"): + cmd = " -netdev %s,id=%s" % (mode, netdev_id) + else: + cmd = " -net %s,vlan=%d" % (mode, vlan) if mode == "tap": if ifname: cmd += ",ifname=%s" % ifname if script: cmd += ",script=%s" % script @@ -313,7 +321,8 @@ class VM: mac = None if "address_index" in nic_params: mac = kvm_utils.get_mac_ip_pair_from_dict(nic_params)[0] - qemu_cmd += add_nic(help, vlan, nic_params.get("nic_model"), mac) + qemu_cmd += add_nic(help, vlan, nic_params.get("nic_model"), mac, + self.netdev_id[vlan]) # Handle the '-net tap' or '-net user' part script = nic_params.get("nic_script") downscript = nic_params.get("nic_downscript") @@ -323,7 +332,7 @@ class VM: downscript = kvm_utils.get_path(root_dir, downscript) qemu_cmd += add_net(help, vlan, nic_params.get("nic_mode", "user"), nic_params.get("nic_ifname"), - script, downscript) + script, downscript, self.netdev_id[vlan]) # Proceed to next NIC vlan += 1