[Top][All Lists]

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

Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks.

From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks.
Date: Thu, 13 Aug 2009 11:06:41 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

Gerd Hoffmann <address@hidden> writes:

> On 08/13/09 08:17, Markus Armbruster wrote:
>> One problem with passing up error codes is diagnostics: when we reach
>> the point where we can decide on policy, we've lost the context for
>> precise diagnostics.  net.c tackles that problem by passing the
>> destination for diagnostics down, to let code report errors with
>> config_error() while remaining unaware of policy.
> I don't want pass additional arguments all the way down just for error
> reporting.

It sure is tedious and ugly.

>             One thing we can do is storing the error message in a
> global or thread-local variable (much like errno).  We could also add
> a errmsg field to DeviceState and use that.
>> Issue also exists elsewhere.  Try monitor command "pci_add auto
>> model=?".
> Thats why I'd tend to use a global variable.  It also works in case
> don't have a DeviceState.

I find stashing error messages for later printing rather awkward.  Do
you provide space for one fixed-sized message?  Or arbitrary length?
Arbitrary number of messages?  Once you start to malloc(), you get to
worry about free()...  Meh.

I'd rather use the global or thread-local state to hold the sink for the
messages, then send the messages there as we make them.  No memory
management worries.

reply via email to

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