Giter Club home page Giter Club logo

windows-gaming's Introduction

Windows Gaming

windows-gaming was a project that "officially" started exactly 5 years ago on the day that I'm writing this. The goal was easy and straightforward GPU passthrough for Windows guests on Linux host systems. Sadly, development stalled only one year later. With most of the basic functionality in place, there was little justification for myself or the other contributors to spend time working on features we no longer had any use for (e.g. easy setup, the project's original motivation). Can't speak for the others, but it has always served me well in my daily use.

Today's State

Over the last week, I have taken the old code and updated large parts of it to work with today's Rust ecosystem. I have written a new guest agent in Rust. Major features include better shutdown (fixing a longstanding issue where windows would blatantly ignore ACPI shutdown signals when the screen is off) and a new clipboard implementation (the old X11 code does not work properly with XWayland under Wayland compositors). Shoutout to @oberien, whose qmpgen idea is reality nowadays.

Roadmap

There is no roadmap. I made some changes which I sorely needed, and will continue to do so. Working on a tool that benefits a broader audience is outside the scope of that and requires substantial work from other contributors.

License

The original code was licensed under the Apache 2.0 license. The old master branch still exists, and you can find the license as well as the original copyright holders there.

My modifications on the main branch, including some of my unreleased libraries (zerocost-clipboard etc) remain All Rights Reserved for now. My changes are documented in detail using git commits. If you would like to use the code (and hence need a different license), just open an issue and we can discuss.

-- @main--, 2021-11-18

windows-gaming's People

Contributors

main-- avatar oberien avatar statshelix-server avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ediacarium

windows-gaming's Issues

Support non-wizard mode

Scenario A: Using windows-gaming within some scripted thing (unlikely but possible).

Scenario B: You'd like to do something the wizard doesn't directly support, e.g. slightly modifying my setup later without starting over entirely.

The original design intended for you to just edit the config, but TOML is not that popular and it's not always enough (config files and stuff).

Fix stuck keys after IO exit

Of the Ctrl+Alt+Ins sequence, you would usually still be holding Ctrl and Alt when the keyboard is disconnected, causing those keys to be stuck in the VM with most keyboard drivers.

Could hack around this by just delaying the VM exit but usability might suffer.

qapi

The monitor command line is not a stable interface, so we should switch to qapi instead.

Make sudo work

Accessing /dev/vfio/1 needs sudo permissions, which the setup does not have in user-mode.

Automatic samba setup

  • Query what the user wants in the wizard
  • Automatically mount the share from the guest agent

Drop sudo from smbd (at least in user mode)

I wanted to avoid running smbd as root at all costs which is why we're currently always invoking it through sudo:

    write!(usernet,
           ",guestfwd=tcp:10.0.2.1:445-cmd:sudo -u {} -- smbd --configfile {}",
           samba.user,
           samba_cfg.display())

Now that user mode is strongly preferred, this makes significantly less sense: This sudo invocation will only work if:

  1. You are root (system mode)
  2. It's the same user (so sudo does nothing)
  3. You manually configured sudo so the current user has passwordless sudo to the target user (who even does that)

Depending on how much we want to support or neglect system mode, 1 may be a reason to keep it. For 2 it's completely useless however. 3 affects a tiny portion of our already nonexistantly small userbase so I guess we can ignore it.

(Non)Critical Tasks

Before switching to tokio / futures / mio, we had the structure of Pollables being separated into non-critical tasks, meaning they can die without any further implication, and critical tasks, which would end the whole application if one fails or all end successfully.
With tokio, we can achieve the same by spawning non-critical tasks into a Handle and joining all criticals tasks into a single future which is executed with Core::run.

Add logging

Log stuff like the executed qemu command with log and env_logger.

Command Line Interface

We need a cli to better control the setup, startup process and implement a control client ( #1 ). I'd suggest using clap. It has support for subcommands which we can use to create the following commands:

  1. windows-gaming setup to invoke everything setup related.
  2. windows-gaming start/run to start qemu and run the driver.
  3. windows-gaming control for #1

If start/run is executed, we somehow need to check if the setup has already been run / verify the config file. What is your opinion on that?

Precisely control device tree

So far we're only doing this for USB devices (creating our own bus and assigning ports) but ideally we would control the entire device tree (PCI root ports etc).

Consider using the -readconfig option for this as passing all devices on the command line kinda sucks.

See also this sample config.

Supply the virtio drivers as cdrom instead of floppy

Apparently there might be compatibility issues with floppy.

The floppy was neat because it contained exactly what we need (the only alternative they offer is the full ISO with i386 and all drivers and it's literally 50x the size) but that doesn't matter when it doesn't actually work.

I'd suggest repackaging the vfd to an iso (like mcopy -i virtio-win_amd64.vfd -s ::/amd64 .) but that's an mtools dependency so not sure.

Kill efi framebuffer

This is necessary on some system configurations.

  • Figure out exactly where (optional)
  • Systemd unit or similar to fix things without making the machine unusable (create a new console in case efi is the only one)

Return Futures from Controller Methods

Action-performing methods should return a future which resolves as soon as the performed action is confirmed by qemu / the GA.

  • io_attach: Resolves when {return: {}} is returned by qemu. When waking up from suspend it resolves after attaching the devices. If all devices are already attached, an instataneously resolving future will be returned.
  • io_force_attach: ~
  • io_detach: Resolves when DEVICE_DELETED is returned by qemu as often as the number of devices to be disconnected.
  • action: Resolves based on the previous action taken.
  • suspend: Resolves when SUSPEND is returned by qemu.
  • shutdown: Resolves when SHUTDOWN or SUSPEND_DISK is returned by qemu.

Clipboard sharing

  • Simple mode - Basically xsel --clipboard: You can pipe into and out of it.
  • Luxury mode: Daemon that keeps clipboard contents synchronized at all times (needs to be X11/wayland-aware obviously).

Running this as a service

What we can (and probably should) ship is a systemd service unit for both user and system/root mode. It just runs windows-gaming-driver with the default config. However, this is only fully implemented once we make sure that the service never attempts to run the wizard. (isatty(3) is probably the most straightforward solution here)

The setup wizard can then even enable the unit for you.

Implementing full daemonization is very useful for non-systemd distributions (or they would have to resort to some wrapper like FreeBSD's daemon) but I guess that's more of a backlog thing.

USB Passthrough

  • udev picker to select mouse and keyboard
  • support headless setup
  • support passing through other USB devices as well
  • allow more granular selection and setup of USB devices to select which flags should be set (e.g. permanent, bind ById or ByPort, …)

Fix fast boot

  • Make the guest agent installer disable it
  • Create our own version that boots windows with the host and then puts it to sleep if the user doesn't enter for ~1min.

Add support for engine hooks

Add a system to execute sh commands on the following events:

  • pre-startup
  • post-startup
  • pre-shutdown
  • post-shutdown

Let the user specify optional strings inside the config file for these hooks to be executed inside sh -c '…'.

ga_hello one clone too much

key: hotkey.key.clone(),

As we already clone the whole hotkeys vector, use into_iter instead of iter so we don't need to clone the key again.

Networking setup

Again something very very tricky as this depends entirely on the user's networking software. Bridged networking should be fine for most users, but NAT (like VirtualBox does it) should actually work for everyone so it might be a little better. No clue how to set this up though.

New name for "windows-gaming-driver"

Currently the host side of our software containing the driver and setup is called windows-gaming-driver. As it was first planned to only contain the actual diver, we should think about a new name for both the folder and the cargo package name. Here are some of my horrible suggestions:

  • host-agent
  • host
  • windows-gaming

Setup: Add warning to change libgl drivers and xorg.conf

When switching from nvidia to intel graphics, one needs to remove all nvidia packets and replace them with mesa-libgl (and lib32-mesa-libgl if using multilib). Also /etc/X11/xorg.conf needs to be removed / adapted to not use nvidia anymore.

Use error_chain

Currently different errors are all over the place and expected everywhere, which is bad style. Instead error_chain should be used to unify different errors.

Guest-Agent HotKeyBinding error when waking up

After a suspend when waking up the driver receives a ga_hello, on which it sends all hotkeys to the GA. As the GA has already registered those bindings, it errors:

client says that it's suspending
{"timestamp": {"seconds": 1497008566, "microseconds": 825259}, "event": "SUSPEND"}
IO entry requested!
{"return": {}}
{"timestamp": {"seconds": 1497008571, "microseconds": 28995}, "event": "WAKEUP"}
client is now alive!
{"return": {}}
{"return": {}}
HotKeyBinding failed: bind error: System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully
HotKeyBinding failed: bind error: System.ComponentModel.Win32Exception (0x80004005): Hot key is already registered
HotKeyBinding failed: bind error: System.ComponentModel.Win32Exception (0x80004005): Hot key is already registered
HotKeyBinding failed: bind error: System.ComponentModel.Win32Exception (0x80004005): Hot key is already registered
HotKeyBinding failed: bind error: System.ComponentModel.Win32Exception (0x80004005): Hot key is already registered

Control client

Even if it's just shell scripts calling netcat, we need something that allows you to actually use the control socket.

Check what optional dependencies are actually installed

Right now, we just blindly assume that they exist if the user attempts to use them. Obviously, this is bad.

  • qemu GTK (sidenote: maybe support qemu's SDL GUI as well?)
  • samba
  • windows10-downloader

(Issue was renamed - original text below)


A dependency of windows-gaming-git is qemu-headless. From its description:

QEMU without GUI

Therefore running qemu with a visual setup does not work resulting in qemu-system-x86_64: -display gtk: GTK support is disabled.

Suspend guest when the host sleeps

One big issue is that Windows really doesn't like it when you just suspend the host and usually/always crashes.

For systemd users we can just use a sleep inhibitor (this mess shows how to do it).

Supporting bare pm-utils for non-systemd users is nice to have as well.

In any case, I believe this needs guest agent support.

Automatically add user to vfio group

When running the setup in user mode, it can't access /dev/vfio/X. The user manually needs to add himself to that group. This process should be automated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.