Bug 460812

Summary: Console not created/connected
Product: [Community] Virtualization Tools Reporter: Stefan de Konink <stefan>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED WORKSFORME QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: unspecifiedCC: adam.hamsik, berrange
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-01-22 12:53:36 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stefan de Konink 2008-09-01 12:58:34 UTC
Description of problem:

After the <bootloader /> issued looked to be fixed, it created a regression in the console handling.


Version-Release number of selected component (if applicable):
git head + xen patch, now running Xen 3.3


How reproducible:

<domain type='xen'>
  <name>klant1_monetdb</name>
  <uuid>a850ec08-7c7d-2133-1f0e-0b56a793f858</uuid>
  <memory>4194304</memory>
  <currentMemory>4194304</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type>linux</type>
    <kernel>/usr/lib/xen/boot/linux-2.6.20-xen-r6</kernel>
    <cmdline> root=/dev/xvda ro ip=85.17.131.51:1.2.3.4:85.17.131.254:255.255.255.0::eth0:off</cmdline>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <disk type='file' device='disk'>
      <driver name='tap' type='aio'/>
      <source file='/mnt/images/klant1_monetdb_1'/>
      <target dev='xvda' bus='xen'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='tap' type='aio'/>
      <source file='/mnt/images/klant1_osm'/>
      <target dev='xvdb' bus='xen'/>
    </disk>
    <interface type='bridge'>
      <mac address='00:16:3e:00:00:29'/>
      <source bridge='xenbr0'/>
      <target dev='vif-1.0'/>
    </interface>
    <console type='pty'>
      <target port='0'/>
    </console>
  </devices>
</domain>

This file was created by the libvirt api using an inactive configuration. It results in:


<domain type='xen' id='7'>
  <name>klant1_monetdb</name>
  <uuid>a850ec08-7c7d-2133-1f0e-0b56a793f858</uuid>
  <memory>4194304</memory>
  <currentMemory>4194304</currentMemory>
  <vcpu>1</vcpu>
  <bootloader></bootloader>
  <os>
    <type>linux</type>
    <kernel>/usr/lib/xen/boot/linux-2.6.20-xen-r6</kernel>
    <cmdline> root=/dev/xvda ro ip=85.17.131.51:1.2.3.4:85.17.131.254:255.255.255.0::eth0:off</cmdline>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
    <disk type='file' device='disk'>
      <driver name='tap' type='aio'/>
      <source file='/mnt/images/klant1_monetdb_1'/>
      <target dev='xvda' bus='xen'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='tap' type='aio'/>
      <source file='/mnt/images/klant1_osm'/>
      <target dev='xvdb' bus='xen'/>
    </disk>
    <interface type='bridge'>
      <mac address='00:16:3e:00:00:29'/>
      <source bridge='xenbr0'/>
      <target dev='vif7.0'/>
    </interface>
    <console type='pty' tty='/dev/pts/4'>
      <source path='/dev/pts/4'/>
      <target port='0'/>
    </console>
  </devices>
</domain>



Steps to Reproduce:
1. create domain
2. try to connect to it
  
Actual results:

xenapi bin # ./virsh create /mnt/netapp/users/klant1/monetdb/index.xml 
Domain klant1_monetdb created from /mnt/netapp/users/klant1/monetdb/index.xml

xenapi bin # xm console klant1_monetdb
xenconsole: Could not open tty `/dev/pts/4': No such file or directory

Comment 1 Daniel Berrangé 2009-01-22 12:53:36 UTC
I've tried again to reproduce this but it always works correctly for me. The console path in the XML is something we get given directly from XenD, so if the console then does not exist, I can only think XenD is giving us back incorrect information. Or alternatively the guest is crashing immediately after starting causing the QEMU process which provides the console, to exit. Either way I don't immediately see any libvirt bug here. Please re-open if you can find a way to reproduce.

Comment 2 adam.hamsik 2010-01-27 09:03:00 UTC
I can reproduce same bug with libvirt version 0.7.5 and this serail console configuration 

   <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty' tty='/de/pts/1'>
      <target port='0'/>
    </console>

 I used strace to find what is going on, and relevant part of strace output is attached. I think that problem is in open call which is trying to open /dev/pts/1

sendto(3, "\0\0\0008 \0\200\206\0\0\0\1\0\0\0\20\0\0\0\0\0\0\0\5\0\0\0\0\0\0\0\3"..., 56, 0, NULL, 0) = 56
poll([{fd=3, events=POLLIN}, {fd=4, events=POLLIN}], 2, -1) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\0\0\0X", 4, 0, NULL, NULL) = 4
recvfrom(3, " \0\200\206\0\0\0\1\0\0\0\20\0\0\0\1\0\0\0\5\0\0\0\0\0\0\0\1\0\0\0\0"..., 84, 0, NULL, NULL) = 84
poll([{fd=3, events=POLLOUT}, {fd=4, events=POLLIN}], 2, -1) = 1 ([{fd=3, revents=POLLOUT}])
sendto(3, "\0\0\0< \0\200\206\0\0\0\1\0\0\0\16\0\0\0\0\0\0\0\6\0\0\0\0\0\0\0\3"..., 60, 0, NULL, 0) = 60
poll([{fd=3, events=POLLIN}, {fd=4, events=POLLIN}], 2, -1) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\0\0\6\340", 4, 0, NULL, NULL) = 4
recvfrom(3, " \0\200\206\0\0\0\1\0\0\0\16\0\0\0\1\0\0\0\6\0\0\0\0\0\0\6\242<dom"..., 1756, 0, NULL, NULL) = 1756
futex(0x7f1690795b60, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1690c83000
write(1, "Connected to domain pdc\n", 24Connected to domain pdc
) = 24
write(1, "Escape character is ^]\n", 23Escape character is ^]
) = 23
open("/dev/pts/1 ", O_RDWR|O_NOCTTY)    = -1 ENOENT (No such file or directory)

pts device is '/dev/pts/1' but we are trying to open '/dev/pts/1 ' which doesn't exists. 

if I change cmdRunConsole code below to open hardcoded '/dev/pts/1' everythings works. I then suspect that problem can be in obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/@tty)", ctxt); which returns bad string from xml.

if (vshRunConsole((const char *)obj->stringval) == 0)