QEMU v4.0.0 released
qemu.org
qemu.org
The official documentation just explains the numerous parameters. It also points to tutorials (wikibook, etc), which unfortunately are very basic and out of sync. Even Arch Linux does not provide a good documentation (lack of clarity, some obsolete syntax, "Networking" section is a mess...). Like often, Debian's wiki is obsolete, and even their QEMU images are 5 years old. I had to combine the following 3 sources and a lot of try and guesses to build my VMs.
QEMU Gentoo : https://wiki.gentoo.org/wiki/QEMU/Options
QEMU official : https://qemu.weilnetz.de/doc/qemu-doc.html
KVM Performance : http://www.linux-kvm.org/page/Tuning_KVM
That's a fact.
And not many people need to look at the code in real life...
Both gnome-boxes and virt-manager use QEMU under the hood though, and they provide a point-and-click experience. I use virt-manager myself and I do not think it's any more difficult than VirtualBox is.
Everytime I tried to migrate to qemu or virt-manager or gnome-boxes it was a real nightmare especially installing SPICE+virtio drivers+ networking. I read in Phoronix the performance of virtualbox is subpar and all KVM/qemu is the way to go.
Please, could the OSS community build a easy to use GUI that SPICE+virtio drivers+ networking is made simple. Any one from qemu, I really appreciate the work but still very challenging for sysadmins.
The problems I did have were with VMs I tried to convert from VMware to KVM, and those stemmed from Windows' inability (version 7) to properly handle changing hardware. Perhaps it's better at nowadays.
The exercise was a good (and incremental) learning experience and increased my general networking and sys-admin knowledge, which I've used well as part of my software engineering career. I would have been lost in many professional situations without it. QEMU/KVM are awesome.
EDIT: more and better words
https://www.spice-space.org/download.html
It will contain everything you need for a fairly seamless experience on windows, and libvirtd and virt-manager make host side a cakewalk as well.
I would say forget spice + libvirt graphics layer. Use RDP, if on linux remmina work's great. RDP will outperform in my experience SPICE. I've also had constant troubles with the vga/qxl/virtio graphics.
Secondily for virtio: https://docs.fedoraproject.org/en-US/quick-docs/creating-win...
There is an iso at the above link. Grab that and have it added during install. When you get to the select a drive. None will show up until you load the virtiostorage driver.
There are a lot of nuances to first setting up a windows vm. But the performance is great. It has removed the need for a windows install for gaming at all.
I believe his pain point is that with Virtual Box you get a very simple GUI where you can get VM up and running very quickly without having to use Google or read any guides at all.
Virt-manager adds a very nice VirtualBox-style GUI front-end to libvirt.
I suggest QEMU's documentation could mention libvirt and its user-friendly interfaces.
"QEMU aims to fit into a variety of use cases. It can be invoked directly by users wishing to have full control over its behaviour and settings. It also aims to facilitate integration into higher level management layers, by providing a stable command line interface and monitor API. It is commonly invoked indirectly via the libvirt library when using open source applications such as oVirt, OpenStack and virt-manager."
But I get it, not everyone goes in search of a README buried in a Git repository. I myself am not sure if this REAMDE is rendered in an HTML format somewhere.
actually, having gone through the process of successfully setting up the vm’s make you eminently suitable to contribute documentation knowledge that is sorely lacking in the online resources you have pointed out.
i am sure it will be greatly appreciated and will get improved upon areas that are missing etc.
E.g. here is a minimal QEMU command-line that gives you access to a serial console in the guest:
`qemu-system-x86_64 -display none -no-user-config -nodefaults -m 2048 -device virtio-scsi-pci,id=scsi -device virtio-serial-pci -serial stdio -drive file=/export/cirros.qcow2,format=qcow2,if=virtio`
Simple, yeah? Now here (it's too long to post in this comment) is a real world QEMU command-line (as launched by the libvirt[1]):
htttps://kashyapc.fedorapeople.org/Fedora-28-QEMU-command-line-by-libvirt.txt
Compare and contrast the number of devices that libvirt adds.
FWIW, I strongly recommend to use libvirt to launch your QEMU-based guests. It is far more effective, and more importantly, provides security infrastructure like running the QEMU process as an unprivileged user, protecting the QEMU process (and its associated disk iamges) via the SELinux-based sVirt mechanism, and so forth.
Check out these[2] slides (recording is online, too) on "Security in QEMU" from one of the QEMU maintainers, Stefan Hajnoczi, at last year's KVM Forum in Edinburgh.
[2] https://vmsplice.net/~stefan/stefanha-kvm-forum-2018.pdf
Anyone can run your example "qemu-system-x86_64 -display none -no-user-config -nodefaults -m 2048 -device virtio-scsi-pci,id=scsi -device virtio-serial-pci -serial stdio -drive file=/export/cirros.qcow2,format=qcow2,if=virtio" from the command line/bash, as non-root user, yet libvirt which requires root to install, and is expecting root to configure it, is better? How?
Libvirt is one of those softwares which ads a layer of complexity for the sake of complexity, yet offers nothing of value in return.
People forget that software is malleable. Bend it to your needs, instead of adding fragile wrapper layers.
The libvirt team definitely does view qemu as malleable, and bends it to their needs.
The problem is that the libvirt authors contributing to qemu look at qemu as a machine-interface (to be consumed by libvirt), not as a human-interface. Many of the more poorly documented or otherwise difficult-for-humans flags were contributed by the libvirt team. And they're useful! They make it so qemu can do things it couldn't do before. But they're also kinda the reason qemu is difficult to use without libvirt.
Sure its possible to do all this without libvirt, but it comes as one integrated, easy to manage package instead of hundreds of disparate parts.
You might not need (all) these features, but to claim libvirt is useless is extremely parochial.
Its also untrue that it needs root, you can virt-manager for instance without a root libvirtd instance at all, and it will run VMs without any permissions needed.
everything libvirt does can be done without it by talking to qemu directly. and yes, Ive done many of the above "by hand", it was easier to read man qemu and other qemu docs than to swallow libvirt.
Its fine if your use cases are covered by plain QEMU, but libvirt does a hell of a lot more than plain QEMU alone is capable of.
Again all of that is possible via other means, but when other means involve recreating half of libvirt in shell scripts or other code, id rather let somebody else do the work for me.
QEMU is designed to run virtual machines, libvirtd is designed to manage VM server infrastructure.
Libvirtd is much better suited to managing that sort of complexity.
Isn't that sort of like saying the system startup scripts/subsystem adds complexity for the sake of complexity, and you should just use ifconfig and route manually in some script after startup?
In both cases, that you can fall back to the underlying commands is great. That you should use them instead of the normalized interface provided is debatable.
EDIT: Nevermind, `-enable-kvm` also doesn't need root. I'm not sure what libvirt uses root for.
Instead, one of the more annoying things I have ever done was foolishly installing libvirt and having it do all kinds of whackiness to a previously excellent QEMU set-up. I still cannot figure out where it managed to change all QEMU invocations to be VNC-based.
Yes, there may be many switches in the invocation, but at least they are in one place, the invocation syntax rarely changes and works accross distributions, and they are applied from scratch in each invocation rather than having lots of implicit state hidden in daemons and their configurations / databases.
Your example is nicer on the eyes written in a config file style and leaving out the unnecessary options:
qemu-system-x86_64 \
-display none \
-m 2048 \
-serial stdio \
-drive file=/export/cirros.qcow2,\
format=qcow2,\
if=virtioI appreciate that libvirt may not be a suitable option for some. That said, you might want to consider the below points on where it adds value (for production VMs; not talking about test and development setups):
• It's not about having all the QEMU "switches available in one place". The dizzying array of switches make it trivial to let you shoot yourself in the shoulder (e.g. getting fiddly details like PCI device addressing right manually).
• Knowing the "best practice" command-line will get you optimal performance out of your (production) guest—libvirt handles that for you. And if the best practices change, libvirt will automatically handle that for you, as it keeps track of "QEMU command-line best practice evolution".
• Launching the command-line is only the first step. If it's a production guest, at some point you might need to live-migrate the guest, or take a live disk backup, or if your guest has a long disk image backing chain, you want to "merge" the disk images into a single, coalesced image—all of this without the guest going offline. These tasks can be done manually (assuming you launched QEMU the 'right away' upfront) via extremely tedious and error-prone ways using QEMU's JSON-based run-time interface, QMP (QEMU Machine Protocol). But that's too risky and a colossal waste of time.
• Speaking of QMP, the run-time interface, it has even more dizzying array of commands—to be more precise, as of 2015: QMP had about 126 commands + 33 events. And more than 700 named arguments and results. Try keeping track of all of that manually. It reminds me of how once a QEMU sub-maintainer memorably compared (in his 2015 talk, "QEMU interface introspection: From hacks to solutions") the volume of QMP schema to old religious books: "QMP schema is larger than "Gospel of Luke", but smaller than "Genesis". :-)
IOW, I'm yet to see anyone who launches multiple guests (on the moderate scale of hundreds of VMs) use direct QEMU in production. There are odd examples, as I noted earlier, but it's certainly not the norm.
qemu-system-x86_64 \
-display none \
-m 2048 \
-serial stdio \
-drive "$(printf "%s"
file=/export/cirros.qcow2, \
format=qcow2, \
if=virtio
)" args=(
-display none
-m 2048
-serial stdio
# -disabled-option
)
qemu-system-x86_64 "${args[@]}"
The array syntax means you can ditch the tedious backslashes and easily comment individual lines. drive_args=(
file=/export/cirros.qcow2,
format=qcow2,
if=virtio
)
qemu_args=(
-display none
-m 2048
-serial stdio
-drive "$(printf "%s" "${drive_args[@]}")"
)
qemu-system-x86_64 "${qemu_args[@]}"
Personally, I prefer it with the backslashes if I don't need to comment.But NixOS has a neat feature where any (?) NixOS configuration can trivially instead be built as a "vm", which will assemble an initrd for the described system along with a script which will run a tailored qemu invocation to launch the system, leaving a qcow2 file of any changes you make to the filesystem in your cwd. Makes the whole thing extremely usable, and is done in a very extensible way.
> -nodefaults
Once you add `-nodefaults`, the list of arguments grows because now you must add a bunch of things that were there by default. If by "minimal command-line" you mean "the simplest list of arguments", then your example is wrong. If by "minimal command-line" you mean "command-line that gives the minimal VM", then you're being misleading, because that's not how people will take it.
Most of the devices added by libvirt would be included by qemu automatically if you didn't say `-nodefaults`. libvirt uses `-nodefaults` and specifies its own defaults, so that it doesn't need to keep track of changes in Qemu's defaults between versions of Qemu (since libvirt cares about the nitty-gritty more than most humans do).
PS: You have too many "t"s in the "htttps://" in one of those URLs.
Partly true (refer below).
> If by "minimal command-line" you mean [...]
I appreciate your corrections, but please don't read too much into the word "minimal". I just quickly pasted it from one of the "subjective scripts" named `min-qemu.sh` lying around on my file system. By the time I realized, it was too late to adjust it.
> Most of the devices added by libvirt would be included by qemu automatically if you didn't say `-nodefaults`
Not quite; I just double-checked with an upstream libvirt dev: when you remove `-nodefaults`, some of the built-in devices get removed, whether those equate to "most" or not depends how many devices you've asked for.
> PS: You have too many "t"s in the "htttps://" in one of those URLs.
Yeah, realized too late that there was a typo :-(
> `qemu-system-x86_64 -display none -no-user-config -nodefaults -m 2048 -device virtio-scsi-pci,id=scsi -device virtio-serial-pci -serial stdio -drive file=/export/cirros.qcow2,format=qcow2,if=virtio`
That's far more than I typically put in my qemu calls. You can technically be fine with just:
qemu-system-x86_64 foobar.qcow2
but I always add `-enable-kvm` and use `-monitor stdio` or `-nographic` depending if I want a graphic display from the vm or not. `-nographic` is all I need to give me access to a serial console in the guest (besides configuring the guest kernel with the paramater `console=ttyS0`). I also add `-m` because the default amount of memory is just 128 MiB, which is typically not enough for my use. Sometimes I add network related arguments, but we're going beyond minimal then.I ran Foreman inside a CentOS VM, which talked to my desktop's Libvirtd to provision new VMs, hand out IPs via DHCP, boot via TFTP, then kickstart. It worked pretty well, and helped me to spin up a vcenter foreman controlled dev environment for a few hundred users in just a few days.
My recommendation would be Vagrant + Libvirt.
In the end we rolled our own solution that is much more lightweight, uses QEMU directly and provides better visibility, ease of use and even some potentially useful networking features. Here are a few screencasts [1].
This is mainly designed as a module for Flockport and we will preview this soon.
In Linux distributions, you basically install `virt-manager` and the package manager will resolve all dependencies to provide you a fully working virtualization desktop software which is well capable to be used on servers.
To get macOS to see my GPUs with full acceleration and audio over HDMI, I use the Clover bootloader to inject a small section into the DSDT, mapping the emulated PCI address to a device that actually looks like a graphics card to macOS. This same DSDT patch works for both NVIDIA and AMD GPUs (the ones I've tried anyway).
The best thing about Hackintosh in a VM is that you no longer need to fear macOS upgrades. Just create a snapshot, try the upgrade, and if it doesn't work out, you can restore, investigate, and try again.
LTT's video is a nice overview, but his claim that "because this is a VM... it will run on any hardware" isn't quite true when talking about GPUs. Unlike the CPU, memory, and some other devices, the GPU is seen (nearly) directly by the guest VM, so guest OS support is in fact required to see the advantages of GPU passthrough.
In summary, it's never going to be super easy, but it's not too difficult either, and the performance (and flexibility) is actually really great.
I was thinking about expanding the setup to include a beefier linux host (more gpus and better hardware) and more seats -- windows gaming for me and osx for my wife. But you mentioned several possible osx specific caveats: amd gpus, clover (?) bootloader w/ dsdt (?), disable_idle_d3, etc. Can you link to some info or READMEs regarding your setup or how you came across these solutions?
- Good starting point for setting up macOS under QEMU/KVM: https://github.com/kholia/OSX-KVM
- DSDT/SSDT patching: https://www.tonymacx86.com/threads/ssdt-gpu-graphics-card-in...
- AMD reset bug: https://www.reddit.com/r/VFIO/comments/5h351m/gpu_stuck_in_d...
- Kernel extension that can help with some GPU issues: https://github.com/acidanthera/WhateverGreen
The DSDT/SSDT patch was probably the trickiest thing. I've posted my particular patch here if you're interested: https://pastebin.com/ngvkVZYN
Also, a few of my other scripts/config: https://pastebin.com/9Nh5rheZ
Previously, I also attempted using a kernel patch that's been floating around (DECLARE_PCI_FIXUP_HEADER ... quirk_no_bus_reset), but it just gives me corrupt graphics when rebooting the VM.
I had success getting macOS running on QEMU with my existing PC, but its performance suffered without a dedicated GPU and CPU pinning, which my new build will be configured to handle
Edit: Tested it, aaaaaand NaN compares are still broken :(
But support appears to be there as of a week ago, fyi.
While years ago I would mainly use Virtual PC (I do miss its great GUI) and VMWare (and rarely bochs), qemu improved a lot and has (somewhat decent) support for so many more architectures. You can run Solaris for SPARC and Mac Os 9, for example.
I'm an avid follower of virtuallyfun.com and right now the latest post is about installing AIX on QEMU. If you look into the qemu category ( https://virtuallyfun.com/wordpress/category/qemu/ ) you'll find OS X Server, Unixware and more.
The author, neozeed, is very friendly and you can leave him comments or shoot him an email and he usually answers pretty in depth.
As for OS 9, I'm not sure it is as refined and functional as SheepShaver on Windows yet, but I'm on OS X, where SheepShaver takes more effort to set up. There's a modified QEMU for enhanced OS 9 compatibility (I think more G3 emulation?) here, and people managed to install 9.2: https://www.emaculation.com/forum/viewtopic.php?f=34&t=9028
Link?
Or do you mean a copy of the ISO? For that I'd try archive.org or winworldpc
(See https://taoofmac.com/space/blog/2019/04/21/2300 and https://github.com/insightfulsystems/alpine-python)
Will be trying ARM64 soon, as soon as I have a suitable development board.
You can write a system configuration, generate a QEMU VM and run it. Also all NixOS automatic tests[1] are running in QEMU VMs that are generated from a Nix configuration.
The most beautiful thing is that you can create multiple VMs and run them simultaneously to create a virtual network. For example you can test a client-server application by running the client and the server on two hosts or test some network configuration[2].
[1]: https://nixos.org/nixos/manual/index.html#sec-nixos-tests
[2]: https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/nat...
There are a lot of rough edges to the desktop experience, but it generally works. And while that's faint praise, I have no current plans to switch back to Fedora (3 years) or Debian (12 years prior to that).
It's comforting to know that my entire base system configuration is declarative, and it's pleasant to not worry about libraries conflicting or unnecessary packages lingering around.
Immediate, ephemeral access to programs via, e.g., `nix-shell -p pdftk` is extremely convenient: they're only available in that shell session, and they (along with their dependencies) get cleaned up the next time you run `nix-collect-garbage`. Super handy.
edit: nevermind, I didn't realize it was a Linux distro.
When you launch a KVM-based guest, most often you would see QEMU doing the major user space heavy-lifting by providing a PC-like environment—it handles guest memory management, network cards, emulated storage devices, and so forth. QEMU also has a robust Block Layer; not to mention its versatile, and widely-used, native disk image format, QCOW2.
PS: I am biased, as I work with QEMU on a daily basis :-)
This has really freed me up because I'm no longer tied to a single machine. My home dirs are mounted volumes that are also backed up, so I can tear down and rebuild the environment with a single command (which means that my environments are also deterministic). I can connect to them from anywhere on the planet, using any machine as a client (even my phone or a tablet). My main laptop is now a weaksauce 1080p chromebook that acts as a glorified thin client and web browser.
The most complete guide is probably the Arch Linux one: https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVM....
Also I recently discovered some very in-depth blog posts here: https://heiko-sieger.info/iommu-groups-what-you-need-to-cons...
Another whole website about this topic (no joke): https://passthroughpo.st/
What remote desktop app do you use?
What’s your latency like? What are the drawbacks to a setup like this?
Latency varies a lot and I’ve found hotel WiFi to sometimes be unusable. ATT LTE on the device generally works pretty well. I’m primarily running this setup just to have access to a full browser environment for my tinkering with web scraping so having a super responsive low latency connection isn’t as vital as it would be to do something like gaming. The main drawback is always needing a solid connection which is mostly solved with LTE where I go.
I did a similar thing with the Raspberry Pi a few years ago, but the QEMU support wasn't great back then which made debugging incredibly hard. I think the support has improved a lot since then, so I should probably give it another go.
[1] https://github.com/SgtCoDFish/bedrock-bootstrap - I'm writing the steps as a kind of tutorial to myself to aid learning, but fair warning that it's all a bit of a mess right now!
If you are using MS-DOS on QEMU there is a open source utility called DOSIDLE.EXE that keep the CPU usage low and stop the annoying CPU fan from spinning.
QEMU has just the right mix of performance and hackability that I need for my "printf debugging" workflow :) (I've used Bochs a lot, too, which is more hackable, but far less performant.)
Also trying to setup gvt-g with dmabuf but corner cases still need fixes, e.g. video playback doesn’t work on overlay sprite of yuv encoding.
I got sick of trying to figure out which thing I needed to click in virt-manager to get it to pass the flags I wanted, so I wrote my own minimal qemu-wrapper that covers all of the functionality from libvirt that I care about (vCPU pinning, binding to NUMA nodes, running as non-privileged user), and integrates better with the other system (systemd) monitoring than libvirt does. https://git.lukeshu.com/systemd-qemu/
----
I'm also involved with the Parabola GNU/Linux-libre distribution. Qemu user-mode emulation is essential to our support of non-x86 platforms (ARM and PPC). It lets us run cross-architecture chroots without a full-blown VM.
Setting it up was somewhat difficult. When I did it there weren't many good guides for just exactly my situation, so I had to use many, many different resources to get it running. Based on some of the links others have posted here, there seems to be more out there on it now.
This was my last working startup script. I no longer recall why or even if any of these options were necessary or beneficial. At the time, it was just what worked. (Dual monitor, separate video cards for host and guest, L-CTRL+R-CTRL to pass mouse/keyboard control back and forth.) I haven't used this in quite a while, so I can't say if all of these options are still legit anymore.
#!/bin/bash
cp /usr/share/edk2-ovmf/OVMF_VARS.fd /tmp/my_vars.fd
qemu-system-x86_64 \
-enable-kvm \
-m 16G \
-cpu qemu64,hv_vendor_id=whatever,kvm=off,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,smep=off \
-smp cores=8,threads=1,sockets=1 \
-machine q35,type=pc -vga std -display gtk \
-drive if=pflash,format=raw,readonly,file=/usr/share/edk2-ovmf/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/tmp/my_vars.fd \
-drive file=/dev/disk/by-id/ata-Samsung_SSD_860_EVO_250GB_XXXXXXXXXXXXXXX,format=raw,if=virtio \
-drive file=/dev/disk/by-id/ata-ST3000DM001-XXXXXXXXXXXXXXX,format=raw,if=virtio \
-boot order=d \
-object input-linux,id=kbd,evdev=/dev/input/by-id/usb-XXXXXXXXXXXXX_USB_Keyboard-event-kbd,grab_all=yes \
-object input-linux,id=mouse,evdev=/dev/input/by-id/usb-XXXXXXXXXXXXXXXX-event-mouse \
-device virtio-mouse-pci \
-device virtio-keyboard-pci \
-netdev user,id=user.0 -device e1000,netdev=user.0 \
&Having a collection of emulated Unix workstations is an upgrade in terms of space saved.
The steps are here for posterity: https://github.com/kholia/mips-hacking
https://astr0baby.wordpress.com/2018/09/22/running-solaris-2...
I used a Solaris 7 .iso from archive.org.
http://www.w6rz.net/netscape.png
That was with a Solaris 8 disk image that I found here:
So the version number is essentially meaningless now - the year of release (eg, QEMU v2019.0.0) would give you more information. I can't say I'm a fan.
Error starting domain: internal error: qemu unexpectedly closed the monitor
....
libvirtError: internal error: qemu unexpectedly closed the monitor