Bug 1876467 - A problem with the alias length matching of scsi-hostdev
Summary: A problem with the alias length matching of scsi-hostdev
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.3
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: 8.3
Assignee: Peter Krempa
QA Contact: gaojianan
URL:
Whiteboard:
: 1876984 (view as bug list)
Depends On:
Blocks: 1876605
TreeView+ depends on / blocked
 
Reported: 2020-09-07 09:45 UTC by gaojianan
Modified: 2020-11-19 09:04 UTC (History)
7 users (show)

Fixed In Version: libvirt-6.6.0-6.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-17 17:51:44 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description gaojianan 2020-09-07 09:45:23 UTC
Description of problem:
As subject

Version-Release number of selected component (if applicable):
libvirt-6.6.0-2.virtcov.el8.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Start a guest with scsi-host alias
#  virsh dumpxml test |grep hostdev -A10
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host3'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <alias name='ua-7996c8dc-a4fa-4012-b76f-043d20144263'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>

# virsh start test
error: Failed to start domain test
error: internal error: node-name 'libvirt-ua-7996c8dc-a4fa-4012-b76f-043d20144263-backend' too long for qemu


Actual results:
Start failed since the node-name of the scsi-hostdev alias is too long.

Expected results:
This length of alias for the guest should start successfully.

Additional info:
I saw there is a new commit for scsi hostdev alias:https://github.com/libvirt/libvirt/commit/78e8bb743b830ba15f9e07f39dc61074158a5cc2.
This problem may cause this bug.

Comment 1 Jiri Denemark 2020-09-08 16:32:02 UTC
*** Bug 1876984 has been marked as a duplicate of this bug. ***

Comment 2 Peter Krempa 2020-09-15 14:53:20 UTC
Fixed upstream:

commit 2f7ee6914d77c31eaaff8910ebd44d5a846d2ad1
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 17:00:13 2020 +0200

    qemuxml2argvtest: hostdev-scsi-virtio-scsi: Use longer user-alias for SCSI hostdev
    
    Test that we can cope with a long useralias when generating SCSI hostdev
    commandline.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit e5dc1427d742556ad07fb97fb28202ce130cda4e
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 15:43:54 2020 +0200

    qemuDomainPrepareHostdev: Don't base backend nodename on device alias
    
    QEMU's blockdev nodenames which are used to back SCSI/iSCSI hostdevs are
    limited to 32 characters. If a user passes a very long user alias as
    name of the host device it's easy to end up with a too-long nodename.
    
    To prevent this from happening don't base the nodename on the possibly
    user-specified alias but on the normal sequential node name generator.
    
    We then store the name in the status XML for further use.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit a669d68336310ba629962ed1fe342bf583acff5b
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 15:39:49 2020 +0200

    qemuDomainPrepareHostdev: base hostdev secret object names on backend alias
    
    The secret object is used to pass data to the backend so it's better
    fitting to base the secret object name on the SCSI host device backend
    name.
    
    Since we store the object alias in the status XML this modification is
    safe in regards to existing guests.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit ca495825a34d8cad12972805d1c15092aefb444b
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 15:33:45 2020 +0200

    qemuDomainPrepareHostdev: Allocate backend nodenames in the prepare function
    
    Allocate the nodename in the setup function rather than in the command
    line generator.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>


commit c17e4907fec9a5fe6b777f58db61c45598148fb8
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 15:10:21 2020 +0200

    qemuDomainSecretHostdevPrepare: remove
    
    The function is no longer used once we setup per-hostdev data.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit 3673bdbe13898d0f03fdbf50db6d2b1cc5554597
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 12:32:04 2020 +0200

    qemu: domain: Extract preparation of hostdev specific data to a separate function
    
    Historically we've prepared secrets for all objects in one place. This
    doesn't make much sense and it's semantically more appealing to prepare
    everything for a single device type in one place.
    
    Move the setup of the (iSCSI|SCSI) hostdev secrets into a new function
    which will be used to setup other things as well in the future.
    
    This is a similar approach we do for disks.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit 82b60ec8cec231443bed716ecd854eee6c770b12
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 08:32:41 2020 +0200

    qemuBlockStorageSourceAttachData: remove 'storageNodeNameCopy'
    
    This was a hack when we were locally regenerating the nodename so that
    it's not leaked. Now that we use proper virStorageSource with
    persistence it's no longer required.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit cca2dd4890c0f7ef362ac7aa47f9fc00bd36619a
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 08:25:37 2020 +0200

    qemuBuildHostdevSCSI(A|De)tachPrepare: Use virStorageSource in def for SCSI hostdevs
    
    Modify the attach/detach data generators to actually use the
    virStorageSourceStructure embedded in the SCSI config data rather than
    creating an ad-hoc internal one.
    
    The modification will allow us to properly store the nodename used for
    the backend in the status XML rather than re-generating it all the
    time.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>


commit 482c52b177750a2893e60e90905e51d31a16782b
Author: Peter Krempa <pkrempa>
Date:   Wed Sep 9 17:58:34 2020 +0200

    qemu: domain: Fill in (i)SCSI backend nodename if it is not present in status XML
    
    For upgrade reasons so that we can modify the used nodename we must
    generate the old version for all status XMLs which don't have it stored
    explicitly.
    
    The change will be required as using the user-provided alias may result
    in too-long nodenames which will be rejected by qemu.
    
    Add code which fills in the appropriate old value and add test cases to
    validate that it's added and also that existing nodenames are not
    overwritten.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit 8e008c101301248a53f8074c69fe8bca8e484d2b
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 17:28:46 2020 +0200

    tests: qemustatusxml2xmldata: Add local SCSI hostdev to 'upgrade' case
    
    Add a local SCSI host device to validate upcoming generated data.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit d240e599e6394ae941c9dc5e6a1bb5004ab4237d
Author: Peter Krempa <pkrempa>
Date:   Fri Sep 11 15:40:23 2020 +0200

    tests: qemustatusxml2xmldata: Rename 'disk-secinfo-upgrade' case to 'upgrade'
    
    The test case tests other things besides disk secinfos, so we can make
    it more universal.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit 981d098250cc5b9de723a4b499602c3650a9bde5
Author: Peter Krempa <pkrempa>
Date:   Wed Sep 9 15:27:45 2020 +0200

    conf: Add virStorageSource member for SCSI host device config data
    
    The backend for the SCSI host device is a storage source. While the
    definition doesn't look like that it's converted to a storage source
    when the VM is running.
    
    Add the storage source to the definition object and also parse/format
    its private data which will be used for internal state storage while
    the VM is running.
    
    Note that the virStorageSourcePtr may not be allocated all the time so
    the private data parser allocates it if there is any private data
    present.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit baea669e80a6e57d5fc66a35869b3aeb3a877b7c
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 15:48:38 2020 +0200

    qemuxml2argvtest: hostdev-scsi-virtio-scsi: Add hostdev with useralias
    
    Add a SCSI host device with a user-specified alias to illustrate the
    upcoming changes.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit 931c1d128d14884e6e1978ec9a2e374cbb82eb13
Author: Peter Krempa <pkrempa>
Date:   Thu Sep 10 15:37:33 2020 +0200

    syntax-check: Don't forbid curly braces around single line condition body
    
    This syntax rule doesn't make much sense, especially if there are so
    much exceptions to it. Just remove it and adjust the coding style.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit b4d2cb58b2bcde2c7a536d067a2c03f462a75a80
Author: Peter Krempa <pkrempa>
Date:   Wed Sep 9 16:17:05 2020 +0200

    virDomainHostdevSubsysSCSIHostDefParseXML: Switch to a more modern XML parsing approach
    
    Use XPath instead of iterating through the nodes.
    
    Few error messages were modified so that the parser can be written in a
    simpler way.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit 00688ea47e62c9aa822847cd3c03607048217f62
Author: Peter Krempa <pkrempa>
Date:   Wed Sep 9 16:17:05 2020 +0200

    virDomainStorageNetworkParseHosts: Switch to a more modern XML parsing approach
    
    Use XPath to get the host list instead of iterating through the nodes.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit a269ac0f62e21859296bcef6f2be527b1e0090d4
Author: Peter Krempa <pkrempa>
Date:   Wed Sep 9 15:22:57 2020 +0200

    virDomainHostdevSubsysSCSIiSCSIClear: Inline contents into only caller
    
    There's just one caller for the function. Move the code into the caller.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

Comment 6 gaojianan 2020-09-17 08:02:06 UTC
Verified on libvirt version:
libvirt-6.6.0-6.virtcov.el8.x86_64

Step:
1.Prepare two iscsi device,login 1 and set 1 as pass-through with CHAP
2.Edit vm xml as and configure libvirt secret:
# cat secret.xml
<secret ephemeral='no' private='yes'>
<description>Passphrase for the iSCSI example.com server</description>
<usage type='iscsi'>
<target>libvirtiscsi</target>
</usage>
</secret>

# virsh secret-define secret.xml
Secret 51611f0c-9afa-44f9-9ae0-27eae978cbdd created

# virsh secret-set-value 51611f0c-9afa-44f9-9ae0-27eae978cbdd `printf %s "redhat" | base64`
Secret value set

Vm xml will edit as:
...
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
        <adapter name='scsi_host3'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <alias name='ua-7996c8dc-a4fa-4012-b76f-043d20144263'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source protocol='iscsi' name='iqn.1992-01.com.example/0'>
        <host name='127.0.0.1' port='3260'/>
        <auth username='redhat'>
          <secret type='iscsi' usage='libvirtiscsi'/>
        </auth>
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </hostdev>
...

3.Start the vm and check qemu-cmd line:
# virsh start test2
Domain test2 started
# ps -ef |grep test2
...
device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=libvirt-3-backend,id=ua-7996c8dc-a4fa-4012-b76f-043d20144263 -object secret,id=libvirt-4-backend-secret0,data=h6inZ51XwGjxAotHFFrDaw==,keyid=masterKey0,iv=jY1B0mbidXqC1hgtOnzq5A==,format=base64 -blockdev {"driver":"iscsi","portal":"127.0.0.1:3260","target":"iqn.1992-01.com.example","lun":0,"transport":"tcp","user":"redhat","password-secret":"libvirt-4-backend-secret0","node-name":"libvirt-4-backend","read-only":false}...


Work as expected ,so verified.

Comment 9 errata-xmlrpc 2020-11-17 17:51: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 (virt:8.3 bug fix and enhancement update), 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/RHBA-2020:5137


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