Bug 1170092

Summary: domain cannot start with virtio and serial console when the first console is virtio
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Erik Skultety <eskultet>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, eskultet, mzhan, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.13-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:56:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luyao Huang 2014-12-03 08:52:51 UTC
description of problem:
domain cannot start with virtio and serial console

Version-Release number of selected component (if applicable):
libvirt-1.2.8-9.el7.x86_64


How reproducible:
100%

Steps to Reproduce:

1.notice the sequence of two console
# virsh dumpxml test3
    <serial type='pty'>
      <target type='isa-serial' port='0'/>
    </serial>
    <console type='pty'>
      <target type='virtio' port='0'/>
    </console>
    <console type='pty'>
      <target type='serial' port='1'/>
    </console>

2.
# virsh start test3
error: Failed to start domain test3
error: internal error: no assigned pty for device charconsole1

Actual results:
Cannot start if virtio console before serial console, but can start if after it.

# virsh start test3
Domain test3 started

# virsh dumpxml test3
   <serial type='pty'>
      <source path='/dev/pts/8'/>
      <target type='isa-serial' port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/8'>
      <source path='/dev/pts/8'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <console type='pty'>
      <source path='/dev/pts/9'/>
      <target type='virtio' port='1'/>
      <alias name='console1'/>
    </console>


Expected results:
Can start or if we do not support this should give a check before
call qemuProcessLookupPTYs and give a useful error.

Additional info:
After check the code maybe the cause is in qemuProcessFindCharDevicePTYsMonitor:

    /* For historical reasons, console[0] can be just an alias
     * for serial[0]. That's why we need to update it as well. */
    if (vm->def->nconsoles) {
        virDomainChrDefPtr chr = vm->def->consoles[0];

        if (vm->def->nserials &&

libvirt only check if the first console is serial, but when set virtio console be the first console libvirt do the wrong things here, but qemu can recognize this sequence, so the second console cannot get a 'entry' in qemuProcessLookupPTYs.

Comment 1 Erik Skultety 2014-12-17 08:35:49 UTC
Fixed upstream:
commit d85dcae4b2bb7277503001519e533d21133f65d4
Author: Erik Skultety <eskultet>
Date:   Thu Dec 11 12:28:22 2014 +0100

    conf: move the check for secondary consoles of targetType serial
    
    For historical reasons, only the first <console> element might be of targetType
    serial, but we checked for other consoles of targetType serial in our post-parse
    callback if and only if we knew the first console was serial, otherwise
    the check was skipped.
    This patch moves the check one level up, so first
    the check for secondary console of type serial is performed and then the
    rest of operations continue unchanged.

v1.2.11-6-gd85dcae

Comment 3 Hu Jianwei 2015-05-07 06:33:41 UTC
Verified as below:

[root@localhost ~]# rpm -q libvirt qemu-kvm-rhev
libvirt-1.2.15-1.el7.x86_64
qemu-kvm-rhev-2.3.0-1.el7.x86_64

Add below lines to domain xml

    <serial type='pty'>
      <target type='isa-serial' port='0'/>
    </serial>
    <console type='pty'>
      <target type='virtio' port='0'/>
    </console>
    <console type='pty'>
      <target type='serial' port='1'/>
    </console>

Then, save the xml in "virsh edit"
[root@localhost ~]# virsh edit r71
error: unsupported configuration: Only the first console can be a serial port
Failed. Try again? [y,n,i,f,?]: 

The expected error message will be toasted.

Comment 5 errata-xmlrpc 2015-11-19 05:56:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html