mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-10 01:18:03 +03:00
serialcon: Release the text console when the VM window is closed (bz 1016445)
This commit is contained in:
parent
5798c5b9b4
commit
bcfa8d287f
@ -1107,6 +1107,9 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
self.viewer_connected = False
|
||||
self.leave_fullscreen()
|
||||
|
||||
for serial in self.serial_tabs:
|
||||
serial.close()
|
||||
|
||||
def update_widget_states(self, vm, status_ignore):
|
||||
runable = vm.is_runable()
|
||||
pages = self.widget("console-pages")
|
||||
@ -1533,22 +1536,11 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
title = Gtk.Label(label=name)
|
||||
self.widget("console-pages").append_page(serial.box, title)
|
||||
self.serial_tabs.append(serial)
|
||||
serial.open_console()
|
||||
|
||||
serial.open_console()
|
||||
page_idx = self.serial_tabs.index(serial) + CONSOLE_PAGE_OFFSET
|
||||
self.widget("console-pages").set_current_page(page_idx)
|
||||
|
||||
def _close_serial_tab(self, serial):
|
||||
if not serial in self.serial_tabs:
|
||||
return
|
||||
|
||||
page_idx = self.serial_tabs.index(serial) + CONSOLE_PAGE_OFFSET
|
||||
self.widget("console-pages").remove_page(page_idx)
|
||||
|
||||
serial.cleanup()
|
||||
self.serial_tabs.remove(serial)
|
||||
|
||||
|
||||
def populate_serial_menu(self, src):
|
||||
for ent in src:
|
||||
src.remove(ent)
|
||||
|
@ -50,6 +50,8 @@ class ConsoleConnection(vmmGObject):
|
||||
self.vm = None
|
||||
self.conn = None
|
||||
|
||||
def is_open(self):
|
||||
raise NotImplementedError()
|
||||
def open(self, dev, terminal):
|
||||
raise NotImplementedError()
|
||||
def close(self):
|
||||
@ -70,6 +72,9 @@ class LocalConsoleConnection(ConsoleConnection):
|
||||
self.source = None
|
||||
self.origtermios = None
|
||||
|
||||
def is_open(self):
|
||||
return self.fd is not None
|
||||
|
||||
def open(self, dev, terminal):
|
||||
if self.fd is not None:
|
||||
self.close()
|
||||
@ -192,6 +197,9 @@ class LibvirtConsoleConnection(ConsoleConnection):
|
||||
libvirt.VIR_STREAM_EVENT_HANGUP)
|
||||
|
||||
|
||||
def is_open(self):
|
||||
return self.stream is not None
|
||||
|
||||
def open(self, dev, terminal):
|
||||
if self.stream:
|
||||
self.close()
|
||||
@ -202,10 +210,9 @@ class LibvirtConsoleConnection(ConsoleConnection):
|
||||
if not name:
|
||||
raise RuntimeError(_("Cannot open a device with no alias name"))
|
||||
|
||||
self.stream = self.conn.get_backend().newStream(
|
||||
libvirt.VIR_STREAM_NONBLOCK)
|
||||
|
||||
self.vm.open_console(name, self.stream)
|
||||
stream = self.conn.get_backend().newStream(libvirt.VIR_STREAM_NONBLOCK)
|
||||
self.vm.open_console(name, stream)
|
||||
self.stream = stream
|
||||
|
||||
self.stream.eventAddCallback((libvirt.VIR_STREAM_EVENT_READABLE |
|
||||
libvirt.VIR_STREAM_EVENT_ERROR |
|
||||
@ -379,13 +386,18 @@ class vmmSerialConsole(vmmGObject):
|
||||
self.terminal = None
|
||||
self.box = None
|
||||
|
||||
def close(self):
|
||||
if self.console:
|
||||
self.console.close()
|
||||
|
||||
def show_error(self, msg):
|
||||
self.error_label.set_markup("<b>%s</b>" % msg)
|
||||
self.box.set_current_page(1)
|
||||
|
||||
def open_console(self):
|
||||
try:
|
||||
self.console.open(self.lookup_dev(), self.terminal)
|
||||
if not self.console.is_open():
|
||||
self.console.open(self.lookup_dev(), self.terminal)
|
||||
self.box.set_current_page(0)
|
||||
return True
|
||||
except Exception, e:
|
||||
|
Loading…
Reference in New Issue
Block a user