LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-01-2023, 01:27 PM   #1
the_zone
Member
 
Registered: Nov 2008
Distribution: Slackware
Posts: 83

Rep: Reputation: 7
Not clue how to put pci device in passthrough in current


I have 2 the same network cards.

One of them will be the WAN side of pfsense which runs in qemu.
I'd like to isolate this card, instead of bridging it, and give it to pfsense solely.

Code:
01:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 15)
	Subsystem: Hewlett-Packard Company RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [103c:82a2]
	Kernel driver in use: r8169
	Kernel modules: r8169
02:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06)
	Subsystem: TP-LINK Technologies Co., Ltd. TG-3468 Gigabit PCI Express Network Adapter [7470:3468]
	Kernel driver in use: r8169
	Kernel modules: r8169
I have tried to add a vfio.conf in /lib/modprobe.d which contains:

Code:
options vfio-pci ids=02:00.0|10ec:8168
First of all I am not sure whether the syntax is right. Cause by adding the device "10ec:8168" I will passthrough bot NICS. So i added the bus.
It did not work.

Secondly I tried by overriding the device by cat-ting "vfio-pci" in

/sys/bus/pci/devices/0000:02:00.0/driver_override

Also this did not work because after boot it defaulted.

Third, I tried by using vfio-bind.
This command does not seems to be available on current.

Also the following does not work:

Code:
virsh nodedev-dettach pci_0000_02_00_0
error: Failed to detach device pci_0000_02_00_0
error: argument unsupported: VFIO device assignment is currently not supported on this system
To be sure the kernel module vfio-pci was loaded I did a

Code:
modeprobe vfio-pci
Code:
lsmod
returned with :

Code:
Module                  Size  Used by
vfio_pci               16384  0
vfio_pci_core          69632  1 vfio_pci
vfio_virqfd            16384  1 vfio_pci_core
vfio_iommu_type1       45056  0
vfio                   32768  2 vfio_pci_core,vfio_iommu_type1
So that seems to be OK.

I did a grep on vfio in dmesg and I got

Code:
[ 3018.707503] vfio_pci: add [0002:0000[ffffffff:ffffffff]] class 0x000000/00000000
That looks OK, isn't it ?

However qemu still complains that the host is not able to put pci devices in passthrough.
And, yes, I have enabled the correct BIOS options (VT-X etc...).







Anyone suggestions ?

br,

ST

Last edited by the_zone; 01-01-2023 at 02:00 PM.
 
Old 01-01-2023, 02:41 PM   #2
linuxdaddy
Member
 
Registered: May 2022
Location: New Mexico, USA
Distribution: Slackware 15.0 & 64 bit-current, antiX
Posts: 118

Rep: Reputation: 29
Hi the_zone,

I'm not familiar with qemu. Would the config file let you use eth0/eth1 names instead of the
device ID? Or the subsystem number which is different.
 
Old 01-01-2023, 02:45 PM   #3
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 994

Rep: Reputation: 675Reputation: 675Reputation: 675Reputation: 675Reputation: 675Reputation: 675
I haven't tried it myself, I have only used bridging and tun/tap with qemu for purposes like that, but maybe this page will help:

https://www.theseus-os.com/Theseus/b...ssthrough.html

That page adds "0000:" before the pci id, what should be added can probably be found in /sys/bus/pci/devices/

regards Henrik
 
Old 01-03-2023, 12:46 PM   #4
the_zone
Member
 
Registered: Nov 2008
Distribution: Slackware
Posts: 83

Original Poster
Rep: Reputation: 7
@linuxdaddy
I am using qemu via virt-manager. It lets you use the NICs via NAT or bridged mode.

@henca
That link gave away part of the trick indeed

I made it work.

Initially I changed my elilo.conf file, adding intel_iommu=on as kernel parameter, and ran eliloconfig, which overwrote my changes. I am used to LILO
Now that intel_iommu=on has been corretly passed I can set my NIC in passthrough with the help of the following script which I found.
Here is the link to the source of the script
https://docs.opennebula.io/6.4/open_...ssthrough.html

Code:
#!/bin/sh
modprobe vfio-pci
for dev in "$@"; do
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/\$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done
paste it in to a file called vfio-bind.

Calling it with the correct pci bus/device parameter

Code:
./vfio-bind 0000:00:02.0
puts it in passthrough.

Last edited by the_zone; 01-03-2023 at 12:48 PM.
 
4 members found this post helpful.
Old 01-03-2023, 01:30 PM   #5
yvesjv
Member
 
Registered: Sep 2015
Location: Australia
Distribution: Slackware, Devuan, Freebsd
Posts: 578

Rep: Reputation: Disabled
Nice, I could use that solution.
If you were Gryffindor... 10 points to you! ( ͡~ ͜ʖ ͡°)
 
Old 01-04-2023, 01:06 AM   #6
the_zone
Member
 
Registered: Nov 2008
Distribution: Slackware
Posts: 83

Original Poster
Rep: Reputation: 7
@yvesjv
Glad this thread is of help to someone else to.
If you have further questions, please pm me.
 
1 members found this post helpful.
  


Reply

Tags
nic, passthrough, pci



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Chipset support for PCI Passthrough in KVM rajivdp Linux - Virtualization and Cloud 0 06-14-2011 02:02 AM
PCI Passthrough with KVM fails martdj Linux - Virtualization and Cloud 5 02-01-2010 08:01 AM
LXer: Linux virtualization and PCI passthrough LXer Syndicated Linux News 0 10-29-2009 12:20 PM
problem with kvm and pci passthrough with two devices vegatux Linux - General 0 09-24-2009 10:53 AM
I have no clue on how to put alien package into synaptic. I have an eee pc DJ Carlos Linux - Newbie 4 05-07-2008 06:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration