1. 程式人生 > >ubuntu下用libvirt安裝kvm虛擬機器時找不到/bin/qemu-kvm問題解決

ubuntu下用libvirt安裝kvm虛擬機器時找不到/bin/qemu-kvm問題解決

啟動虛擬機器的時候老出現:error: Cannot check QEMU binary /bin/qemu-kvm: No such file or directory

我用的是以下xml配置檔案

<domain type='kvm'>
    <name>rheltest</name>
    <uuid>32b95fab-6d78-4e28-beca-2c3988ff8cfe</uuid>
    <memory unit='KiB'>1048576</memory>
    <currentMemory unit='KiB'>1048576</currentMemory>
    <vcpu placement='static'>1</vcpu>
    <os>
        <type arch='x86_64' machine='pc-1.2'>hvm</type>
        <boot dev='cdrom'/>
        <boot dev='hd'/>
    </os>
    <features>
        <acpi/>
        <apic/>
        <pae/>
    </features>
    <clock offset='utc'/>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>restart</on_crash>
    <devices>
        <emulator>/bin/qemu-kvm</emulator>
        <disk type='file' device='disk'>
            <driver name='qemu' type='qcow2'/>
            <source file='/home/lisp/code/auto-rhel/virt/rheltest'/>
            <target dev='hda' bus='ide'/>
            <address type='drive' controller='0' buss='0' target='0' unit='0'/>
        </disk>
        <disk type='file' device='cdrom'>
            <driver name='qemu' type='raw'/>
            <source file='/home/lisp/os.iso/rhelcustom.iso'/>
            <target dev='hdc' bus='ide'/>
        <readonly/>
        </disk>
        <controller type='usb' index='0'>
            <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
        </controller>
        <controller type='ide' index='0'>
            <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
        </controller>
        <interface type='bridge'>
            <mac address='52:54:00:78:f9:59'/>
            <source bridge='virbr0'/>
            <model type='virtio'/>
            <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
        </interface>
        <input type='mouse' bus='ps2'/>
        <graphics type='vnc' port='-1' autoprot='yes'/>
        <memballoon model='virtio'>
            <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
        </memballoon>
    </devices>
</domain>

在沒有找到/bin/qemu-kvm這個檔案,後來才知道,對ubuntu的應該對應是/usr/bin/qemu這個檔案,把上面xml配置檔案對應的那行改為如下就行了
<emulator>/usr/bin/qemu</emulator>