Bug 1942367

Summary: Error message can be improved to include the alias mismatch info
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: yalzhang <yalzhang>
Component: libvirtAssignee: khanicov
Status: CLOSED ERRATA QA Contact: Yanqiu Zhang <yanqzhan>
Severity: low Docs Contact:
Priority: medium    
Version: 8.3CC: jdenemar, jsuchane, khanicov, smitterl, virt-maint, yanqzhan
Target Milestone: rcKeywords: Triaged, Upstream
Target Release: 8.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-7.5.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-16 07:52:17 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: 7.4.0
Embargoed:

Description yalzhang@redhat.com 2021-03-24 09:28:42 UTC
Description of problem:
Error message can be improved to include the alias as the alias name not match

Version-Release number of selected component (if applicable):
libvirt-7.0.0-10.module+el8.4.0+10417+37f6984d.x86_64

How reproducible:
100%

Steps to Reproduce:
1. # virsh dumpxml avocado-vt-vm1 | grep /interface -B12
...
<interface type='network'>
      <mac address='52:54:00:ab:1c:27'/>
      <source network='default' portid='0b147661-cc1c-4e91-ba17-4fa48aad54d9' bridge='virbr0'/>
      <target dev='vnet4'/>
      <model type='virtio'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </interface>
2. try to detach the interface with right mac and pci but wrong alias:
# cat net6.xml
<interface type='network'>
      <mac address='52:54:00:ab:1c:27'/>
      <source network='default' portid='0b147661-cc1c-4e91-ba17-4fa48aad54d9' bridge='virbr0'/>
      <target dev='vnet4'/>
      <model type='virtio'/>
      <alias name='net9'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </interface>
# virsh detach-device avocado-vt-vm1 net6.xml
error: Failed to detach device from net6.xml
error: device not found: no device matching MAC address 52:54:00:ab:1c:27 found on 0000:04:00.0
When the alias name is different in the xml file, the hot unplug failed, but the error message does not mention the alias difference, so it is confusing.
Actual results:
The root cause of the failure of match is the wrong alias, but the error message, but the error message doesn't mention it.

Expected results:
Improve the error message to include the mismatch of alias name

Additional info:
Refer to bug 1926190#c21

Comment 1 khanicov 2021-05-18 09:51:24 UTC
Patch proposed on the list:
https://listman.redhat.com/archives/libvir-list/2021-May/msg00481.html

Comment 2 khanicov 2021-05-20 14:19:13 UTC
Patch v2 proposed on the list:
https://listman.redhat.com/archives/libvir-list/2021-May/msg00616.html

Comment 3 khanicov 2021-06-17 10:27:35 UTC
Merged upstream as:

7ab1ba112f conf: Report alias name of the detached device in error 

v7.3.0-254-g7ab1ba112f

Comment 4 Yanqiu Zhang 2021-06-28 10:23:57 UTC
Tested on:
libvirt-7.5.0-1.fc35.x86_64
qemu-kvm-6.0.0-6.fc35.x86_64

virsh detach-device rhel9 net7.xml     
error: Failed to detach device from net7.xml
error: device not found: no device found at address '0000:00:03.0' matching MAC address '52:54:00:84:71:f7' and alias 'net7'

Comment 7 Yanqiu Zhang 2021-07-16 04:00:49 UTC
Verify on:
libvirt-daemon-7.5.0-1.module+el8.5.0+11664+59f87560.x86_64
qemu-kvm-6.0.0-23.module+el8.5.0+11740+35571f13.x86_64

Steps:
0. run a vm with interfaces:
# virsh dumpxml avocado-vt-vm1|grep /interface -B8
    </controller>
    <interface type='network'>
      <mac address='52:54:00:8c:2a:67'/>
      <source network='default' portid='15705c62-4e4a-48d3-a58a-e12c78ab9baa' bridge='virbr0'/>
      <target dev='vnet2'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>
    <interface type='direct'>
      <mac address='52:54:00:44:ff:e4'/>
      <source dev='enp0s25' mode='vepa'/>
      <target dev='macvtap2'/>
      <model type='rtl8139'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

1. Detach by right mac + wrong pci address
    <interface type='network'>
      <mac address='52:54:00:8c:2a:67'/>
      <source network='default' portid='4512200e-a41a-45bb-b66b-a17713703ded' bridge='virbr0'/>
      <target dev='vnet1'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
# virsh detach-device avocado-vt-vm1 net4.xml 
error: Failed to detach device from net4.xml
error: device not found: no device found at address '0000:00:03.0' matching MAC address '52:54:00:8c:2a:67' and alias 'net0'

2. no mac and wrong pci
# cat net8.xml 
<interface type='network'>
      <source network='default'/>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
    </interface>
# virsh detach-device avocado-vt-vm1 net8.xml 
error: Failed to detach device from net8.xml
error: device not found: no device found at address '0000:00:11.0' matching MAC address '(<null>)' and alias '(<null>)'

3. no PCI and wrong mac
# cat net9.xml 
<interface type='network'>
      <source network='default'/>
 <mac address='52:54:00:76:80:66'/>
      <model type='rtl8139'/>
    </interface>
# virsh detach-device avocado-vt-vm1 net9.xml 
error: Failed to detach device from net9.xml
error: device not found: no device found at address '(<null>)' matching MAC address '52:54:00:76:80:66' and alias '(<null>)'

4.multiple interface with the same mac
Change the second interface of vm to also use mac 52:54:00:8c:2a:67',
<interface type='network'>
      <mac address='52:54:00:8c:2a:67'/>
      <source network='isolated' bridge='virbr2'/>
    </interface>
# virsh detach-device avocado-vt-vm1 net11.xml 
error: Failed to detach device from net11.xml
error: operation failed: multiple devices matching MAC address 52:54:00:8c:2a:67 found

Comment 8 Yanqiu Zhang 2021-07-16 08:47:30 UTC
5. no matching device found
Run vm without interface device.
# virsh dumpxml avocado-vt-vm1|grep interface
(nothing)
# cat net6.xml
<interface type='network'>
      <source network='default' bridge='virbr0'/>
    </interface>
# virsh detach-device avocado-vt-vm1 net6.xml 
error: Failed to detach device from net6.xml
error: device not found: no device found at address '(<null>)' matching MAC address '(<null>)' and alias '(<null>)'

Comment 9 smitterl 2021-07-16 09:47:10 UTC
Confirmed for CCW addresses with:
libvirt-daemon-7.5.0-1.module+el8.5.0+11664+59f87560.s390x
qemu-kvm-6.0.0-23.module+el8.5.0+11740+35571f13.s390x


# virsh detach-device avocado-vt-vm1 iface_wrong_ccw.xml --config
error: Failed to detach device from iface_wrong_ccw.xml
error: device not found: no device found at address 'fe.0.0002' matching MAC address '52:54:00:54:eb:87' and alias '(<null>)'

# cat iface_wrong_ccw.xml 
   <interface type='network'>
      <mac address='52:54:00:54:eb:87'/>
      <source network='default'/>
      <model type='virtio'/>
      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
    </interface>

# virsh detach-device avocado-vt-vm1 iface_wrong_ccw_no_mac.xml --config
error: Failed to detach device from iface_wrong_ccw_no_mac.xml
error: device not found: no device found at address 'fe.0.0002' matching MAC address '(<null>)' and alias '(<null>)'

# cat iface_wrong_ccw_no_mac.xml 
   <interface type='network'>
      <source network='default'/>
      <model type='virtio'/>
      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
    </interface>

Comment 10 Yanqiu Zhang 2021-07-16 10:30:05 UTC
Thanks Sebas for ccw part testing.

Since above results are as expected, mark bug as verified.

Comment 12 errata-xmlrpc 2021-11-16 07:52:17 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:av 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-2021:4684