3

Remote virt-manager from Mac OS

 10 months ago
source link: https://gist.github.com/davesilva/da709c6f6862d5e43ae9a86278f79188
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

If you have a Linux machine with KVM on it, you can manage those VMs remotely from a Mac using virt-manager.

Step 1: Allow your user non-root access to KVM

SSH to the Linux machine and add your SSH user to the libvirt group

sudo usermod -a -G libvirt $(whoami)

Running id $(whoami) should list the libvirt group. You may also need to edit /etc/libvirt/libvirtd.conf to ensure that the socket has the right owner and permissions. Make sure you have these lines in there:

unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"

you should now be able to manage your VMs from the Linux machine without root access. If you open virt-manager locally on the Linux machine (assuming it's not headless) you will no longer be prompted to enter your password.

Step 2: Install virt-manager for Mac OS

Homebrew recipe for virt-manager

As stated in the readme, you can install it using

brew tap jeffreywildman/homebrew-virt-manager
brew install virt-manager virt-viewer

Step 3: Connect virt-manager to the Linux machine over SSH

First you need to ensure that you're using an SSH key rather than a password to log into the Linux machine. If you connect over ssh without specifying a password then you should be good.

If you try to tell virt-manager to connect over SSH by just specifying the hostname it might not work though. You'll see an error like End of file while reading data: nc: unix connect failed: No such file or directory: Input/output error. The file it's referring to is the libvirtd socket and the reason it can't find it is because it's looking in the wrong place. It's looking for the sock file in /usr/local/lib but it actually lives at /var/run/libvirt/libvirt-sock (at least it does on Debian). Luckily there's a query param you can pass in the SSH URL to override the socket location:

virt-manager --connect="qemu+ssh://USER@HOSTNAME/system?socket=/var/run/libvirt/libvirt-sock"

That should allow virt-manager to connect and let you manage your VMs.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK