[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Abnormal function exit message in Qemu block drivers code
From: |
shu ming |
Subject: |
[Qemu-devel] Abnormal function exit message in Qemu block drivers code |
Date: |
Thu, 27 Oct 2011 14:16:30 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 |
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;
}
- [Qemu-devel] Abnormal function exit message in Qemu block drivers code,
shu ming <=