Xen 4.3, Windows 8 with VGA Passthrough on Arch Linux

As I write today’s post I am feeling very pleased with the setup as it stands. The aim of this post is to detail the steps required to setup Windows 8 as a VM for Xen 4.3 on Arch Linux, with working GPU on reboot.

To recap quickly my summer project, which I embarked upon some 4 weeks ago, has been all about consolidation and making my ’24/7 server’ at home earn its keep somewhat. What I have now is the following:

Dom0 (Host) – Arch Linux
  • Arch Linux with Xen Hypervisor 4.3.0-4 (ATI patched).
  • XBMC via the motherboard HDMI out powered by the i5 3470′s HD4000 internal GPU.
  • XBMC MySQL database host.
DomU1 – unRAID 5.0
  • 23TB of protected storage (JBOD + parity drive) which only spins the drive it’s currently reading from – this is very important for me when I have 12 drives!
  • PCI Passthrough of 2x SATA controllers – 1x Supermicro SAS-AOC-SASLP-MV8 (8 ports), 1x motherboard SATA controller (6 ports)
  • unRAID Server is a Network Attached Storage server operating system that boots from a USB Flash device and specifically designed for digital media storage.
DomU2 – Ubuntu 13.04
  • SABnzbd, Sickbeard, Couchpotato, Subsonic, OwnCloud, Dropbox, Google Drive, Headphones, Plex Media Server, BTSync and Air Video Server.
  • This VM automates all the media collection from the Internet and makes sure, via BTSync, that my photo collection is exchanged with a friend for backup purposes.
DomU3 – Windows 8
  • My desktop computer.
  • My gaming rig.
  • VGA passthrough of a Sapphire HD7870 Ghz edition.
  • HDMI output from GPU split 2 ways – 1 to Lounge TV, 1 to desktop monitor upstairs via 30m Cat6 HDMI extenders.
  • USB passthrough connected to wireless Xbox 360 controller for Lounge gaming.
  • 30m USB over Cat5e extenders for keyboard and mouse to a powered USB hub upstairs on my desk.
DomU4 – Dev Machine (OS changes frequently)
  • Web development etc.
  • App development etc.

How to setup Windows 8 with VGA passthrough (to survive a reboot of VM)

Setting up Windows as a VM on Xen is a piece of cake really. VGA passthrough with my ATI card was just as easy as passing through a disk controller to unRAID etc. Where I’ve spent the last week going around in circles is regarding host lockups / VM black screens on reboot. I’m pleased to say I’ve fixed this and have included all the necessary info below.

The version of Xen I used is 4.3.0-4 and can be found here (remember to compile it with ATI patch enabled by editing PKGBUILD before running makepkg -s). This package is maintained by Kantras on AUR, make sure to go thank him for it!

** Updated 22/12/2013 **
Here is a freshly compiled, working package of Xen - xen-4.3.1-2-x86_64.pkg.tar.xz
Change directory to wherever you like and install the package like this:

 

Install Windows 8

You’ll need a Windows 8 .iso to do this. Here is my xl config file.

It’s worth noting that you’ll have to create an LVM structure for your Windows install, mine is split in two but it’s up to you. If you’re unsure about what to do here I recommend this page on the Arch Wiki.

https://wiki.archlinux.org/index.php/LVM

Furthermore, you probably want to install Windows with no PCI passthrough and do it over VNC.

Post install tasks

Once Windows is installed it’s time to passthrough your USB ports and GPU (video and audio remember, hence the 3x devices on my list). I have done a ton of other posts on PCI passthrough so will not cover that here.

You must make sure that you use traiditional qemu as upstream is broken and it will not currently work! It’s in my config so if you just copied and pasted, you’re good to go!

Now boot up Windows using xl create as normal. It’s working right? Right?! Awesome. Well let’s fix reboots now…

 

Getting rebooting to work

So, rebooting works just fine if you manually eject the card before rebooting the VM but who wants to do that EVERY time?! No-one. So here’s how you automate it.

Go to nirsoft and download DevManView.exe (64 bit is required if you’re running 64 bit Windows), also download my reboot scripts below.

http://www.nirsoft.net/utils/device_manager_view.html

Reboot Scripts and Device Instance IDs

rebootscripts

Place the DevManView.exe file anywhere you like in your system, I put mine the root of “C:/Program Files”. If you place it anywhere else you should update the paths in the logon.cmd and logoff.cmd appropriately.

You’ll need to use DevManView to grab your Device Instance ID (copy and paste works great when you select the graphics card row) and replace the ID in my scripts. Replace between the speech marks only, leaving the speech marks at either end of the Device ID, which will look something like this:

*note this ID will be different for your system and is case sensitive. Just copy and paste!

If you’d like to test your script is working before rebooting, just double click the logon script. If your display goes black and comes back after a few seconds, it worked. The logon script disables then immediately reenables the card, so it’s a good test.

 

Use gpedit.msc to automate the process at startup and shutdown

Next you need to tell these scripts to run automatically at startup and shutdown using “gpedit.msc“. Add the logon script to startup and logoff to shutdown.

Screen Shot 2013-12-22 at 10.57.55

That’s it. Simple, automated and solid.

*** Before doing anything complex like Windows Update it is advised to disable the adapter altogether and perform the maintenance with VNC only. Once updates etc are done, you’re OK again.

23 Comments

  1. Just so you know, I took over the maintainership of the xen AUR package, so all the updates are now included in it.

    David (aka Kantras)

    • alexktz

      November 21, 2013 at 9:13 am

      great news, and it compiles properly these days!

      the updates still require ‘qemu-traditional’ however.

  2. Love the reboot scripts! Thanks for providing them. They fixed the last annoying thing I had going with my Windows 8 VM.

  3. Thanks for the reboot scripts. I’ve hesitated to make the jump to Xen 4.3 exactly because of the reboot issues. I’ve written an elaborate VGA passthrough how-to at the Linux Mint forum, but for the older 13 and 14 releases. Linux Mint 15 or 16 with Xen 4.3 would greatly reduce the complexity and length of that how-to, but they are having the guest reboot issue. Hope to be able to give Xen 4.3 a try soon, as well as your scripts.

  4. Hello, I’m having trouble with the reboot scripts on a Win7 machine. I could just be derping, but I am unable to get my VM to run smoothly after reboots still and experience serve lag/delay . I’ve adjusted your scripts with the IDs of my own graphics card, but I’m not clear as to where you placed DevManView. Could you please elaborate on how the reboot scripts are done?
    Thanks.

    • Not sure which one fixed it, but I had downloaded the 64bit version, and also had not put the script parameters into gpedit.msc.

    • IronicBadger

      January 5, 2014 at 1:18 am

      i’ve updated the post with a bit more info on gpedit.msc

      as Zenzou says you must download either the 32 / 64 bit version according the version of Windows you’re running.

  5. Thanks for sharing this hint about “ejecting” the devices via script. I already got stuck on the reboot problem some month before and – frustrated – stepped back to Win7 when using GFX passthru to avoid this reboot hassle. Now I can confirm that my setup (Biostar TA890FXE with 890FX and HD6670) work fine on Win 8.1×64. BUT to run this stable without glitches on video output I have to using a self compiled Xen 4.4-unstable (lastest git tree) as of 25.12 on ArchLinux ;-)

    • IronicBadger

      January 5, 2014 at 1:19 am

      that’s really good to know! i’ve not tried 4.4 yet, and probably won’t until it goes to either RC or higher. i absolutely zero luck with windows 7, i only got anywhere with windows 8 / 8.1.

      i’m really happy with 4.3 and have around 19 days uptime atm, so i consider it stable enough. :)

  6. Good writeup.
    Do you know if these reboot eject scripts work with kvm/qemu vga passthrough aswell?

    • IronicBadger

      January 21, 2014 at 11:42 am

      I have not tried that yet, due to various hardware issues on my end! I’d be grateful if you would give them a go and report back.

      • I will try them as soon as i can, and let you know how it goes.

      • Tried them with kv/qemu in arch and works great! only problem is if windows 8 domU crashed then it cant eject the vga and gets a reboot failure.. Anyway great job helped me alot! :)

  7. Wonderful xen safe(!) vga passthrough workflow! Thanks you so much :D. Maybe someguys also want to passthru usb keyboard and mouse, DevManView’s disable_enable' method will do the work properly.

    And last, I'm curious to know how the writer actually manage the power supporting vga on xen workstation. XL toolstack provides trigger’ subcommand, as an example xl trigger sleep'. But when sleep’ command is passed to domU(Win HVM), they’re NEVER able to wake-up with `s3resume’. If triggering ATI ZCP(ZeroCore Power) is possible, That will be awesome!

  8. I am also interested in the last question. If the Zerocore AMD is supported if you do VGA passthrough
    (if the fan of the videocard (7870) stops when the windows 8 machine is shutdown)

  9. Hello, I am using Xen 4.4 and I can’t get vga PCI passthrough to work ): I think windows sees it and tries to switch to it but nothing shows up on my monitors. lspci -k reports my vga and the accompanying sound controller are controlled by pciback and xl list-assignable-devices lists them both. And windows appears to recognize and use the device. But no output.

    • IronicBadger

      April 14, 2014 at 1:50 pm

      Need more information than this dude. I haven’t experimented with 4.4 yet, but I can’t imagine that will be the cause.

      Which OS ? Presumably Arch? What hardware etc etc etc…

  10. Thanks to this post, I was able to restart my guest without restarting the host.
    I still have a very tiny missing bit, but I feel I’m almost here!

    I have Xen 4.4 (Arch AUR build) with ati-passthrough.patch, a Radeon HD 6770, and a working Windows 7 guest.
    If I eject the card before rebooting, I can restart and get VNC display. I can then re-enable the card from VNC, restart, and get the GPU display (without ati-passthrough.patch, this isn’t working, the second boot will show a mouse on a black screen on the GPU display, and no VNC display on the guest, so the card is unusable until host reboot.)

    When using the scripts, it works well, except that the startup script will only re-enable the card, but not let Windows 7 switch to the GPU display. Afterwards, the shutdown script will disable the card again, and so VNC display again.
    If I restart with the shutdown script, let the startup script re-enable the card, _remove the shutdown script_ and reboot again, then I get the guest back on GPU!
    So that’s not bad at all, but I guess Windows 7 is running the startup script a tiny bit too late. Any tips on where I could look for more information or clues?

    • IronicBadger

      April 14, 2014 at 1:47 pm

      I don’t actually use the ATI passthrough patch anymore. I think you’re problem is you’re using Windows 7. I had massive problems, similar to what you are describing, getting the passthrough to work reliably on reboot. Sadly the only solution was to use Windows 8.

      • +1 on Windows 8 rendering a far better experience on ATI passthrough. Tried both 7 and 8 and found that although 7 sometime worked, 8 seems to be far more reliable and functional in regards to ejecting the GPU.

        Cheers

Leave a Reply

Your email address will not be published.

*


seven + 9 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

© 2014 ktz.me

Theme by Anders NorenUp ↑