Gaming on Windows 7 VM

Hey all!

Wasn't really planning on sharing this, but it's done, and I'm actually kinda proud of myself, so here you go.

I'm using QEMU on ubuntu studio 16.04. Windows 7 has 4 cores, 16GB RAM, and a GTX 760 passed through.

The startup script also starts the synergy server, and the synergy client starts automatically on Windows. The virtual C:\ drive is on an SSD, and there's a second virtual drive on the HDD. Also set up a samba folder for sharing files with the host.

I also made a second startup script which assigned fewer cores and skips the GPU passthru for non-gaming tasks (downloads, updates, etc.). This leaves both the host and guest in a reasonably usable condition. Finally, there's a script for restoring the virtual C:\ drive in case it's corrupted (which I've even had the pleasure of using now, twice, because &$^%@ steam).

This has honestly gone way better than I imagined it would. Games are performing wonderfully. The only really frustrating part was getting a USB hub passed through (this took WEEKS!). The GPU passthru went perfect, first time. I still have a few tweeks to make. For example, the drives are currently using IDE drivers, so I'm going to switch those to virtio.

This is my son's rig, and it will be going back with him when this visit is over. But it's been a blast.

Thanks for looking!

8 Likes

How is your performance compared to bare metal? I have a similar setup with an AMD R9 390 passed through to a windows 10 VM. My experience with newer games like Doom 2016, Evolve, Tomb Raider etc has been great, almost like bare metal but older games or at least some direct x9 games run horribly, borderline unplayable. I am not sure if this is something related to the DirectX versions or maybe win10, well at least in my situation.

Well, at least older DX9 games should be able to run decently enough on wine.

I've never used this system with a bare metal windows install, so I don't really have a basis for comparison. I can say that I expected it to work "okay" and I've been pleasantly surprised that it exceeded my expectations and works "good." I don't play a lot of games, personally. So far my son has been playing csgo, bf1, portal, and dirt showdown; they all work fine. I plan to find benchmarks and try them out; I will post the scores.

One thing we have had an intermittent problem with is sound. We're getting sound through the hdmi out on the GPU. Once in a while, the sound becomes very distorted. Most times, stopping the program using sound and restarting fixes it. sometimes a full reboot is required. Twice, video has been affected also. The odd part is that it does not affect the entire system; only the particular program. For example, one time when video was affected, it was a youtube video: the GPU was not under stress but the video became choppy and the sound distorted. The browser itself and the rest of the system was unaffected.

I'd also like to hear if anyone has recommendations for GPU monitoring software for windows 7. The nvidia control panel on linux shows useful info like temps, load, etc., but I was surprised to find the windows version doesn't. : ( It's been a long time since I looked for windows software. it all looks like malware to me. ; )

I gave up on getting the sound to work properly and just passed the integrated sound controller through instead. The only problem with this is that you would not be able to have sound playing on both host and guest systems at the same time but at least you get proper audio.

As for the GPU monitoring software, you can probably try out MSI afterburner. It's free too!!!

1 Like

This, or GPU-Z

1 Like

thanks for the suggestion! i'm trying -soundhw hda and it seems to be working better. If it happens again I'll see if I can get the integrated sound controller passed through.

thanks, does what i was looking for : )

eh.. firestrike didn't do too great. but games are still performing more than fine. this is not high-end hardware, and the gpu is secondhand, so I'm pretty satisfied. good practice, and we can upgrade it in the future.

Firestrike 1.1
---------------
overall  | 3928
physics  | 1811
combined | 2214

23rd percentile.

^ As someone soon going to leave Windows, this one cracked me up. xD

Good job on what you did! How do the controls feel using Synergy? I have cosidered using it too but read about quite severe lag and other issues in their forum.

1 Like

This is pretty badass and is really useful to know. I've been doing this at work for the past week, our end goal is to virtualize the entire company. Seriously useful and awesome. ESXi with some hacking supports it as well, and honestly Hyper-v has the best support with vGPUs for CAD/workstation tasks that I've seen thus far if you don't have a quadro.

1 Like

Feels native. Synergy shares the mouse/kb over ethernet, and a virtual NIC between host and guest is just blazing fast.

(Note, I have experienced synergy lag when connected to a different physical machine over wireless, but over local ethernet is still okay.)

One oddity I've found is that any time Windows asks "do you want to let {program x} make changes to your computer?", synergy seems to be "interrupted." The mouse pointer drops back to the Linux screen and I have to move it back to Windows. There's no waiting, though; it can move back to the windows screen immediately and the keyboard doesn't seem to be interrupted at all.

And, of course, if you need a mouse/kb during boot or in the short time between Windows booting and Synergy connection, you'll need to connect directly to the VM. This is actually the main reason I worked so hard to get a USB controller passed through.

I have a "floating" goal of setting up my next system to run virtualized (including my daily driver). Dunno when that will be, but this experience has been very encouraging/inspiring.

Thanks!

1 Like

I had a similar problem with synergy on Win10 and It was related to the UAC level. Apparently it interrupts the network connection on it's default setting when the dialogue box pops up. I just managed to stumble across it on this guide:

https://davidyat.es/2016/09/08/gpu-passthrough/

3 Likes

Nice! been doing something similar on my skylake box, so I can game while I'm training neural networks or rendering long video projects. Are you using libvirt? OVMF? I'd love to see pastebins for the configs and scripts, or more detailed info in general!

Using QEMU with KVM. Setup is based mostly on this and this. Here's the main script:

#!/bin/bash

synergy&

configfile=/home/noah/.win7/vfio-pci1.cfg

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
}

modprobe vfio-pci

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

sudo qemu-system-x86_64 -enable-kvm -M q35 -m 16384 -cpu kvm64,kvm=off \
-smp 4,maxcpus=4,sockets=1,cores=4,threads=1 \
-vga none \
-soundhw hda \
-device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \
-device vfio-pci,host=02:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on \
-device vfio-pci,host=02:00.1,bus=root.1,addr=00.1 \
-device vfio-pci,host=00:12.0,bus=pcie.0 \
-device vfio-pci,host=00:12.2,bus=pcie.0 \
-drive file=/home/noah/.vimgs-ssd/win7C.img,id=diskC,format=raw,if=virtio \
-drive file=/home/noah/.vimgs-hdd/win7D.img,id=diskD,format=raw,if=virtio \
-net nic,model=virtio \
-net user,smb=/home/noah/Desktop/store/vm-shared \
-boot menu=on

exit 0

@_adrian I managed to run Synergy via virtual NIC. You are right, it's insanely fast. Now I am glad I didn't try to use a hardware switch.

One question though, did your mouse and keyboard layout work out of the box? I am using a Logitech MX Master and the forward/backward buttons are assigned to the side-scrolling wheel. I couldn't find a good source that shows how to rebind these keys. Do you have any tips for me?

They worked fine, out of the box, but I used a fairly "basic" kb and mouse — only 3 buttons with a scroll wheel. My son mainly uses a controller for gaming (which is plugged straight into the passed-thru USB port), so we didn't look at passing through anything fancier.

Unfortunately this machine is now on the other side of the country, so I couldn't really try anything out for you. My daily mouse has back/forward buttons, though, as well as a scroll wheel that pushes left/right, and I can pass it to my laptop just fine with no problems.

One thing I can tell you, though, is that because synergy switches between machines by pointing off-screen, you might have some unexpected "mouseleave" events during a game! We worked around this by configuring synergy to put the guest's screen "below" the host screen (i.e., betting that we'd be looking left/right a lot more than up/down). However, when he gets more comfortable using a mouse for gaming, I suspect he'll get a dedicated one and plug it in directly, as with the controller.

edit

Maybe use Logitech's "Options" software, inside the VM, to assign functions?

Pressing scroll lock should lock the mouse to the current screen.

1 Like