[pve-devel] [PATCH proxmox-perl-rs v2 02/11] add Perl mapping for OCI container image parser/extractor

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Jun 25 10:10:11 CEST 2025


On Wed, Jun 25, 2025 at 09:59:08AM +0200, Filip Schauer wrote:
> On 24/06/2025 14:51, Wolfgang Bumiller wrote:
> > > +    #[export]
> > > +    pub fn parse_and_extract_image(
> > > +        oci_tar_path: &str,
> > > +        rootfs_path: &str,
> > > +    ) -> Result<Option<Config>, Error> {
> > > +        match proxmox_oci::parse_and_extract_image(oci_tar_path, rootfs_path) {
> > > +            Ok(config) => Ok(Some(config.unwrap_or_default())),
> > > +            Err(err) => match err {
> > > +                ProxmoxOciError::ParseError(ParseError::NotAnOciImage(_)) => Ok(None),
> > ^ Why are we doing this?
> 
> In the Perl code of the create_vm API method at PVE::API2::LXC, if a
> .tar file is used as the container template,
> PVE::RS::OCI::parse_and_extract_image is first attempted.
> It returns undef, when the .tar file is not an OCI image. Thus we deduce
> that the file is an LXC template. If some other kind of error occurrs,
> (e.g. I/O error) then the Perl code should die.
> 
> The point is, there needs to be a way to differentiate between the file
> actually being an LXC template, and some general failure.

Given how the errors in the oci-spec work I think it would make more
sense to do this detection separately by simply looking for an
`oci-layout` file in the archive (or looking for all of `oci-layout`,
`blobs`, `index.json` at only the top level).

An an error in the OCI data should not cause us to try to extract this
as a regular container either.

In the long run, this needs to be a separate content type anyway, since
don't want to just extract tar files like this. Rather, we want to later
also add the ability to use the base image via overlayfs.




More information about the pve-devel mailing list