请在下面找到我的dom xml示例。我正在运行命令virsh create,我收到此错误:
Unable to open file <json file located inside install_dir>
此文件的权限都很好。
qemu:commandline
标记下的参数是否需要特殊权限?无论我在本节中提到的参数和文件如何,我都会收到错误消息。
<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>my_instance</name>
<uuid>35615c44-b004-4b3f-9f42-da182b9662ee</uuid>
<memory unit='KiB'>786432</memory>
<currentMemory unit='KiB'>786432</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='armv7l' machine='my_machine'>hvm</type>
<kernel>/home/user/KernelPath/zImage</kernel>
<dtb>/home/user/DTPPath/emmc.dtb</dtb>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-arm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/user/Install_Dir/emmc.dat'/>
<target dev='sd' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
<controller type='scsi' index='0'/>
<serial type='pty'>
<target port='0'/>
</serial>
<serial type='pty'>
<target port='1'/>
</serial>
<serial type='pty'>
<target port='2'/>
</serial>
<serial type='pty'>
<target port='3'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='60316' autoport='no' websocket='60381' listen=''>
<listen type='address' address=''/>
</graphics>
<graphics type='sdl'/>
<video>
<model type='qxl'/>
</video>
<memballoon model='none'/>
</devices>
<qemu:commandline>
<qemu:arg value='-spdir'/>
<qemu:arg value='/home/user/Install_Dir'/>
<qemu:arg value='-show-cursor'/>
</qemu:commandline>
</domain>
答案 0 :(得分:0)
Libvirt将尝试使用专用用户帐户(通常为qemu:qemu
用户/组对)运行访客,而还应用SELinux或AppArmor规则限制它。通常,libvirt会自动设置文件所有权,并将SELinux / AppArmor策略设置为“正常工作”。 qemu命令行passthrough虽然是libvirt的黑盒子,但它不知道它需要你的/home/user/Install_Dir
路径。如果您的用户/组所有权是正确的,则可能是拒绝访问的SELinux / AppArmor策略。唯一可行的解决方法是禁用它们(通过/etc/libvirt/qemu.conf
),并接受较低的安全保护
答案 1 :(得分:0)
不建议使用root特权运行QEMU,因为从6.0.0版本开始,它不会剥离Linux功能。
在我的情况下是AppArmor。我想为虚拟机添加电池的SSDT文件。 AppArmor允许访问某些文件夹,而其他文件夹(例如/home/something
)则被禁止。 /var/lib/libvirt/images/
是允许的文件夹之一。尽管我将文件放在此处,但AppArmor策略仍然不允许使用该文件(如sudo cat /var/log/kern.log | grep -C 10 apparmor | grep -C 10 qemu
所示)。起作用的是在/var/lib/libvirt/images/SSDT1.dat rk
中添加/etc/apparmor.d/libvirt/TEMPLATE.qemu
,如下所示:
#
# This profile is for the domain whose UUID matches this file.
#
#include <tunables/global>
profile LIBVIRT_TEMPLATE flags=(attach_disconnected) {
#include <abstractions/libvirt-qemu>
/var/lib/libvirt/images/SSDT1.dat rk,
}