From nobody Mon Feb 9 12:26:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1571920629; cv=none; d=zoho.com; s=zohoarc; b=LQ6fr6zQONNPYEqI65Op6D+cIPchcKeh/MhjW0JeZze9NHO17q6Q7/YhXrxo6iaT1Ia7PgSZ/avn2dv0o2eO+tdsqqzdHVahiPeFwmnoFXipy212uBW3Jx0CI4wZY9egVnzsw3CqmbKRvaD8EWJsLR7SHwvxUCdm9x3TGXUfkUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571920629; 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=QfWhCwcuiYkNb11FtX/FzN/pr1AfKjeQ1vIewiT9ZaQ=; b=fJkBZRjq597GMg2+eGUiyrYTdyK3XZENszvpeU9mWfZhBK9qZfbJV5lHomjbyFm8ST1HzmBXM4b15PUhKREOUTvOmwSQ8PfiXZtra4bElOw5pNiRheXmbOC1y3dzdkMP6NSYoL+UjWO3yh8rm1jjqUvYGHBpHWmT/KgOD1lvAqI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571920629801152.39761451492518; Thu, 24 Oct 2019 05:37:09 -0700 (PDT) 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-378-90ZxMfb9NKS9UkWOjmCRZA-1; Thu, 24 Oct 2019 08:35:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B25D35FD; Thu, 24 Oct 2019 12:35:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85B0C6062E; Thu, 24 Oct 2019 12:35:42 +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 3C04C180BAA8; Thu, 24 Oct 2019 12:35:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9OCZ9nR004505 for ; Thu, 24 Oct 2019 08:35:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC2DB6012D; Thu, 24 Oct 2019 12:35:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.36.118.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AA3F600CC; Thu, 24 Oct 2019 12:35:06 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1E60B113294D; Thu, 24 Oct 2019 14:34:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571920628; 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=QfWhCwcuiYkNb11FtX/FzN/pr1AfKjeQ1vIewiT9ZaQ=; b=iJipu6xCkFDINQfxPKKjwhhhoTEwx9AH/iTBieVq54DFs4orjo4d7an9fuKvnU+u0PyOmy gGCDodiaN2Ds4jTfmnwG+X1NeuyGyhdimGekO/aBVPEkwmZ92kKdLDzaMvFtQJQuKHdxVy f4Bq3WvGEr8SzyLwEauoBgOgGu75VCo= From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 24 Oct 2019 14:34:50 +0200 Message-Id: <20191024123458.13505-12-armbru@redhat.com> In-Reply-To: <20191024123458.13505-1-armbru@redhat.com> References: <20191024123458.13505-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com Subject: [libvirt] [RFC PATCH 11/19] qapi: Simplify how qmp_dispatch() gets the request ID 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.13 X-MC-Unique: 90ZxMfb9NKS9UkWOjmCRZA-1 X-Mimecast-Spam-Score: 0 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 d1643fe37a..0cbb663097 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; =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.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list