How to save game system from home PC by means of virtualization

  • Tutorial
Thanks to the competition and the development of scientific and technical progress, modern PCs allow you to perform many simple and complex tasks at the same time, for example, play and play video on TV, render graphics and read news on the Internet, distributing torrents in parallel, etc. etc. Many go further and use several PCs for work and entertainment. However, with the help of virtualization technologies, on the one hand, you can expand the capabilities of your PC, and on the other, save money, because in fact, you can run several operating systems on the same hardware at the same time.


This article will be hosted host settings specifically for use in the "home", ie talk about GPU PASSTHROUGH .

Introduction


First, a few words about virtualization in general. According to Wikipedia :
Virtualization is the provision of a set of computing resources or their logical combination, abstracted from the hardware implementation, and while providing logical isolation from each other of computing processes running on the same physical resource.
It is achieved both with the help of applications (for example VirtualBox, VMware) and at the level of systems that support hardware virtualization (for example KVM, ESXi, Hyper-V). In the latter case, the loss of performance compared to native systems is minimal .

Hereinafter, the article will describe the settings of the Proxmox open source virtualization system because it is moderately friendly, there is easy access to the console via a web form, and it is also based on a bunch of Debian + kvm, which have a lot of guides and descriptions on the network , i.e. documentation including and in Russian.

Hardware requirements


We need:

- a processor and motherboard with support for VT-x, VT-d from Intel or AMD-Vi, IOMMU from AMD. Do not be lazy and specify whether your copy supports these requirements.

As for motherboards. I categorically do not recommend to drive iron with mediocre wiring on the power board. By Z270 and Z390 ignore the orange zone or leave to work in stock.

  • 2 video cards, one game (on the network for fewer problems when forwarding to a virtual machine they praise the red ones, but personally, everything worked out with the video card from the green ones), the second one for the host. In my case, it is integrated into the processor.
  • 1-2 monitors and cables to them, in order to
  • a pair of keyboard + mouse sets to make it convenient to work and configure systems
  • a second PC or tablet connected to the local network to make settings through a web form.

Installation and settings


I used the following game configuration:

- The host PC configuration was built on a far from the best motherboard, but in English forums it is very often praised by this company because its hardware is most suitable for such things:
Processor - i7 8700k
Mother - ASRock Z390M Pro4
Video Card - INNO3D GeForce GTX 1070 iChill X4
- second PC (Morefine-M1s Mini-PC),
- 2 mice,
- 1 host keyboard, on the other devices used softkey,
- 3 Dell U2713HM monitor connections (VGA - for integrated video cards, HDMI - for the GTX1070, on the DVI there is a Mini-PC. video signals carried out through the monitor menu)

0th stage- On the motherboard, turn on VT-d: Enable, Intel Vitrualization Technology: Enable, Primary Graphx adapter: VGA, Above 4G Decoding: Enable. If possible, be sure to select the one on which the host will work, i.e. weaker graphics card and switch to it.

1st stage - Install Proxmox on the host. For this:

1.1. Download the disk image from the official site

1.2. We write the image to the flash drive using special programs

1.3. We boot from the USB flash drive, and perform the installation indicating which hard drive to install on, enter the password for the future root user, and also explicitly set the network settings.

2nd stage- We connect via the network via the web interface using a second PC or
tablet (in my case it was a Mini-PC) to the host and configure Proxmox for this guide through a text console.

image

There is a small nuance that may cost software, but I decided that changing the previous motherboard would be easier, because Gigabyte's board did not meet this requirement:
1) Run the "dmesg | grep ecap »command.

2) On the IOMMU lines, the hexadecimal value after "ecap" indicates whether interrupt remapping is supported. If the last character of this value is an 8, 9, a, b, c, d, e, or an f, interrupt remapping is supported. For example, "ecap 1000" indicates there is no interrupt remapping support. "Ecap 10207f" indicates interrupt remapping support, as the last character is an "f".

Interrupt remapping will only be enabled if every IOMMU supports it.
If the condition is met, continue.

So, the settings:

Open the file with a command from the console (you do not need to enter the double-lattice symbol, so I will separate the commands from what needs to be entered into the file in the text)

## nano /etc/default/grub

make replacement

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

for Intel processors

GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"

for AMD processors

GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"

next we give the command

## update-grub

then we reboot the host via the web interface

PC grub file in article
# 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_TIMEOUT=5
GRUB_DISTRIBUTOR="Proxmox Virtual Environment"
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"
GRUB_CMDLINE_LINUX=""
# Disable os-prober, it might add menu entries for each guest
GRUB_DISABLE_OS_PROBER=true
# 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
# 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"


Add the necessary drivers to the configuration file

## nano /etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd

We write in the console

## lspci

A list of devices available for forwarding will be displayed on the screen, we will find the unit with the video card that interests us, in my case these are 2 devices in the video card group and sound at the addresses 01: 00.0 and 01: 00.1, so I immediately register the group.

## nano /etc/pve/qemu-server/vmid.conf

hostpci0: 01:00

We write the command in the console in order to determine the model and its id

## lspci -n -s 01:00
01: 00.0 0300: 10de: 1b81 (rev a2)
01: 00.1 0403: 10de: 10f0 (rev a1)

Now we edit the file for our video card (in your case id will be different)

## nano /etc/modprobe.d/vfio.conf

options vfio-pci ids=10de:1b81,10de:10f0

We put in the black sheet of the driver

## nano /etc/modprobe.d/blacklist.conf

blacklist radeon
blacklist nouveau
blacklist nvidia

Now we create through the web interface and edit the virtual machine settings file through the console. Here the line "args:" solves, because without it, the video card driver will detect virtualization, but by changing the name of the equipment, more precisely, hv_vendor_id = willitwork, we remove the problem with error 43 , which the device’s video driver can generate. There is a virtual machine number in proxmox used as a name.

## nano /etc/pve/qemu-server/.conf

args: -cpu 'host,+kvm_pv_unhalt,+kvm_pv_eoi,hv_vendor_id=willitwork,kvm=off'
.....
bios: ovmf
.....
hostpci0: 01:00.0,pcie=1
.....
machine: q35

PC virtual machine settings file in article
args: -cpu 'host,+kvm_pv_unhalt,+kvm_pv_eoi,hv_vendor_id=willitwork,kvm=off'
bios: ovmf
boot: dcn
bootdisk: sata0
cores: 8
cpu: host
hostpci0: 01:00.0,pcie=1
ide2: local:iso/ru-en_windows_10_1803_x86-x64.iso,media$
machine: q35
memory: 16384
net0: e1000=EA:20:FA:6A:D6:A0,bridge=vmbr0
numa: 0
ostype: win10
sata0: local-lvm:vm-100-disk-0,size=120G
scsihw: virtio-scsi-pci
smbios1: uuid=751edeca-d249-4c0d-9ded-b59d929df0f1
sockets: 1
usb0: host=1-8.4
usb1: host=1-8.3
vmgenid: b75aeb27-3102-458d-8e23-18cd27796dc1


Now reboot the host and start the virtual machine.

3rd stage - Through the Remote Video Console, install Windows and drivers. In my case, Windows first recognized the proxmox video driver for working through the video console, then found the driver for the GTX1070, and after updating via the Internet (forced search for drivers on the network) downloaded and installed the driver I needed for the game video card.

4th stage - Restart the Virtual Machine, switch the display of the video stream on the monitor to the video card connector and ... in my case everything worked right away, no errors 43 ... Moreover, the desktop is defined as No. 2.

I tried to launch the Blue-ray video - no problem, there were no delays and friezes with the video sequence, I launched Warhammer online - it started up and it was comfortable to play in PvP, I launched GTA5, the story popped up, I shot quite comfortably. Visually, there are no performance losses.

If we need to forward the entire hard drive, then in the virtual machine settings file we need to add the line:
ide0: volume = / dev / sda

or
sata0: volume = / dev / sda

Specifically, which sda / sdb / sdc /, etc. can be specified in the web interface.

image

PS

To the barrel of honey there is also a fly in the ointment. The integrated sound cannot be thrown separately, as in his group are other devices that, after forwarding the sound card to the virtual machine, disappear for the host until the next host overload. In my case, it is

00: 1f.0 ISA bridge: Intel Corporation Device a305 (rev 10)
00: 1f.3 Audio device: Intel Corporation Device a348 (rev 10)
00: 1f.4 SMBus: Intel Corporation Device a323 (rev 10 )
00: 1f.5 Serial bus controller [0c80]: Intel Corporation Device a324 (rev 10)
00: 1f.6 Ethernet controller: Intel Corporation Device 15bc (rev 10)

Those. sound or through a video cable to a monitor or external sound card. USB ports are routed without problems. Unfortunately, it is currently unresolved. There is an option to remotely connect from another PC to the game, via RDP or SPICE . In this case, everything will be fine.

Not always the video card forwarding is perfect as in my case, either error 43 or something else gets in the way. Other settings that may help are described here . Ideally, you need to search the network for successful setups and focus on them, as for me this appeared , in addition there is also a list of hardware that allows me to achieve the same as me, but it is not complete.

UPDATE1:
A few notes on the periphery:
1. How to get the keyboard from the PS / 2 port to the VM:
first, enter the command in the console
## dmesg | grep input
We are looking for a text in the text
...
input: AT Translated Set 2 keyboard as / devices / platform / i8042 / serio0 / input / input 2
...
Remember the number 2 at the end, it can be different. Then we add to the VM settings file in the line:
args: -object 'input-linux, id = kbd, evdev = / dev / input / event 2 , grab_all = on, repeat = on'
inserting 2 at the end evdev = / dev / input / event 2

For the mouse - similarly.

2. By USB:
As for USB devices, everything is simpler there, devices are scrolled directly from the web form by ID or you can wholly port the port. However, there is a nuance - if for some reason you cannot, like me, throw an audio device into the VM, because it is contained in a group with key controllers without which the host cannot fully work, then forwarding the port / device via USB solves this problem, but the sound can begin to fall off after some time, hiss / buzz and others ... etc., at the same time on the native everything will be great for the system. In this case, it is necessary to forward not the port / device, but the USB controller itself as a PCIe device according to the method specified in the article. And everything will improve dramatically. But at the same time, after starting the VM with such settings, it will no longer be possible to forward other devices from this controller through the host.

3. Hard drives can be forwarded as through a controller forwarding as a PCIe device according to the method specified in the article (I do not recommend forwarding the controller integrated into the motherboard, only connected to PCIe), or directly:
go to
## cd / dev / disk / by-id
through dir we look at the listing ... we
copy lines of the form ata-WDC_WD40EFRX-68WT0N6_WD-WCC4E1AC9SX9, in which the connection interface, brand and series number of the hard disk are registered. Then open the VM configuration file and write:
sata1: volume = / dev / disk / by-id / ata-WDC_WD40EFRX-68WT0N6_WD-WCC4E1AC9SX9
and everything works, keep in mind that sata0-sata5, i.e. for one VM, the number of disks thus connected, including virtual ones, cannot exceed 6pcs.

Also popular now: