Publish/Export lxd virtual machines for use with other systems (virt-manager/vmware)

Exporting an lxd vm to virt-manager

Thank goodness I work with @Teaton . The missing piece is in the firmware which is also in the exported tar.

# lxc export isg-mon-02 -v --compression gzip --instance-only isg-lxd-vm.tgz
# tar -xzvf isg-lxd-vm.tgz backup/virtual-machine.img
# qemu-img convert -f raw -O qcow2 backup/virtual-machine.img /var/lib/libvirt/images/isg-mon-02.qcow2
# tar -xzvf isg-lxd-vm.tgz backup/virtual-machine/qemu.nvram
# cp backup/virtual-machine/qemu.nvram /var/lib/libvirt/qemu/nvram/isg-mon-02.nvram

Then use virt-manager to create a new kvm and adjust the new disk and qemu/nvram settings

# virsh edit isg-mon-02
..... blah blahh .....
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.9'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/isg-mon-02.nvram</nvram>
    <boot dev='hd'/>
  </os>
..... more stuff .....
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/isg-mon-02.qcow2' index='1'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
    </disk>
....
virsh start isg-mon-02 --console

And that’s it. (aside from a bunch of other minor os adjustments).

2 Likes