public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Friedrich Weber <f.weber@proxmox.com>
To: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH container] lxc start: warn in case of conflicting lxc.idmap entries
Date: Thu, 16 Mar 2023 16:07:34 +0100	[thread overview]
Message-ID: <c8b026af-8256-0493-f346-e56d0afab280@proxmox.com> (raw)
In-Reply-To: <20230316135936.hhr7jmw5nnkhdqa5@casey.proxmox.com>

Thanks for the review!

On 16/03/2023 14:59, Wolfgang Bumiller wrote:
> Both seem a bit excessive to me.
> 
> Let's look at the data:
> We have a set of ranges consisting of a type, 2 starts and a count.
> The types are uids and gids, so we can view those as 2 separate
> instances of sets of [ct_start, host_start, count].
> Since neither the container nor the host sides must overlap we can -
> again - view these as separate sets of container side [start, count] and
> host side [start, count].
> In other words, we can see the entire id map as just 4 sets of [start,
> count] ranges which must not overlap.
> 
> So I think all we need to do is sort these by the 'start' value, and for
> each element make sure that
> 
>      prevous_start + previous_count <= current_start
> 
> And yes, that means we need to sort $id_maps twice, once by ct id, once
> by host id, and then iterate and do the above check.
> 
> Should be much shorter (and faster).

Yeah, good point, splitting $id_maps into separate uid/gid maps, and 
then sorting+iterating twice (I'll call this the "sorting algorithm" 
below) does sound more understandable than the current ad-hoc approach, 
and faster too.

However, one small benefit of iterating over $id_maps in its original 
order (instead of sorting) is that the error message always references 
the *first* invalid map entry in the config, e.g. (omitting host uids 
for clarity)

   1) u 1000 <...> 100
   2) u 950 <...> 100
   3) u 900 <...> 100
   4) u 850 <...> 100

The sorting algorithm would error on entry 3, which might suggest to 
users that entries 1-2 are okay (which they are not). The current 
algorithm errors on line 2 already. Similar things would happen with 
interleaved uid/gid mappings, I guess.

But I'm not sure if this really matters to users. What do you think?




  reply	other threads:[~2023-03-16 15:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23 17:03 Friedrich Weber
2023-03-16 13:59 ` Wolfgang Bumiller
2023-03-16 15:07   ` Friedrich Weber [this message]
2023-03-16 16:09     ` Wolfgang Bumiller
2023-03-17  8:53       ` Friedrich Weber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8b026af-8256-0493-f346-e56d0afab280@proxmox.com \
    --to=f.weber@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=w.bumiller@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal