Best practice to convert container to VM?

Hello all,
I know this isn’t officially supported, but I would be interested to understand how to best convert a container into a vm.
Background is that after a few years and migrations in between container hosts, containers will stop to work, or require changes to the host systemthat might not be compatible with newer containers.
In such a case it would be good to continue running the container as a VM with its own (legacy) kernel etc.
I’d be glad for any leads in that direction.

Could you run the container inside a VM with a legacy kernel?

I’m interested in that too. One use case is to do some testing inside a lightweight container, and then convert to a full-fat VM.

A more niche use case would be to take a zfs container image, copy it to a zfs pool in a raw partition in an empty VM image, and then make it bootable (e.g. install a kernel and grub). This would give me a zfs-on-root VM without the pain; this VM could then in turn be used to host incus containers.

I wondered if it’s possible to do an incus export from a container, tweak it a bit, then incus import it as a VM? Since incus import doesn’t have a --vm flag, I guess this must be in the export metadata.

Looking at incus export from a VM, it looks very VM-specific:

$ tar -tvzf jool.tar.gz
-rw-r--r-- root/root      5800 2024-03-22 13:39 backup/index.yaml
d--x------ root/root         0 2023-07-08 21:15 backup/virtual-machine
-rw------- lxd/root     540672 2024-03-03 15:23 backup/virtual-machine/OVMF_VARS.4MB.ms.fd
-rw-r--r-- root/root       692 2023-07-08 21:15 backup/virtual-machine/agent-client.crt
-rw------- root/root       288 2023-07-08 21:15 backup/virtual-machine/agent-client.key
-rw-r--r-- root/root       729 2023-07-08 21:15 backup/virtual-machine/agent.crt
-rw------- root/root       288 2023-07-08 21:15 backup/virtual-machine/agent.key
-r-------- root/root      5385 2024-03-22 13:39 backup/virtual-machine/backup.yaml
dr-x------ lxd/root          0 2024-03-03 15:23 backup/virtual-machine/config
-r-------- lxd/root          2 2024-03-03 15:23 backup/virtual-machine/config/agent-mounts.json
-rw-r--r-- lxd/root        836 2024-03-03 15:23 backup/virtual-machine/config/agent.conf
-r-------- lxd/root        729 2024-03-03 15:23 backup/virtual-machine/config/agent.crt
-r-------- lxd/root        288 2024-03-03 15:23 backup/virtual-machine/config/agent.key
dr-x------ lxd/root          0 2024-03-03 15:23 backup/virtual-machine/config/files
-rw-r--r-- lxd/root        299 2024-03-03 15:23 backup/virtual-machine/config/files/metadata.yaml
-rwx------ lxd/root        957 2024-03-03 15:23 backup/virtual-machine/config/install.sh
-r-x------ lxd/root   13959784 2024-02-09 12:00 backup/virtual-machine/config/lxd-agent
dr-x------ lxd/root          0 2024-03-03 15:23 backup/virtual-machine/config/nics
-r-------- lxd/root        692 2024-03-03 15:23 backup/virtual-machine/config/server.crt
dr-x------ lxd/root          0 2023-07-08 21:15 backup/virtual-machine/config/systemd
-r-x------ lxd/root        898 2024-03-03 15:23 backup/virtual-machine/config/systemd/lxd-agent-setup
-r-------- lxd/root        410 2024-03-03 15:23 backup/virtual-machine/config/systemd/lxd-agent.service
dr-x------ lxd/root          0 2023-07-08 21:15 backup/virtual-machine/config/udev
-r-------- lxd/root        215 2024-03-03 15:23 backup/virtual-machine/config/udev/99-lxd-agent.rules
-rw-r--r-- root/root       299 2023-07-08 07:49 backup/virtual-machine/metadata.yaml
lrwxrwxrwx root/root         0 2023-07-08 21:15 backup/virtual-machine/qemu.nvram -> OVMF_VARS.4MB.ms.fd
-rw------- root/root 10737418240 2024-03-22 13:39 backup/virtual-machine.img

(Aside: interesting that it chooses the lxd uid, which still exists on this machine as 999, rather than the incus uid 993)