Signed-off-by: Stefan Hanreich <s.hanre...@proxmox.com> Signed-off-by: Alexandre Derumier <aderum...@odiso.com> --- PVE/API2/Qemu.pm | 6 ++++++ PVE/QemuServer.pm | 15 +++++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 38bdaab..a0f8243 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -991,6 +991,8 @@ __PACKAGE__->register_method({ eval { PVE::QemuServer::template_create($vmid, $restored_conf) }; warn $@ if $@; } + + PVE::QemuServer::create_ifaces_ipams_ips($restored_conf, $vmid) if $unique; }; # ensure no old replication state are exists @@ -1066,6 +1068,8 @@ __PACKAGE__->register_method({ } PVE::AccessControl::add_vm_to_pool($vmid, $pool) if $pool; + + PVE::QemuServer::create_ifaces_ipams_ips($conf, $vmid); }; PVE::QemuConfig->lock_config_full($vmid, 1, $realcmd); @@ -3763,6 +3767,8 @@ __PACKAGE__->register_method({ PVE::QemuConfig->write_config($newid, $newconf); + PVE::QemuServer::create_ifaces_ipams_ips($newconf, $vmid); + if ($target) { # always deactivate volumes - avoid lvm LVs to be active on several nodes PVE::Storage::deactivate_volumes($storecfg, $vollist, $snapname) if !$running; diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index d157f9e..7248346 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -8629,4 +8629,19 @@ sub del_nets_bridge_fdb { } } +sub create_ifaces_ipams_ips { + my ($conf, $vmid) = @_; + + return if !$have_sdn; + + foreach my $opt (keys %$conf) { + if ($opt =~ m/^net(\d+)$/) { + my $value = $conf->{$opt}; + my $net = PVE::QemuServer::parse_net($value); + eval { PVE::Network::SDN::Vnets::add_next_free_cidr($net->{bridge}, $conf->{name}, $net->{macaddr}, $vmid, undef, 1) }; + warn $@ if $@; + } + } +} + 1; -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel