qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/4] qcow2: Add qcow2_signal_corruption()
Date: Wed, 20 Aug 2014 21:17:09 +0200	[thread overview]
Message-ID: <53F4F435.8040707@redhat.com> (raw)
In-Reply-To: <20140820101019.GC6122@noname.redhat.com>

On 20.08.2014 12:10, Kevin Wolf wrote:
> Am 16.08.2014 um 23:16 hat Max Reitz geschrieben:
>> Add a helper function for easily marking an image corrupt while
>> outputting an informative message to stderr and via QAPI.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   block/qcow2.c | 28 ++++++++++++++++++++++++++++
>>   block/qcow2.h |  4 ++++
>>   2 files changed, 32 insertions(+)
>>
>> diff --git a/block/qcow2.c b/block/qcow2.c
>> index 435e0e1..ef2c931 100644
>> --- a/block/qcow2.c
>> +++ b/block/qcow2.c
>> @@ -30,6 +30,8 @@
>>   #include "qemu/error-report.h"
>>   #include "qapi/qmp/qerror.h"
>>   #include "qapi/qmp/qbool.h"
>> +#include "qapi/qmp/types.h"
>> +#include "qapi-event.h"
>>   #include "trace.h"
>>   #include "qemu/option_int.h"
>>   
>> @@ -2378,6 +2380,32 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts)
>>       return 0;
>>   }
>>   
>> +void qcow2_signal_corruption(BlockDriverState *bs, int64_t offset, int64_t size,
>> +                             const char *message_format, ...)
>> +{
>> +    char *message;
>> +    va_list ap;
>> +
>> +    va_start(ap, message_format);
>> +    message = g_strdup_vprintf(message_format, ap);
>> +    va_end(ap);
>> +
>> +    if (bs->read_only) {
>> +        fprintf(stderr, "qcow2: Image is corrupt: %s\n", message);
> The BDS isn't made unusable in read-only mode, so we can produce quite a
> lot of these messages and fill up the log. Perhaps it would be better to
> print the message only the first time (or the first n times) and then
> tell the user that further errors won't be logged.
>
> Also, including the block device or file name (or both) wouldn't hurt.

I'll include both in v2.

Max

>> +    } else {
>> +        fprintf(stderr, "qcow2: Marking image as corrupt: %s\n", message);
>> +        qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs), message,
>> +                                              offset >= 0, offset,
>> +                                              size >= 0, size, &error_abort);
>> +    }
>> +    g_free(message);
>> +
>> +    if (!bs->read_only) {
>> +        qcow2_mark_corrupt(bs);
>> +        bs->drv = NULL; /* make BDS unusable */
>> +    }
>> +}
> Kevin

  reply	other threads:[~2014-08-20 19:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-16 21:16 [Qemu-devel] [PATCH 0/4] qcow2: Check L1/L2/reftable entries for alignment Max Reitz
2014-08-16 21:16 ` [Qemu-devel] [PATCH 1/4] qcow2: Add qcow2_signal_corruption() Max Reitz
2014-08-20 10:10   ` Kevin Wolf
2014-08-20 19:17     ` Max Reitz [this message]
2014-08-16 21:16 ` [Qemu-devel] [PATCH 2/4] qcow2: Use qcow2_signal_corruption() for overlaps Max Reitz
2014-08-16 21:16 ` [Qemu-devel] [PATCH 3/4] iotests: Fix output of 060 Max Reitz
2014-08-20 10:13   ` Kevin Wolf
2014-08-16 21:16 ` [Qemu-devel] [PATCH 4/4] qcow2: Check L1/L2/reftable entries for alignment Max Reitz
2014-08-20 10:51   ` Kevin Wolf
2014-08-20 19:26     ` Max Reitz
2014-08-21  8:14       ` Kevin Wolf
2014-08-21 12:24         ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53F4F435.8040707@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).