RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1089914 - first serial console is not formatted when other consoles are present
Summary: first serial console is not formatted when other consoles are present
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
medium
low
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-04-22 08:41 UTC by Hu Jianwei
Modified: 2015-11-19 05:45 UTC (History)
7 users (show)

Fixed In Version: libvirt-1.2.17-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 05:45:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description Hu Jianwei 2014-04-22 08:41:01 UTC
Description of problem:
Libvirt can not dumpxml serial type console device after hot-plugging a virtio console device

Version-Release number of selected component (if applicable):
libvirt-1.1.1-29.el7.x86_64
qemu-kvm-rhev-1.5.3-60.el7ev.x86_64
kernel-3.10.0-121.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

[root@localhost ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     r7                             shut off

1. Remove below serial console part from inactive domain. Exactly, the serial console device will be added by libvirt automatically if we remove it purposely.(I think it works as design. )

    <console type='pty'>
      <target type='serial' port='0'/>
    </console>

[root@localhost ~]# virsh edit r7
Domain r7 XML configuration edited.

[root@localhost ~]# virsh dumpxml r7 | grep "<console" -A5
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
...

2. Start the domain and check the <console> device
[root@localhost ~]# virsh start r7
Domain r7 started

[root@localhost ~]# virsh dumpxml r7 | grep "<console" -A5
    <console type='pty' tty='/dev/pts/2'>
      <source path='/dev/pts/2'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
...

3. Attach a virtio console device to doamin, and check the console devices using dumpxml command line
[root@localhost ~]# cat console.xml 
<console type='pty'>
<target type='virtio'/>
</console>
[root@localhost ~]# virsh attach-device r7 console.xml
Device attached successfully

[root@localhost ~]# virsh dumpxml r7 | grep "<console" -A5
    <console type='pty' tty='/dev/pts/5'>
      <source path='/dev/pts/5'/>
      <target type='virtio' port='0'/>
      <alias name='console0'/>
    </console>
...

4. Check the serial console in guest

In guest, type below command line:
[root@localhost ~]# echo hello > /dev/ttyS0

In host, we can receive the word from the source side.
[root@localhost ~]# cat /dev/pts/2
hello
^C

Actual results:
As shown above, after step 3, the existing serial console device can not be displayed when using dumpxml to check it.

Expected results:
When we deleted the serial console device purposely, libvirt can add it back to domain and should show it normally even though we take some actions on console type devices.

Comment 2 Ján Tomko 2014-08-13 14:38:00 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2014-August/msg00577.html

Comment 4 Ján Tomko 2015-05-28 13:55:54 UTC
I rebased and resent the patch from last year:
https://www.redhat.com/archives/libvir-list/2015-May/msg01085.html

Comment 5 Ján Tomko 2015-06-04 08:36:27 UTC
Now pushed:
commit 8728a78e904de7ddfa32b7761b40d6339fa15030
Author:     Ján Tomko <jtomko>
CommitDate: 2015-06-04 10:04:44 +0200

    Always add 'console' matching the 'serial' device
    
    We have been formatting the first serial device also
    as a console device, but only if there were no other consoles.
    
    If there is a <serial> device present in the XML, but no serial
    <console>, or if there isn't any <console> at all but the domain
    definition hasn't gone through a parse->format->parse round-trip,
    the <console> device would not be formatted.
    
    Change the code to always add the stub device for the first
    serial device.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1089914

git describe: v1.2.16-59-g8728a78

Comment 8 Shanzhi Yu 2015-07-13 08:20:54 UTC
1. Define a guest with below xml file(without console)
# virsh define /dev/stdin <<EOF
<domain type='kvm'>
  <name>r7</name>
  <memory unit='KiB'>1049600</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.2.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/r7.img'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
  </devices>
</domain>
EOF
Domain r7 defined from /dev/stdin

2. delete '<console></console>' part with 'virsh edit guest'
Domain r7 XML configuration edited.

3. check console part of guest 

# virsh dumpxml r7|grep console -A3 
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>

4. Start guest, check the console part and hotplug another console 
# virsh start r7 
Domain r7 started

# cat console.xml 
<console type='pty'>
    <target type='virtio'/>
</console>

# virsh attach-device  r7 console.xml 
error: Failed to attach device from console.xml
error: internal error: no virtio-serial controllers are available

# virsh dumpxml r7|grep console -A3 
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>

5. Cold-plug another console 

# virsh attach-device  r7 console.xml --config
Device attached successfully

# virsh dumpxml r7 --inactive |grep console -A3  
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <console type='pty'>
      <target type='virtio' port='1'/>
    </console>

6. Destroy/start guest, then check console again
# virsh destroy r7 
Domain r7 destroyed

# virsh start r7 
Domain r7 started

# virsh dumpxml r7   |grep console -A3  
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <console type='pty'>
      <source path='/dev/pts/5'/>
      <target type='virtio' port='1'/>
      <alias name='console1'/>
    </console>

The failure in step 4 is because there is no virtio-serial type controller, if I add '<controller type='virtio-serial></controller>', then the hot-plug will succeed. 
So, should libvirt will auto add this controller when I hot-plug a pty type console?

I'd change this bug to be verified status if it's acceptable

Comment 9 Ján Tomko 2015-07-13 12:14:47 UTC
Auto-adding a virtio-serial controller on hotplug is unrelated to this bug.

Please file a separate bug if you think the functionality would be helpful. Personally, I do not see the need for it - we don't auto add a controller for PCI devices either. And a virtio-serial controller can be hotplugged separately.

Comment 10 Shanzhi Yu 2015-07-13 12:29:17 UTC
Jan, thanks
Verify this bug.

Comment 12 errata-xmlrpc 2015-11-19 05:45:48 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


Note You need to log in before you can comment on or make changes to this bug.