qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <mlureau@redhat.com>
To: Alberto Garcia <berto@igalia.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH v6 15/18] monitor: use qmp_dispatch()
Date: Tue, 20 Sep 2016 18:00:39 -0400 (EDT)	[thread overview]
Message-ID: <81179735.279206.1474408839927.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1441973931.277653.1474408728887.JavaMail.zimbra@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]



----- Original Message -----
> Hi Alberto
> 
> ----- Original Message -----
> > On Mon, Sep 12, 2016 at 01:19:10PM +0400, Marc-André Lureau wrote:
> > > Replace the old manual dispatch and validation code by the generic one
> > > provided by qapi common code.
> > > 
> > > Note that it is now possible to call the following commands that used to
> > > be disabled by compile-time conditionals:
> > > - dump-skeys
> > > - query-spice
> > > - rtc-reset-reinjection
> > > - query-gic-capabilities
> > > 
> > > Their fallback functions return an appropriate "feature disabled" error.
> > > 
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > 
> > This patch breaks iotest 085 because the "missing parameter" error is
> > now different:
> > 
> > -{"error": {"class": "GenericError", "desc": "Parameter 'snapshot-file' is
> > missing"}}
> > +{"error": {"class": "GenericError", "desc": "Invalid parameter type for
> > 'snapshot-file', expected: string"}}
> > 
> > I was thinking to update the expected output of the iotest, but I
> > guess it's better to return a more meaningful error message?
> 
> The change is relatively easy (see attached patch), but there are other tests
> that expected the current error, see commit fe509ee237307843. I guess we
> should decided with one, and I think missing parameter is more appropriate.
> 

diff attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qapi-missingp.patch --]
[-- Type: text/x-patch; name=qapi-missingp.patch, Size: 5183 bytes --]

diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index 64dd392..22b132b 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -169,7 +169,11 @@ static void qmp_input_start_struct(Visitor *v, const char *name, void **obj,
     if (obj) {
         *obj = NULL;
     }
-    if (!qobj || qobject_type(qobj) != QTYPE_QDICT) {
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
+    if (qobject_type(qobj) != QTYPE_QDICT) {
         error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
                    "QDict");
         return;
@@ -194,7 +198,11 @@ static void qmp_input_start_list(Visitor *v, const char *name,
     QObject *qobj = qmp_input_get_object(qiv, name, true);
     const QListEntry *entry;
 
-    if (!qobj || qobject_type(qobj) != QTYPE_QLIST) {
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
+    if (qobject_type(qobj) != QTYPE_QLIST) {
         if (list) {
             *list = NULL;
         }
@@ -234,8 +242,10 @@ static void qmp_input_start_alternate(Visitor *v, const char *name,
     QmpInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qmp_input_get_object(qiv, name, false);
 
-    if (!qobj) {
+    if (obj) {
         *obj = NULL;
+    }
+    if (!qobj) {
         error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
         return;
     }
@@ -250,8 +260,13 @@ static void qmp_input_type_int64(Visitor *v, const char *name, int64_t *obj,
                                  Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
-    QInt *qint = qobject_to_qint(qmp_input_get_object(qiv, name, true));
+    QObject *qobj = qmp_input_get_object(qiv, name, true);
+    QInt *qint = qobject_to_qint(qobj);
 
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
     if (!qint) {
         error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
                    "integer");
@@ -266,8 +281,13 @@ static void qmp_input_type_uint64(Visitor *v, const char *name, uint64_t *obj,
 {
     /* FIXME: qobject_to_qint mishandles values over INT64_MAX */
     QmpInputVisitor *qiv = to_qiv(v);
-    QInt *qint = qobject_to_qint(qmp_input_get_object(qiv, name, true));
+    QObject *qobj = qmp_input_get_object(qiv, name, true);
+    QInt *qint = qobject_to_qint(qobj);
 
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
     if (!qint) {
         error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
                    "integer");
@@ -281,8 +301,13 @@ static void qmp_input_type_bool(Visitor *v, const char *name, bool *obj,
                                 Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
-    QBool *qbool = qobject_to_qbool(qmp_input_get_object(qiv, name, true));
+    QObject *qobj = qmp_input_get_object(qiv, name, true);
+    QBool *qbool = qobject_to_qbool(qobj);
 
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
     if (!qbool) {
         error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
                    "boolean");
@@ -296,8 +321,16 @@ static void qmp_input_type_str(Visitor *v, const char *name, char **obj,
                                Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
-    QString *qstr = qobject_to_qstring(qmp_input_get_object(qiv, name, true));
+    QObject *qobj = qmp_input_get_object(qiv, name, true);
+    QString *qstr = qobject_to_qstring(qobj);
 
+    if (obj) {
+        *obj = NULL;
+    }
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
     if (!qstr) {
         *obj = NULL;
         error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
@@ -316,6 +349,10 @@ static void qmp_input_type_number(Visitor *v, const char *name, double *obj,
     QInt *qint;
     QFloat *qfloat;
 
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
     qint = qobject_to_qint(qobj);
     if (qint) {
         *obj = qint_get_int(qobject_to_qint(qobj));
@@ -338,6 +375,14 @@ static void qmp_input_type_any(Visitor *v, const char *name, QObject **obj,
     QmpInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qmp_input_get_object(qiv, name, true);
 
+    if (obj) {
+        *obj = NULL;
+    }
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
+
     qobject_incref(qobj);
     *obj = qobj;
 }
@@ -347,6 +392,10 @@ static void qmp_input_type_null(Visitor *v, const char *name, Error **errp)
     QmpInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qmp_input_get_object(qiv, name, true);
 
+    if (!qobj) {
+        error_setg(errp, QERR_MISSING_PARAMETER, name ? name : "null");
+        return;
+    }
     if (qobject_type(qobj) != QTYPE_QNULL) {
         error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
                    "null");

  reply	other threads:[~2016-09-20 22:01 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12  9:18 [Qemu-devel] [PATCH v6 00/18] qapi: remove the 'middle' mode Marc-André Lureau
2016-09-12  9:18 ` [Qemu-devel] [PATCH v6 01/18] build-sys: define QEMU_VERSION_{MAJOR, MINOR, MICRO} Marc-André Lureau
2016-09-12 20:05   ` Eric Blake
2016-09-13  7:33     ` Markus Armbruster
2016-09-13 15:02       ` Eric Blake
2016-09-12  9:18 ` [Qemu-devel] [PATCH v6 02/18] qapi-schema: use generated marshaller for 'qmp_capabilities' Marc-André Lureau
2016-09-12  9:18 ` [Qemu-devel] [PATCH v6 03/18] qapi-schema: add 'device_add' Marc-André Lureau
2016-09-12  9:18 ` [Qemu-devel] [PATCH v6 04/18] monitor: simplify invalid_qmp_mode() Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 05/18] monitor: register gen:false commands manually Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 06/18] qapi: Support unregistering QMP commands Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 07/18] qmp: Hack to keep commands configuration-specific Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 08/18] qapi: export the marshallers Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 09/18] monitor: use qmp_find_command() (using generated qapi code) Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 10/18] monitor: implement 'qmp_query_commands' without qmp_cmds Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 11/18] monitor: remove mhandler.cmd_new Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 12/18] qapi: remove the "middle" mode Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 13/18] qapi: check invalid arguments on no-args commands Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 14/18] tests: add a test to check invalid args Marc-André Lureau
2016-09-12 11:23   ` Markus Armbruster
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 15/18] monitor: use qmp_dispatch() Marc-André Lureau
2016-09-20 14:48   ` Alberto Garcia
2016-09-20 21:58     ` Marc-André Lureau
2016-09-20 22:00       ` Marc-André Lureau [this message]
2016-09-21  6:15         ` Markus Armbruster
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 16/18] build-sys: remove qmp-commands-old.h Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 17/18] qmp-commands.hx: fix some styling Marc-André Lureau
2016-09-12  9:19 ` [Qemu-devel] [PATCH v6 18/18] Replace qmp-commands.hx by docs/qmp-commands.txt Marc-André Lureau
2016-09-12 21:22   ` Eric Blake
2016-09-13  7:37     ` Markus Armbruster
2016-09-12 21:52   ` Peter Maydell
2016-09-12 22:37     ` Marc-André Lureau
2016-09-13  7:41       ` Markus Armbruster
2016-09-12 11:46 ` [Qemu-devel] [PATCH v6 00/18] qapi: remove the 'middle' mode Markus Armbruster

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=81179735.279206.1474408839927.JavaMail.zimbra@redhat.com \
    --to=mlureau@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=eblake@redhat.com \
    --cc=marcandre.lureau@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).