console: Handle autoconnect=off for serial console too

Fixes: https://github.com/virt-manager/virt-manager/issues/584

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2024-11-11 14:04:37 -05:00
parent 97ab16a73d
commit dc1c998265
2 changed files with 38 additions and 33 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkNotebook" id="console-pages">
@ -253,32 +253,6 @@
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkButton" id="console-connect-button">
<property name="label" translatable="yes">_Connect to console</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="use-underline">True</property>
<signal name="clicked" handler="on_console_connect_button_clicked" swapped="no"/>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label">Connect</property>
</object>
<packing>
<property name="position">3</property>
<property name="tab-fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
@ -295,6 +269,32 @@
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkButton" id="console-connect-button">
<property name="label" translatable="yes">_Connect to console</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="use-underline">True</property>
<signal name="clicked" handler="on_console_connect_button_clicked" swapped="no"/>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Connect</property>
</object>
<packing>
<property name="position">3</property>
<property name="tab-fill">False</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="console-pages-atkobject">
<property name="AtkObject::accessible-name">console-pages</property>

View File

@ -20,13 +20,13 @@ from ..lib.keyring import vmmKeyring
# console-pages IDs
(_CONSOLE_PAGE_UNAVAILABLE,
_CONSOLE_PAGE_SERIAL,
_CONSOLE_PAGE_GRAPHICS) = range(3)
_CONSOLE_PAGE_GRAPHICS,
_CONSOLE_PAGE_CONNECT) = range(4)
# console-gfx-pages IDs
(_GFX_PAGE_VIEWER,
_GFX_PAGE_AUTH,
_GFX_PAGE_UNAVAILABLE,
_GFX_PAGE_CONNECT) = range(4)
_GFX_PAGE_UNAVAILABLE) = range(3)
class _TimedRevealer(vmmGObject):
@ -625,8 +625,8 @@ class vmmConsolePages(vmmGObjectUI):
if self._viewer:
self._viewer.console_grab_focus()
def _activate_gfx_connect_page(self):
self.widget("console-gfx-pages").set_current_page(_GFX_PAGE_CONNECT)
def _activate_console_connect_page(self):
self.widget("console-pages").set_current_page(_CONSOLE_PAGE_CONNECT)
def _viewer_is_visible(self):
is_visible = self.widget("console-pages").is_visible()
@ -659,7 +659,7 @@ class vmmConsolePages(vmmGObjectUI):
if (not self.vm.get_console_autoconnect() and
not self._viewer_connect_clicked):
self._activate_gfx_connect_page()
self._activate_console_connect_page()
return
self._activate_gfx_unavailable_page(
@ -856,6 +856,11 @@ class vmmConsolePages(vmmGObjectUI):
self.widget("serial-pages").append_page(serial.get_box(), title)
self._serial_consoles.append(serial)
if (not self.vm.get_console_autoconnect() and
not self._viewer_connect_clicked):
self._activate_console_connect_page()
return
serial.open_console()
page_idx = self._serial_consoles.index(serial)
self.widget("console-pages").set_current_page(_CONSOLE_PAGE_SERIAL)