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 1230039 - cannot attach a virtio channel device
Summary: cannot attach a virtio channel device
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-06-10 07:41 UTC by Luyao Huang
Modified: 2015-11-19 06:41 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 06:41:00 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 Luyao Huang 2015-06-10 07:41:41 UTC
description of problem:
cannot attach a channel device

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

How reproducible:
100%

Steps to Reproduce:

1. prepare a running vm

# virsh list
 Id    Name                           State
----------------------------------------------------
 2     rhel7.0                        running


2. attach channel device:

# cat channel-file.xml
    <channel type='file'>
      <source path='/tmp/file'/>
      <target type='virtio' name='123'/>
    </channel>


# virsh attach-device rhel7.0 channel-file.xml
error: Failed to attach device from channel-file.xml
error: internal error: virtio serial device has invalid address type

4. add virtio-serial address
# cat channel-file.xml
    <channel type='file'>
      <source path='/tmp/file'/>
      <target type='virtio' name='123'/>
<address type='virtio-serial' controller='0' bus='0' port='2'/>
    </channel>

# virsh attach-device rhel7.0 channel-file.xml
error: Failed to attach device from channel-file.xml
error: internal error: virtio serial device has invalid address type


Actual results:
cannot attach a channel device

Expected results:
attach success , test with 1.2.15-2 attach success

Additional info:

seems because this patches:

commit 9807c47147a92a423f632e799137a31acd3ac41e
Author: Michal Privoznik <mprivozn>
Date:   Mon May 11 15:20:54 2015 +0200

    qemuDomainAttachChrDevice: Fix chardev hotplug

This need a check for the device type(channel, console, serial). Not all the chardev device type is serial.

    if (chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI) {
        if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &chr->info) < 0)
            goto cleanup;
    } else if (chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) {
        /* XXX */
    } else {
        if (virDomainVirtioSerialAddrAutoAssign(NULL,
                                                priv->vioserialaddrs,
                                                &chr->info,
                                                allowZero) < 0)
            goto cleanup;
    }

Comment 2 Luyao Huang 2015-06-10 14:58:55 UTC
First try(send a patch to upstream):

https://www.redhat.com/archives/libvir-list/2015-June/msg00480.html

Comment 3 Ján Tomko 2015-06-30 14:28:25 UTC
Another version:
https://www.redhat.com/archives/libvir-list/2015-June/msg01661.html

Comment 4 Ján Tomko 2015-07-01 06:15:23 UTC
Now pushed upstream:
commit f967e7a6690ed20478623b0707b846f81f469ff4
Author:     Luyao Huang <lhuang>
AuthorDate: 2015-06-10 22:49:37 +0800
Commit:     Ján Tomko <jtomko>
CommitDate: 2015-07-01 08:09:43 +0200

    qemu: fix address allocation on chardev attach
    
    Also check the device type when deciding what type the address should
    be. Commit 9807c47 (aiming to fix another error in address allocation)
    only checked the target type, but its value is different for different
    device types. This resulted in an error when trying to attach
    a channel with target type 'virtio':
    
    error: Failed to attach device from channel-file.xml
    error: internal error: virtio serial device has invalid address type
    
    Make the logic for releasing the address dependent only on
    * the address type
    * whether it was allocated earlier
    to avoid copying the device and target type checks.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1230039
    
    Signed-off-by: Luyao Huang <lhuang>
    Signed-off-by: Ján Tomko <jtomko>

git describe: v1.2.17-rc1-20-gf967e7a

Comment 6 Shanzhi Yu 2015-07-13 09:53:06 UTC
Verify this bug with libvirt-1.2.17-2.el7.x86_64 

1. Prepare a running guest 
# virsh list 
 Id    Name                           State
----------------------------------------------------
 21    r7                             running


2. Attach/detach file type channel without address element

# cat channel-1.xml 
    <channel type='file'>
      <source path='/tmp/file'/>
      <target type='virtio' name='123'/>
    </channel>

# virsh attach-device r7 channel-1.xml 
Device attached successfully

# virsh dumpxml r7|grep channel -A 4 
    <channel type='file'>
      <source path='/tmp/file'/>
      <target type='virtio' name='123'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>

# virsh detach-device r7 channel-1.xml 
Device detached successfully

# virsh dumpxml r7|grep channel -A 4 

3. Attach/detach file type channel with address element

# cat channel-2.xml 
    <channel type='file'>
      <source path='/tmp/file'/>
      <target type='virtio' name='123'/>
      <address type='virtio-serial' controller='0' bus='0' port='2'/>
    </channel>

# virsh attach-device r7 channel-2.xml 
Device attached successfully


# virsh dumpxml r7|grep channel -A 4 
    <channel type='file'>
      <source path='/tmp/file'/>
      <target type='virtio' name='123'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='2'/>
    </channel>

# virsh detach-device r7 channel-2.xml 
Device detached successfully

# virsh dumpxml r7|grep channel -A 4 

So, this bug can be verified.

Comment 8 errata-xmlrpc 2015-11-19 06:41:00 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.