Running Windows 10 in a UEFI enabled QEMU environment with KVM.
Download qemu
$ sudo pacman -S qemu # For Arch Linux
Download windows and setup
Download Win10 «manually» — https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewadvanced
$ wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
https://www.kraxel.org/repos/jenkins/edk2/edk2.git-ovmf-x64-0-20160509.b1788.ga93786a.noarch.rpm
$ qemu-img create win10.hd.img.raw 40G
Formatting 'win10.hd.img.raw', fmt=raw size=42949672960
Installing
$ qemu-system-x86_64 -bios OVMF.fd -enable-kvm -cpu host -smp 4 -m 2048 \ -cdrom Windows10_InsiderPreview_Client_x64_en-us_14332.iso \ -net nic,model=virtio -net user \ -drive file=win10.hd.img.raw,format=raw,if=virtio -vga qxl \ -drive file=virtio-win.iso,index=1,media=cdrom
Installing (no KVM, UI over VNC)
$ qemu-system-x86_64 -bios OVMF.fd -smp 4 -m 2048 -vnc 0.0.0.0:1 \ -cdrom Windows10_InsiderPreview_Client_x64_en-us_14332.iso \ -net nic,model=virtio -net user \ -drive file=win10.hd.img.raw,format=raw,if=virtio -vga qxl \ -drive file=virtio-win.iso,index=1,media=cdrom
$ qemu-system-x86_64 -bios /usr/share/ovmf/ovmf_x64.bin \
-enable-kvm -cpu host -smp 4 -m 4096 \
-net nic,model=virtio -net user \
-drive file=~/vm/win10.hd.img.raw,format=raw,if=virtio \
-vga qxl -usbdevice tablet -rtc base=utc
It is actually quite easy to boot Windows virtualized using KVM. But to properly use the UEFI bootloader, suitable QEMU arguments are required. Here is a lightly commented QEMU command I use to boot virtual Windows 10 I have on a separate partition.
sudo qemu-system-x86_64 --enable-kvm -cpu host -m 2048 \
-smp 4,sockets=1,cores=2,threads=2 -mem-path /dev/hugepages \
-vga qxl -display none -serial mon:stdio \
-rtc clock=host,base=localtime \
-device qemu-xhci,id=xhci \
-device virtio-tablet,wheel-axis=true \
-soundhw ac97 \
-netdev user,id=vmnic,smb=/ \
-device virtio-net,netdev=vmnic \
-drive file=/usr/share/ovmf/x64/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
-drive file=$HOME/.config/qemu-windows.nvram,if=pflash,format=raw,unit=1 \
-drive file=/dev/sdb,index=0,media=disk,driver=raw \
-cdrom /opt/UefiShell.iso
For now I use sudo, because QEMU needs to access raw partitions from /dev/sdb. The other, maybe better way would be assigning a group to /dev/sdb, setting up proper group permissions and adding me to that group.
-m 2048 -smp 4,sockets=1,cores=2,threads=2 says to allocate 2GB of RAM for the guest and use CPU threads (1 CPU socket, with 2 cores, each core having 2 threads).
-mem-path /dev/hugepages is better described in Arch wiki.
-display sdl -vga qxl Use SDL for rendering and window management in the host and QXL GPU device in the guest (there are QXL drivers for Windows).
-device qemu-xhci,id=xhci Enable USB3 support by emulating an XHCI controller
-device virtio-tablet,wheel-axis=true Emulate a tablet pointing device with mouse scroll support
-soundhw ac97 Emulate ac97. You can then use Realtek driver. It worked better in QEMU than Intel hda for me.
netdev stuff Is for setting up network interface
-drive file=/usr/share/ovmf/x64/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on This is a very important part. It loads OVMF UEFI firmware read-only as the first Flash device. This firmware implements a UEFI bios and allows running UEFI Shell or booting .efi bootloader for Windows (bootmgfw.efi). This OVMF can be downloaded directly from the OVMF project repo or if you are using Arch Linux, just install ovmf package.
-drive file=$HOME/.config/qemu-windows.nvram,if=pflash,format=raw,unit=1 this loads a read-write NVRam flash image as the second virtual flash chip. OVMF firmware uses this to store UEFI variables, .efi boot order, etc. The default image can be copied from the OVMF setup (at /usr/share/ovmf/x64/OVMF_VARS.fd in ovmf Arch linux package). It must be a writable copy.
-drive file=/dev/sdb,index=0,media=disk,driver=raw Attaches my raw sdb block device to the virtual machine. That is used as a HDD for the guest, it has Windows pre-installed there together with EFI partition.
-cdrom /opt/UefiShell.iso UEFI shell iso as a CDROM. Before OVMF nvram is properly configured to boot Windows by default, this will result in booting into the EFI shell which allows to run .efi executables manually. Windows can be run by just navigating into the EFI partition and running the Windows efi loader – blkX:\EFI\Microsoft\Boot\bootmgfw.efi.
I don’t know how to force Windows to write UEFI boot order. There doesn’t seem to be a tool like efibootmgr on Windows. It would set the UEFI boot order up randomly during Windows Updates (mostly when you don’t want it to touch your EFI setup). If TianoCore fails to find your Windows installation, you can try pressing ESC during TianoCore EFI boot to get to boot menu. Or you can always boot Linux using the -cdrom command and use efibootmgr to force the OVMF to boot the Windows loader entry for this virtual machine by default. Usage of the efibootmgr command is out of scope of this article and can be found in many online resources elsewhere.
You can even use SPICE to connect to the booted VM remotely. To do that, add these options:
-spice port=5900,addr=127.0.0.1,disable-ticketing -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent \
-chardev spicevmc,name=usbredir,id=usbredirchardev1 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1 \
-chardev spicevmc,name=usbredir,id=usbredirchardev2 -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2 \
-chardev spicevmc,name=usbredir,id=usbredirchardev3 -device usb-redir,chardev=usbredirchardev3,id=usbredirdev3 \
It says to listen on port 5900 (localhost-only), adds SPICE channel between host and guest (to allow remote copy-paste) and 4 remotelly-attachable USB devices.
You can then use SPICE client like remote-viewer to connect to the VM. If the original local VM graphical output is not needed, add -display none
parameter.
Have fun with virtualized Windows and remember – Windows is good for games only and for stuff like government PDFs which use proprietary Adobe XFA forms and are therefore supported in official Adobe Reader which has the best support in this platform only. Windows definitely shouldn’t be used on servers or anything serious! By default it is very limited (maximum number or RAM, maximum number of CPU cores, maximum number of listening socket connections, etc) until you pay huge amounts of money to Microsoft. Wise people use Linux and lazy people who don’t care about privacy or freedom use Mac OS X.
This article describes the setup of a Windows guest using QEMU.
Configuration
Host
To create a disk image for the virtual machine, run:
user $
qemu-img create -f qcow2 WindowsVM.img 25G
Tip
Consider allocating more space if you are aiming for newer Windows versions as e.g. Win 10 Pro 22H2 after fresh install already occupies 20G. You may extend disk images easily by qemu-img resize
later on, but as Windows rescue partition is located at the end of the disk this needs further steps.
Download a Windows driver image from this location.
Since QEMU requires a lot of options, it would be a good idea to put them into a shell script, e.g.:
FILE WindowsVM.sh
#!/bin/sh exec qemu-system-x86_64 -enable-kvm \ -cpu host \ -drive file=WindowsVM.img,if=virtio \ -net nic -net user,hostname=windowsvm \ -m 1G \ -monitor stdio \ -name "Windows" \ "$@"
Change the path to the disk image WindowsVM.img in the script. Additional options can be used when calling the script. To boot the disk image, run:
user $
./WindowsVM.sh -boot d -drive file=WINDOWS.iso,media=cdrom -drive file=DRIVER.iso,media=cdrom
Install the Windows guest. See the guest section for optimum support. After the installation start the script without the additional options.
Note
When upgrading to QEMU 1.3 the -enable-kvm
must be added to keep the guest responsive. Also change -net nic
to -net nic,model=rtl8139
to have a network interface in the guest.
Note
When upgrading to QEMU 1.5.3, add -display sdl,frame=off,window_close=off"
to keep a full screen session full screen. Without this option there may be a (new) menu bar at the top of the screen, pushing the Windows bottom menu off screen.
Note
When upgrading to QEMU 2.0.0 replace qemu-kvm
with qemu-system-<CPUTYPE>
(e.g. qemu-system-x86_64) (-enable-kvm
switch may need to be added); the qemu-kvm wrapper has been removed — see bug #506566
Note
German (and perhaps other) localized Windows versions likely are not able to setup any virtual network card properly on QEMU >=6.0 due to a problem in Windows — see QEMU issue #774
Guest
- During installation at the partition step Windows doesn’t detect the VirtIO hard drive. Windows will require the viostor driver from the driver image listed above.
- After installation the VirtIO Ethernet adapter will appear without a driver. Windows will require the netkvm driver from the driver image listed above.
- For 32-bit Windows 7 a sound driver for the Intel 82801AA AC97 exists.
- For 64-bit Windows 7 Intel HDA is available as an option (QEMU option:
-soundhw hda
) - Windows 10 guest audio emulation is tricky for ALSA users. Pass these options to QEMU:
-audiodev alsa,id=snd0,out.try-poll=off -device ich9-intel-hda -device hda-output,audiodev=snd0
- This assumes use of the default ALSA device for playback.
- we cannot use AC97 for Windows 10 because there is no driver for it.
out.try-poll=off
is an odd option, but without it I got nothing but clicks and pops during playback.- there may be more options required for line-in and line-out (
-device hda-duplex
) or microphone and line-out (-device hda-micro
). - For PulseAudio, see ArchWiki
- USB 2.0 pass through can be configured from host to guest with variations of:
-usb -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,vendorid=1452
- For Windows 8.1 USB tablet is available only with USB 2.0 pass through (QEMU option:
-device usb-ehci,id=ehci -device usb-tablet,bus=ehci.0
- The USB tablet device helps the Windows guest to accurately track mouse movements. Without it mouse movements will be jerky.
- Another device that can be presented to the Windows guest is the random number generator. Add QEMU option:
-device virtio-rng-pci
. Now install the viorng driver from the driver image. - For Windows 10, to boot using UEFI the sys-firmware/edk2-ovmf is required on the host, then add QEMU option:
-bios /usr/share/edk2-ovmf/OVMF_CODE.fd.
to the qemu call. This option is essential for running Hyper-V guest images.
SPICE
QEMU with SPICE support enables (among other things) the more powerful QXL display device and makes clipboard sharing possible (copy/paste between clients and the virtual machine).
To use SPICE with QEMU enable the following USE flag in package.use:
FILE /etc/portage/package.use
Setting USE variable
Build QEMU:
root #
emerge app-emulation/qemu
To connect spice server, a client like net-misc/spice-gtk is required.
Guest
On Windows guests, install Windows guest tools.
On Windows 8.1 guest, to set screen resolution more than 1024×768, install drivers from https://fedoraproject.org/wiki/Windows_Virtio_Drivers#Direct_download and QXL WDDM DOD driver. If trying to install Windows guest tool, QXL WDDM DOD driver won’t work well because of Windows SPICE agent .
To try the new qlx-dod driver linked above, in order to use the driver, update’ the basic windows display adapter driver and point it to the unzipped folder for the new driver. This can be found by: Right click the Start button -> Device Manager. Expand ‘Display adapters’ and right click on the sub entry and hit update driver.
Initialization script
To run QEMU from a script (the spicy viewer requires net-misc/spice-gtk):
FILE WindowsVM.sh
#!/bin/sh SPICE_PORT=5924 qemu-system-x86_64 -enable-kvm -daemonize \ -cpu host \ -drive file=WindowsVM.img,if=virtio \ -net nic -net user,hostname=windowsvm \ -m 1G \ -vga qxl \ -spice port=${SPICE_PORT},disable-ticketing=on \ -usbdevice tablet \ -device virtio-serial \ -chardev spicevmc,id=vdagent,name=vdagent \ -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \ "$@" exec spicy --title Windows 127.0.0.1 -p ${SPICE_PORT}
Or remote-viewer (app-emulation/virt-viewer):
FILE WindowsVM.sh
#!/bin/sh SPICE_PORT=5924 qemu-system-x86_64 -enable-kvm -daemonize \ -cpu host \ -drive file=WindowsVM.img,if=virtio \ -net nic -net user,hostname=windowsvm \ -m 1G \ -vga qxl \ -spice port=${SPICE_PORT},disable-ticketing=on \ -usbdevice tablet \ -device virtio-serial \ -chardev spicevmc,id=vdagent,name=vdagent \ -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \ "$@" exec remote-viewer --title Windows spice://127.0.0.1:${SPICE_PORT}
1. Download and install QEMU 4.2.0 for Windows.
32-bit version
64-bit version
2. Download Linaro UEFI 15.10 32-bit and copy this file to the QEMU installation folder.
3. Download HxD Hex Editor.
4. Patch trustzone, for this open qemu-system-arm.exe
in the HxD Hex Editor and replace the following hex string: 4531C931D24C8D05BE515C004889F1E87AD82E00
with: 9090909090909090909090909090909090909090
.
5. Download and install GTK2-Runtime 2.14.4-2008-10-22.
6. Download ARM32 build of viostor driver.
7. Add viostor driver to the install.wim
. Extract viostor_arm32.7z
archive, then run Command Prompt as administrator and then run the following commands:
dism /mount-image /imagefile:\WIM\file\path /mountdir:\WIM\mount\path /index:1 dism /image:\WIM\mount\path /add-driver /driver:\path\to\viostor.inf dism /unmount-image /mountdir:\WIM\mount\path /commit
8. Create needed VHD files by using the diskpart
utility. For this, run the following commands. (Note that these files will be created in a directory on your C drive called «15035», and they will be mounted under the drive letters P and W).
create vdisk file="C:\15035\hdd.vhd" maximum=40000 type=expandable select vdisk file="C:\15035\hdd.vhd" attach vdisk convert gpt create partition efi size=100 format quick fs=fat32 assign letter=p create partition primary format quick assign letter=w exit
9. Apply the install.wim
to VHD, and then create boot files:
dism /apply-image /imagefile:<WIM file path> /index:1 /applydir:W:\ bcdboot W:\Windows /s P: /f UEFI
After that, eject P or W. Once ejected, P remains and disappears after a reboot.
10. Run QEMU by going to your QEMU installation folder, saving the following text to a batch file, and then running it to start the emulator:
qemu-system-arm -M virt,highmem=false -cpu cortex-a15 -smp 2 -accel tcg,thread=multi -m 2048 -bios QEMU_EFI.fd -drive if=virtio,file=C:\15035\hdd.vhd,format=vpc -device VGA -device ich9-usb-ehci1 -device usb-kbd -device usb-tablet -rtc base=2017-02-09,clock=vm
11. If you want to change screen resolution press F2 to enter EFI settings, enter Device Manager
and then OVMF Platform Configuration
. Change the resolution to the desired one then commit the changes and exit. Choose Machine
in the QEMU menu and then reset the emulator.
12. Select EFI Internal Shell
. Enter a drive letter (such as FS0:
) in the shell and run the following command:
efi\boot\bootarm.efi
(The above commands allow you to start the OOBE).
During the first launch, error 0xc00000428
is possible. You must disable driver signature enforcement. To do this, press the F8 key and then press the 4 key.
13. Set testsigning on.
To do this press Shift + F10, then the command line will appear. Enter the following command:
bcdedit -set testsigning on
After the completion of the OOBE, you can boot into the system.
14. If OOBE fails.
If OOBE fails, then you must follow the steps below to bypass it and log in:
a. On the first screen of OOBE, press Shift + F10, a command prompt will appear.
b. Enter the regedit
command, then you will open the Registry Editor.
c. Go to the following path: \HKEY_LOCAL_MACHINE\SYSTEM\Setup
.
d. Change the value of the CmdLine
parameter from oobe/windeploy.exe
to cmd.exe
.
e. Change the value of the OOBEInProgress
parameter from 1 to 0.
f. Change the value of the SetupPhase
parameter from 4 to 1.
g. Close Registry Editor and at the command prompt type the following command: shutdown /r /t 00
to reboot.
h. Now, if you did everything right, when you boot, you should automatically have a command line. You need to manually create an administrator account and delete the defaultuser0 account. To do this, run the following commands:
net user Administrator /active:yes net user defaultuser0 /delete
i. After that, launch the Task Manager. To do this, in the command line, enter the taskmgr
command. Then end the winlogon.exe
process.
#1 2022-06-28 00:37:02
- robg
- Member
- Registered: 2015-03-05
- Posts: 219
Windows 10 on QEMU
Dear Arch Community,
I am running into problems trying to install Windows 10 inside a QEMU VM. Before giving a detailed account of said problems, here the relevant system information:
-
HP Elite Book 840 G8
-
11th Gen Intel i5
$ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Vendor ID: GenuineIntel Model name: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz CPU family: 6 Model: 140 Thread(s) per core: 2 Core(s) per socket: 4 Socket(s): 1 Stepping: 1 CPU(s) scaling MHz: 19% CPU max MHz: 4200.0000 CPU min MHz: 400.0000 BogoMIPS: 4840.00 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 invpcid_single cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear ibt flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 192 KiB (4 instances) L1i cache: 128 KiB (4 instances) L2 cache: 5 MiB (4 instances) L3 cache: 8 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-7 Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected
-
KVM modules loaded
$ lsmod | grep kvm kvm_intel 389120 4 kvm 1118208 1 kvm_intel irqbypass 16384 1 kvm
-
Virtualization enabled in BIOS
-
Up-to-date generic Arch install with default kernel ($ uname -a Linux hp 5.18.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 25 Jun 2022 20:22:01 +0000 x86_64 GNU/Linux)
I have installed the qemu-desktop package, and created a raw disk image via `qemu-img create -f raw win.raw 40G`. I now seek to boot the official Windows 10 ISO and install the operating system inside a QEMU VM. This leaves me with the following problems:
Starting as simple as possible, running only `qemu-system-x86_64 -cdrom win10.iso -boot order=d -drive file=win.raw,format=raw -m 4G`, appears to boot the system until this blue screen hits. If I add `-enable-kvm` to the QEMU parameters, the boot process hangs indefinitely at the Windows logo.
For comparison, I have observed the exact same behavior (hanging/failing depending on whether KVM is enabled) with a Windows 7 ISO. It is also the same on Virtualbox. The ArchLinux ISO boots flawlessly in QEMU, irrespective of whether KVM is enabled.
My understanding is that the simple boot configuration in the preceding paragraph should suffice to boot Windows 10. If I am wrong, what (least) other parameters should I include? Or what else might cause this behavior?
Many thanks in advance for your help!
#2 2022-06-28 04:52:13
- Maniaxx
- Member
- Registered: 2014-05-14
- Posts: 758
Re: Windows 10 on QEMU
Try ‘virt-manager’ as a guided gui app to set up Windows with predefined settings. Once it’s running you can extract the qemu command line from the logfile.
#3 2022-06-28 14:06:57
- qinohe
- Member
- From: Netherlands
- Registered: 2012-06-20
- Posts: 1,498
Re: Windows 10 on QEMU
There should be no reason for the VM to stale using KVM.
Have tried it here and it starts just fine.
I’m not a Win user and don’t have a key for it so I don’t get any further then the moment I need to input the key…
Try this line with your own paths of course
Haven’t done any tweaking .. that’s something you need to do yourself;)
qemu-system-x86_64 -boot order=d,menu=on,reboot-timeout=5000 -m size=4096,slots=0,maxmem=4294967296 -k en-us -name Win10_21H2_English_x64.iso,process=Win10_21H2_English_x64.iso_0 -device virtio-scsi-pci,id=scsi0 -device virtio-vga-gl -display sdl,gl=on -audiodev pa,id=snd0 -device ich9-intel-hda -device hda-output,audiodev=snd0 -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0,hostfwd=tcp::60037-:22 -machine type=q35,accel=kvm,usb=on,pcspk-audiodev=snd0 -global ICH9-LPC.disable_s3=1 -enable-kvm -device scsi-cd,bus=scsi0.0,drive=cdrom0 -drive id=cdrom0,if=none,format=raw,media=cdrom,read-only=on,file=Win10_21H2_English_x64.iso -cpu host,hv-relaxed,hv-vapic,hv-spinlocks=0x1fff,hv-time -device qemu-xhci -device usb-tablet -drive file=virtio-win-0.1.217.iso,media=cdrom -hdd win10 -serial stdio -no-reboot
You can have a look at the next thread for explanations and clues and there are links you can follow; https://bbs.archlinux.org/viewtopic.php?id=274354
Also download the latest virtio-drivers you need from here: https://fedorapeople.org/groups/virt/vi … -downloads
#4 2022-06-29 11:34:34
- sekret
- Member
- Registered: 2013-07-22
- Posts: 291
Re: Windows 10 on QEMU
I’d recommend to give Quickemu a try.
I have a running Windows 11 installation and it runs very smoothly.
#5 2022-06-29 15:35:57
- qinohe
- Member
- From: Netherlands
- Registered: 2012-06-20
- Posts: 1,498
Re: Windows 10 on QEMU
Let me start by saying I don’t want to start a dispute about what anyone should use;)
But using ‘quickemu’ why? what’s the fun in that… none in my opinion.
BTW. The script is using the adguard domain to download image files for Win while you can get them directly from MS!
Really, I wont say don’t use ‘quickemu’ it it’s just .. well …
Fiddling with and tweaking your lines should be something Archers like to do, mostly I think.
How easy is it to just write a nice script to do the job for you, at least you would have learned something from it.
I went ahead and did just that, don’t just use it but to give you an impression of what you could do with a simple shell script.
Oh and this is mainly gathered from known sources, not much of my own, so you know!
#!/bin/sh
# change to where the files actually are
w10="$HOME"/archiso/iso-and-img/hd-img/win10
winiso="$HOME"/archiso/iso-and-img/iso-img/Win10_21H2_English_x64.iso
virtio="$HOME"/archiso/iso-and-img/iso-img/virtio-win-0.1.217.iso
dummy="$HOME"/archiso/iso-and-img/qcow-img/dummy
# install windows 10 to a virtual disk file
inst_win() {
qemu-system-x86_64 -enable-kvm \
-machine type=q35 \
-cpu host,hv-relaxed,hv-vapic,hv-spinlocks=0x1fff,hv-time \
-device qemu-xhci -device usb-tablet \
-drive file="${w10}",index=0,media=disk,if=virtio \
-drive file="${winiso}",index=2,media=cdrom \
-drive file="${virtio}",index=3,media=cdrom \
-boot menu=on \
-net nic -net user,hostname=windows1064 \
-m 4G \
-monitor stdio \
-name "Windows 10 64 bits"
}
# install virtio driver in safe mode
virtio_win() {
qemu-system-x86_64 -enable-kvm \
-machine type=q35 \
-cpu host,hv-relaxed,hv-vapic,hv-spinlocks=0x1fff,hv-time \
-m 4G \
-drive file="${w10}",if=ide \
-drive file="${dummy}",if=virtio \
-cdrom "${virtio}"
}
# use windows 10 installed VM
use_win() {
qemu-system-x86_64 -enable-kvm \
-machine type=q35 \
-cpu host,hv-relaxed,hv-vapic,hv-spinlocks=0x1fff,hv-time \
-device qemu-xhci -device usb-tablet \
-drive file="${w10}",index=0,media=disk,if=virtio \
-boot menu=on \
-net nic -net user,hostname=windows1064 \
-m 4G \
-monitor stdio \
-name "Windows 10 64 bits"
}
pass() {
[ "$1" = 'i' ] && inst_win
[ "$1" = 'v' ] && virtio_inst
[ "$1" = 'u' ] && use_win
}
pass "$@"
edit: small change & some;)
Last edited by qinohe (2022-06-29 17:42:56)
#6 2022-06-29 20:22:48
- robg
- Member
- Registered: 2015-03-05
- Posts: 219
Re: Windows 10 on QEMU
Thanks so much for the many kind answers!
Clearly, the fact that Arch boots and Windows does not, indicates that the problem is because of the latter and not (primarily) because of QEMU.
As much as I would have liked for this to remain a QEMU-only journey (sharing the sentiment of qinohe), the plethora of available command line options means that I have for now taken up Maniaxx’s suggestion, and installed virt-manager. Of course, a naive install with virt-manager’s default settings failed as described in my first post. However, I have found this tutorial which uses TianoCore UEFI instead of the default SeaBIOS, and now Windows 10 boots and installs properly.
I will later look into extracting the corresponding qemu-system-x86_64 call (that will certainly include other overlooked parameters besides the bios setting).
#7 2022-06-29 21:54:24
- qinohe
- Member
- From: Netherlands
- Registered: 2012-06-20
- Posts: 1,498
Re: Windows 10 on QEMU
robg wrote:
…the plethora of available command line options means that I have for now taken up Maniaxx’s suggestion, and installed virt-manager. Of course, a naive install with virt-manager’s default settings failed as described in my first post. However, I have found this tutorial which uses TianoCore UEFI instead of the default SeaBIOS, and now Windows 10 boots and installs properly.
I don’t think there’s anything wrong with virt-manager I simply can’t work with that ‘thing’;)
Very nice you managed to install it with TianoCore, I managed to install it perfectly fine but then it went awry somewhere along the way…
Will try it somewhere later (without the video;) and update the script too, which seems to do the job just fine .. for a BIOS system:-)
#8 2022-06-30 16:26:43
- siepo
- Member
- Registered: 2020-11-23
- Posts: 10
Re: Windows 10 on QEMU
I am also running windows VMs under KVM/QEMU with libvirt.
With me, a windows 10 VM hangs at the logo. This is on my laptop, with an 11-th gen i5. Downgrading the kernel to e.g. 5.17.7 solves the problem.
On my other machine, very similarly configured but with an 8-th gen i5, everything is fine.
I have been wondering whether I should report this or just wait for a working kernel, for there should be plenty other people running into this.
#9 2022-06-30 20:37:27
- robg
- Member
- Registered: 2015-03-05
- Posts: 219
Re: Windows 10 on QEMU
qinohe wrote:
I don’t think there’s anything wrong with virt-manager I simply can’t work with that ‘thing’;)
I agree — in that I prefer the non-ambiguity of the command line over the comfort of GUI applications.
Regarding this thread: If you are facing issues running Windows VMs on QEMU with a Gen-11 Intel chipset, the current workaround is to select the UEFI boot option in virt-manager (adding the corresponding UEFI paramter to a `qemu` call may not suffice, as virt-manager includes other parameters under the hood.) However, because Windows should boot with SeaBIOS, this does not constitute a proper solution, and I shall refrain from marking the thread as solved.
#10 2022-07-05 19:35:28
- siepo
- Member
- Registered: 2020-11-23
- Posts: 10
Re: Windows 10 on QEMU
Indeed, on my laptop with a gen-11 i5, a new UEFI-based win10 VM works just fine with the current kernel. I am glad I found this thread.
#11 2022-10-10 12:35:27
- to_you_bannana
- Member
- Registered: 2022-07-15
- Posts: 50
Re: Windows 10 on QEMU
Sorry for necrobumping this, but for any wanderers the ideal steps are below
1. Create a directory and cd in it
2. Download the windows ISO (I got the Windows 1709 ISO for the best performance and stability)
3. Download the virtio drivers from https://fedorapeople.org/groups/virt/vi … -downloads
4. Create a new image by
qemu-img create -f qcow2 WindowsVM.img 64G
(change the size accordingly) for the storage
5. Launch the vm by the following command of which the parameters should be edited according to your system (if you are not sure, do not change the amount of sockets and threads, cores can be changed):
qemu-system-x86_64 -drive file=WindowsVM.img,format=qcow2,if=virtio -drive file=WindowsXXXXXX.iso,media=cdrom -drive file=virtio-win-X.X.XXX.iso,media=cdrom -boot order=d -device qemu-xhci -device usb-tablet -enable-kvm -machine type=q35 -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_time,hv_vapic,hv_vendor_id=0xDEADBEEFFF -rtc clock=host,base=localtime -m 32G -smp sockets=1,cores=6,threads=1 -vga virtio -display sdl,gl=on -name "Windows 10 1709 64 bit"
(to ensure windows skips the «Sign in with Microsoft» step do not add a network device and bring your main interface down)
6. Continue with the installation procedure
7. Click «Custom: Install windows only»
8. Click Browse > CD Drive with the virtio-win drivers > amd64 > wXX (for windows 10 it would be w10 etc) and OK then Next
9. Continue
10. After the installation shut off the VM, and to run from the disk just remove the virtio drivers and the ISO from the command. Also if the network already is not working you can add
-net nic -net user,hostname=windows
to the arguments. If you want to use VFIO/pass through a single GPU you can try following this guide: https://gitlab.com/YuriAlek/vfio/-/wikis/Use#windows
Last edited by to_you_bannana (2022-10-10 17:46:02)