diff options
author | uvok cheetah | 2021-03-23 21:13:11 +0100 |
---|---|---|
committer | uvok cheetah | 2021-03-23 21:13:11 +0100 |
commit | 67915fc3d4943bbe3e08d9483658953c82e99e8e (patch) | |
tree | 92085109bb6d598c86fa862f671c2a4483d4c6f8 /_posts/2021-03-23-winvm.md | |
parent | d625d76319d7a66816df64954cf422b66fee76f5 (diff) |
VM post!
Diffstat (limited to '_posts/2021-03-23-winvm.md')
-rw-r--r-- | _posts/2021-03-23-winvm.md | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/_posts/2021-03-23-winvm.md b/_posts/2021-03-23-winvm.md new file mode 100644 index 0000000..031614f --- /dev/null +++ b/_posts/2021-03-23-winvm.md @@ -0,0 +1,101 @@ +--- +layout: post +title: Windows VM under Devuan with QEMU / libvirt +date: 2021-03-23 20:32 +0100 +categories: tech +--- +So, I'm running Devuan Beowulf (Debian Buster based). Recently, I was in the need of running a +tax software which only supports Windows (also has a web-based solution, which is okay, but I prefer +to keep my data local). + +I started running the software with Wine 5. A system upgrade to Wine 6 broke the software. I managed to downgrade +wine, however, the software was really running flaky and unreliably from that on. + +So I convinced myself to run a Windows VM. VirtualBox is "too easy", also, there seem to be performance issues. +Also, I wanted to learn something, so I dove into the libvirt/qemu/KVM stack. + +Boy, did I lose some hair over this. + +[With](https://linuxhint.com/libvirt_qemu_kvm_debian/) [some](https://www.florian-fritsch.com/kvm-unter-debian-10-mit-windows-10-vm/) +[help](https://dennisnotes.com/note/20180614-ubuntu-18.04-qemu-setup/) from the internet, I managed to get a Windows machine running. + +From what I figured out, I need the following packages. I don't remember what apt installed as recommended/suggested packages +anymore, though. + +- virt-manager: GUI for managing VMs +- gir1.2-spice-client-gtk-3.0: Needed for viewing the VM +- spice-vdagent: Desktop integration (copy/paste, auto-resize) +- dnsmasq: Needed for NAT networking (daemon can be disabled) +- libguestfs-tools: Command line tools for managing disk images +- qemu-kvm qemu: Actual virtualization software +- virt-viewer: Additional tool for viewing guest, has additional feature of folder sharing (?) +- libvirt-daemon libvirt-daemon-system: Virtualization daemon. Calls QEMU? (also supports LXC and others) +- libvirt-clients: Command line tool to manage VMs +- ovmf: For UEFI support + +A word about ovmf: I created the VM before installing it. Once the VM is created, it's not possible +to change the firmware from BIOS to UEFI. So better install it first. + +So + +``` +# apt install virt-manager gir1.2-spice-client-gtk-3.0 spice-vdagent dnsmasq libguestfs-tools qemu-kvm qemu virt-viewer libvirt-daemon libvirt-daemon-system libvirt-clients ovmf +``` + +Next, there was a suggestion to add a libvirt group - or libvirtd, whatever you prefer (which Devuan doesn't seem to do automatically). +Next, add your user to the group. + +``` +# groupadd --system libvirt +# gpasswd -a <username> libvirt +# gpasswd -a <username> libvirt-qemu +``` + +Next, there are some config file changes to do. + +First, edit `/etc/libvirt/libvirtd.conf`. Search for the respective settings. + +``` +unix_sock_group = "libvirt" +unix_sock_rw_perms = "0770" +``` + +Then, edit `/etc/libvirt/qemu.conf`. + +``` +user = "libvirt-qemu" +group = "libvirt-qemu" + +nvram = [ + "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd" +] +# Important! You need to remove all other default entries, even if they +# are comments. The config parser seems to have problems with comments +# inside the array. So this won't work: +# nvram = [ +# "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd" +# # other.... +# # entries... +# ] +``` + +You might also want to copy `/etc/libvirt/libvirt.conf` to `$HOME/.config/libvirt/` and adjust the +default connection URL, so virsh on command line will use the system qemu connection. + +``` +# $HOME/.config/libvirt/libvirt.conf +uri_default = "qemu:///system" +``` + +After these changes, you must restart the libvirtd daemon. Also, logout and login so you're member +of the correct groups. You're better off with restarting the system probably. + +Finally, you can create a VM with virt-manager, which I won't detail in here. Look at the other guides ;) + +However, I should mention I had severe problems with virt-manager complaining about +insufficient permissions for the disk image when creating the VM, although it was owned by the +libvirt-qemu group, which I was a member of. + +I ended up creating the VM as root, which is less than ideal. Somehow the image +ended up being owned by root:root, although, from my understanding, it should've been created +for the group libvirt-qemu. Input is welcome. |