Skip to content

elbepack: add support for base images#461

Open
kanavin wants to merge 2 commits into
Linutronix:masterfrom
kanavin:base-image
Open

elbepack: add support for base images#461
kanavin wants to merge 2 commits into
Linutronix:masterfrom
kanavin:base-image

Conversation

@kanavin
Copy link
Copy Markdown
Contributor

@kanavin kanavin commented May 21, 2026

This is very much a demo/proof-of-concept/starting point for discussion and further improvements. Particularly there is no documentation or tests, and the code contains several hardcoded assumptions (e.g. about the image format, partitions layout, etc.)

The code replaces the debootstrap step with mounting and copying the content of the base image instead, if base image is found in the xml spec.

I've also added two demonstration xmls, which are copies of simple validation image xml with some tweaks to allow staged image builds.

Demo:

    $ ./elbe --stacktrace-on-error initvm submit --skip-build-bin --skip-build-sources tests/simple-validation-image-base.xml
    $ ./elbe --stacktrace-on-error initvm submit --skip-build-bin --skip-build-sources --base-image ./elbe-build-20260520-183738/sda.img tests/simple-validation-image-extended.xml

kanavin added 2 commits May 21, 2026 13:49
This takes an image provided on command line and uploads
it into qemu using the same mechanism as cdrom uploads.
It doesn't take too long: a few seconds for the simple validation image.

The code to actually use that upload is added in the following commit.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
This is very much a demo/proof-of-concept/starting point for discussion and further improvements.
Particularly there is no documentation or tests, and the code contains several
hardcoded assumptions (e.g. about the image format, partitions layout, etc.)

The code replace the debootstrap step with mounting and copying the content of the
base image instead, if base image is found in the xml spec.

I've also added two demonstration xmls, which are copies of simple validation image xml
with some tweaks to allow staged image builds.

Demo:

$ ./elbe --stacktrace-on-error initvm submit --skip-build-bin --skip-build-sources tests/simple-validation-image-base.xml
$ ./elbe --stacktrace-on-error initvm submit --skip-build-bin --skip-build-sources --base-image ./elbe-build-20260520-183738/sda.img tests/simple-validation-image-extended.xml

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Copy link
Copy Markdown
Contributor

@t-8ch t-8ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also need a way to make the SBOMs work correctly for a layered image.

The first commit message talks about "qemu". This should be "initvm" I think.

Comment thread elbepack/initvmaction.py
f = add_argument('--build-sdk', dest='build_sdk', action='store_true', default=False,
help="Also make 'initvm submit' build an SDK.")(f)

f = add_argument('--base-image', dest='base_image', default=None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default=None is the default and can be dropped.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you trim down these test images to the bare minimum to show and test the feature?
Right now it is hard to see what is necessary and what just copied.

Comment thread elbepack/initvmaction.py
help="Also make 'initvm submit' build an SDK.")(f)

f = add_argument('--base-image', dest='base_image', default=None,
help='Use a base image instead of debootstrap')(f)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making the base image usage explicit in the XML.
Maybe as a new type of debootrstrap?

<debootstrap>
   <type>base-image</type>
</debootstrap>

And it should be possible to specify the base image in the XML directly, possibly to be overwritten by --base-image.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree about specifying base image usage explicitly and will add that, but I'm less certain about putting the default path to it into the XML.

If it's in the XML as an absolute path, that makes XML not usable in iterative development (where base images are in timestamped directories), or anywhere outside of the exact CI environment where that path can be fulfilled. If it's a relative path, then it isn't clear relative to what the image should be, and the image name is still hardcoded and must match exactly. I feel providing it over command line is both more flexible and user-friendly (elbe would error out if the xml says base image must be used, but none was given on the command line).

I'll leave the path in xml out for now, and we can add it later if a clear use case emerges. I think it would be much more useful to allow specifying a http link to the image in the xml, so that it would download the default image (for example, published by Linutronix to customers) unless the user says otherwise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was for the base image location in the XML to be optional.
If it makes sense for the user to specify they could do so.
But let's postpone this as you suggested, we can always add it later.

ep.xml.set_base_image(
path.join(
ep.builddir,
'uploaded_base_image.img'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lot of newlines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a copy paste of set_upload_cdrom(), which has similar odd newlines (and it's elsewhere in the file too). I'd rather be consistent with existing code.

Comment thread elbepack/rfs.py
do(['mkdir', '-p', base_image_mount])
with losetup(base_image_file) as loopdev:
with mount(loopdev+'p1', base_image_mount):
do(['cp', '-a', base_image_mount, self.path])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./elbe --stacktrace-on-error initvm submit --skip-build-bin --skip-build-sources --base-image ./elbe-build-20260520-183738/sda.img tests/simple-validation-image-extended.xml

I strongly prefer to only allow special rootfs archives as base, and not arbitrary disk images.
For example a tar archive, similar to what ELBE can already emit. See examples/x86_64-docker.xml.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, yes. Then perhaps the nomenclature (options, variables, xml entries) should not be talking about images at all, but rather root filesystems?

E.g. command line option: --base-rootfs-archive path/to/tarball

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's quite a mouthful and I don't really like it, but I don't have something clearly better.
Maybe "base layer"?
But we can do the naming when everything else is finished and we know what was actually built.
Your choice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I'll stick with base images for now.

Comment thread elbepack/soapclient.py
Comment thread elbepack/rfs.py
'#!/bin/sh\nexit 101\n')
self.debootstrap(arch)
self.fresh_debootstrap = True
self.need_dumpdebootstrap = True
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this into a helper function first?
If you have some preparatory cleanup commits I'm happy to apply those directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants