[libvirt] [PATCH] qemu: Report binary path if error parsing -help

Cole Robinson crobinso at redhat.com
Thu Feb 25 17:00:04 UTC 2010


On 02/25/2010 07:32 AM, Daniel Veillard wrote:
> On Wed, Feb 24, 2010 at 12:55:19PM -0500, Cole Robinson wrote:
>>
>> Signed-off-by: Cole Robinson <crobinso at redhat.com>
>> ---
>>  src/qemu/qemu_conf.c |   14 ++++++++------
>>  src/qemu/qemu_conf.h |    3 ++-
>>  tests/qemuhelptest.c |    3 ++-
>>  3 files changed, 12 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
>> index e3da08a..1f8a9c3 100644
>> --- a/src/qemu/qemu_conf.c
>> +++ b/src/qemu/qemu_conf.c
>> @@ -1237,7 +1237,8 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
>>  
>>  #define SKIP_BLANKS(p) do { while ((*(p) == ' ') || (*(p) == '\t')) (p)++; } while (0)
>>  
>> -int qemudParseHelpStr(const char *help,
>> +int qemudParseHelpStr(const char *qemu,
>> +                      const char *help,
>>                        unsigned long long *flags,
>>                        unsigned int *version,
>>                        unsigned int *is_kvm,
>> @@ -1308,8 +1309,8 @@ fail:
>>          p = strndup(help, p - help);
>>  
>>      qemuReportError(VIR_ERR_INTERNAL_ERROR,
>> -                    _("cannot parse QEMU version number in '%s'"),
>> -                    p ? p : help);
>> +                    _("cannot parse %s version number in '%s'"),
>> +                    qemu, p ? p : help);
>>  
>>      VIR_FREE(p);
>>  
>> @@ -1340,12 +1341,13 @@ int qemudExtractVersionInfo(const char *qemu,
>>      enum { MAX_HELP_OUTPUT_SIZE = 1024*64 };
>>      int len = virFileReadLimFD(newstdout, MAX_HELP_OUTPUT_SIZE, &help);
>>      if (len < 0) {
>> -        virReportSystemError(errno, "%s",
>> -                             _("Unable to read QEMU help output"));
>> +        virReportSystemError(errno,
>> +                             _("Unable to read %s help output"), qemu);
>>          goto cleanup2;
>>      }
>>  
>> -    if (qemudParseHelpStr(help, &flags, &version, &is_kvm, &kvm_version) == -1)
>> +    if (qemudParseHelpStr(qemu, help, &flags,
>> +                          &version, &is_kvm, &kvm_version) == -1)
>>          goto cleanup2;
>>  
>>      if (retversion)
>> diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
>> index ae187dc..c8757c5 100644
>> --- a/src/qemu/qemu_conf.h
>> +++ b/src/qemu/qemu_conf.h
>> @@ -175,7 +175,8 @@ int         qemudExtractVersionInfo     (const char *qemu,
>>                                           unsigned int *version,
>>                                           unsigned long long *qemuCmdFlags);
>>  
>> -int         qemudParseHelpStr           (const char *str,
>> +int         qemudParseHelpStr           (const char *qemu,
>> +                                         const char *str,
>>                                           unsigned long long *qemuCmdFlags,
>>                                           unsigned int *version,
>>                                           unsigned int *is_kvm,
>> diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
>> index 0f2b509..ad355d7 100644
>> --- a/tests/qemuhelptest.c
>> +++ b/tests/qemuhelptest.c
>> @@ -49,7 +49,8 @@ static int testHelpStrParsing(const void *data)
>>      if (virtTestLoadFile(path, &help, MAX_HELP_OUTPUT_SIZE) < 0)
>>          return -1;
>>  
>> -    if (qemudParseHelpStr(help, &flags, &version, &is_kvm, &kvm_version) == -1)
>> +    if (qemudParseHelpStr("QEMU", help, &flags,
>> +                          &version, &is_kvm, &kvm_version) == -1)
>>          return -1;
>>  
>>      if (flags != info->flags) {
> 
>   ACK,
> 
> Daniel
> 

Thanks, pushed this and my other pending error message patches.

- Cole




More information about the libvir-list mailing list