virsh domif-setlink is broken
Software environment
- Operating system: ArchLinux
- Architecture: x86_64
- kernel version: 6.1.8-arch1-1
- libvirt version: 9.0.0
- Hypervisor and version: KVM
Description of problem
domif-setlink
cannot change link state up or down if the link
tag is already in the XML.
virsh # domif-setlink win10 <MAC> up
error: Failed to update interface link state
error: (device_definition):5: Attribute state redefined
<link state="up" state="up"/>
---------------------------------^
virsh # domif-setlink win10 <MAC> down
error: Failed to update interface link state
error: (device_definition):5: Attribute state redefined
<link state="up" state="down"/>
-----------------------------------^
Steps to reproduce
- Create a domain
- Run
domif-setlink <domain_name> <mac_addr> up
more than once.
Additional information
This line looks suspicious: https://gitlab.com/libvirt/libvirt/-/blob/v9.0.0/tools/virsh-domain.c#L3212.
I think it should be if (xmlHasProp(linkNode, BAD_CAST "state"))
Edited by Recursive G