From patchwork Fri Feb 18 23:11:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 574201 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 p1INBQKb009251 for ; Fri, 18 Feb 2011 23:11:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753687Ab1BRXLS (ORCPT ); Fri, 18 Feb 2011 18:11:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52725 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757590Ab1BRXLQ (ORCPT ); Fri, 18 Feb 2011 18:11:16 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1INBF97021955 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Feb 2011 18:11:15 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1INBFho032564; Fri, 18 Feb 2011 18:11:15 -0500 Received: from qu0061.eng.lab.tlv.redhat.com ([10.35.16.61]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p1INBCTR028535; Fri, 18 Feb 2011 18:11:13 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 2/2] KVM test: kvm_vm.py: make 'nic_mac' trigger a VM restart when changed Date: Sat, 19 Feb 2011 01:11:28 +0200 Message-Id: <1298070688-12228-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1298070688-12228-1-git-send-email-mgoldish@redhat.com> References: <1298070688-12228-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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.6 (demeter1.kernel.org [140.211.167.41]); Fri, 18 Feb 2011 23:11:26 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index d852784..1ceef7a 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -850,15 +850,12 @@ class VM: for vlan in range(num_nics): nic_name = params.objects("nics")[vlan] nic_params = params.object_params(nic_name) - if nic_params.get("nic_mac", None): - mac = nic_params.get("nic_mac") + mac = (nic_params.get("nic_mac") or + mac_source and mac_source.get_mac_address(vlan)) + if mac: kvm_utils.set_mac_address(self.instance, vlan, mac) else: - mac = mac_source and mac_source.get_mac_address(vlan) - if mac: - kvm_utils.set_mac_address(self.instance, vlan, mac) - else: - kvm_utils.generate_mac_address(self.instance, vlan) + kvm_utils.generate_mac_address(self.instance, vlan) # Assign a PCI assignable device self.pci_assignable = None @@ -1233,7 +1230,10 @@ class VM: @raise VMMACAddressMissingError: If no MAC address is defined for the requested NIC """ - mac = kvm_utils.get_mac_address(self.instance, nic_index) + nic_name = self.params.objects("nics")[nic_index] + nic_params = self.params.object_params(nic_name) + mac = (nic_params.get("nic_mac") or + kvm_utils.get_mac_address(self.instance, nic_index)) if not mac: raise VMMACAddressMissingError(nic_index) return mac