]> git.proxmox.com Git - pve-container.git/commitdiff
fix #2453: actually reflect random MAC address selection in config
authorOguz Bektas <o.bektas@proxmox.com>
Wed, 6 Nov 2019 14:58:55 +0000 (15:58 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 6 Nov 2019 16:57:19 +0000 (17:57 +0100)
When creating/changing the network interface of a container, the
parse_lxc_network can have side-effects, e.g., it adds a new random
MAC hwaddr if the netX format-string did not had any. Thus, we need
to call print_lxc_network again in order to have the correct,
up-to-date, property string in the config file.

Apparently this was a regression introduced with the pending changes
series.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/LXC/Config.pm

index 2699d3d69a6e40333be040a1c89319a2a26829fe..7e51b8dd72b2196798538b24798ecab8dd7ec388 100644 (file)
@@ -1211,6 +1211,7 @@ sub vmconfig_hotplug_pending {
            } elsif ($opt =~ m/^net(\d+)$/) {
                my $netid = $1;
                my $net = $class->parse_lxc_network($value);
+               $value = $class->print_lxc_network($net);
                PVE::LXC::update_net($vmid, $conf, $opt, $net, $netid, $rootdir);
            } elsif ($opt eq 'memory' || $opt eq 'swap') {
                if (!$hotplug_memory_done) { # don't call twice if both opts are passed
@@ -1297,6 +1298,10 @@ sub vmconfig_apply_pending {
                            if !$class->is_volume_in_use($conf, $conf->{$opt}, 1, 1);
                    }
                }
+           } elsif ($opt =~ m/^net(\d+)$/) {
+               my $netid = $1;
+               my $net = $class->parse_lxc_network($conf->{pending}->{$opt});
+               $conf->{pending}->{$opt} = $class->print_lxc_network($net);
            }
        };
        if (my $err = $@) {