我设法使用以下命令在 qemu 中运行 osx guest 虚拟机:
// create the virtual image
$ qemu-img create -f qcow2 mac_hdd.img 35G
// .. install osx ...
// start the guest
$ qemu-system-x86_64 -enable-kvm -m 2048 -cpu core2duo -machine q35 \
-usb -device usb-kbd -device usb-mouse \
-device isa-applesmc,osk="XXXXXXXXredactedXXXXXXXX" \
-kernel ./chameleon_svn2360_boot -smbios type=2 \
-device ide-drive,bus=ide.2,drive=MacHDD -drive id=MacD,if=none,index=2,file=mac_hdd.img \
-netdev user,id=hub0port0 -device e1000-82545em,netdev=hub0port0,id=mac_vnet0 \
-monitor stdio
客人运行良好;但我也希望能够从 virt-manager 控制它,所以我执行了转换工具,如下所示:
$ cat > mac_hdd.args <<EOF
// herestring of the arguments
EOF
$ virsh domxml-from-native qemu-argv mac_hdd.args > osx10.8.3.xml
// as root
# virsh define osx10.8.3.xml
这会生成以下配置:
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>unnamed</name>
<uuid>7872c6ca-8c58-4eee-801b-b070a2b06abb</uuid>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='q35'>hvm</type>
<kernel>./chameleon_svn2360_boot</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>qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='./mac_hdd.img'/>
<target dev='hdc' bus='ide'/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<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='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='sdl'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
</video>
<memballoon model='none'/>
</devices>
<qemu:commandline>
<qemu:arg value='-device'/>
<qemu:arg value='usb-kbd'/>
<qemu:arg value='-device'/>
<qemu:arg value='usb-mouse'/>
<qemu:arg value='-device'/>
<qemu:arg value='isa-applesmc,osk="XXXXXXredactedXXXXXXXquot;'/>
<qemu:arg value='-smbios'/>
<qemu:arg value='type=2'/>
<qemu:arg value='-device'/>
<qemu:arg value='ide-drive,bus=ide.2,drive=MacHDD'/>
<qemu:arg value='-netdev'/>
<qemu:arg value='user,id=hub0port0'/>
<qemu:arg value='-device'/>
<qemu:arg value='e1000-82545em,netdev=hub0port0,id=mac_vnet0'/>
</qemu:commandline>
</domain>
不幸的是,这不起作用(请不要介意相对路径,我修复了这个问题);一旦我启动虚拟机,我就会收到错误cannot find drive MacHDD
;然后我尝试在定义<alias>MacHDD</alias>
中添加 an <disk>
,但仍然生成相同的错误。
如果我删除:
<qemu:arg value='-device'/>
<qemu:arg value='ide-drive,bus=ide.2,drive=MacHDD'/>
根据定义,虚拟机启动,但无法在 BIOS 屏幕上启动。
有办法做到这一点吗?我在 Fedora 21 上使用 libvirt-1.2.9.2