LibVirt Management from MacOS

Aug 23, 2021

Author: Brandon B. Jozsa
Updated: 03/09/22 - Updated tap source for MacOS Monterey w/potential error resolution

This will be a really quick post about how you can leverage virt-manager and virt-viewer from MacOS to manage libvirt virtual machines running on Red Hat systems.

In all honesty, this blog doesn't even really need to exist because it's really straight forward. But I am writing a whole series on how users can deploy and manage libvirt systems more easily with Redfish, and this tooling came to mind as a GUI alternative.


You can install both virt-manager and virt-viewer like this:
(Note: you must have homebrew installed first)

brew tap Krish-sysadmin/homebrew-virt-manager
brew install virt-manager virt-viewer


If you are using MacOS Monterey, you may encounter an issue like the following:

==> Installing virt-manager from krish-sysadmin/virt-manager
==> Patching
==> python3 -m venv --system-site-packages /usr/local/Cellar/virt-manager/2.2.1_3/libexec
==> /usr/local/Cellar/virt-manager/2.2.1_3/libexec/bin/pip install -v --no-deps --no-binary :all: --ignore-installed /private/tmp/virt-manager--libvirt-python-20220309-64893-9iygho/libvirt-python-7.8.0
Last 15 lines from /Users/bjozsa/Library/Logs/Homebrew/virt-manager/02.pip:
    running build
    /usr/local/Homebrew/Library/Homebrew/shims/mac/super/pkg-config --print-errors --atleast-version=0.9.11 libvirt
    /usr/local/Cellar/virt-manager/2.2.1_3/libexec/bin/python3.9 libvirt /usr/local/Cellar/libvirt/8.1.0/share/libvirt/api/libvirt-api.xml
    Found 493 functions in /usr/local/Cellar/libvirt/8.1.0/share/libvirt/api/libvirt-api.xml
    Found 0 functions in libvirt-override-api.xml
    Generated 403 wrapper functions
    Missing type converters:
    ERROR: failed virDomainSetLaunchSecurityState
    error: command '/usr/local/Cellar/virt-manager/2.2.1_3/libexec/bin/python3.9' failed with exit code 1
    Running install for libvirt-python: finished with status 'error'
ERROR: Command errored out with exit status 1: /usr/local/Cellar/virt-manager/2.2.1_3/libexec/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/virt-manager--libvirt-python-20220309-64893-9iygho/libvirt-python-7.8.0/'"'"'; __file__='"'"'/private/tmp/virt-manager--libvirt-python-20220309-64893-9iygho/libvirt-python-7.8.0/'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code ='"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-2f217mq7/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/Cellar/virt-manager/2.2.1_3/libexec/include/site/python3.9/libvirt-python Check the logs for full command output.
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/local/Cellar/virt-manager/2.2.1_3/libexec/bin/python3.9 -m pip install --upgrade pip' command.

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):

If you run into this issue, you will need to edit the .rb file for the virt-manager tap. This is according to an outstanding issue/PR in GitHub. So edit the following file, and make the following changes:

vi /usr/local/Homebrew/Library/Taps/krish-sysadmin/homebrew-virt-manager/virt-manager.rb 

You are going to change out the following:

    url ""
    sha256 "9d07416d66805bf1a17f34491b3ced2ac6c42b6a012ddf9177e0e3ae1b103fd5"

For the following lines:

    url ""
    sha256 "a21ecfab6d29ac1bdd1bfd4aa3ef58447f9f70919aefecd03774613f65914e43"

This will update the libvirt-python package to 8.1.0 from version 7.8.0.

Next, make sure to clean up the brew cache, and attempt to re-install:

brew cleanup
brew install virt-manager virt-viewer

And everything should work this time...


Once installed, you can run the following to leverage a qemu host over SSH.

virt-manager -c 'qemu+ssh://username@ =/var/run/libvirt/libvirt-sock'

Replace username and with your own values. That's it!

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.