[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 0/8]: QError v2
From: |
Luiz Capitulino |
Subject: |
Re: [Qemu-devel] [RFC 0/8]: QError v2 |
Date: |
Wed, 11 Nov 2009 21:35:59 -0200 |
On Wed, 11 Nov 2009 15:20:30 -0600
Anthony Liguori <address@hidden> wrote:
> Luiz Capitulino wrote:
> > Hi,
> >
> > I can't remember seeing updated versions of a RFC series, but this should
> > prevent Anthony's scripts from merging these patches.
> >
> > This new QError version has two major changes: the static error table has
> > been dropped and I'm using symbolic names instead of error codes.
> >
> > Now, a call to:
> >
> > monitor_printf(mon, "husb: host usb device %d.%d is already open\n",
> > bus_num, addr);
> >
> > Would become something like:
> >
> > qemu_error_new('DeviceAlreadyOpen', "{ 'bus_num': %d, 'addr': %d }",
> > bus_num, addr);
> >
>
> I mostly like this but this is not what the patches do :-)
>
> Here's what I would like to see:
>
> #define QERR_DEVICE_ALREADY_OPEN "{'class': 'DeviceAlreadyOpen', 'data'
> : {'bus_num': %d, 'addr': %d}"
>
> qemu_error_new(QERR_DEVICE_ALREADY_OPEN, bus_num, addr);
>
> That gives us a nice simple interface with full error checking on the
> parameters.
>
> For human readable strings, I'd suggest making a table somewhere else
> that looked like:
>
> QErrorStringTable qerror_descriptions[] = {
> { QERR_DEVICE_ALREADY_OPEN, "This device at %(bus_num)d.%(addr)d is
> already open." },
> ...
> };
>
> There are a number of advantages to an approach like this. The table
> can be reused by both in the server and by a client.
I'm ok with this, the only comment I have is that 'class' should
be a member of QErrorStringTable, so that we can use it to lookup the
table.
- [Qemu-devel] [PATCH 1/8] QJSon: Introduce qobject_from_json_va(), (continued)
- [Qemu-devel] [PATCH 1/8] QJSon: Introduce qobject_from_json_va(), Luiz Capitulino, 2009/11/04
- [Qemu-devel] [PATCH 3/8] Add qstring_append_chr() unit-test, Luiz Capitulino, 2009/11/04
- [Qemu-devel] [PATCH 2/8] QString: Introduce qstring_append_chr(), Luiz Capitulino, 2009/11/04
- [Qemu-devel] [PATCH 4/8] QString: Introduce qstring_append_int(), Luiz Capitulino, 2009/11/04
- [Qemu-devel] [PATCH 5/8] Introduce QError, Luiz Capitulino, 2009/11/04
- [Qemu-devel] [PATCH 6/8] monitor: QError support, Luiz Capitulino, 2009/11/04
- [Qemu-devel] [PATCH 7/8] qdev: Use QError for not found error, Luiz Capitulino, 2009/11/04
- [Qemu-devel] [PATCH 8/8] monitor: do_info_balloon(): use QError, Luiz Capitulino, 2009/11/04
- Re: [Qemu-devel] [RFC 0/8]: QError v2, Anthony Liguori, 2009/11/11