It seems that my wireless network controller sometimes failed to work even when I use the method described below:
My wifi controller as in lspci is:
Ethernet controller: Intel Corporation Ethernet Connection I217-LM (rev 04)
Network controller: Intel Corporation Wireless 7260 (rev c3)
I will provide my observation and conjecture here ...
Sometimes when wireless network failed, usually it is when qubes have difficulty suspending all the vms at suspension within a short amount of time, because some of my VM were doing some CPU/memory intensive jobs when I suspend (for example, batch fedora updates, install part). I suspect that the netvm is just being suspended before its job is done.
Well, as it seems like a common problem and I am grateful that qubes has already solved tons of my problems, I do not expect the original problem will have a quick solution ... But I want a way to recover from the state.
The state is that sys-net cannot access to wifi, which is annoying. I tried killing and restarting sys-net. As far as I remember it worked one time, but other times it will not work and the sys-net will simple failed to boot (something like, in Qubes VM manager it becomes yellow, and then without becoming green it goes off as if it has not been started).
I tried detaching pci devices before shutting down sys-net. I cannot do it in GUI, so I use qvm-pci -d sys-net 03:00.0 and try detaching the network controllers. But the detaching and attaching fail with:
libxl: error: libxl_device.c:1269:libxl__wait_for_backend: Backend /local/domain/0/backend/pci/34/0 not ready
and the device is not visible in GUI! (It seems like a problem that xen failed but qubes gui has finished the transaction prematurely)
And the story goes the same.
Moreover, I have tried to change the netvm of sys-firewall to be none before I play with sys-net, but sometimes it also will not work, sometimes it fails with no reason (unknown error something like that), I tried changing the netvm via commandline and it fails with the same reason.
However, it seems when I have closed all the vms - actually maybe sys-firewall, when I close that, I can open sys-net with the network controllers and it runs without problems. But for qubes when you do this basically it is like rebooting since you are rebooting your worker vms actually ... It becomes inconvenient when you have 3 jobs to do at the same time, your 3+ vms are starting different project with several files open and suddenly wifi fxxk up and you will need to close everything and start over and ...
The report seems messy, so if anyone is interested in some of the details I can take time to try out how it works when I am free.
So here comes the problem: How can I recover without rebooting all my working vms when wifi fails?
It sounds strange, but when my wifi was working normally just now, and I typed the 4 lines that you provided me in dom0 terminal, I successfully reseted my netVM and network connection of all the other VMs works seamlessly.
It is not very easy to make failure of wifi controller happen deliberately, to see whether the four lines work when it fails ... And when failure happened in the past, what I did then that seems closest to what you have provided may be that, set the netvm of sys-firewall in the GUI to be none, and sometimes this failed with "unknown error". I never tried to use qvm-kill in the terminal, though - so when I use this in the GUI mode it does not work very well.
I am not very sure whether there is any difference between the effects when I use GUI or CLI, other than the visible ones, such as something just cannot be done in GUI (like live attaching/detaching PCI devices).