mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
domain: Simplify get_serial_devs
Just pass around the dev, rather than a broken out list. Will be needed for future serialcon work
This commit is contained in:
parent
adc3e0466f
commit
e053f1c94a
@ -415,10 +415,6 @@ class vmmDetails(vmmGObjectUI):
|
||||
self.close()
|
||||
|
||||
try:
|
||||
self.vm = None
|
||||
self.conn = None
|
||||
self.addhwmenu = None
|
||||
|
||||
if self.addhw:
|
||||
self.addhw.cleanup()
|
||||
self.addhw = None
|
||||
@ -437,6 +433,10 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
self.console.cleanup()
|
||||
self.console = None
|
||||
|
||||
self.vm = None
|
||||
self.conn = None
|
||||
self.addhwmenu = None
|
||||
except:
|
||||
logging.exception("Error cleaning up details")
|
||||
|
||||
@ -876,7 +876,17 @@ class vmmDetails(vmmGObjectUI):
|
||||
add_row(_("No text console available"),
|
||||
None, False, False, None, None)
|
||||
|
||||
for serialdesc, serialtype, serialpath, serialidx in devs:
|
||||
def build_desc(dev):
|
||||
if dev.virtual_device_type == "console":
|
||||
return "Text Console %d" % (dev.vmmindex + 1)
|
||||
return "Serial %d" % (dev.vmmindex + 1)
|
||||
|
||||
for dev in devs:
|
||||
serialdesc = build_desc(dev)
|
||||
serialtype = dev.char_type
|
||||
serialpath = dev.source_path
|
||||
serialidx = dev.vmmindex
|
||||
|
||||
sensitive = False
|
||||
err = None
|
||||
|
||||
|
@ -819,17 +819,8 @@ class vmmDomain(vmmLibvirtObject):
|
||||
devs = self.get_char_devices()
|
||||
devlist = []
|
||||
|
||||
serials = filter(lambda x: x.virtual_device_type == "serial", devs)
|
||||
consoles = filter(lambda x: x.virtual_device_type == "console", devs)
|
||||
|
||||
for dev in serials:
|
||||
devlist.append(["Serial %s" % (dev.vmmindex + 1), dev.char_type,
|
||||
dev.source_path, dev.vmmindex])
|
||||
|
||||
for dev in consoles:
|
||||
devlist.append(["Text Console %s" % (dev.vmmindex + 1),
|
||||
dev.char_type, dev.source_path, dev.vmmindex])
|
||||
|
||||
devlist += filter(lambda x: x.virtual_device_type == "serial", devs)
|
||||
devlist += filter(lambda x: x.virtual_device_type == "console", devs)
|
||||
return devlist
|
||||
|
||||
def get_graphics_console(self):
|
||||
|
@ -48,7 +48,7 @@ class ConsoleConnection(vmmGObject):
|
||||
self.vm = None
|
||||
self.conn = None
|
||||
|
||||
def open(self, ipty, terminal):
|
||||
def open(self, dev, terminal):
|
||||
raise NotImplementedError()
|
||||
def close(self):
|
||||
raise NotImplementedError()
|
||||
@ -70,10 +70,11 @@ class LocalConsoleConnection(ConsoleConnection):
|
||||
def cleanup(self):
|
||||
ConsoleConnection.cleanup(self)
|
||||
|
||||
def open(self, ipty, terminal):
|
||||
def open(self, dev, terminal):
|
||||
if self.fd != None:
|
||||
self.close()
|
||||
|
||||
ipty = dev and dev.source_path or None
|
||||
logging.debug("Opening serial tty path: %s" % ipty)
|
||||
if ipty == None:
|
||||
return
|
||||
@ -135,7 +136,7 @@ class vmmSerialConsole(vmmGObject):
|
||||
|
||||
self.vm = vm
|
||||
self.target_port = target_port
|
||||
self.ttypath = None
|
||||
self.lastpath = None
|
||||
|
||||
self.console = LocalConsoleConnection(self.vm)
|
||||
|
||||
@ -147,9 +148,7 @@ class vmmSerialConsole(vmmGObject):
|
||||
|
||||
self.box.connect("realize", self.handle_realize)
|
||||
self.box.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 init_terminal(self):
|
||||
self.terminal = vte.Terminal()
|
||||
@ -185,29 +184,31 @@ class vmmSerialConsole(vmmGObject):
|
||||
self.box = None
|
||||
|
||||
def handle_realize(self, ignore=None):
|
||||
self.console.open(self.ttypath, self.terminal)
|
||||
self.console.open(self.lookup_dev(), self.terminal)
|
||||
|
||||
def handle_unrealize(self, src_ignore=None, ignore=None):
|
||||
self.console.close()
|
||||
|
||||
def vm_status_changed(self, src_ignore, oldstatus_ignore, status):
|
||||
if status in [libvirt.VIR_DOMAIN_RUNNING]:
|
||||
self.console.open(self.ttypath)
|
||||
self.console.open(self.lookup_dev(), self.terminal)
|
||||
else:
|
||||
self.console.close()
|
||||
|
||||
def update_tty_path(self, vm):
|
||||
serials = vm.get_serial_devs()
|
||||
for s in serials:
|
||||
port = s[3]
|
||||
path = s[2]
|
||||
def lookup_dev(self):
|
||||
devs = self.vm.get_serial_devs()
|
||||
for dev in devs:
|
||||
port = dev.vmmindex
|
||||
path = dev.source_path
|
||||
|
||||
if port == self.target_port:
|
||||
if path != self.ttypath:
|
||||
if path != self.lastpath:
|
||||
logging.debug("Serial console '%s' path changed to %s."
|
||||
% (self.target_port, path))
|
||||
self.ttypath = path
|
||||
return
|
||||
% (self.target_port, path))
|
||||
self.lastpath = path
|
||||
return dev
|
||||
|
||||
logging.debug("No devices found for serial target port '%s'." %
|
||||
self.target_port)
|
||||
self.ttypath = None
|
||||
self.lastpath = None
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user