From c17ecca28dcaacfd2c9c0dc2b6de8aff28d800d3 Mon Sep 17 00:00:00 2001 From: Stefan Reiter Date: Wed, 18 Dec 2019 13:19:50 +0100 Subject: [PATCH] ui/vnc: reload IFrame-embedded noVNC on VM startup Avoids having to do the 'Console' -> 'Summary' -> 'Console' dance everytime the VM is started and the Console window is currently open. Signed-off-by: Stefan Reiter --- www/manager6/VNCConsole.js | 6 ++++++ www/manager6/qemu/Config.js | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/www/manager6/VNCConsole.js b/www/manager6/VNCConsole.js index 758b6839..039c9687 100644 --- a/www/manager6/VNCConsole.js +++ b/www/manager6/VNCConsole.js @@ -57,6 +57,12 @@ Ext.define('PVE.noVncConsole', { me.on('afterrender', function() { me.focus(); }); + }, + + reloadConsole: function() { + // reload IFrame content to forcibly reconnect VNC/xterm.js to VM + var box = this.down(); + box.getWin().location.reload(); } }); diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js index 58a1568c..8c15dadb 100644 --- a/www/manager6/qemu/Config.js +++ b/www/manager6/qemu/Config.js @@ -365,6 +365,7 @@ Ext.define('PVE.qemu.Config', { me.callParent(); + var prevQmpstatus = 'unknown'; me.mon(me.statusStore, 'load', function(s, records, success) { var status; var qmpstatus; @@ -412,6 +413,16 @@ Ext.define('PVE.qemu.Config', { shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running'); me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped'); consoleBtn.setDisabled(template); + + if (['prelaunch', 'stopped', 'suspended'].indexOf(prevQmpstatus) !== -1 + && qmpstatus === 'running') { + var con = me.down('#console'); + if (con) { + con.reloadConsole(); + } + } + + prevQmpstatus = qmpstatus; }); me.on('afterrender', function() {