diff --git a/README.md b/README.md index e93da75..16e6bc7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Run Windows applications (including [Microsoft 365](https://www.microsoft365.com ## Underlying Mechanism WinApps works by: -1. Running Windows in a `Docker` or `libvirt + KVM/QEMU` virtual machine (deprecated). +1. Running Windows in a `Docker`, `Podman` or `libvirt` virtual machine. 2. Querying Windows for all installed applications. 3. Creating shortcuts to selected Windows applications on the host GNU/Linux OS. 4. Using [`FreeRDP`](https://www.freerdp.com/) as a backend to seamlessly render Windows applications alongside GNU/Linux applications. @@ -75,13 +75,13 @@ Contributing to the list of supported applications is encouraged through submiss ## Installation ### Step 1: Configure a Windows VM -The optimal choice for running a Windows VM as a subsystem for WinApps is `Docker`. `Docker` facilitates automated installation processes while leveraging a `KVM/QEMU` backend. Despite continuing to provide documentation for configuring a Windows VM using `virt-manager`, this method is now considered deprecated. +Both `Docker` and `Podman` are recommended backends for running the Windows virtual machine, as they facilitate an automated Windows installation process. WinApps is also compatible with `libvirt`. While this method requires considerably more manual configuration, it also provides greater virtual machine customisation options. All three methods leverage the `KVM` hypervisor, ensuring excellent virtual machine performance. Ultimately, the choice of backend depends on your specific use case. The following guides are available: - [Creating a Windows VM with `Docker` or `Podman`](docs/docker.md) -- [Creating a Windows VM with `virt-manager`](docs/KVM.md) (Deprecated) +- [Creating a Windows VM with `libvirt`](docs/libvirt.md) -If you already have a Windows VM or server you wish to use with WinApps, you will need to merge `install/RDPApps.reg` into the Windows Registry. +If you already have a Windows VM or server you wish to use with WinApps, you will need to merge `install/RDPApps.reg` into the Windows Registry manually. ### Step 2: Clone WinApps Repository and Dependencies 1. Clone the WinApps GitHub repository. @@ -137,14 +137,14 @@ RDP_PASS="MyWindowsPassword" > If you wish to use an alternative WinApps backend (other than `Docker`), uncomment and change `WAFLAVOR="docker"` to `WAFLAVOR="podman"` or `WAFLAVOR="libvirt"`. #### Configuration Options Explained -- When using a pre-existing non-KVM RDP server, you must use `RDP_IP` to specify the location of the Windows server. -- If running a Windows VM in KVM with NAT enabled, leave `RDP_IP` commented out and WinApps will auto-detect the local IP address for the VM. +- If using a pre-existing Windows RDP server on your LAN, you must use `RDP_IP` to specify the location of the Windows server. You may also wish to configure a static IP address for this server. +- If running a Windows VM using `libvirt` with NAT enabled, leave `RDP_IP` commented out and WinApps will auto-detect the local IP address for the VM. - For domain users, you can uncomment and change `RDP_DOMAIN`. -- On high-resolution (UHD) displays, you can set `RDP_SCALE` to the scale you would like to use [100|140|160|180]. -- To add flags to the FreeRDP call, such as `/audio-mode:1` to pass in a microphone, uncomment and use the `RDP_FLAGS` configuration option. +- On high-resolution (UHD) displays, you can set `RDP_SCALE` to the scale you would like to use (100, 140 or 180). +- To add additional flags to the FreeRDP call (e.g. `/prevent-session-lock 120`), uncomment and use the `RDP_FLAGS` configuration option. - For multi-monitor setups, you can try enabling `MULTIMON`. A FreeRDP bug may result in a black screen however, in which case you should revert this change. -- If you enable `DEBUG`, a log will be created on each application start in `~/.local/share/winapps/winapps.log` -- If using a system on which the FreeRDP command is not `xfreerdp`, the correct command can be specified using `FREERDP_COMMAND`. +- If you enable `DEBUG`, a log will be created on each application start in `~/.local/share/winapps/winapps.log`. +- If using a system on which the FreeRDP command is not `xfreerdp` or `xfreerdp3`, the correct command can be specified using `FREERDP_COMMAND`. ### Step 4: Run the WinApps Installer Run the WinApps installer. @@ -161,7 +161,7 @@ Adding your own applications with custom icons and MIME types to the installer i 1. Modify the name and variables to reflect the appropriate/desired values for your application. 2. Replace `icon.svg` with an SVG for your application (ensuring the icon is appropriately licensed). 3. Remove and reinstall WinApps. -4. (Optional, but strongly encouraged) Submit a pull request to add your application to WinApps as an officially supported application once you have tested your configuration files to verify functionality. +4. Submit a pull request to add your application to WinApps as an officially supported application once you have tested and verified your configuration (optional, but encouraged). ## Running Applications Manually WinApps offers a manual mode for running applications that were not configured by the WinApps installer. This is completed with the `manual` flag. Executables that are in the Windows PATH do not require full path definition. diff --git a/bin/winapps b/bin/winapps index a927654..900538c 100755 --- a/bin/winapps +++ b/bin/winapps @@ -310,6 +310,7 @@ function waRunCommand() { +dynamic-resolution \ +auto-reconnect \ +home-drive \ + /audio-mode:1 \ /wm-class:"Microsoft Windows" \ /v:"$RDP_IP" &>/dev/null & elif [ "$1" = "manual" ]; then @@ -324,6 +325,7 @@ function waRunCommand() { +auto-reconnect \ +clipboard \ +home-drive \ + /audio-mode:1 \ -wallpaper \ +dynamic-resolution \ "$MULTI_FLAG" \ @@ -358,6 +360,7 @@ function waRunCommand() { +auto-reconnect \ +clipboard \ +home-drive \ + /audio-mode:1 \ -wallpaper \ +dynamic-resolution \ "$MULTI_FLAG" \ @@ -379,6 +382,7 @@ function waRunCommand() { +auto-reconnect \ +clipboard \ +home-drive \ + /audio-mode:1 \ -wallpaper \ +dynamic-resolution \ "$MULTI_FLAG" \ diff --git a/docs/libvirt.md b/docs/libvirt.md new file mode 100644 index 0000000..cb82dfb --- /dev/null +++ b/docs/libvirt.md @@ -0,0 +1,555 @@ +# Creating a `libvirt` Windows VM +## Understanding The Virtualisation Stack +This method of configuring a Windows virtual machine for use with WinApps is significantly more involved than utilising `Docker` or `Podman`. Nevertheless, expert users may prefer this method due to its greater flexibility and wider range of customisation options. + +Before beginning, it is important to have a basic understanding of the various components involved in this particular method. + +1. `QEMU` is a FOSS emulator that performs hardware virtualisation, enabling operating systems and applications designed for one architecture (e.g., aarch64) to run on systems with differing architectures (e.g., amd64). When used in conjunction with `KVM`, it can run virtual machines at near-native speed (provided the guest virtual machine matches the host architecture) by utilising hardware extensions like Intel VT-x or AMD-V. +2. `KVM` is a Linux kernel module that enables the kernel to function as a type-1 hypervisor. `KVM` runs directly on the underlying hardware (as opposed to on top of the GNU/Linux host OS). For many workloads, the performance overhead is minimal, often in the range of 2-5%. `KVM` requires a CPU with hardware virtualisation extensions. +3. `libvirt` is an open-source API, daemon, and management tool for orchestrating platform virtualisation. It provides a consistent and stable interface for managing various virtualisation technologies, including `KVM` and `QEMU` (as well as others). `libvirt` offers a wide range of functionality to control the lifecycle of virtual machines, storage, networks, and interfaces, making it easier to interact with virtualisation capabilities programmatically or via command-line tools. +4. `virt-manager` (Virtual Machine Manager) is a GUI desktop application that provides an easy-to-use interface for creating, configuring and controlling virtual machines. `virt-manager` utilises `libvirt` as a backend. + +Together, these components form a powerful and flexible virtualization stack, with `KVM` providing low-level kernel-based virtualisation capabilities, `QEMU` providing high-level userspace-based virtualisation functionality, `libvirt` managing the resources and `virt-manager` offering an intuitive graphical management interface. + +

+ +

+ +## Prerequisites +1. Ensure your CPU supports hardware virtualisation extensions by [reading this article](https://wiki.archlinux.org/title/KVM). + +2. Install all dependencies by installing `virt-manager`. This will ensure that your package manager automatically installs all the necessary components. + ```bash + sudo apt install virt-manager # Debian/Ubuntu + sudo dnf install virt-manager # Fedora/RHEL + sudo pacman -S virt-manager # Arch Linux + sudo emerge app-emulation/virt-manager # Gentoo Linux + ``` + +3. Download a [Windows 10](https://www.microsoft.com/software-download/windows10ISO) or [Windows 11](https://www.microsoft.com/software-download/windows11) installation `.ISO` image. + +> [!IMPORTANT] +> 'Professional', 'Enterprise' or 'Server' editions of Windows are required to run RDP applications. Windows 'Home' will NOT suffice. + +4. Download [VirtIO drivers](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso) for the Windows virtual machine. + +> [!NOTE] +> VirtIO drivers enhance system performance and minimize overhead by enabling the Windows virtual machine to use specialised network and disk device drivers. These drivers are aware that they are operating inside a virtual machine, and cooperate with the hypervisor. This approach eliminates the need for the hypervisor to emulate physical hardware devices, which is a computationally expensive process. This setup allows guests to achieve high-performance network and disk operations, leveraging the benefits of paravirtualisation. +> You can read more about `VirtIO` [here](https://wiki.libvirt.org/Virtio.html). + +## Creating a Windows VM +> [!NOTE] If you are an expert user, you may wish to: +> - [Define a Windows virtual machine from an existing `.XML` file](#defining-windows-vm-from-xml) +> - [Configure Rootless `libvirt`](#configuring-rootless-libvirt) + +1. Open `virt-manager`. + +> [!NOTE] +> The name given to the application can vary between GNU/Linux distributions (e.g., 'Virtual Machines', 'Virtual Machine Manager', etc.) + +

+ +

+ +2. Navigate to `Edit`→`Preferences`. Ensure `Enable XML editing` is enabled, then click the `Close` button. + +

+ +

+ +3. Create a new virtual machine by clicking the `+` button. + +

+ Creating a new virtual machine in 'virt-manager' +

+ +4. Choose `Local install media` and click `Forward`. + +

+ +

+ +5. Select the location of your Windows 10 or 11 `.ISO` by clicking `Browse...` and `Browse Local`. Ensure `Automatically detect from the installation media / source` is enabled. + +

+ + +

+ +5. Configure the RAM and CPU cores allocated to the Windows virtual machine. We recommend `2` CPUs and `4096MB` of RAM. We will use the `VirtIO` Memory Ballooning service, which means the virtual machine can use up to `4096MB` of memory, but it will only consume this amount if necessary. + +

+ +

+ +6. Configure the virtual disk by setting its maximum size. While this size represents the largest it can grow to, the disk will only use this space as needed. + +

+ +

+ +7. Name your virtual machine `RDPWindows` to ensure it is recognized by WinApps, and select the option to `Customize configuration before installation`. + +

+ +

+ +8. After clicking `Finish`, select `Copy host CPU configuration` under 'CPUs', and then click `Apply`. + +> [!NOTE] +> Sometimes this feature gets disabled after installing Windows. Make sure to check and re-enable this option after the installation is complete. + +

+ +

+ +9. (Optional) Configure 'CPU pinning' by following [this excellent guide](https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#CPU_pinning). + +> [!NOTE] +> CPU pinning involves assigning specific physical CPU cores to a virtual machine. This can improve performance by reducing context switching and ensuring that the VM's workload consistently uses the same cores, leading to better CPU cache utilisation. + +5. Navigate to the `XML` tab, and edit the `` section to disable all timers except for the hypervclock, thereby drastically reducing idle CPU usage. Once changed, click `Apply`. + ```xml + + + + + + + + ``` + +

+ +

+ +6. Enable Hyper-V enlightenments by adding the following to the `` section. Once changed, click `Apply`. + + ```xml + + + + + + + + + + + + + + + + ``` + +> [!NOTE] +> Hyper-V enlightenments make Windows (and other Hyper-V guests) think they are running on top of a Hyper-V compatible hypervisor. This enables use of Hyper-V specific features, allowing `KVM` to implement paravirtualised interfaces for improved virtual machine performance. + +7. In the 'Memory' section, set the `Current allocation` to the minimum amount of memory you want the virtual machine to use, with a recommended value of `1024MB`. + +

+ +

+ +8. (Optional) Under `Boot Options`, enable `Start virtual machine on host boot up`. + +

+ +

+ +9. Navigate to 'SATA Disk 1' and set the `Disk bus` type to `VirtIO`. This allows disk access to be paravirtualised, improving virtual machine performance. + +

+ +

+ +10. Navigate to 'NIC' and set the `Device model` type to `virtio` to enable paravirtualised networking. + +

+ +

+ +11. Click the `Add Hardware` button in the lower left, and choose `Storage`. For `Device type`, select `CDROM device` and choose the VirtIO driver `.ISO` you downloaded earlier. Click `Finish` to add the new CD-ROM device. + +> [!IMPORTANT] +> If you skip this step, the Windows installer will fail to recognise and list the virtual hard drive you created earlier. + +

+ +

+ +12. Click `Begin Installation` in the top left. + +

+ +

+ +### Example `.XML` File +Below is an example `.XML` file that describes a Windows 11 virtual machine. + +```xml + + RDPWindows + 4d76e36e-c632-43e0-83c0-dc9f36c2823a + + + + + + 8388608 + 8388608 + 4 + + + + + + + + hvm + + + + + /usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2 + /var/lib/libvirt/qemu/nvram/RDPWindows_VARS.qcow2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + destroy + restart + destroy + + + + + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + +
+ + + + + +
+ + + + + + + + + + + +
+ + +
+ + + + + + + + + + + +
+ +