Bug 1918674 - output proper error when <dhcp><lease "expiry" can't be parsed
Summary: output proper error when <dhcp><lease "expiry" can't be parsed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.4
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: rc
: 8.4
Assignee: Peter Krempa
QA Contact: Yanqiu Zhang
URL:
Whiteboard:
Depends On:
Blocks: 1926508
TreeView+ depends on / blocked
 
Reported: 2021-01-21 10:44 UTC by yalzhang@redhat.com
Modified: 2021-11-23 08:39 UTC (History)
3 users (show)

Fixed In Version: libvirt-7.3.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 07:51:32 UTC
Type: Bug
Target Upstream Version: 7.1.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4684 0 None None None 2021-11-16 07:51:58 UTC

Description yalzhang@redhat.com 2021-01-21 10:44:33 UTC
Description of problem:
Suggest to update error message "An error occurred, but the cause is unknown"

Version-Release number of selected component (if applicable):
libvirt-7.0.0-1.module+el8.4.0+9464+3e71831a.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Edit the network with invalid expiry time, it will report error:
<network>
  <name>test5</name>
  <uuid>9d0ddef3-0ce9-4d1e-ad24-be10477f0e79</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr1' stp='on' delay='0'/>
  <mac address='52:54:00:cf:d0:48'/>
  <ip address='192.168.232.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.232.2' end='192.168.232.254'>
       ** <lease expiry='sdf' unit='hours'/> **
      </range>
    </dhcp>
  </ip>
error: An error occurred, but the cause is unknown
Failed. Try again? [y,n,f,?]: 

2. try "<lease expiry='' unit='hours'/>", <lease expiry='  ' unit='hours'/>, same error occurs.

Actual results:
The error message says  "An error occurred, but the cause is unknown"

Expected results:
The error message can be more detailed

Additional info:

Comment 1 Peter Krempa 2021-01-22 09:42:48 UTC
Fixed upstream:

commit 196ebfc24086b358f5110177b4b9f8e35b7daed0
Author: Peter Krempa <pkrempa>
Date:   Thu Jan 21 17:35:12 2021 +0100

    virNetworkDHCPLeaseTimeDefParseXML: Output error when 'expiry' can't be parsed
    
    virStrToLong_ul doesn't report it's own error.

Comment 4 Yanqiu Zhang 2021-06-03 10:40:42 UTC
Verified on:
libvirt-daemon-7.4.0-1.module+el8.5.0+11218+83343022.x86_64
qemu-kvm-6.0.0-17.module+el8.5.0+11173+c9fce0bb.x86_64


Steps:
1. # virsh net-define net-test5.xml
error: Failed to define network from net-test5.xml
error: XML error: Invalid value for attribute 'expiry' in element 'lease': 'sdf'. Expected integer value

error: Failed to define network from net-test5.xml
error: XML error: Invalid value for attribute 'expiry' in element 'lease': ''. Expected integer value

2. # virsh net-edit test5 
error: XML error: Invalid value for attribute 'expiry' in element 'lease': 'abc'. Expected integer value
Failed. Try again? [y,n,f,?]: 

error: XML error: Invalid value for attribute 'expiry' in element 'lease': ''. Expected integer value
Failed. Try again? [y,n,f,?]:

3. # virsh net-create net-test5.xml 
error: Failed to create network from net-test5.xml
error: XML error: Invalid value for attribute 'expiry' in element 'lease': '23now'. Expected integer value

error: Failed to create network from net-test5.xml
error: XML error: Invalid value for attribute 'expiry' in element 'lease': ''. Expected integer value

4. With a long number:
error: XML error: Invalid value for attribute 'expiry' in element 'lease': '111111111111111111111111111111111111'. Expected integer value

Mark as verified per steps1-3. Ignore step4's minor issue.

Comment 6 errata-xmlrpc 2021-11-16 07:51:32 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


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