首页 文章

使用自定义qemu二进制文件与libvirt失败?

提问于
浏览
1

我有一个本地建造的qemu . 我使用libvirt python API来定义XML . 我收到错误:

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:Permission denied Traceback(最近一次调用last):File “testcustomQemu.py”,第70行,在dom = conn.defineXML(xmlconfig)文件“/home/deepti/.virtualenvs/testlibvirt/local/lib/python2.7/site-packages/libvirt.py”,第3685行,在defineXML中如果ret为None: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:权限被拒绝

/home/deepti/testqemu 的所有权为 root:root . 将权限更改为 +x 也不起作用 .

我错过了什么如何才能获得我的自定义qemu?

我的脚本和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 回答

  • 0

    您正在使用libvirtd的系统实例,因此QEMU进程将作为qemu:qemu用户/组对运行 . 通常配置主目录,以便其他用户无法访问它们包含的任何文件 . IOW,qemu:qemu无法读取/ home / deepti /,因此无法运行QEMU二进制文件 . 你可以做“chmod o x $ HOME”,或者在/ usr / local这样的地方安装QEMU .

    请注意,如果主机的SELinux或AppArmor处于活动状态,则在异常位置使用QEMU二进制文件时也可能会导致权限问题 .

相关问题