使用自定义qemu二进制文件与libvirt失败?
I have a locally built qemu. I am using libvirt python API to defineXML. I get the error:
我有一个本地建造的qemu。我使用libvirt python API来定义XML。我收到错误:
libvirt: error : internal error: Child process (LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /home/deepti/testqemu/bin/qemu-system-arm -help) unexpected exit status 126: libvirt: error : cannot execute binary /home/deepti/testqemu/bin/qemu-system-arm: Permission denied Traceback (most recent call last): File "testcustomQemu.py", line 70, in dom = conn.defineXML(xmlconfig) File "/home/deepti/.virtualenvs/testlibvirt/local/lib/python2.7/site-packages/libvirt.py", line 3685, in defineXML if ret is None:raise libvirtError('virDomainDefineXML() failed', conn=self) libvirt.libvirtError: internal error: Child process (LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /home/deepti/testqemu/bin/qemu-system-arm -help) unexpected exit status 126: libvirt: error : cannot execute binary /home/deepti/testqemu/bin/qemu-system-arm: Permission denied
libvirt:错误:内部错误:子进程(LC_ALL = C PATH = / usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin / home / deepti / testqemu / bin / qemu-system-arm -help)意外退出状态126:libvirt:错误:无法执行binary / home / deepti / testqemu / bin / qemu-system-arm:权限被拒绝回溯(最近一次调用最后一次):文件“ testcustomQemu.py“,第70行,在dom = conn.defineXML(xmlconfig)文件”/home/deepti/.virtualenvs/testlibvirt/local/lib/python2.7/site-packages/libvirt.py“,第3685行,如果ret为None,则为defineXML:raise libvirtError('virDomainDefineXML()failed',conn = self)libvirt.libvirtError:内部错误:子进程(LC_ALL = C PATH = / usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin / home / deepti / testqemu / bin / qemu-system-arm -help)意外退出状态126:libvirt:错误:无法执行binary / home / deepti / testqemu / bin / qemu-system-arm:权限被拒绝
The ownership for /home/deepti/testqemu
is root:root
. Changing the permission to +x
also does not work.
/ home / deepti / testqemu的所有权是root:root。将权限更改为+ x也不起作用。
What am I missing. How can I get my custom qemu to be taken?
我错过了什么如何才能获得我的自定义qemu?
My script and xml are as below:
我的脚本和xml如下:
import libvirt
import sys
xmlconfig = """<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>limom_instance</name>
<uuid>35615c44-b004-4b3f-9f42-da182b9662ef</uuid>
<memory unit='KiB'>786432</memory>
<currentMemory unit='KiB'>786432</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='armv7l' machine='limott'>hvm</type>
<kernel>/home/deepti/limom/FinalArtifacts/kerneldist1/zImage</kernel>
<dtb>/home/deepti/limom/FinalArtifacts/dtbdist1/emmc.dtb</dtb>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/home/deepti/testqemu/bin/qemu-system-arm</emulator>
<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>
<memballoon model='none'/>
</devices>
<qemu:commandline>
<qemu:arg value='-sdl'/>
<qemu:arg value='-show-cursor'/>
<qemu:arg value='-nographic'/>
<qemu:arg value='-sd'/>
<qemu:arg value='/home/deepti/limom/FinalArtifacts/emmc.dat'/>
</qemu:commandline>
</domain>"""
conn = libvirt.open('qemu:///system')
if conn == None:
print('Failed to open connection to qemu:///system')
exit(1)
uri = conn.getURI()
print('Canonical URI: '+uri)
dom = conn.defineXML(xmlconfig)
if dom == None:
print('Failed to define a domain from an XML definition')
exit(1)
conn.close()
1 个解决方案
#1
0
You're using the system instance of libvirtd, so the QEMU process will run as a qemu:qemu user/group pair. Home directories are normally configured so that other users cannot access any files they contain. IOW, qemu:qemu cannot read /home/deepti/, and thus cannot run the QEMU binary. You could either do "chmod o+x $HOME", or install QEMU in a place like /usr/local instead.
您正在使用libvirtd的系统实例,因此QEMU进程将作为qemu:qemu用户/组对运行。通常配置主目录,以便其他用户无法访问它们包含的任何文件。 IOW,qemu:qemu无法读取/ home / deepti /,因此无法运行QEMU二进制文件。你可以做“chmod o + x $ HOME”,或者在/ usr / local这样的地方安装QEMU。
Beware that if the host has SELinux or AppArmor active that may also cause permission problems when using QEMU binaries in unusual locations.
请注意,如果主机的SELinux或AppArmor处于活动状态,则在异常位置使用QEMU二进制文件时也可能会导致权限问题。
更多相关文章
- Django -表单无效但没有错误
- 套接字。接受错误24:对许多打开的文件
- Python之错误异常和文件处理
- django模板引擎有错误检查?
- 套接字错误“IP地址在其上下文中无效” - Python
- 无法安装ndg-httpsclient或者我的解决方案错误
- Python套接字代理示例,不断收到调用bind()的错误..为什么?
- 是什么导致了Python分割错误?
- Linux的文件权限