From nobody Thu Nov 13 23:24:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583253390; cv=none; d=zohomail.com; s=zohoarc; b=Tb9bQcZNIWg2ALFzIjxm71yw7d1NpsghK7TdWnoFahme1gD39ClklkKpgqWBjyGTsDS8lCOhGcRavELc/mOSlGGRgo2RXcKZkP3jGQVko4kcvCa8HhxlXtTZcxNsQqiruBl4IvzDax3Hp7eGEuNhadYqrTFWZSLBtxu11wNRN3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583253390; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DolF0eQFcYj8TmoxPP0W7/I7b+3KWwKUpg3+CYqCpWk=; b=D5oXR5HEtwDtRmYkFidQ10ALvjqvXpww4w4OjH8ymySnCZb4y2UqoQYXalrtRatuG/onLxFGa5+akjCJjwsSjzTpQNIWK9ksKVW4EPtf/013VpPXq/aMjQGad37bGwgOZRqMbJaVEhktJB2MHOTkZmkev8iX2pr+xrlcvlaeJew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583253390175691.7710057229464; Tue, 3 Mar 2020 08:36:30 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-c0CIqPjRNT2zW9ya3y5dXw-1; Tue, 03 Mar 2020 11:36:26 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2EE199B58A; Tue, 3 Mar 2020 16:36:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0125560BF3; Tue, 3 Mar 2020 16:36:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8F42986A28; Tue, 3 Mar 2020 16:36:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 023GZHKC001347 for ; Tue, 3 Mar 2020 11:35:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id D2225272CC; Tue, 3 Mar 2020 16:35:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C947719C4F; Tue, 3 Mar 2020 16:35:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 08DF611329BF; Tue, 3 Mar 2020 17:35:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583253389; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DolF0eQFcYj8TmoxPP0W7/I7b+3KWwKUpg3+CYqCpWk=; b=BUvi0hKkQEyndkwG5Jhlh30mEVXzQtEAs0gUaHA3QwLOxK3l46w7ZGTIOAyuQxx9zwjjPI chREz1dVEBQ8ualcmqYuNaFJJ/JrkFtLLvjErD3VvEYhGKWskROO9Q8OPJ7H7zP9zepg/X 6IvsBquKqVDXNlo5kYxhaCusIv50QLY= X-MC-Unique: c0CIqPjRNT2zW9ya3y5dXw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 23/30] qapi: Simplify how qmp_dispatch() gets the request ID Date: Tue, 3 Mar 2020 17:34:58 +0100 Message-Id: <20200303163505.32041-24-armbru@redhat.com> In-Reply-To: <20200303163505.32041-1-armbru@redhat.com> References: <20200303163505.32041-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We convert the request object to a QDict twice: first in qmp_dispatch() to get the request ID, and then again in qmp_dispatch_check_obj(), which converts to QDict, then checks and returns it. We can't get the request ID from the latter, because it's null when the qdict flunks the checks. Move getting the request ID into qmp_dispatch_check_obj(). Signed-off-by: Markus Armbruster --- qapi/qmp-dispatch.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 550d1fe8d2..112d29a9ab 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -20,7 +20,7 @@ #include "qapi/qmp/qbool.h" =20 static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oo= b, - Error **errp) + QObject **id, Error **errp) { const char *exec_key =3D NULL; const QDictEntry *ent; @@ -30,10 +30,13 @@ static QDict *qmp_dispatch_check_obj(const QObject *req= uest, bool allow_oob, =20 dict =3D qobject_to(QDict, request); if (!dict) { + *id =3D NULL; error_setg(errp, "QMP input must be a JSON object"); return NULL; } =20 + *id =3D qdict_get(dict, "id"); + for (ent =3D qdict_first(dict); ent; ent =3D qdict_next(dict, ent)) { arg_name =3D qdict_entry_key(ent); @@ -103,12 +106,12 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *re= quest, const char *command; QDict *args; QmpCommand *cmd; - QDict *dict =3D qobject_to(QDict, request); - QObject *id =3D dict ? qdict_get(dict, "id") : NULL; + QDict *dict; + QObject *id; QObject *ret =3D NULL; QDict *rsp =3D NULL; =20 - dict =3D qmp_dispatch_check_obj(request, allow_oob, &err); + dict =3D qmp_dispatch_check_obj(request, allow_oob, &id, &err); if (!dict) { goto out; } --=20 2.21.1