[pve-devel] [PATCH qemu-server v2 1/2] fix #2114: set correct link status on hotplug

Dominik Csapak d.csapak at proxmox.com
Thu Feb 28 09:15:59 CET 2019


we also need to set the link status if the whole device changed,
otherwise a change of macaddress allows a network connection even
if link_down is set to 1

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
* move the qemu_set_link_status into vm_deviceplug and do correct error
  handling (iow. when setting the link status does not work, remove the
  device again)
 PVE/QemuServer.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6e56eda..5422296 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4140,7 +4140,10 @@ sub vm_deviceplug {
 
         my $netdevicefull = print_netdevice_full($vmid, $conf, $device, $deviceid, undef, $use_old_bios_files, $arch, $machine_type);
         qemu_deviceadd($vmid, $netdevicefull);
-        eval { qemu_deviceaddverify($vmid, $deviceid); };
+	eval {
+	    qemu_deviceaddverify($vmid, $deviceid);
+	    qemu_set_link_status($vmid, $deviceid, !$device->{link_down});
+	};
 	if (my $err = $@) {
 	    eval { qemu_netdevdel($vmid, $deviceid); };
 	    warn $@ if $@;
-- 
2.11.0





More information about the pve-devel mailing list