Bug 697808 - Improve error message when passing XML doc with wrong root element to define/create APIs.
Summary: Improve error message when passing XML doc with wrong root element to define/...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-04-19 10:46 UTC by Vivian Bian
Modified: 2012-06-20 06:27 UTC (History)
9 users (show)

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.
Clone Of:
Environment:
Last Closed: 2012-06-20 06:27:10 UTC


Attachments (Terms of Use)


Links
System 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 19:31:38 UTC

Description Vivian Bian 2011-04-19 10:46:46 UTC
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 Berrangé 2011-04-19 11:07:42 UTC
> # 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 15:01:17 UTC
Patches sent upstream:

https://www.redhat.com/archives/libvir-list/2011-April/msg01183.html

Comment 6 Michal Privoznik 2011-11-28 15:47:04 UTC
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 06:43:46 UTC
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 07:54:57 UTC
    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 06:27:10 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, 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.