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 2165466 - Can not update interface link state by domif-setlink
Summary: Can not update interface link state by domif-setlink
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: yalzhang@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-01-30 07:23 UTC by yalzhang@redhat.com
Modified: 2023-05-09 08:11 UTC (History)
3 users (show)

Fixed In Version: libvirt-9.0.0-3.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:27:45 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-146843 0 None None None 2023-01-30 07:45:42 UTC
Red Hat Product Errata RHBA-2023:2171 0 None None None 2023-05-09 07:28:15 UTC

Description yalzhang@redhat.com 2023-01-30 07:23:56 UTC
Description of problem:
Can not update interface link state by domif-setlink

Version-Release number of selected component (if applicable):
libvirt-9.0.0-2.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare a vm with interface xml with link state setting:
# virsh dumpxml rhel --xpath //interface
<interface type="network">
  <mac address="52:54:00:60:8a:32"/>
  <source network="default"/>
  <model type="virtio"/>
  <link state="up"/>
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>

2. start the vm, then live update the link state by domif-setlink:
# virsh start rhel
Domain 'rhel' started

# virsh domiflist rhel
 Interface   Type      Source    Model    MAC
-------------------------------------------------------------
 vnet3       network   default   virtio   52:54:00:60:8a:32

# virsh domif-setlink rhel vnet3 down
error: Failed to update interface link state
error: (device_definition):6: Attribute state redefined
      <link state="up" state="down"/>
-----------------------------------^

Actual results:
In step 2, the xml  parsing doesn't make sense

Expected results:
The domif-setlink should work properly

Additional info:

Comment 1 Peter Krempa 2023-01-31 09:13:57 UTC
Fixed upstream by:

commit 6f3f6c0f763b9ffd8ef93eb124c88dd0b79138fc
Author: Michal Prívozník <mprivozn>
Date:   Mon Jan 30 10:55:22 2023 +0100

    virsh: Make domif-setlink work more than once
    
    In virsh, we have this convenient domif-setlink command, which is
    just a wrapper over virDomainUpdateDeviceFlags() and which allows
    setting link state of given guest NIC. It does so by fetching
    corresponding <interface/> XML snippet and either putting <link
    state=''/> into it, OR if the element already exists setting the
    attribute to desired value. The XML is then fed into the update
    API.
    
    There's, however, a small bug in detecting the pre-existence of
    the element and its attribute. The code looks at "link"
    attribute, while in fact, the attribute is called "state".
    
    Resolves: https://gitlab.com/libvirt/libvirt/-/issues/426
    Fixes: e575bf082ed4889280be07c986375f1ca15bb7ee
    Signed-off-by: Michal Privoznik <mprivozn>
    Reviewed-by: Ján Tomko <jtomko>

Comment 3 yalzhang@redhat.com 2023-02-02 07:41:13 UTC
Test on libvirt-9.0.0-3.el9.x86_64, the result is as expected.

# virsh dumpxml rhel --xpath //interface 
<interface type="network">
  <mac address="52:54:00:60:8a:32"/>
  <source network="default" portid="c6ec8acd-ddb8-46b6-ab45-f0f949b2a3e6" bridge="virbr0"/>
  <target dev="vnet0"/>
  <model type="virtio"/>
  <link state="up"/>
  <alias name="net0"/>
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>

# virsh domif-setlink rhel vnet0 down
Device updated successfully

# virsh dumpxml rhel --xpath //interface 
<interface type="network">
  <mac address="52:54:00:60:8a:32"/>
  <source network="default" portid="c6ec8acd-ddb8-46b6-ab45-f0f949b2a3e6" bridge="virbr0"/>
  <target dev="vnet0"/>
  <model type="virtio"/>
  <link state="down"/>
  <alias name="net0"/>
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>

Comment 6 yalzhang@redhat.com 2023-02-02 10:31:08 UTC
Run auto cases "virsh.domif_setlink_getlink", no such issue any more.

Comment 8 errata-xmlrpc 2023-05-09 07:27:45 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 (libvirt 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-2023:2171


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