qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Abnormal function exit message in Qemu block drivers code
@ 2011-10-27  6:16 shu ming
  2011-10-27  8:05 ` Cao,Bing Bu
  0 siblings, 1 reply; 2+ messages in thread
From: shu ming @ 2011-10-27  6:16 UTC (permalink / raw)
  To: QEMU Developers

Hi,
   After reading the block driver code in,  it was found that the error 
exit code behaved in different ways.  Here are some examples.  It seems 
that way 3 is a better way to log the error message.  In fact,  It is 
pretty important for a administrator to know what is going on and be 
informed the error when that happens. I believe  we should convert all 
the error exit code to way 3 gradually and make all the new code to 
follow an unique standard.
   Further more, really, some errors can be ignored while others can 
not.  So we can have a more flexible function to classify the level of 
the error message like
error_report(log_level,  "string format", string);

1)The error code exited silently.

case QCOW2_EXT_MAGIC_BACKING_FORMAT:
             if (ext.len >= sizeof(bs->backing_format)) {
                 fprintf(stderr, "ERROR: ext_backing_format: len=%u too 
large"
                         " (>=%zu)\n",
                         ext.len, sizeof(bs->backing_format));
                 return 2;
             }

2)  fprintf() to emit the error message

case QCOW2_EXT_MAGIC_BACKING_FORMAT:
             if (ext.len >= sizeof(bs->backing_format)) {
                 fprintf(stderr, "ERROR: ext_backing_format: len=%u too 
large"
                         " (>=%zu)\n",
                         ext.len, sizeof(bs->backing_format));
                 return 2;

3) A error_report() function to emit the error message.

/* Find driver and parse its options */
     drv = bdrv_find_format(fmt);
     if (!drv) {
         error_report("Unknown file format '%s'", fmt);
         ret = -EINVAL;
         goto out;
     }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] Abnormal function exit message in Qemu block drivers code
  2011-10-27  6:16 [Qemu-devel] Abnormal function exit message in Qemu block drivers code shu ming
@ 2011-10-27  8:05 ` Cao,Bing Bu
  0 siblings, 0 replies; 2+ messages in thread
From: Cao,Bing Bu @ 2011-10-27  8:05 UTC (permalink / raw)
  To: shu ming; +Cc: QEMU Developers

On 10/27/2011 02:16 PM, shu ming wrote:
> Hi,
>   After reading the block driver code in,  it was found that the error 
> exit code behaved in different ways.  Here are some examples.  It 
> seems that way 3 is a better way to log the error message.  In fact,  
> It is pretty important for a administrator to know what is going on 
> and be informed the error when that happens. I believe  we should 
> convert all the error exit code to way 3 gradually and make all the 
> new code to follow an unique standard.
>   Further more, really, some errors can be ignored while others can 
> not.  So we can have a more flexible function to classify the level of 
> the error message like
> error_report(log_level,  "string format", string);
>
> 1)The error code exited silently.
>
> case QCOW2_EXT_MAGIC_BACKING_FORMAT:
>             if (ext.len >= sizeof(bs->backing_format)) {
>                 fprintf(stderr, "ERROR: ext_backing_format: len=%u too 
> large"
>                         " (>=%zu)\n",
>                         ext.len, sizeof(bs->backing_format));
>                 return 2;
>             }

The example of the first way looks like not correct.

     case QCOW2_EXT_MAGIC_BACKING_FORMAT:
         if (ext.len >= sizeof(bs->backing_format)) {
-           fprintf(stderr, "ERROR: ext_backing_format: len=%u too large"
-                      " (>=%zu)\n",
-                       ext.len, sizeof(bs->backing_format));
             return 2;
         }

> 2)  fprintf() to emit the error message
>
> case QCOW2_EXT_MAGIC_BACKING_FORMAT:
>             if (ext.len >= sizeof(bs->backing_format)) {
>                 fprintf(stderr, "ERROR: ext_backing_format: len=%u too 
> large"
>                         " (>=%zu)\n",
>                         ext.len, sizeof(bs->backing_format));
>                 return 2;
> 3) A error_report() function to emit the error message.
>
> /* Find driver and parse its options */
>     drv = bdrv_find_format(fmt);
>     if (!drv) {
>         error_report("Unknown file format '%s'", fmt);
>         ret = -EINVAL;
>         goto out;
>     }
>
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-27  8:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-27  6:16 [Qemu-devel] Abnormal function exit message in Qemu block drivers code shu ming
2011-10-27  8:05 ` Cao,Bing Bu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).