diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py index 8eaf658..090e17b 100644 --- a/nova/virt/libvirt/config.py +++ b/nova/virt/libvirt/config.py @@ -1053,6 +1053,9 @@ class LibvirtConfigGuestCharBase(LibvirtConfigGuestDevice): dev = super(LibvirtConfigGuestCharBase, self).format_dom() dev.set("type", self.type) + if self.root_name == "console": + dev.set("tty", self.source_path) + if self.type == "file": dev.append(etree.Element("source", path=self.source_path)) elif self.type == "unix": diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 9bd75fa..de2735e 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -213,6 +213,9 @@ libvirt_opts = [ help='A path to a device that will be used as source of ' 'entropy on the host. Permitted options are: ' '/dev/random or /dev/hwrng'), + cfg.BoolOpt('virsh_console_serial', + default=False, + help='Use virsh console on serial terminal'), ] CONF = cfg.CONF @@ -3278,14 +3281,29 @@ class LibvirtDriver(driver.ComputeDriver): # client app is connected. Thus we can't get away # with a single type=pty console. Instead we have # to configure two separate consoles. - consolelog = vconfig.LibvirtConfigGuestSerial() - consolelog.type = "file" - consolelog.source_path = self._get_console_log_path(instance) - guest.add_device(consolelog) - consolepty = vconfig.LibvirtConfigGuestSerial() - consolepty.type = "pty" - guest.add_device(consolepty) + if CONF.libvirt.virsh_console_serial: # Y.Kawada + consolepty = vconfig.LibvirtConfigGuestSerial() + consolepty.type = "pty" + consolepty.target_port = "0" + consolepty.source_path = "/dev/pts/11" + consolepty.alias_name = "serial0" + guest.add_device(consolepty) + + consolepty = vconfig.LibvirtConfigGuestConsole() + consolepty.type = "pty" + consolepty.target_port = "0" + consolepty.source_path = "/dev/pts/11" + consolepty.alias_name = "serial0" + else: + consolelog = vconfig.LibvirtConfigGuestSerial() + consolelog.type = "file" + consolelog.source_path = self._get_console_log_path(instance) + guest.add_device(consolelog) + + consolepty = vconfig.LibvirtConfigGuestSerial() + consolepty.type = "pty" + guest.add_device(consolepty) else: consolepty = vconfig.LibvirtConfigGuestConsole() consolepty.type = "pty"