Bug 1001078

Summary: virsh net-update delete ip-dhcp-host fails with incomplete XML
Product: Red Hat Enterprise Linux 7 Reporter: Ján Tomko <jtomko>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, dyuan, gsun, honzhang, jmiao
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.1.1-3.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 11:50:47 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:
Embargoed:

Description Ján Tomko 2013-08-26 13:02:05 UTC
Description of problem:
deleting a host with incomplete XML 

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

How reproducible:
You may rely on it.

Steps to Reproduce:
1. Have a network with a host in the dhcp section:
<network>
  <name>default</name>
...
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
      <host mac='12:34:56:78:90:ab' name='aaa' ip='192.168.122.123' />
    </dhcp>
  </ip>
</network>

2. virsh # net-update default delete ip-dhcp-host "<host ip='192.168.122.123'/>"
error: Failed to update network default
error: XML error: Static host definition in IPv4 network 'default' must have mac or name attribute

Expected results:
The host is deleted since it's uniquely identified by the IP.

Additional info:
Fixed upstream by:
commit cf602e7c597830a2d949017fe71f06b5f542c805
Author:     Ján Tomko <jtomko>
AuthorDate: 2013-07-31 13:25:59 +0200
Commit:     Ján Tomko <jtomko>
CommitDate: 2013-08-07 16:31:12 +0200

    Reverse logic allowing partial DHCP host XML
    
    Before, missing attributes were only OK when adding entries;
    modification and deletion required all of them.
    
    Now, only deletion works with missing attributes, as long as
    the host is uniquely identified.

git describe: v1.1.1-76-gcf602e7

The commit message is not completely accurate: Even though partial entries were parsed as correct when adding hosts by the function the commit is fixing, they were rejected later when the whole network XML was verified.

Comment 3 Jincheng Miao 2013-09-03 06:27:11 UTC
# rpm -q libvirt
libvirt-1.1.1-3.el7.x86_64

# virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>a04a5f8f-1f1a-45f6-ad95-e9d7cc07cf5f</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:71:f8:62'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
      <host mac='12:34:56:78:90:ab' name='aaa' ip='192.168.122.123' />
    </dhcp>
  </ip>
</network>

# virsh net-update default delete ip-dhcp-host "<host ip='192.168.122.123'/>"
Updated network default live state

# virsh net-dumpxml default<network>
  <name>default</name>
  <uuid>a04a5f8f-1f1a-45f6-ad95-e9d7cc07cf5f</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:71:f8:62'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>

host part is removed correctly, so I change the status to VERIFIED.

Comment 4 Ludek Smid 2014-06-13 11:50:47 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.