Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 697808 - Improve error message when passing XML doc with wrong root element to define/create APIs.
Improve error message when passing XML doc with wrong root element to define/...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.1
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Michal Privoznik
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-19 06:46 EDT by Vivian Bian
Modified: 2012-06-20 02:27 EDT (History)
9 users (show)

See Also:
Fixed In Version: libvirt-0.9.9-1.el6
Doc Type: Bug Fix
Doc Text:
Cause: Passing a XML with incorrect root element throws an wrong and useless error. Consequence: Users were confused. Change: Change error strings (from "incorrect root element" to "unexpected root element X expecting to see Y") and error codes (from "internal error" to "xml error"). Result: Users are no longer confused even when they provide incorrect XML.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-20 02:27:10 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 15:31:38 EDT

  None (edit)
Description Vivian Bian 2011-04-19 06:46:46 EDT
Description of problem:


Version-Release number of selected component (if applicable):
libvirt-0.8.7-18.el6.x86_64


How reproducible:
always

Steps to Reproduce:
# virsh pool-list --all
Name                 State      Autostart 
-----------------------------------------
default              active     yes       
mypool               inactive   no  

# virsh pool-dumpxml mypool > mypool-duplicate

# vim mypool-duplicate  (edit the pool name to mypool-duplicate , and leave the
uuid the same with mypool)

# virsh define mypool-duplicate
error: Failed to define domain from mypool-duplicate
error: internal error incorrect root element

# virsh pool-list --all
Name                 State      Autostart 
-----------------------------------------
default              active     yes       
mypool               inactive   no    


Although we don't allow to create pools with same UUID , but the error thrown
out doesn't point out the exact errors .
  
Actual results:


Expected results:


Additional info:
Comment 1 Daniel Berrange 2011-04-19 07:07:42 EDT
> # virsh define mypool-duplicate
> error: Failed to define domain from mypool-duplicate
> error: internal error incorrect root element

You are using the wrong command here. You need 'pool-define', not 'define'.

I would close this NOTABUG, but I think we could actually improve the error message 

 a. It is not an 'internal error', it is a user error
 b. 'incorrect root element' should really say 'unexpected root element <pool>, expecting to see <domain>'


I expect all the other virXXXXDefine and virXXXCreate methods which accept an XML doc could benefit from same improved error messages.
Comment 2 Michal Privoznik 2011-04-27 11:01:17 EDT
Patches sent upstream:

https://www.redhat.com/archives/libvir-list/2011-April/msg01183.html
Comment 6 Michal Privoznik 2011-11-28 10:47:04 EST
Moving to POST:

commit a6916977bb4d3b1d765ceccd614f6514b0ce355a
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Fri Nov 25 13:23:03 2011 +0100
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Mon Nov 28 15:12:37 2011 +0100

    conf: Improve incorrect root element error messages
    
    When user pass wrong root element, it is not 'internal error' and
    we can give him hint what we are expecting.

v0.9.7-167-ga691697
Comment 9 zhe peng 2012-01-10 01:43:46 EST
I can reproduce this bug with libvirt-0.8.7-18.el6_1.3.x86_64

verify on:
libvirt-0.9.9-1.el6.x86_64

step:
# virsh pool-list --all
Name                 State      Autostart 
-----------------------------------------
default              active     yes       
dir                  active     yes       
testiqn              active     yes   

#virsh pool-dumpxml dir > dir-duplicate

#virsh define dir-duplicate
error: Failed to define domain from dir-duplicate
error: XML error: unexpected root element <pool>, expecting <domain>

the error message improved.
move to verified.
Comment 10 Michal Privoznik 2012-05-02 03:54:57 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: Passing a XML with incorrect root element throws an wrong and useless error.
Consequence: Users were confused.
Change: Change error strings (from "incorrect root element" to "unexpected root element X expecting to see Y") and error codes (from "internal error" to "xml error").
Result: Users are no longer confused even when they provide incorrect XML.
Comment 12 errata-xmlrpc 2012-06-20 02:27:10 EDT
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, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0748.html

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