HOW-TO make dual-boot obsolete using kvm VGA passthrough

Questions about virtualization software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
dminuth

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by dminuth »

Thnx Powerhouse..
Ya i only realised that when i was doing the calcuations for the ram and the hugepage sizes i was allocating ALL my ram.. Idiot me wasn't thinking about just the ram that i wanted the VM to have.

I did find out about the sleep and hibernate thing though.. lol.. Blanks the screen and no way to get it back other than to "quit" and "start" in the qemu console.

Almost ready for those benchmarks.

Once again, AWESOME guide. :)
dminuth

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by dminuth »

Ok, all is working great.. Got low scores on both benchmarks, but i don't have the greatest hardware to begin with. I do have 1 issue.
the sound in the windows VM, seems laggy. kinda distorted. Once i am in game ie fallout 4 everything is ok, except in the menus, then the sound is the same quality as in windows. I have tried lowering the Hz of the sound used by windows to 44Hz and even a step lower, but it stays unchanged.
any ideas ?

am thinking maybe a pulseaudio thing, might have to switch to alsa or something along those lines, will have to search further.
dminuth

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by dminuth »

Hey powerhouse,
was doing reading to see if i can increase Win10 performance on vm anyway, and came across some about i/o mode=native. Apparantly something to put into the same line where one declares the disks. Any idea about syntax for it, all i can find is for virsh.
Same idea with cache mode = none.

Am still researching to see how to implement as to test if it really does change anything, but thought maybe you might have already come across this.

http://unix.stackexchange.com/questions ... inside-kvm

it's on the above link about halfway down the page in bullet points.
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

dminuth wrote:Ok, all is working great.. Got low scores on both benchmarks, but i don't have the greatest hardware to begin with. I do have 1 issue.
the sound in the windows VM, seems laggy. kinda distorted. Once i am in game ie fallout 4 everything is ok, except in the menus, then the sound is the same quality as in windows. I have tried lowering the Hz of the sound used by windows to 44Hz and even a step lower, but it stays unchanged.
any ideas ?

am thinking maybe a pulseaudio thing, might have to switch to alsa or something along those lines, will have to search further.
Thanks for bringing this up. In fact, I have also some sound distortion when passing sound from the Windows VM to Linux pulseaudio. I haven't done anything about it since it's good enough for me.

There are some possible solutions to this:

1. Buy a USB DAC, pass through a USB port (or PCI passthrough a USB controller, if you have a spare one) and feed the USB audio line or headphone output to the line input of your onboard sound card using a cable. These USB DACs can be dirt cheap (some $), but the good stuff costs around $80+ (for example a Dragonfly) and beat any onboard audio by a mile, that is if you are into audiophile listening.

2. Use the audio from your graphics card via HDMI. You need a screen with built-in speakers or a headphone (line) socket on the screen. You can also get an HDMI to AV converter for around $16 that will give you RCA L+R connectors (see for example here: https://www.amazon.com/s/ref=nb_sb_noss ... +composite - WARNING: I never tried one of those, so make sure the specs are right).

3. Search for a way to fix the pulseaudio issue. I haven't yet experimented with it, but if I find something, I'll post.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

dminuth wrote:Hey powerhouse,
was doing reading to see if i can increase Win10 performance on vm anyway, and came across some about i/o mode=native. Apparantly something to put into the same line where one declares the disks. Any idea about syntax for it, all i can find is for virsh.
Same idea with cache mode = none.

Am still researching to see how to implement as to test if it really does change anything, but thought maybe you might have already come across this.

http://unix.stackexchange.com/questions ... inside-kvm

it's on the above link about halfway down the page in bullet points.
I tried several options myself, including the following:

Code: Select all

  -drive if=none,id=drive0,cache=directsync,format=raw,file=/dev/mapper/os-win10 \
  -device virtio-blk-pci,drive=drive0,scsi=off,x-data-plane=on \
Please note that my tutorial uses an image file, which is the slowest option, but perhaps the most convenient for starters.

The above example uses an LVM volume. I'm using LVM for all my disks (7 at the moment, or 8?, I stopped counting). Two of my disks are SSD, the rest HDD. My Windows 10 VM resides on a SSD, so does Linux.

The best configuration I found so far for my Windows 10 SSD drive is this:

Code: Select all

-device virtio-scsi-pci,id=scsi \
  -drive id=disk0,if=virtio,cache=none,format=raw,file=/dev/mapper/os-win10 \
I use the following for my Windows 10 data HDD drives (LVM volumes):

Code: Select all

  -drive id=disk1,if=virtio,cache=none,file=/dev/mapper/data-photos \
  -device virtio-scsi-pci,id=scsi1 \
In all cases I use the virtio-scsi drivers.

More information on KVM performance tuning: https://wiki.mikejung.biz/KVM_/_Xen#Lib ... KVM_Guests - NOTE: These suggestions didn't work for me. Perhaps because I use the -machine q35 option? Don't know.

(The problem with KVM is that there are zillions of options, few of which are actually documented. Now if you throw in virsh, libvirt and virt-manager, things look even worse, which is why I don't bother with them.)

Back to performance: If you are concerned about disk performance, then you need to use a separate partition or an LVM volume for your Windows VM, together with the virtio drivers. Today I tried to switch from the SCSI drivers I use to the Virtio block drivers (viostor) and wasn't successful. However, during the Windows installation I believe the viostor driver was an option. You could try that driver with the first qemu option I listed above (-drive if=none,id=drive0,cache=directsync,format=raw,file=...).

If you have followed my tutorial and used a raw image file (e.g. win.img), then disk performance will be rather poor. (I wanted to keep the tutorial short and not make things more complicated than they already are.) So unless you use a separate partition or LVM volume, there is not much point in tweaking disk performance for a raw image file.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
O_Shovah

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by O_Shovah »

Hello Everybody,

As i have already done with the XEN tutorial ( with success thanks to powerhouse) i am trying now on my new maschine with the KVM.
But already i have run into a problem with the installation of the Guest system.

But first the system facts:

MB: Asrock Rack EPC602D8A
CPU: Xeon E5-2670 V1
RAM: 2x8GB Kingston
Host GPU: AMD HD6450
Guest GPU: AMD R9 290
HDD: OCZ Vertex 4 512GB
OS: Ubuntu 14.04.3 LTS

My windows7vm.sh file:

Code: Select all

#!/bin/bash

configfile=/etc/vfio-pci.cfg
vmname="windows7vm"

vfiobind() {
   dev="$1"
        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
   
}


#if ps -A | grep -q $vmname; then
#   echo "$vmname is already running." &
#   exit 1

#else

   cat $configfile | while read line;do
   echo $line | grep ^# >/dev/null 2>&1 && continue
      vfiobind $line
   done

# use pulseaudio
export QEMU_AUDIO_DRV=pa

cp /usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd /tmp/my_vars.fd

qemu-system-x86_64 \
  -name $vmname,process=$vmname \
  -machine type=q35,accel=kvm \
  -cpu host \
  -smp 4,sockets=1,cores=2,threads=2 \
  -enable-kvm \
  -m 8G \
  -mem-path /run/hugepages/kvm \
  -mem-prealloc \
  -balloon none \
  -rtc clock=host,base=localtime \
  -vga none \
  -nographic \
  -serial none \
  -parallel none \
  -soundhw hda \
  -usb -usbdevice host:046d:c035 -usbdevice host:046a:0011 \
  -device vfio-pci,host=06:00.0,multifunction=on \
  -device vfio-pci,host=06:00.1 \
  -drive if=pflash,format=raw,readonly,file=/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd \
  -drive if=pflash,format=raw,file=/tmp/my_vars.fd \
  -boot order=dc \
  -device virtio-scsi-pci,id=scsi \
  -drive id=disk0,if=virtio,cache=none,format=raw,file=/media/o_shovah/win.img \
  -drive file=/home/o_shovah/ISO/de_windows_7_professional_with_sp1_x64_dvd_u_676919.iso,id=isocd,format=raw,if=none -device scsi-cd,drive=isocd \
  -drive file=/home/o_shovah/Downloads/virtio-win-0.1.112.iso,id=virtiocd,format=raw,if=none -device ide-cd,bus=ide.1,drive=virtiocd \
  -netdev type=tap,id=net0,ifname=tap0,vhost=on \
  -device virtio-net-pci,netdev=net0,mac=00:16:3e:00:01:01

   exit 0
fi
The Case:

The installation guide worked flawlessly until the startup of the shell script.
At first the shell script reported the script to be already running.
Executing the command manually yet returned no result. I therefore commented
this part out as you can see in my file above.
The script could be started after that but reported to have found no network bridge.
I surpassed this by creating a bridge like described in the Xen tutorial of Powerhouse.

Then i could start the KVM machine.
-The "BIOS" screen appears and reports 8GB RAM successfully checked
-Press a button to boot from DVD/CD -> Button pressed
-"Windows installer is loading files" progress bar runs through
-"Windows installer is starting" appears.
And thats the point where the machine stalls/freezes and no further
progess is made independent of waiting time. :(

I asume to have fallen to a simple pitfall and would appreciate any help
pointing it out to me :)
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

@O_Shovah: I'm afraid it's going to be more difficult. I too tried to install Windows 7 and failed! It probably has to do with UEFI support under Windows 7, which seems problematic. This is why I switched to Windows 10 where installation was a piece of cake.

The tutorial is for UEFI boot. I suppose you checked that your guest graphics card supports UEFI?

Option 1

In order to install Windows 7 with UEFI, you need to create a bootable FAT32 partition, size 4GB, on a GPT drive! See http://ubuntuforums.org/showthread.php?t=2266916 and search for Windows 7 on that page, go to the 3rd occurrence of the search term:
You'll need a copy of Windows 8 or 8.1. It's apparently possible to install Windows 7 but I found it was more trouble than it's worth. DO NOT try to install the Ultimate version - install Professional or Home

Your graphics card will need to be UEFI capable. Mine is an older AMD card for which there is no official UEFI bios .... but I was able to construct one (see the beginning of this post)

Create a disk image for the VM - I recommend an LVM partition. In my case I allocate LVM partitions on the mechanical drive until I'm happy everything's running ok and then copy them across to the SSD using dd.
You'll also need a small (4GB) Fat32 partition on a "GPT" drive which we'll copy the installation files to. The install iso should be copied to an install partition as accessible to a VM ie.

* Create a new partition for this purpose, can be LVM or 'flat' but must reside on a GPT disk not MBR
* Allocate the new partition to a VM – so it can be formatted. DO NOT format this using host format tools, it must be done from a VM
* Allocate the new partition to a windows VM
* Format as FAT32, consider adding the WIN xx bootloader as well. Not necessary but seems cleaner and make the partition bootable (set “active” or bootable flag in parition table)
* Copy the install iso to the newly formatted partition. This can be accomplished by passing the iso to the VM used to format the new install partition as a CD-ROM (use virt-manager)
* Check that the \efi\boot partition exists and contains the same files as \efi\microsoft\boot. If necessary copy files into a new \efi\boot partition. Also must contain a copy bootmgw.efi named bootx64.efi in \efi\boot
* Check the contents of \source\ei.cfg to ensure it nominates the correct OS product (best to use “Professional”).
* It can be beneficial to use Win Toolkit to include the linux qxl driver (spice screen driver) in the Windows build although I'm not convinced this is necessary.
* Exit the VM used to format the install partition
Another possibility would be to use a Windows install ISO and have it format a drive or partition. Warning: You need to physically disconnect all unused drives and make a complete external backup of the drive you want to format. Windows is known for wiping out entire disks. This is only a temporary partition where the Windows 7 ISO content is copied to. After that some UEFI files are modified to make the UEFI boot work with Windows 7.

As you can see, quite a pain in the neck. Somewhere along the above I decided to use my free upgrade to Windows 10.

Option 2

You can always skip UEFI boot and use the legacy VGA boot using Seabios - see also https://bbs.archlinux.org/viewtopic.php?id=162768. In that case you don't need the OVMF package and you need to delete the following lines from your start script:

Code: Select all

  -drive if=pflash,format=raw,readonly,file=/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd \
  -drive if=pflash,format=raw,file=/tmp/my_vars.fd \
You might need to play with the display options / VNC. A year or 2 ago I managed to pass through an AMD card using primary passthrough, so no VNC viewer was necessary. But your mileage may vary.

If you manage to get this working, I would be curious about the performance differences between KVM and Xen. Care to post benchmarks (see my tutorial at the end)?

One more thing: I hope you backed up your Xen installation and Windows VM. I was running Xen for over 3 years and was very happy with it, until I ran into a problem with my AMD GPU on the host (no DDC support and generally poor performance under Linux). I decided to go with Nvidia which was the trigger to use KVM. My host runs an Nvidia Quadro with Nvidia proprietary driver and my Windows guest uses an Nvidia GTX 970. I knew it would work with KVM, but had my doubts about making it work under Xen. In other words, I had my good reason to switch to KVM. I doubt I would have made this switch when using AMD GPUs.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

@O_Shovah: Just a note on the above. In my failed attempt to install Windows 7 I wasn't following the instructions above (creating a 4GB partition for the installation files). Instead I mounted the ISO image and manipulated its content to create a modified ISO, which obviously didn't work. I can't remember how and what exactly I did, but I suggest not to try to make shortcuts. Good luck!

P.S.: Just had a look at your hardware - nice specs! It looks like you plan to do some serious virtualization stuff.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
Trainguyrom

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by Trainguyrom »

Hey I'm doing the final checks before setting up the VM and upon running gmesg | grep pci-stub I get the following output:

Code: Select all

[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.19.0-32-generic root=UUID=137e9e77-b3c9-43c6-8704-7120972bdfc3 ro quiet splash intel_iommu=on nouveau.blacklist=1 pci-stub.ids=10de:13c2,10de:0fbb
[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-3.19.0-32-generic root=UUID=137e9e77-b3c9-43c6-8704-7120972bdfc3 ro quiet splash intel_iommu=on nouveau.blacklist=1 pci-stub.ids=10de:13c2,10de:0fbb
[    8.087113] pci-stub: add 10DE:13C2 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[    8.087121] pci-stub 0000:02:00.0: claimed by stub
[    8.087125] pci-stub: add 10DE:0FBB sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[    8.087129] pci-stub 0000:02:00.1: claimed by stub
[    8.822413] pci-stub 0000:02:00.0: enabling device (0000 -> 0003)
Should I be concerned about that last line?

Also, when editing the Grub config I noticed that the flag nomodeset wasn't set, but there was a flag splash. In other words, by default it had the flags "quiet splash" Here's the entire grub config:

Code: Select all

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on nouveau.blacklist=1 pci-stub.ids=10de:13c2,10de:0fbb"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
And as for my PC specs:

Code: Select all

Intel i7 4790k
Asus z97-A USB3.1
32GB (4x8GB DDR3-1600) Memory
EVGA GTX750TI 2GB OC (Mint 17.3 Host)
EVGA GTX970 4GB FTW (Windows 7 Guest)
I'm leaving out irrelevant peripherals and drives, but if you want/need those you can look here, just pretend that this is also listed on Graphics Cards

I saw some previous posts suggesting that Windows 7 may not be compatible with this method and I may have to replace the UEFI with a BIOS for the Guest, but I may just switch to 10 to make things easier, if this turns out to be a problem.

Anyways, I'm going to try enabling the nomodeset flag to see if that helps while I wait for a response.

Thank you in advance
-Train
steakikan

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by steakikan »

Hi, do you know how to make sure the guest os shutdown when the host os shutdown? I try to setup automatic shutdown from a UPS but not sure if I sent shutdown -h to host does it directly kill qemu? Thanks
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

steakikan wrote:Hi, do you know how to make sure the guest os shutdown when the host os shutdown? I try to setup automatic shutdown from a UPS but not sure if I sent shutdown -h to host does it directly kill qemu? Thanks
That's the easy one: There is no communication between the Linux host and the guest VM. In other words, when you shutdown -h your Windows guest doesn't get any trigger to shutdown as well.

There are Windows guest additions that may allow such communication. I'm not familiar with it, but check out the Redhat virtio website (see also references at the end of the tutorial). Please post here your findings.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
steakikan

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by steakikan »

Ah I see, that's mean I have to use some other means to shutdown the guest os. One more question, I have difficulty in connecting the network connection, can you help? In qemu there is an error message : W: /etc/qemu-ifup: no bridge for guest interface found. Thanks for your help.
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

@Trainguyrom:

1. Just give it a try and run the script. If you get the Tianocore screen, all is fine.

2. nomodeset is not related to what we are doing. I use it simply because some graphics cards require this setting. splash etc. is likewise irrelevant. If your system works with these settings, just keep them and add the "intel_iommu=on nouveau.blacklist=1 pci-stub.ids=10de:13c2,10de:0fbb" stuff.

3. Windows 7 will not work with UEFI boot, at least not out of the box. You can simply use the legacy Seabios boot as I described in a post above. If you feel like and have the option, you could upgrade to Windows 10. Last not least, you could follow the steps I mentioned in the post above to make Windows 7 work, but I can't give you a guarantee on that since I didn't have the patience to go through with it.

Your hardware seems to be good - I use a GTX 970 myself for the Windows guest :) .
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

steakikan wrote:Ah I see, that's mean I have to use some other means to shutdown the guest os. One more question, I have difficulty in connecting the network connection, can you help? In qemu there is an error message : W: /etc/qemu-ifup: no bridge for guest interface found. Thanks for your help.
You might need to create the bridge. In my hurry writing the tutorial I may have forgotten this part. Install "bridge-utils" and then follow step 6 in my Xen tutorial here: http://forums.linuxmint.com/viewtopic.p ... 13#p628768.

Tell me if that works and I will add that step to the tutorial.

(Note: I was running Xen before using kvm, so I already had a bridge configured and working.)
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
O_Shovah

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by O_Shovah »

powerhouse wrote:
steakikan wrote:Ah I see, that's mean I have to use some other means to shutdown the guest os. One more question, I have difficulty in connecting the network connection, can you help? In qemu there is an error message : W: /etc/qemu-ifup: no bridge for guest interface found. Thanks for your help.
You might need to create the bridge. In my hurry writing the tutorial I may have forgotten this part. Install "bridge-utils" and then follow step 6 in my Xen tutorial here: http://forums.linuxmint.com/viewtopic.p ... 13#p628768.

Tell me if that works and I will add that step to the tutorial.

(Note: I was running Xen before using kvm, so I already had a bridge configured and working.)
I can Report the step 6 of your Xen tutorial to be working fine as i mentioned in my post above :)

[I am stil struggeling with my seabios/GPU passtrough but will report back on that]
steakikan

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by steakikan »

powerhouse wrote:
steakikan wrote:Ah I see, that's mean I have to use some other means to shutdown the guest os. One more question, I have difficulty in connecting the network connection, can you help? In qemu there is an error message : W: /etc/qemu-ifup: no bridge for guest interface found. Thanks for your help.
You might need to create the bridge. In my hurry writing the tutorial I may have forgotten this part. Install "bridge-utils" and then follow step 6 in my Xen tutorial here: http://forums.linuxmint.com/viewtopic.p ... 13#p628768.

Tell me if that works and I will add that step to the tutorial.

(Note: I was running Xen before using kvm, so I already had a bridge configured and working.)
Yep it works, thanks for your guide. It is really helpful as most guide either refer to Arch or Fedora. In regards to acpi shutdown the only one I found is to manually use socket or telnet to shutdown the guess gracefully then shutdown the host.

edit: I try to pass a PCIe USB card 4x but when i try to pass it this error come out:
(qemu) qemu-system-x86_64: -device vfio-pci,host=02:00.0: vfio: error opening /dev/vfio/21: No such file or directory
qemu-system-x86_64: -device vfio-pci,host=02:00.0: vfio: failed to get group 21
qemu-system-x86_64: -device vfio-pci,host=02:00.0: Device initialization failed.
qemu-system-x86_64: -device vfio-pci,host=02:00.0: Device 'vfio-pci' could not be initialized

The device that I am passing tru:
-device vfio-pci,host=02:00.0 \
-device vfio-pci,host=02:00.1 \
-device vfio-pci,host=03:01.0 \
-device vfio-pci,host=03:05.0 \
-device vfio-pci,host=03:07.0 \
-device vfio-pci,host=03:09.0 \
-device vfio-pci,host=04:00.0 \
-device vfio-pci,host=05:00.0 \
-device vfio-pci,host=06:00.0 \
-device vfio-pci,host=07:00.0 \
02:00.0 PCI bridge [0604]: PLX Technology, Inc. PEX 8609 8-lane, 8-Port PCI Express Gen 2 (5.0 GT/s) Switch with DMA [10b5:8609] (rev ba)
02:00.1 System peripheral [0880]: PLX Technology, Inc. PEX 8609 8-lane, 8-Port PCI Express Gen 2 (5.0 GT/s) Switch with DMA [10b5:8609] (rev ba)
03:01.0 PCI bridge [0604]: PLX Technology, Inc. PEX 8609 8-lane, 8-Port PCI Express Gen 2 (5.0 GT/s) Switch with DMA [10b5:8609] (rev ba)
03:05.0 PCI bridge [0604]: PLX Technology, Inc. PEX 8609 8-lane, 8-Port PCI Express Gen 2 (5.0 GT/s) Switch with DMA [10b5:8609] (rev ba)
03:07.0 PCI bridge [0604]: PLX Technology, Inc. PEX 8609 8-lane, 8-Port PCI Express Gen 2 (5.0 GT/s) Switch with DMA [10b5:8609] (rev ba)
03:09.0 PCI bridge [0604]: PLX Technology, Inc. PEX 8609 8-lane, 8-Port PCI Express Gen 2 (5.0 GT/s) Switch with DMA [10b5:8609] (rev ba)
04:00.0 USB controller [0c03]: ASMedia Technology Inc. Device [1b21:1142]
05:00.0 USB controller [0c03]: ASMedia Technology Inc. Device [1b21:1142]
06:00.0 USB controller [0c03]: ASMedia Technology Inc. Device [1b21:1142]
07:00.0 USB controller [0c03]: ASMedia Technology Inc. Device [1b21:1142]

And I have checked they are all under 1 iommu group, can you help? Thanks.
/sys/kernel/iommu_groups/21/devices/0000:02:00.0
/sys/kernel/iommu_groups/21/devices/0000:02:00.1
/sys/kernel/iommu_groups/21/devices/0000:03:01.0
/sys/kernel/iommu_groups/21/devices/0000:03:05.0
/sys/kernel/iommu_groups/21/devices/0000:03:07.0
/sys/kernel/iommu_groups/21/devices/0000:03:09.0
/sys/kernel/iommu_groups/21/devices/0000:04:00.0
/sys/kernel/iommu_groups/21/devices/0000:05:00.0
/sys/kernel/iommu_groups/21/devices/0000:06:00.0
/sys/kernel/iommu_groups/21/devices/0000:07:00.0
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

@steakikan: Perhaps you forgot to enter the PCI bus numbers into the /etc/vfio-pci.cfg file?

Go to /etc/ and create the file vfio-pci.cfg. Enter the PCI bus number for the graphics card you wish to pass through to Windows without blank lines!!! In my example the content is:

Code: Select all

0000:02:00.0
0000:02:00.1
Don't forget the leading "0000:".

That was a long Linux Mint forum outage! I think will put my tutorials on my own website.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
steakikan

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by steakikan »

steakikan wrote:Ah I see, that's mean I have to use some other means to shutdown the guest os. One more question, I have difficulty in connecting the network connection, can you help? In qemu there is an error message : W: /etc/qemu-ifup: no bridge for guest interface found. Thanks for your help.
Just updating my own post, there is a way for safe shutdown guest using telnet protocol and qmp, i haven't found a way to lock the telnet to localhost but the idea is to use the telnet json protocol to send shutdown command and wait for qmp to reply then you execute the host shutdown command.
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

steakikan wrote:
steakikan wrote:Ah I see, that's mean I have to use some other means to shutdown the guest os. One more question, I have difficulty in connecting the network connection, can you help? In qemu there is an error message : W: /etc/qemu-ifup: no bridge for guest interface found. Thanks for your help.
Just updating my own post, there is a way for safe shutdown guest using telnet protocol and qmp, i haven't found a way to lock the telnet to localhost but the idea is to use the telnet json protocol to send shutdown command and wait for qmp to reply then you execute the host shutdown command.
Thanks for this - very helpful.

Did you manage to solve the PCI passthrough issue?
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
Trainguyrom

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by Trainguyrom »

Hey, it looks like I'm having issues with both of my graphics cards being in the same iommu group, as well as the network bridge failing.

Code: Select all

W: /etc/qemu-ifup: no bridge for guest interface found
QEMU 2.1.2 monitor - type 'help' for more information
(qemu) qemu-system-x86_64: -device vfio-pci,host=02:00.0,multifunction=on: vfio: error, group 1 is not viable, please ensure all devices within the iommu_group are bound to their vfio bus driver.
qemu-system-x86_64: -device vfio-pci,host=02:00.0,multifunction=on: vfio: failed to get group 1
qemu-system-x86_64: -device vfio-pci,host=02:00.0,multifunction=on: Device initialization failed.
qemu-system-x86_64: -device vfio-pci,host=02:00.0,multifunction=on: Device 'vfio-pci' could not be initialized
Looking in /sys/bus/pci/devices/<device name>/iommu_group/devices for both cards. I see everything is in the same group. It looks like I need to move 0000:02:00.0 and 0000:02:00.1 to their own group.
Locked

Return to “Virtual Machines”