[pve-devel] applied: [PATCH container] clone: randomize network MAC HW address of clone
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Mar 21 10:47:47 CET 2018
applied
On Tue, Mar 20, 2018 at 03:28:46PM +0100, Thomas Lamprecht wrote:
> adapt code from qemu-servers clone API path and generate a new
> randomized network hardware address (MAC) for the new clone to avoid
> address collisions
>
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
> 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 0c9ee40..0c834d4 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -1350,6 +1350,12 @@ __PACKAGE__->register_method({
> # TODO: allow bind mounts?
> die "unable to clone mountpint '$opt' (type $mp->{type})\n";
> }
> + } elsif ($opt =~ m/^net(\d+)$/) {
> + # always change MAC! address
> + my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');
> + my $net = PVE::LXC::Config->parse_lxc_network($value);
> + $net->{hwaddr} = PVE::Tools::random_ether_addr($dc->{mac_prefix});
> + $newconf->{$opt} = PVE::LXC::Config->print_lxc_network($net);
> } else {
> # copy everything else
> $newconf->{$opt} = $value;
> --
> 2.14.2
More information about the pve-devel
mailing list