2014-10-08 161 views
3

我有一個很難該QEMU命令轉換爲libvirt的域XML:轉換QEMU命令行參數傳遞給libvirt的網域XML

qemu-system-x86_64 -enable-kvm \ 
-m 3072 \ 
-cpu core2duo \ 
-machine q35 \ 
-smp 2 \ 
-usbdevice keyboard \ 
-usbdevice mouse \ 
-vga std \ 
-device isa-applesmc,osk="${osx_osk_key}" \ 
-kernel "${chameleon_file_path}" \ 
-device ide-drive,bus=ide.2,drive=MacHDD \ 
-drive id=MacHDD,if=none,cache=none,file="${vm_hdd_img_file_path}" 
-netdev user,id=hub0port0 \ 
-device virtio-net,netdev=hub0port0,id=eth0 

它完美,如果我把它從一個終端(Ubuntu的14.10),但virsh domxml-from-native qemu-argv失敗的MacHDD -device與此錯誤:

error: internal error: missing index/unit/bus parameter in drive 'id=MacHDD,if=none,cache=none,file="${vm_hdd_img_file_path}"' 

(注:當然,我用實際路徑嘗試在地方的變量,同樣的錯誤的 - 如果我刪除最後一個有兩個參數它將它轉換甚至在包含變量的情況下對XML進行域化)

我該如何解決這個問題?或者什麼是域xml中最後兩個參數的等價物? (嘗試了很多不同的組合,但不能把它與libvirt的/的virsh工作)

編輯

對於這個記錄是我所得到的,而不-device運行的virsh的領域,從本地命令-drive

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> 
    <name>unnamed</name> 
    <uuid>38cafecb-4774-4590-83eb-e576a79aab93</uuid> 
    <memory unit='KiB'>3145728</memory> 
    <currentMemory unit='KiB'>3145728</currentMemory> 
    <vcpu placement='static'>2</vcpu> 
    <os> 
    <type arch='x86_64' machine='q35'>hvm</type> 
    <kernel>${chameleon_file_path}</kernel> 
    </os> 
    <features> 
    <acpi/> 
    </features> 
    <cpu mode='custom' match='exact'> 
    <model fallback='allow'>core2duo</model> 
    </cpu> 
    <clock offset='utc'/> 
    <on_poweroff>destroy</on_poweroff> 
    <on_reboot>restart</on_reboot> 
    <on_crash>destroy</on_crash> 
    <devices> 
    <emulator>/usr/bin/qemu-system-x86_64</emulator> 
    <controller type='sata' index='0'/> 
    <controller type='pci' index='0' model='pcie-root'/> 
    <controller type='pci' index='1' model='dmi-to-pci-bridge'/> 
    <controller type='pci' index='2' model='pci-bridge'/> 
    <input type='keyboard' bus='usb'/> 
    <input type='mouse' bus='usb'/> 
    <input type='mouse' bus='ps2'/> 
    <input type='keyboard' bus='ps2'/> 
    <graphics type='sdl'/> 
    <video> 
     <model type='vga' vram='9216' heads='1'/> 
    </video> 
    <memballoon model='none'/> 
    </devices> 
    <qemu:commandline> 
    <qemu:arg value='-device'/> 
    <qemu:arg value='isa-applesmc,osk=&quot;${osx_osk_key}&quot;'/> 
    <qemu:arg value='-netdev'/> 
    <qemu:arg value='user,id=hub0port0'/> 
    <qemu:arg value='-device'/> 
    <qemu:arg value='virtio-net,netdev=hub0port0,id=eth0'/> 
    </qemu:commandline> 
</domain> 

但我無法弄清楚什麼是在這種情況下,-device -drive相當於,我無法從該域的XML創建一個VM。

即使沒有MacHDD -device和A-驅動,當我嘗試用$ virsh create

error: Failed to create domain from libvirt.xml 
error: internal error: cannot load AppArmor profile 'libvirt-38cafecb-4774-4590-83eb-e576a79aab93' 

回答

1

TBH我不是那熟悉的libvirt創建VM我得到這個錯誤,但不會是什麼如:

<disk type='file' device='disk'> 
    <source file='/path/to/image.img'/> 
    <target dev='hda' bus='ide'/> 
    </disk> 
+0

我想我嘗試過這樣的事情,但我會試一試。 – 2014-10-25 07:00:06

0

這對我有用。

變化:

-drive id=MacHDD,if=none,cache=none,file="${vm_hdd_img_file_path}" 

對於

-drive id=MacHDD,if=ide,index=2,file="${vm_hdd_img_file_path}" 
0

這個怎麼樣?

<disk type='file' device='disk'> 
    <driver name='qemu' type='qcow2'/> 
    <source file='/home/vbox/mac_hdd_10.10Chimera410R1280x1024x32TV.img'/> 
    <target dev='hda' bus='ide'/> 
    <boot order='1'/> 
    <address type='drive' controller='0' bus='0' target='0' unit='0'/> 
</disk> 
<seclabel type='dynamic' model='apparmor' relabel='yes'/> 

這是kimchi所做的,當時我使用virt-manager創建了VM。並感謝那<qemu:commandline>的事情。我正在尋找它。如果可能的話,請指出有關使用Mac OS X KVM的聲音的任何信息?