From: Yolkfull Chow Subject: Re: [Autotest] [PATCH] KVM test: Add PCI device assignment support Date: Tue, 19 Jan 2010 09:23:05 +0800 Message-ID: <20100119011903.GB2516@aFu.nay.redhat.com> References: <1263320893-6219-1-git-send-email-lmr@redhat.com> <20100113021838.GA2333@aFu.nay.redhat.com> <6ac58f4f1001180849v267fef64vafbdd358da16c5fe@mail.gmail.com> Reply-To: Yolkfull Chow Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: autotest@test.kernel.org, kvm@vger.kernel.org To: Lucas Meneghel Rodrigues Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34903 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752525Ab0ASBXN (ORCPT ); Mon, 18 Jan 2010 20:23:13 -0500 Content-Disposition: inline In-Reply-To: <6ac58f4f1001180849v267fef64vafbdd358da16c5fe@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Jan 18, 2010 at 02:49:14PM -0200, Lucas Meneghel Rodrigues wrot= e: > Ok, after some consideration I have applied the patch: >=20 > http://autotest.kernel.org/changeset/4144 >=20 > Thank you for your work on this test! I should thank you for improving this test. :-) >=20 > On Wed, Jan 13, 2010 at 12:19 AM, Yolkfull Chow wr= ote: > > On Tue, Jan 12, 2010 at 04:28:13PM -0200, Lucas Meneghel Rodrigues = wrote: > >> Add support to PCI device assignment on the kvm test. It supports > >> both SR-IOV virtual functions and physical NIC card device > >> assignment. > >> > >> Single Root I/O Virtualization (SR-IOV) allows a single PCI device= to > >> be shared amongst multiple virtual machines while retaining the > >> performance benefit of assigning a PCI device to a virtual machine= =2E > >> A common example is where a single SR-IOV capable NIC - with perha= ps > >> only a single physical network port - might be shared with multipl= e > >> virtual machines by assigning a virtual function to each VM. > >> > >> SR-IOV support is implemented in the kernel. The core implementati= on > >> is contained in the PCI subsystem, but there must also be driver s= upport > >> for both the Physical Function (PF) and Virtual Function (VF) devi= ces. > >> With an SR-IOV capable device one can allocate VFs from a PF. The = VFs > >> surface as PCI devices which are backed on the physical PCI device= by > >> resources (queues, and register sets). > >> > >> Device support: > >> > >> In 2.6.30, the Intel=C2=AE 82576 Gigabit Ethernet Controller is th= e only > >> SR-IOV capable device supported. The igb driver has PF support and= the > >> igbvf has VF support. > >> > >> In 2.6.31 the Neterion=C2=AE X3100=E2=84=A2 is supported as well. = This device uses > >> the same vxge driver for the PF as well as the VFs. > >> > >> In order to configure the test: > >> > >> =C2=A0 * For SR-IOV virtual functions passthrough, we could specif= y the > >> =C2=A0 =C2=A0 module parameter 'max_vfs' in config file. > >> =C2=A0 * For physical NIC card pass through, we should specify the= device > >> =C2=A0 =C2=A0 name(s). > > > > Looks good for me. > > Lucas, thank you so much for improving this patch. :-) > > > >> > >> Signed-off-by: Yolkfull Chow > >> Signed-off-by: Lucas Meneghel Rodrigues > >> --- > >> =C2=A0client/tests/kvm/kvm_utils.py =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0| =C2=A0284 ++++++++++++++++++++++++++++++++ > >> =C2=A0client/tests/kvm/kvm_vm.py =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 | =C2=A0 60 +++++++ > >> =C2=A0client/tests/kvm/tests_base.cfg.sample | =C2=A0 22 +++- > >> =C2=A03 files changed, 365 insertions(+), 1 deletions(-) > >> > >> diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_= utils.py > >> index 2bbbe22..a2d9607 100644 > >> --- a/client/tests/kvm/kvm_utils.py > >> +++ b/client/tests/kvm/kvm_utils.py > >> @@ -924,3 +924,287 @@ def create_report(report_dir, results_dir): > >> =C2=A0 =C2=A0 =C2=A0reporter =3D os.path.join(report_dir, 'html_re= port.py') > >> =C2=A0 =C2=A0 =C2=A0html_file =3D os.path.join(results_dir, 'resul= ts.html') > >> =C2=A0 =C2=A0 =C2=A0os.system('%s -r %s -f %s -R' % (reporter, res= ults_dir, html_file)) > >> + > >> + > >> +def get_full_pci_id(pci_id): > >> + =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0Get full PCI ID of pci_id. > >> + > >> + =C2=A0 =C2=A0@param pci_id: PCI ID of a device. > >> + =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0cmd =3D "lspci -D | awk '/%s/ {print $1}'" % pci_id > >> + =C2=A0 =C2=A0status, full_id =3D commands.getstatusoutput(cmd) > >> + =C2=A0 =C2=A0if status !=3D 0: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return None > >> + =C2=A0 =C2=A0return full_id > >> + > >> + > >> +def get_vendor_from_pci_id(pci_id): > >> + =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0Check out the device vendor ID according to pci_id. > >> + > >> + =C2=A0 =C2=A0@param pci_id: PCI ID of a device. > >> + =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0cmd =3D "lspci -n | awk '/%s/ {print $3}'" % pci_id > >> + =C2=A0 =C2=A0return re.sub(":", " ", commands.getoutput(cmd)) > >> + > >> + > >> +class PciAssignable(object): > >> + =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0Request PCI assignable devices on host. It will che= ck whether to request > >> + =C2=A0 =C2=A0PF (physical Functions) or VF (Virtual Functions). > >> + =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0def __init__(self, type=3D"nic_vf", driver=3DNone, = driver_option=3DNone, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 names=3D= None, devices_requested=3DNone): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Initialize parameter 'type' which cou= ld be: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0nic_vf: Virtual Functions > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0nic_pf: Physical Function (actual har= dware) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0mixed: =C2=A0Both includes VFs and PF= s > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0If pass through Physical NIC cards, w= e need to specify which devices > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0to be assigned, e.g. 'eth1 eth2'. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0If pass through Virtual Functions, we= need to specify how many vfs > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0are going to be assigned, e.g. passth= rough_count =3D 8 and max_vfs in > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0config file. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param type: PCI device type. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param driver: Kernel module for the = PCI assignable device. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param driver_option: Module option t= o specify the maximum number of > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0VFs (eg '= max_vfs=3D7') > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param names: Physical NIC cards corr= espondent network interfaces, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0e.g.'eth1= eth2 ...' > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param devices_requested: Number of d= evices being requested. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0self.type =3D type > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0self.driver =3D driver > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0self.driver_option =3D driver_option > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if names: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.name_list =3D name= s.split() > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if devices_requested: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.devices_requested = =3D int(devices_requested) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0else: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.devices_requested = =3D None > >> + > >> + > >> + =C2=A0 =C2=A0def _get_pf_pci_id(self, name, search_str): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Get the PF PCI ID according to name. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param name: Name of the PCI device. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param search_str: Search string to b= e used on lspci. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "ethtool -i %s | awk '/bus-in= fo/ {print $2}'" % name > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0s, pci_id =3D commands.getstatusoutpu= t(cmd) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if not (s or "Cannot get driver infor= mation" in pci_id): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return pci_id[5:] > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "lspci | awk '/%s/ {print $1}= '" % search_str > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0pci_ids =3D [id for id in commands.ge= toutput(cmd).splitlines()] > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0nic_id =3D int(re.search('[0-9]+', na= me).group(0)) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if (len(pci_ids) - 1) < nic_id: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return None > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return pci_ids[nic_id] > >> + > >> + > >> + =C2=A0 =C2=A0def _release_dev(self, pci_id): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Release a single PCI device. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param pci_id: PCI ID of a given PCI = device. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0base_dir =3D "/sys/bus/pci" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0full_id =3D get_full_pci_id(pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0vendor_id =3D get_vendor_from_pci_id(= pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0drv_path =3D os.path.join(base_dir, "= devices/%s/driver" % full_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if 'pci-stub' in os.readlink(drv_path= ): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "echo '%s' > %s= /new_id" % (vendor_id, drv_path) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if os.system(cmd): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return Fa= lse > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0stub_path =3D os.path.j= oin(base_dir, "drivers/pci-stub") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "echo '%s' > %s= /unbind" % (full_id, stub_path) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if os.system(cmd): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return Fa= lse > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0driver =3D self.dev_dri= vers[pci_id] > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "echo '%s' > %s= /bind" % (full_id, driver) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if os.system(cmd): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return Fa= lse > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return True > >> + > >> + > >> + =C2=A0 =C2=A0def get_vf_devs(self): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Catch all VFs PCI IDs. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@return: List with all PCI IDs for th= e Virtual Functions avaliable > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if not self.sr_iov_setup(): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return [] > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "lspci | awk '/Virtual Functi= on/ {print $1}'" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return commands.getoutput(cmd).split(= ) > >> + > >> + > >> + =C2=A0 =C2=A0def get_pf_devs(self): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Catch all PFs PCI IDs. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@return: List with all PCI IDs for th= e physical hardware requested > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0pf_ids =3D [] > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0for name in self.name_list: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pf_id =3D self._get_pf_= pci_id(name, "Ethernet") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not pf_id: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0continue > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pf_ids.append(pf_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return pf_ids > >> + > >> + > >> + =C2=A0 =C2=A0def get_devs(self, count): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Check out all devices' PCI IDs accord= ing to their name. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param count: count number of PCI dev= ices needed for pass through > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@return: a list of all devices' PCI I= Ds > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if self.type =3D=3D "nic_vf": > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vf_ids =3D self.get_vf_= devs() > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0elif self.type =3D=3D "nic_pf": > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vf_ids =3D self.get_pf_= devs() > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0elif self.type =3D=3D "mixed": > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vf_ids =3D self.get_vf_= devs() > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vf_ids.extend(self.get_= pf_devs()) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return vf_ids[0:count] > >> + > >> + > >> + =C2=A0 =C2=A0def get_vfs_count(self): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Get VFs count number according to lsp= ci. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "lspci | grep 'Virtual Functi= on' | wc -l" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# For each VF we'll see 2 prints of '= Virtual Function', so let's > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# divide the result per 2 > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return int(commands.getoutput(cmd)) /= 2 > >> + > >> + > >> + =C2=A0 =C2=A0def check_vfs_count(self): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Check VFs count number according to t= he parameter driver_options. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return (self.get_vfs_count =3D=3D sel= f.devices_requested) > >> + > >> + > >> + =C2=A0 =C2=A0def is_binded_to_stub(self, full_id): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Verify whether the device with full_i= d is already binded to pci-stub. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@param full_id: Full ID for the given= PCI device > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0base_dir =3D "/sys/bus/pci" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0stub_path =3D os.path.join(base_dir, = "drivers/pci-stub") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if os.path.exists(os.path.join(stub_p= ath, full_id)): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return True > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return False > >> + > >> + > >> + =C2=A0 =C2=A0def sr_iov_setup(self): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Ensure the PCI device is working in s= r_iov mode. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Check if the PCI hardware device driv= e is loaded with the appropriate, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0parameters (number of VFs), and if it= 's not, perform setup. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@return: True, if the setup was compl= eted successfuly, False otherwise. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0re_probe =3D False > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0s, o =3D commands.getstatusoutput('ls= mod | grep %s' % self.driver) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if s: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0re_probe =3D True > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0elif not self.check_vfs_count(): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0os.system("modprobe -r = %s" % self.driver) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0re_probe =3D True > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# Re-probe driver with proper number = of VFs > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if re_probe: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd =3D "modprobe %s %s= " % (self.driver, self.driver_option) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s, o =3D commands.getst= atusoutput(cmd) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if s: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return Fa= lse > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not self.check_vfs_c= ount(): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return Fa= lse > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return True > >> + > >> + > >> + =C2=A0 =C2=A0def request_devs(self): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Implement setup process: unbind the P= CI device and then bind it > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0to the pci-stub driver. > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0@return: a list of successfully reque= sted devices' PCI IDs. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0base_dir =3D "/sys/bus/pci" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0stub_path =3D os.path.join(base_dir, = "drivers/pci-stub") > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0self.pci_ids =3D self.get_devs(self.d= evices_requested) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0logging.debug("The following pci_ids = were found: %s" % self.pci_ids) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0requested_pci_ids =3D [] > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0self.dev_drivers =3D {} > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# Setup all devices specified for ass= ignment to guest > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0for pci_id in self.pci_ids: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0full_id =3D get_full_pc= i_id(pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not full_id: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0continue > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0drv_path =3D os.path.jo= in(base_dir, "devices/%s/driver" % full_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev_prev_driver=3D os.p= ath.realpath(os.path.join(drv_path, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0os.readlink(drv_path))) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.dev_drivers[pci_id= ] =3D dev_prev_driver > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Judge whether the dev= ice driver has been binded to stub > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not self.is_binded_t= o_stub(full_id): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logging.d= ebug("Binding device %s to stub" % full_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vendor_id= =3D get_vendor_from_pci_id(pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0stub_new_= id =3D os.path.join(stub_path, 'new_id') > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unbind_de= v =3D os.path.join(drv_path, 'unbind') > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0stub_bind= =3D os.path.join(stub_path, 'bind') > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0info_writ= e_to_files =3D [(vendor_id, stub_new_id), > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (ful= l_id, unbind_dev), > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (ful= l_id, stub_bind)] > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for conte= nt, file in info_write_to_files: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0try: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0utils.open_write_close(content, file) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0except IOError: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0logging.debug("Failed to write %s to file %s" % > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cont= ent, file)) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0continue > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not se= lf.is_binded_to_stub(full_id): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0logging.error("Binding device %s to stub failed" % > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0continue > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logging.d= ebug("Device %s already binded to stub" % pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0requested_pci_ids.appen= d(pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0self.pci_ids =3D requested_pci_ids > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return self.pci_ids > >> + > >> + > >> + =C2=A0 =C2=A0def release_devs(self): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0Release all PCI devices currently ass= igned to VMs back to the > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0virtualization host. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0""" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0try: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for pci_id in self.dev_= drivers: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not se= lf._release_dev(pci_id): > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0logging.error("Failed to release device %s to host" % > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0logging.info("Released device %s successfully" % pci_id) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0except: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return > >> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.= py > >> index 7229b79..78a16ac 100755 > >> --- a/client/tests/kvm/kvm_vm.py > >> +++ b/client/tests/kvm/kvm_vm.py > >> @@ -119,6 +119,7 @@ class VM: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.params =3D params > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.root_dir =3D root_dir > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.address_cache =3D address_c= ache > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0self.pci_assignable =3D None > >> > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Find available monitor filenam= e > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0while True: > >> @@ -304,6 +305,12 @@ class VM: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0elif params.get("uuid"): > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0qemu_cmd +=3D " -u= uid %s" % params.get("uuid") > >> > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# If the PCI assignment step went OK,= add each one of the PCI assigned > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# devices to the qemu command line. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if self.pci_assignable: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for pci_id in self.pa_p= ci_ids: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0qemu_cmd = +=3D " -pcidevice host=3D%s" % pci_id > >> + > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return qemu_cmd > >> > >> > >> @@ -392,6 +399,50 @@ class VM: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self= =2Euuid =3D f.read().strip() > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0f.cl= ose() > >> > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if not params.get("pci_= assignable") =3D=3D "no": > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pa_type =3D= params.get("pci_assignable") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pa_device= s_requested =3D params.get("devices_requested") > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Virtual= Functions (VF) assignable devices > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if pa_typ= e =3D=3D "vf": > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0pa_driver =3D params.get("driver") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0pa_driver_option =3D params.get("driver_option") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0self.pci_assignable =3D kvm_utils.PciAssignable(type=3Dpa_type, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= driver=3Dpa_driver, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= driver_option=3Dpa_driver_option, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= devices_requested=3Dpa_devices_requested) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Physica= l NIC (PF) assignable devices > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0elif pa_t= ype =3D=3D "pf": > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0pa_device_names =3D params.get("device_names") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0self.pci_assignable =3D kvm_utils.PciAssignable(type=3Dpa_type, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= names=3Dpa_device_names, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= devices_requested=3Dpa_devices_requested) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Working= with both VF and PF > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0elif pa_t= ype =3D=3D "mixed": > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0pa_device_names =3D params.get("device_names") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0pa_driver =3D params.get("driver") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0pa_driver_option =3D params.get("driver_option") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0self.pci_assignable =3D kvm_utils.PciAssignable(type=3Dpa_type, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= driver=3Dpa_driver, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= driver_option=3Dpa_driver_option, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= names=3Dpa_device_names, > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= devices_requested=3Dpa_devices_requested) > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.pa_p= ci_ids =3D self.pci_assignable.request_devs() > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if self.p= a_pci_ids: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0logging.debug("Successfuly assigned devices: %s" % > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.pa_pci_ids) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0logging.error("No PCI assignable devices were assigned " > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"and 'pci_assignabl= e' is defined to %s " > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"on your config fil= e. Aborting VM creation." % > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pa_type) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0return False > >> + > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.pci_= assignable =3D None > >> + > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Make qemu comman= d > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0qemu_command =3D s= elf.make_qemu_command() > >> > >> @@ -537,6 +588,8 @@ class VM: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Is it already de= ad? > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if self.is_dead(): > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logg= ing.debug("VM is already down") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if self.p= ci_assignable: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0self.pci_assignable.release_devs() > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0retu= rn > >> > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logging.debug("Des= troying VM with PID %d..." % > >> @@ -557,6 +610,9 @@ class VM: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0finally: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0session.close() > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0if self.pci_assignable: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self.pci_assignable.release_devs() > >> + > >> > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Try to destroy w= ith a monitor command > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logging.debug("Try= ing to kill VM with monitor command...") > >> @@ -566,6 +622,8 @@ class VM: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Wa= it for the VM to be really dead > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if k= vm_utils.wait_for(self.is_dead, 5, 0.5, 0.5): > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0logging.debug("VM is down") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0if self.pci_assignable: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0self.pci_assignable.release_devs() > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0return > >> > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# If the VM isn't = dead yet... > >> @@ -575,6 +633,8 @@ class VM: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Wait for the VM = to be really dead > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if kvm_utils.wait_= for(self.is_dead, 5, 0.5, 0.5): > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logg= ing.debug("VM is down") > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if self.p= ci_assignable: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0self.pci_assignable.release_devs() > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0retu= rn > >> > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logging.error("Pro= cess %s is a zombie!" % self.process.get_pid()) > >> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests= /kvm/tests_base.cfg.sample > >> index b8f25f4..49b6d6b 100644 > >> --- a/client/tests/kvm/tests_base.cfg.sample > >> +++ b/client/tests/kvm/tests_base.cfg.sample > >> @@ -889,7 +889,27 @@ variants: > >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0extra_params +=3D " -mem-path /m= nt/kvm_hugepage" > >> > >> > >> +variants: > >> + =C2=A0 =C2=A0- @no_pci_assignable: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0pci_assignable =3D no > >> + =C2=A0 =C2=A0- pf_assignable: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0pci_assignable =3D pf > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0device_names =3D eth1 > >> + =C2=A0 =C2=A0- vf_assignable: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0pci_assignable =3D vf > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# Driver (kernel module) that support= s SR-IOV hardware. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# As of today (30-11-2009), we have 2= drivers for this type of hardware: > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# Intel=C2=AE 82576 Gigabit Ethernet = Controller - igb > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# Neterion=C2=AE X3100=E2=84=A2 - vxg= e > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0driver =3D igb > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# Driver option to specify the maximu= m number of virtual functions > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# (on vxge the option is , for exampl= e, is max_config_dev) > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# the default below is for the igb dr= iver > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0driver_option =3D "max_vfs=3D7" > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# Number of devices that are going to= be requested. > >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0devices_requested =3D 7 > >> + > >> + > >> =C2=A0image_name.* ?<=3D images/ > >> =C2=A0cdrom.* ?<=3D isos/ > >> =C2=A0steps ?<=3D steps/ > >> - > >> -- > >> 1.6.5.2 > > _______________________________________________ > > Autotest mailing list > > Autotest@test.kernel.org > > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest > > >=20 >=20 >=20 > --=20 > Lucas