qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [RFC] Fixing the error failure
Date: Wed, 20 Jun 2012 14:48:38 -0300	[thread overview]
Message-ID: <20120620144838.2abb5a4f@doriath.home> (raw)
In-Reply-To: <20120619101229.52273d97@doriath.home>

Yet another thread fork.

After talking with Daniel and Markus about QMP errors (which is not just about
QMP, as this affects QEMU as whole), I've put together the proposal below.

I'll discuss three points. First, the error format and classes. Second, the
internal API and third compatibility.

Don't be afraid about the length of this email, only the first section is long
but it mostly contains error classes listings.

1. Error format and classes

We can keep the same error format we have today, which is:

 { "error": { "class": json-string,
              "data": json-object,
              "desc": json-string }, "id": json-value }

  where 'data', 'desc' and 'id' are optional fields.

However, we'd change how we use 'desc' and our error classes. 'desc' would
become a string which is filled by a printf-like function (see section 2) and
we'd replace all error classes we have today by the following ones:

  o ParameterError: any error which involves a bad parameter. Replaces
    InvalidParameter, InvalidParameterCombination, InvalidParameterType,
    InvalidParameterValue, MissingParameter

  o SystemError: syscall or library errors. Replaces BufferOverrun,
    IOError, OpenFileFailed, PermissionDenied, TooManyFiles,
    SockConnectInprogress, SockConnectFailed, SockListenFailed,
    SockBindFailed, SockCreateFailed.

    This error can include an optional 'os-error' field in the 'data'
    member (see section 2).

  o QEMUError: errors that are internal to QEMU, like AmbiguousPath,
    BadBusForDevice, BusNoHotplug, BusNotFound, CommandDisabled,
    CommandNotFound, DuplicateId, FeatureDisabled, JSONParseError,
    JSONParsing, KVMMissingCap, MigrationActive, MigrationNotSupported,
    MigrationExpected, NoBusForDevice, NotSupported, PropertyValueBad,
    PropertyValueInUse, PropertyValueNotFound, PropertyValueNotPowerOf2,
    PropertyValueOutOfRange, ResetRequired, SetPasswdFailed, Unsupported,
    VirtFSFeatureBlocksMigration, VNCServerFailed

  o UndefinedError: the same it's today, undefined :)

Now, there are two important points to be observed:

 - We check for DeviceEncrypted in hmp.c and fetch its parameters. This
   probably indicates that we might want to create specialized classes
   when necessary

 - I don't know where to put all the DeviceFoo errors, but they probably fit
   in QEMUError or a new class like DeviceError

2. Internal API

This is very straightforward:

 o error_set_deprecated();

   Current error_set(), case we keep it for compatibility (see section 3).

 o error_set(ErrorClass err_class, const char *fmt, ...);

   Main function, sets the error classes and allow for a free human-readable
   error message.

 o error_set_sys_fmt(int err_no, const char *fmt, ...);
 o error_set_sys(int err_no);

   Helpers for setting SystemError errors. error_set_sys() gets the 'desc'
   string from strerror().

3. Compatibility

We have two options here:

 1. Maintain the current errors and implement the new way only for new
    commands (includes commands merged for 1.2).

      Pros: maintains compatibility and won't require any code churn
      Cons: we'll have two different errors schemas in use at the same
            time and will be carrying garbage forward

 2. Do a full conversion to the new way.

      Pros: we drop bad code and avoid pollution (good for Rio+20)
      Cons: possibly breaks compatibility and will require a lot of code
            churn up front

  reply	other threads:[~2012-06-20 17:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1338387301-10074-1-git-send-email-lcapitulino@redhat.com>
     [not found] ` <1338387301-10074-3-git-send-email-lcapitulino@redhat.com>
     [not found]   ` <4FC74B1A.8080700@redhat.com>
     [not found]     ` <20120531110608.4dc3fe22@doriath.home>
     [not found]       ` <4FC77F6C.8000008@redhat.com>
     [not found]         ` <20120531113127.1c8aa213@doriath.home>
     [not found]           ` <4FC78637.4040605@redhat.com>
     [not found]             ` <20120531124411.659ed161@doriath.home>
     [not found]               ` <4FC79316.6080603@redhat.com>
     [not found]                 ` <20120531130814.5779aae9@doriath.home>
2012-06-01 12:40                   ` [Qemu-devel] [PATCH 02/14] qerror: add new errors Kevin Wolf
2012-06-13 17:49             ` [Qemu-devel] Adding errno to QMP errors Luiz Capitulino
2012-06-15 14:46               ` Luiz Capitulino
2012-06-15 16:52               ` Anthony Liguori
2012-06-15 16:55                 ` Paolo Bonzini
2012-06-15 17:48                   ` Anthony Liguori
2012-06-15 19:11                     ` Paolo Bonzini
2012-06-15 17:02                 ` Luiz Capitulino
2012-06-15 17:23                   ` Kevin Wolf
2012-06-15 17:03                 ` Daniel P. Berrange
2012-06-18 15:41                   ` Markus Armbruster
2012-06-18 18:31                     ` Anthony Liguori
2012-06-19  7:39                       ` Kevin Wolf
2012-06-19  9:20                         ` Daniel P. Berrange
2012-06-19  9:31                           ` Kevin Wolf
2012-06-19 13:12                       ` Luiz Capitulino
2012-06-20 17:48                         ` Luiz Capitulino [this message]
2012-06-20 18:46                           ` [Qemu-devel] [RFC] Fixing the error failure Anthony Liguori
2012-06-20 19:40                             ` Luiz Capitulino
2012-06-20 19:47                               ` Anthony Liguori
2012-06-20 20:13                                 ` Luiz Capitulino
2012-06-21 12:42                           ` Daniel P. Berrange
     [not found]                             ` <20120625165651.31f9e0bd@doriath.home>
     [not found]                               ` <m34npyld8y.fsf@blackfin.pond.sub.org>
     [not found]                                 ` <20120626093511.GD14451@redhat.com>
     [not found]                                   ` <m3hatyco9g.fsf@blackfin.pond.sub.org>
     [not found]                                     ` <4FE9E275.40303@codemonkey.ws>
     [not found]                                       ` <m3txxvq3i3.fsf@blackfin.pond.sub.org>
2012-07-02 12:47                                         ` Anthony Liguori
2012-07-02 13:47                                           ` Luiz Capitulino
2012-07-02  8:03                           ` Paolo Bonzini

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=20120620144838.2abb5a4f@doriath.home \
    --to=lcapitulino@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).