virsh from the libvirt package uses netcat to communicate with a remote server (in fact the command is executed locally on the remote server):
command -p port [-l username] hostname netcat -U socket
from: libvirt> Remote support> Extra parameters
However, the server I’m testing with runs Arch Linux; virt-manager, libvirt and its dependencies were installed through AUR; In the list of dependencies the OpenBSD implementation of netcat wasn’t listed. I’m aware Debian has ported it. The special feature in this netcat re-write is support for UNIX socket. As libvirt uses UNIX socket to communicate, the gnu-netcat cannot be used; it doesn’t understand the -U flag. The error happens when you try to connect to a remote server through a SSH tunnel:
virsh -d 5 -c qemu+ssh://somehost/system list
If the netcat binary on the remote host doesn’t understand -U, it will fail.
A quick dirty fix, more like a workaround, is to use a wrapper. socat‘s speciality is socket. We can use it like this:
- rename original netcat: mv /usr/bin/netcat /usr/bin/netcat.orig
- create the wrapper /usr/bin/netcat with as content:
#!/bin/sh if [ "$1" == "-U" ]; then socat - unix-client:$2 else netcat.orig $@ fi
And you’re ready to rock
On the long run libvirt shouldn’t rely on the OpenBSD implementation of netcat. As there’s only a few Linux distributions out there that adopted this rewrite. Perhaps give the user the freedom to choose which socket-tool to use in the configuration file?
No related posts.
