xqemu / xqemu-manager

Simple graphical user interface to manage XQEMU
http://xqemu.com
GNU General Public License v2.0
34 stars 10 forks source link

Loss of QMP connection results in abort / crash of XQEMU-Manager #58

Open JayFoxRox opened 5 years ago

JayFoxRox commented 5 years ago

When pressing "Restart" it will crash XQEMU (See #50). When pressing the button again, XQEMU-Manager will try to send another QMP command before realizing that XQEMU crashed.

This leads to XQEMU-Manager aborting (closing):

Traceback (most recent call last):
  File "./main.py", line 426, in onRestartButtonClicked
    self.inst.restart()
  File "./main.py", line 330, in restart
    return self.run_cmd('system_reset')
  File "./main.py", line 318, in run_cmd
    resp = self._qmp.cmd_obj(cmd)
  File "xqemu-manager/qmp.py", line 174, in cmd_obj
    resp = self.__json_read()
  File "xqemu-manager/qmp.py", line 82, in __json_read
    data = self.__sockfile.readline()
  File "/usr/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
Aborted (core dumped)

or

Traceback (most recent call last):
  File "./main.py", line 426, in onRestartButtonClicked
    self.inst.restart()
  File "./main.py", line 330, in restart
    return self.run_cmd('system_reset')
  File "./main.py", line 320, in run_cmd
    raise Exception('Disconnected!')
Exception: Disconnected!
Aborted (core dumped)

We should handle the disconnection / loss of connection more gracefully.

This might also affect other QMP commands.