libvirt qemu-system-arm, error: XML error: No PCI buses available

拜拜、爱过 提交于 2021-02-11 06:21:14

问题


I am trying to run a linux image i created with buildroot with libvirt.

If i use qemu-system-arm directly, everything works as intended:

/usr/bin/qemu-system-arm \
-M versatilepb \
-kernel output/images/zImage \
-dtb output/images/versatile-pb.dtb \
-drive index=0,file=output/images/rootfs.ext2,if=scsi,format=raw \
-append "root=/dev/sda console=ttyAMA0,115200" \
-net nic,model=rtl8139 \
-net user \
-nographic

However, when i try to create the xml from my qemu cmdline, it fails:

$ virsh domxml-from-native qemu-argv qemu.args                                                                     
error: XML error: No PCI buses available

I also tried to create a basic XML by hand:

<?xml version='1.0'?>
<domain type='qemu'>
        <name>Linux ARM</name>
        <uuid>ce1326f0-a9a0-11e3-a5e2-0800200c9a66</uuid>
        <memory>131072</memory>
        <currentMemory>131072</currentMemory>
        <vcpu>1</vcpu>
        <os>
                <type machine='versatilepb'>hvm</type>
                <kernel>zImage</kernel>
                <cmdline>root=/dev/sda console=ttyAMA0,115200</cmdline>
                <dtb>versatile-pb.dtb</dtb>
        </os>
        <devices>
                <disk type='file' device='disk'>
                        <source file='rootfs.ext2'/>
                        <target dev="sda" bus="scsi"/>
                </disk>
                <interface type='network'>
                        <source network='default'/>
                </interface>
        </devices>
</domain>

which fails with the same error:

$ virsh create guest-test.xml 
error: Failed to create domain from guest-test.xml
error: XML error: No PCI buses available

I already tried with the brand-new and latest libvirt-3.0.0, without any success

What do i need to change in my cmdline/xml?


回答1:


virsh domxml-from-native issue

The reason why the domxml-from-native command does not work is because the underlying code in libvirt that does the parsing expects the suffix of qemu-system- to be a canonical architecture name, and arm is not. In your case it would seem you want arm to map to armv7l which is a cannonical architecture name. You can pull this of by creating a soft-link qemu-system-armv7l that points you your system's qemu-system-arm and then use the location of the softlink in your qemu.args

code references

  • https://github.com/libvirt/libvirt/blob/v4.0.0/src/qemu/qemu_parse_command.c#L1906
  • https://github.com/libvirt/libvirt/blob/v4.0.0/src/util/virarch.c#L135

xml issues

Your xml is giving you the same error for multiple unrelated reasons. In the type element under os you need to specify arch="armv7l" (or some other canonical arm arch name). Note also that the kernel and dtb references need to be absolute paths or prefixed with a .. Finally some of the devices you have require a PCI bus and will not work with the machine you are going for. Consider the following alternative.

<domain type='qemu'>
  <name>Linux ARM</name>
  <uuid>ce1326f0-a9a0-11e3-a5e2-0800200c9a66</uuid>
  <memory>131072</memory>
  <currentMemory>131072</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch="armv7l" machine='versatilepb'>hvm</type>
    <kernel>/path/to/zImage</kernel>
    <cmdline>root=/dev/sda console=ttyAMA0,115200</cmdline>
    <dtb>/path/to/versatile-pb.dtb</dtb>
  </os>
  <devices>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"></driver>
      <source file="/path/to/root.qcow2"></source>
      <target dev="sda" bus="sd"></target>
    </disk>
    <serial type="tcp">
      <source mode="bind" host="localhost" service="4000"></source>
      <protocol type="telnet"></protocol>
    </serial>
  </devices>
</domain>


来源:https://stackoverflow.com/questions/42240121/libvirt-qemu-system-arm-error-xml-error-no-pci-buses-available

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!