serialcon: Fix serial reopening when VM reboots

This commit is contained in:
Cole Robinson 2010-06-23 13:05:09 -04:00
parent d052b6a829
commit 4570afd1dc
2 changed files with 20 additions and 12 deletions

View File

@ -1194,8 +1194,6 @@ class vmmDomain(vmmDomainBase):
"netRxRate" : 10.0,
}
self._update_status()
self.config.on_stats_enable_net_poll_changed(
self.toggle_sample_network_traffic)
self.config.on_stats_enable_disk_poll_changed(
@ -1217,6 +1215,7 @@ class vmmDomain(vmmDomainBase):
self._backend)
# Hook up our own status listeners
self._update_status()
self.connect("status-changed", self._update_start_vcpus)
##########################
@ -1959,6 +1958,11 @@ class vmmDomain(vmmDomainBase):
if status != self.lastStatus:
oldstatus = self.lastStatus
self.lastStatus = status
# Send 'config-changed' before a status-update, so users
# are operating with fresh XML
self.refresh_xml()
util.safe_idle_add(util.idle_emit, self, "status-changed",
oldstatus, status)

View File

@ -64,7 +64,9 @@ class vmmSerialConsole(gtk.HBox):
self.connect("realize", self.handle_realize)
self.connect("unrealize", self.handle_unrealize)
self.vm.connect("config-changed", self.update_tty_path)
self.vm.connect("status-changed", self.vm_status_changed)
self.update_tty_path(self.vm)
def handle_realize(self, ignore=None):
self.opentty()
@ -72,14 +74,14 @@ class vmmSerialConsole(gtk.HBox):
def handle_unrealize(self, src=None, ignore=None):
self.closetty()
def vm_status_changed(self, src, status, ignore):
def vm_status_changed(self, src, oldstatus_ignore, status):
if status in [ libvirt.VIR_DOMAIN_RUNNING ]:
self.opentty()
else:
self.closetty()
def get_tty_path(self):
serials = self.vm.get_serial_devs()
def update_tty_path(self, vm):
serials = vm.get_serial_devs()
for s in serials:
port = s[3]
path = s[2]
@ -87,25 +89,27 @@ class vmmSerialConsole(gtk.HBox):
if path != self.ttypath:
logging.debug("Serial console '%s' path changed to %s."
% (self.target_port, path))
self.ttypath = path
return
return path
logging.debug("No serial devices found for serial console '%s'." %
logging.debug("No devices found for serial target port '%s'." %
self.target_port)
return None
self.ttypath = None
def opentty(self):
if self.ptyio != None:
self.closetty()
self.ttypath = self.get_tty_path()
ipty = self.ttypath
logging.debug("Opening serial tty path: %s" % self.ttypath)
if ipty == None:
return
self.ptyio = pty.slave_open(ipty)
fcntl.fcntl(self.ptyio, fcntl.F_SETFL, os.O_NONBLOCK)
self.ptysrc = gobject.io_add_watch(self.ptyio, gobject.IO_IN | gobject.IO_ERR | gobject.IO_HUP, self.display_data)
self.ptysrc = gobject.io_add_watch(self.ptyio,
gobject.IO_IN | gobject.IO_ERR | gobject.IO_HUP,
self.display_data)
# Save term settings & set to raw mode
self.ptytermios = termios.tcgetattr(self.ptyio)