====== Websocket Communication ======
===== Goals =====
We want our virtualization platform to use noVNC web-based consoles and have support for serial communication.
We'll be doing this using Qemu VNC UNIX websockets. It may be easier to try with a normal IP-based socket first, then convert your code to use UNIX sockets.
There is probably two ways this can be implemented, 1) we use websockets in qemu and proxy it to the client; and 2) we use raw communication between our app and qemu, and proxy that over websockets to the client.
I'd prefer we handle all communication in the same flask app than use a proxy process that requires an additional port to be opened. This way authentication would be easier and contained in the same app?
===== POC Process =====
* Flask app to forward websock communication from VM to browser window
* noVNC
* Get basic forwarding of websock communication working with noVNC
* Opening multiple browser windows must work
* serial console
* Get basic forwarding of websock communication working with xtermjs
* Opening multiple browser window must work
* Add very basic test:test authentication
* Protect endpoint
===== Useful Links =====
* https://github.com/cs01/pyxterm.js/blob/master/pyxtermjs/app.py
* https://github.com/novnc/noVNC/issues/184
* https://github.com/NaughtyCodes/FlaskSocketIoWithTCP/blob/master/app/app.py
* https://github.com/VietHTran/Ganbare/blob/83cd1b39ccae0e5f324941f15911413ccb769888/console/client.py
* https://github.com/search?q=flask+socketio+tcp&type=Code
* Socket authentication https://stackoverflow.com/questions/31218047/flask-socketio-authenticate-on-connect-event-by-sending-token
* https://github.com/m0udd/uCAB/blob/ad3124fe9fd9a127df712ea078a4ebfa42506aab/Serveur/Embedded_uCAB_RPI/uCAB.py
* https://github.com/RaitoBezarius/massive-octo-archer/blob/306b1af6ffdad247defd36357a0372d5d74ea78d/Website/run_website.py
===== Testing =====
Basic noVNC testing with an IP-based socket...
qemu-system-x86_64 -m 512 --enable-kvm -vnc :0,websocket
python -m http.server
http://localhost:8000/vnc.html
We however need the above to work with UNIX sockets...
qemu-system-x86_64 -m 512 --enable-kvm -vnc /tmp/test.sock,websocket
For serial...
-chardev socket,id=serial0,path=/tmp/ws-serial.sock,server,nowait,websocket -serial chardev:serial0