Bug 1566525

Summary: Hosted Engine VM (deployed in the past) fails to reboot with 'libvirtError: internal error: failed to format device alias for PTY retrieval' due to an error in console device in libvirt XML generated by the engine [rhel-7.5.z]
Product: Red Hat Enterprise Linux 7 Reporter: Oneata Mircea Teodor <toneata>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: yalzhang <yalzhang>
Severity: high Docs Contact:
Priority: urgent    
Version: 7.5CC: akrejcir, bugs, dyuan, jdenemar, jherrman, jinqi, jiyan, lmen, mavital, mgoldboi, michal.skrivanek, mprivozn, mtessun, ratamir, rbalakri, stirabos, xuzhang, yafu
Target Milestone: rcKeywords: Upstream, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-3.9.0-14.el7_5.4 Doc Type: Bug Fix
Doc Text:
Previously, user aliases for PTY devices that were longer than 32 characters were not supported. Consequently, if a domain included a PTY device with a user alias longer than 32 characters, the domain would not start. With this update, a static buffer was replaced with a dynamic buffer. As a result, the domain starts even if the length of the user alias for a PTY device is longer than 32 characters.
Story Points: ---
Clone Of: 1560976 Environment:
Last Closed: 2018-05-14 16:11:44 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:
Bug Depends On: 1560976    
Bug Blocks:    

Description Oneata Mircea Teodor 2018-04-12 13:12:56 UTC
This bug has been copied from bug #1560976 and has been proposed to be backported to 7.5 z-stream (EUS).

Comment 6 yalzhang@redhat.com 2018-04-23 10:56:28 UTC
Test on libvirt-3.9.0-14.el7_5.4.x86_64, the serial and console, channel device can use uuid as alias. vm start successfully and hotplug works well, set this bug to be verified.

1. prepare an inactive vm, and modify the xml to add uuid as alias for serial pty device, save and start the vm
# virsh start rhel
Domain rhel started

# virsh dumpxml rhel | grep /console -B11
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f353'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='serial' port='0'/>
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f353'/>
    </console>

2. start vm with uuid alias for channel device and virtio console device, guest can start successfully
# virsh start rhel
Domain rhel started

# virsh dumpxml rhel
...
<console type='pty'>
      <source path='/dev/pts/2'/>
      <target type='virtio' port='1'/>
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f358'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-15-rhel/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='connected'/>
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f359'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
...

3. do save and restore successfully and xml no change

4. do managedsave and start successfully and xml no change

5. do hotplug with such alias successfully
for console:
# cat console.xml
<console type='pty'>
      <source path='/dev/pts/2'/>
      <target type='virtio' port='1'/>
      <alias name='ua-5b93a4b8-3167-410b-a365-ab31e88a709a'/>
    </console>

# virsh attach-device rhel console.xml
Device attached successfully

# virsh dumpxml rhel | grep ua
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f358'/>
      <alias name='ua-5b93a4b8-3167-410b-a365-ab31e88a709a'/>
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f359'/>

for channel:
# cat channel.xml
<channel type='pty'> 
<target type='virtio' name='org.linux-kvm.port.3'/> 
<address type='virtio-serial' controller='0' bus='0' port='4'/> 
<alias name='ua-209377ba-e83b-4cee-9ac5-7e467e290dae'/>
</channel>

# virsh attach-device rhel channel.xml
Device attached successfully

# virsh dumpxml rhel | grep ua
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f358'/>
      <alias name='ua-5b93a4b8-3167-410b-a365-ab31e88a709a'/>
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f359'/>
      <alias name='ua-209377ba-e83b-4cee-9ac5-7e467e290dae'/>

for serial:
# cat serial.xml
<serial type='pty'>
      <source path='/dev/pts/1'/>
      <target type='pci-serial' port='0'>
        <model name='pci-serial'/>
      </target>
      <alias name='ua-09de3cbb-e85c-4526-8fe6-2b8ea0c5e03b'/>
    </serial>

# virsh attach-device rhel serial.xml
Device attached successfully

# virsh dumpxml rhel | grep ua
      <alias name='ua-09de3cbb-e85c-4526-8fe6-2b8ea0c5e03b'/>
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f358'/>
      <alias name='ua-5b93a4b8-3167-410b-a365-ab31e88a709a'/>
      <alias name='ua-c60aba6e-b6d8-448b-ab6e-8c7b5c29f359'/>
      <alias name='ua-209377ba-e83b-4cee-9ac5-7e467e290dae'/>

Comment 9 errata-xmlrpc 2018-05-14 16:11:44 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://access.redhat.com/errata/RHSA-2018:1396