[pve-devel] [PATCH v3 container 2/2] clear machine-id also after container clone
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Jun 10 13:51:42 CEST 2021
On May 27, 2021 11:26 am, Oguz Bektas wrote:
> pass $clone=1 to avoid removing the file. instead we truncate it to an
> empty file
>
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
> v2->v3:
> * clear machine-id at the end of clone task worker
>
> src/PVE/API2/LXC.pm | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index a9ea3a6..d5c12dc 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -1590,6 +1590,12 @@ __PACKAGE__->register_method({
> die "clone failed: $err";
> }
>
> + my $lastconf = PVE::LXC::Config->load_config($newid);
> + my $rootdir = PVE::LXC::mount_all($newid, $storecfg, $lastconf, 1);
> + my $lxc_setup = PVE::LXC::Setup->new($lastconf, $rootdir);
> + $lxc_setup->clear_machine_id($lastconf, 1);
> + PVE::LXC::umount_all($newid, $storecfg, $lastconf, 1);
this is dangerous - the config is not locked anymore at this point, and
we don't hold any other lock either!
another unrelated thing I just noticed - in case the clone fails, we
don't remove a potentially cloned firewall config..
> +
> return;
> };
>
> --
> 2.20.1
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
>
More information about the pve-devel
mailing list