Red Hat Bugzilla – Bug 697808
Improve error message when passing XML doc with wrong root element to define/create APIs.
Last modified: 2012-06-20 02:27:10 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:
> # 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.
Patches sent upstream: https://www.redhat.com/archives/libvir-list/2011-April/msg01183.html
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
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.
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.
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