Author Topic: VM and pci passthrough  (Read 1508 times)

0 Members and 1 Guest are viewing this topic.

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
VM and pci passthrough
« on: July 27, 2022, 07:59:45 pm »
In order to use a certain card in a vm of win7 32 under linux, I unbound all other pci devices in the iommu group as the desired card. So when this happens I can't use my motherboard gigabit nic and the cdrom is not connected, as well as some USB ports connected to the Southbridge. So up to now I sort of took it that I could never use those devices (until rebooting) again. Then I was thinking about it and wondering why I could not just have the host system talk to the devices in their new locations? It could be that they are not accessible due to environmental fencing at that point? Also it could be doable if Linux itself was being hypervised, but I don't want to deal with it. Just wondering if anyone knew if the computer itself could reclaim some of these vfio-pci devices? As it stands I am using a USB wireless dongle to be sending this.
« Last Edit: July 27, 2022, 08:10:19 pm by msuffidy »
 

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
Re: VM and pci passthrough
« Reply #1 on: July 27, 2022, 10:44:25 pm »
Have to review it but this sounds like a good overview of the problem.
« Last Edit: July 27, 2022, 10:45:58 pm by msuffidy »
 

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
Re: VM and pci passthrough
« Reply #2 on: July 28, 2022, 05:03:55 am »
Another mostly day wasted on trying various combinations of things and not working. I am not pursuing it, but there was some potential to install the gigabit nic on the the vm side and somehow bond all the networks into one, or to somehow tunnel through the vm side to openwrt to unpack. I was also looking at maybe a usb to usb transfer on some sort between a openwrt router and the computer. A small but beneficial spin off was I noticed if I got the vm to claim the cdrom sata driver, I then have the cdrom in windows. So at that point I can copy it back to the host through a windows share. I am not messing with the ACS patch but there was a ACS option I left on in the BIOS that had no immediate effects.
« Last Edit: July 28, 2022, 05:21:23 am by msuffidy »
 

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
Re: VM and pci passthrough
« Reply #3 on: July 28, 2022, 06:03:35 pm »
I made 2 shell scripts for before and after the vm is used so I can get the devices back by going between them. There is an issue with suspend after using the VM in fedora 34. It involves unbinding/binding to the /sys tree and rmmoding the vfio-pci module.

OK GOT IT TOTALLY TOGGLING NOW: a bit of a hauppage

[root@FRZNWSTE hacks]# cat unsafe-enter
#!/bin/bash
rmmod r8169
rmmod firewire_ohci
rmmod emu10k1_gp

echo "1" > /sys/bus/pci/devices/0000:06:00.0/remove
echo 0000:01:00.0 > /sys/bus/pci/devices/0000:01:00.0/driver/unbind
echo 0000:01:00.1 > /sys/bus/pci/devices/0000:01:00.1/driver/unbind
# echo 0000:03:00.0 > /sys/bus/pci/devices/0000:03:00.0/driver/unbind
echo 0000:05:01.0 > /sys/bus/pci/devices/0000:05:01.0/driver/unbind
# echo 0000:05:01.1 > /sys/bus/pci/devices/0000:05:01.1/driver/unbind
# echo 0000:05:01.2 > /sys/bus/pci/devices/0000:05:01.2/driver/unbind
# echo 0000:06:00.0 > /sys/bus/pci/devices/0000:06:00.0/driver/unbind
[root@FRZNWSTE hacks]# cat exit-win7
#!/bin/bash
rmmod vfio-pci

rmmod snd_emu10k1_synth
rmmod snd_emu10k1

echo "1" > /sys/bus/pci/devices/0000:01:00.0/remove
echo "1" > /sys/bus/pci/devices/0000:01:00.1/remove
echo "1" > /sys/bus/pci/devices/0000:03:00.0/remove
echo "1" > /sys/bus/pci/devices/0000:05:01.2/remove
echo "1" > /sys/bus/pci/devices/0000:05:01.1/remove
echo "1" > /sys/bus/pci/devices/0000:05:01.0/remove
echo "1" > /sys/bus/pci/rescan


I was having trouble with a HD TV over the air PCIe card. It seemed to be totally unstable doing the whatever, and what seems to work is removing it from the transaction BUS 6. Then I can suspend again also.
« Last Edit: July 29, 2022, 03:00:18 am by msuffidy »
 

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
Re: VM and pci passthrough
« Reply #4 on: August 02, 2022, 12:56:39 am »
Yes I was looking at those sort of options to solve the problem, but I like the cards where they are and I almost pursued a usb etthernet dongle, but it was not supported at this time for linux. I can do 60mbit through my wireless n 2.4 tp link dongle as it is. I have the option to stop the vm and put the system back to the way it was. It was tedious but it is over now and works in the on off manner.
 

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
Re: VM and pci passthrough
« Reply #5 on: August 03, 2022, 12:10:37 am »
Weird thing is I was out getting some free scraps off the internet on my bike and I think maybe I got what I need, but it is 100 not 1000. So well. Better.
 

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
Re: VM and pci passthrough
« Reply #6 on: August 03, 2022, 02:24:26 am »
I was just testing out that unit and it seems to not be working thus far and USB 1 which all together makes it a bad solution. Linux sort of sees the usb device but the cable is always unplugged and the link led never comes on the unit.
 

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
Re: VM and pci passthrough
« Reply #7 on: August 03, 2022, 04:27:24 pm »
Again it is slower than my wireless N dongle which seems to be working properly anyway, but my guess is the lan side got blown somehow. The correct driver is loaded but the link and tx leds never go on. The router sees the link is set up. I took it apart no obvious problems. Giving up on that one.
 

Offline msuffidyTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: ca
Re: VM and pci passthrough
« Reply #8 on: August 04, 2022, 07:39:53 pm »
OK It bugged me so I got a usb 3 to gigabit adapter for $20.40 Canadian today. It is working properly and had native drivers for Fedora Core 34 as I checked it out before buying. The graph there shows a file copy between 2 computers on my home gigabit lan, it does not reflect access speed to the internet.
« Last Edit: August 04, 2022, 09:28:02 pm by msuffidy »
 
The following users thanked this post: evb149


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf