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 2036895 - Update-device for interface with --live failed but with --persistent succeeded when a different alias specified
Summary: Update-device for interface with --live failed but with --persistent succeede...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.0
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Yanqiu Zhang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-04 11:07 UTC by Yanqiu Zhang
Modified: 2022-05-17 13:06 UTC (History)
8 users (show)

Fixed In Version: libvirt-8.0.0-0rc1.1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-17 12:46:17 UTC
Type: Bug
Target Upstream Version: 8.0.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-106786 0 None None None 2022-01-04 11:09:37 UTC
Red Hat Product Errata RHBA-2022:2390 0 None None None 2022-05-17 12:46:49 UTC

Description Yanqiu Zhang 2022-01-04 11:07:43 UTC
Description of problem:
Update-device for interface with --live failed but with --persistent succeeded when a different alias specified

Version-Release number of selected component (if applicable):
libvirt-7.10.0-1.el9.x86_64
qemu-kvm-6.2.0-1.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. edit vm:
    <interface type='network'>
      <mac address='52:54:00:44:11:60'/>
      <source network='default'/>
      <model type='virtio'/>
    </interface>

2. start vm
# virsh start avocado-bios
Domain 'avocado-bios' started
# virsh dumpxml avocado-bios |grep /inter -B8
    </controller>
    <interface type='network'>
      <mac address='52:54:00:44:11:60'/>
      <source network='default' portid='0728375b-5586-451d-8bf1-193f979278a5' bridge='virbr0'/>
      <target dev='vnet4'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

3. update-device
# cat iface-new.xml
    <interface type='network'>
      <mac address='52:54:00:44:11:60'/>
      <source network='default' portid='0728375b-5586-451d-8bf1-193f979278a5' bridge='virbr0'/>
      <target dev='vnet4'/>
      <model type='virtio'/>
            <link state='down'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

# virsh update-device avocado-bios iface-new.xml
error: Failed to update device from iface-new.xml
error: device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:44:11:60' and alias 'net1'

# virsh update-device avocado-bios iface-new.xml --persistent
Device updated successfully

Then get different live xml and inactive xml
# virsh dumpxml avocado-bios |grep /interface -B8
    <interface type='network'>
      <mac address='52:54:00:44:11:60'/>
      <source network='default' portid='1367e7d9-9156-4298-83aa-02c7ccba264b' bridge='virbr0'/>
      <target dev='vnet5'/>
      <model type='virtio'/>
      <link state='down'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

# virsh dumpxml avocado-bios --inactive|grep /interface -B8
    </controller>
    <interface type='network'>
      <mac address='52:54:00:44:11:60'/>
      <source network='default'/>
      <model type='virtio'/>
      <link state='down'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>


Actual results:
As in step3, update-device --live failed, but --persistent succeeded.

Expected results:
--persistent should only succeed when both --live and --config can succeed.
The live update-device should succeed or sth.

Additional info:
In man page: 
  "For  compatibility  purposes,  --persistent behaves like --config for an offline domain, and like --live --config for a running domain."
Take an example:
  # virsh attach-device avocado-vt-vm1 filesystem.xml --persistent 
   error: Failed to attach device from filesystem.xml
   error: Operation not supported: live attach of device 'filesystem' is not supported
  # virsh attach-device avocado-vt-vm1 filesystem.xml --config 
  Device attached successfully

Comment 1 Michal Privoznik 2022-01-04 16:47:15 UTC
This is bug in qemuDomainUpdateDeviceFlags(). Using --persistent is equivalent to --live --config; and qemu implementation does a copy of parsed input XML so that the original can be fed to live attach handling function and the copy to config attach handling function. But during this copy creation the live information is not preserved (the alias is considered as live information). The fix should be trivial, just swap those two copies.

Comment 2 Michal Privoznik 2022-01-04 17:00:04 UTC
Patch posted upstream:

https://listman.redhat.com/archives/libvir-list/2022-January/msg00129.html

Comment 3 Michal Privoznik 2022-01-06 11:34:56 UTC
Merged upstream:

7d9a7fdcd4 Account for fact that virDomainDeviceDefCopy() does an inactive copy

v7.10.0-431-g7d9a7fdcd4

Comment 6 Yanqiu Zhang 2022-01-10 08:23:37 UTC
Reproduce for detach-device scenario:
libvirt-7.10.0-1.el9.x86_64
qemu-kvm-6.2.0-1.el9.x86_64

Steps:
# virsh detach-device avocado-bios iface.xml 
error: Failed to detach device from iface.xml
error: device not found: no device found at address '(<null>)' matching MAC address '52:54:00:44:11:60' and alias 'net1'

# virsh detach-device avocado-bios iface.xml  --persistent
Device detached successfully


Pre-verify on:
libvirt: v7.10.0-469-g82d514084a
qemu-kvm-6.2.0-1.fc36.x86_64

Steps:
1. update-device:
# virsh update-device vm-bios iface-new.xml 
error: Failed to update device from iface-new.xml
error: device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:8c:f5:1c' and alias 'net1'

# virsh update-device vm-bios iface-new.xml  --live
error: Failed to update device from iface-new.xml
error: device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:8c:f5:1c' and alias 'net1'

# virsh update-device vm-bios iface-new.xml  --persistent
error: Failed to update device from iface-new.xml
error: device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:8c:f5:1c' and alias 'net1'

Check both live and inactive xml, neither changed:
# virsh dumpxml vm-bios |grep /inter -B8
    </controller>
    <interface type='network'>
      <mac address='52:54:00:8c:f5:1c'/>
      <source network='default' portid='40ea7af5-fb7e-4643-94c4-471d2341d2f7' bridge='virbr0'/>
      <target dev='vnet1'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>
# virsh dumpxml vm-bios --inactive |grep /inter -B8
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:8c:f5:1c'/>
      <source network='default'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

# virsh update-device vm-bios iface-new.xml  --config
Device updated successfully

# virsh dumpxml vm-bios --inactive |grep /inter -B8
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:8c:f5:1c'/>
      <source network='default'/>
      <model type='virtio'/>
      <link state='down'/>    <==changed
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

2. Detach-device:
# cat iface.xml
    <interface type='network'>
      <mac address='52:54:00:8c:f5:1c'/>
      <source network='default' portid='bdb8eeec-33d4-42b0-b7be-aacf84105c23' bridge='virbr0'/>
      <target dev='vnet2'/>
      <model type='virtio'/>
      <alias name='net1'/>  <==only change alias from live xml
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

# virsh detach-device vm-bios iface.xml 
error: Failed to detach device from iface.xml
error: device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:8c:f5:1c' and alias 'net1'

# virsh detach-device vm-bios iface.xml  --live
error: Failed to detach device from iface.xml
error: device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:8c:f5:1c' and alias 'net1'

# virsh detach-device vm-bios iface.xml  --persistent
error: Failed to detach device from iface.xml
error: device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:8c:f5:1c' and alias 'net1'

# virsh dumpxml vm-bios |grep /interface
    </interface>
# virsh dumpxml vm-bios --inactive |grep /inter
    </interface>

# virsh detach-device vm-bios iface.xml  --config
Device detached successfully

# virsh dumpxml vm-bios |grep /interface
    </interface>

# virsh dumpxml vm-bios --inactive |grep /inter 
(nothing output)

Comment 11 Yanqiu Zhang 2022-01-25 03:40:49 UTC
Verify on:
libvirt-8.0.0-1.el9.x86_64
qemu-kvm-6.2.0-3.el9.x86_64

Steps and results are same as pre-verification in comment6.

Comment 12 Yanqiu Zhang 2022-01-25 07:29:02 UTC
Covered in existing cases' steps.

Comment 14 errata-xmlrpc 2022-05-17 12:46: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 (new packages: libvirt), 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-2022:2390


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