Skip to content

Instantly share code, notes, and snippets.

@Juul
Created March 2, 2021 14:49
Show Gist options
  • Save Juul/ff04f5d5c0a2e77682965f0a531fbb88 to your computer and use it in GitHub Desktop.
Save Juul/ff04f5d5c0a2e77682965f0a531fbb88 to your computer and use it in GitHub Desktop.
notes_on_winxp_vm_with_iommu
git pull <papazoga repo>
cd qemu/
git checkout ni-mite
git add remote upstream https://github.com/qemu/qemu
git fetch origin upstream (?)
git pull upstream master # pull upstream's master branch into current repo
It will ask you to accept the default commit message about a merge
# Install dependencies
Edit /etc/apt/sources.list uncommenting each line that begins with `deb-src` in order to enable the source repos.
Then run `sudo apt update`.
Install all required build dependencies for qemu:
```
sudo apt-get build-dep qemu
```
If you want opengl support you will want to also run:
```
sudo apt install libepoxy-dev libdrm-dev libgbm-dev
```
Then configure:
```
# From within the `qemu` git repo
mkdir build
cd build/
../configure # For OpenGL support add: --enable-virglrenderer --enable-opengl
```
If you want to install qemu in a custom location you can add e.g. `--prefix /opt/qemu` to set the install path.
Check that all the stuff you want enabled is enabled. If something is missing you are probably missing a library or a library's `-dev` package. Use `apt-cache search lib<somename>` to find the package names and install the packages and their `-dev` counterparts. Then re-run the configure command.
Build qemu:
```
make
```
Before installing, ensure you have KVM and qemu installed. I like to use the graphical manage for libvirt which pulls in all the relevant packages when you install it:
```
sudo apt install virt-manager
```
Now install qemu. Note that this will likely break libvirt's ability to use your existing qemu until you fix the issue described in the next session.
```
sudo make install
```
Check if apparmor is enabled by running `sudo aa-status`.
If it's enabled then you will likely need to grant some permissions for the new qemu install.
Edit the files `/etc/apparmor.d/usr.sbin.libvirtd` and `/etc/apparmor.d/abstractions/libvirt-qemu` adding the following line on a new line before the last closing bracket at the bottom of the files:
```
/usr/local/bin/qemu* rmix,
```
Then run `sudo systemctl reload apparmor` to reload the new apparmor rules.
Now run virt-manager:
```
sudo virt-manager
```
Go to `Edit -> Preferences` and check `Enable XML editing`.
Create a new virtual machine using the wizard. When you get to the last step check the option `Customize configuration before install` before clicking Finish.
Go to the XML tab in the Overview section and ensure that emulator path is set correctly, e.g:
```
<domain>
...
<devices>
...
<emulator>/usr/local/bin/qemu-system-x86_64</emulator>
...
</devices>
...
</domain>
```
If you instead want to use the unmodified qemu installed by apt then you can just change the path to `/usr/bin/...` instead of `/usr/local/bin/...`
Click "Apply" if you made any changed, then click "Begin Installation".
# Switch to virtio
If you have the VirtIO Windows drivers installed then you can switch the virtual disk and network adapter to using VirtIO for a performance boost. Windows XP Integral Edition already includes the VirtIO drivers. Unfortunately modern versions of the VirtIO windows drivers no longer include the Windows XP version so you'll have to do some digging through [the archives](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/) to find the latest version that supported Windows XP if your copy of WinXP doesn't already have the drivers installed.
TODO how
# Samba sharing
```
sudo apt install samba
cd /etc/samba
sudo mv smb.conf smb.conf.old
mkdir ~/WinXP
```
Now create `/etc/samba/smb.conf` with the following contents
```
[global]
workgroup = WORKGROUP
security = user
map to guest = Bad User
server string = %h server (Samba, Ubuntu)
dns proxy = No
wins support = Yes
usershare allow guests = Yes
panic action = /usr/share/samba/panic-action %d
client min protocol = NT1
server min protocol = NT1
lanman auth = yes
ntlm auth = yes
[vmhost]
comment = Shared Folder for QEMU
path = /home/myuser/WinXP
public = yes
browseable = yes
writeable = yes
read only = no
guest ok = yes
force user = myuser
```
but change `myuser` to the name of your user (on the linux host).
Restart smbd and nmbd:
```
sudo systemctl restart smbd
sudo systemctl restart nmbd
```
On the windows guest go to "My Network Places" and click "Set up a home or small office network". Click through the guide selecting sane options.
On the windows guest you can now browse to `\\<ip of host>\vmhost`.
This works even when qemu is using a NAT for connectivity to the guest.
This directory is now shared with your entire network. You might want to change `smb.conf` or use firewall rules to restrict access.
# Audio
Add yourself to the libvirt group:
```
sudo usermod -a -G libvirt myuser
```
In `/etc/libvirt/libvirtd.conf` uncomment the lines:
```
unix_sock_group = "libvirt"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"
```
In `/etc/libvirt/qemu.conf` add the lines:
```
user = "juul"
group = "libvirt"
```
Stop `virt-manager` and any virtual machines currently running.
Restart libvirtd and pulseaudio:
```
sudo systemctl restart libvirtd
pulseaudio -k
```
Start `virt-manager` _without_ sudo as your own user:
```
virt-manager
```
Ensure that the sound device is configured as model "AC97".
Sound should now work through pulseaudio.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment