can not use virsh console on serial terminal

Bug #1340518 reported by Yukihiro KAWADA
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Opinion
Wishlist
heng jiang

Bug Description

In KVM case:
We can not use virsh console on serial terminal.
So, can not login to each vm using 'virsh console' command on terminal.
Because vm's config xml file is not support it now.
This feature is so important for us.

Please apply this patch:
CONF.libvirt.virsh_console_serial=False (default. is same now)

if you using virsh console then set
CONF.libvirt.virsh_console_serial=True

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"

Revision history for this message
Yukihiro KAWADA (warp-kawada) wrote :
Changed in nova:
assignee: nobody → heng jiang (johnkeepmoving)
Tracy Jones (tjones-i)
tags: added: libvirt
tags: added: console
Revision history for this message
Sean Dague (sdague) wrote :

It is not clear what the use case is here, please explain further if you'd like to take this forward. Also patches need to be provided via gerrit not via the tracker.

Changed in nova:
status: New → Opinion
importance: Undecided → Wishlist
Revision history for this message
Yukihiro KAWADA (warp-kawada) wrote :

hello

default instances's xml file is
    <serial type='file'>
      <source path='/var/lib/nova/instances/b742bc72-8d65-481a-a4ec-9be7a18a0a5b/console.log'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target port='1'/>
      <alias name='serial1'/>
    </serial>
    <console type='file'>
      <source path='/var/lib/nova/instances/b742bc72-8d65-481a-a4ec-9be7a18a0a5b/console.log'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>

If you try virsh console on terminal (cnode0001)

cnode0001:~# virsh console du3-00000709
Connected to domain du3-00000709
Escape character is ^]
error: internal error cannot find character device (null)

If my changes apply
  <devices>
     :
    <serial type='pty'>
      <source path='/dev/pts/0'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/0'>
      <source path='/dev/pts/0'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
     :
 </devices>

cnode0001:~# virsh console du3-00000709
Connected to domain du3-00000709
Escape character is ^]

CentOS release 6.5 (Final)
Kernel 2.6.32-431.17.1.el6.x86_64 on an x86_64
vxxx-xxx-xxx-xxx.z0d1.static.cnode.jp login: root
Password:

I'm going to be to be able to virsh console like this.
got it?

Revision history for this message
Harsh Jain (harshjain32) wrote :

Hi Yukihiro,

Thanks for your patch. From last 1 month i am trying to find the solution to login VM from host compute.

What changes are required to access the VM from Horizon GUI. We don't have VNC support for ARM64 machine.

Revision history for this message
Harsh Jain (harshjain32) wrote :
Revision history for this message
Yukihiro KAWADA (warp-kawada) wrote :

Hi Harsh

I don't know ARM64 VM.
Is it on KVM?
If it was KVM, you can connect VM's serial console with virsh console.
Then It needs my revise for each cnodes.
And it needs to add virsh console interface to horizon.

We GMO intenet.INC are serving 'conoHa' VPS using openstack engine.
https://www.conoha.jp/en

In this case , we support anyterm by using virsh console and conserver.
Anyterm is text based terminal , not VNC.
It is good for us that we can copy and paste in text is available.

http://anyterm.org/
http://www.conserver.com/

Thank you.

Revision history for this message
Javier Domingo Cansino (javier-domingo) wrote :

Just in case, it's possible with Juno to get the virsh console as a telnet endpoint.

I have achieved this adding the following config to /etc/nova/nova.conf

[serial_console]
enabled = True

It will create all the serial ports as telnet ports in 10000 onwards. Have the config here (for Juno):

https://github.com/openstack/nova/blob/c5ac21f3dbb4ad59efcb631d91e4e64f77fba43f/nova/console/serial.py#L33-L52

Revision history for this message
Javier Domingo Cansino (javier-domingo) wrote :

I don't know exactly why, I suppose it's due to being a serial port, but characters should be sent ASAP, therefore, you may need to configure tenet with "mode char"

Revision history for this message
Harsh Jain (harshjain32) wrote :

HI,

Yes ARM64 is KVM enabled.The only currently supported 64-bit ARM board is "virt", which
has no display (graphics) device at all, so -vnc is not supported.
We am able to connect VM using virsh console <instance-ID>.
Do we need code changes to support console in Horizon.?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.