virt-manager in MacOS

AxLabs
2 min readMar 16, 2021

Ok, imagine that you use Mac and want to create virtual machines (not containers!) in a Linux server. But, aren't you tired to do that manually, over the command line (a.k.a., SSH)?

Well, maybe not… or maybe yes... 🤔 😃

After years of typing commands in virsh I've got to the conclusion that I'm kind of too old for that 😅.

The question is: what's the alternative if you use MacOS? Is it possible to execute virt-manager in MacOS without relying on the ported version? If yes, how?

That's when I discovered the power of XQuartz project. 👏 🚀

Basically, XQuartz is a version of the X.Org X Window System that runs on MacOS. The advantage of that is to use X11 forwarding over SSH, telling your server "hey, if the program I'm executing has a graphical interface I'm able to render it here on my side — bring it on!".

Sounds sexy, huh? Yes… with that you can execute a program with a Graphical User Interface (GUI) in your Linux server, but operating in your MacOS — remotely. Here we will focus on virt-manager , but it applies to anything else… even a bitcoin-gui running in your private and (super) secure server.

Below I will describe the steps to:

  1. Allow X11 Forwarding in your Linux server (SSH daemon)
  2. Install QEMU-KVM and all dependencies in a Ubuntu
  3. Fix X11 keyboard mappings in your MacOS (ALT and CTRL keys compatibility)
  4. Run virt-manager using SSH X11 Forwarding

Enable X11 Forwarding

The first step is to log in to your Linux server and add (or change if already exists) the following line in the/etc/ssh/sshd_config file:

X11Forwarding yes

Install QEMU-KVM

Now, let's install all the required tools to create and run a full-fledged virtual machine:

sudo apt install qemu-kvm libvirt-bin bridge-utils virtinst virt-manager

Then you should add your user to some groups in order to properly manage the virtual resources using libvirt:

sudo usermod -aG libvirt $USER

sudo usermod -aG kvm $USER

Fix Keyboard Mappings in MacOS for X11

If it doesn't exist yet, create the file ~/.Xmodmap and add the following:

Run virt-manager through SSH

Ok… last but not least, here you go:

ssh -X <YOUR_LINUX_SERVER_HOSTNAME> virt-manager

Something like this will come up:

virt-manager main window

That's it! 🚀

You will be able to create virtual machines and manage all your virtualized resources on that QEMU/KVM instance. 😃

--

--

AxLabs

Breaking down the barrier to Web3, one dApp at a time.