Unverified Commit 0e773a90 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Error handling during QMP disconnect (#1098)

parent 68ff6cdd
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -718,7 +718,13 @@ class BalloonMonitor:
                self.event_task.cancel()
            if self.qmp:
                logging.getLogger("qemu.qmp").setLevel(logging.WARNING)
                try:
                    await self.qmp.disconnect()
                except (OSError, StateError) as e:
                    # Expected during shutdown if QMP is already disconnected; safe to ignore.
                    log.debug("Ignoring QMP disconnect error during shutdown: %s", e)
                except Exception as e:
                    log.debug("QMP disconnect during shutdown failed: %s", e, exc_info=True)

# ==========================================================
# Main Execution
@@ -802,6 +808,9 @@ if __name__ == "__main__":
    except KeyboardInterrupt:
        log.debug("Monitor stopped by user.")
        sys.exit(0)
    except asyncio.CancelledError:
        log.info("Monitor exiting: cancelled")
        sys.exit(0)
    except ConnectionError as e:
        log.info("Monitor exiting: %s", e)
        sys.exit(0)