Virtualbox

防止 libvirtd 修改文件屬性

  • January 28, 2014

我有一個在和.vdi之間共享的磁碟文件。libvirtd``VirtualBox

每次我使用 啟動程序時libvirtd,文件的所有者.vdi都設置為 root。

我想知道它是否可以配置?我知道這可能是一項安全功能,但我希望禁用它。

編輯

執行 Arch Linux,最新

libvirt 1.2.1-1
libvirt-glib 0.1.7-2
libvirt-python 1.2.1-1

如果您查看文件內部,/etc/libvirt/qemu.conf您會注意到此部分:

# The user for QEMU processes run by the system instance. It can be
# specified as a user name or as a user id. The qemu driver will try to
# parse this value first as a name and then, if the name doesn't exist,
# as a user id.
#
# Since a sequence of digits is a valid user name, a leading plus sign
# can be used to ensure that a user id will not be interpreted as a user
# name.
#
# Some examples of valid values are:
#
#       user = "qemu"   # A user named "qemu"
#       user = "+0"     # Super user (uid=0)
#       user = "100"    # A user named "100" or a user with uid=100
#
#user = "root"

# The group for QEMU processes run by the system instance. It can be
# specified in a similar way to user.
#group = "root"

您可以將userand更改為group您想要的任何內容,這樣就libvirtd可以停止竊取所有權。

動態所有權

您可能需要在文件中設置另一個選項qemu.conf以禁止qemu更改文件的所有權.img

dynamic_ownership=0

此 libvirt 送出日誌中提到了此選項:“ Don’t chown qemu saved image back to root after save if dynamic_ownership=0 ”。這個開關的一個例子在實際中是qemu.conf可用的,你可以看到下面的關鍵部分:

# Whether libvirt should dynamically change file ownership
# to match the configured user/group above. Defaults to 1.
# Set to 0 to disable file ownership changes.
@!@
if configRegistry.get( 'uvmm/kvm/qemu/dynamic_ownership' ):
   if configRegistry.is_false( 'uvmm/kvm/qemu/dynamic_ownership' ):
       print 'dynamic_ownership = 0'
   else:
       print 'dynamic_ownership = 1'
else:
   print '#dynamic_ownership = 1'
@!@

參考

引用自:https://unix.stackexchange.com/questions/110357