5

I have a hard time converting this QEMU command to a libvirt domain 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

It works perfectly if I call it from a Terminal (Ubuntu 14.10) but the virsh domxml-from-native qemu-argv fails for the MacHDD -device with this error:

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

(Note: of course I tried it with actual paths in place of the variables, same error - and if I remove the last two args it converts it to domain XML even with the variables included)

How could I solve this? Or what would be the equivalent of the last two args in domain xml? (Tried a lot of different combinations but couldn't get it work with libvirt/virsh)

EDIT

For the record this is what I get running virsh's domain-from-native command without the -device -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>

But I can't figure out what would be the equivalent of the -device -drive in this situation and I'm unable to create a VM from this domain xml.

Even without the MacHDD -device and -drive I get this error when I try to create the VM with $ virsh create

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

3 Answers 3

2

This works for me.

Change:

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

For

-drive id=MacHDD,if=ide,index=2,file="${vm_hdd_img_file_path}"
Sign up to request clarification or add additional context in comments.

Comments

1

TBH I'm not that familiar with libvirt, but wouldn't it be something like:

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

1 Comment

I think I tried something like this but I'll git it a try.
0

How about this?

<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'/>  

This is what kimchi has done, when I created VM using virt-manager. And thanks for that <qemu:commandline> thing. I was looking for it. If possible could you please point out any info on sound working with Mac OS X KVM?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.