Sounds like Network Manager messing the connection up when it enables wifi power management, the usual solution is to
sudo sed -i 's/wifi.powersave = 3/wifi.powersave = 2/' /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
systemctl restart network-manager.service
as I posted at...
If you are trying to access wifi in a vm you normally need to use a USB wifi device and tell the vm to allow the guest OS to control it. Most vm's created a virtual ethernet device on the guest that is bridged to the connection on the host OS