Ask HN: What do you use VMs for regularly?

113 points by pvinis ↗ HN
I know many people use VMs for work, or to test things they develop. Makes sense.

But what else do people use it for? I want to hear interesting or unusual things you use a VM for.

For example, I have thought of running a VM only to use git in there, maybe so try and see if magit will run faster in a VM rather than on the host macos. I also have thought of using a VM to only run a browser in there, to keep the memory under control. Not sure any of these are good, but they are interesting.

What are your ideas or actual ways you use VMs?

176 comments

[ 2.2 ms ] story [ 229 ms ] thread
Testing features on Linux. Sounds dumb a d obvious, but if you use a windows laptop for work, being able to pipe into a Linux VM that is corporate approved is nice. Also use it for certain debuggers that aren't supported on my host OS. Basically as a stitch in for the fact I can't use Linux at work.
There are a lot of prebuilt VM's around, you might get some ideas there:

https://app.vagrantup.com/boxes/search?page=1

https://www.osboxes.org/virtualbox-images/

I use Parallels to run windows on a Mac, a pretty common use. I've heard of people running game servers in VM's e.g. Minecraft

I still use the fool out of vagrant. I often have to write small tools that run across 10000s of servers running various versions of OSes (but all x86 these days, thankfully). Almost always I need to hit /proc, /sys, and various glibc versions, so having a full kernel and user space is better than fussing with Docker.

It lets me test against all of them pretty easily. Tear down, spin up, repeat.

I learned that various versions of RHEL6 kernels have stuff like epoll() but others don’t and it’s not everything after kernel version X.Y. Joy.

Better than before when I had to support HP-UX, Solaris, AIX, etc. At least I have a consistent shell and least common denominator tools. That was like old school browser detection.

But yeah, a lot of focus on doing work without stressing the machine at all to not impact business workloads. Not my “day job”, but get pulled into emergencies because folks trust that I’ll do it. Log4j2 detection/validation was not fun. That was a “real cli” with a degraded pure shell fallback. And due to the lack of predictably, that was a try, fail, degrade. Nested jars/wars/ears suck when you can’t just play in memory.

I run macOS with virtualbox locally, but can get all the Linuxes I need and quickly ruby/shell a test harness.

Only annoying thing is remembering to remove them all when I’m done to get that disk back.

> VM to only run a browser in there, to keep the memory under control

For other Linux users out there — a VM is not needed for this, use a cgroup with memory limits. It's very easy to do with systemd, but can be done without it:

  $ systemd-run --user --pty --property MemoryHigh=2G firefox
The kernel will prevent Firefox from using more than 2 GiBs of RAM by forcing it into swap (including all child processes). To quote systemd.resource-control(5):

> Specify the throttling limit on memory usage of the executed processes in this unit. Memory usage may go above the limit if unavoidable, but the processes are heavily slowed down and memory is taken away aggressively in such cases. This is the main mechanism to control memory usage of a unit.

If you'd rather have it OOMed, use MemoryMax=2G.

It's actually very useful for torrent clients. If you seed terabytes of data (like I do), the client quickly forces out more useful data out of the page cache. Even if you have dozens of gigabytes of RAM, the machine can get pretty slow. This prevents the client from doing that.

There are lots of other interesting controllers that can put limits on disk and network I/O, CPU usage, etc.

ulimit?
ulimit can only control virtual memory caps, not physical memory caps.
If you fine with the process being terminated, then maybe. Although I believe ulimit doesn't account for the page cache (this is not important for browsers, but definitely for torrent clients — they can effectively eat up all your memory even if RSS + SHR never go above a few hundred megabytes). Also not sure how it works for shared memory (which is heavily used by modern browsers), which is definitely accounted for by cgroups (and limited by MemoryHigh/MemoryMax).
Interesting - is this possible and/or advisable on MacOS? Browsers - all of them - seem to be among the worst offenders.
Browsers seem mostly to operate under the principle that they're the only program the user wants to interact with, and probably the only userspace program running.

For most folks, they're right.

> cgroup with memory limits. It's very easy to do with systemd, but can be done without it

I prefer lxd for gui programs personally, while probably a tad more effort initially setting up the x11 profile to get gpu acceleration, once that is done you can pop everything into its own linux container using that profile. From there you can control resource limits permanently.

Especially like it for intrusive apps such as discord, zoom, etc which are hard to escape from.

For GUI applications, firejail might be easier to use. It too isolates applications from your system, but comes with a bunch of pre-configured profiles for many popular applications (including proprietary ones), thus requiring zero configuration.

Some of its more interesting features (in addition to the obvious path/privilege restrictions):

- putting the application into a separate network namespace with its own firewall rules/network interfaces (for example, you can force Firefox to work through a VPN connection only, or block incoming connections with your main firewall rules and allow them for a single application)

- using a separate X server for each application (works pretty much transparently)

- setting resource limits (network bandwidth, memory, CPU, I/O; although not as flexible as systemd limits, they can be combined)

- running `sudo firecfg` once will create a bunch of symlinks for all applications installed on your system and supported by firejail. After that, those applications will run under a sandbox automatically. Or you can create them manually (I did it for the PDF reader and such).

https://github.com/netblue30/firejail/

You can also limit memory usage with Windows Sandbox.
> by forcing it into swap

What if there's no swap (as I believe is the current fashion in desktop envs, unlike servers)?

It does something called reclaim where it halts the running of the program and does an O(n) scan of that processes memory space to find pages that can be dropped (forces dirty writes to complete and drops file cache)
Docker. I'd rather have a proper environment I control than whatever bastardization "Docker Desktop" is. It uses VMs in the background anyway.
When I reinstalled Docker recently, it tried to push Docker Desktop for Linux at me quite a bit, which was new from the last time I installed Docker.

In the end, I went and specifically hunted down Docker for use on servers to get an installation without all the Desktop cruft - even on that page [0] there's a big thing advertising Docker Desktop for Linux.

0: https://docs.docker.com/engine/install/

They have to get that sweet corporate money somehow. Teaching people to use Docker Desktop so they pester their employer for a license seems to be the premier way to do it.
The latest macOS doesn't support my printer out of the box anymore but it's still supported on Linux, so I just passthrough the printer and print from there. Strange times.
Pretty funny considering that CUPS is an Apple project and has been maintained by an Apple engineer for years.
It's probably because they just focused on IPPAnywhere which is a pretty good idea, just a bummer that the whole PPD train got derailed because of it.

Another highly likely possibility is a proprietary filter from the printer manufacturer that wasn't complied as a universal binary or compiled with i386 dependencies and thus won't run on x64-only versions of the OS.

Mostly as a clean slate to run ansible against. That in turn sets up various services.

I could put multiple services on a single vm but split is easier mental model wise

Do you use vagrant with Ansible runner than?
Nope. Homegrown ansible script straight against proxmox command line interface over SSH.

So if I need a new VM I copy an existing inventory section for a VM (which has mem, cpu, NFS mounts etc variables defined), tweak that and run the deploy script with that.

Followed by another ansible script specific to the software piece I'm deploying.

Bit unorthodox (traditionally deploy part is terraform not ansible) but works for me. This is home server though...for cloud VMs I'd use terraform.

Running Linux on my mac. A VM is particularly useful because I can spin one up to install some crapware needed to work and then discard it.

Installing tunnels and certs needed for contract work.

Experimenting with new software environments.

Running Linux desktops on a Windows system, and vice-versa, for development, testing or simply running some program without having to move to a different room and power up the desktop system, for example.

Testing and playing with older systems (Windows 9x, Linux distros from the 90s) for fun and kicks (or to compile some sutpidly old tarball of something that sounds interesting or fun but hasn't been updated in 15 years)

Building network meshes to play around with running BGP, OSPF etc. on FRRouting

I find it a lot easier to find a Docker container with whatever service I want to use vs trying to figure out how to install it locally. Nothing super exotic, but currently I'm running OpenSearch and PostgreSQL in a VM (via Docker).
I'm using VMs for everything. Disposable, self-destructing VMs for untrusted browsing. Network VM solely for connecting to the Internet, Firewal VM for isolating the network from other parts of my system. Work VM for everything connected to work. Archive VM (with no networking) for storing important files. Banking VM for managing bank accounts. Zoom VM for isolating Zoom from the rest of my system. And so on.

All this works with a great, unified interface on Qubes OS (https://qubes-os.org). See also: https://forum.qubes-os.org/t/how-to-pitch-qubes-os/4499/15.

What about security? I always thought that it's easy to get into vm from host, but it way harder to get to host from vm. I thought about using VM for security things, but the idea that it easy to get inside vm keeps me from doing it
(comment deleted)
> I always thought that it's easy to get into vm from host, but it way harder to get to host from vm

That's right.

> but the idea that it easy to get inside vm keeps me from doing it

No! Of course the host is the ultimate dictator. Just don't do untrusted operations in the host context. Have low-trust, low-connectivity, low resource level VM for untrusted work.

You might have it backwards. Most people typically do untrusted actions inside the VM and keep their host “clean”. You’re correct though that VM escapes are pretty difficult, especially with modern, patched microcode processors.
> modern, patched microcode processors

This makes me wonder how many security holes CPUs have which have been buried into secrecy by the manufacturers.

> VM escapes are pretty difficult, especially with modern, patched microcode processors

Most VM escapes happen through buggy virtual-devices written in C/C++/.. code. Virtual-device bugs that are exploitable by attackers with root access in the VM are found frequently.

You are right. The host on Qubes OS (dom0) has no networking and never runs any software by default. Also, hardware virtualization which Qubes uses last time was broken in 2006 by its founder: https://en.wikipedia.org/wiki/Blue_Pill_(software).
The hypervisor problem can be solved (in theory) with secure boot configured with custom keys and full disk encryption. I don't know anyone who actually uses Qubes so I don't know how practical that solution is. Coreboot has something similar to secure boot, so even if you use an open source boot loader, this can be done.

An attacker would need to do some quite invasive hardware tampering to get a third party hypervisor to work on a system secured like that.

Furthermore, preventing hypervisor detection requires constant updates if the OS itself is configured to check for the presence of a hypervisor. There's a constant arms race going on between security researchers and cybercriminals who don't want their malware to trigger on analysts' machines, many of which use virtualization to easily reset the system back to a known, secure state. Every time malware comes up with a new method of detection your evil hypervisor needs to be patched to fake that stuff too or you risk detection next time the OS updates its detection algorithms.

I just wish Qubes had a simpler architecture, such that dom0 and the Qubes Components could be implemented in eg. Guix or Nix instead of a traditional distro. Love Qubes' desktop integrations.
Me too!

It's nearly worth it for avoiding Google's terrible account switching UX alone :)

I've been using QubesOS as my daily dev machine for a couple of years now. No regrets. I really like that I've set up each of my clients' work in their own VMs, so there's no way one can pollute the other.

Switching back to macOS is a relief for some tasks, but it feels dirty smudging all my different types of task into the one OS again.

Oh man Qubes looks awesome. I am just addicted to a windows game that doesn't have any linux support :(
Depending on your hardware, you could try GPU passthrough.
is that with virtualbox or something?
With Qubes OS, the context of this thread.
Does WSL2 on Windows count?

Because 2 years ago I moved back to Windows from MacOS for my daily driver because of WSL2.

I get the same "modern GUI on top, Unix-like shell underneath" experience that I had with MacOS but now I have a 24-core machine with 32GB of RAM for a third (or less) the price of what a similar Mac would have cost me.

I hope to not start a flame war, but for "modern GUI on top, Unix-like shell underneath" I am extremely happy with KDE 5. I run it on Kubuntu, which is Ubuntu with stock KDE. It perfectly handles multiple monitors and desktops, I can move windows from one monitor to another via keyboard shortcut, Window-on-Top, and the killer feature highlight-to-copy and middle-click-to-paste which is about the only thing I do with the mouse.

The only thing I've had to add to it is an addon called Owl for accessing MS Exchange with Thunderbird at my previous employer. But stock Thunderbird is good enough for accessing Office 365 where I work now.

That's what I ran at my old job and I definitely miss it at my new one, where what I have is Windows with MSYS2 and WSL.

Plasma feels more predictable to me than Windows does, and I really like what it builds into the desktop environment itself. The essentials— window management, the volume mixer, global keyboard shortcut configuration, the panels, the desktop, compose key support, the default terminal emulator, the network management applet, display configuration, the default GUI text editor, the file manager, etc.— all feel just right to me, with very little tweaking required. What configuration is required is straightforward in the GUI and super easy to automate or save in my dotfiles.

Some of this is my own habituation to Plasma's quirks over the years, and some of it is my usage patterns not intersecting with open issues that Windows users would likely find strange. But I do think it's genuinely a wildly underrated desktop that a lot of developers would quickly come to love if they gave it a chance.

I'm honestly glad to hear that KDE and Linux are so viable as daily driver desktop environments now. I haven't looked at KDE in a long time...
Genuine question, why don't you just use desktop linux?

I'm curious as to what pain points make you avoid it. Do you prefer the windows GUI interface? do you not want to deal with with updates breaking your system or having to manage things yourself? or are there programs that you use on windows that aren't available on linux? (or something else).

I want to stress that this is a good faith question. (since it seems flame-war territory adjacent, which I'm not interested in getting into).

Desktop Linux does not run many, many useful apps, and I don't want to continually struggle with drivers and more. If apps do run on Linux, they can often be terrible.

I think the other question is, why would one want to use desktop Linux? With Windows 11 and WSL2, I get both. I can run all my normal apps on Windows 11, and if I really want to run GUI apps on WSL2, I can do that too.

Honestly, Windows plus WSL is the most "just works" platform out there right now. macOS is far too brittle and a compromise between high-level OS and a Unix-like environment. Linux does Linux, obviously, but it struggles as a low-friction, high-level OS.

Will have to "agree to disagree" on your conclusion here.

GNOME 4 is superior to Windows and MacOS as low-friction, high-level OS in my experience. Control panel is clear, if spartan, three finger gestures stolen from MacOS "just work", and the desktop just stays out of the way so I can focus on the applications that I really care about.

I have not had a "struggle with drivers" for over a decade with Ubuntu, Fedora, and Manjaro (YMMV in other distros of course, but it's much more uniform these days), and Windows has become even worse with doing unnecessary BS work in the background slowing down the GUI such that heavyweight desktops like GNOME and KDE feel as svelte as LXDE in comparison.

I honestly can't stand any time I have to use a Windows machine due to how inconsistent the settings are, how many ~200-300ms pauses happen randomly, especially when I'm trying to type, and applications that don't "just work" but only because of the high marketshare I can google a solution. (MacOS is less viscerally disgusting to me, but more disappointing due to all of the "small" bugs that have creeped in despite having 100% control of the hardware in question. Wake-from-sleep shouldn't screw up the Wifi, unplugging and plugging back in an external monitor shouldn't shuffle the window locations, etc.)

My big issue, and friction generator is that Linux - as a desktop - is always a year or more behind consumer hardware, and it unfortunately perpetually struggles with drivers.

Last time I tried Linux, driver support for my new graphics card was poor, my multi-monitor displayport setup was unsupported, DPI scaling - despite even Windows supporting it well for the previous 5 years - was quite bad (and non-integer scaling especially so). Even my CPU simply didn't work without some custom boot args.

So when it comes to "just works", the year of the linux desktop is here if your hardware is at least 2 years old. There's nothing wrong with 2-year-old hardware, but whenever I get a new computer, I install Windows and it just works, rarely do I ever have a good enough reason to switch to Linux given the effort involved.

Sorry you've been unlucky, but I've bought brand new Dell and Lenovo laptops and slapped Fedora on them and they just worked with no driver BS involved. Literally did this just a few months ago.

Ubuntu/Debian tend to take longer to support brand new hardware because they're more conservative with kernel updates, but you can also just use the System76 PPA to get a super-recent kernel on Ubuntu. But faster-paced or rolling distros like Fedora or Manjaro are best for that kind of thing.

I haven't had a single GPU-related issue, AMD or nVidia, for about a decade, if you're willing to go with non-free drivers.

I think your experience is the outlier and not that the other person was "unlucky". Screen sharing is not working on a "mobile desktop" Thinkpad laptop with Red Hat Linux, a paid Linux distribution no less, freshly installed due to poor communication between several screen sharing apps and drivers or just poor drivers. Outlook is not available for Linux. And the least keeps on going.

> I haven't had a single GPU-related issue, AMD or nVidia, for about a decade

While I might be off-base, I would wager that you have probably forgotten and not noticed the amount of times you have debugged these things and other driver-related issues.

No, I hate debugging on personal machines. I really haven't had GPU driver issues for 10 years on any of my Linux machines, and it's a pretty eclectic mix of Ubuntu, Fedora, Manjaro, and now one Steam Deck on SteamOS.
You know I totally agree with you on Gnome being superior. Heck, my preferred WM is DWM and I would use it every day if I could. But here I am, on a Mac, just because I just CANNOT deal with another hardware related issue again. I used desktop linux most of my life (ages 12-28). But with a job and a family, I just don't have time for a single second of down time or debugging my computer. Same for android vs iOS. Used Android for 10 years, switched to iOS. Tried to go back with Pixel 3a, and it would freeze up maybe once a month. That's too much for me. My iPhone has frozen up maybe once in 2 years. Before you judge me, I do extensive infra shit at work and fix broken systems all the time. I just cannot deal with it on my personal devices.
No judgment. Same reasoning for me. In 2016 the bugs with MacOS got annoying enough that I looked around again and I had a more stable experience with GNOME 3 on a Dell laptop than anything on MacOS or Windows and switched.

I had way more problems debugging weird crap with the Wifi when walking between meetings with my MacBook Air, annoyed that when I plugged back into my monitor at my desk I would have to rearrange my windows on my desktops again (GNOME 4 puts the windows back where they were if you plug back into the exact same monitor). And dealing with Homebrew BS because Apple likes to break it on OS updates and sometimes it would break randomly on its own while Debian-derived distros never have package issues pushed me back.

Just saying that you really ought to try it out again, and Fedora is a super-polished GNOME experience if you want "Mac-like, but not annoying."

GNOME isn't an OS is it, so how is it superior to Windows and macOS? It's just a desktop shell as far as I know. So even that shows the downsides of Linux: "Hey, try GNOME." "Ok, what distribution?"

I used to be a heavy Macbook user but am no longer. I use Windows because it simply has the least amount of friction. Every time I try Linux for anything other than a certain style of software development, it's an endless chain of web searching and configuration. Windows is far superior to macOS in terms of memory management. On a high-end Macbook Pro with 16GB, I am almost always maxed out, and the Macbook can't even drive my monitor properly with a dedicated graphics card. Mouse and keyboard settings reset every other day. I can't even imagine how much time I would have to spend setting up just my monitor, webcam, mouse, and keyboard setup with Linux, if drivers and applications are even available. My Windows laptops and desktops don't have any of these issues.

I am pointing at GNOME because from my experience you can basically substitute any of the big distros these days and get a near identical experience.

What webcam, mouse, or keyboard doesn't work with Linux? I have not run into one, and I have several weird ones like the Tap keyboard.

Other than the fingerprint scanner thing on my touchpad I haven’t encountered a non- working out of the box piece of hardware on a laptop for so long I don’t even know how long its been.

And apparently the fingerprint scanner works but I just never got around to it because I don’t care.

So, I have spent zero minutes setting up hardware on Linux in at least the last 15 years and then it was one of those hand tracking things the company donated to the Blender Foundation that I ended up with which was experimental so didn’t have drivers in the distro.

This is more or less the opposite of my experience which has seen Linux installs get so easy that I can guide my 84yo mother over the "phone" (Nextcloud Talk but you get the idea) through one where installing Windows on the same hardware is (if not impossible) a lot harder due to the need to get hold of and install vendor drivers. The same goes for installing applications where sudo apt install name_of_application is far easier that find installable on web, make sure it does not come with a bunch of spy/malware, run installer, answer inane questions to be left with yet another auto-updating program built in a toolkit which looks radically different from all the other ones on the system.

Is the Linux experience perfect? Certainly not, there can be hiccups - try guiding someone on the other side of a phone line through connecting one of those Dell USB3 docks which needs that Synaptic-provided DisplayPort driver - but compared to Windows it is a breath of fresh air. Since Linux in general only serves one master - you - where Windows has to serve at least two - Microsoft first, you may come in second but it is quite possible for some other vendors to push themselves in front of that queue - this is hardly surprising.

Because I only have room in my apartment for one PC, and I want something that can do all my work, but also play games, do hobby dev with my Index VR headset, do good photo and video editing with the software I already know how to use, etc..

I have nothing against Linux (or MacOS), and it was a fair question.. =)

I think for lots of people it would be a very suitable choice, and if I had a "work only" machine, I would absolutely consider Linux, probably even over MacOS at this point..

But for my specific uses, Windows (with WSL2) lets me do all the things I want to with one machine, so it's the winner.

What machine do you use?
I built it myself, it's based around an AMD 5900x CPU.
Absolutely. Windows is the most popular desktop Linux distro.
I LOL'd but then was a bit depressed when it dawned on me you could well be right.
Windows Sandbox to run Adobe Flash to access old data rooms.
I've been banned from selling on eBay and I get around it by having multiple Windows 10 VMs (running on proxmox) with 4G USB dongles passed through to each machine. It keeps everything tidy with no chance of me ever making a mistake and getting found out.
What exactly are you selling?
Thousands of different items that I import from China. I've got a lot of money invested in inventory so I can't risk having my business shutdown by eBay's algorithm or $2/h "service" team again. eBay stealth OPSEC is the only way to have any sort of job security in this game.
This might be silly to mention, but wouldn’t a VPN suffice? Even a VPN set to “always on” in a VM? Another option would be to stand up a t2.micro on AWS and then dynamic port forward web traffic via “ssh -D 7777 $awshost” and use a browser proxy.
At home I use VMs for work environments (usually Ubuntu desktop VMs). Home PC is a gaming computer. All my laptops run Ubuntu.
I use VMs for piracy. I use a Linux VM with iptables configured to only allow connections to/from a specific VPN IP/port. This is probably overkill, but it is nice to have everything separated and isolated without having to worry about IP leaks.
A pretty regular one: Some dev / analyst / whatever wants one. Nothing more, nothing less.

I've had great use of VMs when testing more boutique and unsupported software, where I need to test compatibility on various versions of OS

Lately with docker it hasn't been as necessary, but I used to run VMs for just about every service so I don't have to worry about other apps being affected by an OS issue.
WSL2 can’t be scanned by my work’s antivirus so node projects build and run at full speed.

(2 minutes for starting the project outside vs 25 seconds inside)

If you're talking about running a node project in WSL2 vs in an emulator or VM etc it might just be that most of the speedup comes from Linux and WSL2 itself, as it's quite fast. What you've mentioned isn't a controlled experiment for testing performance
WSL2 is a VM, though. It was only WSL1 that tried to do a kernel-level shim for the Linux userspace layer.
I assume he means WSL2 vs node.exe
Antivirus on Windows are notorious at inserting itself as filesystem filters that triggered on every file access, which adds overhead into every read and write action. Combined with node_modules containing gazillion files, I'm surprised his project only loads in 2 minutes :)
Malware analysis. I run Windows malware on FLARE VM with all traffic routed to REMnux, a Linux distro that emulates internet services with INetSim.
At work we're running some self hosted service, issue is, the service is quite old, and the client only works with other old openjdk versions, so the vm runs the client.

I'm also running android-x86[1], for a single mobile game with an x86 port

[1] https://www.android-x86.org/

I have a DVD-A ripper that only runs on Windows. Because I use a Mac, I primarily use a Windows VM just to rip DVD-A disks.

(DVD-A is a variant of the DVD format where audio is lossless, compressed using MLP. (Very similar to FLAC.) In general, DVD-A is 100% obsolete because Bluray supports lossless audio over HDMI without a special player. Unfortunately, some artists still release on DVD-A for reasons I don't fully understand.)

I use VMs to serve Plex and the software I run around Plex to make it fun and useful. I have a few NUCs that run ESXi, and in turn, my aforementioned VMs. The last time I rebuilt the box, I was considering going back to bare metal for Plex (at least), but the ability to treat the VM as effectively ephemeral but also backed up in case something happened is very useful. It is also theoretically portable if I got a second one and externalized it. I also like to think that virtualizing the machines lets me better carve the otherwise-overpowered host machine and allow it to decide how best to use it's resources, but I haven't actually sat and verified that is what happens.

I use a VM on my work machine to get around Docker Desktop licensing on macOS. I also use VMs on my work and personal machines to test out new-to-me OSes that I want to play with but don't necessarily want to run full time. And once upon a time, I used VMs heavily to write and test Chef cookbooks, but those days are mostly over for me.

Is Plex still able to take advantage of your GPU through virtualization?

Perhaps my understanding is outdated, but I remember a time when the GPU was somewhat limited when virtualized since it potentially needed to be shared as well be exposed through a common layer.

Maybe this doesn't matter for all use cases, but for Plex especially when it's doing transcoding, I'd imagine it's very important.

No the OP, last time I tried GPU pass through I needed some specific settings on the mother board (beyond the normal virtualization stuff) that I didn't have. So I didn't get very far.

On the other hand, I was able to very easily get GPU pass through working on Emby inside and LXC container.

SR-IOV I'm pretty sure. I think you can get away with that with direct PCI passthrough, but it's been a good few years since I did that for realsies.
You are correct, the gpu needs to be passed through. However transcoding can generally be avoided if you pay attention to how you're getting your source material. Also if you aren't transcoding 4k, 1080 is almost trivial now.
I don't use transcoding for Plex at all. I've found it much better to stream directly to a client like Infuse and have it use the client's native hardware decoding. Now granted, this is only really feasible if you're streaming within your own house, but it works great. Plex can be run on any dinky little system that way and have no trouble serving up full bitrate UHD rips.
Direct streaming is great but I wish you could enforce it natively from the server side.

The challenge is getting your friends and family to change the default prefer-transcoding behavior every time they fire up a new client.

I know you can use tricks like tautulli events to terminate transcode streams but they're difficult to deploy and a bad UX for the users even at their best. Better to have Plex tell users something like "This content can't be played at your preferred bitrate X, would you like to use more data to play at full bitrate Y? Yes/No/Always"

My i7-8700t supports GVT-g which lets me split up the igpu for passthrough. I have a Windows VM with HW accel and a Linux VM with HW accel running off a single optiplex micro. Both vms are doing lots of video encoding.
I do not know if it enters the definition but it's my first step for trying "dangerous" stuff, like debugging a macOS kernel extension, or installing an exotic OS.

And of course for learning. For example you can learn a lot about operating systems if you can just run any older version at your will.

Also, you are obviously speaking of virtualization of a given hardware platform but a lot of stuff is modeled as a "virtual machine" in the generalized sense - e.g. the pickle Python format.

Currently, I'm not using them that much. However, I use containers intensively for some workloads like services on my UnRaid server or for development.
Yeah, I'll spin up a VM every once in a while on UnRaid but by and large I only use docker containers. I think the last time I used a VM was a few years ago for some windows-only software I needed for a few hours.
Job provides Windows or Mac but I prefer to use Linux. So I installed Linux in VM and do all the work in it. VMWare Workstation is rock solid with great performance. I boot Windows, then Linux in VMWare Workstation, go full screen and never look at Windows again for the whole day.
My last job gave me a Mac and I installed Linux on it with rEFInd [1]. But of course this won't work on M1 macs. And sometimes there's "company policy" blocking it sadly.

[1] https://www.rodsbooks.com/refind/