From: David Ahern <dsahern@gmail.com>
To: Avi Kivity <avi@redhat.com>, Chris Friesen <chris.friesen@genband.com>
Cc: Sasha Levin <levinsasha928@gmail.com>, kvm@vger.kernel.org
Subject: Re: SR-IOV and KVM?
Date: Mon, 27 Jun 2011 09:15:57 -0600 [thread overview]
Message-ID: <4E089EAD.5070104@gmail.com> (raw)
In-Reply-To: <4E089675.5050903@redhat.com>
On 06/27/2011 08:40 AM, Avi Kivity wrote:
> On 06/27/2011 05:15 PM, Chris Friesen wrote:
>>
>> Maybe it's just a documentation thing. I'm just getting into KVM and
>> trying to figure everything out, and I don't see a step-by-step guide
>> to configuring a host/guest system with either SR-IOV or Intel's VMDq.
>
> You can use virt-manager; it has a GUI for that. Once you're
> comfortable with it you can drop down to virsh command line and from
> there to raw qemu command line / monitor.
To some virt-manager is more painful than the command line is not too
painful. I have a set of home grown scripts. This is the code I added
for PCI devices:
function claim_pci_dev
{
local pciid=$1
local domain=0000 # TO-DO: determine this automatically
local id
[ -z "$pciid" ] && return 1
local drv=$(lspci -s ${pciid} -k | awk '$0 ~ /Kernel driver in
use:/ {print $NF}')
[ "$drv" = "pci-stub" ] && return 0
id=$(lspci -n | awk '{if ($1 == "'${pciid}'") {print $3}}')
id=${id/:/ }
if [ -z "$id" ]
then
err "failed to find vendor-product id for PCI id \"$pciid\""
return 1
fi
echo "$id" > /sys/bus/pci/drivers/pci-stub/new_id
if [ $? -ne 0 ]
then
err "Failed to tell pci-stub about id \"$id\""
return 1
fi
echo "${domain}:${pciid}" >
/sys/bus/pci/devices/${domain}:${pciid}/driver/unbind
if [ $? -ne 0 ]
then
err "Failed to unbind PCI device \"${domain}:${pciid}\""
return 1
fi
# pci-stub claims device so it can be assigned guest
echo "${domain}:${pciid}" > /sys/bus/pci/drivers/pci-stub/bind
if [ $? -ne 0 ]
then
err "Failed to bind pci-stub to device
\"${domain}:${pciid}\""
return 1
fi
return 0
}
e.g., claim_pci_dev "06:10.0"
PF-VF correlations. Example using eth2
INTFC=eth2
# pci id to VF correlation:
DEVPATH=$(readlink -f /sys/class/net/${INTFC})
ls -l ${DEVPATH}/device/virtfn*
# map a virtual function to a netdevice - in this case find the PCI id
for VF 0
VFN=0
VFID=$(readlink ${DEVPATH}/device/virtfn${VFN} | sed -e 's,^../,,')
--> VFID is the PCI device ID for VF 0 on netdevice eth2
qemu-kvm command line addition is:
-device pci-assign,host=${PCIID}
>
>>
>> For SR-IOV I assume I need to configure the PF in the host, enable
>> some number of VFs, pass through a VF to each guest and load the vf
>> driver. Is that right?
>
> I think all that is needed is to prevent the host from binding to the
> guest - not sure.
See above.
>
>> Do I need to configure a software bridge to allow the guests to talk
>> to each other?
>
> S/R-IOV networking is beyond my knowledge - I think it depends on your
> switch, sometimes it will loop back packets to other guests, other times
> the NIC itself will do that. It may just work, so try it out.
PF for the NIC is attached to the network. VFs within the nic are
attached by extension. VF-VF packet flows (ie., VM to VM on the same
host) work more efficiently than hitting the wire, but not as well as
virtio connected to a bridge:
http://comments.gmane.org/gmane.comp.emulators.kvm.devel/70686
Very good descriptions in the companion guide at
http://www.intel.com/products/ethernet/resource.htm#s1=Gigabit%20Ethernet&s2=82576EB&s3=all
David
>
>> I assume the passthrough require VT-d support in the hardware and host
>> kernel--is that correct?
>>
>
> Yes. Recent kernels have that.
>
next prev parent reply other threads:[~2011-06-27 15:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-24 21:10 SR-IOV and KVM? Chris Friesen
2011-06-25 1:09 ` lidong chen
2011-06-25 1:13 ` Sasha Levin
2011-06-27 14:15 ` Chris Friesen
2011-06-27 14:40 ` Avi Kivity
2011-06-27 15:15 ` David Ahern [this message]
2011-06-27 15:34 ` Steve Dobbelstein
2011-06-25 8:53 ` Troels Arvin
2011-06-27 4:23 ` David Ahern
2011-06-27 8:18 ` Troels Arvin
2011-06-27 14:59 ` David Ahern
2011-06-28 20:09 ` Troels Arvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E089EAD.5070104@gmail.com \
--to=dsahern@gmail.com \
--cc=avi@redhat.com \
--cc=chris.friesen@genband.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox