Skip to contentSkip to conversation

Help needed with combining host and guest VM images in Yocto #qemu #qemux86-64

DISCUSSION Ryan Lovelett 2 participants 6 messages Feb 27, 2025 – Mar 5, 2025

lore
Share & tools
lore
#0 lore raw

I am trying to create a Yocto build that produces a host image containing QEMU and also embeds a guest image that Yocto builds. The idea is to have a host root filesystem that includes QEMU along with a separate "disk" holding the guest image. At boot, a systemd unit in the host would launch QEMU using the embedded guest image as its disk.

I would like to know if this conceptual approach would work and, if so, what the best practices are. In particular, I am looking for guidance on:

* The recommended method to build the guest image with the host image.
* The recommended method to include the guest image in the host image.

Any pointers or recommendations would be appreciated.

#1 lore raw
Quoted 9 lines · Ryan Lovelett via lists.yoctoproject.org

I am trying to create a Yocto build that produces a host image containing QEMU and also embeds a guest image that Yocto builds. The idea is to have a host root filesystem that includes QEMU along with a separate "disk" holding the guest image. At boot, a systemd unit in the host would launch QEMU using the embedded guest image as its disk.

I would like to know if this conceptual approach would work and, if so, what the best practices are. In particular, I am looking for guidance on:

The recommended method to build the guest image with the host image. The recommended method to include the guest image in the host image.

Any pointers or recommendations would be appreciated.

Look into meta-virtualization layer. There are reference images to build e.g. kvm-minimal-image
which could be your final image. Then build another image for guest maybe core-image-minimal or something
write a new image which inherits from kvm-minimal-image and adds core-image-minimal to install
also adds a systemd unit file which is perhaps another package added to IMAGE_INSTALL of your-image

Quoted 13 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#64880): https://lists.yoctoproject.org/g/yocto/message/64880
Mute This Topic: https://lists.yoctoproject.org/mt/111407542/1997914
Mute #qemu:https://lists.yoctoproject.org/g/yocto/mutehashtag/qemu Mute #qemux86-64:https://lists.yoctoproject.org/g/yocto/mutehashtag/qemux86-64 Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Thank you for the pointer to meta-virtualization and the reference images. I'm truly stumped right now. I'm struggling with what I don't know, and the part about "adding core-image-minimal to install" is the part I find most confusing. I really don't understand how to get an image to install another image. What does "installing" another image even look like? Is it a qcow file? A directory on the rootfs? Or something else entirely? I would appreciate further explanation on this point.

#3 lore raw

Just wanted to provide an update if anyone stumbles on this in the future. This is more or less what I've done to get it working. I created a recipe called core-image-minimal-disk-image_1.0.bb. The contents of that recipe is below:

SUMMARY = "Installs the disk image generated from core-image-minimal" LICENSE = "CLOSED"
SRC_URI = ""

DEPENDS += "core-image-minimal"

do_install () {
install -d ${D}/usr/share/vm
cp ${DEPLOY_DIR_IMAGE}/core-image-minimal-latest.ext4 ${D}/usr/share/vm/rootfs.raw || \
bbnote "Guest image not found. Make sure core-image-minimal is built."
}

FILES:${PN} += "/usr/share/vm/rootfs.raw"

The only other "extra" thing was I had to add a core-image-minimal.bbappend that added IMAGE_FSTYPES:append = " ext4" and IMAGE_LINK_NAME = "${PN}-latest".

I am still trying to improve it in 2 key ways:

* I would really love it if the rootfs.raw was just included as a partition on the final disk image. That way I could grow it with systemd-growfs or similar.
* Currently it is using the same machine, and thus the same, kernel as the host OS. Not a deal breaker but not ideal.

I do not think this is "right", or maybe it is, either way I'm still open to further constructive criticism.

#4 lore raw

Just a follow up. I was wrong the DEPENDS is not sufficient. I had to add do_install[depends] += "core-image-minimal:do_image_complete" to get it to work.

#5 lore raw
Quoted 2 lines · Ryan Lovelett via lists.yoctoproject.org

Just a follow up. I was wrong the DEPENDS is not sufficient. I had to add do_install[depends] += "core-image-minimal:do_image_complete"to get it to work.

yes thats task level dependency which is what you would need here.

Quoted 12 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#64924): https://lists.yoctoproject.org/g/yocto/message/64924
Unfollow This Topic: https://lists.yoctoproject.org/unft/111407542/1997914
Mute #qemu:https://lists.yoctoproject.org/g/yocto/mutehashtag/qemu Mute #qemux86-64:https://lists.yoctoproject.org/g/yocto/mutehashtag/qemux86-64 Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-