From patchwork Fri Apr 24 19:01:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 464370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 145981402D1 for ; Sat, 25 Apr 2015 05:02:07 +1000 (AEST) Received: from localhost ([::1]:46024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlirV-0007l5-9u for incoming@patchwork.ozlabs.org; Fri, 24 Apr 2015 15:02:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yliqs-0006HP-7v for qemu-devel@nongnu.org; Fri, 24 Apr 2015 15:01:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yliqq-00025g-UC for qemu-devel@nongnu.org; Fri, 24 Apr 2015 15:01:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yliqq-00025a-PH for qemu-devel@nongnu.org; Fri, 24 Apr 2015 15:01:24 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 60A388EA24; Fri, 24 Apr 2015 19:01:24 +0000 (UTC) Received: from localhost (ovpn-113-99.phx2.redhat.com [10.3.113.99]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3OJ1Ni2032545; Fri, 24 Apr 2015 15:01:24 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Fri, 24 Apr 2015 15:01:17 -0400 Message-Id: <1429902078-21770-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1429902078-21770-1-git-send-email-lcapitulino@redhat.com> References: <1429902078-21770-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 3/4] qmp-commands: fix incorrect uses of ":O" specifier X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paolo Bonzini As far as the QMP parser is concerned, neither the 'O' nor the 'q' format specifiers put any constraint on the command. However, there are two differences: 1) from a documentation point of view 'O' says that this command takes a dictionary. The dictionary will be converted to QemuOpts in the handler to match the corresponding HMP command. 2) 'O' sets QMP_ACCEPT_UNKNOWNS, resulting in the command accepting invalid extra arguments. For example the following is accepted: { "execute": "send-key", "arguments": { "keys": [ { "type": "qcode", "data": "ctrl" }, { "type": "qcode", "data": "alt" }, { "type": "qcode", "data": "delete" } ], "foo": "bar" } } Neither send-key nor migrate-set-capabilities take a QemuOpts-like dictionary; they take an array of dictionaries. And neither command really wants to have extra unknown arguments. Thus, the right specifier to use in this case is 'q'; with this patch the above command fails with {"error": {"class": "GenericError", "desc": "Invalid parameter 'foo'"}} as intended. Reported-by: Alberto Garcia Signed-off-by: Paolo Bonzini Reviewed-by: Alberto Garcia Signed-off-by: Luiz Capitulino --- qmp-commands.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qmp-commands.hx b/qmp-commands.hx index 3a42ad0..09f48ba 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -332,7 +332,7 @@ EQMP { .name = "send-key", - .args_type = "keys:O,hold-time:i?", + .args_type = "keys:q,hold-time:i?", .mhandler.cmd_new = qmp_marshal_input_send_key, }, @@ -3288,7 +3288,7 @@ EQMP { .name = "migrate-set-capabilities", - .args_type = "capabilities:O", + .args_type = "capabilities:q", .params = "capability:s,state:b", .mhandler.cmd_new = qmp_marshal_input_migrate_set_capabilities, },