]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer.pm
fix #2114: set correct link status on hotplug
[qemu-server.git] / PVE / QemuServer.pm
index 1dc3ca7fbef0cbd276292005264da143da5b952d..5422296602e8da2616194e69460e84f0fafab201 100644 (file)
@@ -3579,7 +3579,7 @@ sub config_to_command {
        next if !$d;
 
        my $pcie = $d->{pcie};
-       if($pcie){
+       if ($pcie) {
            die "q35 machine model is not enabled" if !$q35;
            # win7 wants to have the pcie devices directly on the pcie bus
            # instead of in the root port
@@ -3588,7 +3588,7 @@ sub config_to_command {
            } else {
                $pciaddr = print_pcie_addr("hostpci$i");
            }
-       }else{
+       } else {
            $pciaddr = print_pci_addr("hostpci$i", $bridges, $arch, $machine_type);
        }
 
@@ -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 $@;
@@ -5506,6 +5509,10 @@ sub vm_stop_cleanup {
 
        if ($conf->{ivshmem}) {
            my $ivshmem = PVE::JSONSchema::parse_property_string($ivshmem_fmt, $conf->{ivshmem});
+           # just delete it for now, VMs which have this already open do not
+           # are affected, but new VMs will get a separated one. If this
+           # becomes an issue we either add some sort of ref-counting or just
+           # add a "don't delete on stop" flag to the ivshmem format.
            unlink '/dev/shm/pve-shm-' . ($ivshmem->{name} // $vmid);
        }