qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v7] pflash: Require backend size to match device


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH v7] pflash: Require backend size to match device, improve errors
Date: Fri, 8 Mar 2019 18:18:58 +0100
User-agent: Mutt/1.11.3 (2019-02-01)

Am 08.03.2019 um 18:03 hat Markus Armbruster geschrieben:
> >> bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
> >>                                  Error **errp)
> >> {
> >>     int64_t blk_len;
> >>     int ret;
> >> 
> >>     blk_len = blk_getlength(blk);
> >>     if (blk_len < 0) {
> >>         error_setg_errno(errp, -blk_len,
> >>                          "can't get size of block backend '%s'",
> >>                          blk_name(blk));
> >>         return false;
> >>     }
> >>     if (blk_len != size) {
> >>         error_setg(errp, "device requires %" PRIu64 " bytes, "
> >>                    "block backend '%s' provides %" PRIu64 " bytes",
> >>                    size, blk_name(blk), blk_len);
> >
> > Should size use HWADDR_PRIu?
> 
> Yes.
> 
> > I'm not sure if printing the BlockBackend name is a good idea because
> > hopefully one day the BlockBackend will be anonymous even for the flash
> > devices.
> 
> Hmm.  Tell me what else I can use to identify the troublemaker to the
> user.

My hope was that a caller of this would prefix the right context. For
example, if the device were created by -device, the error message would
be prefixed with the whole "-device driver=pflash...:" string, which
gives enough context to the user.

Machine code that instantiates the device based on -drive should
probably do something similar.

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]