[KVM/QEMU] Convert complicated libvirt xml config to lxd --vm profile

Hi, I use LXD 3.20. Virtual machine creating very easy. And I want to try migrate vm from libvirt to lxd.

lxc launch m1 --empty --vm

But can you help me to understand how to make profile for virtual machine from this libvirt xml config? There is the way to do that? Some examples would help. Thank you!


<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
	macOS libvirt XML configuration.

        Run "virt-xml-validate macOS-libvirt-NG.xml" to validate this file.

	You may hot-redirect USB with ease from GNOME Boxes and other goodies.

	To install this file, you may place it at ~/.config/libvirt/qemu/
	and run: virsh define macOS-libvirt.xml.

	This configuration has been tested in Fedora 27 with stock QEMU-KVM.

	Move/rename images and loader/nvmram files and paths as you wish.

	Don't forget to replace CHANGEME with your values.

	Replace gnome-boxes path with libvirt path if you don't use it.

	Adjust memory and currentMemory to 3145728 if you want only 3 GiB.

	Consider removing some cpu features if your hardware lacks support.

	Replace spice with vnc if you prefer it.

	Current network configuration is a local bridge (192.157.12x.x).
	Change it to if you prefer a public bridge instead:
		Change interface to <interface type='user'>
		and remove the <source bridge='virbr0'/>
		Or use virt-manager to edit this line instead of virsh edit.

	Note: Default configuration caused severe clock problems
	under Fedora 27 w/ i7-5820K. This is because Darwin uses
	tsc (time since last tick) for time, and for me did not
	fall back to rtc in the event of a clock mismatch with
	libvirt's default time source. Therefore we must explicitly
	give the clock a tsc timer for kvm to pass to the guest.
	See comments on the <kvm> and <clock> attributes.
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>4</vcpu>
    <type arch='x86_64' machine='q35'>hvm</type>
    <loader readonly='yes' type='pflash'>/opt/libvirt-images/macos/OVMF_CODE.fd</loader>
<!-- Note: On Fedora 27 w/ an i7-5820K CPU and repository QEMU version as of 27-Jan-2018, the guest experienced severe clock issues. If you encounter these issues, try changing this to <hidden state ='off'/> -->
      <hidden state='on'/>
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>Penryn</model>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='x2apic'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='invtsc'/>
    <feature policy='require' name='aes'/>
    <feature policy='require' name='xsave'/>
    <feature policy='require' name='avx'/>
    <feature policy='require' name='xsaveopt'/>
    <feature policy='require' name='avx2'/>
    <feature policy='require' name='smep'/>
    <feature policy='require' name='vmware-cpuid-freq'/>
<!-- Note: To resolve clock issues experienced on Fedora 27 as described at top of file,
     we need to add a timer. Replace the clock offset line with,

     <clock offset='utc'>
       <timer name='tsc'/>

     Please remember to also change the kvm hidden state as well, as described above.
  <clock offset='utc'/>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='writeback'/>
      <source file='/opt/libvirt-images/macos/CloverNG.qcow2'/>
      <target dev='sda' bus='sata'/>
      <boot order='1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='writeback'/>
      <source file='/opt/libvirt-pool/mac_hdd_ng.img'/>
      <target dev='sdb' bus='sata'/>
      <boot order='2'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/opt/libvirt-images/macos/BaseSystem.img'/>
      <target dev='sdc' bus='sata'/>
      <boot order='3'/>
      <address type='drive' controller='0' bus='0' target='0' unit='2'/>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x7'/>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x0' multifunction='on'/>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x1'/>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x2'/>
    <interface type='bridge'>
      <mac address='52:54:00:8e:e2:66'/>
      <source bridge='virbr0'/>
      <target dev='tap0'/>
      <model type='vmxnet3'/>
      <address type='pci' domain='0x0000' bus='0x0' slot='0x02' function='0x0'/>
    <input type='keyboard' bus='usb'>
      <address type='usb' bus='0' port='2'/>
    <input type='mouse' bus='ps2'/>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='3'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='spice' autoport='yes'>
      <listen type='address'/>
    <sound model='ich9'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='5'/>
    <hub type='usb'>
      <address type='usb' bus='0' port='1'/>
    <memballoon model='none'/>
  <!-- Note: Enable the next line when SELinux is enabled -->
  <!-- seclabel type='dynamic' model='selinux' relabel='yes'/> -->
    <qemu:arg value='-device'/>
    <qemu:arg value='isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc'/>
    <qemu:arg value='-smbios'/>
    <qemu:arg value='type=2'/>
    <qemu:arg value='-cpu'/>
    <qemu:arg value='Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check'/>