Signed-off-by: Alexandre Derumier <aderum...@odiso.com>
---
 PVE/API2/Qemu.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 24dba86..e8c7107 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -22,6 +22,7 @@ use PVE::GuestHelpers;
 use PVE::QemuConfig;
 use PVE::QemuServer;
 use PVE::QemuServer::Drive;
+use PVE::QemuServer::Ipam;
 use PVE::QemuServer::CPUConfig;
 use PVE::QemuServer::Monitor qw(mon_cmd);
 use PVE::QemuMigrate;
@@ -1365,6 +1366,23 @@ my $update_vm_api  = sub {
                        die "only root can modify '$opt' config for real 
devices\n";
                    }
                    $conf->{pending}->{$opt} = $param->{$opt};
+               } elsif ($opt =~ m/^net(\d+)/) {
+                   my $netid = $1;
+                   my $net = PVE::QemuServer::parse_net($param->{$opt});
+                   my $hostname = $param->{name} ? $param->{name} : 
$conf->{name};
+                   if ($conf->{pending}->{$opt}) {
+                       my $oldnet = 
PVE::QemuServer::parse_net($conf->{pending}->{$opt});
+                       my $pending_hostname = "pending.".$hostname;
+                       PVE::QemuServer::Ipam::update_net_ip($net, $oldnet, 
$pending_hostname, $pending_hostname, "vm:$vmid net:$netid pending:1");
+                   } elsif ($conf->{$opt}) {
+                       my $oldnet = PVE::QemuServer::parse_net($conf->{$opt});
+                       my $oldhostname = $conf->{name};
+                       PVE::QemuServer::Ipam::update_net_ip($net, $oldnet, 
$hostname, $oldhostname, "vm:$vmid net:$netid");
+                   } else {
+                       PVE::QemuServer::Ipam::update_net_ip($net, undef, 
$hostname, undef, "vm:$vmid net:$netid");
+                   }
+                   my $value = PVE::QemuServer::print_net($net);
+                   $conf->{pending}->{$opt} = $value;
                } else {
                    $conf->{pending}->{$opt} = $param->{$opt};
 
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to