VNC 的 KVM unix 套接字文件权限

VNC 的 KVM unix 套接字文件权限

我正在使用 kvm-qemu/libvirtd 来处理一堆 kvm。我正在使用 vnc 作为图形界面。默认情况下,它监听 tcp 套接字。我想让它监听 unix 套接字。查看一些文档(http://libvirt.org/formatdomain.html) 我懂了:

“QEMU 不使用 listen/port,而是支持套接字属性,用于监听 unix 域套接字路径”

我使用以下 xml 进行了此设置:

<graphics type='vnc' socket='/tmp/lamptest.sock'/>

这是可行的,它创建了套接字,所有事情都通过它进行。但它没有我想要的权限。它有权限,这不允许我以我的用户身份使用 virt-manager:

srwxr-xr-x  1 libvirt-qemu kvm

相反,我希望套接字具有以下权限:

srwxrwx---  1 root libvirtd

我还没找到在 xml 中更改它的方法,而且我不想每次启动 kvm 时都手动更改它。有人知道是否可以在某处配置它吗?

编辑:

看看这个补丁关联,看来该功能不存在。我会仔细查看新版本的代码,看看它是否被添加了,但我猜我需要提交功能请求并编写一个 cron 来同时修复文件权限 :(

答案1

正在查看/etc/libvirt/libvirtd.conf

# UNIX socket access controls
#

# Set the UNIX domain socket group ownership. This can be used to
# allow a 'trusted' set of users access to management capabilities
# without becoming root.
#
# This is restricted to 'root' by default.
#unix_sock_group = "libvirt"

# Set the UNIX socket permissions for the R/O socket. This is used
# for monitoring VM status only
#
# Default allows any user. If setting group ownership may want to
# restrict this to:
#unix_sock_ro_perms = "0777"

# Set the UNIX socket permissions for the R/W socket. This is used
# for full management of VMs
#
# Default allows only root. If PolicyKit is enabled on the socket,
# the default will change to allow everyone (eg, 0777)
#
# If not using PolicyKit and setting group ownership for access
# control then you may want to relax this to:
#unix_sock_rw_perms = "0770"

# Set the name of the directory in which sockets will be found/created.
#unix_sock_dir = "/var/run/libvirt"

看起来unix_sock_group就是您想要的参数。不同发行版之间可能有所不同。

相关内容