Re: [libvirt] [PATCH 4/8] Fix up the error message if we can't parse the snapshot XML.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/4/27 Chris Lalancette <clalance@xxxxxxxxxx>:
> On 04/23/2010 02:06 PM, Matthias Bolte wrote:
>> 2010/4/23 Chris Lalancette <clalance@xxxxxxxxxx>:
>>> Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
>>> ---
>>>  src/conf/domain_conf.c |    3 +--
>>>  1 files changed, 1 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>>> index 6dc26c3..139712a 100644
>>> --- a/src/conf/domain_conf.c
>>> +++ b/src/conf/domain_conf.c
>>> @@ -6614,8 +6614,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
>>>     }
>>>
>>>     if (!xmlStrEqual(root->name, BAD_CAST "domainsnapshot")) {
>>> -        virDomainReportError(VIR_ERR_INTERNAL_ERROR,
>>> -                              "%s", _("incorrect root element"));
>>> +        virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot"));
>>>         goto cleanup;
>>>     }
>>>
>>
>> Could we have a bit more verbose error message here, like "unknown
>> root element for domain snapshot"?
>
> Well, we could go one of two ways.  The text that automatically
> comes out from VIR_ERR_XML_ERROR is:
>
> XML description for %s is not well formed or invalid
>

Ah, sorry. I missed the fact that VIR_ERR_XML_ERROR results in this
format string. I'm fine with the original patch then.

ACK.

If you grep the codebase for VIR_ERR_XML_ERROR then you'll find that
in most cases VIR_ERR_XML_ERROR is used in the wrong way, resulting in
a broken error message:

                virInterfaceReportError(VIR_ERR_XML_ERROR,
                                        "%s", _("bridge interface
misses the bridge element"));

Just reporting that the XML in not well formed (the string for
VIR_ERR_XML_ERROR implies this usage) is not that helpful. So we
include the relevant details in the error message, ignoring that the
string associated with VIR_ERR_XML_ERROR indicates a different usage.

Maybe we should unify the structure of the error code strings to a
format that expects the additional error message as a more detailed
description of the error. For example VIR_ERR_NO_DOMAIN or
VIR_ERR_INVALID_MAC or VIR_ERR_AUTH_FAILED already have this format.

Matthias

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]